<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>
\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>
ADD_ELEM0D,
ADD_BIQUAD_QUADRANGLE,
ADD_TRIQUAD_HEXA,
- ADD_HEXAGONAL_PRISM
+ ADD_HEXAGONAL_PRISM,
+ ADD_BALL
};
struct log_block
EDGE,
FACE,
VOLUME,
- ELEM0D
+ ELEM0D,
+ BALL
};
typedef sequence<ElementType> array_of_ElementType ;
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
};
/*!
Entity_Hexagonal_Prism,
Entity_Polyhedra,
Entity_Quad_Polyhedra,
+ Entity_Ball,
Entity_Last
};
long Nb0DElements()
raises (SALOME::SALOME_Exception);
+ long NbBalls()
+ raises (SALOME::SALOME_Exception);
+
long NbEdges()
raises (SALOME::SALOME_Exception);
*/
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
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
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:
const bool doGroupOfNodes,
const bool doGroupOfEdges,
const bool doGroupOfFaces,
- const bool doGroupOfVolumes)
+ const bool doGroupOfVolumes,
+ const bool doGroupOf0DElems,
+ const bool doGroupOfBalls)
{
DriverMED_FamilyPtrList aFamilies;
- string anAllNodesGroupName = "Group_Of_All_Nodes";
- string anAllEdgesGroupName = "Group_Of_All_Edges";
- string anAllFacesGroupName = "Group_Of_All_Faces";
+ string anAllNodesGroupName = "Group_Of_All_Nodes";
+ 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;
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);
+ }
}
}
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;
myGroupNames.insert(string(theGroup->GetStoreName()));
Quantity_Color aColor = theGroup->GetColor();
- double aRed = aColor.Red();
+ double aRed = aColor.Red();
double aGreen = aColor.Green();
- double aBlue = aColor.Blue();
+ double aBlue = aColor.Blue();
int aR = int( aRed*255 );
int aG = int( aGreen*255 );
int aB = int( aBlue*255 );
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 );
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
{
// 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;
#include <set>
#define REST_NODES_FAMILY 1
-#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_EDGES_FAMILY -1
+#define REST_FACES_FAMILY -2
+#define REST_VOLUMES_FAMILY -3
+#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
{
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
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;
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
// Mesh dimension definition
TInt aSpaceDimension;
TCoordHelperPtr aCoordHelperPtr;
- {
+ {
bool anIsXDimension = false;
bool anIsYDimension = false;
bool anIsZDimension = false;
// Storing SMDS groups and sub-meshes as med families
//----------------------------------------------------
- int myNodesDefaultFamilyId = 0;
+ int myNodesDefaultFamilyId = 0;
int my0DElementsDefaultFamilyId = 0;
- int myEdgesDefaultFamilyId = 0;
- int myFacesDefaultFamilyId = 0;
- int myVolumesDefaultFamilyId = 0;
- int nbNodes = myMesh->NbNodes();
- //int nb0DElements = myMesh->Nb0DElements();
- 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;
+ int myBallsDefaultFamilyId = 0;
+ int myEdgesDefaultFamilyId = 0;
+ int myFacesDefaultFamilyId = 0;
+ int myVolumesDefaultFamilyId = 0;
+ int nbNodes = myMesh->NbNodes();
+ 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 (myDoGroupOf0DElems && nb0DElements) my0DElementsDefaultFamilyId = REST_0DELEM_FAMILY;
+ if (myDoGroupOfVolumes && nbVolumes) myBallsDefaultFamilyId = REST_BALL_FAMILY;
MESSAGE("Perform - aFamilyInfo");
//cout << " DriverMED_Family::MakeFamilies() " << endl;
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;
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
case SMDSAbs_0DElement:
defaultFamilyId = my0DElementsDefaultFamilyId;
break;
+ case SMDSAbs_Ball:
+ defaultFamilyId = myBallsDefaultFamilyId;
+ break;
case SMDSAbs_Edge:
defaultFamilyId = myEdgesDefaultFamilyId;
break;
}
// 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() ) {
- nbPolygonNodes += anElem->NbNodes();
- if ( ++iElem == aElemTypeData->_nbElems )
- break;
- }
+ while ( elemIterator->more() ) {
+ const SMDS_MeshElement* anElem = elemIterator->next();
+ nbPolygonNodes += anElem->NbNodes();
+ if ( ++iElem == aElemTypeData->_nbElems )
+ break;
}
}
else {
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;
// ----------------
else if (aElemTypeData->_geomType == ePOLYEDRE )
{
+ elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYHEDRA );
+
if ( nbPolyhedronNodes == 0 ) {
// Count nb of nodes
- while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
- const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
- if ( aPolyedre && aPolyedre->IsPoly()) {
- nbPolyhedronNodes += aPolyedre->NbNodes();
- nbPolyhedronFaces += aPolyedre->NbFaces();
- if ( ++iElem == aElemTypeData->_nbElems )
- break;
- }
+ while ( elemIterator->more() ) {
+ const SMDS_MeshElement* anElem = elemIterator->next();
+ const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
+ if ( !aPolyedre ) continue;
+ nbPolyhedronNodes += aPolyedre->NbNodes();
+ nbPolyhedronFaces += aPolyedre->NbFaces();
+ if ( ++iElem == aElemTypeData->_nbElems )
+ break;
}
}
else {
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;
}
} // 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
}
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
void AddGroupOfEdges();
void AddGroupOfFaces();
void AddGroupOfVolumes();
+ void AddGroupOf0DElems();
+ void AddGroupOfBalls();
/*! functions to prepare adding one mesh
*/
bool myDoGroupOfEdges;
bool myDoGroupOfFaces;
bool myDoGroupOfVolumes;
+ bool myDoGroupOf0DElems;
+ bool myDoGroupOfBalls;
};
if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
- vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
- vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",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();
VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
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];
my0DProp->Delete();
my0DActor->Delete();
+ myBallActor->Delete();
//my0DExtProp->Delete();
//my0DExtActor->Delete();
if(my0DActor)
my0DActor->SetCellsLabeled(theIsCellsLabeled);
+ if(myBallActor)
+ myBallActor->SetCellsLabeled(theIsCellsLabeled);
+
myTimeStamp->Modified();
}
if(my0DActor)
result = result || my0DActor->GetCellsLabeled();
+ if(myBallActor)
+ result = result || myBallActor->GetCellsLabeled();
+
return result;
}
my1DActor->GetMapper()->SetScalarVisibility(false);
my2DActor->GetMapper()->SetScalarVisibility(false);
my3DActor->GetMapper()->SetScalarVisibility(false);
+ myBallActor->GetMapper()->SetScalarVisibility(false);
myScalarBarActor->SetVisibility(false);
bool anIsScalarVisible = theMode > eNone;
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);
my3DExtActor->RemoveFromRender(theRenderer);
myNodeActor->RemoveFromRender(theRenderer);
my0DActor->RemoveFromRender(theRenderer);
+ myBallActor->RemoveFromRender(theRenderer);
my1DActor->RemoveFromRender(theRenderer);
theRenderer->RemoveActor(myScalarBarActor);
myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->Init(myVisualObj,myImplicitBoolean);
+ myBallActor->Init(myVisualObj,myImplicitBoolean);
//my0DExtActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->Init(myVisualObj,myImplicitBoolean);
my3DExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->GetMapper()->SetLookupTable(myLookupTable);
+ myBallActor->GetMapper()->SetLookupTable(myLookupTable);
//my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my1DActor->GetMapper()->SetLookupTable(myLookupTable);
myNodeExtActor->SetTransform(theTransform);
my0DActor->SetTransform(theTransform);
+ myBallActor->SetTransform(theTransform);
//my0DExtActor->SetTransform(theTransform);
my1DActor->SetTransform(theTransform);
myNodeExtActor->VisibilityOff();
my0DActor->VisibilityOff();
+ myBallActor->VisibilityOff();
//my0DExtActor->VisibilityOff();
my1DActor->VisibilityOff();
if(myEntityMode & e0DElements){
my0DActor->VisibilityOn();
}
+ if(myEntityMode & eBallElem){
+ myBallActor->VisibilityOn();
+ }
if(myEntityMode & eEdges && GetRepresentation() != ePoint){
my1DActor->VisibilityOn();
if(my0DActor)
my0DActor->UpdateLabels();
+ if(myBallActor)
+ myBallActor->UpdateLabels();
+
if(my1DActor)
my1DActor->UpdateLabels();
theMode &= ~e0DElements;
}
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
+ myEntityState &= ~eBallElem;
+ theMode &= ~eBallElem;
+ }
+
if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
myEntityState &= ~eEdges;
theMode &= ~eEdges;
if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
theMode |= e0DElements;
+ if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
+ theMode |= eBallElem;
+
if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
theMode |= eEdges;
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);
//my0DActor->SetProperty(aProp);
//my0DActor->SetBackfaceProperty(aBackProp);
my0DActor->SetRepresentation(aReperesent);
+ myBallActor->SetRepresentation(aReperesent);
//my0DExtActor->SetRepresentation(aReperesent);
switch(myControlMode){
if(my0DActor)
my0DActor->UpdateLabels();
+ if(myBallActor)
+ myBallActor->UpdateLabels();
+
if(my1DActor)
my1DActor->UpdateLabels();
::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();
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 );
myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
//my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
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;
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 };
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);
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);
vtkProperty* my0DProp;
SMESH_CellLabelActor* my0DActor;
+ vtkProperty* myBallProp;
+ SMESH_CellLabelActor* myBallActor;
vtkProperty* my0DExtProp;
SMESH_DeviceActor* my0DExtActor;
std::map<SMDSAbs_ElementType,int> GetEntitiesFromObject(SMESH_VisualObj *theObject) {
std::map<SMDSAbs_ElementType,int> entities;
- entities.insert(std::pair<SMDSAbs_ElementType,int>(SMDSAbs_0DElement,
+ 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,
{
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;
// 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;
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
{
}
}
- vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
- nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
+ vtkIdType aNbCells =
+ nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Ball ] + nbEnts[ SMDSAbs_Edge ] +
+ nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG )
MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize );
//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 ;
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;
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;
{
return myClient->Nb0DElements();
}
+ case SMDSAbs_Ball:
+ {
+ return myClient->NbBalls();
+ }
break;
case SMDSAbs_Edge:
{
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;
//=================================================================================
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 ;
}
return mySubMeshServer->GetNumberOfNodes( /*all=*/true );
}
break;
+ case SMDSAbs_Ball:
case SMDSAbs_0DElement:
case SMDSAbs_Edge:
case SMDSAbs_Face: