mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-05 17:44:17 +05:00
export the brep + create the file on the client side
This commit is contained in:
parent
587e24773a
commit
15854f5a98
@ -4013,25 +4013,25 @@ module GEOM
|
||||
{
|
||||
/*!
|
||||
* Export a shape to XAO Format
|
||||
* \param fileName The name of the exported file
|
||||
* \param shape The shape to export
|
||||
* \param groups The list of groups to export
|
||||
* \param fields The list of fields to export
|
||||
* \param xao The exported XAO
|
||||
* \return boolean indicating if export was succeful.
|
||||
*/
|
||||
|
||||
boolean ExportXAO(in string fileName, in GEOM_Object shape, in ListOfGO groups, in ListOfGO fields);
|
||||
boolean ExportXAO(in GEOM_Object shape, in ListOfGO groups, in ListOfGO fields, out string xao);
|
||||
|
||||
/*!
|
||||
* Import a shape from XAO Format
|
||||
* \param fileName The name of the imported file
|
||||
* \param xao The XAO data to import
|
||||
* \param shape The imported shape
|
||||
* \param groups The list of imported groups
|
||||
* \param fields The list of imported fields
|
||||
* \return boolean indicating if import was succeful.
|
||||
*/
|
||||
|
||||
//boolean ImportXAO(in string fileName, out GEOM_Object shape, out ListOfGO groups, out ListOfGO fields);
|
||||
//boolean ImportXAO(in string xao, out GEOM_Object shape, out ListOfGO groups, out ListOfGO fields);
|
||||
|
||||
/*@@ insert new functions before this line @@ do not remove this line @@*/
|
||||
};
|
||||
|
@ -626,8 +626,8 @@ module GEOM
|
||||
//-----------------------------------------------------------//
|
||||
// ImportExportOperations //
|
||||
//-----------------------------------------------------------//
|
||||
boolean ExportXAO(in string fileName, in GEOM_Object exportingShape,
|
||||
in GEOM_List groups, in GEOM_List fields);
|
||||
boolean ExportXAO(in GEOM_Object exportingShape,
|
||||
in GEOM_List groups, in GEOM_List fields, out string xao);
|
||||
// boolean ImportXAO(in string fileName, out GEOM_Object exportingShape,
|
||||
// out GEOM_List groups, out GEOM_List fields);
|
||||
|
||||
|
@ -4888,10 +4888,18 @@ be specified in meters).</translation>
|
||||
<source>GEOM_IMPORTEXPORT_204</source>
|
||||
<translation>Export XAO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_SELECT_EXPORT_XAO</source>
|
||||
<translation>Export to XAO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>XAO_FILES</source>
|
||||
<translation>XAO files (*.xao)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOOLS_IMPORTEXPORT</source>
|
||||
<translation>Import / Export</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BasicGUI_CurveDlg</name>
|
||||
|
@ -4887,11 +4887,18 @@ le paramètre '%1' aux préférences du module Géométrie.</translati
|
||||
<source>GEOM_IMPORTEXPORT_204</source>
|
||||
<translation>Export XAO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_SELECT_EXPORT_XAO</source>
|
||||
<translation>Export XAO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>XAO_FILES</source>
|
||||
<translation>Fichiers XAO (*.xao)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<message>
|
||||
<source>TOOLS_IMPORTEXPORT</source>
|
||||
<translation>Import / Export</translation>
|
||||
</message></context>
|
||||
<context>
|
||||
<name>BasicGUI_CurveDlg</name>
|
||||
<message>
|
||||
|
@ -111,17 +111,17 @@ GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations()
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Export a shape to XAO Format
|
||||
* \param fileName The name of the exported file
|
||||
* \param shape The shape to export
|
||||
* \param groups The list of groups to export
|
||||
* \param fields The list of fields to export
|
||||
* \param xao The exported XAO.
|
||||
* \return boolean indicating if export was succeful.
|
||||
*/
|
||||
//=============================================================================
|
||||
bool GEOMImpl_IImportExportOperations::ExportXAO(const std::string fileName,
|
||||
Handle(GEOM_Object) shape,
|
||||
bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
|
||||
std::list<Handle(GEOM_Object)> groupList,
|
||||
std::list<Handle(GEOM_Object)> fieldList)
|
||||
std::list<Handle(GEOM_Object)> fieldList,
|
||||
char*& xao)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
@ -245,27 +245,32 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(const std::string fileName,
|
||||
xaoObject->addGroup(group);
|
||||
}
|
||||
|
||||
xaoObject->exportToFile(fileName.c_str());
|
||||
const char* data = xaoObject->getXML();
|
||||
xao = new char[strlen(data)];
|
||||
strcpy(xao, data);
|
||||
delete data;
|
||||
|
||||
// make a Python command
|
||||
/*TCollection_AsciiString fileNameStr = fileName.c_str();
|
||||
GEOM::TPythonDump pd(exportFunction);
|
||||
std::list<Handle(GEOM_Object)>::iterator itG = groupList.begin();
|
||||
std::list<Handle(GEOM_Object)>::iterator itF = fieldList.begin();
|
||||
//pd << /*isGood <<**" = geompy.ExportXAO(" << shape << ", " << fileNameStr.ToCString() << ", [";
|
||||
pd << "exported = geompy.ExportXAO(";
|
||||
|
||||
pd << (*itG++);
|
||||
while (itG != groupList.end())
|
||||
{
|
||||
pd << ", " << (*itG++);
|
||||
}
|
||||
pd << "], [";
|
||||
pd << (*itF++);
|
||||
while (itF != fieldList.end())
|
||||
{
|
||||
pd << ", " << (*itF++);
|
||||
}
|
||||
pd << "])";*/
|
||||
pd << shape << "shpae, [], [], xao";
|
||||
pd << ")";
|
||||
|
||||
// std::list<Handle(GEOM_Object)>::iterator itG = groupList.begin();
|
||||
// pd << (*itG++);
|
||||
// while (itG != groupList.end())
|
||||
// {
|
||||
// pd << ", " << (*itG++);
|
||||
// }
|
||||
// pd << "], [";
|
||||
// std::list<Handle(GEOM_Object)>::iterator itF = fieldList.begin();
|
||||
// pd << (*itF++);
|
||||
// while (itF != fieldList.end())
|
||||
// {
|
||||
// pd << ", " << (*itF++);
|
||||
// }
|
||||
// pd << "])";
|
||||
|
||||
SetErrorCode(OK);
|
||||
|
||||
|
@ -44,10 +44,10 @@ public:
|
||||
Standard_EXPORT GEOMImpl_IImportExportOperations(GEOM_Engine* engine, int docID);
|
||||
Standard_EXPORT ~GEOMImpl_IImportExportOperations();
|
||||
|
||||
Standard_EXPORT bool ExportXAO (const std::string fileName,
|
||||
Handle(GEOM_Object) shape,
|
||||
Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape,
|
||||
std::list<Handle(GEOM_Object)> groupList,
|
||||
std::list<Handle(GEOM_Object)> fieldList);
|
||||
std::list<Handle(GEOM_Object)> fieldList,
|
||||
char*& xao);
|
||||
// Standard_EXPORT bool ImportXAO (const std::string fileName,
|
||||
// Handle(GEOM_Object) shape,
|
||||
// std::list<Handle(GEOM_Object)> groupList,
|
||||
|
@ -64,17 +64,17 @@ GEOM_IImportExportOperations_i::~GEOM_IImportExportOperations_i()
|
||||
* \return boolean indicating if export was succeful.
|
||||
*/
|
||||
//=============================================================================
|
||||
CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(const char* fileName,
|
||||
GEOM::GEOM_Object_ptr shape, const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields)
|
||||
CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
|
||||
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields, CORBA::String_out xao)
|
||||
{
|
||||
bool isGood = false;
|
||||
//Set a not done flag
|
||||
// Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
// Get the reference shape
|
||||
Handle(GEOM_Object) reference = GetObjectImpl(shape);
|
||||
|
||||
//Get the reference groups
|
||||
// Get the reference groups
|
||||
int ind = 0;
|
||||
std::list<Handle(GEOM_Object)> groupsObj;
|
||||
for (; ind < groups.length(); ind++)
|
||||
@ -84,7 +84,7 @@ CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(const char* fileName,
|
||||
groupsObj.push_back(gobj);
|
||||
}
|
||||
|
||||
//Get the reference point
|
||||
// Get the reference fields
|
||||
ind = 0;
|
||||
std::list<Handle(GEOM_Object)> fieldsObj;
|
||||
for (; ind < fields.length(); ind++)
|
||||
@ -97,7 +97,10 @@ CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(const char* fileName,
|
||||
if (!reference.IsNull())
|
||||
{
|
||||
// Export XAO
|
||||
isGood = GetOperations()->ExportXAO(fileName, reference, groupsObj, fieldsObj);
|
||||
char* data;
|
||||
isGood = GetOperations()->ExportXAO(reference, groupsObj, fieldsObj, data);
|
||||
xao = CORBA::string_dup(data);
|
||||
delete data;
|
||||
}
|
||||
|
||||
return isGood;
|
||||
@ -106,14 +109,14 @@ CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(const char* fileName,
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Import a shape from XAO Format
|
||||
* \param fileName The name of the imported file
|
||||
* \param xao The XAO data to import
|
||||
* \param shape The imported shape
|
||||
* \param groups The list of imported groups
|
||||
* \param fields The list of imported fields
|
||||
* \return boolean indicating if import was succeful.
|
||||
*/
|
||||
//=============================================================================
|
||||
//bool GEOMImpl_IImportExportOperations::ImportXAO(const std::string fileName,
|
||||
//bool GEOMImpl_IImportExportOperations::ImportXAO(const std::xao fileName,
|
||||
// Handle(GEOM_Object),
|
||||
// std::list<Handle_GEOM_Object, std::allocator<Handle_GEOM_Object> > groups,
|
||||
// std::list<Handle_GEOM_Object, std::allocator<Handle_GEOM_Object> > fields)
|
||||
|
@ -42,11 +42,11 @@ public:
|
||||
::GEOMImpl_IImportExportOperations* theImpl);
|
||||
~GEOM_IImportExportOperations_i();
|
||||
|
||||
CORBA::Boolean ExportXAO (const char* fileName,
|
||||
GEOM::GEOM_Object_ptr shape,
|
||||
CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape,
|
||||
const GEOM::ListOfGO& groups,
|
||||
const GEOM::ListOfGO& fields);
|
||||
CORBA::Boolean ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape,
|
||||
const GEOM::ListOfGO& fields,
|
||||
CORBA::String_out xao);
|
||||
CORBA::Boolean ImportXAO (const char* xao, GEOM::GEOM_Object_out shape,
|
||||
GEOM::ListOfGO_out groups,
|
||||
GEOM::ListOfGO_out fields);
|
||||
/*@@ insert new functions before this line @@ do not remove this line @@*/
|
||||
|
@ -3451,8 +3451,8 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDividedCylinder (CORBA::Double theR,
|
||||
//=============================================================================
|
||||
// ExportXAO
|
||||
//=============================================================================
|
||||
CORBA::Boolean GEOM_Superv_i::ExportXAO (const char* fileName, GEOM::GEOM_Object_ptr shape,
|
||||
GEOM::GEOM_List_ptr groups, GEOM::GEOM_List_ptr fields)
|
||||
CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
|
||||
GEOM::GEOM_List_ptr groups, GEOM::GEOM_List_ptr fields, CORBA::String_out xao)
|
||||
{
|
||||
beginService( " GEOM_Superv_i::ExportXAO" );
|
||||
MESSAGE("GEOM_Superv_i::ExportXAO");
|
||||
@ -3463,7 +3463,7 @@ CORBA::Boolean GEOM_Superv_i::ExportXAO (const char* fileName, GEOM::GEOM_Object
|
||||
if (GEOM_List_i<GEOM::ListOfGO>* fieldList =
|
||||
dynamic_cast<GEOM_List_i<GEOM::ListOfGO>*>(GetServant(fields, myPOA).in()))
|
||||
{
|
||||
CORBA::Boolean isGood = myImportExportOp->ExportXAO(fileName, shape, groupList->GetList(), fieldList->GetList());
|
||||
CORBA::Boolean isGood = myImportExportOp->ExportXAO(shape, groupList->GetList(), fieldList->GetList(), xao);
|
||||
endService( " GEOM_Superv_i::ExportXAO" );
|
||||
return isGood;
|
||||
}
|
||||
|
@ -715,8 +715,8 @@ public:
|
||||
//-----------------------------------------------------------//
|
||||
// ImportExport Operations //
|
||||
//-----------------------------------------------------------//
|
||||
CORBA::Boolean ExportXAO(const char* fileName,
|
||||
GEOM::GEOM_Object_ptr shape, GEOM::GEOM_List_ptr groups, GEOM::GEOM_List_ptr fields);
|
||||
CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape,
|
||||
GEOM::GEOM_List_ptr groups, GEOM::GEOM_List_ptr fields, CORBA::String_out xao);
|
||||
// CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape,
|
||||
// GEOM::GEOM_List_out groups, GEOM::GEOM_List_out fields);
|
||||
/*@@ insert new functions before this line @@ do not remove this line @@*/
|
||||
|
@ -273,7 +273,8 @@ void ImportExportGUI_ExportXAODlg::SetEditCurrentArgument()
|
||||
//=================================================================================
|
||||
void ImportExportGUI_ExportXAODlg::btnFileSelectClicked()
|
||||
{
|
||||
QString selFile = QFileDialog::getSaveFileName(this, tr("GEOM_SELECT_XAO"), QString(), tr("XAO_FILES"));
|
||||
QString selFile = QFileDialog::getSaveFileName(this, tr("GEOM_SELECT_EXPORT_XAO"),
|
||||
QString(), tr("XAO_FILES"));
|
||||
if (!selFile.isEmpty())
|
||||
{
|
||||
ledFileName->setText(selFile);
|
||||
@ -338,15 +339,15 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
|
||||
GEOM::ListOfGO_var groups = new GEOM::ListOfGO();
|
||||
groups->length(selGroups.count());
|
||||
int i = 0;
|
||||
for (QList<QListWidgetItem*>::iterator it = selGroups.begin(); it != selGroups.end(); ++it)
|
||||
{
|
||||
QListWidgetItem* item = (*it);
|
||||
int index = item->data(Qt::UserRole).toInt();
|
||||
groups[i++] = m_groups[index].copy();
|
||||
}
|
||||
for (QList<QListWidgetItem*>::iterator it = selGroups.begin(); it != selGroups.end(); ++it)
|
||||
{
|
||||
QListWidgetItem* item = (*it);
|
||||
int index = item->data(Qt::UserRole).toInt();
|
||||
groups[i++] = m_groups[index].copy();
|
||||
}
|
||||
|
||||
// get selected fields
|
||||
QList<QListWidgetItem*> selFields = lstFields->selectedItems();
|
||||
// get selected fields
|
||||
QList<QListWidgetItem*> selFields = lstFields->selectedItems();
|
||||
GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
|
||||
fields->length(m_fields.count());
|
||||
for (QList<QListWidgetItem*>::iterator it = selFields.begin(); it != selFields.end(); ++it)
|
||||
@ -358,8 +359,15 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
|
||||
|
||||
// call engine function
|
||||
GEOM::GEOM_IImportExportOperations_var ieOp = GEOM::GEOM_IImportExportOperations::_narrow(getOperation());
|
||||
res = ieOp->ExportXAO(ledFileName->text().toStdString().c_str(),
|
||||
m_mainObj, groups, fields);
|
||||
char* xao;
|
||||
res = ieOp->ExportXAO(m_mainObj, groups, fields, xao);
|
||||
|
||||
// dump xao to file
|
||||
ofstream exportFile;
|
||||
exportFile.open(ledFileName->text().toStdString().c_str());
|
||||
exportFile << xao;
|
||||
exportFile.close();
|
||||
delete xao;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ Geometry::~Geometry()
|
||||
{
|
||||
}
|
||||
|
||||
void Geometry::setShape(TopoDS_Shape shape)
|
||||
void Geometry::setShape(const TopoDS_Shape& shape)
|
||||
{
|
||||
m_shape = shape;
|
||||
|
||||
@ -82,7 +82,10 @@ const char* Geometry::getBREP()
|
||||
{
|
||||
std::ostringstream streamShape;
|
||||
BRepTools::Write(m_shape, streamShape);
|
||||
return streamShape.str().c_str();
|
||||
std::string data = streamShape.str();
|
||||
char* res = new char[data.size()];
|
||||
strcpy(res, data.c_str());
|
||||
return res;
|
||||
}
|
||||
|
||||
void Geometry::initListIds(const Standard_Integer shapeType)
|
||||
|
@ -58,7 +58,7 @@ namespace XAO
|
||||
{
|
||||
return m_shape;
|
||||
}
|
||||
void setShape(TopoDS_Shape shape);
|
||||
void setShape(const TopoDS_Shape& shape);
|
||||
|
||||
const char* getBREP();
|
||||
void setShape(const char* brep);
|
||||
|
Loading…
Reference in New Issue
Block a user