IMP 0020089: Take into account 0D elements (MED_POINT1)

This commit is contained in:
jfa 2009-07-16 13:33:03 +00:00
parent f5a2b6350e
commit 4592fecfcf
46 changed files with 1116 additions and 256 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -6,6 +6,7 @@
<ul> <ul>
<li>\ref adding_nodes_anchor "Nodes"</li> <li>\ref adding_nodes_anchor "Nodes"</li>
<li>\ref adding_0delems_anchor "0D Elements"</li>
<li>\ref adding_edges_anchor "Edges"</li> <li>\ref adding_edges_anchor "Edges"</li>
<li>\ref adding_triangles_anchor "Triangles"</li> <li>\ref adding_triangles_anchor "Triangles"</li>
<li>\ref adding_quadrangles_anchor "Quadrangles"</li> <li>\ref adding_quadrangles_anchor "Quadrangles"</li>
@ -43,6 +44,18 @@ created:
\image html add_node.png \image html add_node.png
<br>
\anchor adding_0delems_anchor
<h2>Adding 0D elements</h2>
\image html add0delement.png
In this dialog box specify the node which will form your 0d element by
selecting it in the 3D viewer and click the \b Apply or
<b>Apply and Close</b> button. Your 0D element will be created:
\image html add_0delement.png
<br> <br>
\anchor adding_edges_anchor \anchor adding_edges_anchor
<h2>Adding edges</h2> <h2>Adding edges</h2>

View File

