import and export XAO with Fields

This commit is contained in:
fps 2013-11-12 16:32:55 +00:00
parent 1ccc5a5f3f
commit 6f7151b5d7
14 changed files with 367 additions and 106 deletions

View File

@ -3743,7 +3743,7 @@ module GEOM
* \return boolean indicating if export was successful.
*/
boolean ExportXAO(in GEOM_Object shape,
in ListOfGO groups, in ListOfGO fields,
in ListOfGO groups, in ListOfFields fields,
in string author, in string fileName);
/*!
@ -3756,7 +3756,7 @@ module GEOM
* \return boolean indicating if import was successful.
*/
boolean ImportXAO(in string fileName, out GEOM_Object shape,
out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
};
// # GEOM_IKindOfShape:

View File

@ -269,10 +269,10 @@ module GEOM
void ExportTranslators (out string_array theFormats,
out string_array thePatterns) ;
boolean ExportXAO(in GEOM_Object shape,
in ListOfGO groups, in ListOfGO fields,
in string author, in string fileName);
in ListOfGO groups, in ListOfFields fields,
in string author, in string fileName);
boolean ImportXAO(in string fileName, out GEOM_Object shape,
out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
//-----------------------------------------------------------//
// TransformOperations //

View File

@ -216,6 +216,7 @@ namespace GEOM
};
typedef GenericObjPtr<GEOM::GEOM_Object> GeomObjPtr;
typedef GenericObjPtr<GEOM::GEOM_Field> GeomFieldPtr;
typedef GenericObjPtr<GEOM::GEOM_IBasicOperations> BasicOpPtr;
typedef GenericObjPtr<GEOM::GEOM_ITransformOperations> TransformOpPtr;
typedef GenericObjPtr<GEOM::GEOM_I3DPrimOperations> I3DPrimOpPtr;

View File

