mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 07:00:34 +05:00
debug export XAO
This commit is contained in:
parent
37b0d2eb73
commit
c79ce12152
@ -4013,14 +4013,14 @@ module GEOM
|
||||
{
|
||||
/*!
|
||||
* Export a shape to XAO Format
|
||||
* \param theExportingShape Shape to export
|
||||
* \param theFileName The name of the exported file
|
||||
* \param thelGroups List of groups to export
|
||||
* \param thelFields List of fields to export
|
||||
* \return New GEOM_Object, containing the created shape.
|
||||
* \param exportingShape Shape to export
|
||||
* \param fileName The name of the exported file
|
||||
* \param groups List of groups to export
|
||||
* \param fields List of fields to export
|
||||
* \return boolean indicating if export was succeful.
|
||||
*/
|
||||
|
||||
boolean ExportXAO (in GEOM_Object theExportingShape, in string theFileName, in ListOfGO thelGroups, in ListOfGO thelFields);
|
||||
boolean ExportXAO(in GEOM_Object shape, in string fileName, in ListOfGO groups, in ListOfGO fields);
|
||||
|
||||
/*@@ insert new functions before this line @@ do not remove this line @@*/
|
||||
};
|
||||
|
@ -626,7 +626,7 @@ module GEOM
|
||||
//-----------------------------------------------------------//
|
||||
// ImportExportOperations //
|
||||
//-----------------------------------------------------------//
|
||||
boolean ExportXAO (in GEOM_Object theExportingShape, in string theFileName, in GEOM_List thelGroups, in GEOM_List thelFields);
|
||||
boolean ExportXAO(in GEOM_Object exportingShape, in string fileName, in GEOM_List groups, in GEOM_List fields);
|
||||
|
||||
/*@@ insert new functions before this line @@ do not remove this line @@*/
|
||||
};
|
||||
|
@ -92,14 +92,6 @@ GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations(GEOM_Engine*
|
||||
GEOM_IOperations(engine, docID)
|
||||
{
|
||||
MESSAGE("GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations");
|
||||
/*myBasicOperations = new GEOMImpl_IBasicOperations(GetEngine(), GetDocID());
|
||||
myBooleanOperations = new GEOMImpl_IBooleanOperations(GetEngine(), GetDocID());
|
||||
myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
|
||||
myTransformOperations = new GEOMImpl_ITransformOperations(GetEngine(), GetDocID());
|
||||
myBlocksOperations = new GEOMImpl_IBlocksOperations(GetEngine(), GetDocID());
|
||||
my3DPrimOperations = new GEOMImpl_I3DPrimOperations(GetEngine(), GetDocID());
|
||||
myLocalOperations = new GEOMImpl_ILocalOperations(GetEngine(), GetDocID());
|
||||
myHealingOperations = new GEOMImpl_IHealingOperations(GetEngine(), GetDocID());*/
|
||||
m_shapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
|
||||
m_groupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
|
||||
}
|
||||
@ -112,14 +104,6 @@ GEOMImpl_IImportExportOperations::GEOMImpl_IImportExportOperations(GEOM_Engine*
|
||||
GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations()
|
||||
{
|
||||
MESSAGE("GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations");
|
||||
/*delete myBasicOperations;
|
||||
delete myBooleanOperations;
|
||||
delete myShapesOperations;
|
||||
delete myTransformOperations;
|
||||
delete myBlocksOperations;
|
||||
delete my3DPrimOperations;
|
||||
delete myLocalOperations;
|
||||
delete myHealingOperations;*/
|
||||
delete m_shapesOperations;
|
||||
delete m_groupOperations;
|
||||
}
|
||||
@ -139,11 +123,7 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
|
||||
std::list<Handle(GEOM_Object)> groupList,
|
||||
std::list<Handle(GEOM_Object)> fieldList)
|
||||
{
|
||||
std::cout << ">> ExportXAO" << std::endl;
|
||||
SetErrorCode(KO);
|
||||
bool isGood = false;
|
||||
|
||||
//
|
||||
|
||||
// add a new shape function with parameters
|
||||
Handle(GEOM_Function) lastFunction = shape->GetLastFunction();
|
||||
@ -163,42 +143,17 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
|
||||
if (exportFunction->GetDriverGUID() != GEOMImpl_ExportXAODriver::GetID())
|
||||
return false;
|
||||
|
||||
/*GEOMImpl_IExportXAO aData (aRefFunction);
|
||||
|
||||
TCollection_AsciiString FileName = theFileName.c_str();
|
||||
aData.SetExportingShape(aRefFunction);
|
||||
aData.SetFileName(FileName);
|
||||
aData.SetlGroups(thelGroups);
|
||||
aData.SetlFields(thelFields);
|
||||
|
||||
//Compute the resulting value
|
||||
try {
|
||||
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
||||
OCC_CATCH_SIGNALS;
|
||||
#endif
|
||||
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||
SetErrorCode("ExportXAO driver failed : Not enough space on disk, or you haven't permissions to write this directory");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||
SetErrorCode(aFail->GetMessageString());
|
||||
return false;
|
||||
}*/
|
||||
XAO::Xao* xaoObject = new XAO::Xao();
|
||||
|
||||
XAO::Geometry* geometry = new XAO::Geometry();
|
||||
TopoDS_Shape topoShape = shape->GetValue();
|
||||
std::ostringstream dumpStream;
|
||||
BRepTools::Dump(topoShape, dumpStream);
|
||||
geometry->setShape(dumpStream.str().c_str());
|
||||
geometry->setShape(topoShape);
|
||||
geometry->setName(shape->GetName());
|
||||
|
||||
Handle(TColStd_HSequenceOfTransient) subObjects = m_shapesOperations->GetExistingSubObjects(shape, false);
|
||||
int nbSubObjects = subObjects->Length();
|
||||
std::cout << "nb sub obj = " << nbSubObjects << std::endl;
|
||||
int nbVertices = 0, nbEdges = 0, nbFaces = 0, nbSolids = 0, nbGroups = 0;
|
||||
|
||||
int tmpIndex;
|
||||
for (int i = 1; i <= nbSubObjects; i++)
|
||||
{
|
||||
Handle(Standard_Transient) transientSubObject = subObjects->Value(i);
|
||||
@ -206,109 +161,94 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
|
||||
continue;
|
||||
|
||||
Handle(GEOM_Object) subObject = Handle(GEOM_Object)::DownCast(transientSubObject);
|
||||
if (subObject->GetType() == GEOM_GROUP)
|
||||
{
|
||||
nbGroups++;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (subObject->GetValue().ShapeType())
|
||||
{
|
||||
case TopAbs_VERTEX: nbVertices++; break;
|
||||
case TopAbs_EDGE: nbEdges++; break;
|
||||
case TopAbs_FACE: nbFaces++; break;
|
||||
case TopAbs_SOLID: nbSolids++; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Nb = " << nbVertices << ", " << nbEdges << ", " << nbFaces << ", " << nbSolids << ", " << nbGroups << std::endl;
|
||||
if (nbVertices > 0) geometry->setCountVertices(nbVertices);
|
||||
if (nbEdges > 0) geometry->setCountEdges(nbEdges);
|
||||
if (nbFaces > 0) geometry->setCountFaces(nbFaces);
|
||||
if (nbSolids > 0) geometry->setCountSolids(nbSolids);
|
||||
|
||||
int vInd = 0, eInd = 0, fInd = 0, sInd = 0;
|
||||
for (int i = 1; i <= nbSubObjects; i++)
|
||||
{
|
||||
Handle(Standard_Transient) transientSubObject = subObjects->Value(i);
|
||||
if (transientSubObject.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(GEOM_Object) subObject = Handle(GEOM_Object)::DownCast(transientSubObject);
|
||||
std::cout << " sub[" << i << "] N=" << subObject->GetName()
|
||||
//<< " E=" << subObject->GetEntry()
|
||||
//<< " D=" << subObject->GetDocID()
|
||||
<< " T=" << subObject->GetType() << std::endl;
|
||||
if (subObject->GetType() != GEOM_GROUP)
|
||||
{
|
||||
int index = m_shapesOperations->GetSubShapeIndex(shape, subObject);
|
||||
const char* strIndex = XAO::XaoUtils::intToString(index);
|
||||
std::cout << " index= " << index << std::endl;
|
||||
int subIndex = m_shapesOperations->GetSubShapeIndex(shape, subObject);
|
||||
// convert index to a string
|
||||
std::stringstream str;
|
||||
str << subIndex;
|
||||
std::string strIndex = str.str();
|
||||
|
||||
switch (subObject->GetValue().ShapeType())
|
||||
{
|
||||
case TopAbs_VERTEX:
|
||||
geometry->setVertex(vInd++, subObject->GetName(), strIndex);
|
||||
tmpIndex = geometry->getVertexIndexByReference(strIndex.c_str());
|
||||
geometry->setVertexName(tmpIndex, subObject->GetName());
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
geometry->setEdge(eInd++, subObject->GetName(), strIndex);
|
||||
tmpIndex = geometry->getEdgeIndexByReference(strIndex.c_str());
|
||||
geometry->setEdgeName(tmpIndex, subObject->GetName());
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
geometry->setFace(fInd++, subObject->GetName(), strIndex);
|
||||
tmpIndex = geometry->getFaceIndexByReference(strIndex.c_str());
|
||||
geometry->setFaceName(tmpIndex, subObject->GetName());
|
||||
break;
|
||||
case TopAbs_SOLID:
|
||||
geometry->setSolid(sInd++, subObject->GetName(), strIndex);
|
||||
tmpIndex = geometry->getSolidIndexByReference(strIndex.c_str());
|
||||
geometry->setSolidName(tmpIndex, subObject->GetName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
xaoObject->setGeometry(geometry);
|
||||
|
||||
xaoObject->exportToFile(fileName.c_str());
|
||||
|
||||
/*
|
||||
// adding groups
|
||||
std::list<Handle(GEOM_Object)>::iterator itG1 = groupList.begin();
|
||||
int gInd = 0;
|
||||
while (itG1 != groupList.end())
|
||||
{
|
||||
std::cout << "Group = " << gInd++ << std::endl;
|
||||
Handle(GEOM_Object) itGroup = (*itG1++);
|
||||
XAO::Group* group = new XAO::Group();
|
||||
group->setName(itGroup->GetName());
|
||||
Handle(TColStd_HArray1OfInteger) groupIds = m_groupOperations->GetObjects(itGroup);
|
||||
TopAbs_ShapeEnum shapeGroup = m_groupOperations->GetType(itGroup);
|
||||
std::cout << "GroupShape = " << shapeGroup << std::endl;
|
||||
if (shapeGroup == TopAbs_VERTEX)
|
||||
|
||||
XAO::Group* group = new XAO::Group();
|
||||
group->setName(itGroup->GetName());
|
||||
switch (shapeGroup)
|
||||
{
|
||||
group->setDimension(0);
|
||||
for (int i = 1; i <= groupIds->Length(); i++)
|
||||
{
|
||||
const char* index = geometry->getVertexReference(groupIds->Value(i));
|
||||
group->addElement(index);
|
||||
}
|
||||
case TopAbs_VERTEX:
|
||||
group->setDimension(0);
|
||||
for (int i = 1; i <= groupIds->Length(); i++)
|
||||
{
|
||||
const char* ref = XAO::XaoUtils::intToString(groupIds->Value(i));
|
||||
const int index = geometry->getVertexIndexByReference(ref);
|
||||
group->addElement(index);
|
||||
}
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
group->setDimension(1);
|
||||
for (int i = 1; i <= groupIds->Length(); i++)
|
||||
{
|
||||
const char* ref = XAO::XaoUtils::intToString(groupIds->Value(i));
|
||||
const int index = geometry->getEdgeIndexByReference(ref);
|
||||
group->addElement(index);
|
||||
}
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
group->setDimension(2);
|
||||
for (int i = 1; i <= groupIds->Length(); i++)
|
||||
{
|
||||
const char* ref = XAO::XaoUtils::intToString((int)(groupIds->Value(i)));
|
||||
const int index = geometry->getFaceIndexByReference(ref);
|
||||
group->addElement(index);
|
||||
}
|
||||
break;
|
||||
case TopAbs_SOLID:
|
||||
group->setDimension(3);
|
||||
for (int i = 1; i <= groupIds->Length(); i++)
|
||||
{
|
||||
const char* ref = XAO::XaoUtils::intToString(groupIds->Value(i));
|
||||
const int index = geometry->getSolidIndexByReference(ref);
|
||||
group->addElement(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
xaoObject->addGroup(group);
|
||||
/*{
|
||||
case TopAbs_SOLID:
|
||||
Group->setType(3);
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
Group->setType(2);
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
Group->setType(1);
|
||||
break;
|
||||
case TopAbs_VERTEX:
|
||||
Group->setType(0);
|
||||
break;
|
||||
} *
|
||||
}
|
||||
|
||||
}*/
|
||||
xaoObject->exportToFile(fileName.c_str());
|
||||
|
||||
/*
|
||||
// make a Python command
|
||||
TCollection_AsciiString fileNameStr = fileName.c_str();
|
||||
/*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();
|
||||
@ -329,6 +269,6 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape,
|
||||
|
||||
SetErrorCode(OK);
|
||||
|
||||
return isGood;
|
||||
return true;
|
||||
}
|
||||
/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -65,7 +65,6 @@ bool ImportExportGUI::OnGUIEvent(int commandId, SUIT_Desktop* parent)
|
||||
|
||||
getGeometryGUI()->EmitSignalDeactivateDialog();
|
||||
|
||||
|
||||
QDialog* dialog = NULL;
|
||||
switch (commandId)
|
||||
{
|
||||
|
@ -167,12 +167,13 @@ void ImportExportGUI_ExportXAODlg::processObject()
|
||||
else
|
||||
{
|
||||
ledShape->setText(GEOMBase::GetName(m_mainObj));
|
||||
GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations(getStudyId());
|
||||
GEOM::ListOfGO_var Groups = aShOp->GetExistingSubObjects(m_mainObj, true);
|
||||
// Affichage des noms des groupes
|
||||
for (int i = 0, n = Groups->length(); i < n; i++)
|
||||
GEOM::GEOM_IShapesOperations_var shapeOp = getGeomEngine()->GetIShapesOperations(getStudyId());
|
||||
GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true);
|
||||
// add groups names
|
||||
for (int i = 0, n = groups->length(); i < n; i++)
|
||||
{
|
||||
lstGroups->addItem(GEOMBase::GetName(Groups[i]));
|
||||
lstGroups->addItem(GEOMBase::GetName(groups[i]));
|
||||
m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -296,20 +297,16 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
|
||||
GEOM::ListOfGO_var groups = shapesOp->GetExistingSubObjects(m_mainObj, true);
|
||||
GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
|
||||
|
||||
std::cout << " == Groups" << std::endl;
|
||||
groups->length(m_groups.count());
|
||||
for (int i = 0; i < m_groups.count(); i++)
|
||||
groups[i] = m_groups[i].copy();
|
||||
|
||||
std::cout << " == Fields" << std::endl;
|
||||
fields->length(m_fields.count());
|
||||
for (int i = 0; i < m_fields.count(); i++)
|
||||
fields[i] = m_fields[i].copy();
|
||||
|
||||
// call engine function
|
||||
std::cout << " >> ExportXAO" << std::endl;
|
||||
res = ieOp->ExportXAO(m_mainObj, ledFileName->text().toStdString().c_str(), groups, fields);
|
||||
std::cout << " << ExportXAO" << std::endl;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ private:
|
||||
GEOM::GEOM_Object_var m_mainObj;
|
||||
QList<GEOM::GeomObjPtr> m_groups;
|
||||
QList<GEOM::GeomObjPtr> m_fields;
|
||||
//ImportExportGUI_1Sel1LineEdit2ListWidget* myGrp;
|
||||
QLineEdit* ledShape;
|
||||
QLineEdit* ledFileName;
|
||||
QListWidget* lstGroups;
|
||||
@ -69,8 +68,6 @@ private slots:
|
||||
void LineEditReturnPressed();
|
||||
void SelectionIntoArgument();
|
||||
void SetEditCurrentArgument();
|
||||
//void ValueChangedInSpinBox();
|
||||
//void SetDoubleSpinBoxStep( double );
|
||||
};
|
||||
|
||||
#endif // IMPORTEXPORTGUI_EXPORTXAODLG_H
|
||||
|
@ -37,6 +37,10 @@ if GEOM_ENABLE_GUI
|
||||
GroupGUI BlocksGUI AdvancedGUI ImportExportGUI GEOM_SWIG_WITHIHM
|
||||
endif
|
||||
|
||||
if CPPUNIT_IS_OK
|
||||
SUBDIRS += XAO/tests
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \
|
||||
SKETCHER OCC2VTK GEOM BREPExport \
|
||||
BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \
|
||||
|
@ -18,6 +18,7 @@
|
||||
//
|
||||
// Author : Frederic Pons (OpenCascade)
|
||||
|
||||
#include <cstring>
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
|
||||
#include "GeometricElement.hxx"
|
||||
@ -71,7 +72,6 @@ void GeometricElementList::setElement(const int index, const char* name, const c
|
||||
m_elements[index].setReference(reference);
|
||||
}
|
||||
|
||||
|
||||
const char* GeometricElementList::getName(const int index)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
@ -103,3 +103,19 @@ void GeometricElementList::setReference(const int index, const char* name)
|
||||
|
||||
m_elements[index].setReference(name);
|
||||
}
|
||||
|
||||
const int GeometricElementList::getIndexByReference(const char* ref)
|
||||
{
|
||||
for (int index = 0; index < m_count; ++index)
|
||||
{
|
||||
if (strcmp(ref, m_elements[index].getReference()) == 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
// std::string msg = "Cannot find element with reference ";
|
||||
// msg += name;
|
||||
// throw SALOME_Exception(msg.c_str());
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ namespace XAO
|
||||
void setName(const int index, const char* name);
|
||||
const char* getReference(const int index);
|
||||
void setReference(const int index, const char* reference);
|
||||
const int getIndexByReference(const char* reference);
|
||||
|
||||
private:
|
||||
int m_count;
|
||||
|
@ -85,53 +85,6 @@ const char* Geometry::getBREP()
|
||||
return streamShape.str().c_str();
|
||||
}
|
||||
|
||||
/*
|
||||
void Geometry::changeVertexName(int id, const char* name)
|
||||
{
|
||||
if (m_nbVertices == 0)
|
||||
Standard_TypeMismatch::Raise("Problem with number of vertices");
|
||||
|
||||
if (m_verticesNames == NULL)
|
||||
m_verticesNames = new std::string[m_nbVertices];
|
||||
|
||||
int index = findVertex(id);
|
||||
|
||||
if (index == -1)
|
||||
Standard_TypeMismatch::Raise("Problem with the id of the vertex");
|
||||
|
||||
m_verticesNames[index] = name;
|
||||
}
|
||||
|
||||
const char* Geometry::findVertexName(int id)
|
||||
{
|
||||
if (m_nbVertices == 0)
|
||||
{
|
||||
Standard_TypeMismatch::Raise("Problem with number of vertices");
|
||||
return "";
|
||||
}
|
||||
|
||||
int index = findVertex(id);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
Standard_TypeMismatch::Raise("Problem with the id of the vertex");
|
||||
return "";
|
||||
}
|
||||
|
||||
return m_verticesNames[index].c_str();
|
||||
}*/
|
||||
/*
|
||||
int Geometry::findVertex(int id)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0, n = m_nbVertices; i < n; i++)
|
||||
{
|
||||
if (m_verticesIds[i] == id)
|
||||
return i;
|
||||
}
|
||||
return index;
|
||||
}*/
|
||||
|
||||
void Geometry::initListIds(const Standard_Integer shapeType)
|
||||
{
|
||||
TopTools_MapOfShape mapShape;
|
||||
@ -145,50 +98,49 @@ void Geometry::initListIds(const Standard_Integer shapeType)
|
||||
}
|
||||
|
||||
if (listShape.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
TopExp::MapShapes(m_shape, anIndices);
|
||||
TopTools_IndexedMapOfShape indices;
|
||||
TopExp::MapShapes(m_shape, indices);
|
||||
//Handle (TColStd_HArray1OfInteger) anArray;
|
||||
|
||||
std::list<int> aList;
|
||||
std::list<int> indexList;
|
||||
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
||||
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
||||
{
|
||||
TopoDS_Shape value = itSub.Value();
|
||||
aList.push_back(anIndices.FindIndex(value));
|
||||
//std::cout << "index = " << indices.FindIndex(value) << std::endl;
|
||||
indexList.push_back(indices.FindIndex(value));
|
||||
}
|
||||
|
||||
std::list<int>::iterator it = aList.begin();
|
||||
std::list<int>::iterator it = indexList.begin();
|
||||
switch (shapeType)
|
||||
{
|
||||
case TopAbs_VERTEX: /* Fill vertices ids */
|
||||
{
|
||||
m_vertices.setSize(aList.size());
|
||||
for (int i = 0; it != aList.end(); it++, i++)
|
||||
m_vertices.setSize(indexList.size());
|
||||
for (int i = 0; it != indexList.end(); it++, i++)
|
||||
m_vertices.setReference(i, XaoUtils::intToString((*it)));
|
||||
break;
|
||||
}
|
||||
case TopAbs_EDGE: /* Fill edges ids */
|
||||
{
|
||||
m_edges.setSize(aList.size());
|
||||
for (int i = 0; it != aList.end(); it++, i++)
|
||||
m_edges.setSize(indexList.size());
|
||||
for (int i = 0; it != indexList.end(); it++, i++)
|
||||
m_edges.setReference(i, XaoUtils::intToString((*it)));
|
||||
break;
|
||||
}
|
||||
case TopAbs_FACE: /* Fill faces ids */
|
||||
{
|
||||
m_faces.setSize(aList.size());
|
||||
for (int i = 0; it != aList.end(); it++, i++)
|
||||
m_faces.setSize(indexList.size());
|
||||
for (int i = 0; it != indexList.end(); it++, i++)
|
||||
m_faces.setReference(i, XaoUtils::intToString((*it)));
|
||||
break;
|
||||
}
|
||||
case TopAbs_SOLID: /* Fill solids ids */
|
||||
{
|
||||
m_solids.setSize(aList.size());
|
||||
for (int i = 0; it != aList.end(); it++, i++)
|
||||
m_solids.setSize(indexList.size());
|
||||
for (int i = 0; it != indexList.end(); it++, i++)
|
||||
m_solids.setReference(i, XaoUtils::intToString((*it)));
|
||||
break;
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ namespace XAO
|
||||
void setCountFaces(const int nb) { m_faces.setSize(nb); }
|
||||
void setCountSolids(const int nb) { m_solids.setSize(nb); }
|
||||
|
||||
void setVertex(const int index, const char* name, const char* reference) { m_vertices.setElement(index, name,reference); }
|
||||
void setEdge(const int index, const char* name, const char* reference) { m_edges.setElement(index, name,reference); }
|
||||
void setFace(const int index, const char* name, const char* reference) { m_faces.setElement(index, name,reference); }
|
||||
void setSolid(const int index, const char* name, const char* reference) { m_solids.setElement(index, name,reference); }
|
||||
void setVertex(const int index, const char* name, const char* reference) { m_vertices.setElement(index, name, reference); }
|
||||
void setEdge(const int index, const char* name, const char* reference) { m_edges.setElement(index, name, reference); }
|
||||
void setFace(const int index, const char* name, const char* reference) { m_faces.setElement(index, name, reference); }
|
||||
void setSolid(const int index, const char* name, const char* reference) { m_solids.setElement(index, name, reference); }
|
||||
|
||||
const char* getVertexName(const int index) { return m_vertices.getName(index); }
|
||||
const char* getEdgeName(const int index) { return m_edges.getName(index); }
|
||||
@ -98,10 +98,10 @@ namespace XAO
|
||||
void setFaceReference(const int index, const char* reference) { m_faces.setReference(index, reference); }
|
||||
void setSolidReference(const int index, const char* reference) { m_solids.setReference(index, reference); }
|
||||
|
||||
// int findVertex(int id);
|
||||
// void changeVertexName(const int id, const char* name);
|
||||
// const char* findVertexName(int id);
|
||||
|
||||
const int getVertexIndexByReference(const char* reference) { return m_vertices.getIndexByReference(reference); }
|
||||
const int getEdgeIndexByReference(const char* reference) { return m_edges.getIndexByReference(reference); }
|
||||
const int getFaceIndexByReference(const char* reference) { return m_faces.getIndexByReference(reference); }
|
||||
const int getSolidIndexByReference(const char* reference) { return m_solids.getIndexByReference(reference); }
|
||||
|
||||
private:
|
||||
void initListIds(const Standard_Integer shapeType);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef __XAO_GROUP_HXX__
|
||||
#define __XAO_GROUP_HXX__
|
||||
|
||||
# include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -55,21 +56,21 @@ namespace XAO
|
||||
return m_elements.size();
|
||||
}
|
||||
|
||||
void addElement(const char* value)
|
||||
void addElement(const int value)
|
||||
{
|
||||
m_elements.push_back(value);
|
||||
}
|
||||
|
||||
const char* getElement(const int index)
|
||||
const int getElement(const int index)
|
||||
{
|
||||
return m_elements[index].c_str();
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
int m_dimension;
|
||||
int m_count;
|
||||
std::vector<std::string> m_elements;
|
||||
std::vector<int> m_elements;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,6 @@
|
||||
#
|
||||
include $(top_srcdir)/adm_local/unix/make_common_starter.am
|
||||
|
||||
if CPPUNIT_IS_OK
|
||||
SUBDIRS = . tests
|
||||
endif
|
||||
|
||||
# ===============================================================
|
||||
# Files to be installed
|
||||
# ===============================================================
|
||||
|
@ -109,6 +109,8 @@ Group* Xao::getGroup(const int index)
|
||||
if (i == index)
|
||||
return (*it);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +231,7 @@ void Xao::exportGroups(xmlNodePtr xao)
|
||||
for (int i = 0; i < grp->getCount(); ++i)
|
||||
{
|
||||
xmlNodePtr elt = xmlNewChild(group, 0, C_TAG_ELEMENT, 0);
|
||||
xmlNewProp(elt, C_ATTR_ELEMENT_INDEX, BAD_CAST grp->getElement(i));
|
||||
xmlNewProp(elt, C_ATTR_ELEMENT_INDEX, BAD_CAST XaoUtils::intToString(grp->getElement(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -507,7 +509,7 @@ void Xao::parseGroupNode(xmlNodePtr groupNode)
|
||||
xmlChar* index = xmlGetProp(node, C_ATTR_ELEMENT_INDEX);
|
||||
if (index == NULL)
|
||||
throw SALOME_Exception("Bad index for group element");
|
||||
group->addElement((char*)index);
|
||||
group->addElement(atoi((char*)index));
|
||||
xmlFree(index);
|
||||
}
|
||||
}
|
||||
|
@ -83,15 +83,15 @@ void ImportExportTest::testExportGeometry()
|
||||
xao.addGroup(group);
|
||||
group->setName("boite1");
|
||||
group->setDimension(3);
|
||||
group->addElement("1");
|
||||
group->addElement(1);
|
||||
|
||||
group = new Group();
|
||||
xao.addGroup(group);
|
||||
group->setName("faces");
|
||||
group->setDimension(2);
|
||||
group->addElement("5");
|
||||
group->addElement("8");
|
||||
group->addElement("9");
|
||||
group->addElement(5);
|
||||
group->addElement(8);
|
||||
group->addElement(9);
|
||||
|
||||
bool res = xao.exportToFile("mygeom.xao");
|
||||
CPPUNIT_ASSERT(res);
|
||||
@ -113,7 +113,7 @@ void ImportExportTest::testGeometryError()
|
||||
|
||||
void ImportExportTest::testImportXao()
|
||||
{
|
||||
std::cout << std::endl;
|
||||
//std::cout << std::endl;
|
||||
Xao xao;
|
||||
xao.importFromFile(getTestFile("test.xao").c_str());
|
||||
CPPUNIT_ASSERT(strcmp(xao.getAuthor(), "me") == 0);
|
||||
@ -156,12 +156,12 @@ void ImportExportTest::testImportXao()
|
||||
CPPUNIT_ASSERT(group->getCount() == 1);
|
||||
CPPUNIT_ASSERT(strcmp(group->getName(), "boite_1") == 0);
|
||||
CPPUNIT_ASSERT(group->getDimension() == 3);
|
||||
CPPUNIT_ASSERT(strcmp(group->getElement(0), "1") == 0);
|
||||
CPPUNIT_ASSERT(group->getElement(0) == 1);
|
||||
group = xao.getGroup(1);
|
||||
CPPUNIT_ASSERT(group->getCount() == 3);
|
||||
CPPUNIT_ASSERT(strcmp(group->getName(), "") == 0);
|
||||
CPPUNIT_ASSERT(group->getDimension() == 2);
|
||||
CPPUNIT_ASSERT(strcmp(group->getElement(0), "5") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(group->getElement(1), "8") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(group->getElement(2), "9") == 0);
|
||||
CPPUNIT_ASSERT(group->getElement(0) == 5);
|
||||
CPPUNIT_ASSERT(group->getElement(1) == 8);
|
||||
CPPUNIT_ASSERT(group->getElement(2) == 9);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user