0021459: EDF 1495 SMESH: Manipulation of discrete elements with attributes

This commit is contained in:
eap 2012-07-19 12:50:10 +00:00
parent 20bed398e1
commit 229db9cb6f
27 changed files with 399 additions and 98 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -7,6 +7,7 @@
<ul>
<li>\ref adding_nodes_anchor "Nodes"</li>
<li>\ref adding_0delems_anchor "0D Elements"</li>
<li>\ref adding_balls_anchor "Ball Elements"</li>
<li>\ref adding_edges_anchor "Edges"</li>
<li>\ref adding_triangles_anchor "Triangles"</li>
<li>\ref adding_quadrangles_anchor "Quadrangles"</li>
@ -76,6 +77,18 @@ selecting it in the 3D viewer and click the \b Apply or
\image html add_0delement.png
\anchor adding_balls_anchor
<h2>Adding ball elements</h2>
\image html addball.png
In this dialog box specify the node which will form your ball element
either by selecting it in the 3D viewer or by manual entering its ID,
specify a ball diameter and click the \b Apply or <b>Apply and
Close</b> button. Your ball element will be created:
\image html add_ball.png
<br>
\anchor adding_edges_anchor
<h2>Adding edges</h2>

View File

@ -74,7 +74,8 @@ module SMESH
ADD_ELEM0D,
ADD_BIQUAD_QUADRANGLE,
ADD_TRIQUAD_HEXA,
ADD_HEXAGONAL_PRISM
ADD_HEXAGONAL_PRISM,
ADD_BALL
};
struct log_block
@ -119,7 +120,8 @@ module SMESH
EDGE,
FACE,
VOLUME,
ELEM0D
ELEM0D,
BALL
};
typedef sequence<ElementType> array_of_ElementType ;
@ -131,14 +133,15 @@ module SMESH
Geom_POINT,
Geom_EDGE,
Geom_TRIANGLE,
Geom_QUADRANGLE,
Geom_POLYGON,
Geom_QUADRANGLE, // when a new GeometryType is added, please
Geom_POLYGON, // update a corresponding list in SMESH_2smeshpy.cxx, ln 665
Geom_TETRA,
Geom_PYRAMID,
Geom_HEXA,
Geom_PENTA,
Geom_HEXAGONAL_PRISM,
Geom_POLYHEDRA
Geom_POLYHEDRA,
Geom_BALL
};
/*!
@ -180,6 +183,7 @@ module SMESH
Entity_Hexagonal_Prism,
Entity_Polyhedra,
Entity_Quad_Polyhedra,
Entity_Ball,
Entity_Last
};
@ -684,6 +688,9 @@ module SMESH
long Nb0DElements()
raises (SALOME::SALOME_Exception);
long NbBalls()
raises (SALOME::SALOME_Exception);
long NbEdges()
raises (SALOME::SALOME_Exception);
@ -899,6 +906,11 @@ module SMESH
*/
boolean IsQuadratic(in long id);
/*!
* Returns diameter of a ball discrete element or zero in case of an invalid \a id
*/
double GetBallDiameter(in long id);
/*!
* Returns XYZ coordinates of bary center for given element
* as list of double

View File

@ -64,7 +64,7 @@ module SMESH
long RemoveOrphanNodes();
/*!
* \brief Add new node.
* \brief Add a new node.
* \param x X coordinate of new node
* \param y Y coordinate of new node
* \param z Z coordinate of new node
@ -73,14 +73,20 @@ module SMESH
long AddNode(in double x, in double y, in double z);
/*!
* Create 0D element on the given node.
* Create a 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
* by number of given nodes).
* Create a ball element on the given node.
* \param IdOfNode Node IDs for creation of element.
*/
long AddBall(in long IDOfNode, in double diameter);
/*!
* Create an edge, either linear and quadratic (this is determed
* by number of given nodes, two or three).
* \param IdsOfNodes List of node IDs for creation of element.
* Needed order of nodes in this list corresponds to description
* of MED. This description is located by the following link:

View File

@ -151,7 +151,9 @@ DriverMED_Family
const bool doGroupOfNodes,
const bool doGroupOfEdges,
const bool doGroupOfFaces,
const bool doGroupOfVolumes)
const bool doGroupOfVolumes,
const bool doGroupOf0DElems,
const bool doGroupOfBalls)
{
DriverMED_FamilyPtrList aFamilies;
@ -159,9 +161,11 @@ DriverMED_Family
string anAllEdgesGroupName = "Group_Of_All_Edges";
string anAllFacesGroupName = "Group_Of_All_Faces";
string anAllVolumesGroupName = "Group_Of_All_Volumes";
string anAll0DElemsGroupName = "Group_Of_All_0DElems";
string anAllBallsGroupName = "Group_Of_All_Balls";
// Reserve four ids for families of free elements
// (1 - nodes, -1 - edges, -2 - faces, -3 - volumes).
// Reserve 6 ids for families of free elements
// (1 - nodes, -1 - edges, -2 - faces, -3 - volumes, -4 - 0D, -5 - balls).
// 'Free' means here not belonging to any group.
int aNodeFamId = FIRST_NODE_FAMILY;
int aElemFamId = FIRST_ELEM_FAMILY;
@ -263,6 +267,12 @@ DriverMED_Family
else if (aFam->myType == SMDSAbs_Volume) {
if (doGroupOfVolumes) aFam->myGroupNames.insert(anAllVolumesGroupName);
}
else if (aFam->myType == SMDSAbs_0DElement) {
if (doGroupOfVolumes) aFam->myGroupNames.insert(anAll0DElemsGroupName);
}
else if (aFam->myType == SMDSAbs_Ball) {
if (doGroupOfVolumes) aFam->myGroupNames.insert(anAllBallsGroupName);
}
}
}
@ -303,6 +313,24 @@ DriverMED_Family
aFamilies.push_back(aFreeVolumesFam);
}
if (doGroupOf0DElems)
{
DriverMED_FamilyPtr aFree0DFam (new DriverMED_Family);
aFree0DFam->SetId(REST_0DELEM_FAMILY);
aFree0DFam->myType = SMDSAbs_0DElement;
aFree0DFam->myGroupNames.insert(anAll0DElemsGroupName);
aFamilies.push_back(aFree0DFam);
}
if (doGroupOfBalls)
{
DriverMED_FamilyPtr aFreeBallsFam (new DriverMED_Family);
aFreeBallsFam->SetId(REST_BALL_FAMILY);
aFreeBallsFam->myType = SMDSAbs_Ball;
aFreeBallsFam->myGroupNames.insert(anAllBallsGroupName);
aFamilies.push_back(aFreeBallsFam);
}
DriverMED_FamilyPtr aNullFam (new DriverMED_Family);
aNullFam->SetId(0);
aNullFam->myType = SMDSAbs_All;
@ -428,6 +456,8 @@ DriverMED_Family
DriverMED_FamilyPtr anEdgesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aFacesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aVolumesFamily (new DriverMED_Family);
// DriverMED_FamilyPtr a0DElemsFamily (new DriverMED_Family);
// DriverMED_FamilyPtr aBallsFamily (new DriverMED_Family);
char submeshGrpName[ 30 ];
sprintf( submeshGrpName, "SubMesh %d", theId );
@ -494,13 +524,14 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
DriverMED_FamilyPtr common)
{
// Elements
ElementsSet::iterator anIter = by->myElements.begin();
ElementsSet::iterator anIter = by->myElements.begin(), elemInMe;
while ( anIter != by->myElements.end())
{
if (myElements.find(*anIter) != myElements.end())
elemInMe = myElements.find(*anIter);
if (elemInMe != myElements.end())
{
common->myElements.insert(*anIter);
myElements.erase(*anIter);
myElements.erase(elemInMe);
by->myElements.erase(anIter++);
}
else
@ -511,11 +542,7 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
{
// Groups list
common->myGroupNames = myGroupNames;
MED::TStringSet::iterator aGrNamesIter = by->myGroupNames.begin();
for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++)
{
common->myGroupNames.insert(*aGrNamesIter);
}
common->myGroupNames.insert( by->myGroupNames.begin(), by->myGroupNames.end() );
// Type
common->myType = myType;

View File

@ -40,18 +40,21 @@
#include <set>
#define REST_NODES_FAMILY 1
#define FIRST_NODE_FAMILY 2
#define REST_EDGES_FAMILY -1
#define REST_FACES_FAMILY -2
#define REST_VOLUMES_FAMILY -3
#define FIRST_NODE_FAMILY 2
#define FIRST_ELEM_FAMILY -4
#define REST_0DELEM_FAMILY -4
#define REST_BALL_FAMILY -5
#define FIRST_ELEM_FAMILY -6
class DriverMED_Family;
typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
typedef std::list<DriverMED_FamilyPtr> DriverMED_FamilyPtrList;
typedef std::map<int,SMESHDS_SubMesh*> SMESHDS_SubMeshPtrMap;
typedef std::list<SMESHDS_GroupBase*> SMESHDS_GroupBasePtrList;
typedef std::set<const SMDS_MeshElement*> ElementsSet;
typedef std::list<DriverMED_FamilyPtr > DriverMED_FamilyPtrList;
typedef std::map<int,SMESHDS_SubMesh* > SMESHDS_SubMeshPtrMap;
typedef std::list<SMESHDS_GroupBase* > SMESHDS_GroupBasePtrList;
typedef std::set<const SMDS_MeshElement* > ElementsSet;
class MESHDRIVERMED_EXPORT DriverMED_Family
{
@ -73,7 +76,9 @@ class MESHDRIVERMED_EXPORT DriverMED_Family
const bool doGroupOfNodes,
const bool doGroupOfEdges,
const bool doGroupOfFaces,
const bool doGroupOfVolumes);
const bool doGroupOfVolumes,
const bool doGroupOf0DElems,
const bool doGroupOfBalls);
//! Create TFamilyInfo for this family
MED::PFamilyInfo

View File

@ -189,6 +189,70 @@ DriverMED_R_SMESHDS_Mesh
for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
const EGeometrieElement& aGeom = aGeom2SizeIter->first;
if ( anEntity == eSTRUCT_ELEMENT ) // MED_BALL (issue 0021459)
{
PBallInfo aBallInfo = aMed->GetPBallInfo(aMeshInfo);
TInt aNbBalls = aBallInfo->GetNbElem();
EBooleen anIsElemNum = takeNumbers ? aBallInfo->IsElemNum() : eFAUX;
if ( anIsElemNum && aBallInfo->myElemNum->empty() )
anIsElemNum = eFAUX;
// get supporting nodes
TNodeIds aNodeIds;
#ifdef _EDF_NODE_IDS_
if(anIsNodeNum) {
aNodeIds.resize( aNbBalls );
for(TInt iBall = 0; iBall < aNbBalls && anIsNodeNum; iBall++)
{
aNodeIds[iBall] = aNodeInfo->GetElemNum(iBall);
anIsNodeNum = myMesh->FindNode( aNodeIds[iBall] ) ? eVRAI : eFAUX;
}
}
#endif
if ( !anIsNodeNum )
aNodeIds.swap( *(aBallInfo->myConn ));
// allocate array of diameters
vtkIdType maxID = myMesh->MaxElementID() + aNbBalls;
if ( anIsElemNum && !aBallInfo->myElemNum->empty() )
maxID = *std::max_element( aBallInfo->myElemNum->begin(),
aBallInfo->myElemNum->end() );
myMesh->getGrid()->AllocateDiameters( maxID ); // performance optimization
// create balls
SMDS_MeshElement* anElement;
DriverMED_FamilyPtr aFamily;
for ( TInt iBall = 0; iBall < aNbBalls; iBall++)
{
anElement = 0;
if ( anIsElemNum ) {
if (!(anElement = myMesh->AddBallWithID( aNodeIds[iBall],
aBallInfo->myDiameters[iBall],
aBallInfo->GetElemNum(iBall))))
anIsElemNum = eFAUX;
}
if ( !anElement )
myMesh->AddBall( myMesh->FindNode( aNodeIds[iBall]),
aBallInfo->myDiameters[iBall] );
// Save reference to this element from its family
TInt aFamNum = aBallInfo->GetFamNum(iBall);
if ( checkFamilyID ( aFamily, aFamNum ))
{
aFamily->AddElement(anElement);
aFamily->SetType( SMDSAbs_Ball );
}
}
if ( !anIsElemNum &&
( takeNumbers && aBallInfo->IsElemNum() && !aBallInfo->myElemNum->empty() ))
if ( aResult < DRS_WARN_RENUMBER )
aResult = DRS_WARN_RENUMBER;
continue;
} // MED_BALL
switch(aGeom) {
// case ePOINT1: ## PAL16410
// break;
@ -388,7 +452,7 @@ DriverMED_R_SMESHDS_Mesh
INFOS("Following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was cought !!!");
INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif

View File

@ -396,22 +396,22 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
//----------------------------------------------------
int myNodesDefaultFamilyId = 0;
int my0DElementsDefaultFamilyId = 0;
int myBallsDefaultFamilyId = 0;
int myEdgesDefaultFamilyId = 0;
int myFacesDefaultFamilyId = 0;
int myVolumesDefaultFamilyId = 0;
int nbNodes = myMesh->NbNodes();
//int nb0DElements = myMesh->Nb0DElements();
int nb0DElements = myMesh->Nb0DElements();
int nbBalls = myMesh->NbBalls();
int nbEdges = myMesh->NbEdges();
int nbFaces = myMesh->NbFaces();
int nbVolumes = myMesh->NbVolumes();
if (myDoGroupOfNodes && nbNodes)
myNodesDefaultFamilyId = REST_NODES_FAMILY;
if (myDoGroupOfEdges && nbEdges)
myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
if (myDoGroupOfFaces && nbFaces)
myFacesDefaultFamilyId = REST_FACES_FAMILY;
if (myDoGroupOfVolumes && nbVolumes)
myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
if (myDoGroupOfNodes && nbNodes) myNodesDefaultFamilyId = REST_NODES_FAMILY;
if (myDoGroupOfEdges && nbEdges) myEdgesDefaultFamilyId = REST_EDGES_FAMILY;
if (myDoGroupOfFaces && nbFaces) myFacesDefaultFamilyId = REST_FACES_FAMILY;
if (myDoGroupOfVolumes && nbVolumes) myVolumesDefaultFamilyId = REST_VOLUMES_FAMILY;
if (myDoGroupOf0DElems && nb0DElements) my0DElementsDefaultFamilyId = REST_0DELEM_FAMILY;
if (myDoGroupOfVolumes && nbVolumes) myBallsDefaultFamilyId = REST_BALL_FAMILY;
MESSAGE("Perform - aFamilyInfo");
//cout << " DriverMED_Family::MakeFamilies() " << endl;
@ -422,14 +422,18 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
myDoGroupOfNodes && nbNodes,
myDoGroupOfEdges && nbEdges,
myDoGroupOfFaces && nbFaces,
myDoGroupOfVolumes && nbVolumes);
myDoGroupOfVolumes && nbVolumes,
myDoGroupOf0DElems && nb0DElements,
myDoGroupOfBalls && nbBalls);
} else {
aFamilies = DriverMED_Family::MakeFamilies
(mySubMeshes, myGroups,
myDoGroupOfNodes && nbNodes,
myDoGroupOfEdges && nbEdges,
myDoGroupOfFaces && nbFaces,
myDoGroupOfVolumes && nbVolumes);
myDoGroupOfVolumes && nbVolumes,
myDoGroupOf0DElems && nb0DElements,
myDoGroupOfBalls && nbBalls);
}
//cout << " myMed->SetFamilyInfo() " << endl;
list<DriverMED_FamilyPtr>::iterator aFamsIter;
@ -515,6 +519,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
ePOINT1,
nbElemInfo.Nb0DElements(),
SMDSAbs_0DElement));
#ifdef _ELEMENTS_BY_DIM_
anEntity = eSTRUCT_ELEMENT;
#endif
aTElemTypeDatas.push_back( TElemTypeData(anEntity,
eBALL,
nbElemInfo.NbBalls(),
SMDSAbs_Ball));
#ifdef _ELEMENTS_BY_DIM_
anEntity = eARETE;
#endif
@ -632,6 +643,9 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
case SMDSAbs_0DElement:
defaultFamilyId = my0DElementsDefaultFamilyId;
break;
case SMDSAbs_Ball:
defaultFamilyId = myBallsDefaultFamilyId;
break;
case SMDSAbs_Edge:
defaultFamilyId = myEdgesDefaultFamilyId;
break;
@ -646,24 +660,23 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
}
// iterator on elements of a current type
SMDS_ElemIteratorPtr elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType );
if ( !elemIterator->more()) continue;
SMDS_ElemIteratorPtr elemIterator;
int iElem = 0;
// Treat POLYGONs
// ---------------
if ( aElemTypeData->_geomType == ePOLYGONE )
{
elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYGON );
if ( nbPolygonNodes == 0 ) {
// Count nb of nodes
while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
if ( anElem->IsPoly() ) {
while ( elemIterator->more() ) {
const SMDS_MeshElement* anElem = elemIterator->next();
nbPolygonNodes += anElem->NbNodes();
if ( ++iElem == aElemTypeData->_nbElems )
break;
}
}
}
else {
// Store in med file
PPolygoneInfo aPolygoneInfo = myMed->CrPolygoneInfo(aMeshInfo,
@ -676,11 +689,9 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
TElemNum & index = *(aPolygoneInfo->myIndex.get());
index[0] = 1;
while ( const SMDS_MeshElement* anElem = elemIterator->next() )
while ( elemIterator->more() )
{
if ( !anElem->IsPoly() )
continue;
const SMDS_MeshElement* anElem = elemIterator->next();
// index
TInt aNbNodes = anElem->NbNodes();
index[ iElem+1 ] = index[ iElem ] + aNbNodes;
@ -714,18 +725,20 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
// ----------------
else if (aElemTypeData->_geomType == ePOLYEDRE )
{
elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYHEDRA );
if ( nbPolyhedronNodes == 0 ) {
// Count nb of nodes
while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
while ( elemIterator->more() ) {
const SMDS_MeshElement* anElem = elemIterator->next();
const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
if ( aPolyedre && aPolyedre->IsPoly()) {
if ( !aPolyedre ) continue;
nbPolyhedronNodes += aPolyedre->NbNodes();
nbPolyhedronFaces += aPolyedre->NbFaces();
if ( ++iElem == aElemTypeData->_nbElems )
break;
}
}
}
else {
// Store in med file
PPolyedreInfo aPolyhInfo = myMed->CrPolyedreInfo(aMeshInfo,
@ -744,13 +757,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
faces[0] = 1;
TInt iFace = 0, iNode = 0;
while ( const SMDS_MeshElement* anElem = elemIterator->next() )
while ( elemIterator->more() )
{
const SMDS_MeshElement* anElem = elemIterator->next();
const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
if ( !aPolyedre )
continue;
if ( !aPolyedre->IsPoly() )
continue;
if ( !aPolyedre ) continue;
// index
TInt aNbFaces = aPolyedre->NbFaces();
index[ iElem+1 ] = index[ iElem ] + aNbFaces;
@ -785,6 +796,48 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
}
} // if (aElemTypeData->_geomType == ePOLYEDRE )
// Treat BALLs
// ----------------
else if (aElemTypeData->_geomType == eBALL )
{
// allocate data arrays
PBallInfo aBallInfo = myMed->CrBallInfo( aMeshInfo,
aElemTypeData->_nbElems );
// build map of family numbers for this type
if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ])
{
fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType );
isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true;
}
elemIterator = myMesh->elementsIterator( SMDSAbs_Ball );
while ( elemIterator->more() )
{
const SMDS_MeshElement* anElem = elemIterator->next();
// connectivity
const SMDS_MeshElement* aNode = anElem->GetNode( 0 );
#ifdef _EDF_NODE_IDS_
(*aBallInfo->myConn)[ iElem ] = aNodeIdMap[aNode->GetID()];
#else
(*aBallInfo->myConn)[ iElem ] = aNode->GetID();
#endif
// element number
aBallInfo->SetElemNum( iElem, anElem->GetID() );
// diameter
aBallInfo->myDiameters[ iElem ] =
static_cast<const SMDS_BallElement*>( anElem )->GetDiameter();
// family number
int famNum = getFamilyId( anElemFamMap, anElem, defaultFamilyId );
aBallInfo->SetFamNum( iElem, famNum );
++iElem;
}
// store data in a file
myMed->SetBallInfo(aBallInfo);
}
else
{
// Treat standard types
@ -807,8 +860,10 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
}
TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType);
while ( const SMDS_MeshElement* anElem = elemIterator->next() )
elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType );
while ( elemIterator->more() )
{
const SMDS_MeshElement* anElem = elemIterator->next();
if ( anElem->NbNodes() != aNbNodes || anElem->IsPoly() )
continue; // other geometry

View File

@ -56,6 +56,8 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
void AddGroupOfEdges();
void AddGroupOfFaces();
void AddGroupOfVolumes();
void AddGroupOf0DElems();
void AddGroupOfBalls();
/*! functions to prepare adding one mesh
*/
@ -77,6 +79,8 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
bool myDoGroupOfEdges;
bool myDoGroupOfFaces;
bool myDoGroupOfVolumes;
bool myDoGroupOf0DElems;
bool myDoGroupOfBalls;
};