@ -32,6 +32,7 @@
#include <GEOMImpl_Types.hxx>
#include "GEOMImpl_IShapesOperations.hxx"
#include "GEOMImpl_IGroupOperations.hxx"
#include "GEOMImpl_IFieldOperations.hxx"
#include "GEOMImpl_XAODriver.hxx"
#include "GEOMImpl_IImportExportXAO.hxx"
@ -45,6 +46,14 @@
#include <XAO_Group.hxx>
#include <XAO_Field.hxx>
#include <XAO_XaoUtils.hxx>
#include <XAO_BooleanField.hxx>
#include <XAO_IntegerField.hxx>
#include <XAO_DoubleField.hxx>
#include <XAO_StringField.hxx>
#include <XAO_BooleanStep.hxx>
#include <XAO_IntegerStep.hxx>
#include <XAO_DoubleStep.hxx>
#include <XAO_StringStep.hxx>
#include <Basics_OCCTVersion.hxx>
@ -67,6 +76,7 @@
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
#include <TColStd_HArray1OfByte.hxx>
#include <TColStd_HArray1OfReal.hxx>
#else
#include <TDataStd_HArray1OfByte.hxx>
#endif
@ -100,6 +110,7 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
myFieldOperations = new GEOMImpl_IFieldOperations(GetEngine(), GetDocID());
}
//=============================================================================
@ -112,6 +123,7 @@ GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
delete myShapesOperations;
delete myGroupOperations;
delete myFieldOperations;
}
//=============================================================================
@ -837,7 +849,9 @@ XAO::Dimension shapeEnumToDimension(const TopAbs_ShapeEnum& shape)
return dim;
}
void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList,
XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry)
{
// add the groups
std::list<Handle(GEOM_Object)>::iterator groupIterator = groupList.begin();
@ -855,42 +869,129 @@ void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> gro
case TopAbs_VERTEX:
for (int i = 1; i <= groupIds->Length(); i++)
{
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getVertexIndexByReference(ref);
group->add(index);
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getVertexIndexByReference(ref);
group->add(index);
}
break;
case TopAbs_EDGE:
for (int i = 1; i <= groupIds->Length(); i++)
{
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getEdgeIndexByReference(ref);
group->add(index);
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getEdgeIndexByReference(ref);
group->add(index);
}
break;
case TopAbs_FACE:
for (int i = 1; i <= groupIds->Length(); i++)
{
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getFaceIndexByReference(ref);
group->add(index);
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getFaceIndexByReference(ref);
group->add(index);
}
break;
case TopAbs_SOLID:
for (int i = 1; i <= groupIds->Length(); i++)
{
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getSolidIndexByReference(ref);
group->add(index);
std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
int index = geometry->getSolidIndexByReference(ref);
group->add(index);
}
break;
}
}
}
void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Field)> fieldList,
XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry)
{
// TODO
std::list<Handle(GEOM_Field)>::iterator fieldIterator = fieldList.begin();
while (fieldIterator != fieldList.end())
{
Handle(GEOM_Field) currField = (*fieldIterator++);
int fdim = currField->GetDimension();
int ftype = currField->GetDataType();
int nbComponents = currField->GetNbComponents();
std::string name = currField->GetName().ToCString();
XAO::Field* field = xaoObject->addField((XAO::Type)ftype, (XAO::Dimension)fdim, nbComponents, name);
Handle(TColStd_HArray1OfExtendedString) components = currField->GetComponents();
std::cout << "nb comp " << nbComponents << std::endl;
std::cout << components->Lower() << " - " << components->Upper() << std::endl;
for (int i = components->Lower(), j = 0; i <= components->Upper(); ++i, ++j)
{
field->setComponentName(j, TCollection_AsciiString(components->Value(i)).ToCString());
}
std::list< Handle(GEOM_FieldStep)> steps = currField->GetSteps();
std::list<Handle(GEOM_FieldStep)>::iterator stepIterator = steps.begin();
while (stepIterator != steps.end())
{
Handle(GEOM_FieldStep) currStep = (*stepIterator++);
XAO::Step* step = field->addNewStep(currStep->GetID());
step->setStamp(currStep->GetStamp());
switch (ftype)
{
case 0: // bool
{
XAO::BooleanStep* bs = (XAO::BooleanStep*)step;
Handle(TColStd_HArray1OfInteger) bvalues = currStep->GetIntValues();
std::vector<bool> bv;
bv.reserve(bvalues->Upper());
for ( int i = bvalues->Lower(), nb = bvalues->Upper(); i <= nb; ++i )
{
bv.push_back(bvalues->Value(i) != 0);
}
bs->setValues(bv);
break;
}
case 1: // integer
{
XAO::IntegerStep* is = (XAO::IntegerStep*)step;
Handle(TColStd_HArray1OfInteger) ivalues = currStep->GetIntValues();
std::vector<int> iv;
iv.reserve(ivalues->Upper());
for ( int i = ivalues->Lower(), nb = ivalues->Upper(); i <= nb; ++i )
{
iv.push_back(ivalues->Value(i));
}
is->setValues(iv);
break;
}
case 2: // double
{
XAO::DoubleStep* ds = (XAO::DoubleStep*)step;
Handle(TColStd_HArray1OfReal) dvalues = currStep->GetDoubleValues();
std::vector<double> dv;
dv.reserve(dvalues->Upper());
for ( int i = dvalues->Lower(), nb = dvalues->Upper(); i <= nb; ++i )
{
dv.push_back(dvalues->Value(i));
}
ds->setValues(dv);
break;
}
case 3: // string
{
XAO::StringStep* ss = (XAO::StringStep*)step;
Handle(TColStd_HArray1OfExtendedString) svalues = currStep->GetStringValues();
std::vector<std::string> sv;
sv.reserve(svalues->Upper());
for ( int i = svalues->Lower(), nb = svalues->Upper(); i <= nb; ++i )
{
sv.push_back(TCollection_AsciiString(svalues->Value(i)).ToCString());
}
ss->setValues(sv);
break;
}
}
}
}
}
void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry)
@ -911,17 +1012,17 @@ void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shap
switch (subObject->GetValue().ShapeType())
{
case TopAbs_VERTEX:
geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
break;
geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
break;
case TopAbs_EDGE:
geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
break;
geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
break;
case TopAbs_FACE:
geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
break;
geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
break;
case TopAbs_SOLID:
geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
break;
geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
break;
}
}
}
@ -938,10 +1039,10 @@ void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shap
*/
//=============================================================================
bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
std::list<Handle(GEOM_Object)> groupList,
std::list<Handle(GEOM_Object)> fieldList,
const char* author,
const char* fileName)
std::list<Handle(GEOM_Object)> groupList,
std::list<Handle(GEOM_Field)> fieldList,
const char* author,
const char* fileName)
{
SetErrorCode(KO);
@ -1000,7 +1101,7 @@ bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
pd << "], [";
if (fieldList.size() > 0)
{
std::list<Handle(GEOM_Object)>::iterator itField = fieldList.begin();
std::list<Handle(GEOM_Field)>::iterator itField = fieldList.begin();
pd << (*itField++);
while (itField != fieldList.end())
{
@ -1017,8 +1118,8 @@ bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
}
void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry,
Handle(GEOM_Function) function, int shapeType, int dim,
Handle(TColStd_HSequenceOfTransient)& subShapeList)
Handle(GEOM_Function) function, int shapeType, int dim,
Handle(TColStd_HSequenceOfTransient)& subShapeList)
{
Handle(GEOM_Object) subShape;
Handle(GEOM_Function) aFunction;
@ -1070,10 +1171,10 @@ void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry,
*/
//=============================================================================
bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
Handle(GEOM_Object)& shape,
Handle(TColStd_HSequenceOfTransient)& subShapes,
Handle(TColStd_HSequenceOfTransient)& groups,
Handle(TColStd_HSequenceOfTransient)& fields)
Handle(GEOM_Object)& shape,
Handle(TColStd_HSequenceOfTransient)& subShapes,
Handle(TColStd_HSequenceOfTransient)& groups,
Handle(TColStd_HSequenceOfTransient)& fields)
{
SetErrorCode(KO);
@ -1158,7 +1259,102 @@ bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
function = group->GetLastFunction();
}
// TODO: create the fields
// create the fields
int nbFields = xaoObject->countFields();
for (int i = 0; i < nbFields; ++i)
{
XAO::Field* xaoField = xaoObject->getField(i);
Handle(TColStd_HArray1OfExtendedString) components = new TColStd_HArray1OfExtendedString(0, xaoField->countComponents());
for (int j = 0; j < xaoField->countComponents(); ++j)
{
components->SetValue(j, (TCollection_ExtendedString)xaoField->getComponentName(j).c_str());
}
Handle(GEOM_Field) field = myFieldOperations->CreateField(shape,
xaoField->getName().c_str(),
(int)xaoField->getType(),
(int)xaoField->getDimension(),
components);
switch (xaoField->getType())
{
case XAO::BOOLEAN:
{
XAO::BooleanField* bfield = (XAO::BooleanField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::BooleanStep* bstep = bfield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(bstep->getStep(), bstep->getStamp());
Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, bstep->countValues());
std::vector<bool> bvalues = bstep->getValues();
for (int k = 0; k < bstep->countValues(); ++k)
{
values->SetValue(0, bvalues[k] ? 1 : 0);
}
step->SetValues(values);
}
break;
}
case XAO::INTEGER:
{
XAO::IntegerField* ifield = (XAO::IntegerField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::IntegerStep* istep = ifield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(istep->getStep(), istep->getStamp());
Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, istep->countValues());
std::vector<int> ivalues = istep->getValues();
for (int k = 0; k < istep->countValues(); ++k)
{
values->SetValue(0, ivalues[k]);
}
step->SetValues(values);
}
break;
}
case XAO::DOUBLE:
{
XAO::DoubleField* dfield = (XAO::DoubleField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::DoubleStep* dstep = dfield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(dstep->getStep(), dstep->getStamp());
Handle(TColStd_HArray1OfReal) values = new TColStd_HArray1OfReal(0, dstep->countValues());
std::vector<double> dvalues = dstep->getValues();
for (int k = 0; k < dstep->countValues(); ++k)
{
values->SetValue(0, dvalues[k]);
}
step->SetValues(values);
}
break;
}
case XAO::STRING:
{
XAO::StringField* sfield = (XAO::StringField*)xaoField;
for (int j = 0; j < xaoField->countSteps(); ++j)
{
XAO::StringStep* sstep = sfield->getStep(j);
Handle(GEOM_FieldStep) step = field->AddStep(sstep->getStep(), sstep->getStamp());
Handle(TColStd_HArray1OfExtendedString) values = new TColStd_HArray1OfExtendedString(0, sstep->countValues());
std::vector<std::string> svalues = sstep->getValues();
for (int k = 0; k < sstep->countValues(); ++k)
{
values->SetValue(0, TCollection_ExtendedString(svalues[k].c_str()));
}
step->SetValues(values);
}
break;
}
}
fields->Append(field);
}
// make a Python command
GEOM::TPythonDump pd(function);