@ -46,6 +46,7 @@ module SMESH
enum log_command enum log_command
{ {
ADD_NODE, ADD_NODE,
ADD_ELEM0D,
ADD_EDGE, ADD_EDGE,
ADD_TRIANGLE, ADD_TRIANGLE,
ADD_QUADRANGLE, ADD_QUADRANGLE,
@ -110,6 +111,7 @@ module SMESH
{ {
ALL, ALL,
NODE, NODE,
ELEM0D,
EDGE, EDGE,
FACE, FACE,
VOLUME VOLUME
@ -532,6 +534,9 @@ module SMESH
long NbElements() long NbElements()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long Nb0DElements()
raises (SALOME::SALOME_Exception);
long NbEdges() long NbEdges()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);

View File

@ -41,6 +41,12 @@ module SMESH
long AddNode(in double x, in double y, in double z); long AddNode(in double x, in double y, in double z);
/*!
* Create 0D element on the given node.
* \param IdOfNode Node IDs for creation of element.
*/
long Add0DElement(in long IDOfNode);
/*! /*!
* Create edge, either linear and quadratic (this is determed * Create edge, either linear and quadratic (this is determed
* by number of given nodes). * by number of given nodes).

View File

@ -31,8 +31,10 @@
<parameter name="fill_color" value="0, 170, 255"/> <parameter name="fill_color" value="0, 170, 255"/>
<parameter name="outline_color" value="0, 170, 255"/> <parameter name="outline_color" value="0, 170, 255"/>
<parameter name="backface_color" value="0, 0, 255"/> <parameter name="backface_color" value="0, 0, 255"/>
<parameter name="elem0d_color" value="0, 255, 0"/>
<parameter name="highlight_color" value="0, 255, 255"/> <parameter name="highlight_color" value="0, 255, 255"/>
<parameter name="node_size" value="3" /> <parameter name="node_size" value="3" />
<parameter name="elem0d_size" value="5" />
<parameter name="element_width" value="1" /> <parameter name="element_width" value="1" />
<parameter name="shrink_coeff" value="75"/> <parameter name="shrink_coeff" value="75"/>
<parameter name="orientation_color" value="255, 255, 255"/> <parameter name="orientation_color" value="255, 255, 255"/>

View File

@ -395,6 +395,16 @@ DriverMED_R_SMESHDS_Mesh
//MESSAGE("Try to create element # " << iElem << " with id = " //MESSAGE("Try to create element # " << iElem << " with id = "
// << aCellInfo->GetElemNum(iElem)); // << aCellInfo->GetElemNum(iElem));
switch(aGeom) { switch(aGeom) {
case ePOINT1:
//anElement = FindNode(myMesh,aNodeIds[0]);
if(anIsElemNum)
anElement = myMesh->Add0DElementWithID
(aNodeIds[0], aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->Add0DElement(FindNode(myMesh,aNodeIds[0]));
isRenum = anIsElemNum;
}
break;
case eSEG2: case eSEG2:
if(anIsElemNum) if(anIsElemNum)
anElement = myMesh->AddEdgeWithID(aNodeIds[0], anElement = myMesh->AddEdgeWithID(aNodeIds[0],
@ -680,11 +690,8 @@ DriverMED_R_SMESHDS_Mesh
isRenum = anIsElemNum; isRenum = anIsElemNum;
} }
break; break;
case ePOINT1:
anElement = FindNode(myMesh,aNodeIds[0]);
break;
} }
#ifndef _DEXCEPT_ #ifndef _DEXCEPT_
}catch(const std::exception& exc){ }catch(const std::exception& exc){
//INFOS("Follow exception was cought:\n\t"<<exc.what()); //INFOS("Follow exception was cought:\n\t"<<exc.what());

View File

@ -223,8 +223,9 @@ namespace{
//------------------------------------------------------- //-------------------------------------------------------
/*! /*!
* \brief Class helping to use either SMDS_EdgeIterator, SMDS_FaceIterator * \brief Class helping to use either SMDS_0DElementIterator,
* or SMDS_VolumeIterator in the same code * SMDS_EdgeIterator, SMDS_FaceIterator or SMDS_VolumeIterator
* in the same code
*/ */
//------------------------------------------------------- //-------------------------------------------------------
struct TElemIterator struct TElemIterator
@ -244,6 +245,7 @@ namespace{
else return 0; else return 0;
} }
}; };
typedef TypedElemIterator< SMDS_0DElementIteratorPtr > T0DElementIterator;
typedef TypedElemIterator< SMDS_EdgeIteratorPtr > TEdgeIterator; typedef TypedElemIterator< SMDS_EdgeIteratorPtr > TEdgeIterator;
typedef TypedElemIterator< SMDS_FaceIteratorPtr > TFaceIterator; typedef TypedElemIterator< SMDS_FaceIteratorPtr > TFaceIterator;
typedef TypedElemIterator< SMDS_VolumeIteratorPtr > TVolumeIterator; typedef TypedElemIterator< SMDS_VolumeIteratorPtr > TVolumeIterator;
@ -422,10 +424,12 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
// Storing SMDS groups and sub-meshes as med families // Storing SMDS groups and sub-meshes as med families
//---------------------------------------------------- //----------------------------------------------------
int myNodesDefaultFamilyId = 0; int myNodesDefaultFamilyId = 0;
int my0DElementsDefaultFamilyId = 0;
int myEdgesDefaultFamilyId = 0; int myEdgesDefaultFamilyId = 0;
int myFacesDefaultFamilyId = 0; int myFacesDefaultFamilyId = 0;
int myVolumesDefaultFamilyId = 0; int myVolumesDefaultFamilyId = 0;
int nbNodes = myMesh->NbNodes(); int nbNodes = myMesh->NbNodes();
int nb0DElements = myMesh->Nb0DElements();
int nbEdges = myMesh->NbEdges(); int nbEdges = myMesh->NbEdges();
int nbFaces = myMesh->NbFaces(); int nbFaces = myMesh->NbFaces();
int nbVolumes = myMesh->NbVolumes(); int nbVolumes = myMesh->NbVolumes();
@ -533,6 +537,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
list< TElemTypeData > aTElemTypeDatas; list< TElemTypeData > aTElemTypeDatas;
EEntiteMaillage anEntity = eMAILLE; EEntiteMaillage anEntity = eMAILLE;
#ifdef _ELEMENTS_BY_DIM_
anEntity = eNOEUD_ELEMENT;
#endif
aTElemTypeDatas.push_back(TElemTypeData(anEntity,
ePOINT1,
nbElemInfo.Nb0DElements(),
SMDSAbs_0DElement));
#ifdef _ELEMENTS_BY_DIM_ #ifdef _ELEMENTS_BY_DIM_
anEntity = eARETE; anEntity = eARETE;
#endif #endif
@ -635,6 +646,10 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
PElemIterator elemIterator; PElemIterator elemIterator;
int defaultFamilyId = 0; int defaultFamilyId = 0;
switch ( aElemTypeData->_smdsType ) { switch ( aElemTypeData->_smdsType ) {
case SMDSAbs_0DElement:
elemIterator = PElemIterator( new T0DElementIterator( myMesh->elements0dIterator() ));
defaultFamilyId = my0DElementsDefaultFamilyId;
break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
elemIterator = PElemIterator( new TEdgeIterator( myMesh->edgesIterator() )); elemIterator = PElemIterator( new TEdgeIterator( myMesh->edgesIterator() ));
defaultFamilyId = myEdgesDefaultFamilyId; defaultFamilyId = myEdgesDefaultFamilyId;

View File

@ -124,13 +124,14 @@ SMESH_ActorDef::SMESH_ActorDef()
if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) ) if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1); myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3); vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1); vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
VTKViewer_ExtractUnstructuredGrid* aFilter = NULL; VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
//Definition 2D and 3D divices of the actor //Definition 2D and 3D devices of the actor
//----------------------------------------- //-----------------------------------------
vtkFloatingPointType anRGB[3] = {1,1,1}; vtkFloatingPointType anRGB[3] = {1,1,1};
mySurfaceProp = vtkProperty::New(); mySurfaceProp = vtkProperty::New();
@ -194,7 +195,7 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//Definition 1D divice of the actor //Definition 1D device of the actor
//--------------------------------- //---------------------------------
myEdgeProp = vtkProperty::New(); myEdgeProp = vtkProperty::New();
myEdgeProp->SetAmbient(1.0); myEdgeProp->SetAmbient(1.0);
@ -242,8 +243,49 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
//Definition 0D divice of the actor //Definition 0D device of the actor (0d elements)
//--------------------------------- //-----------------------------------------------
my0DProp = vtkProperty::New();
SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
my0DProp->SetPointSize(aElem0DSize);
my0DActor = SMESH_DeviceActor::New();
my0DActor->SetUserMatrix(aMatrix);
my0DActor->SetStoreClippingMapping(true);
my0DActor->PickableOff();
my0DActor->SetVisibility(false);
my0DActor->SetProperty(my0DProp);
my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = my0DActor->GetExtractUnstructuredGrid();
//aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_VERTEX);
//my0DExtProp = vtkProperty::New();
//my0DExtProp->DeepCopy(my0DProp);
//anRGB[0] = 1 - anRGB[0];
//anRGB[1] = 1 - anRGB[1];
//anRGB[2] = 1 - anRGB[2];
//my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
//my0DExtProp->SetPointSize(aElem0DSize);
//
//my0DExtActor = SMESH_DeviceActor::New();
//my0DExtActor->SetUserMatrix(aMatrix);
//my0DExtActor->SetStoreClippingMapping(true);
//my0DExtActor->PickableOff();
//my0DExtActor->SetHighlited(true);
//my0DExtActor->SetVisibility(false);
//my0DExtActor->SetProperty(my0DExtProp);
//my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
//aFilter = my0DExtActor->GetExtractUnstructuredGrid();
////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
//aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
//aFilter->RegisterCellsWithType(VTK_VERTEX);
//Definition 0D device of the actor (nodes)
//-----------------------------------------
myNodeProp = vtkProperty::New(); myNodeProp = vtkProperty::New();
SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) ); SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
@ -295,7 +337,8 @@ SMESH_ActorDef::SMESH_ActorDef()
myHighlightProp->SetSpecular(0.0); myHighlightProp->SetSpecular(0.0);
SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
myHighlightProp->SetPointSize(aPointSize); //myHighlightProp->SetPointSize(aPointSize);
myHighlightProp->SetPointSize(std::max(aElem0DSize,aPointSize)); // ??
myHighlightProp->SetRepresentation(1); myHighlightProp->SetRepresentation(1);
myPreselectProp = vtkProperty::New(); myPreselectProp = vtkProperty::New();
@ -304,7 +347,8 @@ SMESH_ActorDef::SMESH_ActorDef()
myPreselectProp->SetSpecular(0.0); myPreselectProp->SetSpecular(0.0);
SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) ); SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
myPreselectProp->SetPointSize(aPointSize); //myPreselectProp->SetPointSize(aPointSize);
myPreselectProp->SetPointSize(std::max(aElem0DSize,aPointSize)); // ??
myPreselectProp->SetRepresentation(1); myPreselectProp->SetRepresentation(1);
myHighlitableActor = SMESH_DeviceActor::New(); myHighlitableActor = SMESH_DeviceActor::New();
@ -461,6 +505,12 @@ SMESH_ActorDef::~SMESH_ActorDef()
myNodeProp->Delete(); myNodeProp->Delete();
myNodeExtProp->Delete(); myNodeExtProp->Delete();
my0DProp->Delete();
my0DActor->Delete();
//my0DExtProp->Delete();
//my0DExtActor->Delete();
my1DProp->Delete(); my1DProp->Delete();
my1DActor->Delete(); my1DActor->Delete();
@ -479,7 +529,7 @@ SMESH_ActorDef::~SMESH_ActorDef()
myHighlitableActor->Delete(); myHighlitableActor->Delete();
//Deleting of pints numbering pipeline //Deleting of points numbering pipeline
//--------------------------------------- //---------------------------------------
myPointsNumDataSet->Delete(); myPointsNumDataSet->Delete();
@ -621,6 +671,7 @@ SetControlMode(eControl theMode,
myControlMode = eNone; myControlMode = eNone;
theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false ); theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
my0DActor->GetMapper()->SetScalarVisibility(false);
my1DActor->GetMapper()->SetScalarVisibility(false); my1DActor->GetMapper()->SetScalarVisibility(false);
my2DActor->GetMapper()->SetScalarVisibility(false); my2DActor->GetMapper()->SetScalarVisibility(false);
my3DActor->GetMapper()->SetScalarVisibility(false); my3DActor->GetMapper()->SetScalarVisibility(false);
@ -806,6 +857,9 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
theRenderer->AddActor(my1DActor); theRenderer->AddActor(my1DActor);
theRenderer->AddActor(my1DExtActor); theRenderer->AddActor(my1DExtActor);
theRenderer->AddActor(my0DActor);
//theRenderer->AddActor(my0DExtActor);
theRenderer->AddActor(myHighlitableActor); theRenderer->AddActor(myHighlitableActor);
theRenderer->AddActor2D(myScalarBarActor); theRenderer->AddActor2D(myScalarBarActor);
@ -827,6 +881,9 @@ void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
theRenderer->RemoveActor(myHighlitableActor); theRenderer->RemoveActor(myHighlitableActor);
theRenderer->RemoveActor(my0DActor);
//theRenderer->RemoveActor(my0DExtActor);
theRenderer->RemoveActor(my1DActor); theRenderer->RemoveActor(my1DActor);
theRenderer->RemoveActor(my1DExtActor); theRenderer->RemoveActor(my1DExtActor);
@ -859,6 +916,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
myNodeExtActor->Init(myVisualObj,myImplicitBoolean); myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->Init(myVisualObj,myImplicitBoolean);
//my0DExtActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->Init(myVisualObj,myImplicitBoolean); my1DActor->Init(myVisualObj,myImplicitBoolean);
my1DExtActor->Init(myVisualObj,myImplicitBoolean); my1DExtActor->Init(myVisualObj,myImplicitBoolean);
@ -866,6 +926,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
my2DExtActor->Init(myVisualObj,myImplicitBoolean); my2DExtActor->Init(myVisualObj,myImplicitBoolean);
my3DActor->Init(myVisualObj,myImplicitBoolean); my3DActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->GetMapper()->SetLookupTable(myLookupTable);
//my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my1DActor->GetMapper()->SetLookupTable(myLookupTable); my1DActor->GetMapper()->SetLookupTable(myLookupTable);
my1DExtActor->GetMapper()->SetLookupTable(myLookupTable); my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
@ -931,6 +994,9 @@ void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
myNodeExtActor->SetTransform(theTransform); myNodeExtActor->SetTransform(theTransform);
my0DActor->SetTransform(theTransform);
//my0DExtActor->SetTransform(theTransform);
my1DActor->SetTransform(theTransform); my1DActor->SetTransform(theTransform);
my1DExtActor->SetTransform(theTransform); my1DExtActor->SetTransform(theTransform);
@ -1060,6 +1126,9 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
myNodeExtActor->VisibilityOff(); myNodeExtActor->VisibilityOff();
my0DActor->VisibilityOff();
//my0DExtActor->VisibilityOff();
my1DActor->VisibilityOff(); my1DActor->VisibilityOff();
my1DExtActor->VisibilityOff(); my1DExtActor->VisibilityOff();
@ -1102,6 +1171,10 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
myNodeActor->VisibilityOn(); myNodeActor->VisibilityOn();
} }
if(myEntityMode & e0DElements){
my0DActor->VisibilityOn();
}
if(myEntityMode & eEdges){ if(myEntityMode & eEdges){
my1DActor->VisibilityOn(); my1DActor->VisibilityOn();
} }
@ -1127,25 +1200,34 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
} }
void SMESH_ActorDef::SetEntityMode(unsigned int theMode){ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
{
myEntityState = eAllEntity; myEntityState = eAllEntity;
if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){ if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
myEntityState &= ~e0DElements;
theMode &= ~e0DElements;
}
if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
myEntityState &= ~eEdges; myEntityState &= ~eEdges;
theMode &= ~eEdges; theMode &= ~eEdges;
} }
if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){ if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
myEntityState &= ~eFaces; myEntityState &= ~eFaces;
theMode &= ~eFaces; theMode &= ~eFaces;
} }
if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){ if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
myEntityState &= ~eVolumes; myEntityState &= ~eVolumes;
theMode &= ~eVolumes; theMode &= ~eVolumes;
} }
if(!theMode){ if (!theMode) {
if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
theMode |= e0DElements;
if(myVisualObj->GetNbEntities(SMDSAbs_Edge)) if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
theMode |= eEdges; theMode |= eEdges;
@ -1168,8 +1250,13 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
aHightFilter->ClearRegisteredCellsWithType(); aHightFilter->ClearRegisteredCellsWithType();
aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
if (myEntityMode & e0DElements) {
if (MYDEBUG) MESSAGE("0D ELEMENTS");
aFilter->RegisterCellsWithType(VTK_VERTEX);
aHightFilter->RegisterCellsWithType(VTK_VERTEX);
}
if(myEntityMode & eEdges){ if (myEntityMode & eEdges) {
if (MYDEBUG) MESSAGE("EDGES"); if (MYDEBUG) MESSAGE("EDGES");
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
@ -1178,7 +1265,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
} }
if(myEntityMode & eFaces){ if (myEntityMode & eFaces) {
if (MYDEBUG) MESSAGE("FACES"); if (MYDEBUG) MESSAGE("FACES");
aFilter->RegisterCellsWithType(VTK_TRIANGLE); aFilter->RegisterCellsWithType(VTK_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_POLYGON);
@ -1193,7 +1280,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
} }
if(myEntityMode & eVolumes){ if (myEntityMode & eVolumes) {
if (MYDEBUG) MESSAGE("VOLUMES"); if (MYDEBUG) MESSAGE("VOLUMES");
aFilter->RegisterCellsWithType(VTK_TETRA); aFilter->RegisterCellsWithType(VTK_TETRA);
aFilter->RegisterCellsWithType(VTK_VOXEL); aFilter->RegisterCellsWithType(VTK_VOXEL);
@ -1220,37 +1307,39 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
SetVisibility(GetVisibility(),false); SetVisibility(GetVisibility(),false);
} }
void SMESH_ActorDef::SetRepresentation(int theMode){ void SMESH_ActorDef::SetRepresentation (int theMode)
{
int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge); int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face); int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume); int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
if(theMode < 0){
if (theMode < 0) {
myRepresentation = eSurface; myRepresentation = eSurface;
if(!aNbFaces && !aNbVolumes && aNbEdges){ if (!aNbFaces && !aNbVolumes && aNbEdges) {
myRepresentation = eEdge; myRepresentation = eEdge;
}else if(!aNbFaces && !aNbVolumes && !aNbEdges){ } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
myRepresentation = ePoint; myRepresentation = ePoint;
} }
}else{ } else {
switch(theMode){ switch (theMode) {
case eEdge: case eEdge:
if(!aNbFaces && !aNbVolumes && !aNbEdges) return; if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
break; break;
case eSurface: case eSurface:
if(!aNbFaces && !aNbVolumes) return; if (!aNbFaces && !aNbVolumes) return;
break; break;
} }
myRepresentation = theMode; myRepresentation = theMode;
} }
if(!GetUnstructuredGrid()->GetNumberOfCells()) if (!GetUnstructuredGrid()->GetNumberOfCells())
myRepresentation = ePoint; myRepresentation = ePoint;
if(myIsShrunk){ if (myIsShrunk) {
if(myRepresentation == ePoint){ if (myRepresentation == ePoint) {
UnShrink(); UnShrink();
myIsShrunk = true; myIsShrunk = true;
}else{ } else {
SetShrink(); SetShrink();
} }
} }
@ -1261,7 +1350,7 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
vtkProperty *aProp = NULL, *aBackProp = NULL; vtkProperty *aProp = NULL, *aBackProp = NULL;
SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1); SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation(); SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
switch(myRepresentation){ switch (myRepresentation) {
case ePoint: case ePoint:
myPickableActor = myNodeActor; myPickableActor = myNodeActor;
myNodeActor->SetVisibility(true); myNodeActor->SetVisibility(true);
@ -1295,9 +1384,16 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
my3DActor->SetBackfaceProperty(aBackProp); my3DActor->SetBackfaceProperty(aBackProp);
my3DActor->SetRepresentation(aReperesent); my3DActor->SetRepresentation(aReperesent);
//my0DExtActor->SetVisibility(false);
my1DExtActor->SetVisibility(false); my1DExtActor->SetVisibility(false);
my2DExtActor->SetVisibility(false); my2DExtActor->SetVisibility(false);
// ???
//my0DActor->SetProperty(aProp);
//my0DActor->SetBackfaceProperty(aBackProp);
my0DActor->SetRepresentation(aReperesent);
//my0DExtActor->SetRepresentation(aReperesent);
switch(myControlMode){ switch(myControlMode){
case eLength: case eLength:
case eMultiConnection: case eMultiConnection:
@ -1312,7 +1408,6 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
else if(aQuadraticMode == SMESH_Actor::eArcs) else if(aQuadraticMode == SMESH_Actor::eArcs)
my1DActor->SetQuadraticArcMode(true); my1DActor->SetQuadraticArcMode(true);
my1DActor->SetProperty(aProp); my1DActor->SetProperty(aProp);
my1DActor->SetBackfaceProperty(aBackProp); my1DActor->SetBackfaceProperty(aBackProp);
my1DActor->SetRepresentation(aReperesent); my1DActor->SetRepresentation(aReperesent);
@ -1567,8 +1662,12 @@ void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){ void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
myNodeProp->SetPointSize(theVal); myNodeProp->SetPointSize(theVal);
myNodeExtProp->SetPointSize(theVal); myNodeExtProp->SetPointSize(theVal);
myHighlightProp->SetPointSize(theVal);
myPreselectProp->SetPointSize(theVal); vtkFloatingPointType aPointSize = my0DProp->GetPointSize() > theVal ? my0DProp->GetPointSize() : theVal;
//myHighlightProp->SetPointSize(theVal);
myHighlightProp->SetPointSize(aPointSize); // ??
//myPreselectProp->SetPointSize(theVal);
myPreselectProp->SetPointSize(aPointSize); // ??
my1DProp->SetPointSize(theVal + aPointSizeInc); my1DProp->SetPointSize(theVal + aPointSizeInc);
my1DExtProp->SetPointSize(theVal + aPointSizeInc); my1DExtProp->SetPointSize(theVal + aPointSizeInc);
@ -1593,8 +1692,7 @@ IsImplicitFunctionUsed() const
} }
void void
SMESH_ActorDef:: SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
{ {
myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
@ -1603,6 +1701,9 @@ SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
//my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
@ -1612,8 +1713,7 @@ SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
} }
vtkIdType vtkIdType
SMESH_ActorDef:: SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
AddClippingPlane(vtkPlane* thePlane)
{ {
if(thePlane){ if(thePlane){
myImplicitBoolean->GetFunction()->AddItem(thePlane); myImplicitBoolean->GetFunction()->AddItem(thePlane);

View File

@ -74,7 +74,7 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
enum EReperesent { ePoint, eEdge, eSurface}; enum EReperesent { ePoint, eEdge, eSurface};
enum EEntityMode { eEdges = 0x01, eFaces = 0x02, eVolumes = 0x04, eAllEntity = 0x07}; enum EEntityMode { e0DElements = 0x01, eEdges = 0x02, eFaces = 0x04, eVolumes = 0x08, eAllEntity = 0x0f};
enum EQuadratic2DRepresentation { eLines = 0x01, eArcs = 0x02 }; enum EQuadratic2DRepresentation { eLines = 0x01, eArcs = 0x02 };

View File

@ -233,6 +233,11 @@ class SMESH_ActorDef : public SMESH_Actor
vtkProperty* my1DExtProp; vtkProperty* my1DExtProp;
SMESH_DeviceActor* my1DExtActor; SMESH_DeviceActor* my1DExtActor;
vtkProperty* my0DProp;
SMESH_DeviceActor* my0DActor;
vtkProperty* my0DExtProp;
SMESH_DeviceActor* my0DExtActor;
unsigned int myEntityMode; unsigned int myEntityMode;
unsigned int myEntityState; unsigned int myEntityState;
bool myIsPointsVisible; bool myIsPointsVisible;

View File

@ -86,6 +86,9 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
{ {
switch( theType ) switch( theType )
{ {
case SMDSAbs_0DElement:
return VTK_VERTEX;
case SMDSAbs_Edge: case SMDSAbs_Edge:
if( theNbNodes == 2 ) return VTK_LINE; if( theNbNodes == 2 ) return VTK_LINE;
else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE; else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE;
@ -295,22 +298,23 @@ void SMESH_VisualObjDef::buildElemPrs()
// Calculate cells size // Calculate cells size
static SMDSAbs_ElementType aTypes[ 3 ] = { SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume }; static SMDSAbs_ElementType aTypes[ 4 ] =
{ SMDSAbs_0DElement, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume };
// get entity data // get entity data
map<SMDSAbs_ElementType,int> nbEnts; map<SMDSAbs_ElementType,int> nbEnts;
map<SMDSAbs_ElementType,TEntityList> anEnts; map<SMDSAbs_ElementType,TEntityList> anEnts;
for ( int i = 0; i <= 2; i++ ) for ( int i = 0; i <= 3; i++ )
nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] ); nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] );
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead, // PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
// so check remaining memory size for safety // so check remaining memory size for safety
SMDS_Mesh::CheckMemory(); // PAL16631 SMDS_Mesh::CheckMemory(); // PAL16631
vtkIdType aCellsSize = 3 * nbEnts[ SMDSAbs_Edge ]; vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ];
for ( int i = 1; i <= 2; i++ ) // iterate through faces and volumes for ( int i = 2; i <= 3; i++ ) // iterate through faces and volumes
{ {
if ( nbEnts[ aTypes[ i ] ] ) if ( nbEnts[ aTypes[ i ] ] )
{ {
@ -321,7 +325,8 @@ void SMESH_VisualObjDef::buildElemPrs()
} }
} }
vtkIdType aNbCells = nbEnts[ SMDSAbs_Edge ] + nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ]; vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize ); MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize );
@ -347,9 +352,9 @@ void SMESH_VisualObjDef::buildElemPrs()
SMDS_Mesh::CheckMemory(); // PAL16631 SMDS_Mesh::CheckMemory(); // PAL16631
for ( int i = 0; i <= 2; i++ ) // iterate through edges, faces and volumes for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes
{ {
if( nbEnts[ aTypes[ i ] ] > 0 ) if ( nbEnts[ aTypes[ i ] ] > 0 )
{ {
const SMDSAbs_ElementType& aType = aTypes[ i ]; const SMDSAbs_ElementType& aType = aTypes[ i ];
const TEntityList& aList = anEnts[ aType ]; const TEntityList& aList = anEnts[ aType ];
@ -367,7 +372,7 @@ void SMESH_VisualObjDef::buildElemPrs()
myVTK2SMDSElems.insert( TMapOfIds::value_type( iElem, anId ) ); myVTK2SMDSElems.insert( TMapOfIds::value_type( iElem, anId ) );
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
switch(aType){ switch (aType) {
case SMDSAbs_Volume:{ case SMDSAbs_Volume:{
aConnect.clear(); aConnect.clear();
std::vector<int> aConnectivities; std::vector<int> aConnectivities;
@ -568,6 +573,7 @@ int SMESH_MeshObj::GetElemDimension( const int theObjId )
int aType = anElem->GetType(); int aType = anElem->GetType();
switch ( aType ) switch ( aType )
{ {
case SMDSAbs_0DElement : return 0;
case SMDSAbs_Edge : return 1; case SMDSAbs_Edge : return 1;
case SMDSAbs_Face : return 2; case SMDSAbs_Face : return 2;
case SMDSAbs_Volume: return 3; case SMDSAbs_Volume: return 3;
@ -588,6 +594,11 @@ int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
return myClient->NbNodes(); return myClient->NbNodes();
} }
break; break;
case SMDSAbs_0DElement:
{
return myClient->Nb0DElements();
}
break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
{ {
return myClient->NbEdges(); return myClient->NbEdges();
@ -621,6 +632,12 @@ int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList&
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_0DElement:
{
SMDS_0DElementIteratorPtr anIter = myClient->elements0dIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
{ {
SMDS_EdgeIteratorPtr anIter = myClient->edgesIterator(); SMDS_EdgeIteratorPtr anIter = myClient->edgesIterator();
@ -882,6 +899,7 @@ int SMESH_subMeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
return mySubMeshServer->GetNumberOfNodes( false ); return mySubMeshServer->GetNumberOfNodes( false );
} }
break; break;
case SMDSAbs_0DElement:
case SMDSAbs_Edge: case SMDSAbs_Edge:
case SMDSAbs_Face: case SMDSAbs_Face:
case SMDSAbs_Volume: case SMDSAbs_Volume:

View File

@ -35,6 +35,7 @@ salomeinclude_HEADERS = \
SMDS_ElemIterator.hxx \ SMDS_ElemIterator.hxx \
SMDS_FacePosition.hxx \ SMDS_FacePosition.hxx \
SMDS_Mesh.hxx \ SMDS_Mesh.hxx \
SMDS_Mesh0DElement.hxx \
SMDS_MeshEdge.hxx \ SMDS_MeshEdge.hxx \
SMDS_MeshElement.hxx \ SMDS_MeshElement.hxx \
SMDS_MeshElementIDFactory.hxx \ SMDS_MeshElementIDFactory.hxx \
@ -76,6 +77,7 @@ dist_libSMDS_la_SOURCES = \
SMDS_SpacePosition.cxx \ SMDS_SpacePosition.cxx \
SMDS_VertexPosition.cxx \ SMDS_VertexPosition.cxx \
SMDS_MeshNode.cxx \ SMDS_MeshNode.cxx \
SMDS_Mesh0DElement.cxx \
SMDS_MeshEdge.cxx \ SMDS_MeshEdge.cxx \
SMDS_MeshFace.cxx \ SMDS_MeshFace.cxx \
SMDS_MeshVolume.cxx \ SMDS_MeshVolume.cxx \

View File

@ -33,6 +33,7 @@ enum SMDSAbs_ElementType
{ {
SMDSAbs_All, SMDSAbs_All,
SMDSAbs_Node, SMDSAbs_Node,
SMDSAbs_0DElement,
SMDSAbs_Edge, SMDSAbs_Edge,
SMDSAbs_Face, SMDSAbs_Face,
SMDSAbs_Volume, SMDSAbs_Volume,

View File

@ -22,9 +22,9 @@
// SMESH SMDS : implementaion of Salome mesh data structure // SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_MeshElement.hxx // File : SMDS_MeshElement.hxx
// Module : SMESH // Module : SMESH
// Created: 12.01.05 18:02:52 // Created: 12.01.05 18:02:52
// Author: Michael Sazonov // Author: Michael Sazonov
//
#ifndef SMDS_ElemIterator_HeaderFile #ifndef SMDS_ElemIterator_HeaderFile
#define SMDS_ElemIterator_HeaderFile #define SMDS_ElemIterator_HeaderFile
@ -33,6 +33,7 @@
class SMDS_MeshElement; class SMDS_MeshElement;
class SMDS_MeshNode; class SMDS_MeshNode;
class SMDS_Mesh0DElement;
class SMDS_MeshEdge; class SMDS_MeshEdge;
class SMDS_MeshFace; class SMDS_MeshFace;
class SMDS_MeshVolume; class SMDS_MeshVolume;
@ -43,6 +44,9 @@ typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIte
typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator; typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr; typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
typedef SMDS_Iterator<const SMDS_Mesh0DElement *> SMDS_0DElementIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_Mesh0DElement *> > SMDS_0DElementIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator; typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr; typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr;

View File

@ -20,7 +20,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// SMESH SMDS : implementaion of Salome mesh data structure // SMESH SMDS : implementaion of Salome mesh data structure
//
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif
@ -166,6 +166,52 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
return NULL; return NULL;
} }
///////////////////////////////////////////////////////////////////////////////
/// create a Mesh0DElement and add it to the current Mesh
/// @return : The created Mesh0DElement
///////////////////////////////////////////////////////////////////////////////
SMDS_Mesh0DElement* SMDS_Mesh::Add0DElementWithID(int idnode, int ID)
{
SMDS_MeshNode * node = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode);
if (!node) return NULL;
return SMDS_Mesh::Add0DElementWithID(node, ID);
}
///////////////////////////////////////////////////////////////////////////////
/// create a Mesh0DElement and add it to the current Mesh
/// @return : The created Mesh0DElement
///////////////////////////////////////////////////////////////////////////////
SMDS_Mesh0DElement* SMDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
{
return SMDS_Mesh::Add0DElementWithID(node, myElementIDFactory->GetFreeID());
}
///////////////////////////////////////////////////////////////////////////////
/// Create a new Mesh0DElement and at it to the mesh
/// @param idnode ID of the node
/// @param ID ID of the 0D element to create
/// @return The created 0D element or NULL if an element with this
/// ID already exists or if input node is not found.
///////////////////////////////////////////////////////////////////////////////
SMDS_Mesh0DElement* SMDS_Mesh::Add0DElementWithID(const SMDS_MeshNode * n, int ID)
{
if (!n) return 0;
if (my0DElements.Extent() % CHECKMEMORY_INTERVAL == 0) CheckMemory();
SMDS_Mesh0DElement * el0d = new SMDS_Mesh0DElement(n);
if (myElementIDFactory->BindID(ID, el0d)) {
SMDS_MeshNode *node = const_cast<SMDS_MeshNode*>(n);
node->AddInverseElement(el0d);
my0DElements.Add(el0d);
myInfo.myNb0DElements++;
return el0d;
}
delete el0d;
return NULL;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// create a MeshEdge and add it to the current Mesh /// create a MeshEdge and add it to the current Mesh
/// @return : The created MeshEdge /// @return : The created MeshEdge
@ -1121,6 +1167,15 @@ void SMDS_Mesh::RemoveNode(const SMDS_MeshNode * node)
/// Remove an edge and all the elements which own this edge /// Remove an edge and all the elements which own this edge
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::Remove0DElement(const SMDS_Mesh0DElement * elem0d)
{
RemoveElement(elem0d,true);
}
///////////////////////////////////////////////////////////////////////////////
/// Remove an edge and all the elements which own this edge
///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge) void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge)
{ {
RemoveElement(edge,true); RemoveElement(edge,true);
@ -1201,6 +1256,11 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * element,
SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(element); SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(element);
switch ( elem->GetType() ) switch ( elem->GetType() )
{ {
case SMDSAbs_0DElement: {
if ( SMDS_Mesh0DElement* elem0d = dynamic_cast<SMDS_Mesh0DElement*>( elem ))
Ok = elem0d->ChangeNode( nodes[0] );
break;
}
case SMDSAbs_Edge: { case SMDSAbs_Edge: {
if ( nbnodes == 2 ) { if ( nbnodes == 2 ) {
if ( SMDS_MeshEdge* edge = dynamic_cast<SMDS_MeshEdge*>( elem )) if ( SMDS_MeshEdge* edge = dynamic_cast<SMDS_MeshEdge*>( elem ))
@ -1322,6 +1382,50 @@ bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem,
} }
//=======================================================================
//function : Find0DElement
//purpose :
//=======================================================================
const SMDS_Mesh0DElement* SMDS_Mesh::Find0DElement(int idnode) const
{
const SMDS_MeshNode * node = FindNode(idnode);
if(node == NULL) return NULL;
return Find0DElement(node);
}
const SMDS_Mesh0DElement* SMDS_Mesh::Find0DElement(const SMDS_MeshNode * node)
{
if (!node) return 0;
const SMDS_Mesh0DElement* toReturn = NULL;
SMDS_ElemIteratorPtr it1 = node->GetInverseElementIterator(SMDSAbs_0DElement);
while (it1->more() && (toReturn == NULL)) {
const SMDS_MeshElement* e = it1->next();
if (e->NbNodes() == 1) {
toReturn = static_cast<const SMDS_Mesh0DElement*>(e);
}
}
return toReturn;
}
//=======================================================================
//function : Find0DElementOrCreate
//purpose :
//=======================================================================
SMDS_Mesh0DElement* SMDS_Mesh::Find0DElementOrCreate(const SMDS_MeshNode * node)
{
if (!node) return 0;
SMDS_Mesh0DElement * toReturn = NULL;
toReturn = const_cast<SMDS_Mesh0DElement*>(Find0DElement(node));
if (toReturn == NULL) {
if (my0DElements.Extent() % CHECKMEMORY_INTERVAL == 0) CheckMemory();
toReturn = new SMDS_Mesh0DElement(node);
my0DElements.Add(toReturn);
myInfo.myNb0DElements++;
}
return toReturn;
}
//======================================================================= //=======================================================================
//function : FindEdge //function : FindEdge
//purpose : //purpose :
@ -1666,6 +1770,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<int> nodes_ids) const
for (int inode = 0; inode < nbnodes; inode++) { for (int inode = 0; inode < nbnodes; inode++) {
const SMDS_MeshNode * node = FindNode(nodes_ids[inode]); const SMDS_MeshNode * node = FindNode(nodes_ids[inode]);
if (node == NULL) return NULL; if (node == NULL) return NULL;
poly_nodes[inode] = node;
} }
return FindFace(poly_nodes); return FindFace(poly_nodes);
} }
@ -1704,6 +1809,17 @@ void SMDS_Mesh::DumpNodes() const
while(itnode->more()) MESSAGE(itnode->next()); while(itnode->more()) MESSAGE(itnode->next());
} }
//=======================================================================
//function : Dump0DElements
//purpose :
//=======================================================================
void SMDS_Mesh::Dump0DElements() const
{
MESSAGE("dump 0D elements of mesh : ");
SMDS_0DElementIteratorPtr it0d = elements0dIterator();
while(it0d->more()) MESSAGE(it0d->next());
}
//======================================================================= //=======================================================================
//function : DumpEdges //function : DumpEdges
//purpose : //purpose :
@ -1750,6 +1866,7 @@ void SMDS_Mesh::DebugStats() const
MESSAGE("Debug stats of mesh : "); MESSAGE("Debug stats of mesh : ");
MESSAGE("===== NODES ====="<<NbNodes()); MESSAGE("===== NODES ====="<<NbNodes());
MESSAGE("===== 0DELEMS ====="<<Nb0DElements());
MESSAGE("===== EDGES ====="<<NbEdges()); MESSAGE("===== EDGES ====="<<NbEdges());
MESSAGE("===== FACES ====="<<NbFaces()); MESSAGE("===== FACES ====="<<NbFaces());
MESSAGE("===== VOLUMES ====="<<NbVolumes()); MESSAGE("===== VOLUMES ====="<<NbVolumes());
@ -1798,6 +1915,14 @@ int SMDS_Mesh::NbNodes() const
return myNodes.Size(); return myNodes.Size();
} }
///////////////////////////////////////////////////////////////////////////////
/// Return the number of 0D elements
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::Nb0DElements() const
{
return my0DElements.Size();
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Return the number of edges (including construction edges) /// Return the number of edges (including construction edges)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -1859,10 +1984,18 @@ SMDS_Mesh::~SMDS_Mesh()
while (itn->more()) while (itn->more())
myNodeIDFactory->ReleaseID(itn->next()->GetID()); myNodeIDFactory->ReleaseID(itn->next()->GetID());
} }
SetOfNodes::Iterator itn(myNodes); SetOfNodes::Iterator itn(myNodes);
for (; itn.More(); itn.Next()) for (; itn.More(); itn.Next())
delete itn.Value(); delete itn.Value();
SetOf0DElements::Iterator it0d (my0DElements);
for (; it0d.More(); it0d.Next())
{
SMDS_MeshElement* elem = it0d.Value();
delete elem;
}
SetOfEdges::Iterator ite(myEdges); SetOfEdges::Iterator ite(myEdges);
for (; ite.More(); ite.Next()) for (; ite.More(); ite.Next())
{ {
@ -1883,7 +2016,6 @@ SMDS_Mesh::~SMDS_Mesh()
SMDS_MeshElement* elem = itv.Value(); SMDS_MeshElement* elem = itv.Value();
delete elem; delete elem;
} }
} }
//================================================================================ //================================================================================
@ -1921,6 +2053,11 @@ void SMDS_Mesh::Clear()
delete ite->next(); delete ite->next();
myEdges.Clear(); myEdges.Clear();
SMDS_0DElementIteratorPtr it0d = elements0dIterator();
while (it0d->more())
delete it0d->next();
my0DElements.Clear();
SMDS_NodeIteratorPtr itn = nodesIterator(); SMDS_NodeIteratorPtr itn = nodesIterator();
while (itn->more()) while (itn->more())
delete itn->next(); delete itn->next();
@ -2048,6 +2185,17 @@ struct MYNCollection_Map_Iterator: public FATHER
} }
}; };
///////////////////////////////////////////////////////////////////////////////
///Return an iterator on 0D elements of the current mesh.
///////////////////////////////////////////////////////////////////////////////
SMDS_0DElementIteratorPtr SMDS_Mesh::elements0dIterator() const
{
typedef MYNCollection_Map_Iterator
< SetOf0DElements, const SMDS_Mesh0DElement*, SMDS_0DElementIterator > TIterator;
return SMDS_0DElementIteratorPtr(new TIterator(my0DElements));
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
///Return an iterator on edges of the current mesh. ///Return an iterator on edges of the current mesh.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2095,6 +2243,8 @@ SMDS_ElemIteratorPtr SMDS_Mesh::elementsIterator(SMDSAbs_ElementType type) const
return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfFaces >(myFaces)); return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfFaces >(myFaces));
case SMDSAbs_Edge: case SMDSAbs_Edge:
return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfEdges >(myEdges)); return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfEdges >(myEdges));
case SMDSAbs_0DElement:
return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOf0DElements >(my0DElements));
case SMDSAbs_Node: case SMDSAbs_Node:
return myNodeIDFactory->elementsIterator(); return myNodeIDFactory->elementsIterator();
default:; default:;
@ -2184,16 +2334,20 @@ static set<const SMDS_MeshElement*> * getExclusiveNodes(
///@param element The element were to search matching children ///@param element The element were to search matching children
///@param nodes The nodes that the children must have to be selected ///@param nodes The nodes that the children must have to be selected
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren, void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren,
const SMDS_MeshElement * element, set<const SMDS_MeshElement*>& nodes) const SMDS_MeshElement * element,
set<const SMDS_MeshElement*>& nodes)
{ {
switch(element->GetType())
switch(element->GetType()) {
{ case SMDSAbs_Node:
case SMDSAbs_Node: MESSAGE("Internal Error: This should not happend");
MESSAGE("Internal Error: This should not append"); break;
break; case SMDSAbs_0DElement:
case SMDSAbs_Edge: {
}
break;
case SMDSAbs_Edge:
{ {
SMDS_ElemIteratorPtr itn=element->nodesIterator(); SMDS_ElemIteratorPtr itn=element->nodesIterator();
while(itn->more()) while(itn->more())
@ -2206,7 +2360,7 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren
} }
} }
} break; } break;
case SMDSAbs_Face: case SMDSAbs_Face:
{ {
SMDS_ElemIteratorPtr itn=element->nodesIterator(); SMDS_ElemIteratorPtr itn=element->nodesIterator();
while(itn->more()) while(itn->more())
@ -2225,7 +2379,7 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren
addChildrenWithNodes(setOfChildren, ite->next(), nodes); addChildrenWithNodes(setOfChildren, ite->next(), nodes);
} }
} break; } break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
{ {
if(hasConstructionFaces()) if(hasConstructionFaces())
{ {
@ -2240,7 +2394,7 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren
addChildrenWithNodes(setOfChildren, ite->next(), nodes); addChildrenWithNodes(setOfChildren, ite->next(), nodes);
} }
} }
} }
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2248,7 +2402,7 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren
///@param removenodes if true remaining nodes will be removed ///@param removenodes if true remaining nodes will be removed
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
const bool removenodes) const bool removenodes)
{ {
list<const SMDS_MeshElement *> removedElems; list<const SMDS_MeshElement *> removedElems;
list<const SMDS_MeshElement *> removedNodes; list<const SMDS_MeshElement *> removedNodes;
@ -2268,8 +2422,9 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
{ {
// get finite elements built on elem // get finite elements built on elem
set<const SMDS_MeshElement*> * s1; set<const SMDS_MeshElement*> * s1;
if (!hasConstructionEdges() && elem->GetType() == SMDSAbs_Edge || if (elem->GetType() == SMDSAbs_0DElement ||
!hasConstructionFaces() && elem->GetType() == SMDSAbs_Face || elem->GetType() == SMDSAbs_Edge && !hasConstructionEdges() ||
elem->GetType() == SMDSAbs_Face && !hasConstructionFaces() ||
elem->GetType() == SMDSAbs_Volume) elem->GetType() == SMDSAbs_Volume)
{ {
s1 = new set<const SMDS_MeshElement*>(); s1 = new set<const SMDS_MeshElement*>();
@ -2319,6 +2474,12 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
case SMDSAbs_Node: case SMDSAbs_Node:
MESSAGE("Internal Error: This should not happen"); MESSAGE("Internal Error: This should not happen");
break; break;
case SMDSAbs_0DElement:
my0DElements.Remove(static_cast<SMDS_Mesh0DElement*>
(const_cast<SMDS_MeshElement*>(*it)));
//myInfo.Remove0DElement(*it);
myInfo.remove(*it);
break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
myEdges.Remove(static_cast<SMDS_MeshEdge*> myEdges.Remove(static_cast<SMDS_MeshEdge*>
(const_cast<SMDS_MeshElement*>(*it))); (const_cast<SMDS_MeshElement*>(*it)));
@ -2395,6 +2556,12 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
// in meshes without descendants elements are always free // in meshes without descendants elements are always free
switch (aType) { switch (aType) {
case SMDSAbs_0DElement:
my0DElements.Remove(static_cast<SMDS_Mesh0DElement*>
(const_cast<SMDS_MeshElement*>(elem)));
//myInfo.Remove0DElement(elem);
myInfo.remove(elem);
break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
myEdges.Remove(static_cast<SMDS_MeshEdge*> myEdges.Remove(static_cast<SMDS_MeshEdge*>
(const_cast<SMDS_MeshElement*>(elem))); (const_cast<SMDS_MeshElement*>(elem)));
@ -2430,6 +2597,10 @@ bool SMDS_Mesh::Contains (const SMDS_MeshElement* elem) const
while (itn->more()) while (itn->more())
if (elem == itn->next()) if (elem == itn->next())
return true; return true;
SMDS_0DElementIteratorPtr it0d = elements0dIterator();
while (it0d->more())
if (elem == it0d->next())
return true;
SMDS_EdgeIteratorPtr ite = edgesIterator(); SMDS_EdgeIteratorPtr ite = edgesIterator();
while (ite->more()) while (ite->more())
if (elem == ite->next()) if (elem == ite->next())

View File

@ -22,13 +22,14 @@
// SMESH SMDS : implementaion of Salome mesh data structure // SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_Mesh.hxx // File : SMDS_Mesh.hxx
// Module : SMESH // Module : SMESH
//
#ifndef _SMDS_Mesh_HeaderFile #ifndef _SMDS_Mesh_HeaderFile
#define _SMDS_Mesh_HeaderFile #define _SMDS_Mesh_HeaderFile
#include "SMESH_SMDS.hxx" #include "SMESH_SMDS.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_MeshEdge.hxx" #include "SMDS_MeshEdge.hxx"
#include "SMDS_MeshFace.hxx" #include "SMDS_MeshFace.hxx"
#include "SMDS_MeshVolume.hxx" #include "SMDS_MeshVolume.hxx"
@ -47,6 +48,7 @@ public:
SMDS_Mesh(); SMDS_Mesh();
SMDS_NodeIteratorPtr nodesIterator() const; SMDS_NodeIteratorPtr nodesIterator() const;
SMDS_0DElementIteratorPtr elements0dIterator() const;
SMDS_EdgeIteratorPtr edgesIterator() const; SMDS_EdgeIteratorPtr edgesIterator() const;
SMDS_FaceIteratorPtr facesIterator() const; SMDS_FaceIteratorPtr facesIterator() const;
SMDS_VolumeIteratorPtr volumesIterator() const; SMDS_VolumeIteratorPtr volumesIterator() const;
@ -59,6 +61,10 @@ public:
virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID); virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
virtual SMDS_MeshNode* AddNode(double x, double y, double z); virtual SMDS_MeshNode* AddNode(double x, double y, double z);
virtual SMDS_Mesh0DElement* Add0DElementWithID(int n, int ID);
virtual SMDS_Mesh0DElement* Add0DElementWithID(const SMDS_MeshNode * n, int ID);
virtual SMDS_Mesh0DElement* Add0DElement (const SMDS_MeshNode * n);
virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID); virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1, virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2, const SMDS_MeshNode * n2,
@ -419,6 +425,7 @@ public:
const bool removenodes = false); const bool removenodes = false);
virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false); virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
virtual void RemoveNode(const SMDS_MeshNode * node); virtual void RemoveNode(const SMDS_MeshNode * node);
virtual void Remove0DElement(const SMDS_Mesh0DElement * elem0d);
virtual void RemoveEdge(const SMDS_MeshEdge * edge); virtual void RemoveEdge(const SMDS_MeshEdge * edge);
virtual void RemoveFace(const SMDS_MeshFace * face); virtual void RemoveFace(const SMDS_MeshFace * face);
virtual void RemoveVolume(const SMDS_MeshVolume * volume); virtual void RemoveVolume(const SMDS_MeshVolume * volume);
@ -445,6 +452,7 @@ public:
// Renumber all nodes or elements. // Renumber all nodes or elements.
const SMDS_MeshNode *FindNode(int idnode) const; const SMDS_MeshNode *FindNode(int idnode) const;
const SMDS_Mesh0DElement* Find0DElement(int idnode) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const; const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const; const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const; const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
@ -454,6 +462,7 @@ public:
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4, const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8) const; int idnode5, int idnode6, int idnode7, int idnode8) const;
const SMDS_MeshElement *FindElement(int IDelem) const; const SMDS_MeshElement *FindElement(int IDelem) const;
static const SMDS_Mesh0DElement* Find0DElement(const SMDS_MeshNode * n);
static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1, static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2); const SMDS_MeshNode * n2);
static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1, static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
@ -499,11 +508,13 @@ public:
const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; } const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
int NbNodes() const; int NbNodes() const;
int Nb0DElements() const;
int NbEdges() const; int NbEdges() const;
int NbFaces() const; int NbFaces() const;
int NbVolumes() const; int NbVolumes() const;
int NbSubMesh() const; int NbSubMesh() const;
void DumpNodes() const; void DumpNodes() const;
void Dump0DElements() const;
void DumpEdges() const; void DumpEdges() const;
void DumpFaces() const; void DumpFaces() const;
void DumpVolumes() const; void DumpVolumes() const;
@ -527,6 +538,7 @@ public:
bool Contains (const SMDS_MeshElement* elem) const; bool Contains (const SMDS_MeshElement* elem) const;
typedef NCollection_Map<SMDS_MeshNode *> SetOfNodes; typedef NCollection_Map<SMDS_MeshNode *> SetOfNodes;
typedef NCollection_Map<SMDS_Mesh0DElement *> SetOf0DElements;
typedef NCollection_Map<SMDS_MeshEdge *> SetOfEdges; typedef NCollection_Map<SMDS_MeshEdge *> SetOfEdges;
typedef NCollection_Map<SMDS_MeshFace *> SetOfFaces; typedef NCollection_Map<SMDS_MeshFace *> SetOfFaces;
typedef NCollection_Map<SMDS_MeshVolume *> SetOfVolumes; typedef NCollection_Map<SMDS_MeshVolume *> SetOfVolumes;
@ -541,6 +553,7 @@ private:
const SMDS_MeshNode * node2, const SMDS_MeshNode * node2,
const SMDS_MeshNode * node3, const SMDS_MeshNode * node3,
const SMDS_MeshNode * node4); const SMDS_MeshNode * node4);
SMDS_Mesh0DElement* Find0DElementOrCreate(const SMDS_MeshNode * n);
SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1, SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2); const SMDS_MeshNode * n2);
SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1, SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
@ -560,6 +573,7 @@ private:
// Fields PRIVATE // Fields PRIVATE
SetOfNodes myNodes; SetOfNodes myNodes;
SetOf0DElements my0DElements;
SetOfEdges myEdges; SetOfEdges myEdges;
SetOfFaces myFaces; SetOfFaces myFaces;
SetOfVolumes myVolumes; SetOfVolumes myVolumes;

View File

@ -0,0 +1,155 @@
// Copyright (C) 2007-2008 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
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_Mesh0DElement.cxx
// Author : Jean-Michel BOULCOURT
// Module : SMESH
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
using namespace std;
//=======================================================================
//function : SMDS_Mesh0DElement
//purpose :
//=======================================================================
SMDS_Mesh0DElement::SMDS_Mesh0DElement (const SMDS_MeshNode * node)
{
myNode = node;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_Mesh0DElement::Print (ostream & OS) const
{
OS << "0D Element <" << GetID() << "> : (" << myNode << ") " << endl;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_Mesh0DElement::NbNodes() const
{
return 1;
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_Mesh0DElement::NbEdges() const
{
return 0;
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
SMDSAbs_ElementType SMDS_Mesh0DElement::GetType() const
{
return SMDSAbs_0DElement;
}
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
class SMDS_Mesh0DElement_MyNodeIterator: public SMDS_ElemIterator
{
const SMDS_MeshNode * myNode;
int myIndex;
public:
SMDS_Mesh0DElement_MyNodeIterator(const SMDS_MeshNode * node):
myNode(node),myIndex(0) {}
bool more()
{
return myIndex < 1;
}
const SMDS_MeshElement* next()
{
myIndex++;
if (myIndex == 1)
return myNode;
return NULL;
}
};
SMDS_ElemIteratorPtr SMDS_Mesh0DElement::elementsIterator (SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_0DElement:
return SMDS_MeshElement::elementsIterator(SMDSAbs_0DElement);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_Mesh0DElement_MyNodeIterator(myNode));
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type, SMDS_ElemIteratorPtr(new SMDS_Mesh0DElement_MyNodeIterator(myNode))));
}
}
//=======================================================================
//function : operator<
//purpose :
//=======================================================================
bool operator< (const SMDS_Mesh0DElement & e1, const SMDS_Mesh0DElement & e2)
{
int id1 = e1.myNode->GetID();
int id2 = e2.myNode->GetID();
return (id1 < id2);
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode* SMDS_Mesh0DElement::GetNode(const int ind) const
{
if (ind == 0)
return myNode;
return NULL;
}
//=======================================================================
//function : ChangeNode
//purpose :
//=======================================================================
bool SMDS_Mesh0DElement::ChangeNode (const SMDS_MeshNode * node)
{
myNode = node;
return true;
}

View File

@ -0,0 +1,61 @@
// Copyright (C) 2007-2008 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
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_Mesh0DElement.hxx
// Module : SMESH
#ifndef _SMDS_Mesh0DElement_HeaderFile
#define _SMDS_Mesh0DElement_HeaderFile
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include <iostream>
class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshElement
{
public:
SMDS_Mesh0DElement (const SMDS_MeshNode * node);
bool ChangeNode (const SMDS_MeshNode * node);
void Print (std::ostream & OS) const;
SMDSAbs_ElementType GetType() const;
int NbNodes() const;
int NbEdges() const;
friend bool operator< (const SMDS_Mesh0DElement& e1, const SMDS_Mesh0DElement& e2);
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode (const int ind) const;
protected:
SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
protected:
const SMDS_MeshNode* myNode;
};
#endif

View File

@ -42,6 +42,7 @@ public:
int NbNodes() const { return myNbNodes; } int NbNodes() const { return myNbNodes; }
inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const; inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
int Nb0DElements() const { return myNb0DElements; }
inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const; inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const;
inline int NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const; inline int NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const;
inline int NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const; inline int NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const;
@ -69,6 +70,7 @@ private:
int myNbNodes; int myNbNodes;
int myNb0DElements;
int myNbEdges , myNbQuadEdges ; int myNbEdges , myNbQuadEdges ;
int myNbTriangles , myNbQuadTriangles ; int myNbTriangles , myNbQuadTriangles ;
int myNbQuadrangles, myNbQuadQuadrangles; int myNbQuadrangles, myNbQuadQuadrangles;
@ -86,6 +88,7 @@ private:
inline SMDS_MeshInfo::SMDS_MeshInfo(): inline SMDS_MeshInfo::SMDS_MeshInfo():
myNbNodes(0), myNbNodes(0),
myNb0DElements(0),
myNbEdges (0), myNbQuadEdges (0), myNbEdges (0), myNbQuadEdges (0),
myNbTriangles (0), myNbQuadTriangles (0), myNbTriangles (0), myNbQuadTriangles (0),
myNbQuadrangles(0), myNbQuadQuadrangles(0), myNbQuadrangles(0), myNbQuadQuadrangles(0),
@ -97,12 +100,12 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
myNbPolyhedrons(0) myNbPolyhedrons(0)
{ {
// Number of nodes in standard element types // Number of nodes in standard element types
// n v f e // n v f e 0
// o o a d // o o a d d
// d l c g // d l c g
// e e e // e e e
// ----------- // --------------
// 1 // 1 *
// 2 * // 2 *
// 3 * // 3 *
// 4 * * * // 4 * * *
@ -131,6 +134,8 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL); myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL);
myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes; myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes;
myNb[ index( SMDSAbs_0DElement,1 )] = & myNb0DElements;
myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges; myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges; myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges;

View File

@ -1192,6 +1192,18 @@ int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
*/ */
//================================================================================ //================================================================================
int SMESH_Mesh::Nb0DElements() throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
return _myMeshDS->GetMeshInfo().Nb0DElements();
}
//================================================================================
/*!
* \brief Return number of edges of given order in the mesh
*/
//================================================================================
int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception) int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);

View File

@ -202,6 +202,8 @@ public:
int NbNodes() throw(SALOME_Exception); int NbNodes() throw(SALOME_Exception);
int Nb0DElements() throw(SALOME_Exception);
int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);

View File

@ -103,6 +103,28 @@ namespace
} }
//=======================================================================
//function : Add0DElementsWithID
//=======================================================================
inline void Add0DElementsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if (2*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 2*aNbElems != aCoords.length()");
CORBA::Long anIndexId = 0;
for (; anElemId < aNbElems; anElemId++, anIndexId+=2)
{
SMDS_MeshElement* anElem = theMesh->Add0DElementWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId]);
if (!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot Add0DElementWithID for ID = "<<anElemId);
}
}
//======================================================================= //=======================================================================
//function : AddEdgesWithID //function : AddEdgesWithID
//======================================================================= //=======================================================================
@ -708,6 +730,7 @@ SMESH_Client::Update(bool theIsClear)
switch(aCommand) switch(aCommand)
{ {
case SMESH::ADD_NODE : AddNodesWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_NODE : AddNodesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_ELEM0D : Add0DElementsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_EDGE : AddEdgesWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_EDGE : AddEdgesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_TRIANGLE : AddTriasWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_TRIANGLE : AddTriasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( mySMDSMesh, aSeq, anId ); break; case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( mySMDSMesh, aSeq, anId ); break;
@ -796,6 +819,7 @@ SMESH_Client::Update(bool theIsClear)
if ( MYDEBUG && mySMDSMesh ) if ( MYDEBUG && mySMDSMesh )
{ {
MESSAGE("Update - mySMDSMesh->NbNodes() = "<<mySMDSMesh->NbNodes()); MESSAGE("Update - mySMDSMesh->NbNodes() = "<<mySMDSMesh->NbNodes());
MESSAGE("Update - mySMDSMesh->Nb0DElements() = "<<mySMDSMesh->Nb0DElements());
MESSAGE("Update - mySMDSMesh->NbEdges() = "<<mySMDSMesh->NbEdges()); MESSAGE("Update - mySMDSMesh->NbEdges() = "<<mySMDSMesh->NbEdges());
MESSAGE("Update - mySMDSMesh->NbFaces() = "<<mySMDSMesh->NbFaces()); MESSAGE("Update - mySMDSMesh->NbFaces() = "<<mySMDSMesh->NbFaces());
MESSAGE("Update - mySMDSMesh->NbVolumes() = "<<mySMDSMesh->NbVolumes()); MESSAGE("Update - mySMDSMesh->NbVolumes() = "<<mySMDSMesh->NbVolumes());

View File

@ -84,6 +84,22 @@ void SMESHDS_Command::MoveNode(int NodeID, double x, double y, double z)
myNumber++; myNumber++;
} }
//=======================================================================
//function :
//purpose :
//=======================================================================
void SMESHDS_Command::Add0DElement(int New0DElementID, int idnode)
{
if (!myType == SMESHDS_Add0DElement)
{
MESSAGE("SMESHDS_Command::Add0DElement : Bad Type");
return;
}
myIntegers.push_back(New0DElementID);
myIntegers.push_back(idnode);
myNumber++;
}
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :

View File

@ -38,6 +38,7 @@ class SMESHDS_EXPORT SMESHDS_Command
public: public:
SMESHDS_Command(const SMESHDS_CommandType aType); SMESHDS_Command(const SMESHDS_CommandType aType);
void AddNode(int NewNodeID, double x, double y, double z); void AddNode(int NewNodeID, double x, double y, double z);
void Add0DElement(int New0DElementID, int idnode);
void AddEdge(int NewEdgeID, int idnode1, int idnode2); void AddEdge(int NewEdgeID, int idnode1, int idnode2);
void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3); void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3);
void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3, void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3,

View File

@ -30,6 +30,7 @@
enum SMESHDS_CommandType { enum SMESHDS_CommandType {
SMESHDS_AddNode, SMESHDS_AddNode,
SMESHDS_Add0DElement,
SMESHDS_AddEdge, SMESHDS_AddEdge,
SMESHDS_AddTriangle, SMESHDS_AddTriangle,
SMESHDS_AddQuadrangle, SMESHDS_AddQuadrangle,

View File

@ -248,6 +248,30 @@ void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int de
myScript->Renumber( isNodes, startID, deltaID ); myScript->Renumber( isNodes, startID, deltaID );
} }
//=======================================================================
//function : Add0DElement
//purpose :
//=======================================================================
SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
{
SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
if (anElem) myScript->Add0DElement(ID, nodeID);
return anElem;
}
SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
(const SMDS_MeshNode * node, int ID)
{
return Add0DElementWithID(node->GetID(), ID);
}
SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
{
SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
return anElem;
}
//======================================================================= //=======================================================================
//function :AddEdgeWithID //function :AddEdgeWithID
//purpose : //purpose :

View File

@ -30,6 +30,7 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_MeshEdge.hxx" #include "SMDS_MeshEdge.hxx"
#include "SMDS_MeshFace.hxx" #include "SMDS_MeshFace.hxx"
#include "SMDS_MeshVolume.hxx" #include "SMDS_MeshVolume.hxx"
@ -66,7 +67,11 @@ public:
bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H); bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID); virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
virtual SMDS_MeshNode * AddNode(double x, double y, double z); virtual SMDS_MeshNode* AddNode(double x, double y, double z);
virtual SMDS_Mesh0DElement* Add0DElementWithID(int nodeID, int ID);
virtual SMDS_Mesh0DElement* Add0DElementWithID(const SMDS_MeshNode * node, int ID);
virtual SMDS_Mesh0DElement* Add0DElement (const SMDS_MeshNode * node);
virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID); virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1, virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,

View File

@ -95,6 +95,19 @@ void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z); getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
} }
//=======================================================================
//function :
//purpose :
//=======================================================================
void SMESHDS_Script::Add0DElement (int New0DElementID, int idnode)
{
if (myIsEmbeddedMode) {
myIsModified = true;
return;
}
getCommand(SMESHDS_Add0DElement)->Add0DElement(New0DElementID, idnode);
}
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :

View File

@ -44,6 +44,7 @@ class SMESHDS_EXPORT SMESHDS_Script
bool IsModified(); bool IsModified();
void AddNode(int NewNodeID, double x, double y, double z); void AddNode(int NewNodeID, double x, double y, double z);
void Add0DElement(int New0DElementID, int idnode);
void AddEdge(int NewEdgeID, int idnode1, int idnode2); void AddEdge(int NewEdgeID, int idnode1, int idnode2);
void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3); void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3);
void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3, void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3,

View File

@ -508,6 +508,9 @@
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
unsigned int aMode = anActor->GetEntityMode(); unsigned int aMode = anActor->GetEntityMode();
switch(theCommandID){ switch(theCommandID){
case 216:
InverseEntityMode(aMode,SMESH_Actor::e0DElements);
break;
case 217: case 217:
InverseEntityMode(aMode,SMESH_Actor::eEdges); InverseEntityMode(aMode,SMESH_Actor::eEdges);
break; break;
@ -1467,6 +1470,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
break; break;
// Display Entity // Display Entity
case 216: // 0D elements
case 217: // Edges case 217: // Edges
case 218: // Faces case 218: // Faces
case 219: // Volumes case 219: // Volumes
@ -1571,7 +1575,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
break; break;
} }
case 400: // NODES case 4000: // NODES
{ {
if(checkLock(aStudy)) break; if(checkLock(aStudy)) break;
@ -2192,7 +2196,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
break; break;
} }
case 401: // GEOM::EDGE case 4009: // ELEM0D
case 4010: // GEOM::EDGE
case 4021: // TRIANGLE case 4021: // TRIANGLE
case 4022: // QUAD case 4022: // QUAD
case 4023: // POLYGON case 4023: // POLYGON
@ -2205,6 +2210,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
SMDSAbs_ElementType type = SMDSAbs_Edge; SMDSAbs_ElementType type = SMDSAbs_Edge;
int nbNodes = 2; int nbNodes = 2;
switch (theCommandID) { switch (theCommandID) {
case 4009: // ELEM0D
type = SMDSAbs_0DElement; nbNodes = 1; break;
case 4021: // TRIANGLE case 4021: // TRIANGLE
type = SMDSAbs_Face; nbNodes = 3; break; type = SMDSAbs_Face; nbNodes = 3; break;
case 4022: // QUAD case 4022: // QUAD
@ -2729,8 +2736,9 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true ); createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true ); createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true ); createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
createSMESHAction( 400, "NODE", "ICON_DLG_NODE" ); createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
createSMESHAction( 401, "EDGE", "ICON_DLG_EDGE" ); createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" ); createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" ); createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" ); createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
@ -2767,6 +2775,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true ); createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
createSMESHAction( 214, "UPDATE", "ICON_UPDATE" ); createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true ); createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true ); createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true ); createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true ); createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
@ -2883,8 +2892,9 @@ void SMESHGUI::initialize( CAM_Application* app )
createMenu( 6021, ctrlId, -1 ); createMenu( 6021, ctrlId, -1 );
createMenu( separator(), ctrlId, -1 ); createMenu( separator(), ctrlId, -1 );
createMenu( 400, addId, -1 ); createMenu( 4000, addId, -1 );
createMenu( 401, addId, -1 ); createMenu( 4009, addId, -1 );
createMenu( 4010, addId, -1 );
createMenu( 4021, addId, -1 ); createMenu( 4021, addId, -1 );
createMenu( 4022, addId, -1 ); createMenu( 4022, addId, -1 );
createMenu( 4023, addId, -1 ); createMenu( 4023, addId, -1 );
@ -2977,8 +2987,9 @@ void SMESHGUI::initialize( CAM_Application* app )
createTool( 6021, ctrlTb ); createTool( 6021, ctrlTb );
createTool( separator(), ctrlTb ); createTool( separator(), ctrlTb );
createTool( 400, addRemTb ); createTool( 4000, addRemTb );
createTool( 401, addRemTb ); createTool( 4009, addRemTb );
createTool( 4010, addRemTb );
createTool( 4021, addRemTb ); createTool( 4021, addRemTb );
createTool( 4022, addRemTb ); createTool( 4022, addRemTb );
createTool( 4023, addRemTb ); createTool( 4023, addRemTb );
@ -3111,6 +3122,7 @@ void SMESHGUI::initialize( CAM_Application* app )
hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"), hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
hasElems("(count( elemTypes ) > 0)"), hasElems("(count( elemTypes ) > 0)"),
hasDifferentElems("(count( elemTypes ) > 1)"), hasDifferentElems("(count( elemTypes ) > 1)"),
hasElems0d("({'Elem0d'} in elemTypes)"),
hasEdges("({'Edge'} in elemTypes)"), hasEdges("({'Edge'} in elemTypes)"),
hasFaces("({'Face'} in elemTypes)"), hasFaces("({'Face'} in elemTypes)"),
hasVolumes("({'Volume'} in elemTypes)"); hasVolumes("({'Volume'} in elemTypes)");
@ -3169,6 +3181,10 @@ void SMESHGUI::initialize( CAM_Application* app )
anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 ); anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule ); popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
@ -3580,17 +3596,29 @@ void SMESHGUI::createPreferences()
int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab ); int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
setPreferenceProperty( elemGroup, "columns", 2 ); setPreferenceProperty( elemGroup, "columns", 2 );
addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" ); addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" ); addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" ); addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
//int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
//setPreferenceProperty( sp, "hstretch", 0 );
//setPreferenceProperty( sp, "vstretch", 0 );
int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
int sp = addPreference( "", elemGroup, LightApp_Preferences::Space ); int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
LightApp_Preferences::IntSpin, "SMESH", "element_width");
int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
setPreferenceProperty( size0d, "min", 1 );
setPreferenceProperty( size0d, "max", 10 );
setPreferenceProperty( sp, "hstretch", 0 ); setPreferenceProperty( sp, "hstretch", 0 );
setPreferenceProperty( sp, "vstretch", 0 ); setPreferenceProperty( sp, "vstretch", 0 );
int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
setPreferenceProperty( elemW, "min", 1 ); setPreferenceProperty( elemW, "min", 1 );
setPreferenceProperty( elemW, "max", 5 ); setPreferenceProperty( elemW, "max", 5 );

View File

@ -22,8 +22,8 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_AddMeshElementDlg.cxx // File : SMESHGUI_AddMeshElementDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S. // Author : Nicolas REJNERI, Open CASCADE S.A.S.
// SMESH includes // SMESH includes
//
#include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_AddMeshElementDlg.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
@ -255,6 +255,10 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
myNbNodes = nbNodes; myNbNodes = nbNodes;
myElementType = ElementType; myElementType = ElementType;
switch (ElementType) { switch (ElementType) {
case SMDSAbs_0DElement:
if (myNbNodes != 1)
myNbNodes = 1;
break;
case SMDSAbs_Face: case SMDSAbs_Face:
// if (myNbNodes != 3 && myNbNodes != 4) // if (myNbNodes != 3 && myNbNodes != 4)
// myNbNodes = 3; // myNbNodes = 3;
@ -269,7 +273,11 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
} }
QString elemName; QString elemName;
if (myNbNodes == 2) { if (myNbNodes == 1) {
elemName = "ELEM0D";
myHelpFileName = "adding_nodes_and_elements_page.html#adding_0delems_anchor";
}
else if (myNbNodes == 2) {
elemName = "EDGE"; elemName = "EDGE";
myHelpFileName = "adding_nodes_and_elements_page.html#adding_edges_anchor"; myHelpFileName = "adding_nodes_and_elements_page.html#adding_edges_anchor";
} }
@ -277,7 +285,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
elemName = "TRIANGLE"; elemName = "TRIANGLE";
myHelpFileName = "adding_nodes_and_elements_page.html#adding_triangles_anchor"; myHelpFileName = "adding_nodes_and_elements_page.html#adding_triangles_anchor";
} }
else if (myNbNodes == 4) else if (myNbNodes == 4) {
if (myElementType == SMDSAbs_Face) { if (myElementType == SMDSAbs_Face) {
elemName = "QUADRANGLE"; elemName = "QUADRANGLE";
myHelpFileName = "adding_nodes_and_elements_page.html#adding_quadrangles_anchor"; myHelpFileName = "adding_nodes_and_elements_page.html#adding_quadrangles_anchor";
@ -286,6 +294,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
elemName = "TETRAS"; elemName = "TETRAS";
myHelpFileName = "adding_nodes_and_elements_page.html#adding_tetrahedrons_anchor"; myHelpFileName = "adding_nodes_and_elements_page.html#adding_tetrahedrons_anchor";
} }
}
else if (myNbNodes == 8) { else if (myNbNodes == 8) {
elemName = "HEXAS"; elemName = "HEXAS";
myHelpFileName = "adding_nodes_and_elements_page.html#adding_hexahedrons_anchor"; myHelpFileName = "adding_nodes_and_elements_page.html#adding_hexahedrons_anchor";
@ -439,30 +448,31 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
{ {
if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) { if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
myBusy = true; myBusy = true;
SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; SMESH::long_array_var anArrayOfIndices = new SMESH::long_array;
anArrayOfIdeces->length(myNbNodes); anArrayOfIndices->length(myNbNodes);
bool reverse = (Reverse && Reverse->isChecked()); bool reverse = (Reverse && Reverse->isChecked());
QStringList aListId = myEditCurrentArgument->text().split(" ", QString::SkipEmptyParts); QStringList aListId = myEditCurrentArgument->text().split(" ", QString::SkipEmptyParts);
for (int i = 0; i < aListId.count(); i++) for (int i = 0; i < aListId.count(); i++)
if (reverse) if (reverse)
anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt(); anArrayOfIndices[i] = aListId[ myNbNodes - i - 1 ].toInt();
else else
anArrayOfIdeces[i] = aListId[ i ].toInt(); anArrayOfIndices[i] = aListId[ i ].toInt();
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
switch (myElementType) { switch (myElementType) {
case SMDSAbs_0DElement:
aMeshEditor->Add0DElement(anArrayOfIndices[0]); break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; aMeshEditor->AddEdge(anArrayOfIndices.inout()); break;
case SMDSAbs_Face:{ case SMDSAbs_Face: {
if(myIsPoly) if(myIsPoly)
aMeshEditor->AddPolygonalFace(anArrayOfIdeces.inout()); aMeshEditor->AddPolygonalFace(anArrayOfIndices.inout());
else else
aMeshEditor->AddFace(anArrayOfIdeces.inout()); aMeshEditor->AddFace(anArrayOfIndices.inout());
break; break;
} }
case SMDSAbs_Volume: case SMDSAbs_Volume:
aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; aMeshEditor->AddVolume(anArrayOfIndices.inout()); break;
default:; default:;
} }
@ -516,7 +526,8 @@ void SMESHGUI_AddMeshElementDlg::ClickOnHelp()
{ {
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
if (app) if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""),
myHelpFileName);
else { else {
QString platform; QString platform;
#ifdef WIN32 #ifdef WIN32

View File

@ -126,8 +126,15 @@ SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg(SMESHGUI* theModule):
// --> nodes // --> nodes
QLabel* myMeshNbNodesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), myMeshWidget); QLabel* myMeshNbNodesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), myMeshWidget);
myMeshNbNodes = new QLabel(myMeshWidget); myMeshNbNodes = new QLabel(myMeshWidget);
myMeshNbNodes->setMinimumWidth(100); myMeshNbNodes->setMinimumWidth(100);
QFrame* line12 = new QFrame(myMeshWidget);
line12->setFrameStyle(QFrame::HLine | QFrame::Sunken);
// --> 0D elements
QLabel* myMeshNb0DElemsLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), myMeshWidget);
myMeshNb0DElems = new QLabel(myMeshWidget);
myMeshNb0DElems->setMinimumWidth(100);
// --> header with orders // --> header with orders
QLabel* myMeshOrder0Lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), myMeshWidget); QLabel* myMeshOrder0Lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), myMeshWidget);
@ -290,16 +297,19 @@ SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg(SMESHGUI* theModule):
aMeshLayout->addWidget(line1, 1, 0, 1, 2); aMeshLayout->addWidget(line1, 1, 0, 1, 2);
aMeshLayout->addWidget(myMeshNbNodesLab, 2, 0); aMeshLayout->addWidget(myMeshNbNodesLab, 2, 0);
aMeshLayout->addWidget(myMeshNbNodes, 2, 1); aMeshLayout->addWidget(myMeshNbNodes, 2, 1);
aMeshLayout->addWidget(myMeshOrder0Lab, 3, 1); aMeshLayout->addWidget(line12, 3, 0, 1, 2);
aMeshLayout->addWidget(myMeshOrder1Lab, 3, 2); aMeshLayout->addWidget(myMeshNb0DElemsLab, 4, 0);
aMeshLayout->addWidget(myMeshOrder2Lab, 3, 3); aMeshLayout->addWidget(myMeshNb0DElems, 4, 1);
aMeshLayout->addWidget(myMeshNbEdgesLab, 4, 0); aMeshLayout->addWidget(myMeshOrder0Lab, 5, 1);
aMeshLayout->addWidget(myMeshNbEdges, 4, 1); aMeshLayout->addWidget(myMeshOrder1Lab, 5, 2);
aMeshLayout->addWidget(myMeshNbEdges1, 4, 2); aMeshLayout->addWidget(myMeshOrder2Lab, 5, 3);
aMeshLayout->addWidget(myMeshNbEdges2, 4, 3); aMeshLayout->addWidget(myMeshNbEdgesLab, 6, 0);
aMeshLayout->addWidget(myMeshFacesGroup, 5, 0, 1, 4); aMeshLayout->addWidget(myMeshNbEdges, 6, 1);
aMeshLayout->addWidget(myMeshVolumesGroup, 6, 0, 1, 4); aMeshLayout->addWidget(myMeshNbEdges1, 6, 2);
aMeshLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 7, 0); aMeshLayout->addWidget(myMeshNbEdges2, 6, 3);
aMeshLayout->addWidget(myMeshFacesGroup, 7, 0, 1, 4);
aMeshLayout->addWidget(myMeshVolumesGroup, 8, 0, 1, 4);
aMeshLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 9, 0);
// submesh // submesh
mySubMeshWidget = new QWidget(myWGStack); mySubMeshWidget = new QWidget(myWGStack);
@ -331,6 +341,11 @@ SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg(SMESHGUI* theModule):
mySubMeshNbElements->setMinimumWidth(100); mySubMeshNbElements->setMinimumWidth(100);
mySubMeshNbElements->setFont(fnt); mySubMeshNbElements->setFont(fnt);
// --> 0D elements
QLabel* mySubMeshNb0DElemsLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), mySubMeshElementsGroup);
mySubMeshNb0DElems = new QLabel(mySubMeshElementsGroup);
mySubMeshNb0DElems->setMinimumWidth(100);
// --> elements --> edges // --> elements --> edges
QLabel* mySubMeshNbEdgesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), mySubMeshElementsGroup); QLabel* mySubMeshNbEdgesLab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), mySubMeshElementsGroup);
mySubMeshNbEdges = new QLabel(mySubMeshElementsGroup); mySubMeshNbEdges = new QLabel(mySubMeshElementsGroup);
@ -348,12 +363,14 @@ SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg(SMESHGUI* theModule):
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbElementsLab, 0, 0); mySubMeshElementsGroupLayout->addWidget(mySubMeshNbElementsLab, 0, 0);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbElements, 0, 1); mySubMeshElementsGroupLayout->addWidget(mySubMeshNbElements, 0, 1);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbEdgesLab, 1, 0); mySubMeshElementsGroupLayout->addWidget(mySubMeshNb0DElemsLab, 1, 0);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbEdges, 1, 1); mySubMeshElementsGroupLayout->addWidget(mySubMeshNb0DElems, 1, 1);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbFacesLab, 2, 0); mySubMeshElementsGroupLayout->addWidget(mySubMeshNbEdgesLab, 2, 0);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbFaces, 2, 1); mySubMeshElementsGroupLayout->addWidget(mySubMeshNbEdges, 2, 1);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbVolumesLab, 3, 0); mySubMeshElementsGroupLayout->addWidget(mySubMeshNbFacesLab, 3, 0);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbVolumes, 3, 1); mySubMeshElementsGroupLayout->addWidget(mySubMeshNbFaces, 3, 1);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbVolumesLab, 4, 0);
mySubMeshElementsGroupLayout->addWidget(mySubMeshNbVolumes, 4, 1);
aSubMeshLayout->addWidget(mySubMeshNameLab, 0, 0); aSubMeshLayout->addWidget(mySubMeshNameLab, 0, 0);
aSubMeshLayout->addWidget(mySubMeshName, 0, 1); aSubMeshLayout->addWidget(mySubMeshName, 0, 1);
@ -466,6 +483,7 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_OBJECT_MESH") + "]"); setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_OBJECT_MESH") + "]");
myMeshName->setText(aSO->GetName().c_str()); myMeshName->setText(aSO->GetName().c_str());
myMeshNbNodes->setNum((int)aMesh->NbNodes()); myMeshNbNodes->setNum((int)aMesh->NbNodes());
myMeshNb0DElems->setNum((int)aMesh->Nb0DElements());
myMeshNbEdges->setNum((int)aMesh->NbEdges()); myMeshNbEdges->setNum((int)aMesh->NbEdges());
myMeshNbEdges1->setNum((int)aMesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR)); myMeshNbEdges1->setNum((int)aMesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR));
myMeshNbEdges2->setNum((int)aMesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC)); myMeshNbEdges2->setNum((int)aMesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC));
@ -504,6 +522,7 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
mySubMeshName->setText(aSO->GetName().c_str()); mySubMeshName->setText(aSO->GetName().c_str());
mySubMeshNbNodes->setNum((int)aSubMesh->GetNumberOfNodes(true)); mySubMeshNbNodes->setNum((int)aSubMesh->GetNumberOfNodes(true));
mySubMeshNbElements->setNum((int)aSubMesh->GetNumberOfElements()); mySubMeshNbElements->setNum((int)aSubMesh->GetNumberOfElements());
mySubMeshNb0DElems->setNum((int)(aSubMesh->GetElementsByType(SMESH::ELEM0D)->length()));
mySubMeshNbEdges->setNum((int)(aSubMesh->GetElementsByType(SMESH::EDGE)->length())); mySubMeshNbEdges->setNum((int)(aSubMesh->GetElementsByType(SMESH::EDGE)->length()));
mySubMeshNbFaces->setNum((int)(aSubMesh->GetElementsByType(SMESH::FACE)->length())); mySubMeshNbFaces->setNum((int)(aSubMesh->GetElementsByType(SMESH::FACE)->length()));
mySubMeshNbVolumes->setNum((int)(aSubMesh->GetElementsByType(SMESH::VOLUME)->length())); mySubMeshNbVolumes->setNum((int)(aSubMesh->GetElementsByType(SMESH::VOLUME)->length()));
@ -519,6 +538,8 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
switch (aType) { switch (aType) {
case SMESH::NODE: case SMESH::NODE:
strType = "SMESH_MESHINFO_NODES"; break; strType = "SMESH_MESHINFO_NODES"; break;
case SMESH::ELEM0D:
strType = "SMESH_MESHINFO_0DELEMS"; break;
case SMESH::EDGE: case SMESH::EDGE:
strType = "SMESH_MESHINFO_EDGES"; break; strType = "SMESH_MESHINFO_EDGES"; break;
case SMESH::FACE: case SMESH::FACE:

View File

@ -75,6 +75,7 @@ private:
QWidget* myMeshWidget; QWidget* myMeshWidget;
QLabel* myMeshName; QLabel* myMeshName;
QLabel* myMeshNbNodes; QLabel* myMeshNbNodes;
QLabel* myMeshNb0DElems;
QLabel* myMeshNbEdges; QLabel* myMeshNbEdges;
QLabel* myMeshNbEdges1; QLabel* myMeshNbEdges1;
QLabel* myMeshNbEdges2; QLabel* myMeshNbEdges2;
@ -112,6 +113,7 @@ private:
QLabel* mySubMeshNbNodes; QLabel* mySubMeshNbNodes;
QGroupBox* mySubMeshElementsGroup; QGroupBox* mySubMeshElementsGroup;
QLabel* mySubMeshNbElements; QLabel* mySubMeshNbElements;
QLabel* mySubMeshNb0DElems;
QLabel* mySubMeshNbEdges; QLabel* mySubMeshNbEdges;
QLabel* mySubMeshNbFaces; QLabel* mySubMeshNbFaces;
QLabel* mySubMeshNbVolumes; QLabel* mySubMeshNbVolumes;

View File

@ -142,7 +142,7 @@ SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
//======================================================================= //=======================================================================
//function : elemTypes //function : elemTypes
//purpose : may return {'Edge' 'Face' 'Volume'} at most //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume'} at most
//======================================================================= //=======================================================================
QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
@ -152,6 +152,7 @@ QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
if ( actor ) { if ( actor ) {
TVisualObjPtr object = actor->GetObject(); TVisualObjPtr object = actor->GetObject();
if ( object ) { if ( object ) {
if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" ); if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" ); if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" ); if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
@ -231,7 +232,7 @@ QString SMESHGUI_Selection::shrinkMode( int ind ) const
//======================================================================= //=======================================================================
//function : entityMode //function : entityMode
//purpose : may return {'Edge' 'Face' 'Volume'} at most //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume'} at most
//======================================================================= //=======================================================================
QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
@ -240,9 +241,10 @@ QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
SMESH_Actor* actor = getActor( ind ); SMESH_Actor* actor = getActor( ind );
if ( actor ) { if ( actor ) {
unsigned int aMode = actor->GetEntityMode(); unsigned int aMode = actor->GetEntityMode();
if ( aMode & SMESH_Actor::eVolumes) types.append( "Volume"); if ( aMode & SMESH_Actor::eVolumes ) types.append( "Volume" );
if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" ); if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" );
if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" ); if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" );
if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
} }
return types; return types;
} }

View File

@ -810,6 +810,15 @@ namespace SMESH
int SW = mgr->integerValue( "SMESH", "selection_width", 5 ), int SW = mgr->integerValue( "SMESH", "selection_width", 5 ),
PW = mgr->integerValue( "SMESH", "highlight_width", 5 ); PW = mgr->integerValue( "SMESH", "highlight_width", 5 );
// adjust highlight_width to the width of mesh entities
int aPointSize = mgr->integerValue("SMESH", "node_size", 3);
int aElem0DSize = mgr->integerValue("SMESH", "elem0d_size", 5);
int aLineWidth = mgr->integerValue("SMESH", "element_width", 1);
int maxSize = aPointSize;
if (aElem0DSize > maxSize) maxSize = aElem0DSize;
if (aLineWidth > maxSize) maxSize = aLineWidth;
if (PW < maxSize + 2) PW = maxSize + 2;
double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ), double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ), SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ),
SP3 = mgr->doubleValue( "SMESH", "selection_precision_object", 0.025 ); SP3 = mgr->doubleValue( "SMESH", "selection_precision_object", 0.025 );

