From ff7d2479bea74087ed83b798cffba5bec69edb2d Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 17 Sep 2012 10:22:42 +0000 Subject: [PATCH] 0020982: EDF 1547 SMESH: Creation of non-conformal quadratic pyramids + * \brief Returns description of an error/warning occured during the last operation + */ + SMESH::ComputeError* GetLastError(); --- src/SMESH_I/SMESH_MeshEditor_i.cxx | 76 +++++++++++++++++++++++++----- src/SMESH_I/SMESH_MeshEditor_i.hxx | 52 ++++++++++---------- 2 files changed, 91 insertions(+), 37 deletions(-) diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 42d0b3c2f..a5b5f88c1 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -29,20 +29,42 @@ #include "SMESH_MeshEditor_i.hxx" +#include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverMED_W_SMESHDS_Mesh.h" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_ElemIterator.hxx" +#include "SMDS_FacePosition.hxx" +#include "SMDS_IteratorOnIterators.hxx" #include "SMDS_LinearEdge.hxx" #include "SMDS_Mesh0DElement.hxx" #include "SMDS_MeshFace.hxx" #include "SMDS_MeshVolume.hxx" #include "SMDS_PolyhedralVolumeOfNodes.hxx" #include "SMDS_SetIterator.hxx" +#include "SMDS_SetIterator.hxx" +#include "SMDS_VolumeTool.hxx" +#include "SMESHDS_Command.hxx" +#include "SMESHDS_CommandType.hxx" #include "SMESHDS_Group.hxx" +#include "SMESHDS_GroupOnGeom.hxx" #include "SMESH_ControlsDef.hxx" #include "SMESH_Filter_i.hxx" +#include "SMESH_Filter_i.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_Gen_i.hxx" +#include "SMESH_Group.hxx" #include "SMESH_Group_i.hxx" +#include "SMESH_Group_i.hxx" +#include "SMESH_MEDMesh_i.hxx" +#include "SMESH_MeshEditor.hxx" +#include "SMESH_MeshPartDS.hxx" +#include "SMESH_MesherHelper.hxx" +#include "SMESH_PreMeshInfo.hxx" +#include "SMESH_PythonDump.hxx" #include "SMESH_PythonDump.hxx" #include "SMESH_subMeshEventListener.hxx" #include "SMESH_subMesh_i.hxx" +#include "SMESH_subMesh_i.hxx" #include "utilities.h" #include "Utils_ExceptHandlers.hxx" @@ -438,6 +460,7 @@ void SMESH_MeshEditor_i::initData(bool deleteSearchers) if ( deleteSearchers ) TSearchersDeleter::Delete(); } + myEditor.GetError().reset(); } //================================================================================ @@ -458,30 +481,41 @@ void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& ) SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData() { - if ( myPreviewMode ) { // --- MeshPreviewStruct filling --- + const bool hasBadElems = ( myEditor.GetError() && myEditor.GetError()->HasBadElems() ); + + if ( myPreviewMode || hasBadElems ) { // --- MeshPreviewStruct filling --- list aNodesConnectivity; typedef map TNodesMap; TNodesMap nodesMap; - SMESHDS_Mesh* aMeshDS = myEditor.GetMeshDS(); + SMESHDS_Mesh* aMeshDS; + std::auto_ptr< SMESH_MeshPartDS > aMeshPartDS; + if ( hasBadElems ) { + aMeshPartDS.reset( new SMESH_MeshPartDS( myEditor.GetError()->myBadElements )); + aMeshDS = aMeshPartDS.get(); + } + else { + aMeshDS = myEditor.GetMeshDS(); + } int nbEdges = aMeshDS->NbEdges(); int nbFaces = aMeshDS->NbFaces(); int nbVolum = aMeshDS->NbVolumes(); myPreviewData = new SMESH::MeshPreviewStruct(); myPreviewData->nodesXYZ.length(aMeshDS->NbNodes()); - TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( myEditor.GetMesh() ); + SMDSAbs_ElementType previewType = SMDSAbs_All; - if (aPreviewMesh) { - previewType = aPreviewMesh->myPreviewType; - switch ( previewType ) { - case SMDSAbs_Edge : nbFaces = nbVolum = 0; break; - case SMDSAbs_Face : nbEdges = nbVolum = 0; break; - case SMDSAbs_Volume: nbEdges = nbFaces = 0; break; - default:; + if ( !hasBadElems ) + if (TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( myEditor.GetMesh() )) { + previewType = aPreviewMesh->myPreviewType; + switch ( previewType ) { + case SMDSAbs_Edge : nbFaces = nbVolum = 0; break; + case SMDSAbs_Face : nbEdges = nbVolum = 0; break; + case SMDSAbs_Volume: nbEdges = nbFaces = 0; break; + default:; + } } - } myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum); int i = 0, j = 0; @@ -565,6 +599,26 @@ SMESH::long_array* SMESH_MeshEditor_i::GetLastCreatedElems() return myLastCreatedElems._retn(); } +//======================================================================= +/* + * Returns description of an error/warning occured during the last operation + */ +//======================================================================= + +SMESH::ComputeError* SMESH_MeshEditor_i::GetLastError() +{ + SMESH::ComputeError* errOut = new SMESH::ComputeError; + SMESH_ComputeErrorPtr& errIn = myEditor.GetError(); + if ( errIn && !errIn->IsOK() ) + { + errOut->code = -( errIn->myName < 0 ? errIn->myName + 1: errIn->myName ); // -1 -> 0 + errOut->comment = errIn->myComment.c_str(); + errOut->subShapeID = -1; + errOut->hasBadMesh = !errIn->myBadElements.empty(); + } + return errOut; +} + //======================================================================= //function : MakeIDSource //purpose : Wrap a sequence of ids in a SMESH_IDSource diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 7030afa9c..fa76be969 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -38,7 +38,6 @@ #include "SMESH_MeshEditor.hxx" #include -class SMESH_MeshEditor; class SMESH_Mesh_i; class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor @@ -47,9 +46,35 @@ public: SMESH_MeshEditor_i(SMESH_Mesh_i * theMesh, bool isPreview); virtual ~ SMESH_MeshEditor_i(); + /*! + * \brief Return edited mesh ID + * \retval int - mesh ID + */ + int GetMeshId() const { return myMesh->GetId(); } // --- CORBA + /*! + * Return data of mesh edition preview + */ + SMESH::MeshPreviewStruct* GetPreviewData(); + /*! + * If during last operation of MeshEditor some nodes were + * created this method returns list of their IDs, if new nodes + * not created - returns an empty list + */ + SMESH::long_array* GetLastCreatedNodes(); + /*! + * If during last operation of MeshEditor some elements were + * created this method returns list of their IDs, if new elements + * not created - returns an empty list + */ + SMESH::long_array* GetLastCreatedElems(); + /*! + * \brief Returns description of an error/warning occured during the last operation + */ + SMESH::ComputeError* GetLastError(); + /*! * \brief Wrap a sequence of ids in a SMESH_IDSource */ @@ -568,31 +593,6 @@ public: */ CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs); - /*! - * Return data of mesh edition preview - */ - SMESH::MeshPreviewStruct* GetPreviewData(); - - /*! - * If during last operation of MeshEditor some nodes were - * created this method returns list of it's IDs, if new nodes - * not creared - returns empty list - */ - SMESH::long_array* GetLastCreatedNodes(); - - /*! - * If during last operation of MeshEditor some elements were - * created this method returns list of it's IDs, if new elements - * not creared - returns empty list - */ - SMESH::long_array* GetLastCreatedElems(); - - /*! - * \brief Return edited mesh ID - * \retval int - mesh ID - */ - int GetMeshId() const { return myMesh->GetId(); } - CORBA::Boolean DoubleNodes( const SMESH::long_array& theNodes, const SMESH::long_array& theModifiedElems ); -- 2.39.2