View File

@ -26,6 +26,7 @@
#include "GEOM_IOperations.hxx"
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
#include "GEOM_Field.hxx"
#include <Basics_OCCTVersion.hxx>
@ -40,6 +41,7 @@
class GEOMImpl_IShapesOperations;
class GEOMImpl_IGroupOperations;
class GEOMImpl_IFieldOperations;
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
class Handle_TColStd_HArray1OfByte;
@ -103,34 +105,35 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Standard_EXPORT std::list<int> GetAllTextures();
Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape,
std::list<Handle(GEOM_Object)> groupList,
std::list<Handle(GEOM_Object)> fieldList,
const char* author,
const char* fileName);
std::list<Handle(GEOM_Object)> groupList,
std::list<Handle(GEOM_Field)> fieldList,
const char* author,
const char* fileName);
Standard_EXPORT bool ImportXAO(const char* fileName,
Handle(GEOM_Object)& shape,
Handle(TColStd_HSequenceOfTransient)& subShapes,
Handle(TColStd_HSequenceOfTransient)& groups,
Handle(TColStd_HSequenceOfTransient)& fields);
Handle(GEOM_Object)& shape,
Handle(TColStd_HSequenceOfTransient)& subShapes,
Handle(TColStd_HSequenceOfTransient)& groups,
Handle(TColStd_HSequenceOfTransient)& fields);
private:
Standard_Boolean InitResMgr ();
void importSubShapes(XAO::Geometry* xaoGeometry, Handle(GEOM_Function) function,
int shapeType, int dim,
Handle(TColStd_HSequenceOfTransient)& subshapeList);
int shapeType, int dim,
Handle(TColStd_HSequenceOfTransient)& subshapeList);
void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry);
void exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry);
void exportFields(std::list<Handle(GEOM_Field)> fieldList, XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry);
void exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject,
XAO::BrepGeometry* geometry);
XAO::BrepGeometry* geometry);
private:
Handle(Resource_Manager) myResMgr;
Handle(Resource_Manager) myResMgrUser;
GEOMImpl_IShapesOperations* myShapesOperations;
GEOMImpl_IGroupOperations* myGroupOperations;
GEOMImpl_IFieldOperations* myFieldOperations;
};
#endif

