mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-22 15:00:33 +05:00
Mantis issue 0021350: EDF 1948 GEOM: Export IGES 5.3 impossible.
This commit is contained in:
parent
ee46a27702
commit
9f11350cbe
@ -4423,6 +4423,13 @@ Please, select face, shell or solid and try again</translation>
|
|||||||
<source>GEOM_IMPORT_ERRORS</source>
|
<source>GEOM_IMPORT_ERRORS</source>
|
||||||
<translation>Import operation has finished with errors:</translation>
|
<translation>Import operation has finished with errors:</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>EXPORT_IGES_HETEROGENEOUS_COMPOUND</source>
|
||||||
|
<translation>This compound cannot be exported in IGES format
|
||||||
|
without loss, because it contains entities, that must be saved in
|
||||||
|
different modes. It is vertices, edges and wires on the one hand and
|
||||||
|
shells and solids on the other hand.</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>GEOM_PUBLISH_NAMED_SHAPES</source>
|
<source>GEOM_PUBLISH_NAMED_SHAPES</source>
|
||||||
<translation>Create groups for named shapes (if there are any)?</translation>
|
<translation>Create groups for named shapes (if there are any)?</translation>
|
||||||
|
@ -18,12 +18,11 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
|
|
||||||
// GEOM GEOMGUI : GUI for Geometry component
|
// GEOM GEOMGUI : GUI for Geometry component
|
||||||
// File : GEOMBase_Tools.cxx
|
// File : GEOMBase_Tools.cxx
|
||||||
// Author : Damien COQUERET, Open CASCADE S.A.S.
|
// Author : Damien COQUERET, Open CASCADE S.A.S.
|
||||||
//
|
|
||||||
#include "GEOMToolsGUI.h"
|
#include "GEOMToolsGUI.h"
|
||||||
#include "GEOMToolsGUI_DeleteDlg.h"
|
#include "GEOMToolsGUI_DeleteDlg.h"
|
||||||
|
|
||||||
@ -78,9 +77,9 @@ static QString getFileName( QWidget* parent,
|
|||||||
{
|
{
|
||||||
//QStringList filters;
|
//QStringList filters;
|
||||||
QString aBrepFilter;
|
QString aBrepFilter;
|
||||||
for ( FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it ) {
|
for (FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it) {
|
||||||
//filters.push_back( it.key() );
|
//filters.push_back( it.key() );
|
||||||
if ( it.key().contains( "BREP", Qt::CaseInsensitive ) )
|
if (it.key().contains( "BREP", Qt::CaseInsensitive ))
|
||||||
aBrepFilter = it.key();
|
aBrepFilter = it.key();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +256,6 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : GEOMToolsGUI()
|
// function : GEOMToolsGUI()
|
||||||
// purpose : Constructor
|
// purpose : Constructor
|
||||||
@ -267,7 +265,6 @@ GEOMToolsGUI::GEOMToolsGUI( GeometryGUI* parent )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : ~GEOMToolsGUI()
|
// function : ~GEOMToolsGUI()
|
||||||
// purpose : Destructor
|
// purpose : Destructor
|
||||||
@ -276,7 +273,6 @@ GEOMToolsGUI::~GEOMToolsGUI()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : OnGUIEvent()
|
// function : OnGUIEvent()
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -384,7 +380,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===============================================================================
|
//===============================================================================
|
||||||
// function : OnEditDelete()
|
// function : OnEditDelete()
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -533,8 +528,6 @@ void GEOMToolsGUI::OnEditDelete()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
selected.Clear();
|
selected.Clear();
|
||||||
aSelMgr->setSelectedObjects( selected );
|
aSelMgr->setSelectedObjects( selected );
|
||||||
getGeometryGUI()->updateObjBrowser();
|
getGeometryGUI()->updateObjBrowser();
|
||||||
@ -704,11 +697,12 @@ bool GEOMToolsGUI::Import()
|
|||||||
GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, /*withExten=*/true ) );
|
GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, /*withExten=*/true ) );
|
||||||
|
|
||||||
SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy );
|
SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy );
|
||||||
SALOMEDS::SObject_var aSO = GeometryGUI::GetGeomGen()->PublishInStudy( aDSStudy,
|
SALOMEDS::SObject_var aSO =
|
||||||
SALOMEDS::SObject::_nil(),
|
GeometryGUI::GetGeomGen()->PublishInStudy( aDSStudy,
|
||||||
anObj,
|
SALOMEDS::SObject::_nil(),
|
||||||
aPublishObjName.toLatin1().constData() );
|
anObj,
|
||||||
if( ( !aSO->_is_nil() ) )
|
aPublishObjName.toLatin1().constData() );
|
||||||
|
if ( ( !aSO->_is_nil() ) )
|
||||||
anEntryList.append( aSO->GetID() );
|
anEntryList.append( aSO->GetID() );
|
||||||
|
|
||||||
objsForDisplay.append( anObj );
|
objsForDisplay.append( anObj );
|
||||||
@ -752,7 +746,6 @@ bool GEOMToolsGUI::Import()
|
|||||||
return objsForDisplay.count() > 0;
|
return objsForDisplay.count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
// function : Export
|
// function : Export
|
||||||
// purpose : BRep, Iges, Step
|
// purpose : BRep, Iges, Step
|
||||||
@ -801,7 +794,7 @@ bool GEOMToolsGUI::Export()
|
|||||||
bool appropriateObj = false;
|
bool appropriateObj = false;
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO It( selectedObjects );
|
SALOME_ListIteratorOfListIO It( selectedObjects );
|
||||||
for(;It.More();It.Next()) {
|
for (; It.More(); It.Next()) {
|
||||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||||
GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( IObject );
|
GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( IObject );
|
||||||
|
|
||||||
@ -824,20 +817,18 @@ bool GEOMToolsGUI::Export()
|
|||||||
|
|
||||||
anOp->start();
|
anOp->start();
|
||||||
|
|
||||||
|
|
||||||
aInsOp->Export( anObj, file.toStdString().c_str(), fileType.toLatin1().constData() );
|
aInsOp->Export( anObj, file.toStdString().c_str(), fileType.toLatin1().constData() );
|
||||||
|
|
||||||
if ( aInsOp->IsDone() )
|
if (aInsOp->IsDone())
|
||||||
anOp->commit();
|
anOp->commit();
|
||||||
else
|
else {
|
||||||
{
|
anOp->abort();
|
||||||
anOp->abort();
|
wc.suspend();
|
||||||
wc.suspend();
|
SUIT_MessageBox::critical(app->desktop(),
|
||||||
SUIT_MessageBox::critical( app->desktop(),
|
QObject::tr("GEOM_ERROR"),
|
||||||
QObject::tr( "GEOM_ERROR" ),
|
QObject::tr("GEOM_PRP_ABORT") + "\n" + QObject::tr(aInsOp->GetErrorCode()));
|
||||||
QObject::tr("GEOM_PRP_ABORT") + "\n" + QString( aInsOp->GetErrorCode() ) );
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (const SALOME::SALOME_Exception& S_ex) {
|
catch (const SALOME::SALOME_Exception& S_ex) {
|
||||||
//QtCatchCorbaException(S_ex);
|
//QtCatchCorbaException(S_ex);
|
||||||
|
@ -31,8 +31,12 @@
|
|||||||
#include <IGESControl_Writer.hxx>
|
#include <IGESControl_Writer.hxx>
|
||||||
#include <Interface_Static.hxx>
|
#include <Interface_Static.hxx>
|
||||||
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
|
||||||
|
#include <Standard_Failure.hxx>
|
||||||
|
|
||||||
#ifdef WNT
|
#ifdef WNT
|
||||||
#if defined IGESEXPORT_EXPORTS || defined IGESExport_EXPORTS
|
#if defined IGESEXPORT_EXPORTS || defined IGESExport_EXPORTS
|
||||||
@ -52,6 +56,63 @@
|
|||||||
#define IGESEXPORT_EXPORT
|
#define IGESEXPORT_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* KindOfBRep
|
||||||
|
* \return 0 if theShape contains only simple entities (wires, edges and vertices),
|
||||||
|
* 1 if theShape contains only complex entities (shells, solids and compsolids)
|
||||||
|
* 2 if theShape contains only indifferent entities (faces)
|
||||||
|
* -1 if theShape contains both simple and complex entities (and in this case it
|
||||||
|
* cannot be saved without any loss neither in BRepMode == 0 nor in BRepMode == 1)
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
int KindOfBRep (const TopoDS_Shape& theShape)
|
||||||
|
{
|
||||||
|
int aKind = 2;
|
||||||
|
|
||||||
|
switch (theShape.ShapeType())
|
||||||
|
{
|
||||||
|
case TopAbs_COMPOUND:
|
||||||
|
{
|
||||||
|
bool isSimple = false;
|
||||||
|
bool isComplex = false;
|
||||||
|
TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
TopoDS_Shape aS = anIt.Value();
|
||||||
|
int aKindSub = KindOfBRep(aS);
|
||||||
|
if (aKindSub == 0)
|
||||||
|
isSimple = true;
|
||||||
|
else if (aKindSub == 1)
|
||||||
|
isComplex = true;
|
||||||
|
else if (aKindSub == -1) {
|
||||||
|
return -1; // heterogeneous
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isSimple && isComplex)
|
||||||
|
aKind = -1; // heterogeneous
|
||||||
|
else if (isSimple)
|
||||||
|
aKind = 0;
|
||||||
|
else if (isComplex)
|
||||||
|
aKind = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TopAbs_COMPSOLID:
|
||||||
|
case TopAbs_SOLID:
|
||||||
|
case TopAbs_SHELL:
|
||||||
|
aKind = 1;
|
||||||
|
break;
|
||||||
|
case TopAbs_WIRE:
|
||||||
|
case TopAbs_EDGE:
|
||||||
|
case TopAbs_VERTEX:
|
||||||
|
aKind = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
aKind = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return aKind;
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
@ -65,17 +126,32 @@ IGESEXPORT_EXPORT
|
|||||||
const TCollection_AsciiString& theFileName,
|
const TCollection_AsciiString& theFileName,
|
||||||
const TCollection_AsciiString& theFormatName )
|
const TCollection_AsciiString& theFormatName )
|
||||||
{
|
{
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
// define, whether to write only faces (5.1 IGES format)
|
||||||
|
// or shells and solids also (5.3 IGES format)
|
||||||
|
int aBrepMode = 0;
|
||||||
|
if (theFormatName.IsEqual("IGES_5_3"))
|
||||||
|
aBrepMode = 1;
|
||||||
|
|
||||||
MESSAGE("Export IGES into file " << theFileName.ToCString());
|
MESSAGE("Export IGES into file " << theFileName.ToCString());
|
||||||
|
|
||||||
|
// Mantis issue 0021350: check being exported shape, as some standalone
|
||||||
|
// entities (edges, wires and vertices) cannot be saved in BRepMode
|
||||||
|
if (aBrepMode == 1) {
|
||||||
|
int aKind = KindOfBRep(theShape);
|
||||||
|
if (aKind == -1)
|
||||||
|
Standard_Failure::Raise("EXPORT_IGES_HETEROGENEOUS_COMPOUND");
|
||||||
|
else if (aKind == 2)
|
||||||
|
aBrepMode = 1;
|
||||||
|
else
|
||||||
|
aBrepMode = aKind;
|
||||||
|
}
|
||||||
|
|
||||||
// commented for 0021350: Please don't catch exceptions silently and send an
|
// commented for 0021350: Please don't catch exceptions silently and send an
|
||||||
// inappropriate error message instead, it is disturbing for the user and for us
|
// inappropriate error message instead, it is disturbing for the user and for us
|
||||||
//try
|
//try
|
||||||
{
|
{
|
||||||
// define, whether to write only faces (5.1 IGES format)
|
|
||||||
// or shells and solids also (5.3 IGES format)
|
|
||||||
int aBrepMode = 0;
|
|
||||||
if (theFormatName.IsEqual("IGES_5_3"))
|
|
||||||
aBrepMode = 1;
|
|
||||||
|
|
||||||
// Set "C" numeric locale to save numbers correctly
|
// Set "C" numeric locale to save numbers correctly
|
||||||
Kernel_Utils::Localizer loc;
|
Kernel_Utils::Localizer loc;
|
||||||
|
|
||||||
@ -91,18 +167,14 @@ IGESEXPORT_EXPORT
|
|||||||
Interface_Static::SetCVal("write.precision.mode","Max");
|
Interface_Static::SetCVal("write.precision.mode","Max");
|
||||||
|
|
||||||
// perform shape writing
|
// perform shape writing
|
||||||
ICW.AddShape( theShape );
|
if (ICW.AddShape( theShape )) {
|
||||||
ICW.ComputeModel();
|
ICW.ComputeModel();
|
||||||
bool ok = ICW.Write( theFileName.ToCString() );
|
ok = ICW.Write( theFileName.ToCString() );
|
||||||
|
}
|
||||||
// Return previous locale
|
|
||||||
if ( ok )
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
//catch(Standard_Failure)
|
//catch(Standard_Failure)
|
||||||
//{
|
//{
|
||||||
// //THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM);
|
|
||||||
//}
|
//}
|
||||||
return 0;
|
return ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user