View File

@ -139,6 +139,7 @@ SMESH_ActorDef::SMESH_ActorDef()
myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
@ -314,6 +315,26 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_VERTEX);
//Definition 0D device of the actor (ball elements)
//-----------------------------------------------
myBallProp = vtkProperty::New();
SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
myBallProp->SetPointSize(aBallElemSize);
myBallActor = SMESH_CellLabelActor::New();
myBallActor->SetUserMatrix(aMatrix);
myBallActor->SetStoreGemetryMapping(true);
myBallActor->PickableOff();
myBallActor->SetVisibility(false);
myBallActor->SetProperty(myBallProp);
myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = myBallActor->GetExtractUnstructuredGrid();
//aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_VERTEX);
aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
//my0DExtProp = vtkProperty::New();
//my0DExtProp->DeepCopy(my0DProp);
//anRGB[0] = 1 - anRGB[0];
@ -508,6 +529,7 @@ SMESH_ActorDef::~SMESH_ActorDef()
my0DProp->Delete();
my0DActor->Delete();
myBallActor->Delete();
//my0DExtProp->Delete();
//my0DExtActor->Delete();
@ -574,6 +596,9 @@ void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
if(my0DActor)
my0DActor->SetCellsLabeled(theIsCellsLabeled);
if(myBallActor)
myBallActor->SetCellsLabeled(theIsCellsLabeled);
myTimeStamp->Modified();
}
@ -592,6 +617,9 @@ bool SMESH_ActorDef::GetCellsLabeled() {
if(my0DActor)
result = result || my0DActor->GetCellsLabeled();
if(myBallActor)
result = result || myBallActor->GetCellsLabeled();
return result;
}
@ -669,6 +697,7 @@ SetControlMode(eControl theMode,
my1DActor->GetMapper()->SetScalarVisibility(false);
my2DActor->GetMapper()->SetScalarVisibility(false);
my3DActor->GetMapper()->SetScalarVisibility(false);
myBallActor->GetMapper()->SetScalarVisibility(false);
myScalarBarActor->SetVisibility(false);
bool anIsScalarVisible = theMode > eNone;
@ -932,13 +961,14 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
theRenderer->AddActor(myNodeExtActor);
theRenderer->AddActor(my1DExtActor);
my3DActor->AddToRender(theRenderer);
my3DActor ->AddToRender(theRenderer);
my3DExtActor->AddToRender(theRenderer);
my2DActor->AddToRender(theRenderer);
my2DActor ->AddToRender(theRenderer);
my2DExtActor->AddToRender(theRenderer);
myNodeActor->AddToRender(theRenderer);
my1DActor->AddToRender(theRenderer);
my0DActor->AddToRender(theRenderer);
myNodeActor ->AddToRender(theRenderer);
my1DActor ->AddToRender(theRenderer);
my0DActor ->AddToRender(theRenderer);
myBallActor ->AddToRender(theRenderer);
//theRenderer->AddActor(my0DExtActor);
theRenderer->AddActor(myHighlitableActor);
@ -969,6 +999,7 @@ void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
my3DExtActor->RemoveFromRender(theRenderer);
myNodeActor->RemoveFromRender(theRenderer);
my0DActor->RemoveFromRender(theRenderer);
myBallActor->RemoveFromRender(theRenderer);
my1DActor->RemoveFromRender(theRenderer);
theRenderer->RemoveActor(myScalarBarActor);
@ -995,6 +1026,7 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->Init(myVisualObj,myImplicitBoolean);
myBallActor->Init(myVisualObj,myImplicitBoolean);
//my0DExtActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->Init(myVisualObj,myImplicitBoolean);
@ -1006,6 +1038,7 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
my3DExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->GetMapper()->SetLookupTable(myLookupTable);
myBallActor->GetMapper()->SetLookupTable(myLookupTable);
//my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my1DActor->GetMapper()->SetLookupTable(myLookupTable);
@ -1079,6 +1112,7 @@ void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
myNodeExtActor->SetTransform(theTransform);
my0DActor->SetTransform(theTransform);
myBallActor->SetTransform(theTransform);
//my0DExtActor->SetTransform(theTransform);
my1DActor->SetTransform(theTransform);
@ -1219,6 +1253,7 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
myNodeExtActor->VisibilityOff();
my0DActor->VisibilityOff();
myBallActor->VisibilityOff();
//my0DExtActor->VisibilityOff();
my1DActor->VisibilityOff();
@ -1275,6 +1310,9 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
if(myEntityMode & e0DElements){
my0DActor->VisibilityOn();
}
if(myEntityMode & eBallElem){
myBallActor->VisibilityOn();
}
if(myEntityMode & eEdges && GetRepresentation() != ePoint){
my1DActor->VisibilityOn();
@ -1295,6 +1333,9 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
if(my0DActor)
my0DActor->UpdateLabels();
if(myBallActor)
myBallActor->UpdateLabels();
if(my1DActor)
my1DActor->UpdateLabels();
@ -1322,6 +1363,11 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
theMode &= ~e0DElements;
}
if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
myEntityState &= ~eBallElem;
theMode &= ~eBallElem;
}
if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
myEntityState &= ~eEdges;
theMode &= ~eEdges;
@ -1341,6 +1387,9 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
theMode |= e0DElements;
if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
theMode |= eBallElem;
if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
theMode |= eEdges;
@ -1369,6 +1418,11 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aHightFilter->RegisterCellsWithType(VTK_VERTEX);
}
if (myEntityMode & eBallElem) {
aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
}
if (myEntityMode & eEdges) {
if (MYDEBUG) MESSAGE("EDGES");
aFilter->RegisterCellsWithType(VTK_LINE);
@ -1519,6 +1573,7 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
//my0DActor->SetProperty(aProp);
//my0DActor->SetBackfaceProperty(aBackProp);
my0DActor->SetRepresentation(aReperesent);
myBallActor->SetRepresentation(aReperesent);
//my0DExtActor->SetRepresentation(aReperesent);
switch(myControlMode){
@ -1676,6 +1731,9 @@ void SMESH_ActorDef::Update(){
if(my0DActor)
my0DActor->UpdateLabels();
if(myBallActor)
myBallActor->UpdateLabels();
if(my1DActor)
my1DActor->UpdateLabels();
@ -1799,6 +1857,18 @@ void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,
::GetColor(my0DProp,r,g,b);
}
void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myBallProp->SetColor(r,g,b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Ball )
myNameActor->SetBackgroundColor(r,g,b);
Modified();
}
void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(myBallProp,r,g,b);
}
void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myHighlightProp->SetColor(r,g,b);
Modified();
@ -1845,6 +1915,15 @@ vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
return my0DProp->GetPointSize();
}
void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
myBallProp->SetPointSize(theVal);
Modified();
}
vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
return myBallProp->GetPointSize();
}
int SMESH_ActorDef::GetObjDimension( const int theObjId )
{
return myVisualObj->GetElemDimension( theObjId );
@ -1868,6 +1947,7 @@ SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
//my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);

View File

@ -76,6 +76,9 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b) = 0;
virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b) = 0;
virtual void SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b) = 0;
virtual void GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b) = 0;
virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b) = 0;
virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b) = 0;
@ -88,9 +91,12 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
virtual void Set0DSize(vtkFloatingPointType size) = 0;
virtual vtkFloatingPointType Get0DSize() = 0;
virtual void SetBallSize(vtkFloatingPointType size) = 0;
virtual vtkFloatingPointType GetBallSize() = 0;
enum EReperesent { ePoint, eEdge, eSurface};
enum EEntityMode { e0DElements = 0x01, eEdges = 0x02, eFaces = 0x04, eVolumes = 0x08, eAllEntity = 0x0f};
enum EEntityMode { e0DElements = 0x01, eEdges = 0x02, eFaces = 0x04, eVolumes = 0x08, eBallElem = 0x10, eAllEntity = 0x1f};
enum EQuadratic2DRepresentation { eLines = 0x01, eArcs = 0x02 };