View File

@ -373,8 +373,10 @@ GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
*/
//=============================================================================
CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
const char* author, const char* fileName)
const GEOM::ListOfGO& groups,
const GEOM::ListOfFields& fields,
const char* author,
const char* fileName)
{
bool isGood = false;
// Set a not done flag
@ -395,10 +397,10 @@ CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
// Get the reference fields
ind = 0;
std::list<Handle(GEOM_Object)> fieldsObj;
std::list<Handle(GEOM_Field)> fieldsObj;
for (; ind < fields.length(); ind++)
{
Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]);
Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind]));
if (fobj.IsNull()) return false;
fieldsObj.push_back(fobj);
}
@ -424,17 +426,17 @@ CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
*/
//=============================================================================
CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes,
GEOM::ListOfGO_out groups,
GEOM::ListOfGO_out fields)
GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes,
GEOM::ListOfGO_out groups,
GEOM::ListOfFields_out fields)
{
GEOM::GEOM_Object_var vshape;
shape = vshape._retn();
subShapes = new GEOM::ListOfGO;
groups = new GEOM::ListOfGO;
fields = new GEOM::ListOfGO;
fields = new GEOM::ListOfFields;
// Set a not done flag
GetOperations()->SetNotDone();
@ -469,7 +471,8 @@ CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
fields->length(n);
for (int i = 1; i <= n; i++)
{
(*fields)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedFields->Value(i)));
// TODO: FPS
//(*fields)[i - 1] = GetObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i)));
}
shape = GetObject(hshape);

View File

@ -74,16 +74,16 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
GEOM::ListOfLong* GetAllTextures();
CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups,
const GEOM::ListOfGO& fields,
const char* author,
const char* fileName);
const GEOM::ListOfGO& groups,
const GEOM::ListOfFields& fields,
const char* author,
const char* fileName);
CORBA::Boolean ImportXAO (const char* fileName,
GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes,
GEOM::ListOfGO_out groups,
GEOM::ListOfGO_out fields);
GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes,
GEOM::ListOfGO_out groups,
GEOM::ListOfFields_out fields);
::GEOMImpl_IInsertOperations* GetOperations()
{ return (::GEOMImpl_IInsertOperations*)GetImpl(); }

View File

@ -3332,7 +3332,7 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup)
// ExportXAO
//=============================================================================
CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
const char* author, const char* fileName)
{
beginService( " GEOM_Superv_i::ExportXAO" );
@ -3347,7 +3347,7 @@ CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
// ImportXAO
//=============================================================================
CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields)
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields)
{
return false;
}

View File

@ -692,10 +692,10 @@ public:
// ImportExport Operations //
//-----------------------------------------------------------//
CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape,
const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
const char* author, const char* fileName);
CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape,
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields);
GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields);
//-----------------------------------------------------------//
// Advanced Operations //

View File

@ -22,8 +22,10 @@
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_OverrideCursor.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Tools.h>
#include <LightApp_SelectionMgr.h>
#include <QLabel>
@ -32,7 +34,6 @@
#include <QListWidget>
#include <QFileDialog>
#include <QMap>
//#include <ui_ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
@ -43,7 +44,6 @@
#include <GEOMImpl_Types.hxx>
#include "ImportExportGUI_ExportXAODlg.h"
//#include "ImportExportGUI_Widgets.h"
//=================================================================================
// Constructor
@ -137,7 +137,7 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometry
lstGroups = new QListWidget(gbxFilter);
lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection);
lstFields = new QListWidget(gbxFilter);
lstFields ->setSelectionMode(QAbstractItemView::ExtendedSelection);
lstFields->setSelectionMode(QAbstractItemView::ExtendedSelection);
line++; col = 0;
gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1);
@ -184,7 +184,6 @@ void ImportExportGUI_ExportXAODlg::Init()
connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked()));
initName(tr("GEOM_EXPORTXAO"));
SelectionIntoArgument();
}
@ -217,11 +216,25 @@ void ImportExportGUI_ExportXAODlg::processObject()
item->setData(Qt::UserRole, QVariant(i));
item->setText(GEOMBase::GetName(groups[i]));
lstGroups->addItem(item);
item->setSelected(true);
m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
}
lstGroups->sortItems(Qt::AscendingOrder);
// TODO: add fields
// add fields
GEOM::GEOM_IFieldOperations_var fieldOp = getGeomEngine()->GetIFieldOperations(getStudyId());
GEOM::ListOfFields_var fields = fieldOp->GetFields(m_mainObj);
for (int i = 0, n = fields->length(); i < n; i++)
{
QListWidgetItem* item = new QListWidgetItem();
item->setData(Qt::UserRole, QVariant(i));
item->setText(fields[i]->GetName());
lstFields->addItem(item);
item->setSelected(true);
m_fields.append(GEOM::GeomFieldPtr(fields[i].in()));
}
lstFields->sortItems(Qt::AscendingOrder);
}
}
@ -231,8 +244,10 @@ void ImportExportGUI_ExportXAODlg::processObject()
//=================================================================================
void ImportExportGUI_ExportXAODlg::ClickOnOk()
{
setIsApplyAndClose(true);
if (ClickOnApply())
ClickOnCancel();
setIsApplyAndClose(false);
}
//=================================================================================
@ -241,10 +256,46 @@ void ImportExportGUI_ExportXAODlg::ClickOnOk()
//=================================================================================
bool ImportExportGUI_ExportXAODlg::ClickOnApply()
{
if (!onAccept())
return false;
if (!isApplyAndClose())
{
setIsDisableBrowsing(true);
setIsDisplayResult(false);
}
initName();
QString msg;
if (!isValid(msg))
{
showError(msg);
return false;
}
SUIT_OverrideCursor wc;
SUIT_Session::session()->activeApplication()->putInfo("");
try
{
if (openCommand())
if (!execute(/*isApplyAndClose()*/))
{
abortCommand();
showError();
return false;
}
}
catch (const SALOME::SALOME_Exception& e)
{
SalomeApp_Tools::QtCatchCorbaException(e);
abortCommand();
return false;
}
commitCommand();
if (!isApplyAndClose())
{
setIsDisableBrowsing(false);
setIsDisplayResult(true);
}
processObject();
return true;
}
@ -343,7 +394,7 @@ bool ImportExportGUI_ExportXAODlg::isValid(QString& msg)
// function : execute
// purpose :
//=================================================================================
bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
bool ImportExportGUI_ExportXAODlg::execute()
{
bool res = false;
@ -364,8 +415,9 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
// get selected fields
QList<QListWidgetItem*> selFields = lstFields->selectedItems();
GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
GEOM::ListOfFields_var fields = new GEOM::ListOfFields();
fields->length(m_fields.count());
i = 0;
for (QList<QListWidgetItem*>::iterator it = selFields.begin(); it != selFields.end(); ++it)
{
QListWidgetItem* item = (*it);
@ -376,8 +428,8 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
// call engine function
GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
res = ieOp->ExportXAO(m_mainObj, groups, fields,
author.toStdString().c_str(),
fileName.toStdString().c_str());
author.toStdString().c_str(),
fileName.toStdString().c_str());
return res;
}

View File

@ -44,7 +44,7 @@ protected:
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid(QString&);
virtual bool execute(ObjectList&);
virtual bool execute();
private:
void Init();
@ -54,7 +54,7 @@ private:
private:
GEOM::GEOM_Object_var m_mainObj;
QList<GEOM::GeomObjPtr> m_groups;
QList<GEOM::GeomObjPtr> m_fields;
QList<GEOM::GeomFieldPtr> m_fields;
QLineEdit* ledShape;
QLineEdit* ledFileName;
QLineEdit* ledAuthor;
@ -67,7 +67,6 @@ private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
// void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void btnFileSelectClicked();

View File

@ -156,7 +156,7 @@ bool ImportExportGUI_ImportXAODlg::ClickOnApply()
void ImportExportGUI_ImportXAODlg::btnFileSelectClicked()
{
QString selFile = QFileDialog::getOpenFileName(this, tr("GEOM_SELECT_EXPORT_XAO"),
QString(), tr("XAO_FILES"));
QString(), tr("XAO_FILES"));
if (!selFile.isEmpty())
{
ledFileName->setText(selFile);
@ -214,7 +214,8 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
QString fileName = ledFileName->text();
GEOM::GEOM_Object_var shape;
GEOM::ListOfGO_var groups, fields, subShapes;
GEOM::ListOfGO_var groups, subShapes;
GEOM::ListOfFields_var fields;
GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
res = ieOp->ImportXAO(fileName.toStdString().c_str(), shape, subShapes, groups, fields);
@ -239,7 +240,7 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects)
}
for (int i = 0; i < fields->length(); i++)
{
objects.push_back(GEOM::GEOM_Object::_duplicate(fields[i]));
//objects.push_back(GEOM::GEOM_Field::_duplicate(fields[i]));
}
return res;

View File

@ -67,6 +67,8 @@ throw (XAO_Exception)
return countFaces();
if (dim == XAO::SOLID)
return countSolids();
if (dim == XAO::WHOLE)
return 1;
throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
}

View File

@ -86,7 +86,7 @@ namespace {
xmlDocPtr exportXMLDoc(Xao* xaoObject);
void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao);
void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology,
XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
void exportGroups(Xao* xaoObject, xmlNodePtr xao);
void exportFields(Xao* xaoObject, xmlNodePtr xao);
void exportStep(Step* step, Field* field, xmlNodePtr nodeSteps);
@ -109,13 +109,13 @@ namespace {
void parseStepElementNode(xmlNodePtr eltNode, Step* step);
std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
const bool& required, const std::string& defaultValue,
const std::string& exception /*= std::string() */)
const bool& required, const std::string& defaultValue,
const std::string& exception /*= std::string() */)
{
xmlChar* strAttr = xmlGetProp(node, attribute);
if (strAttr == NULL)
@ -138,8 +138,8 @@ namespace {
}
int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
const bool& required, const int& defaultValue,
const std::string& exception /*= std::string() */)
const bool& required, const int& defaultValue,
const std::string& exception /*= std::string() */)
{
xmlChar* strAttr = xmlGetProp(node, attribute);
if (strAttr == NULL)
@ -183,7 +183,7 @@ namespace {
}
void exportGeometricElements(Geometry* xaoGeometry,
xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
{
xmlNodePtr vertices = xmlNewChild(topology, 0, colTag, 0);
xmlNewProp(vertices, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(xaoGeometry->countElements(dim)).c_str());
@ -592,12 +592,16 @@ namespace {
int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1);
xmlChar* data = xmlNodeGetContent(valNode->children);
if (data == NULL)
std::string value = (char*)data;
if (data != NULL)
{
value = (char*)data;
}
else if (step->getType() != XAO::STRING)
{
throw XAO_Exception(MsgBuilder() << "Line " << valNode->line << ": no content for value.");
}
std::string value = (char*)data;
step->setStringValue(index, component, value);
}
}