-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#define NOMINMAX
#endif
+// A macro used in SMESH_TryCatch.hxx,
+// it re-raises a CORBA SALOME exception thrown by SMESH_MeshEditor_i and caught by SMESH_CATCH
+#define SMY_OWN_CATCH \
+ catch ( SALOME::SALOME_Exception & e ) { throw e; }
+
#include "SMESH_MeshEditor_i.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMESH_Gen_i.hxx"
#include "SMESH_Group.hxx"
#include "SMESH_Group_i.hxx"
+#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MeshPartDS.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_PythonDump.hxx"
while ( itMeshElems->more() ) {
const SMDS_MeshElement* aMeshElem = itMeshElems->next();
- SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
+ SMDS_NodeIteratorPtr itElemNodes = aMeshElem->nodeIterator();
while ( itElemNodes->more() ) {
- const SMDS_MeshNode* aMeshNode =
- static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
+ const SMDS_MeshNode* aMeshNode = itElemNodes->next();
int aNodeID = aMeshNode->GetID();
TNodesMap::iterator anIter = nodesMap.find(aNodeID);
if ( anIter == nodesMap.end() ) {
// filling the elements types
SMDSAbs_ElementType aType = aMeshElem->GetType();
bool isPoly = aMeshElem->IsPoly();
-
myPreviewData->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) aType;
- myPreviewData->elementTypes[i].isPoly = isPoly;
+ myPreviewData->elementTypes[i].isPoly = isPoly;
myPreviewData->elementTypes[i].nbNodesInElement = aMeshElem->NbNodes();
i++;
-
}
myPreviewData->nodesXYZ.length( j );
for( int i = 0; aConnIter != aNodesConnectivity.end(); aConnIter++, i++ )
myPreviewData->elementConnectivities[i] = *aConnIter;
}
-
return myPreviewData._retn();
+
SMESH_CATCH( SMESH::throwCorbaException );
return 0;
}
return 0;
}
+//=======================================================================
+//function : ClearLastCreated
+//purpose : Clears sequences of last created elements and nodes
+//=======================================================================
+
+void SMESH_MeshEditor_i::ClearLastCreated() throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ getEditor().CrearLastCreated();
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
//=======================================================================
/*
* Returns description of an error/warning occured during the last operation
+ * WARNING: ComputeError.code >= 100 and no corresponding enum in IDL API
*/
//=======================================================================
nodes[i] = getMeshDS()->FindNode(IDsOfNodes[i]);
SMDS_MeshElement* elem = 0;
- if (NbNodes == 3) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
- }
- else if (NbNodes == 4) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
- }
- else if (NbNodes == 6) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
- nodes[4], nodes[5]);
- }
- else if (NbNodes == 8) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
- nodes[4], nodes[5], nodes[6], nodes[7]);
- }
- else if (NbNodes == 9) {
- elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
- nodes[4], nodes[5], nodes[6], nodes[7], nodes[8] );
- }
- else if (NbNodes > 2) {
- elem = getMeshDS()->AddPolygonalFace(nodes);
+ switch (NbNodes) {
+ case 3: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]); break;
+ case 4: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); break;
+ case 6: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5]); break;
+ case 7: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5], nodes[6]); break;
+ case 8: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5], nodes[6], nodes[7]); break;
+ case 9: elem = getMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3],
+ nodes[4], nodes[5], nodes[6], nodes[7],
+ nodes[8] ); break;
+ default: elem = getMeshDS()->AddPolygonalFace(nodes);
}
// Update Python script
* \brief Bind an element to a shape
* \param ElementID - element ID
* \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
- * \retval boolean - false if ElementID or ShapeID is invalid
*/
//=============================================================================
if ( !elem )
THROW_SALOME_CORBA_EXCEPTION("Invalid ElementID", SALOME::BAD_PARAM);
- if ( mesh->MaxShapeIndex() < ShapeID )
+ if ( mesh->MaxShapeIndex() < ShapeID || ShapeID < 1 )
THROW_SALOME_CORBA_EXCEPTION("Invalid ShapeID", SALOME::BAD_PARAM);
TopoDS_Shape shape = mesh->IndexToShape( ShapeID );
if ( myMesh->NbFaces() == 0 )
THROW_SALOME_CORBA_EXCEPTION("No faces in the mesh", SALOME::BAD_PARAM);
- theElementSearcher = myEditor.GetElementSearcher();
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
}
else
{
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
- theElementSearcher = myEditor.GetElementSearcher(elemsIt);
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), elemsIt);
}
}
// find a face
//=============================================================================
/*!
- *
+ * \brief Fuse neighbour triangles into quadrangles.
*/
//=============================================================================
//=============================================================================
/*!
- *
+ * \brief Fuse neighbour triangles into quadrangles.
*/
//=============================================================================
//=============================================================================
/*!
- *
+ * \brief Split quadrangles into triangles.
*/
//=============================================================================
return 0;
}
-
//=============================================================================
/*!
- *
+ * \brief Split quadrangles into triangles.
*/
//=============================================================================
+
CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
SMESH::NumericalFunctor_ptr Criterion)
throw (SALOME::SALOME_Exception)
return 0;
}
+//================================================================================
+/*!
+ * \brief Split each of quadrangles into 4 triangles.
+ * \param [in] theObject - theQuads Container of quadrangles to split.
+ */
+//================================================================================
+
+void SMESH_MeshEditor_i::QuadTo4Tri (SMESH::SMESH_IDSource_ptr theObject)
+ throw (SALOME::SALOME_Exception)
+{
+ SMESH_TRY;
+ initData();
+
+ TIDSortedElemSet faces;
+ if ( !idSourceToSet( theObject, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/true ) &&
+ faces.empty() )
+ THROW_SALOME_CORBA_EXCEPTION("No faces given", SALOME::BAD_PARAM);
+
+ getEditor().QuadTo4Tri( faces );
+ TPythonDump() << this << ".QuadTo4Tri( " << theObject << " )";
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
//=============================================================================
/*!
- *
+ * \brief Split quadrangles into triangles.
*/
//=============================================================================
+
CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
CORBA::Boolean Diag13)
throw (SALOME::SALOME_Exception)
return 0;
}
-
//=============================================================================
/*!
- *
+ * \brief Split quadrangles into triangles.
*/
//=============================================================================
+
CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean Diag13)
throw (SALOME::SALOME_Exception)
//=============================================================================
/*!
- * BestSplit
+ * Find better splitting of the given quadrangle.
+ * \param IDOfQuad ID of the quadrangle to be splitted.
+ * \param Criterion A criterion to choose a diagonal for splitting.
+ * \return 1 if 1-3 diagonal is better, 2 if 2-4
+ * diagonal is better, 0 if error occurs.
*/
//=============================================================================
return 0;
}
-
//=============================================================================
/*!
*
return 0;
}
-
//=============================================================================
/*!
*
theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
if ( !theNodeSearcher ) {
- theNodeSearcher = myEditor.GetNodeSearcher();
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
}
gp_Pnt p( x,y,z );
if ( const SMDS_MeshNode* node = theNodeSearcher->FindClosestTo( p ))
if ( !node ) // preview moving node
{
if ( !theNodeSearcher ) {
- theNodeSearcher = myEditor.GetNodeSearcher();
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
}
gp_Pnt p( x,y,z );
node = theNodeSearcher->FindClosestTo( p );
theSearchersDeleter.Set( myMesh );
if ( !theElementSearcher ) {
- theElementSearcher = myEditor.GetElementSearcher();
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
}
theElementSearcher->FindElementsByPoint( gp_Pnt( x,y,z ),
SMDSAbs_ElementType( type ),
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
SMDS_ElemIteratorPtr elemsIt( new TIter( elements.begin(), elements.end() ));
- theElementSearcher = myEditor.GetElementSearcher(elemsIt);
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), elemsIt );
}
vector< const SMDS_MeshElement* > foundElems;
SMESH_TRY;
theSearchersDeleter.Set( myMesh );
if ( !theElementSearcher ) {
- theElementSearcher = myEditor.GetElementSearcher();
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
}
return CORBA::Short( theElementSearcher->GetPointState( gp_Pnt( x,y,z )));
//================================================================================
/*!
- * \brief Double nodes on shared faces between groups of volumes and create flat
- * elements on demand.
- * The list of groups must describe a partition of the mesh volumes.
+ * \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
+ * The list of groups must contain at least two groups. The groups have to be disjoint:
+ * no common element into two different groups.
* The nodes of the internal faces at the boundaries of the groups are doubled.
- * In option, the internal faces are replaced by flat elements.
- * Triangles are transformed in prisms, and quadrangles in hexahedrons.
+ * Optionally, the internal faces are replaced by flat elements.
+ * Triangles are transformed into prisms, and quadrangles into hexahedrons.
* The flat elements are stored in groups of volumes.
+ * These groups are named according to the position of the group in the list:
+ * the group j_n_p is the group of the flat elements that are built between the group #n and the group #p in the list.
+ * If there is no shared faces between the group #n and the group #p in the list, the group j_n_p is not created.
+ * All the flat elements are gathered into the group named "joints3D" (or "joints2D" in 2D situation).
+ * The flat element of the multiple junctions between the simple junction are stored in a group named "jointsMultiples".
* @param theDomains - list of groups of volumes
* @param createJointElems - if TRUE, create the elements
* @return TRUE if operation has been completed successfully, FALSE otherwise
SMESHDS_Mesh* aMeshDS = getMeshDS();
+ // MESSAGE("theDomains.length = "<<theDomains.length());
+ if ( theDomains.length() <= 1 )
+ THROW_SALOME_CORBA_EXCEPTION("At least 2 groups are required.", SALOME::BAD_PARAM);
vector<TIDSortedElemSet> domains;
domains.clear();
theSearchersDeleter.Set( myMesh ); // remove theNodeSearcher if mesh is other
if ( !theNodeSearcher )
- theNodeSearcher = aMeshEditor.GetNodeSearcher();
+ theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
vector<double> nodesCoords;
for (int i = 0; i < theNodesCoords.length(); i++)