View File

@ -443,6 +443,8 @@ void SMESHGUI_WhatIsDlg::SelectionIntoArgument()
if(e->GetType() == SMDSAbs_Node) { if(e->GetType() == SMDSAbs_Node) {
anInfo+=tr("MESH_NODE")+"<br>"; anInfo+=tr("MESH_NODE")+"<br>";
//const SMDS_MeshNode *en = (SMDS_MeshNode*) e; // VSR: not used! //const SMDS_MeshNode *en = (SMDS_MeshNode*) e; // VSR: not used!
} else if (e->GetType() == SMDSAbs_0DElement) {
anInfo+=tr("SMESH_ELEM0D")+"<br>";
} else if(e->GetType() == SMDSAbs_Edge) { } else if(e->GetType() == SMDSAbs_Edge) {
anInfo+=tr("SMESH_EDGE")+"<br>"; anInfo+=tr("SMESH_EDGE")+"<br>";
anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> "; anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";

View File

@ -109,6 +109,10 @@
<source>ICON_DLG_BUILD_COMPOUND_MESH</source> <source>ICON_DLG_BUILD_COMPOUND_MESH</source>
<translation>mesh_build_compound.png</translation> <translation>mesh_build_compound.png</translation>
</message> </message>
<message>
<source>ICON_DLG_ELEM0D</source>
<translation>mesh_vertex.png</translation>
</message>
<message> <message>
<source>ICON_DLG_EDGE</source> <source>ICON_DLG_EDGE</source>
<translation>mesh_line.png</translation> <translation>mesh_line.png</translation>

View File

@ -261,6 +261,14 @@
<source>MEN_DISP_ENT</source> <source>MEN_DISP_ENT</source>
<translation>Display Entity</translation> <translation>Display Entity</translation>
</message> </message>
<message>
<source>MEN_ELEM0D</source>
<translation>0D Element</translation>
</message>
<message>
<source>MEN_ELEMS0D</source>
<translation>0D Elements</translation>
</message>
<message> <message>
<source>MEN_EDGE</source> <source>MEN_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
@ -739,6 +747,14 @@ Please enter correct values and try again</translation>
<source>SMESH_ADD_ALGORITHM_TITLE</source> <source>SMESH_ADD_ALGORITHM_TITLE</source>
<translation>Algorithms Assignation</translation> <translation>Algorithms Assignation</translation>
</message> </message>
<message>
<source>SMESH_ADD_ELEM0D</source>
<translation>Add 0D Element</translation>
</message>
<message>
<source>SMESH_ADD_ELEM0D_TITLE</source>
<translation>Add 0D Element</translation>
</message>
<message> <message>
<source>SMESH_ADD_EDGE</source> <source>SMESH_ADD_EDGE</source>
<translation>Add Edge</translation> <translation>Add Edge</translation>
@ -1063,6 +1079,10 @@ so that the application may crash. Do you wish to continue visualization?</trans
<source>SMESH_DZ</source> <source>SMESH_DZ</source>
<translation>dZ</translation> <translation>dZ</translation>
</message> </message>
<message>
<source>SMESH_ELEM0D</source>
<translation>0D Element</translation>
</message>
<message> <message>
<source>SMESH_EDGE</source> <source>SMESH_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
@ -1404,6 +1424,10 @@ Are you sure want to export to MED 2.1 ?</translation>
<source>SMESH_MESH</source> <source>SMESH_MESH</source>
<translation>Mesh</translation> <translation>Mesh</translation>
</message> </message>
<message>
<source>SMESH_MESHINFO_0DELEMS</source>
<translation>0D Elements</translation>
</message>
<message> <message>
<source>SMESH_MESHINFO_ALL_TYPES</source> <source>SMESH_MESHINFO_ALL_TYPES</source>
<translation>Heterogenous</translation> <translation>Heterogenous</translation>
@ -2071,6 +2095,14 @@ Consider saving your work before application crash</translation>
<source>STB_DISP_ENT</source> <source>STB_DISP_ENT</source>
<translation>Display entity</translation> <translation>Display entity</translation>
</message> </message>
<message>
<source>STB_ELEM0D</source>
<translation>0D Element</translation>
</message>
<message>
<source>STB_ELEMS0D</source>
<translation>0D Elements</translation>
</message>
<message> <message>
<source>STB_EDGE</source> <source>STB_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
@ -2557,6 +2589,14 @@ Consider saving your work before application crash</translation>
<source>TOP_DISP_ENT</source> <source>TOP_DISP_ENT</source>
<translation>Display entity</translation> <translation>Display entity</translation>
</message> </message>
<message>
<source>TOP_ELEM0D</source>
<translation>0D Element</translation>
</message>
<message>
<source>TOP_ELEMS0D</source>
<translation>0D Elements</translation>
</message>
<message> <message>
<source>TOP_EDGE</source> <source>TOP_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
@ -3127,6 +3167,14 @@ Please, create VTK viewer and try again</translation>
<source>PREF_TITLE_COLOR</source> <source>PREF_TITLE_COLOR</source>
<translation>Title color</translation> <translation>Title color</translation>
</message> </message>
<message>
<source>PREF_COLOR_0D</source>
<translation>0D elements</translation>
</message>
<message>
<source>PREF_SIZE_0D</source>
<translation>Size of 0D elements</translation>
</message>
<message> <message>
<source>PREF_WIDTH</source> <source>PREF_WIDTH</source>
<translation>Width</translation> <translation>Width</translation>

View File

@ -1066,7 +1066,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
static TStringSet sameMethods; static TStringSet sameMethods;
if ( sameMethods.empty() ) { if ( sameMethods.empty() ) {
const char * names[] = { const char * names[] = {
"RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace", "RemoveElements","RemoveNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace",
"AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint", "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint",
"InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject", "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject",
"BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject",

View File

@ -26,6 +26,7 @@
#include "SMESH_MeshEditor_i.hxx" #include "SMESH_MeshEditor_i.hxx"
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_MeshEdge.hxx" #include "SMDS_MeshEdge.hxx"
#include "SMDS_MeshFace.hxx" #include "SMDS_MeshFace.hxx"
#include "SMDS_MeshVolume.hxx" #include "SMDS_MeshVolume.hxx"
@ -319,6 +320,47 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNo
*/ */
//============================================================================= //=============================================================================
CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
CORBA::Double y, CORBA::Double z)
{
initData();
const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
// Update Python script
TPythonDump() << "nodeID = " << this << ".AddNode( "
<< x << ", " << y << ", " << z << " )";
return N->GetID();
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
{
initData();
const SMDS_MeshNode* aNode = GetMeshDS()->FindNode(IDOfNode);
SMDS_MeshElement* elem = GetMeshDS()->Add0DElement(aNode);
// Update Python script
TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
if (elem)
return elem->GetID();
return 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes) CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
{ {
initData(); initData();
@ -353,26 +395,6 @@ CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
return 0; return 0;
} }
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x,
CORBA::Double y, CORBA::Double z)
{
initData();
const SMDS_MeshNode* N = GetMeshDS()->AddNode(x, y, z);
// Update Python script
TPythonDump() << "nodeID = " << this << ".AddNode( "
<< x << ", " << y << ", " << z << " )";
return N->GetID();
}
//============================================================================= //=============================================================================
/*! /*!
* AddFace * AddFace

View File

@ -55,6 +55,7 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
* Returns ID of created element or 0 if element not created * Returns ID of created element or 0 if element not created
*/ */
CORBA::Long AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z); CORBA::Long AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
CORBA::Long Add0DElement(CORBA::Long IDOfNode);
CORBA::Long AddEdge(const SMESH::long_array & IDsOfNodes); CORBA::Long AddEdge(const SMESH::long_array & IDsOfNodes);
CORBA::Long AddFace(const SMESH::long_array & IDsOfNodes); CORBA::Long AddFace(const SMESH::long_array & IDsOfNodes);
CORBA::Long AddPolygonalFace(const SMESH::long_array & IDsOfNodes); CORBA::Long AddPolygonalFace(const SMESH::long_array & IDsOfNodes);

View File

@ -2416,6 +2416,17 @@ CORBA::Long SMESH_Mesh_i::NbElements()throw (SALOME::SALOME_Exception)
return NbEdges() + NbFaces() + NbVolumes(); return NbEdges() + NbFaces() + NbVolumes();
} }
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_Mesh_i::Nb0DElements()throw (SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
return _impl->Nb0DElements();
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -227,6 +227,9 @@ public:
CORBA::Long NbElements() CORBA::Long NbElements()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long Nb0DElements()
throw (SALOME::SALOME_Exception);
CORBA::Long NbEdges() CORBA::Long NbEdges()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);

View File

@ -1600,6 +1600,12 @@ class Mesh:
def NbElements(self): def NbElements(self):
return self.mesh.NbElements() return self.mesh.NbElements()
## Returns the number of 0d elements in the mesh
# @return an integer value
# @ingroup l1_meshinfo
def Nb0DElements(self):
return self.mesh.Nb0DElements()
## Returns the number of edges in the mesh ## Returns the number of edges in the mesh
# @return an integer value # @return an integer value
# @ingroup l1_meshinfo # @ingroup l1_meshinfo
@ -1938,6 +1944,13 @@ class Mesh:
self.mesh.SetParameters(Parameters) self.mesh.SetParameters(Parameters)
return self.editor.AddNode( x, y, z) return self.editor.AddNode( x, y, z)
## Creates a 0D element on a node with given number.
# @param IDOfNode the ID of node for creation of the element.
# @return the Id of the new 0D element
# @ingroup l2_modif_add
def Add0DElement(self, IDOfNode):
return self.editor.Add0DElement(IDOfNode)
## Creates a linear or quadratic edge (this is determined ## Creates a linear or quadratic edge (this is determined
# by the number of given nodes). # by the number of given nodes).
# @param IDsOfNodes the list of node IDs for creation of the element. # @param IDsOfNodes the list of node IDs for creation of the element.