View File

@ -119,6 +119,9 @@ class SMESH_ActorDef : public SMESH_Actor
virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
virtual void SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
virtual void GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
@ -131,6 +134,9 @@ class SMESH_ActorDef : public SMESH_Actor
virtual void Set0DSize(vtkFloatingPointType size);
virtual vtkFloatingPointType Get0DSize();
virtual void SetBallSize(vtkFloatingPointType size);
virtual vtkFloatingPointType GetBallSize();
virtual int GetNodeObjId(int theVtkID);
virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
@ -259,6 +265,8 @@ class SMESH_ActorDef : public SMESH_Actor
vtkProperty* my0DProp;
SMESH_CellLabelActor* my0DActor;
vtkProperty* myBallProp;
SMESH_CellLabelActor* myBallActor;
vtkProperty* my0DExtProp;
SMESH_DeviceActor* my0DExtActor;

View File

@ -161,6 +161,8 @@ namespace SMESH
std::map<SMDSAbs_ElementType,int> entities;
entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_0DElement,
theObject ? theObject->GetNbEntities(SMDSAbs_0DElement) : 0));
entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_Ball,
theObject ? theObject->GetNbEntities(SMDSAbs_Ball) : 0));
entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_Edge,
theObject ? theObject->GetNbEntities(SMDSAbs_Edge) : 0));
entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_Face,

View File

@ -87,8 +87,9 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
{
switch( theType )
{
case SMDSAbs_0DElement:
return VTK_VERTEX;
case SMDSAbs_0DElement: return VTK_VERTEX;
case SMDSAbs_Ball: return VTK_POLY_VERTEX;
case SMDSAbs_Edge:
if( theNbNodes == 2 ) return VTK_LINE;
@ -344,8 +345,8 @@ void SMESH_VisualObjDef::buildElemPrs()
// Calculate cells size
static SMDSAbs_ElementType aTypes[ 4 ] =
{ SMDSAbs_0DElement, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume };
static SMDSAbs_ElementType aTypes[ 5 ] =
{ SMDSAbs_Ball, SMDSAbs_0DElement, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume };
// get entity data
map<SMDSAbs_ElementType,int> nbEnts;
@ -359,6 +360,7 @@ void SMESH_VisualObjDef::buildElemPrs()
SMDS_Mesh::CheckMemory(); // PAL16631
vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ];
aCellsSize += 2 * nbEnts[ SMDSAbs_Ball ];
for ( int i = 2; i <= 3; i++ ) // iterate through faces and volumes
{
@ -387,7 +389,8 @@ void SMESH_VisualObjDef::buildElemPrs()
}
}
vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
vtkIdType aNbCells =
nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Ball ] + nbEnts[ SMDSAbs_Edge ] +
nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG )
@ -566,6 +569,7 @@ bool SMESH_VisualObjDef::IsValid() const
//MESSAGE("SMESH_VisualObjDef::IsValid");
return GetNbEntities(SMDSAbs_Node) > 0 ||
GetNbEntities(SMDSAbs_0DElement) > 0 ||
GetNbEntities(SMDSAbs_Ball) > 0 ||
GetNbEntities(SMDSAbs_Edge) > 0 ||
GetNbEntities(SMDSAbs_Face) > 0 ||
GetNbEntities(SMDSAbs_Volume) > 0 ;
@ -586,6 +590,9 @@ void SMESH_VisualObjDef::updateEntitiesFlags() {
if( myEntitiesCache[SMDSAbs_0DElement] != 0 || myEntitiesCache[SMDSAbs_0DElement] >= entities[SMDSAbs_0DElement] )
myEntitiesState &= ~SMESH_Actor::e0DElements;
if( myEntitiesCache[SMDSAbs_Ball] != 0 || myEntitiesCache[SMDSAbs_Ball] >= entities[SMDSAbs_Ball] )
myEntitiesState &= ~SMESH_Actor::eBallElem;
if( myEntitiesCache[SMDSAbs_Edge] != 0 || myEntitiesCache[SMDSAbs_Edge] >= entities[SMDSAbs_Edge] )
myEntitiesState &= ~SMESH_Actor::eEdges;
@ -701,6 +708,7 @@ int SMESH_MeshObj::GetElemDimension( const int theObjId )
switch ( aType )
{
case SMDSAbs_0DElement : return 0;
case SMDSAbs_Ball : return 0;
case SMDSAbs_Edge : return 1;
case SMDSAbs_Face : return 2;
case SMDSAbs_Volume: return 3;
@ -725,6 +733,10 @@ int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{
return myClient->Nb0DElements();
}
case SMDSAbs_Ball:
{
return myClient->NbBalls();
}
break;
case SMDSAbs_Edge:
{
@ -761,7 +773,13 @@ int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList&
break;
case SMDSAbs_0DElement:
{
SMDS_0DElementIteratorPtr anIter = myClient->elements0dIterator();
SMDS_ElemIteratorPtr anIter = myClient->elementsIterator(SMDSAbs_0DElement);
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
case SMDSAbs_Ball:
{
SMDS_ElemIteratorPtr anIter = myClient->elementGeomIterator(SMDSGeom_BALL);
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
@ -805,7 +823,7 @@ void SMESH_MeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor
//=================================================================================
bool SMESH_MeshObj::IsNodePrs() const
{
return myClient->Nb0DElements() == 0 && myClient->NbEdges() == 0 && myClient->NbFaces() == 0 && myClient->NbVolumes() == 0 ;
return myClient->Nb0DElements() + myClient->NbEdges() + myClient->NbFaces() + myClient->NbVolumes() + myClient->NbBalls() == 0 ;
}
@ -1031,6 +1049,7 @@ int SMESH_subMeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
return mySubMeshServer->GetNumberOfNodes( /*all=*/true );
}
break;
case SMDSAbs_Ball:
case SMDSAbs_0DElement:
case SMDSAbs_Edge:
case SMDSAbs_Face: