mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 09:20:34 +05:00
23418: [OCC] Mesh: Minimization of memory usage of SMESH
This commit is contained in:
parent
88141f757b
commit
4c16067d42
@ -28,8 +28,6 @@
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_QuadraticEdge.hxx"
|
||||
#include "SMDS_QuadraticFaceOfNodes.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "SMESHDS_GroupBase.hxx"
|
||||
#include "SMESHDS_GroupOnFilter.hxx"
|
||||
@ -253,26 +251,7 @@ bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem,
|
||||
theRes.setElement( anElem );
|
||||
|
||||
// Get nodes of the element
|
||||
SMDS_ElemIteratorPtr anIter;
|
||||
|
||||
if ( anElem->IsQuadratic() ) {
|
||||
switch ( anElem->GetType() ) {
|
||||
case SMDSAbs_Edge:
|
||||
anIter = dynamic_cast<const SMDS_VtkEdge*>
|
||||
(anElem)->interlacedNodesElemIterator();
|
||||
break;
|
||||
case SMDSAbs_Face:
|
||||
anIter = dynamic_cast<const SMDS_VtkFace*>
|
||||
(anElem)->interlacedNodesElemIterator();
|
||||
break;
|
||||
default:
|
||||
anIter = anElem->nodesIterator();
|
||||
}
|
||||
}
|
||||
else {
|
||||
anIter = anElem->nodesIterator();
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr anIter= anElem->interlacedNodesIterator();
|
||||
if ( anIter ) {
|
||||
SMESH_NodeXYZ p;
|
||||
while( anIter->more() ) {
|
||||
@ -771,8 +750,8 @@ double AspectRatio::GetValue( long theId )
|
||||
if ( myCurrElement && myCurrElement->GetVtkType() == VTK_QUAD )
|
||||
{
|
||||
// issue 21723
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myCurrElement->getMeshId()]->getGrid();
|
||||
if ( vtkCell* avtkCell = grid->GetCell( myCurrElement->getVtkId() ))
|
||||
vtkUnstructuredGrid* grid = const_cast<SMDS_Mesh*>( myMesh )->GetGrid();
|
||||
if ( vtkCell* avtkCell = grid->GetCell( myCurrElement->GetVtkID() ))
|
||||
aVal = Round( vtkMeshQuality::QuadAspectRatio( avtkCell ));
|
||||
}
|
||||
else
|
||||
@ -1015,8 +994,8 @@ double AspectRatio3D::GetValue( long theId )
|
||||
// Action from CoTech | ACTION 31.3:
|
||||
// EURIWARE BO: Homogenize the formulas used to calculate the Controls in SMESH to fit with
|
||||
// those of ParaView. The library used by ParaView for those calculations can be reused in SMESH.
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myCurrElement->getMeshId()]->getGrid();
|
||||
if ( vtkCell* avtkCell = grid->GetCell( myCurrElement->getVtkId() ))
|
||||
vtkUnstructuredGrid* grid = const_cast<SMDS_Mesh*>( myMesh )->GetGrid();
|
||||
if ( vtkCell* avtkCell = grid->GetCell( myCurrElement->GetVtkID() ))
|
||||
aVal = Round( vtkMeshQuality::TetAspectRatio( avtkCell ));
|
||||
}
|
||||
else
|
||||
@ -1035,7 +1014,7 @@ double AspectRatio3D::GetValue( const TSequenceOfXYZ& P )
|
||||
|
||||
int nbNodes = P.size();
|
||||
|
||||
if(myCurrElement->IsQuadratic()) {
|
||||
if( myCurrElement->IsQuadratic() ) {
|
||||
if(nbNodes==10) nbNodes=4; // quadratic tetrahedron
|
||||
else if(nbNodes==13) nbNodes=5; // quadratic pyramid
|
||||
else if(nbNodes==15) nbNodes=6; // quadratic pentahedron
|
||||
@ -1827,35 +1806,33 @@ bool Length2D::Value::operator<(const Length2D::Value& x) const
|
||||
void Length2D::GetValues(TValues& theValues)
|
||||
{
|
||||
TValues aValues;
|
||||
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
|
||||
for(; anIter->more(); ){
|
||||
for ( SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); anIter->more(); )
|
||||
{
|
||||
const SMDS_MeshFace* anElem = anIter->next();
|
||||
|
||||
if(anElem->IsQuadratic()) {
|
||||
const SMDS_VtkFace* F =
|
||||
dynamic_cast<const SMDS_VtkFace*>(anElem);
|
||||
if ( anElem->IsQuadratic() )
|
||||
{
|
||||
// use special nodes iterator
|
||||
SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
|
||||
SMDS_NodeIteratorPtr anIter = anElem->interlacedNodesIterator();
|
||||
long aNodeId[4] = { 0,0,0,0 };
|
||||
gp_Pnt P[4];
|
||||
|
||||
double aLength = 0;
|
||||
const SMDS_MeshElement* aNode;
|
||||
if(anIter->more()){
|
||||
aNode = anIter->next();
|
||||
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
|
||||
P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
|
||||
if ( anIter->more() )
|
||||
{
|
||||
const SMDS_MeshNode* aNode = anIter->next();
|
||||
P[0] = P[1] = SMESH_NodeXYZ( aNode );
|
||||
aNodeId[0] = aNodeId[1] = aNode->GetID();
|
||||
aLength = 0;
|
||||
}
|
||||
for(; anIter->more(); ){
|
||||
const SMDS_MeshNode* N1 = static_cast<const SMDS_MeshNode*> (anIter->next());
|
||||
P[2] = gp_Pnt(N1->X(),N1->Y(),N1->Z());
|
||||
for ( ; anIter->more(); )
|
||||
{
|
||||
const SMDS_MeshNode* N1 = anIter->next();
|
||||
P[2] = SMESH_NodeXYZ( N1 );
|
||||
aNodeId[2] = N1->GetID();
|
||||
aLength = P[1].Distance(P[2]);
|
||||
if(!anIter->more()) break;
|
||||
const SMDS_MeshNode* N2 = static_cast<const SMDS_MeshNode*> (anIter->next());
|
||||
P[3] = gp_Pnt(N2->X(),N2->Y(),N2->Z());
|
||||
const SMDS_MeshNode* N2 = anIter->next();
|
||||
P[3] = SMESH_NodeXYZ( N2 );
|
||||
aNodeId[3] = N2->GetID();
|
||||
aLength += P[2].Distance(P[3]);
|
||||
Value aValue1(aLength,aNodeId[1],aNodeId[2]);
|
||||
@ -1872,28 +1849,28 @@ void Length2D::GetValues(TValues& theValues)
|
||||
theValues.insert(aValue2);
|
||||
}
|
||||
else {
|
||||
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
|
||||
SMDS_NodeIteratorPtr aNodesIter = anElem->nodeIterator();
|
||||
long aNodeId[2] = {0,0};
|
||||
gp_Pnt P[3];
|
||||
|
||||
double aLength;
|
||||
const SMDS_MeshElement* aNode;
|
||||
if(aNodesIter->more()){
|
||||
if ( aNodesIter->more())
|
||||
{
|
||||
aNode = aNodesIter->next();
|
||||
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
|
||||
P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
|
||||
P[0] = P[1] = SMESH_NodeXYZ( aNode );
|
||||
aNodeId[0] = aNodeId[1] = aNode->GetID();
|
||||
aLength = 0;
|
||||
}
|
||||
for(; aNodesIter->more(); ){
|
||||
for( ; aNodesIter->more(); )
|
||||
{
|
||||
aNode = aNodesIter->next();
|
||||
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
|
||||
long anId = aNode->GetID();
|
||||
|
||||
P[2] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
|
||||
|
||||
|
||||
P[2] = SMESH_NodeXYZ( aNode );
|
||||
|
||||
aLength = P[1].Distance(P[2]);
|
||||
|
||||
|
||||
Value aValue(aLength,aNodeId[1],anId);
|
||||
aNodeId[1] = anId;
|
||||
P[1] = P[2];
|
||||
@ -1947,8 +1924,7 @@ double Deflection2D::GetValue( const TSequenceOfXYZ& P )
|
||||
{
|
||||
gc += P(i+1);
|
||||
|
||||
if ( const SMDS_FacePosition* fPos = dynamic_cast<const SMDS_FacePosition*>
|
||||
( P.getElement()->GetNode( i )->GetPosition() ))
|
||||
if ( SMDS_FacePositionPtr fPos = P.getElement()->GetNode( i )->GetPosition() )
|
||||
{
|
||||
uv.ChangeCoord(1) += fPos->GetUParameter();
|
||||
uv.ChangeCoord(2) += fPos->GetVParameter();
|
||||
@ -2124,59 +2100,24 @@ bool MultiConnection2D::Value::operator<(const MultiConnection2D::Value& x) cons
|
||||
void MultiConnection2D::GetValues(MValues& theValues)
|
||||
{
|
||||
if ( !myMesh ) return;
|
||||
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
|
||||
for(; anIter->more(); ){
|
||||
const SMDS_MeshFace* anElem = anIter->next();
|
||||
SMDS_ElemIteratorPtr aNodesIter;
|
||||
if ( anElem->IsQuadratic() )
|
||||
aNodesIter = dynamic_cast<const SMDS_VtkFace*>
|
||||
(anElem)->interlacedNodesElemIterator();
|
||||
else
|
||||
aNodesIter = anElem->nodesIterator();
|
||||
long aNodeId[3] = {0,0,0};
|
||||
for ( SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); anIter->more(); )
|
||||
{
|
||||
const SMDS_MeshFace* anElem = anIter->next();
|
||||
SMDS_NodeIteratorPtr aNodesIter = anElem->interlacedNodesIterator();
|
||||
|
||||
//int aNbConnects=0;
|
||||
const SMDS_MeshNode* aNode0;
|
||||
const SMDS_MeshNode* aNode1;
|
||||
const SMDS_MeshNode* aNode1 = anElem->GetNode( anElem->NbNodes() - 1 );
|
||||
const SMDS_MeshNode* aNode2;
|
||||
if(aNodesIter->more()){
|
||||
aNode0 = (SMDS_MeshNode*) aNodesIter->next();
|
||||
aNode1 = aNode0;
|
||||
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode1;
|
||||
aNodeId[0] = aNodeId[1] = aNodes->GetID();
|
||||
}
|
||||
for(; aNodesIter->more(); ) {
|
||||
aNode2 = (SMDS_MeshNode*) aNodesIter->next();
|
||||
long anId = aNode2->GetID();
|
||||
aNodeId[2] = anId;
|
||||
for ( ; aNodesIter->more(); )
|
||||
{
|
||||
aNode2 = aNodesIter->next();
|
||||
|
||||
Value aValue(aNodeId[1],aNodeId[2]);
|
||||
MValues::iterator aItr = theValues.find(aValue);
|
||||
if (aItr != theValues.end()){
|
||||
aItr->second += 1;
|
||||
//aNbConnects = nb;
|
||||
}
|
||||
else {
|
||||
theValues[aValue] = 1;
|
||||
//aNbConnects = 1;
|
||||
}
|
||||
//cout << "NodeIds: "<<aNodeId[1]<<","<<aNodeId[2]<<" nbconn="<<aNbConnects<<endl;
|
||||
aNodeId[1] = aNodeId[2];
|
||||
Value aValue ( aNode1->GetID(), aNode2->GetID() );
|
||||
MValues::iterator aItr = theValues.insert( std::make_pair( aValue, 0 )).first;
|
||||
aItr->second++;
|
||||
aNode1 = aNode2;
|
||||
}
|
||||
Value aValue(aNodeId[0],aNodeId[2]);
|
||||
MValues::iterator aItr = theValues.find(aValue);
|
||||
if (aItr != theValues.end()) {
|
||||
aItr->second += 1;
|
||||
//aNbConnects = nb;
|
||||
}
|
||||
else {
|
||||
theValues[aValue] = 1;
|
||||
//aNbConnects = 1;
|
||||
}
|
||||
//cout << "NodeIds: "<<aNodeId[0]<<","<<aNodeId[2]<<" nbconn="<<aNbConnects<<endl;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -2191,7 +2132,7 @@ double BallDiameter::GetValue( long theId )
|
||||
double diameter = 0;
|
||||
|
||||
if ( const SMDS_BallElement* ball =
|
||||
dynamic_cast<const SMDS_BallElement*>( myMesh->FindElement( theId )))
|
||||
myMesh->DownCast< SMDS_BallElement >( myMesh->FindElement( theId )))
|
||||
{
|
||||
diameter = ball->GetDiameter();
|
||||
}
|
||||
@ -2429,7 +2370,7 @@ void CoincidentNodes::SetMesh( const SMDS_Mesh* theMesh )
|
||||
if ( myMeshModifTracer.IsMeshModified() )
|
||||
{
|
||||
TIDSortedNodeSet nodesToCheck;
|
||||
SMDS_NodeIteratorPtr nIt = theMesh->nodesIterator(/*idInceasingOrder=*/true);
|
||||
SMDS_NodeIteratorPtr nIt = theMesh->nodesIterator();
|
||||
while ( nIt->more() )
|
||||
nodesToCheck.insert( nodesToCheck.end(), nIt->next() );
|
||||
|
||||
@ -2632,31 +2573,21 @@ inline void UpdateBorders(const FreeEdges::Border& theBorder,
|
||||
void FreeEdges::GetBoreders(TBorders& theBorders)
|
||||
{
|
||||
TBorders aRegistry;
|
||||
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
|
||||
for(; anIter->more(); ){
|
||||
for ( SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); anIter->more(); )
|
||||
{
|
||||
const SMDS_MeshFace* anElem = anIter->next();
|
||||
long anElemId = anElem->GetID();
|
||||
SMDS_ElemIteratorPtr aNodesIter;
|
||||
if ( anElem->IsQuadratic() )
|
||||
aNodesIter = static_cast<const SMDS_VtkFace*>(anElem)->
|
||||
interlacedNodesElemIterator();
|
||||
else
|
||||
aNodesIter = anElem->nodesIterator();
|
||||
SMDS_NodeIteratorPtr aNodesIter = anElem->interlacedNodesIterator();
|
||||
if ( !aNodesIter->more() ) continue;
|
||||
long aNodeId[2] = {0,0};
|
||||
const SMDS_MeshElement* aNode;
|
||||
if(aNodesIter->more()){
|
||||
aNode = aNodesIter->next();
|
||||
aNodeId[0] = aNodeId[1] = aNode->GetID();
|
||||
aNodeId[0] = anElem->GetNode( anElem->NbNodes()-1 )->GetID();
|
||||
for ( ; aNodesIter->more(); )
|
||||
{
|
||||
aNodeId[1] = aNodesIter->next()->GetID();
|
||||
Border aBorder( anElemId, aNodeId[0], aNodeId[1] );
|
||||
UpdateBorders( aBorder, aRegistry, theBorders );
|
||||
aNodeId[0] = aNodeId[1];
|
||||
}
|
||||
for(; aNodesIter->more(); ){
|
||||
aNode = aNodesIter->next();
|
||||
long anId = aNode->GetID();
|
||||
Border aBorder(anElemId,aNodeId[1],anId);
|
||||
aNodeId[1] = anId;
|
||||
UpdateBorders(aBorder,aRegistry,theBorders);
|
||||
}
|
||||
Border aBorder(anElemId,aNodeId[0],aNodeId[1]);
|
||||
UpdateBorders(aBorder,aRegistry,theBorders);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4008,24 +3939,20 @@ void ManifoldPart::expandBoundary
|
||||
void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink,
|
||||
ManifoldPart::TVectorOfFacePtr& theFaces ) const
|
||||
{
|
||||
std::set<SMDS_MeshCell *> aSetOfFaces;
|
||||
|
||||
// take all faces that shared first node
|
||||
SMDS_ElemIteratorPtr anItr = theLink.myNode1->facesIterator();
|
||||
for ( ; anItr->more(); )
|
||||
{
|
||||
SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next();
|
||||
if ( !aFace )
|
||||
continue;
|
||||
aSetOfFaces.insert( aFace );
|
||||
}
|
||||
SMDS_ElemIteratorPtr anItr = theLink.myNode1->GetInverseElementIterator( SMDSAbs_Face );
|
||||
SMDS_StdIterator< const SMDS_MeshElement*, SMDS_ElemIteratorPtr > faces( anItr ), facesEnd;
|
||||
std::set<const SMDS_MeshElement *> aSetOfFaces( faces, facesEnd );
|
||||
|
||||
// take all faces that shared second node
|
||||
anItr = theLink.myNode2->facesIterator();
|
||||
anItr = theLink.myNode2->GetInverseElementIterator( SMDSAbs_Face );
|
||||
// find the common part of two sets
|
||||
for ( ; anItr->more(); )
|
||||
{
|
||||
SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next();
|
||||
if ( aSetOfFaces.count( aFace ) )
|
||||
theFaces.push_back( aFace );
|
||||
const SMDS_MeshElement* aFace = anItr->next();
|
||||
if ( aSetOfFaces.count( aFace ))
|
||||
theFaces.push_back( (SMDS_MeshFace*) aFace );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ INCLUDE_DIRECTORIES(
|
||||
${KERNEL_INCLUDE_DIRS}
|
||||
${PROJECT_SOURCE_DIR}/src/SMESHUtils
|
||||
${PROJECT_SOURCE_DIR}/src/SMESHDS
|
||||
${PROJECT_SOURCE_DIR}/src/SMDS
|
||||
)
|
||||
|
||||
# additional preprocessor / compiler flags
|
||||
|
@ -884,7 +884,7 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
|
||||
{
|
||||
const bool reverse = ( elemData[ pos-1 ] < 0 );
|
||||
const int iQuad = face->IsQuadratic() ? 1 : 0;
|
||||
SMDS_ElemIteratorPtr nIter = face->interlacedNodesElemIterator();
|
||||
SMDS_NodeIteratorPtr nIter = face->interlacedNodesIterator();
|
||||
faceNodes.assign( SMDS_MeshElement::iterator( nIter ),
|
||||
SMDS_MeshElement::iterator());
|
||||
if ( iQuad && reverse )
|
||||
@ -1184,6 +1184,9 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
|
||||
|
||||
aResult = myErrorMessages.empty() ? DRS_OK : DRS_WARN_SKIP_ELEM;
|
||||
|
||||
myMesh->Modified();
|
||||
myMesh->CompactMesh();
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
@ -301,26 +301,26 @@ Driver_Mesh::Status DriverCGNS_Write::Perform()
|
||||
vector< double > coords( myMesh->NbNodes() );
|
||||
int iC;
|
||||
// X
|
||||
SMDS_NodeIteratorPtr nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
|
||||
SMDS_NodeIteratorPtr nIt = myMesh->nodesIterator();
|
||||
for ( int i = 0; nIt->more(); ++i ) coords[i] = nIt->next()->X();
|
||||
if ( cg_coord_write( _fn, iBase, iZone, CGNS_ENUMV(RealDouble),
|
||||
"CoordinateX", &coords[0], &iC) != CG_OK )
|
||||
return addMessage( cg_get_error(), /*fatal = */true );
|
||||
// Y
|
||||
nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
|
||||
nIt = myMesh->nodesIterator();
|
||||
for ( int i = 0; nIt->more(); ++i ) coords[i] = nIt->next()->Y();
|
||||
if ( cg_coord_write( _fn, iBase, iZone, CGNS_ENUMV(RealDouble),
|
||||
"CoordinateY", &coords[0], &iC) != CG_OK )
|
||||
return addMessage( cg_get_error(), /*fatal = */true );
|
||||
// Z
|
||||
nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
|
||||
nIt = myMesh->nodesIterator();
|
||||
for ( int i = 0; nIt->more(); ++i ) coords[i] = nIt->next()->Z();
|
||||
if ( cg_coord_write( _fn, iBase, iZone, CGNS_ENUMV(RealDouble),
|
||||
"CoordinateZ", &coords[0], &iC) != CG_OK )
|
||||
return addMessage( cg_get_error(), /*fatal = */true );
|
||||
|
||||
// store CGNS ids of nodes
|
||||
nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
|
||||
nIt = myMesh->nodesIterator();
|
||||
for ( int i = 0; nIt->more(); ++i )
|
||||
{
|
||||
const SMDS_MeshElement* n = nIt->next();
|
||||
|
@ -117,7 +117,7 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
|
||||
}
|
||||
|
||||
SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
|
||||
const SMDS_VtkVolume* v;
|
||||
const SMDS_MeshVolume* v;
|
||||
while(itVolumes->more())
|
||||
{
|
||||
const SMDS_MeshElement * elem = itVolumes->next();
|
||||
@ -125,7 +125,7 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
|
||||
{
|
||||
fprintf(aFileId, "%d %d ", elem->GetID(), 500+elem->NbNodes());
|
||||
|
||||
if (( v = dynamic_cast< const SMDS_VtkVolume*>( elem )))
|
||||
if (( v = myMesh->DownCast< SMDS_MeshVolume >( elem )))
|
||||
{
|
||||
std::vector<int> quant = v->GetQuantities();
|
||||
if ( !quant.empty() )
|
||||
@ -146,7 +146,7 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
|
||||
|
||||
fprintf(aFileId, "\n");
|
||||
}
|
||||
|
||||
|
||||
fclose(aFileId);
|
||||
|
||||
return aResult;
|
||||
|
@ -444,6 +444,9 @@ Driver_Mesh::Status DriverGMF_Read::Perform()
|
||||
}
|
||||
}
|
||||
|
||||
myMesh->Modified();
|
||||
myMesh->CompactMesh();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -574,3 +574,21 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
|
||||
common->myType = myType;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return a number of elements of a given type
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
size_t DriverMED_Family::NbElements( SMDSAbs_ElementType theType ) const
|
||||
{
|
||||
if ( myTypes.size() < 2 )
|
||||
return myElements.size();
|
||||
|
||||
int nb = 0;
|
||||
for ( ElementsSet::iterator e = myElements.begin(); e != myElements.end(); ++e )
|
||||
nb += ( theType == (*e)->GetType() );
|
||||
|
||||
return nb;
|
||||
}
|
||||
|
@ -119,9 +119,11 @@ class MESHDRIVERMED_EXPORT DriverMED_Family
|
||||
|
||||
bool MemberOf(std::string theGroupName) const;
|
||||
|
||||
int GetGroupAttributVal() const;
|
||||
int GetGroupAttributVal() const;
|
||||
void SetGroupAttributVal( int theValue);
|
||||
|
||||
size_t NbElements( SMDSAbs_ElementType ) const;
|
||||
|
||||
private:
|
||||
//! Initialize the tool by SMESHDS_GroupBase
|
||||
void Init (SMESHDS_GroupBase* group);
|
||||
|
@ -273,7 +273,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
||||
if ( anIsElemNum && !aBallInfo->myElemNum->empty() )
|
||||
maxID = *std::max_element( aBallInfo->myElemNum->begin(),
|
||||
aBallInfo->myElemNum->end() );
|
||||
myMesh->getGrid()->AllocateDiameters( maxID ); // performance optimization
|
||||
myMesh->GetGrid()->AllocateDiameters( maxID ); // performance optimization
|
||||
|
||||
// create balls
|
||||
SMDS_MeshElement* anElement;
|
||||
@ -1038,8 +1038,6 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
||||
aResult = addMessage( "Unknown exception", /*isFatal=*/true );
|
||||
}
|
||||
#endif
|
||||
if (myMesh)
|
||||
myMesh->compactMesh();
|
||||
|
||||
// Mantis issue 0020483
|
||||
if (aResult == DRS_OK && isDescConn) {
|
||||
@ -1137,6 +1135,14 @@ void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
|
||||
|
||||
if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( aGroupName )))
|
||||
{
|
||||
size_t groupSize = 0;
|
||||
for ( size_t i = 0; i < famVecPtr->size(); ++i )
|
||||
{
|
||||
DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
|
||||
groupSize += aFamily->NbElements( theGroup->GetType() );
|
||||
}
|
||||
theGroup->SMDSGroup().Reserve( groupSize );
|
||||
|
||||
for ( size_t i = 0; i < famVecPtr->size(); ++i )
|
||||
{
|
||||
DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "MED_Wrapper.hxx"
|
||||
#include "SMDS_IteratorOnIterators.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
|
||||
@ -101,7 +100,7 @@ bool DriverMED_W_Field::Set(SMESHDS_Mesh * mesh,
|
||||
for ( int iG = 0; iG < SMDSEntity_Last; ++iG )
|
||||
{
|
||||
SMDSAbs_EntityType geom = (SMDSAbs_EntityType) iG;
|
||||
SMDSAbs_ElementType t = SMDS_MeshCell::toSmdsType( geom );
|
||||
SMDSAbs_ElementType t = SMDS_MeshCell::ElemType( geom );
|
||||
if ( t != _elemType ) continue;
|
||||
|
||||
nbElems = mesh->GetMeshInfo().NbElements( geom );
|
||||
|
@ -31,9 +31,7 @@
|
||||
#include "MED_Factory.hxx"
|
||||
#include "MED_Utilities.hxx"
|
||||
#include "SMDS_IteratorOnIterators.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
|
||||
@ -360,10 +358,6 @@ namespace
|
||||
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
{
|
||||
Status aResult = DRS_OK;
|
||||
if (myMesh->hasConstructionEdges() || myMesh->hasConstructionFaces()) {
|
||||
INFOS("SMDS_MESH with hasConstructionEdges() or hasConstructionFaces() do not supports!!!");
|
||||
return DRS_FAIL;
|
||||
}
|
||||
try {
|
||||
//MESSAGE("Perform - myFile : "<<myFile);
|
||||
|
||||
@ -408,7 +402,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
const SMDS_MeshNode* aNode = aNodesIter->next();
|
||||
aBounds[0] = min(aBounds[0],aNode->X());
|
||||
aBounds[1] = max(aBounds[1],aNode->X());
|
||||
|
||||
|
||||
aBounds[2] = min(aBounds[2],aNode->Y());
|
||||
aBounds[3] = max(aBounds[3],aNode->Y());
|
||||
|
||||
@ -454,7 +448,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(/*idInceasingOrder=*/true);
|
||||
SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
|
||||
switch ( aSpaceDimension ) {
|
||||
case 3:
|
||||
aCoordHelperPtr.reset(new TCoordHelper(aNodesIter,aXYZGetCoord,aXYZName));
|
||||
@ -857,7 +851,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
|
||||
// Treat POLYEDREs
|
||||
// ----------------
|
||||
else if (aElemTypeData->_geomType == ePOLYEDRE )
|
||||
else if ( aElemTypeData->_geomType == ePOLYEDRE )
|
||||
{
|
||||
elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYHEDRA );
|
||||
|
||||
@ -865,10 +859,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
// Count nb of nodes
|
||||
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();
|
||||
nbPolyhedronNodes += anElem->NbNodes();
|
||||
nbPolyhedronFaces += anElem->NbFaces();
|
||||
if ( ++iElem == aElemTypeData->_nbElems )
|
||||
break;
|
||||
}
|
||||
@ -893,8 +885,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
|
||||
TInt iFace = 0, iNode = 0;
|
||||
while ( elemIterator->more() )
|
||||
{
|
||||
const SMDS_MeshElement* anElem = elemIterator->next();
|
||||
const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
|
||||
const SMDS_MeshElement* anElem = elemIterator->next();
|
||||
const SMDS_MeshVolume *aPolyedre = myMesh->DownCast< SMDS_MeshVolume >( anElem );
|
||||
if ( !aPolyedre ) continue;
|
||||
// index
|
||||
TInt aNbFaces = aPolyedre->NbFaces();
|
||||
|
@ -40,6 +40,7 @@
|
||||
class SMESHDS_Mesh;
|
||||
class SMESHDS_GroupBase;
|
||||
class SMESHDS_SubMesh;
|
||||
class SMDS_MeshElement;
|
||||
|
||||
class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
|
||||
{
|
||||
|
@ -142,6 +142,9 @@ Driver_Mesh::Status DriverSTL_R_SMDS_Mesh::Perform()
|
||||
else
|
||||
aResult = readBinary( file );
|
||||
|
||||
myMesh->Modified();
|
||||
myMesh->CompactMesh();
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
@ -93,11 +93,11 @@ namespace
|
||||
|
||||
DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh()
|
||||
{
|
||||
if (myGroup != 0)
|
||||
delete myGroup;
|
||||
TGroupNamesMap::iterator grp2name = myGroupNames.begin();
|
||||
for ( ; grp2name != myGroupNames.end(); ++grp2name )
|
||||
delete grp2name->first;
|
||||
}
|
||||
|
||||
|
||||
Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
{
|
||||
Kernel_Utils::Localizer loc;
|
||||
@ -137,7 +137,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
}
|
||||
}
|
||||
// Move nodes to SI unit system
|
||||
const double lenFactor = aUnitsRecord.factors[ UNV164::LENGTH_FACTOR ];
|
||||
const double lenFactor = aUnitsRecord.factors[ UNV164::LENGTH_FACTOR ];
|
||||
if ( lenFactor != 1. )
|
||||
{
|
||||
TDataSet::iterator nodeIter = aDataSet2411.begin(), nodeEnd;
|
||||
@ -187,23 +187,23 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
else if(IsFace(aRec.fe_descriptor_id)) {
|
||||
//MESSAGE("add face " << aRec.label);
|
||||
switch(aRec.fe_descriptor_id){
|
||||
case 41: // Plane Stress Linear Triangle
|
||||
case 51: // Plane Strain Linear Triangle
|
||||
case 61: // Plate Linear Triangle
|
||||
case 74: // Membrane Linear Triangle
|
||||
case 81: // Axisymetric Solid Linear Triangle
|
||||
case 91: // Thin Shell Linear Triangle
|
||||
case 41: // Plane Stress Linear Triangle
|
||||
case 51: // Plane Strain Linear Triangle
|
||||
case 61: // Plate Linear Triangle
|
||||
case 74: // Membrane Linear Triangle
|
||||
case 81: // Axisymetric Solid Linear Triangle
|
||||
case 91: // Thin Shell Linear Triangle
|
||||
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
|
||||
aRec.node_labels[1],
|
||||
aRec.node_labels[2],
|
||||
aRec.label);
|
||||
break;
|
||||
|
||||
case 42: // Plane Stress Parabolic Triangle
|
||||
case 52: // Plane Strain Parabolic Triangle
|
||||
case 62: // Plate Parabolic Triangle
|
||||
case 72: // Membrane Parabolic Triangle
|
||||
case 82: // Axisymetric Solid Parabolic Triangle
|
||||
case 42: // Plane Stress Parabolic Triangle
|
||||
case 52: // Plane Strain Parabolic Triangle
|
||||
case 62: // Plate Parabolic Triangle
|
||||
case 72: // Membrane Parabolic Triangle
|
||||
case 82: // Axisymetric Solid Parabolic Triangle
|
||||
case 92: // Thin Shell Parabolic Triangle
|
||||
if ( aRec.node_labels.size() == 7 )
|
||||
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
|
||||
@ -224,12 +224,12 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
aRec.label);
|
||||
break;
|
||||
|
||||
case 44: // Plane Stress Linear Quadrilateral
|
||||
case 54: // Plane Strain Linear Quadrilateral
|
||||
case 64: // Plate Linear Quadrilateral
|
||||
case 71: // Membrane Linear Quadrilateral
|
||||
case 44: // Plane Stress Linear Quadrilateral
|
||||
case 54: // Plane Strain Linear Quadrilateral
|
||||
case 64: // Plate Linear Quadrilateral
|
||||
case 71: // Membrane Linear Quadrilateral
|
||||
case 84: // Axisymetric Solid Linear Quadrilateral
|
||||
case 94: // Thin Shell Linear Quadrilateral
|
||||
case 94: // Thin Shell Linear Quadrilateral
|
||||
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
|
||||
aRec.node_labels[1],
|
||||
aRec.node_labels[2],
|
||||
@ -237,12 +237,12 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
aRec.label);
|
||||
break;
|
||||
|
||||
case 45: // Plane Stress Parabolic Quadrilateral
|
||||
case 55: // Plane Strain Parabolic Quadrilateral
|
||||
case 65: // Plate Parabolic Quadrilateral
|
||||
case 75: // Membrane Parabolic Quadrilateral
|
||||
case 85: // Axisymetric Solid Parabolic Quadrilateral
|
||||
case 95: // Thin Shell Parabolic Quadrilateral
|
||||
case 45: // Plane Stress Parabolic Quadrilateral
|
||||
case 55: // Plane Strain Parabolic Quadrilateral
|
||||
case 65: // Plate Parabolic Quadrilateral
|
||||
case 75: // Membrane Parabolic Quadrilateral
|
||||
case 85: // Axisymetric Solid Parabolic Quadrilateral
|
||||
case 95: // Thin Shell Parabolic Quadrilateral
|
||||
if ( aRec.node_labels.size() == 9 )
|
||||
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
|
||||
aRec.node_labels[2],
|
||||
@ -295,7 +295,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
aRec.node_labels[7],
|
||||
aRec.label);
|
||||
break;
|
||||
|
||||
|
||||
case 112: // Solid Linear Prism - PRISM6
|
||||
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
|
||||
aRec.node_labels[2],
|
||||
@ -305,7 +305,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
aRec.node_labels[4],
|
||||
aRec.label);
|
||||
break;
|
||||
|
||||
|
||||
case 113: // Solid Quadratic Prism - PRISM15
|
||||
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
|
||||
aRec.node_labels[4],
|
||||
@ -328,7 +328,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
aRec.node_labels[7],
|
||||
aRec.label);
|
||||
break;
|
||||
|
||||
|
||||
case 115: // Solid Linear Brick - HEX8
|
||||
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
|
||||
aRec.node_labels[3],
|
||||
@ -396,101 +396,63 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
}
|
||||
}
|
||||
{
|
||||
using namespace UNV2417;
|
||||
using namespace UNV2417;
|
||||
TDataSet aDataSet2417;
|
||||
UNV2417::Read(in_stream,aDataSet2417);
|
||||
if(MYDEBUG) MESSAGE("Perform - aDataSet2417.size() = "<<aDataSet2417.size());
|
||||
if (aDataSet2417.size() > 0) {
|
||||
myGroup = new SMDS_MeshGroup(myMesh);
|
||||
if (aDataSet2417.size() > 0)
|
||||
{
|
||||
TDataSet::const_iterator anIter = aDataSet2417.begin();
|
||||
for(; anIter != aDataSet2417.end(); anIter++){
|
||||
const TGroupId& aLabel = anIter->first;
|
||||
for ( ; anIter != aDataSet2417.end(); anIter++ )
|
||||
{
|
||||
const TRecord& aRec = anIter->second;
|
||||
|
||||
int aNodesNb = aRec.NodeList.size();
|
||||
int aElementsNb = aRec.ElementList.size();
|
||||
int aNodesNb = aRec.NodeList.size();
|
||||
int aElementsNb = aRec.ElementList.size();
|
||||
|
||||
bool useSuffix = ((aNodesNb > 0) && (aElementsNb > 0));
|
||||
int i;
|
||||
if (aNodesNb > 0) {
|
||||
SMDS_MeshGroup* aNodesGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Node);
|
||||
if ( aNodesNb > 0 )
|
||||
{
|
||||
SMDS_MeshGroup* aNodesGroup = new SMDS_MeshGroup( myMesh );
|
||||
std::string aGrName = (useSuffix) ? aRec.GroupName + "_Nodes" : aRec.GroupName;
|
||||
int i = aGrName.find( "\r" );
|
||||
if (i > 0)
|
||||
aGrName.erase (i, 2);
|
||||
myGroupNames.insert(TGroupNamesMap::value_type(aNodesGroup, aGrName));
|
||||
myGroupId.insert(TGroupIdMap::value_type(aNodesGroup, aLabel));
|
||||
myGroupNames.insert( std::make_pair( aNodesGroup, aGrName ));
|
||||
|
||||
for (i = 0; i < aNodesNb; i++) {
|
||||
const SMDS_MeshNode* aNode = myMesh->FindNode(aRec.NodeList[i]);
|
||||
if (aNode)
|
||||
aNodesGroup->Add(aNode);
|
||||
}
|
||||
for ( int i = 0; i < aNodesNb; i++ )
|
||||
if ( const SMDS_MeshNode* aNode = myMesh->FindNode( aRec.NodeList[i] ))
|
||||
aNodesGroup->Add( aNode );
|
||||
}
|
||||
if (aElementsNb > 0){
|
||||
SMDS_MeshGroup* aEdgesGroup = 0;
|
||||
SMDS_MeshGroup* aFacesGroup = 0;
|
||||
SMDS_MeshGroup* aVolumeGroup = 0;
|
||||
if ( aElementsNb > 0 )
|
||||
{
|
||||
std::vector< SMDS_MeshGroup* > aGroupVec( SMDSAbs_NbElementTypes, (SMDS_MeshGroup*)0 );
|
||||
const char* aSuffix[] = { "", "", "_Edges", "_Faces", "_Volumes", "_0D", "_Balls" };
|
||||
bool createdGroup = false;
|
||||
for ( int i = 0; i < aElementsNb; i++)
|
||||
{
|
||||
const SMDS_MeshElement* aElement = myMesh->FindElement( aRec.ElementList[i] );
|
||||
if ( !aElement ) continue;
|
||||
|
||||
for (i = 0; i < aElementsNb; i++) {
|
||||
const SMDS_MeshElement* aElement = myMesh->FindElement(aRec.ElementList[i]);
|
||||
if (aElement) {
|
||||
switch (aElement->GetType()) {
|
||||
|
||||
case SMDSAbs_Edge:
|
||||
if (!aEdgesGroup) {
|
||||
aEdgesGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Edge);
|
||||
if (!useSuffix && createdGroup) useSuffix = true;
|
||||
std::string aEdgesGrName = (useSuffix) ? aRec.GroupName + "_Edges" : aRec.GroupName;
|
||||
int i = aEdgesGrName.find( "\r" );
|
||||
if (i > 0)
|
||||
aEdgesGrName.erase (i, 2);
|
||||
myGroupNames.insert(TGroupNamesMap::value_type(aEdgesGroup, aEdgesGrName));
|
||||
myGroupId.insert(TGroupIdMap::value_type(aEdgesGroup, aLabel));
|
||||
createdGroup = true;
|
||||
}
|
||||
aEdgesGroup->Add(aElement);
|
||||
break;
|
||||
|
||||
case SMDSAbs_Face:
|
||||
if (!aFacesGroup) {
|
||||
aFacesGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Face);
|
||||
if (!useSuffix && createdGroup) useSuffix = true;
|
||||
std::string aFacesGrName = (useSuffix) ? aRec.GroupName + "_Faces" : aRec.GroupName;
|
||||
int i = aFacesGrName.find( "\r" );
|
||||
if (i > 0)
|
||||
aFacesGrName.erase (i, 2);
|
||||
myGroupNames.insert(TGroupNamesMap::value_type(aFacesGroup, aFacesGrName));
|
||||
myGroupId.insert(TGroupIdMap::value_type(aFacesGroup, aLabel));
|
||||
createdGroup = true;
|
||||
}
|
||||
aFacesGroup->Add(aElement);
|
||||
break;
|
||||
|
||||
case SMDSAbs_Volume:
|
||||
if (!aVolumeGroup) {
|
||||
aVolumeGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Volume);
|
||||
if (!useSuffix && createdGroup) useSuffix = true;
|
||||
std::string aVolumeGrName = (useSuffix) ? aRec.GroupName + "_Volumes" : aRec.GroupName;
|
||||
int i = aVolumeGrName.find( "\r" );
|
||||
if (i > 0)
|
||||
aVolumeGrName.erase (i, 2);
|
||||
myGroupNames.insert(TGroupNamesMap::value_type(aVolumeGroup, aVolumeGrName));
|
||||
myGroupId.insert(TGroupIdMap::value_type(aVolumeGroup, aLabel));
|
||||
createdGroup = true;
|
||||
}
|
||||
aVolumeGroup->Add(aElement);
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
SMDS_MeshGroup * & aGroup = aGroupVec[ aElement->GetType() ];
|
||||
if ( !aGroup )
|
||||
{
|
||||
aGroup = new SMDS_MeshGroup( myMesh );
|
||||
if (!useSuffix && createdGroup) useSuffix = true;
|
||||
std::string aGrName = aRec.GroupName;
|
||||
int i = aGrName.find( "\r" );
|
||||
if ( i > 0 )
|
||||
aGrName.erase (i, 2);
|
||||
if ( useSuffix )
|
||||
aGrName += aSuffix[ aElement->GetType() ];
|
||||
myGroupNames.insert( std::make_pair( aGroup, aGrName ));
|
||||
createdGroup = true;
|
||||
}
|
||||
aGroup->Add(aElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const std::exception& exc){
|
||||
INFOS("Follow exception was cought:\n\t"<<exc.what());
|
||||
@ -499,6 +461,9 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
|
||||
INFOS("Unknown exception was cought !!!");
|
||||
}
|
||||
if (myMesh)
|
||||
myMesh->compactMesh();
|
||||
{
|
||||
myMesh->Modified();
|
||||
myMesh->CompactMesh();
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
@ -30,32 +30,22 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
class SMDS_Mesh;
|
||||
class SMDS_MeshGroup;
|
||||
|
||||
|
||||
typedef std::map<SMDS_MeshGroup*, std::string> TGroupNamesMap;
|
||||
typedef std::map<SMDS_MeshGroup*, int> TGroupIdMap;
|
||||
|
||||
typedef std::map<SMDS_MeshGroup*, std::string> TGroupNamesMap;
|
||||
typedef std::map<SMDS_MeshGroup*, int> TGroupIdMap;
|
||||
|
||||
class MESHDRIVERUNV_EXPORT DriverUNV_R_SMDS_Mesh: public Driver_SMDS_Mesh
|
||||
{
|
||||
public:
|
||||
DriverUNV_R_SMDS_Mesh():Driver_SMDS_Mesh(),myGroup(0) {};
|
||||
DriverUNV_R_SMDS_Mesh():Driver_SMDS_Mesh() {};
|
||||
~DriverUNV_R_SMDS_Mesh();
|
||||
|
||||
|
||||
virtual Status Perform();
|
||||
|
||||
const SMDS_MeshGroup* GetGroup() const { return myGroup;}
|
||||
const TGroupNamesMap& GetGroupNamesMap() const { return myGroupNames; }
|
||||
const TGroupIdMap& GetGroupIdMap() const { return myGroupId; }
|
||||
TGroupNamesMap& GetGroupNamesMap() { return myGroupNames; }
|
||||
|
||||
private:
|
||||
SMDS_MeshGroup* myGroup;
|
||||
TGroupNamesMap myGroupNames;
|
||||
TGroupIdMap myGroupId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,9 +25,6 @@
|
||||
#include "DriverUNV_W_SMDS_Mesh.h"
|
||||
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_QuadraticEdge.hxx"
|
||||
#include "SMDS_QuadraticFaceOfNodes.hxx"
|
||||
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
|
||||
#include "SMESHDS_GroupBase.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace UNV2417{
|
||||
@ -34,9 +34,9 @@ namespace UNV2417{
|
||||
typedef std::vector<int> TListOfId; // Nodal connectivitiesList of Id
|
||||
|
||||
struct TRecord{
|
||||
std::string GroupName;
|
||||
TListOfId NodeList;
|
||||
TListOfId ElementList;
|
||||
std::string GroupName;
|
||||
TListOfId NodeList;
|
||||
TListOfId ElementList;
|
||||
};
|
||||
|
||||
typedef int TGroupId; // type of element label
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "SMDS_BallElement.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
#include "SMESHDS_Script.hxx"
|
||||
#include "SMESH_Actor.h"
|
||||
@ -81,54 +80,6 @@ static int MYDEBUGWITHFILES = 0;
|
||||
Class : SMESH_VisualObjDef
|
||||
Description : Base class for all mesh objects to be visuilised
|
||||
*/
|
||||
|
||||
//=================================================================================
|
||||
// function : getCellType
|
||||
// purpose : Get type of VTK cell
|
||||
//=================================================================================
|
||||
// static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
|
||||
// const bool thePoly,
|
||||
// const int theNbNodes )
|
||||
// {
|
||||
// switch( theType )
|
||||
// {
|
||||
// case SMDSAbs_0DElement: return VTK_VERTEX;
|
||||
|
||||
// case SMDSAbs_Ball: return VTK_POLY_VERTEX;
|
||||
|
||||
// case SMDSAbs_Edge:
|
||||
// if( theNbNodes == 2 ) return VTK_LINE;
|
||||
// else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE;
|
||||
// else return VTK_EMPTY_CELL;
|
||||
|
||||
// case SMDSAbs_Face :
|
||||
// if (thePoly && theNbNodes>2 ) return VTK_POLYGON;
|
||||
// else if ( theNbNodes == 3 ) return VTK_TRIANGLE;
|
||||
// else if ( theNbNodes == 4 ) return VTK_QUAD;
|
||||
// else if ( theNbNodes == 6 ) return VTK_QUADRATIC_TRIANGLE;
|
||||
// else if ( theNbNodes == 8 ) return VTK_QUADRATIC_QUAD;
|
||||
// else if ( theNbNodes == 9 ) return VTK_BIQUADRATIC_QUAD;
|
||||
// else if ( theNbNodes == 7 ) return VTK_BIQUADRATIC_TRIANGLE;
|
||||
// else return VTK_EMPTY_CELL;
|
||||
|
||||
// case SMDSAbs_Volume:
|
||||
// if (thePoly && theNbNodes>3 ) return VTK_POLYHEDRON; //VTK_CONVEX_POINT_SET;
|
||||
// else if ( theNbNodes == 4 ) return VTK_TETRA;
|
||||
// else if ( theNbNodes == 5 ) return VTK_PYRAMID;
|
||||
// else if ( theNbNodes == 6 ) return VTK_WEDGE;
|
||||
// else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
|
||||
// else if ( theNbNodes == 12 ) return VTK_HEXAGONAL_PRISM;
|
||||
// else if ( theNbNodes == 10 ) return VTK_QUADRATIC_TETRA;
|
||||
// else if ( theNbNodes == 20 ) return VTK_QUADRATIC_HEXAHEDRON;
|
||||
// else if ( theNbNodes == 27 ) return VTK_TRIQUADRATIC_HEXAHEDRON;
|
||||
// else if ( theNbNodes == 15 ) return VTK_QUADRATIC_WEDGE;
|
||||
// else if ( theNbNodes == 13 ) return VTK_QUADRATIC_PYRAMID; //VTK_CONVEX_POINT_SET;
|
||||
// else return VTK_EMPTY_CELL;
|
||||
|
||||
// default: return VTK_EMPTY_CELL;
|
||||
// }
|
||||
// }
|
||||
|
||||
//=================================================================================
|
||||
// functions : SMESH_VisualObjDef
|
||||
// purpose : Constructor
|
||||
@ -178,7 +129,7 @@ vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID )
|
||||
if( this->GetMesh() ) {
|
||||
aNode = this->GetMesh()->FindNode(theObjID);
|
||||
}
|
||||
return aNode ? aNode->getVtkId() : -1;
|
||||
return aNode ? aNode->GetVtkID() : -1;
|
||||
}
|
||||
|
||||
vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
|
||||
@ -188,7 +139,7 @@ vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
|
||||
TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
|
||||
return i == myVTK2SMDSElems.end() ? -1 : i->second;
|
||||
}
|
||||
return this->GetMesh()->fromVtkToSmds(theVTKID);
|
||||
return this->GetMesh()->FromVtkToSmds(theVTKID);
|
||||
}
|
||||
|
||||
vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
|
||||
@ -203,7 +154,7 @@ vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
|
||||
if ( this->GetMesh() )
|
||||
e = this->GetMesh()->FindElement(theObjID);
|
||||
|
||||
return e ? e->getVtkId() : -1;
|
||||
return e ? e->GetVtkID() : -1;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -280,15 +231,15 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid)
|
||||
else
|
||||
{
|
||||
myLocalGrid = false;
|
||||
if (!GetMesh()->isCompacted())
|
||||
if (!GetMesh()->IsCompacted())
|
||||
{
|
||||
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh()
|
||||
if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!");
|
||||
GetMesh()->compactMesh();
|
||||
GetMesh()->CompactMesh();
|
||||
if ( SMESHDS_Mesh* m = dynamic_cast<SMESHDS_Mesh*>( GetMesh() )) // IPAL53915
|
||||
m->GetScript()->SetModified(false); // drop IsModified set in compactMesh()
|
||||
}
|
||||
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
|
||||
vtkUnstructuredGrid *theGrid = GetMesh()->GetGrid();
|
||||
updateEntitiesFlags();
|
||||
myGrid->ShallowCopy(theGrid);
|
||||
//MESSAGE(myGrid->GetReferenceCount());
|
||||
@ -395,17 +346,16 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
if((*anIter)->GetEntityType() != SMDSEntity_Polyhedra &&
|
||||
(*anIter)->GetEntityType() != SMDSEntity_Quad_Polyhedra) {
|
||||
aCellsSize += (*anIter)->NbNodes() + 1;
|
||||
}
|
||||
}
|
||||
// Special case for the VTK_POLYHEDRON:
|
||||
// itsinput cellArray is of special format.
|
||||
// [nCellFaces, nFace0Pts, i, j, k, nFace1Pts, i, j, k, ...]
|
||||
// [nCellFaces, nFace0Pts, i, j, k, nFace1Pts, i, j, k, ...]
|
||||
else {
|
||||
if( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(*anIter) ) {
|
||||
if ( const SMDS_MeshVolume* ph = SMDS_Mesh::DownCast<SMDS_MeshVolume>( *anIter )) {
|
||||
int nbFaces = ph->NbFaces();
|
||||
aCellsSize += (1 + ph->NbFaces());
|
||||
for( int i = 1; i <= nbFaces; i++ ) {
|
||||
for( int i = 1; i <= nbFaces; i++ )
|
||||
aCellsSize += ph->NbFaceNodes(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,16 +417,14 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
|
||||
if (aType == SMDSAbs_Volume && anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
|
||||
anIdList->Reset();
|
||||
if ( const SMDS_VtkVolume* ph = dynamic_cast<const SMDS_VtkVolume*>(anElem) ) {
|
||||
if ( const SMDS_MeshVolume* ph = SMDS_Mesh::DownCast<SMDS_MeshVolume>( anElem )) {
|
||||
int nbFaces = ph->NbFaces();
|
||||
anIdList->InsertNextId(nbFaces);
|
||||
for( int i = 1; i <= nbFaces; i++ ) {
|
||||
anIdList->InsertNextId(ph->NbFaceNodes(i));
|
||||
for(int j = 1; j <= ph->NbFaceNodes(i); j++) {
|
||||
const SMDS_MeshNode* n = ph->GetFaceNode(i,j);
|
||||
if(n) {
|
||||
anIdList->InsertNextId(mySMDS2VTKNodes[n->GetID()]);
|
||||
}
|
||||
if ( const SMDS_MeshNode* n = ph->GetFaceNode( i, j ))
|
||||
anIdList->InsertNextId( mySMDS2VTKNodes[ n->GetID() ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -504,11 +452,8 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
//Store diameters of the balls
|
||||
if(aScalars) {
|
||||
double aDiam = 0;
|
||||
if(aType == SMDSAbs_Ball) {
|
||||
if (const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>(anElem) ) {
|
||||
aDiam = ball->GetDiameter();
|
||||
}
|
||||
}
|
||||
if (const SMDS_BallElement* ball = SMDS_Mesh::DownCast<SMDS_BallElement>(anElem) )
|
||||
aDiam = ball->GetDiameter();
|
||||
aScalars->SetTuple(aCurId,&aDiam);
|
||||
}
|
||||
|
||||
@ -573,14 +518,14 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
|
||||
|
||||
vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
|
||||
{
|
||||
if ( !myLocalGrid && !GetMesh()->isCompacted() )
|
||||
if ( !myLocalGrid && !GetMesh()->IsCompacted() )
|
||||
{
|
||||
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh()
|
||||
GetMesh()->compactMesh();
|
||||
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in CompactMesh()
|
||||
GetMesh()->CompactMesh();
|
||||
if ( SMESHDS_Mesh* m = dynamic_cast<SMESHDS_Mesh*>( GetMesh() )) // IPAL53915
|
||||
m->GetScript()->SetModified(false); // drop IsModified set in compactMesh()
|
||||
m->GetScript()->SetModified(false); // drop IsModified set in CompactMesh()
|
||||
updateEntitiesFlags();
|
||||
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
|
||||
vtkUnstructuredGrid *theGrid = GetMesh()->GetGrid();
|
||||
myGrid->ShallowCopy(theGrid);
|
||||
}
|
||||
return myGrid;
|
||||
|
@ -42,96 +42,72 @@ SET(_link_LIBRARIES
|
||||
# header files / no moc processing
|
||||
SET(SMDS_HEADERS
|
||||
ObjectPool.hxx
|
||||
SMDS_TypeOfPosition.hxx
|
||||
SMDSAbs_ElementType.hxx
|
||||
SMDS_BallElement.hxx
|
||||
SMDS_CellOfNodes.hxx
|
||||
SMDS_Downward.hxx
|
||||
SMDS_EdgePosition.hxx
|
||||
SMDS_ElemIterator.hxx
|
||||
SMDS_ElementFactory.hxx
|
||||
SMDS_FaceOfNodes.hxx
|
||||
SMDS_FacePosition.hxx
|
||||
SMDS_Iterator.hxx
|
||||
SMDS_IteratorOnIterators.hxx
|
||||
SMDS_LinearEdge.hxx
|
||||
SMDS_Mesh.hxx
|
||||
SMDS_Mesh0DElement.hxx
|
||||
SMDS_LinearEdge.hxx
|
||||
SMDS_MeshCell.hxx
|
||||
SMDS_MeshEdge.hxx
|
||||
SMDS_MeshElement.hxx
|
||||
SMDS_MeshElementIDFactory.hxx
|
||||
SMDS_MeshCell.hxx
|
||||
SMDS_MeshFace.hxx
|
||||
SMDS_MeshGroup.hxx
|
||||
SMDS_MeshIDFactory.hxx
|
||||
SMDS_MeshInfo.hxx
|
||||
SMDS_MeshNode.hxx
|
||||
SMDS_MeshNodeIDFactory.hxx
|
||||
SMDS_MeshObject.hxx
|
||||
SMDS_MeshVolume.hxx
|
||||
SMDS_Position.hxx
|
||||
SMDS_SpacePosition.hxx
|
||||
SMDS_VertexPosition.hxx
|
||||
SMDS_Iterator.hxx
|
||||
SMDS_IteratorOfElements.hxx
|
||||
SMDS_VolumeOfFaces.hxx
|
||||
SMDS_VolumeOfNodes.hxx
|
||||
SMDS_VtkEdge.hxx
|
||||
SMDS_VtkFace.hxx
|
||||
SMDS_VtkVolume.hxx
|
||||
SMDS_VtkCellIterator.hxx
|
||||
SMDS_PolyhedralVolumeOfNodes.hxx
|
||||
SMDS_FaceOfEdges.hxx
|
||||
SMDS_FaceOfNodes.hxx
|
||||
SMDS_PolygonalFaceOfNodes.hxx
|
||||
SMDS_VolumeTool.hxx
|
||||
SMDS_QuadraticEdge.hxx
|
||||
SMDS_QuadraticFaceOfNodes.hxx
|
||||
SMDS_QuadraticVolumeOfNodes.hxx
|
||||
SMDS_Position.hxx
|
||||
SMDS_SetIterator.hxx
|
||||
SMESH_SMDS.hxx
|
||||
SMDS_MeshInfo.hxx
|
||||
SMDS_UnstructuredGrid.hxx
|
||||
SMDS_Downward.hxx
|
||||
SMDS_SpacePosition.hxx
|
||||
SMDS_StdIterator.hxx
|
||||
SMDS_IteratorOnIterators.hxx
|
||||
SMDS_BallElement.hxx
|
||||
)
|
||||
SMDS_TypeOfPosition.hxx
|
||||
SMDS_UnstructuredGrid.hxx
|
||||
SMDS_VertexPosition.hxx
|
||||
SMDS_VolumeOfNodes.hxx
|
||||
SMDS_VolumeTool.hxx
|
||||
SMDS_VtkCellIterator.hxx
|
||||
SMDS_ElementHolder.hxx
|
||||
SMESH_SMDS.hxx
|
||||
chrono.hxx
|
||||
)
|
||||
|
||||
# --- sources ---
|
||||
|
||||
# sources / static
|
||||
SET(SMDS_SOURCES
|
||||
chrono.cxx
|
||||
SMDS_MeshObject.cxx
|
||||
SMDS_MeshElement.cxx
|
||||
SMDS_MeshCell.cxx
|
||||
SMDS_Position.cxx
|
||||
SMDS_EdgePosition.cxx
|
||||
SMDS_FacePosition.cxx
|
||||
SMDS_SpacePosition.cxx
|
||||
SMDS_VertexPosition.cxx
|
||||
SMDS_MeshNode.cxx
|
||||
SMDS_Mesh0DElement.cxx
|
||||
SMDS_LinearEdge.cxx
|
||||
SMDS_MeshEdge.cxx
|
||||
SMDS_MeshFace.cxx
|
||||
SMDS_MeshVolume.cxx
|
||||
SMDS_MeshNodeIDFactory.cxx
|
||||
SMDS_MeshElementIDFactory.cxx
|
||||
SMDS_MeshGroup.cxx
|
||||
SMDS_MeshIDFactory.cxx
|
||||
SMDS_Mesh.cxx
|
||||
SMDS_IteratorOfElements.cxx
|
||||
SMDS_VolumeOfFaces.cxx
|
||||
SMDS_VolumeOfNodes.cxx
|
||||
SMDS_VtkEdge.cxx
|
||||
SMDS_VtkFace.cxx
|
||||
SMDS_VtkVolume.cxx
|
||||
SMDS_VtkCellIterator.cxx
|
||||
SMDS_PolyhedralVolumeOfNodes.cxx
|
||||
SMDS_FaceOfEdges.cxx
|
||||
SMDS_FaceOfNodes.cxx
|
||||
SMDS_PolygonalFaceOfNodes.cxx
|
||||
SMDS_VolumeTool.cxx
|
||||
SMDS_QuadraticEdge.cxx
|
||||
SMDS_QuadraticFaceOfNodes.cxx
|
||||
SMDS_QuadraticVolumeOfNodes.cxx
|
||||
SMDS_UnstructuredGrid.cxx
|
||||
SMDS_BallElement.cxx
|
||||
SMDS_Downward.cxx
|
||||
SMDS_BallElement.cxx
|
||||
SMDS_CellOfNodes.cxx
|
||||
SMDS_ElementFactory.cxx
|
||||
SMDS_FaceOfNodes.cxx
|
||||
SMDS_FacePosition.cxx
|
||||
SMDS_LinearEdge.cxx
|
||||
SMDS_MemoryLimit.cxx
|
||||
SMDS_Mesh.cxx
|
||||
SMDS_MeshCell.cxx
|
||||
SMDS_MeshElement.cxx
|
||||
SMDS_MeshGroup.cxx
|
||||
SMDS_MeshNode.cxx
|
||||
SMDS_MeshObject.cxx
|
||||
SMDS_MeshVolume.cxx
|
||||
SMDS_PolygonalFaceOfNodes.cxx
|
||||
SMDS_SpacePosition.cxx
|
||||
SMDS_UnstructuredGrid.cxx
|
||||
SMDS_VolumeOfNodes.cxx
|
||||
SMDS_VolumeTool.cxx
|
||||
SMDS_VtkCellIterator.cxx
|
||||
SMDS_ElementHolder.cxx
|
||||
chrono.cxx
|
||||
)
|
||||
|
||||
# bin programs
|
||||
|
235
src/SMDS/Notes
235
src/SMDS/Notes
@ -1,235 +0,0 @@
|
||||
--> Branche V6_main
|
||||
|
||||
Problemes en cours
|
||||
==================
|
||||
- a faire
|
||||
+ en cours, OK mais perfectible
|
||||
* OK
|
||||
|
||||
+ visualisation de groupe (type d'element): on voit tout le maillage, mais le groupe est OK
|
||||
creation d'une structure vtkUnstructuredGrid locale : iteration un peu lourde, et pas de partage avec la structure du maillage (pas evident)
|
||||
- inversion d'un volume (tetra): exception
|
||||
- script de creation de noeuds et d'elements: OK, mais pas compatible avec version precedente (numerotation noeuds differente)
|
||||
+ affichage numeros noeuds: numeros en trop sur (O,0,0) pas systematique, trouver la condition (enlever dans vtkUnstructuredGrid ?)
|
||||
==> purge systematique noeuds et cellules en trop dans compactage grid.
|
||||
+ gestion du mode embedded mal faite lors d'un script python : journal commandes intempestif
|
||||
- affichage des noeuds apres changement lineaire <--> quadratique à l'IHM : pas pris en compte, alors que maillage OK,
|
||||
mais script OK
|
||||
==> cassé apres mode embedded ou elimination noeuds en trop ?
|
||||
- extrusion elements 2D along a path : affichage apres calcul pas toujours OK (filaire)
|
||||
- branche git a ouvrir pour merge avec V5_1_4_BR tag V5_1_4rc1
|
||||
|
||||
A tester, non pris en compte
|
||||
============================
|
||||
- engine standalone
|
||||
- polyedres (attendre vtk)
|
||||
|
||||
|
||||
=============================== Hypothese de refonte de l'API de SMDS
|
||||
|
||||
n'utiliser que vtkUnstructuredGrid, ne pas avor d'objets SMDS_MeshElement mais seulement des index de vtkUnstructuredGrid.
|
||||
2987 usages de SMDS_MeshNodes
|
||||
810 SMDS_MeshElement
|
||||
...
|
||||
==> en dernier ressort, lourd
|
||||
================================================================================
|
||||
|
||||
Essai a API SMDS a peu pres constante
|
||||
=====================================
|
||||
|
||||
SMDS_Mesh
|
||||
static vector<SMDS_Mesh*> _meshList; --> retrouver un SMDS_Mesh
|
||||
vtkUnstructuredGrid* myGrid;
|
||||
|
||||
vector<SMDS_MeshNode *> myNodes; --> meme index que dans le pointSet de myGrid
|
||||
vector<SMDS_MeshCell *> myCells; --> index = ID client, pas le meme index que dans le cellTypes de myGrid (ID vtk)
|
||||
|
||||
|
||||
|
||||
SMDS_MeshElement
|
||||
int myID; --> index dans la structure geree par SMDS_Mesh
|
||||
int myMeshId; --> pour retrouver SMDS_Mesh* dans _meshList
|
||||
int myShapeId; --> pour retrouver la subShape
|
||||
|
||||
|
||||
SMDS_MeshNode: SMDS_MeshElement
|
||||
SMDS_PositionPtr myPosition; --> A REVOIR : objet position dans la shape geom
|
||||
##vector<int> myInverseElements; --> SUPPRIME : pour retrouver les elements, vtkCellLinks
|
||||
|
||||
|
||||
SMDS_MeshCell: SMDS_MeshElement --> generique pour tous les elements (cells)
|
||||
int myVtkID --> A SUPPRIMER
|
||||
|
||||
SMDS_MeshVolume: SMDS_MeshCell
|
||||
|
||||
SMDS_VolumeOfNodes: SMDS_MeshVolume --> Garder temporairement, utilisation dans StdMesher et SMDS_VolumeTool
|
||||
const SMDS_MeshNode **myNodes; --> Couteux
|
||||
int myNbNodes; --> ""
|
||||
|
||||
SMDS_VolumeVtkNodes: SMDS_MeshVolume --> Utiliser systematiquement dans SMDS,
|
||||
--> IMPLEMENTER.
|
||||
|
||||
|
||||
SMDS_MeshElementIDFactory: SMDS_MeshNodeIDFactory
|
||||
vector<int> myIDElements; // index = ID client, value = ID vtk --> A SUPPRIMER, ne sert que dans SMDS_MeshElementIDFactory
|
||||
vector<int> myVtkIndex; // index = ID vtk, value = ID client --> A REPORTER dans SMDS_Mesh
|
||||
|
||||
|
||||
|
||||
|
||||
========= TODO ============
|
||||
|
||||
enlever vtkId de SMDS_MeshCell, utiliser SMDS_MeshElementIDFactory.
|
||||
|
||||
ajouter ID dans SMDS_Mesh::createTriangle
|
||||
verifier ID dans SMDS_Mesh::Find*OrCreate
|
||||
|
||||
===================================================
|
||||
occupation memoire cube 100*100*100 sans affichage
|
||||
NOTES:
|
||||
- sur Debian Sarge 64 bits, les mesures malloc_stat() semblent coherentes
|
||||
avec une mesure externe globale(recherche du passage en swap du process).
|
||||
- sur Ubuntu 9.10 64 bits, les mesures malloc_stat() donnent des resultats bizarres (surestimation ?),
|
||||
mais la mesure avec l'outil KDE de surveillance systeme est OK avec la recherche du swap.
|
||||
|
||||
|
||||
Reference : V513 Debian Sarge 64 bits: --> 463 - 33 = 430 Mo
|
||||
-------------------------------------
|
||||
Total (incl. mmap):
|
||||
system bytes = 43757568
|
||||
in use bytes = 32909584 = 33M
|
||||
max mmap regions = 41
|
||||
max mmap bytes = 16371712
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 464670720
|
||||
in use bytes = 463105120 = 463M
|
||||
max mmap regions = 47
|
||||
max mmap bytes = 28188672
|
||||
|
||||
Debian Sarge 64 bits, vtkUnstructuredGrid nodes et hexa, 4 janvier 2010 --> 512 - 41 = 471M
|
||||
-----------------------------------
|
||||
|
||||
Total (incl. mmap):
|
||||
system bytes = 52133888
|
||||
in use bytes = 41340320 : 41M
|
||||
max mmap regions = 72
|
||||
max mmap bytes = 24625152
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 520560640
|
||||
in use bytes = 518735584 : 512M
|
||||
max mmap regions = 88
|
||||
max mmap bytes = 198385664
|
||||
|
||||
idem avec pool SMDS_MeshNodes --> 483 -33 = 450M
|
||||
-----------------------------
|
||||
Total (incl. mmap):
|
||||
system bytes = 43696128
|
||||
in use bytes = 32915184 : 33M
|
||||
max mmap regions = 41
|
||||
max mmap bytes = 16371712
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 484806656
|
||||
in use bytes = 482980992 : 483M
|
||||
max mmap regions = 58
|
||||
max mmap bytes = 184557568
|
||||
|
||||
idem ci-dessus + pool SMDS_VolumeVtkNodes --> 475 -33 = 442M (git: add ObjectPool.hxx)
|
||||
-----------------------------------------
|
||||
|
||||
Total (incl. mmap):
|
||||
system bytes = 43200512
|
||||
in use bytes = 32908576 : 33M
|
||||
max mmap regions = 41
|
||||
max mmap bytes = 16371712
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 478068736
|
||||
in use bytes = 475144400 : 475M
|
||||
max mmap regions = 59
|
||||
max mmap bytes = 184692736
|
||||
|
||||
remplacement SMDS_PositionPtr: (boost::shared_ptr<SMDS_Position> --> SMDS_Position*) --> 436 - 35 = 401M (git SMDS_Position)
|
||||
------------------------------------------------------------------------------------
|
||||
Total (incl. mmap):
|
||||
system bytes = 45408256
|
||||
in use bytes = 35097680 : 35M
|
||||
max mmap regions = 47
|
||||
max mmap bytes = 18116608
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 438935552
|
||||
in use bytes = 436116560 : 436M
|
||||
max mmap regions = 65
|
||||
max mmap bytes = 186437632
|
||||
|
||||
simplification SMDS_SpacePosition (pas de double[3]) --> 418 -33 = 385M (git SMDS_SpacePosition)
|
||||
----------------------------------------------------
|
||||
Total (incl. mmap):
|
||||
system bytes = 42582016
|
||||
in use bytes = 32883552 : 33M
|
||||
max mmap regions = 41
|
||||
max mmap bytes = 16371712
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 421728256
|
||||
in use bytes = 418378000 : 418M
|
||||
max mmap regions = 58
|
||||
max mmap bytes = 183640064
|
||||
|
||||
sizeof(SMDS_MeshElement) 16
|
||||
sizeof(SMDS_MeshNode) 24
|
||||
sizeof(SMDS_MeshCell) 24
|
||||
sizeof(SMDS_VolumeVtkNodes) 24
|
||||
sizeof(SMDS_Position) 16
|
||||
sizeof(SMDS_SpacePosition) 16
|
||||
|
||||
impact d'un int en plus dans SMDS_MeshElement --> 426 - 33 = 393M
|
||||
---------------------------------------------
|
||||
|
||||
sizeof(SMDS_MeshElement) 24
|
||||
sizeof(SMDS_MeshNode) 32 --> on retrouve bien les 8M
|
||||
sizeof(SMDS_MeshCell) 24
|
||||
sizeof(SMDS_VolumeVtkNodes) 24
|
||||
sizeof(SMDS_Position) 16
|
||||
sizeof(SMDS_SpacePosition) 16
|
||||
|
||||
Total (incl. mmap):
|
||||
system bytes = 43192320
|
||||
in use bytes = 32681088 : 33M
|
||||
max mmap regions = 41
|
||||
max mmap bytes = 16371712
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 429334528
|
||||
in use bytes = 426424576 : 426M
|
||||
max mmap regions = 59
|
||||
max mmap bytes = 184692736
|
||||
|
||||
remplacement std::set par std::vector dans SMESHDS_SubMesh --> 347 - 35 = 312M
|
||||
----------------------------------------------------------
|
||||
sizeof(SMDS_MeshElement) 24
|
||||
sizeof(SMDS_MeshNode) 32
|
||||
sizeof(SMDS_MeshCell) 24
|
||||
sizeof(SMDS_VolumeVtkNodes) 24
|
||||
sizeof(SMDS_Position) 16
|
||||
sizeof(SMDS_SpacePosition) 16
|
||||
|
||||
Total (incl. mmap):
|
||||
system bytes = 45404160
|
||||
in use bytes = 35132160 --> 35M
|
||||
max mmap regions = 49
|
||||
max mmap bytes = 17723392
|
||||
----
|
||||
Total (incl. mmap):
|
||||
system bytes = 349831168
|
||||
in use bytes = 346885424 --> 347M
|
||||
max mmap regions = 73
|
||||
max mmap bytes = 204148736
|
||||
|
||||
Ce resultat est coherent avec une recherche de swap sur une machine a 8Go de memoire:
|
||||
Cube a 270**3 mailles (~20M mailles) --> 6.2 Go (idem Debian Sarge et Ubuntu 9.10, 64 bits)
|
||||
Le meme avec V5.1.3 --> 14 Go (swap)
|
||||
|
@ -28,9 +28,9 @@
|
||||
namespace
|
||||
{
|
||||
// assure deallocation of memory of a vector
|
||||
template<class Y> void clearVector(std::vector<Y>& v )
|
||||
template<class Y> void clearVector(Y & v )
|
||||
{
|
||||
std::vector<Y> emptyVec; v.swap( emptyVec );
|
||||
Y emptyVec; v.swap( emptyVec );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,78 +24,24 @@
|
||||
|
||||
#include "SMDS_BallElement.hxx"
|
||||
|
||||
#include "SMDS_ElemIterator.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
|
||||
SMDS_BallElement::SMDS_BallElement()
|
||||
void SMDS_BallElement::init(const SMDS_MeshNode * node, double diameter )
|
||||
{
|
||||
SMDS_MeshCell::init();
|
||||
}
|
||||
|
||||
SMDS_BallElement::SMDS_BallElement (const SMDS_MeshNode * node, double diameter)
|
||||
{
|
||||
init( node->getVtkId(), diameter, SMDS_Mesh::_meshList[ node->getMeshId() ] );
|
||||
}
|
||||
|
||||
SMDS_BallElement::SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh)
|
||||
{
|
||||
init( nodeId, diameter, mesh );
|
||||
}
|
||||
|
||||
void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshCell::init();
|
||||
myMeshId = mesh->getMeshId();
|
||||
myVtkID = mesh->getGrid()->InsertNextLinkedCell( GetVtkType(), 1, &nodeId );
|
||||
mesh->getGrid()->SetBallDiameter( myVtkID, diameter );
|
||||
mesh->setMyModified();
|
||||
int nodeVtkID = node->GetVtkID();
|
||||
int vtkID = getGrid()->InsertNextLinkedCell( toVtkType( SMDSEntity_Ball ), 1, &nodeVtkID );
|
||||
setVtkID( vtkID );
|
||||
getGrid()->SetBallDiameter( GetVtkID(), diameter );
|
||||
}
|
||||
|
||||
double SMDS_BallElement::GetDiameter() const
|
||||
{
|
||||
return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetBallDiameter( myVtkID );
|
||||
return getGrid()->GetBallDiameter( GetVtkID() );
|
||||
}
|
||||
|
||||
void SMDS_BallElement::SetDiameter(double diameter)
|
||||
{
|
||||
SMDS_Mesh::_meshList[myMeshId]->getGrid()->SetBallDiameter( myVtkID, diameter );
|
||||
getGrid()->SetBallDiameter( GetVtkID(), diameter );
|
||||
GetMesh()->setMyModified();
|
||||
}
|
||||
|
||||
bool SMDS_BallElement::ChangeNode (const SMDS_MeshNode * node)
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
pts[0] = node->getVtkId();
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SMDS_BallElement::Print (std::ostream & OS) const
|
||||
{
|
||||
OS << "ball<" << GetID() << "> : ";
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_BallElement::GetNode (const int ind) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( myVtkID, npts, pts );
|
||||
return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ 0 ]);
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_BallElement::elementsIterator (SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
default:
|
||||
;
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,34 +27,23 @@
|
||||
#include "SMESH_SMDS.hxx"
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*!
|
||||
* \brief Ball element. This type is not allocated.
|
||||
* It is only used as function argument type to provide more clear semantic
|
||||
* and to provide API specific to ball element
|
||||
*/
|
||||
class SMDS_EXPORT SMDS_BallElement: public SMDS_MeshCell
|
||||
{
|
||||
void init(const SMDS_MeshNode * node, double diameter);
|
||||
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
public:
|
||||
SMDS_BallElement();
|
||||
SMDS_BallElement (const SMDS_MeshNode * node, double diameter);
|
||||
SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh);
|
||||
void init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh);
|
||||
|
||||
double GetDiameter() const;
|
||||
void SetDiameter(double diameter);
|
||||
bool ChangeNode (const SMDS_MeshNode * node);
|
||||
void SetDiameter(double diameter);
|
||||
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes) { return ChangeNode( nodes[0] ); }
|
||||
virtual void Print (std::ostream & OS) const;
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Ball; }
|
||||
virtual vtkIdType GetVtkType() const { return VTK_POLY_VERTEX; }
|
||||
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Ball; }
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_BALL; }
|
||||
virtual int NbNodes() const { return 1; }
|
||||
virtual int NbEdges() const { return 0; }
|
||||
virtual int NbFaces() const { return 0; }
|
||||
virtual const SMDS_MeshNode* GetNode (const int ind) const;
|
||||
|
||||
protected:
|
||||
SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
|
||||
static SMDSAbs_ElementType Type() { return SMDSAbs_Ball; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,14 +22,41 @@
|
||||
|
||||
// SMESH SMDS : implementation of Salome mesh data structure
|
||||
//
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshFace::GetType() const
|
||||
#include "SMDS_CellOfNodes.hxx"
|
||||
|
||||
SMDS_CellOfNodes::SMDS_CellOfNodes( int id, int shapeID )
|
||||
: myID( id )
|
||||
{
|
||||
return SMDSAbs_Face;
|
||||
setShapeID( shapeID );
|
||||
}
|
||||
|
||||
vtkIdType SMDS_MeshFace::GetVtkType() const
|
||||
void SMDS_CellOfNodes::setID(const int id)
|
||||
{
|
||||
return VTK_POLY_LINE; // --- must be reimplemented in derived classes
|
||||
myID = id;
|
||||
}
|
||||
|
||||
int SMDS_CellOfNodes::GetID() const
|
||||
{
|
||||
return myID;
|
||||
}
|
||||
|
||||
void SMDS_CellOfNodes::setShapeID( const int shapeID )
|
||||
{
|
||||
myShapeID = ( shapeID << BITS_SHIFT ) | ( myShapeID & BIT_IS_MARKED );
|
||||
}
|
||||
|
||||
int SMDS_CellOfNodes::GetShapeID() const
|
||||
{
|
||||
return myShapeID >> BITS_SHIFT;
|
||||
}
|
||||
|
||||
void SMDS_CellOfNodes::setIsMarked( bool is ) const
|
||||
{
|
||||
const_cast< SMDS_CellOfNodes* >( this )->myShapeID = ( myShapeID & ~BIT_IS_MARKED ) | is;
|
||||
}
|
||||
|
||||
bool SMDS_CellOfNodes::isMarked() const
|
||||
{
|
||||
return myShapeID & BIT_IS_MARKED;
|
||||
}
|
@ -21,42 +21,48 @@
|
||||
//
|
||||
|
||||
// SMESH SMDS : implementation of Salome mesh data structure
|
||||
// File : SMDS_MeshElementIDFactory.hxx
|
||||
// File : SMDS_CellOfNodes.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_MeshElementIDFactory_HeaderFile
|
||||
#define _SMDS_MeshElementIDFactory_HeaderFile
|
||||
#ifndef _SMDS_CellOfNodes_HeaderFile
|
||||
#define _SMDS_CellOfNodes_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
|
||||
#include "SMDS_MeshNodeIDFactory.hxx"
|
||||
// ============================================================
|
||||
/*!
|
||||
* \brief Base class for elements of not contained in the mesh
|
||||
*/
|
||||
// ============================================================
|
||||
|
||||
#include <vector>
|
||||
|
||||
class SMDS_MeshElement;
|
||||
class SMDS_Mesh;
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshNodeIDFactory
|
||||
class SMDS_EXPORT SMDS_CellOfNodes : public SMDS_MeshElement
|
||||
{
|
||||
public:
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
SMDS_MeshElementIDFactory();
|
||||
bool BindID(int ID, SMDS_MeshElement * elem);
|
||||
int SetInVtkGrid(SMDS_MeshElement * elem);
|
||||
SMDS_MeshElement * MeshElement(int ID);
|
||||
virtual int GetFreeID();
|
||||
virtual void ReleaseID(int ID, int vtkId = -1);
|
||||
SMDS_ElemIteratorPtr elementsIterator() const;
|
||||
virtual void Clear();
|
||||
|
||||
protected:
|
||||
virtual void updateMinMax() const;
|
||||
void updateMinMax(int id) const
|
||||
{
|
||||
if (id > myMax) myMax = id;
|
||||
if (id < myMin) myMin = id;
|
||||
}
|
||||
virtual int GetID() const;
|
||||
virtual int GetShapeID() const;
|
||||
|
||||
virtual void setIsMarked( bool is ) const;
|
||||
virtual bool isMarked() const;
|
||||
|
||||
virtual VTKCellType GetVtkType() const { return VTK_EMPTY_CELL; }
|
||||
|
||||
protected:
|
||||
|
||||
SMDS_CellOfNodes( int id = -1, int shapeID = 0);
|
||||
|
||||
virtual void setID( const int id);
|
||||
virtual void setShapeID( const int shapeID );
|
||||
|
||||
int myID;
|
||||
int myShapeID;
|
||||
|
||||
enum Bits { // use the 1st right bit of myShapeId to set/unset a mark
|
||||
BIT_IS_MARKED = 1,
|
||||
BITS_SHIFT = 1
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -1145,7 +1145,7 @@ void SMDS_DownTetra::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& o
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
@ -1253,7 +1253,7 @@ void SMDS_DownQuadTetra::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
@ -1387,7 +1387,7 @@ void SMDS_DownPyramid::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>&
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ void SMDS_DownQuadPyramid::getOrderedNodesOfFace(int cellId, std::vector<vtkIdTy
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2] << " " << orderedNodes[3]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
@ -1694,7 +1694,7 @@ void SMDS_DownPenta::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& o
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
@ -1845,7 +1845,7 @@ void SMDS_DownQuadPenta::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
@ -2000,7 +2000,7 @@ void SMDS_DownHexa::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& or
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2] << " " << orderedNodes[3]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
MESSAGE(nodes[4] << " " << nodes[5] << " " << nodes[6] << " " << nodes[7]);
|
||||
@ -2132,7 +2132,7 @@ void SMDS_DownQuadHexa::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>
|
||||
return;
|
||||
}
|
||||
}
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->FromVtkToSmds(_vtkCellIds[cellId]));
|
||||
MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2] << " " << orderedNodes[3]);
|
||||
MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_EdgePosition.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#include "SMDS_EdgePosition.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_EdgePosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_EdgePosition::SMDS_EdgePosition(const double aUParam): myUParameter(aUParam)
|
||||
{
|
||||
//MESSAGE("********************************* SMDS_EdgePosition " << myUParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
SMDS_TypeOfPosition SMDS_EdgePosition::GetTypeOfPosition() const
|
||||
{
|
||||
//MESSAGE("###################################### SMDS_EdgePosition::GetTypeOfPosition");
|
||||
return SMDS_TOP_EDGE;
|
||||
}
|
||||
|
||||
void SMDS_EdgePosition::SetUParameter(double aUparam)
|
||||
{
|
||||
//MESSAGE("############################### SMDS_EdgePosition::SetUParameter " << aUparam);
|
||||
myUParameter = aUparam;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetUParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
double SMDS_EdgePosition::GetUParameter() const
|
||||
{
|
||||
//MESSAGE("########################## SMDS_EdgePosition::GetUParameter " << myUParameter);
|
||||
return myUParameter;
|
||||
}
|
@ -31,18 +31,19 @@
|
||||
|
||||
#include "SMDS_Position.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_EdgePosition:public SMDS_Position
|
||||
class SMDS_EXPORT SMDS_EdgePosition : public SMDS_Position
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_EdgePosition(const double aUParam=0);
|
||||
SMDS_TypeOfPosition GetTypeOfPosition() const;
|
||||
void SetUParameter(double aUparam);
|
||||
double GetUParameter() const;
|
||||
public:
|
||||
SMDS_EdgePosition(const double aUParam=0) : myUParameter( aUParam ) {}
|
||||
virtual SMDS_TypeOfPosition GetTypeOfPosition() const { return SMDS_TOP_EDGE; }
|
||||
virtual void SetUParameter(double aUparam) { myUParameter = aUparam; }
|
||||
virtual double GetUParameter() const { return myUParameter; }
|
||||
virtual const double* GetParameters() const { return &myUParameter; }
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
double myUParameter;
|
||||
double myUParameter;
|
||||
|
||||
};
|
||||
|
||||
|
880
src/SMDS/SMDS_ElementFactory.cxx
Normal file
880
src/SMDS/SMDS_ElementFactory.cxx
Normal file
@ -0,0 +1,880 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// File : SMDS_ElementFactory.cxx
|
||||
// Module : SMESH
|
||||
//
|
||||
|
||||
#include "SMDS_ElementFactory.hxx"
|
||||
|
||||
#include "ObjectPool.hxx"
|
||||
#include "SMDS_EdgePosition.hxx"
|
||||
#include "SMDS_FacePosition.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_SpacePosition.hxx"
|
||||
#include "SMDS_VertexPosition.hxx"
|
||||
|
||||
namespace
|
||||
{
|
||||
// nb of elements allocated by SMDS_ElementChunk at once
|
||||
const int theChunkSize = 1024;
|
||||
|
||||
const int theDefaultShapeDim = 3;
|
||||
|
||||
// classes allowing to modify parameters of SMDS_Position stored in SMDS_ElementFactory
|
||||
|
||||
struct _EdgePosition : public SMDS_EdgePosition
|
||||
{
|
||||
TParam* myUParameter;
|
||||
|
||||
_EdgePosition( TParam* aUParam ) : myUParameter( aUParam )
|
||||
{ SMDS_EdgePosition::SetUParameter( aUParam[0]); }
|
||||
virtual void SetUParameter(double aUparam)
|
||||
{ *myUParameter = (TParam) aUparam; SMDS_EdgePosition::SetUParameter( aUparam ); }
|
||||
};
|
||||
|
||||
struct _FacePosition : public SMDS_FacePosition
|
||||
{
|
||||
TParam* myParameter;
|
||||
|
||||
_FacePosition(TParam* aParam) : myParameter( aParam )
|
||||
{ SMDS_FacePosition::SetParameters( aParam[0], aParam[1] ); }
|
||||
virtual void SetUParameter(double aUparam)
|
||||
{ myParameter[0] = (TParam) aUparam; SMDS_FacePosition::SetUParameter( aUparam ); }
|
||||
virtual void SetVParameter(double aVparam)
|
||||
{ myParameter[1] = (TParam) aVparam; SMDS_FacePosition::SetVParameter( aVparam ); }
|
||||
virtual void SetParameters(double aU, double aV)
|
||||
{ myParameter[0] = aU; myParameter[1] = aV; SMDS_FacePosition::SetParameters( aU, aV ); }
|
||||
};
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a factory of cells or nodes in a given mesh
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_ElementFactory::SMDS_ElementFactory( SMDS_Mesh* mesh, const bool isNodal )
|
||||
: myIsNodal( isNodal ), myMesh( mesh ), myNbUsedElements( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_ElementFactory::~SMDS_ElementFactory()
|
||||
{
|
||||
myChunksWithUnused.clear();
|
||||
myChunks.clear();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return a number of elements in a chunk
|
||||
* \return int - chunk size
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementFactory::ChunkSize()
|
||||
{
|
||||
return theChunkSize;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return minimal ID of a non-used element
|
||||
* \return int - minimal element ID
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementFactory::GetFreeID()
|
||||
{
|
||||
if ( myChunksWithUnused.empty() )
|
||||
{
|
||||
int id0 = myChunks.size() * theChunkSize + 1;
|
||||
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
|
||||
}
|
||||
SMDS_ElementChunk * chunk = (*myChunksWithUnused.begin());
|
||||
return chunk->GetUnusedID();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return maximal ID of an used element
|
||||
* \return int - element ID
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementFactory::GetMaxID()
|
||||
{
|
||||
int id = 0;
|
||||
TIndexRanges usedRanges;
|
||||
for ( int i = myChunks.size() - 1; i >= 0; --i )
|
||||
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
|
||||
{
|
||||
int index = usedRanges.back().second-1;
|
||||
id = myChunks[i].Get1stID() + index;
|
||||
break;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return minimal ID of an used element
|
||||
* \return int - element ID
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementFactory::GetMinID()
|
||||
{
|
||||
int id = 0;
|
||||
TIndexRanges usedRanges;
|
||||
for ( size_t i = 0; i < myChunks.size(); ++i )
|
||||
if ( myChunks[i].GetUsedRanges().GetIndices( true, usedRanges ))
|
||||
{
|
||||
int index = usedRanges[0].first;
|
||||
id = myChunks[i].Get1stID() + index;
|
||||
break;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return an element by ID. NULL if the element with the given ID is already used
|
||||
* \param [in] id - element ID
|
||||
* \return SMDS_MeshElement* - element pointer
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_MeshElement* SMDS_ElementFactory::NewElement( const int id )
|
||||
{
|
||||
int iChunk = ( id - 1 ) / theChunkSize;
|
||||
int index = ( id - 1 ) % theChunkSize;
|
||||
while ((int) myChunks.size() <= iChunk )
|
||||
{
|
||||
int id0 = myChunks.size() * theChunkSize + 1;
|
||||
myChunks.push_back( new SMDS_ElementChunk( this, id0 ));
|
||||
}
|
||||
SMDS_MeshElement* e = myChunks[iChunk].Element( index );
|
||||
if ( !e->IsNull() )
|
||||
return 0; // element with given ID already exists
|
||||
|
||||
myChunks[iChunk].UseElement( index );
|
||||
++myNbUsedElements;
|
||||
|
||||
e->myHolder = & myChunks[iChunk];
|
||||
|
||||
myMesh->setMyModified();
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return an used element by ID. NULL if the element with the given ID is not yet used
|
||||
* \param [in] id - element ID
|
||||
* \return const SMDS_MeshElement* - element pointer
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
const SMDS_MeshElement* SMDS_ElementFactory::FindElement( const int id ) const
|
||||
{
|
||||
if ( id > 0 )
|
||||
{
|
||||
int iChunk = ( id - 1 ) / theChunkSize;
|
||||
int index = ( id - 1 ) % theChunkSize;
|
||||
if ( iChunk < (int) myChunks.size() )
|
||||
{
|
||||
const SMDS_MeshElement* e = myChunks[iChunk].Element( index );
|
||||
return e->IsNull() ? 0 : e;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return an SMDS ID by a Vtk one
|
||||
* \param [inout] vtkID - Vtk ID
|
||||
* \return int - SMDS ID
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementFactory::FromVtkToSmds( vtkIdType vtkID )
|
||||
{
|
||||
if ( vtkID >= 0 && vtkID < (vtkIdType)mySmdsIDs.size() )
|
||||
return mySmdsIDs[vtkID] + 1;
|
||||
return vtkID + 1;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Mark the element as non-used
|
||||
* \param [in] e - element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementFactory::Free( const SMDS_MeshElement* e )
|
||||
{
|
||||
if ( !myVtkIDs.empty() )
|
||||
{
|
||||
size_t id = e->GetID() - 1;
|
||||
size_t vtkID = e->GetVtkID();
|
||||
if ( id < myVtkIDs.size() )
|
||||
myVtkIDs[ id ] = -1;
|
||||
if ( vtkID < mySmdsIDs.size() )
|
||||
mySmdsIDs[ vtkID ] = -1;
|
||||
}
|
||||
e->myHolder->Free( e );
|
||||
const_cast< SMDS_MeshElement*>( e )->myHolder = 0;
|
||||
--myNbUsedElements;
|
||||
|
||||
myMesh->setMyModified();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief De-allocate all elements
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementFactory::Clear()
|
||||
{
|
||||
myChunksWithUnused.clear();
|
||||
clearVector( myChunks );
|
||||
clearVector( myVtkIDs );
|
||||
clearVector( mySmdsIDs );
|
||||
myNbUsedElements = 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Remove unused elements located not at the end of the last chunk.
|
||||
* Minimize allocated memory
|
||||
* \param [out] theVtkIDsNewToOld - theVtkIDsNewToOld[ new VtkID ] = old VtkID
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementFactory::Compact( std::vector<int>& theVtkIDsNewToOld )
|
||||
{
|
||||
int newNbCells = NbUsedElements();
|
||||
int maxCellID = GetMaxID();
|
||||
int newNbChunks = newNbCells / theChunkSize + bool ( newNbCells % theChunkSize );
|
||||
|
||||
theVtkIDsNewToOld.resize( newNbCells );
|
||||
|
||||
if ( newNbCells == 0 ) // empty mesh
|
||||
{
|
||||
clearVector( myChunks );
|
||||
}
|
||||
else if ( newNbCells == maxCellID ) // no holes
|
||||
{
|
||||
int newID, minLastID = std::min( myVtkIDs.size(), theVtkIDsNewToOld.size() );
|
||||
for ( newID = 0; newID < minLastID; ++newID )
|
||||
theVtkIDsNewToOld[ newID ] = myVtkIDs[ newID ];
|
||||
for ( ; newID < newNbCells; ++newID )
|
||||
theVtkIDsNewToOld[ newID ] = newID;
|
||||
}
|
||||
else // there are holes in SMDS IDs
|
||||
{
|
||||
int newVtkID = 0; // same as new smds ID (-1)
|
||||
for ( int oldID = 1; oldID <= maxCellID; ++oldID ) // smds IDs
|
||||
{
|
||||
const SMDS_MeshElement* oldElem = FindElement( oldID );
|
||||
if ( !oldElem ) continue;
|
||||
theVtkIDsNewToOld[ newVtkID++ ] = oldElem->GetVtkID(); // now newVtkID == new smds ID
|
||||
if ( oldID != newVtkID )
|
||||
{
|
||||
const SMDS_MeshElement* newElem = FindElement( newVtkID );
|
||||
if ( !newElem )
|
||||
newElem = NewElement( newVtkID );
|
||||
if ( int shapeID = oldElem->GetShapeID() )
|
||||
const_cast< SMDS_MeshElement* >( newElem )->setShapeID( shapeID );
|
||||
if ( oldID > newNbCells )
|
||||
Free( oldElem );
|
||||
}
|
||||
}
|
||||
}
|
||||
myChunks.resize( newNbChunks );
|
||||
|
||||
myChunksWithUnused.clear();
|
||||
if ( !myChunks.empty() && myChunks.back().GetUsedRanges().Size() > 1 )
|
||||
myChunksWithUnused.insert( & myChunks.back() );
|
||||
|
||||
for ( size_t i = 0; i < myChunks.size(); ++i )
|
||||
myChunks[i].Compact();
|
||||
|
||||
clearVector( myVtkIDs );
|
||||
clearVector( mySmdsIDs );
|
||||
}
|
||||
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return true if Compact() will change IDs of elements
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool SMDS_ElementFactory::CompactChangePointers()
|
||||
{
|
||||
// there can be VTK_EMPTY_CELL's in the VTK grid as well as "holes" in SMDS numeration
|
||||
return ( NbUsedElements() != GetMaxID() );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a factory of nodes in a given mesh
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_NodeFactory::SMDS_NodeFactory( SMDS_Mesh* mesh )
|
||||
: SMDS_ElementFactory( mesh, /*isNodal=*/true )
|
||||
{
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_NodeFactory::~SMDS_NodeFactory()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Remove unused nodes located not at the end of the last chunk.
|
||||
* Minimize allocated memory
|
||||
* \param [out] theVtkIDsOldToNew - vector storing change of vtk IDs
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_NodeFactory::Compact( std::vector<int>& theVtkIDsOldToNew )
|
||||
{
|
||||
// IDs of VTK nodes always correspond to SMDS IDs but there can be "holes"
|
||||
// in the chunks. So we remove holes and report relocation in theVtkIDsOldToNew:
|
||||
// theVtkIDsOldToNew[ old VtkID ] = new VtkID
|
||||
|
||||
int oldNbNodes = myMesh->GetGrid()->GetNumberOfPoints();
|
||||
int newNbNodes = NbUsedElements();
|
||||
int newNbChunks = newNbNodes / theChunkSize + bool ( newNbNodes % theChunkSize );
|
||||
int maxNodeID = GetMaxID();
|
||||
|
||||
theVtkIDsOldToNew.resize( oldNbNodes, -1 );
|
||||
|
||||
if ( newNbNodes == 0 ) // empty mesh
|
||||
{
|
||||
clearVector( myChunks );
|
||||
}
|
||||
else if ( maxNodeID > newNbNodes ) // there are holes
|
||||
{
|
||||
size_t newID = 0;
|
||||
for ( size_t oldID = 0; oldID < theVtkIDsOldToNew.size(); ++oldID )
|
||||
{
|
||||
const SMDS_MeshElement* oldNode = FindNode( oldID+1 );
|
||||
if ( !oldNode )
|
||||
continue;
|
||||
theVtkIDsOldToNew[ oldID ] = newID;
|
||||
if ( oldID != newID )
|
||||
{
|
||||
const SMDS_MeshElement* newNode = FindElement( newID+1 );
|
||||
if ( !newNode )
|
||||
newNode = NewElement( newID+1 );
|
||||
int shapeID = oldNode->GetShapeID();
|
||||
int shapeDim = GetShapeDim( shapeID );
|
||||
int iChunk = newID / theChunkSize;
|
||||
myChunks[ iChunk ].SetShapeID( newNode, shapeID );
|
||||
if ( shapeDim == 2 || shapeDim == 1 )
|
||||
{
|
||||
int iChunkOld = oldID / theChunkSize;
|
||||
TParam* oldPos = myChunks[ iChunkOld ].GetPositionPtr( oldNode );
|
||||
TParam* newPos = myChunks[ iChunk ].GetPositionPtr( newNode, /*allocate=*/true );
|
||||
if ( oldPos )
|
||||
{
|
||||
newPos[0] = oldPos[0];
|
||||
newPos[1] = oldPos[1];
|
||||
}
|
||||
}
|
||||
if ( oldNode->GetID() > newNbNodes )
|
||||
Free( oldNode );
|
||||
}
|
||||
++newID;
|
||||
}
|
||||
}
|
||||
else // no holes
|
||||
{
|
||||
for ( int i = 0; i < newNbNodes; ++i )
|
||||
theVtkIDsOldToNew[ i ] = i;
|
||||
}
|
||||
myChunks.resize( newNbChunks );
|
||||
|
||||
myChunksWithUnused.clear();
|
||||
if ( !myChunks.empty() && myChunks.back().GetUsedRanges().Size() > 1 )
|
||||
myChunksWithUnused.insert( & myChunks.back() );
|
||||
|
||||
for ( size_t i = 0; i < myChunks.size(); ++i )
|
||||
myChunks[i].Compact();
|
||||
|
||||
ASSERT( newNbNodes == GetMaxID() );
|
||||
ASSERT( newNbNodes == NbUsedElements() );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return true if Compact() will change IDs of elements
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool SMDS_NodeFactory::CompactChangePointers()
|
||||
{
|
||||
// IDs of VTK nodes always correspond to SMDS IDs but there can be "holes" in SMDS numeration
|
||||
return ( NbUsedElements() != GetMaxID() );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief De-allocate all nodes
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_NodeFactory::Clear()
|
||||
{
|
||||
SMDS_ElementFactory::Clear();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set a total number of sub-shapes in the main shape
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_NodeFactory::SetNbShapes( size_t nbShapes )
|
||||
{
|
||||
clearVector( myShapeDim );
|
||||
myShapeDim.resize( nbShapes+1, theDefaultShapeDim );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return a dimension of a shape
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_NodeFactory::GetShapeDim( int shapeID ) const
|
||||
{
|
||||
return shapeID < (int)myShapeDim.size() ? myShapeDim[ shapeID ] : theDefaultShapeDim;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set a dimension of a shape
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_NodeFactory::SetShapeDim( int shapeID, int dim )
|
||||
{
|
||||
if ( shapeID >= (int)myShapeDim.size() )
|
||||
myShapeDim.resize( shapeID + 10, theDefaultShapeDim );
|
||||
myShapeDim[ shapeID ] = dim;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief SMDS_ElementChunk constructor
|
||||
* \param [in] factory - the factory
|
||||
* \param [in] id0 - ID of the 1st element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory, int id0 ):
|
||||
myFactory( factory ),
|
||||
my1stID( id0 ),
|
||||
myMinSubID( std::numeric_limits<int>::max() ),
|
||||
myMaxSubID( 0 )
|
||||
{
|
||||
if ( !myFactory )
|
||||
return;
|
||||
if ( myFactory->myIsNodal )
|
||||
myElements = new SMDS_MeshNode[ theChunkSize ];
|
||||
else
|
||||
myElements = new SMDS_MeshCell[ theChunkSize ];
|
||||
|
||||
myUsedRanges.mySet.reserve(2);
|
||||
mySubIDRanges.mySet.insert( _ShapeIDRange( 0, 0 ));
|
||||
myUsedRanges.mySet.insert( _UsedRange( 0, false ));
|
||||
myFactory->myChunksWithUnused.insert( this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief SMDS_ElementChunk destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_ElementChunk::~SMDS_ElementChunk()
|
||||
{
|
||||
delete [] myElements;
|
||||
myFactory->myChunksWithUnused.erase( this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Mark an element as used
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::UseElement( const int index )
|
||||
{
|
||||
myUsedRanges.SetValue( index, true );
|
||||
if ( myUsedRanges.Size() == 1 ) // all elements used
|
||||
myFactory->myChunksWithUnused.erase( this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return ID of the first non-used element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementChunk::GetUnusedID() const
|
||||
{
|
||||
TUsedRangeSet::set_iterator r = myUsedRanges.mySet.begin();
|
||||
for ( ; r != myUsedRanges.mySet.end(); ++r )
|
||||
if ( !IsUsed( *r ))
|
||||
break;
|
||||
|
||||
return my1stID + r->my1st;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Mark an element as non-used
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::Free( const SMDS_MeshElement* e )
|
||||
{
|
||||
bool hasHoles = ( myUsedRanges.Size() > 1 );
|
||||
myUsedRanges.SetValue( Index( e ), false );
|
||||
SetShapeID( e, 0 ); // sub-mesh must do it?
|
||||
SetIsMarked( e, false );
|
||||
if ( !hasHoles )
|
||||
myFactory->myChunksWithUnused.insert( this );
|
||||
|
||||
if ( myUsedRanges.Size() == 1 )
|
||||
{
|
||||
clearVector( myMarkedSet );
|
||||
clearVector( myPositions );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return an SMDS ID of an element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementChunk::GetID( const SMDS_MeshElement* e ) const
|
||||
{
|
||||
return my1stID + Index( e );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set a Vtk ID of an element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::SetVTKID( const SMDS_MeshElement* e, const vtkIdType vtkID )
|
||||
{
|
||||
if ( e->GetID() - 1 != vtkID )
|
||||
{
|
||||
if ((int) myFactory->myVtkIDs.size() <= e->GetID() - 1 )
|
||||
{
|
||||
size_t i = myFactory->myVtkIDs.size();
|
||||
myFactory->myVtkIDs.resize( e->GetID() + 100 );
|
||||
for ( ; i < myFactory->myVtkIDs.size(); ++i )
|
||||
myFactory->myVtkIDs[i] = i;
|
||||
}
|
||||
myFactory->myVtkIDs[ e->GetID() - 1 ] = vtkID;
|
||||
|
||||
if ((vtkIdType) myFactory->mySmdsIDs.size() <= vtkID )
|
||||
{
|
||||
size_t i = myFactory->mySmdsIDs.size();
|
||||
myFactory->mySmdsIDs.resize( vtkID + 100 );
|
||||
for ( ; i < myFactory->mySmdsIDs.size(); ++i )
|
||||
myFactory->mySmdsIDs[i] = i;
|
||||
}
|
||||
myFactory->mySmdsIDs[ vtkID ] = e->GetID() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return a Vtk ID of an element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementChunk::GetVtkID( const SMDS_MeshElement* e ) const
|
||||
{
|
||||
size_t dfltVtkID = e->GetID() - 1;
|
||||
return ( dfltVtkID < myFactory->myVtkIDs.size() ) ? myFactory->myVtkIDs[ dfltVtkID ] : dfltVtkID;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return ID of a shape an element is assigned to
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_ElementChunk::GetShapeID( const SMDS_MeshElement* e ) const
|
||||
{
|
||||
return mySubIDRanges.GetValue( Index( e ));
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set ID of a shape an element is assigned to
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::SetShapeID( const SMDS_MeshElement* e, int shapeID ) const
|
||||
{
|
||||
const size_t nbRanges = mySubIDRanges.Size();
|
||||
|
||||
SMDS_ElementChunk* me = const_cast<SMDS_ElementChunk*>( this );
|
||||
int oldShapeID = me->mySubIDRanges.SetValue( Index( e ), shapeID );
|
||||
if ( oldShapeID == shapeID ) return;
|
||||
|
||||
if ( const SMDS_MeshNode* n = dynamic_cast< const SMDS_MeshNode* >( e ))
|
||||
if ( TParam* uv = me->GetPositionPtr( n ))
|
||||
{
|
||||
uv[0] = 0.;
|
||||
uv[1] = 0.;
|
||||
}
|
||||
// update min/max
|
||||
if (( nbRanges > mySubIDRanges.Size() ) &&
|
||||
( myMinSubID == oldShapeID || myMaxSubID == oldShapeID ))
|
||||
{
|
||||
me->myMinSubID = ( std::numeric_limits<int>::max() );
|
||||
me->myMaxSubID = 0;
|
||||
TSubIDRangeSet::set_iterator it;
|
||||
for ( it = mySubIDRanges.mySet.begin(); it < mySubIDRanges.mySet.end(); ++it )
|
||||
if ( it->myValue > 0 )
|
||||
{
|
||||
me->myMinSubID = std::min( myMinSubID, it->myValue );
|
||||
me->myMaxSubID = std::max( myMaxSubID, it->myValue );
|
||||
}
|
||||
}
|
||||
else if ( shapeID > 0 )
|
||||
{
|
||||
me->myMinSubID = std::min( myMinSubID, shapeID );
|
||||
me->myMaxSubID = std::max( myMaxSubID, shapeID );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set isMarked flag of an element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool SMDS_ElementChunk::IsMarked( const SMDS_MeshElement* e ) const
|
||||
{
|
||||
return ( !myMarkedSet.empty() && myMarkedSet[ Index( e )]);
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return isMarked flag of an element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::SetIsMarked( const SMDS_MeshElement* e, bool is )
|
||||
{
|
||||
if ( !is && myMarkedSet.empty() ) return;
|
||||
if ( myMarkedSet.empty() ) myMarkedSet.resize( theChunkSize, false );
|
||||
myMarkedSet[ Index( e )] = is;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return SMDS_Position of a node on a shape
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_PositionPtr SMDS_ElementChunk::GetPosition( const SMDS_MeshNode* n ) const
|
||||
{
|
||||
int shapeID = GetShapeID( n );
|
||||
int shapeDim = static_cast< SMDS_NodeFactory* >( myFactory )->GetShapeDim( shapeID );
|
||||
|
||||
SMDS_ElementChunk* me = const_cast< SMDS_ElementChunk* >( this );
|
||||
|
||||
switch ( shapeDim ) {
|
||||
case 2:
|
||||
{
|
||||
return SMDS_PositionPtr( new _FacePosition( me->GetPositionPtr( n )));
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
return SMDS_PositionPtr( new _EdgePosition( me->GetPositionPtr( n )));
|
||||
}
|
||||
case 0:
|
||||
return SMDS_VertexPosition::StaticPosition();
|
||||
}
|
||||
|
||||
return SMDS_SpacePosition::originSpacePosition();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set SMDS_Position of a node on a shape
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::SetPosition( const SMDS_MeshNode* n, const SMDS_PositionPtr& pos, int shapeID )
|
||||
{
|
||||
int shapeDim = pos ? pos->GetDim() : theDefaultShapeDim;
|
||||
if ( shapeID < 1 )
|
||||
{
|
||||
if ( shapeDim == theDefaultShapeDim )
|
||||
return;
|
||||
shapeID = GetShapeID( n );
|
||||
if ( shapeID < 1 )
|
||||
throw SALOME_Exception("SetPosition() No shape ID provided");
|
||||
}
|
||||
|
||||
static_cast< SMDS_NodeFactory* >( myFactory )->SetShapeDim( shapeID, shapeDim );
|
||||
|
||||
switch ( shapeDim ) {
|
||||
case 2:
|
||||
{
|
||||
TParam* uv = GetPositionPtr( n, /*allocate=*/true );
|
||||
uv[0] = (TParam) pos->GetParameters()[0];
|
||||
uv[1] = (TParam) pos->GetParameters()[1];
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
GetPositionPtr( n, /*allocate=*/true )[0] = (TParam) pos->GetParameters()[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return pointer to on-shape-parameters of a node
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
TParam* SMDS_ElementChunk::GetPositionPtr( const SMDS_MeshElement* n, bool allocate )
|
||||
{
|
||||
if ( myPositions.empty() && !allocate )
|
||||
return 0;
|
||||
|
||||
myPositions.resize( theChunkSize * 2 );
|
||||
return myPositions.data() + 2 * Index( n );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Minimize allocated memory
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::Compact()
|
||||
{
|
||||
mySubIDRanges.mySet.shrink_to_fit();
|
||||
if ( myUsedRanges.mySet.capacity() > 2 )
|
||||
myUsedRanges.mySet.shrink_to_fit();
|
||||
|
||||
clearVector( myMarkedSet );
|
||||
|
||||
if ( !myPositions.empty() )
|
||||
{
|
||||
// look for the last position that must be kept
|
||||
TSubIDRangeSet::set_t::reverse_iterator it;
|
||||
for ( it = mySubIDRanges.mySet.rbegin(); it != mySubIDRanges.mySet.rend(); ++it )
|
||||
{
|
||||
int shapeDim = static_cast< SMDS_NodeFactory* >( myFactory )->GetShapeDim( it->myValue );
|
||||
if ( shapeDim == 1 || shapeDim == 2 )
|
||||
break;
|
||||
}
|
||||
if ( it == mySubIDRanges.mySet.rend() )
|
||||
{
|
||||
clearVector( myPositions );
|
||||
}
|
||||
else if ( it != mySubIDRanges.mySet.rbegin() )
|
||||
{
|
||||
int nbNodes = (it-1)->my1st;
|
||||
myPositions.resize( nbNodes * 2 );
|
||||
std::vector<TParam> newPos( myPositions.begin(), myPositions.end() );
|
||||
myPositions.swap( newPos );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Print some data for debug purposes
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_ElementChunk::Dump() const
|
||||
{
|
||||
std::cout << "1stID: " << my1stID << std::endl;
|
||||
|
||||
std::cout << "SubID min/max: " << myMinSubID << ", " << myMaxSubID << std::endl;
|
||||
std::cout << "SubIDRanges: " << mySubIDRanges.Size() << " ";
|
||||
{
|
||||
TSubIDRangeSet::set_iterator i = mySubIDRanges.mySet.begin();
|
||||
for ( int cnt = 0; i != mySubIDRanges.mySet.end(); ++i, ++cnt )
|
||||
std::cout << "|" << cnt << " - (" << i->my1st << ", " << i->myValue << ") ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
{
|
||||
std::cout << "UsedRanges: " << myUsedRanges.Size() << " ";
|
||||
TUsedRangeSet::set_iterator i = myUsedRanges.mySet.begin();
|
||||
for ( int cnt = 0; i != myUsedRanges.mySet.end(); ++i, ++cnt )
|
||||
std::cout << cnt << " - (" << i->my1st << ", " << i->myValue << ") ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Compare SMDS_ElementChunk's
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool _ChunkCompare::operator () (const SMDS_ElementChunk* e1, const SMDS_ElementChunk* e2) const
|
||||
{
|
||||
return e1->Get1stID() < e2->Get1stID();
|
||||
}
|
||||
|
559
src/SMDS/SMDS_ElementFactory.hxx
Normal file
559
src/SMDS/SMDS_ElementFactory.hxx
Normal file
@ -0,0 +1,559 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// File : SMDS_ElementFactory.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_ElementFactory_HeaderFile
|
||||
#define _SMDS_ElementFactory_HeaderFile
|
||||
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
#include "SMDS_Position.hxx"
|
||||
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <vtkType.h>
|
||||
|
||||
class SMDS_ElementChunk;
|
||||
class SMDS_Mesh;
|
||||
class SMDS_MeshCell;
|
||||
class SMDS_MeshNode;
|
||||
|
||||
struct _ChunkCompare {
|
||||
bool operator () (const SMDS_ElementChunk* c1, const SMDS_ElementChunk* c2) const;
|
||||
};
|
||||
typedef boost::ptr_vector<SMDS_ElementChunk> TChunkVector;
|
||||
typedef std::set<SMDS_ElementChunk*,_ChunkCompare> TChunkPtrSet;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's )
|
||||
* and bind some attributes to elements:
|
||||
* element ID, element VTK ID, sub-mesh ID, position on shape.
|
||||
*
|
||||
* Elements are allocated by chunks, so there are used and non-used elements
|
||||
*/
|
||||
class SMDS_ElementFactory
|
||||
{
|
||||
protected:
|
||||
bool myIsNodal; // what to allocate: nodes or cells
|
||||
SMDS_Mesh* myMesh;
|
||||
TChunkVector myChunks; // array of chunks of elements
|
||||
TChunkPtrSet myChunksWithUnused; // sorted chunks having unused elements
|
||||
std::vector< vtkIdType > myVtkIDs; // myVtkIDs[ smdsID-1 ] == vtkID
|
||||
std::vector< int > mySmdsIDs; // mySmdsIDs[ vtkID ] == smdsID - 1
|
||||
int myNbUsedElements; // counter of elements
|
||||
|
||||
friend class SMDS_ElementChunk;
|
||||
|
||||
public:
|
||||
|
||||
SMDS_ElementFactory( SMDS_Mesh* mesh, const bool isNodal=false );
|
||||
virtual ~SMDS_ElementFactory();
|
||||
|
||||
//! Return minimal ID of a non-used element
|
||||
int GetFreeID();
|
||||
|
||||
//! Return maximal ID of an used element
|
||||
int GetMaxID();
|
||||
|
||||
//! Return minimal ID of an used element
|
||||
int GetMinID();
|
||||
|
||||
//! Return an element by ID. NULL if the element with the given ID is already used
|
||||
SMDS_MeshElement* NewElement( const int id );
|
||||
|
||||
//! Return a SMDS_MeshCell by ID. NULL if the cell with the given ID is already used
|
||||
SMDS_MeshCell* NewCell( const int id ) { return static_cast<SMDS_MeshCell*>( NewElement( id )); }
|
||||
|
||||
//! Return an used element by ID. NULL if the element with the given ID is not yet used
|
||||
const SMDS_MeshElement* FindElement( const int id ) const;
|
||||
|
||||
//! Return a number of used elements
|
||||
int NbUsedElements() const { return myNbUsedElements; }
|
||||
|
||||
//! Return an iterator on all element filtered using a given filter.
|
||||
// nbElemsToReturn is used to optimize by stopping the iteration as soon as
|
||||
// all elements satisfying filtering condition encountered.
|
||||
template< class ElemIterator >
|
||||
boost::shared_ptr< ElemIterator > GetIterator( SMDS_MeshElement::Filter* filter,
|
||||
size_t nbElemsToReturn = -1 );
|
||||
|
||||
//! Return an iterator on all element assigned to a given shape.
|
||||
// nbElemsToReturn is used to optimize by stopping the iteration as soon as
|
||||
// all elements assigned to the shape encountered.
|
||||
template< class ElemIterator >
|
||||
boost::shared_ptr< ElemIterator > GetShapeIterator( int shapeID, size_t nbElemsToReturn );
|
||||
|
||||
//! Mark the element as non-used
|
||||
void Free( const SMDS_MeshElement* );
|
||||
|
||||
//! Return an SMDS ID by a Vtk one
|
||||
int FromVtkToSmds( vtkIdType vtkID );
|
||||
|
||||
//! De-allocate all elements
|
||||
virtual void Clear();
|
||||
|
||||
//! Remove unused elements located not at the end of the last chunk.
|
||||
// Minimize allocated memory
|
||||
virtual void Compact(std::vector<int>& idCellsOldToNew);
|
||||
|
||||
//! Return true if Compact() will change IDs of elements
|
||||
virtual bool CompactChangePointers();
|
||||
|
||||
//! Return a number of elements in a chunk
|
||||
static int ChunkSize();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Allocate SMDS_MeshNode's
|
||||
*/
|
||||
class SMDS_NodeFactory : public SMDS_ElementFactory
|
||||
{
|
||||
std::vector<char> myShapeDim; // dimension of shapes
|
||||
|
||||
public:
|
||||
|
||||
SMDS_NodeFactory( SMDS_Mesh* mesh );
|
||||
~SMDS_NodeFactory();
|
||||
|
||||
//! Return a SMDS_MeshNode by ID. NULL if the node with the given ID is already used
|
||||
SMDS_MeshNode* NewNode( int id ) { return (SMDS_MeshNode*) NewElement(id); }
|
||||
|
||||
//! Return an used node by ID. NULL if the node with the given ID is not yet used
|
||||
const SMDS_MeshNode* FindNode( int id ) { return (const SMDS_MeshNode*) FindElement(id); }
|
||||
|
||||
//! Set a total number of sub-shapes in the main shape
|
||||
void SetNbShapes( size_t nbShapes );
|
||||
|
||||
//! Return a dimension of a shape
|
||||
int GetShapeDim( int shapeID ) const;
|
||||
|
||||
//! Set a dimension of a shape
|
||||
void SetShapeDim( int shapeID, int dim );
|
||||
|
||||
//! De-allocate all nodes
|
||||
virtual void Clear();
|
||||
|
||||
//! Remove unused nodes located not at the end of the last chunk.
|
||||
// Minimize allocated memory
|
||||
virtual void Compact(std::vector<int>& idNodesOldToNew);
|
||||
|
||||
//! Return true if Compact() will change IDs of node
|
||||
virtual bool CompactChangePointers();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Range of elements in a chunk having the same attribute value
|
||||
*/
|
||||
template< typename ATTR>
|
||||
struct _Range
|
||||
{
|
||||
typedef ATTR attr_t;
|
||||
|
||||
attr_t myValue; // common attribute value
|
||||
int my1st; // index in the chunk of the 1st element
|
||||
_Range( int i0 = 0, attr_t v = 0 ): myValue( v ), my1st( i0 ) {}
|
||||
|
||||
bool operator < (const _Range& other) const { return my1st < other.my1st; }
|
||||
};
|
||||
|
||||
typedef std::vector< std::pair< int, int > > TIndexRanges;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Sorted set of ranges
|
||||
*/
|
||||
template< class RANGE >
|
||||
struct _RangeSet
|
||||
{
|
||||
typedef typename RANGE::attr_t attr_t;
|
||||
typedef boost::container::flat_set< RANGE > set_t;
|
||||
typedef typename set_t::const_iterator set_iterator;
|
||||
|
||||
set_t mySet;
|
||||
|
||||
_RangeSet() { mySet.insert( RANGE( 0, 0 )); }
|
||||
|
||||
/*!
|
||||
* \brief Return a number of ranges
|
||||
*/
|
||||
size_t Size() const { return mySet.size(); }
|
||||
|
||||
/*!
|
||||
* \brief Return a mutable _Range::my1st of a range pointed by an iterator
|
||||
*/
|
||||
int& First( set_iterator rangePtr ) { return const_cast< int& >( rangePtr->my1st ); }
|
||||
|
||||
/*!
|
||||
* \brief Return a number of elements in a range pointed by an iterator
|
||||
*/
|
||||
size_t Size( set_iterator rangePtr ) const
|
||||
{
|
||||
int next1st =
|
||||
( rangePtr + 1 == mySet.end() ) ? SMDS_ElementFactory::ChunkSize() : ( rangePtr + 1 )->my1st;
|
||||
return next1st - rangePtr->my1st;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return ranges of indices (from,to) of elements having a given value
|
||||
*/
|
||||
bool GetIndices( const attr_t theValue, TIndexRanges & theIndices,
|
||||
const attr_t* theMinValue = 0, const attr_t* theMaxValue = 0) const
|
||||
{
|
||||
bool isFound = false;
|
||||
|
||||
if ( sizeof( attr_t ) == sizeof( int ) && theMinValue )
|
||||
if ( theValue < *theMinValue || theValue > *theMaxValue )
|
||||
return isFound;
|
||||
|
||||
for ( set_iterator it = mySet.begin(); it < mySet.end(); ++it )
|
||||
{
|
||||
if ( it->myValue == theValue )
|
||||
{
|
||||
theIndices.push_back( std::make_pair( it->my1st, it->my1st + Size( it )));
|
||||
isFound = true;
|
||||
++it; // the next range value differs from theValue
|
||||
}
|
||||
}
|
||||
return isFound;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return value of an element attribute
|
||||
* \param [in] theIndex - element index
|
||||
* \return attr_t - attribute value
|
||||
*/
|
||||
attr_t GetValue( int theIndex ) const
|
||||
{
|
||||
set_iterator r = mySet.upper_bound( theIndex ) - 1;
|
||||
return r->myValue;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Change value of an element attribute
|
||||
* \param [in] theIndex - element index
|
||||
* \param [in] theValue - attribute value
|
||||
* \return attr_t - previous value
|
||||
*/
|
||||
attr_t SetValue( int theIndex, attr_t theValue )
|
||||
{
|
||||
set_iterator rNext = mySet.upper_bound( theIndex );
|
||||
set_iterator r = rNext - 1;
|
||||
int rSize = Size( r ); // range size
|
||||
attr_t rValue = r->myValue;
|
||||
if ( rValue == theValue )
|
||||
return rValue; // it happens while compacting
|
||||
|
||||
if ( r->my1st == theIndex ) // theIndex is the first in the range
|
||||
{
|
||||
bool joinPrev = // can join theIndex to the previous range
|
||||
( r->my1st > 0 && ( r-1 )->myValue == theValue );
|
||||
|
||||
if ( rSize == 1 )
|
||||
{
|
||||
bool joinNext = // can join to the next range
|
||||
( rNext != mySet.end() && rNext->myValue == theValue );
|
||||
|
||||
if ( joinPrev )
|
||||
{
|
||||
if ( joinNext ) // && joinPrev
|
||||
{
|
||||
mySet.erase( r, r + 2 );
|
||||
}
|
||||
else // joinPrev && !joinNext
|
||||
{
|
||||
mySet.erase( r );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( joinNext ) // && !joinPrev
|
||||
{
|
||||
r = mySet.erase( r ); // then r points to the next range
|
||||
First( r )--;
|
||||
}
|
||||
else // !joinPrev && !joinNext
|
||||
{
|
||||
const_cast< attr_t & >( r->myValue ) = theValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // if rSize > 1
|
||||
{
|
||||
if ( joinPrev )
|
||||
{
|
||||
First( r )++;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = mySet.insert( r, RANGE( theIndex + 1, rValue )) - 1;
|
||||
const_cast< attr_t & >( r->myValue ) = theValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( r->my1st + rSize - 1 == theIndex ) // theIndex is last in the range
|
||||
{
|
||||
if ( rNext != mySet.end() && rNext->myValue == theValue ) // join to the next
|
||||
{
|
||||
First( rNext )--;
|
||||
}
|
||||
else
|
||||
{
|
||||
mySet.insert( r, RANGE( theIndex, theValue ));
|
||||
}
|
||||
}
|
||||
else // theIndex in the middle of the range
|
||||
{
|
||||
r = mySet.insert( r, RANGE( theIndex, theValue ));
|
||||
r = mySet.insert( r, RANGE( theIndex + 1, rValue ));
|
||||
}
|
||||
return rValue;
|
||||
}
|
||||
}; // struct _RangeSet
|
||||
|
||||
|
||||
typedef _Range< int > _ShapeIDRange; // sub-mesh ID range
|
||||
typedef _Range< bool > _UsedRange; // range of used elements
|
||||
|
||||
typedef _RangeSet< _ShapeIDRange > TSubIDRangeSet;
|
||||
typedef _RangeSet< _UsedRange > TUsedRangeSet;
|
||||
typedef boost::dynamic_bitset<> TBitSet;
|
||||
typedef float TParam;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's )
|
||||
* and bind some attributes to elements:
|
||||
* element ID, sub-shape ID, isMarked flag, parameters on shape
|
||||
*/
|
||||
class SMDS_ElementChunk
|
||||
{
|
||||
SMDS_ElementFactory* myFactory; // holder of this chunk
|
||||
SMDS_MeshElement* myElements; // array of elements
|
||||
int my1stID; // ID of myElements[0]
|
||||
TBitSet myMarkedSet; // mark some elements
|
||||
TUsedRangeSet myUsedRanges; // ranges of used/unused elements
|
||||
TSubIDRangeSet mySubIDRanges; // ranges of elements on the same sub-shape
|
||||
int myMinSubID; // min sub-shape ID
|
||||
int myMaxSubID; // max sub-shape ID
|
||||
std::vector<TParam> myPositions; // UV parameters on shape: 2*param_t per an element
|
||||
|
||||
public:
|
||||
|
||||
SMDS_ElementChunk( SMDS_ElementFactory* factory = 0, int id0 = 0 );
|
||||
~SMDS_ElementChunk();
|
||||
|
||||
//! Return an element by an index [0,ChunkSize()]
|
||||
SMDS_MeshElement* Element(int index) { return & myElements[index]; }
|
||||
|
||||
//! Return an element by an index [0,ChunkSize()]
|
||||
const SMDS_MeshElement* Element(int index) const { return & myElements[index]; }
|
||||
|
||||
//! Return ID of the first non-used element
|
||||
int GetUnusedID() const;
|
||||
|
||||
//! Mark an element as used
|
||||
void UseElement( const int index );
|
||||
|
||||
//! Mark an element as non-used
|
||||
void Free( const SMDS_MeshElement* e );
|
||||
|
||||
//! Check if a given range holds used or non-used elements
|
||||
static bool IsUsed( const _UsedRange& r ) { return r.myValue; }
|
||||
|
||||
//! Return index of an element in the chunk
|
||||
int Index( const SMDS_MeshElement* e ) const { return e - myElements; }
|
||||
|
||||
//! Return ID of the 1st element in the chunk
|
||||
int Get1stID() const { return my1stID; }
|
||||
|
||||
//! Return pointer to on-shape-parameters of a node
|
||||
TParam* GetPositionPtr( const SMDS_MeshElement* node, bool allocate=false );
|
||||
|
||||
//! Return ranges of used/non-used elements
|
||||
const TUsedRangeSet& GetUsedRanges() const { return myUsedRanges; }
|
||||
const TUsedRangeSet& GetUsedRangesMinMax( bool& min, bool& max ) const
|
||||
{ min = false; max = true; return myUsedRanges; }
|
||||
|
||||
//! Return ranges of elements assigned to sub-shapes and min/max of sub-shape IDs
|
||||
const TSubIDRangeSet& GetSubIDRangesMinMax( int& min, int& max ) const
|
||||
{ min = myMinSubID; max = myMaxSubID; return mySubIDRanges; }
|
||||
|
||||
//! Minimize allocated memory
|
||||
void Compact();
|
||||
|
||||
//! Print some data
|
||||
void Dump() const; // debug
|
||||
|
||||
|
||||
// Methods called by SMDS_MeshElement
|
||||
|
||||
int GetID( const SMDS_MeshElement* e ) const;
|
||||
|
||||
int GetVtkID( const SMDS_MeshElement* e ) const;
|
||||
void SetVTKID( const SMDS_MeshElement* e, const vtkIdType id );
|
||||
|
||||
int GetShapeID( const SMDS_MeshElement* e ) const;
|
||||
void SetShapeID( const SMDS_MeshElement* e, int shapeID ) const;
|
||||
|
||||
bool IsMarked ( const SMDS_MeshElement* e ) const;
|
||||
void SetIsMarked( const SMDS_MeshElement* e, bool is );
|
||||
|
||||
SMDS_PositionPtr GetPosition( const SMDS_MeshNode* n ) const;
|
||||
void SetPosition( const SMDS_MeshNode* n, const SMDS_PositionPtr& pos, int shapeID );
|
||||
|
||||
SMDS_Mesh* GetMesh() { return myFactory->myMesh; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Iterator on elements in chunks
|
||||
*/
|
||||
template< class ELEM_ITERATOR, class RANGE_SET >
|
||||
struct _ChunkIterator : public ELEM_ITERATOR
|
||||
{
|
||||
typedef typename ELEM_ITERATOR::value_type element_type;
|
||||
typedef SMDS_MeshElement::Filter* filter_ptr;
|
||||
typedef typename RANGE_SET::attr_t attr_type;
|
||||
typedef const RANGE_SET& (SMDS_ElementChunk::*get_rangeset_fun)(attr_type&, attr_type&) const;
|
||||
|
||||
const SMDS_MeshElement* myElement;
|
||||
TIndexRanges myRanges;
|
||||
int myRangeIndex;
|
||||
const TChunkVector& myChunks;
|
||||
int myChunkIndex;
|
||||
get_rangeset_fun myGetRangeSetFun;
|
||||
attr_type myValue;
|
||||
attr_type myMinValue;
|
||||
attr_type myMaxValue;
|
||||
filter_ptr myFilter;
|
||||
size_t myNbElemsToReturn;
|
||||
size_t myNbReturned;
|
||||
|
||||
_ChunkIterator( const TChunkVector & theChunks,
|
||||
get_rangeset_fun theGetRangeSetFun,
|
||||
attr_type theAttrValue,
|
||||
SMDS_MeshElement::Filter* theFilter,
|
||||
size_t theNbElemsToReturn = -1):
|
||||
myElement( 0 ),
|
||||
myRangeIndex( 0 ),
|
||||
myChunks( theChunks ),
|
||||
myChunkIndex( -1 ),
|
||||
myGetRangeSetFun( theGetRangeSetFun ),
|
||||
myValue( theAttrValue ),
|
||||
myFilter( theFilter ),
|
||||
myNbElemsToReturn( theNbElemsToReturn ),
|
||||
myNbReturned( 0 )
|
||||
{
|
||||
next();
|
||||
}
|
||||
~_ChunkIterator()
|
||||
{
|
||||
delete myFilter;
|
||||
}
|
||||
|
||||
virtual bool more()
|
||||
{
|
||||
return myElement;
|
||||
}
|
||||
|
||||
virtual element_type next()
|
||||
{
|
||||
element_type result = (element_type) myElement;
|
||||
myNbReturned += bool( result );
|
||||
|
||||
myElement = 0;
|
||||
if ( myNbReturned < myNbElemsToReturn )
|
||||
while ( ! nextInRange() )
|
||||
{
|
||||
if ( ++myRangeIndex >= (int)myRanges.size() )
|
||||
{
|
||||
myRanges.clear();
|
||||
myRangeIndex = 0;
|
||||
while ( ++myChunkIndex < (int)myChunks.size() &&
|
||||
!getRangeSet().GetIndices( myValue, myRanges, &myMinValue, &myMaxValue ))
|
||||
;
|
||||
if ( myChunkIndex >= (int)myChunks.size() )
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool nextInRange()
|
||||
{
|
||||
if ( myRangeIndex < (int)myRanges.size() )
|
||||
{
|
||||
std::pair< int, int > & range = myRanges[ myRangeIndex ];
|
||||
while ( range.first < range.second && !myElement )
|
||||
{
|
||||
myElement = myChunks[ myChunkIndex ].Element( range.first++ );
|
||||
if ( !(*myFilter)( myElement ))
|
||||
myElement = 0;
|
||||
}
|
||||
}
|
||||
return myElement;
|
||||
}
|
||||
|
||||
const RANGE_SET& getRangeSet()
|
||||
{
|
||||
return ( myChunks[ myChunkIndex ].*myGetRangeSetFun )( myMinValue, myMaxValue );
|
||||
}
|
||||
}; // struct _ChunkIterator
|
||||
|
||||
|
||||
template< class ElemIterator >
|
||||
boost::shared_ptr< ElemIterator >
|
||||
SMDS_ElementFactory::GetIterator( SMDS_MeshElement::Filter* filter,
|
||||
size_t nbElemsToReturn )
|
||||
{
|
||||
typedef _ChunkIterator< ElemIterator, TUsedRangeSet > TChuckIterator;
|
||||
return boost::make_shared< TChuckIterator >( myChunks,
|
||||
& SMDS_ElementChunk::GetUsedRangesMinMax,
|
||||
/*isUsed=*/true,
|
||||
filter,
|
||||
nbElemsToReturn );
|
||||
}
|
||||
|
||||
template< class ElemIterator >
|
||||
boost::shared_ptr< ElemIterator >
|
||||
SMDS_ElementFactory::GetShapeIterator( int shapeID, size_t nbElemsToReturn )
|
||||
{
|
||||
typedef _ChunkIterator< ElemIterator, TSubIDRangeSet > TChuckIterator;
|
||||
return boost::make_shared< TChuckIterator >( myChunks,
|
||||
& SMDS_ElementChunk::GetSubIDRangesMinMax,
|
||||
/*shapeID=*/shapeID,
|
||||
new SMDS_MeshElement::NonNullFilter(),
|
||||
nbElemsToReturn );
|
||||
}
|
||||
|
||||
#endif
|
122
src/SMDS/SMDS_ElementHolder.cxx
Normal file
122
src/SMDS/SMDS_ElementHolder.cxx
Normal file
@ -0,0 +1,122 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// File : SMDS_ElementHolder.cxx
|
||||
// Module : SMESH
|
||||
//
|
||||
|
||||
#include "SMDS_ElementHolder.hxx"
|
||||
|
||||
#include "ObjectPool.hxx"
|
||||
#include "SMDS_CellOfNodes.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_ElementHolder
|
||||
//purpose : register self in the mesh
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElementHolder::SMDS_ElementHolder( const SMDS_Mesh* mesh )
|
||||
: myMesh( const_cast< SMDS_Mesh* >( mesh ))
|
||||
{
|
||||
myPtrInMesh = myMesh->myElemHolders.insert( this ).first;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~SMDS_ElementHolder
|
||||
//purpose : un-register self from the mesh
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElementHolder::~SMDS_ElementHolder()
|
||||
{
|
||||
myMesh->myElemHolders.erase( myPtrInMesh );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : beforeCompacting
|
||||
//purpose : store vtkIDs of elements
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_ElementHolder::beforeCompacting()
|
||||
{
|
||||
int i = 0;
|
||||
for ( SMDS_ElemIteratorPtr it = getElements(); it->more(); ++i )
|
||||
{
|
||||
const SMDS_MeshElement* e = it->next();
|
||||
if ( !e ) continue;
|
||||
if ( e->IsNull() && !dynamic_cast<const SMDS_CellOfNodes*>( e ))
|
||||
continue; // removed element
|
||||
myIsNode.push_back( e->GetType() == SMDSAbs_Node );
|
||||
if ( myMesh->Contains( e ))
|
||||
{
|
||||
myVtkIDs.push_back( e->GetVtkID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
myExternalElems.push_back( e );
|
||||
myVtkIDs.push_back( -1 * (int)myExternalElems.size() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : restoreElements
|
||||
//purpose : restore pointers to elements
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_ElementHolder::restoreElements( const std::vector<int>& idNodesOldToNew,
|
||||
const std::vector<int>& idCellsOldToNew )
|
||||
{
|
||||
tmpClear();
|
||||
|
||||
const SMDS_MeshElement* elem;
|
||||
|
||||
std::vector< bool >::iterator isNode = myIsNode.begin();
|
||||
for ( size_t i = 0; i < myVtkIDs.size(); ++i, ++isNode )
|
||||
{
|
||||
int vtkID = myVtkIDs[i];
|
||||
if ( vtkID < 0 )
|
||||
{
|
||||
elem = myExternalElems[ (-vtkID)-1 ];
|
||||
}
|
||||
else if ( *isNode )
|
||||
{
|
||||
if ( vtkID < (int)idNodesOldToNew.size() )
|
||||
elem = myMesh->FindNodeVtk( idNodesOldToNew[ vtkID ]);
|
||||
else
|
||||
elem = myMesh->FindNodeVtk( vtkID );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( vtkID < (int)idCellsOldToNew.size() )
|
||||
elem = myMesh->FindElementVtk( idCellsOldToNew[ vtkID ]);
|
||||
else
|
||||
elem = myMesh->FindElementVtk( vtkID );
|
||||
}
|
||||
if ( elem )
|
||||
add( elem );
|
||||
}
|
||||
clearVector( myExternalElems );
|
||||
clearVector( myVtkIDs );
|
||||
clearVector( myIsNode );
|
||||
|
||||
compact();
|
||||
}
|
93
src/SMDS/SMDS_ElementHolder.hxx
Normal file
93
src/SMDS/SMDS_ElementHolder.hxx
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// File : SMDS_ElementHolder.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_ElementHolder_HeaderFile
|
||||
#define _SMDS_ElementHolder_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_ElemIterator.hxx"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
class SMDS_Mesh;
|
||||
class SMDS_MeshElement;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Base class of object holding SMDS_MeshElement pointers.
|
||||
* Registering such an object in SMDS_Mesh assures that the
|
||||
* pointers remain valid after compacting the mesh
|
||||
*/
|
||||
class SMDS_EXPORT SMDS_ElementHolder
|
||||
{
|
||||
public:
|
||||
|
||||
//! register self in the mesh
|
||||
SMDS_ElementHolder( const SMDS_Mesh* mesh );
|
||||
|
||||
//! un-register self from the mesh
|
||||
virtual ~SMDS_ElementHolder();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//!< the descendant object return its elements just before the mesh compacting
|
||||
virtual SMDS_ElemIteratorPtr getElements() = 0;
|
||||
|
||||
//!< the descendant object temporary remove its elements
|
||||
virtual void tmpClear() = 0;
|
||||
|
||||
//!< the descendant object re-add its elements after the mesh compacting
|
||||
virtual void add( const SMDS_MeshElement* element ) = 0;
|
||||
|
||||
//!< the descendant squeeze its element storage after re-adding elements
|
||||
virtual void compact() = 0;
|
||||
|
||||
//!< allow the descendant treat its elements before mesh clearing
|
||||
virtual void clear() {}
|
||||
|
||||
SMDS_Mesh* myMesh;
|
||||
|
||||
|
||||
private: // methods called by SMDS_Mesh
|
||||
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
//! store vtkIDs of elements
|
||||
void beforeCompacting();
|
||||
|
||||
//! restore pointers to elements
|
||||
void restoreElements( const std::vector<int>& idNodessOldToNew,
|
||||
const std::vector<int>& idCellsOldToNew );
|
||||
|
||||
|
||||
std::vector<const SMDS_MeshElement*> myExternalElems; //!< elements not contained in the mesh
|
||||
std::vector< int > myVtkIDs; //!< vtk IDs of elements
|
||||
std::vector< bool > myIsNode;
|
||||
std::set< SMDS_ElementHolder* >::iterator myPtrInMesh;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,196 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_FaceOfEdges.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_FaceOfEdges::NbEdges() const
|
||||
{
|
||||
return myNbEdges;
|
||||
}
|
||||
|
||||
int SMDS_FaceOfEdges::NbFaces() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_FaceOfEdges::Print(ostream & OS) const
|
||||
{
|
||||
OS << "face <" << GetID() << " > : ";
|
||||
int i;
|
||||
for (i = 0; i < NbEdges() - 1; i++) OS << myEdges[i] << ",";
|
||||
OS << myEdges[i] << ") " << endl;
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
|
||||
{
|
||||
return SMDSAbs_Face;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
|
||||
{
|
||||
const SMDS_MeshEdge* const *mySet;
|
||||
int myLength;
|
||||
int index;
|
||||
public:
|
||||
SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l):
|
||||
mySet(s),myLength(l),index(0) {}
|
||||
|
||||
bool more()
|
||||
{
|
||||
return index<myLength;
|
||||
}
|
||||
|
||||
const SMDS_MeshElement* next()
|
||||
{
|
||||
index++;
|
||||
return mySet[index-1];
|
||||
}
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_FaceOfEdges::elementsIterator
|
||||
(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges));
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type, SMDS_ElemIteratorPtr
|
||||
(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges))));
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
||||
const SMDS_MeshEdge* edge2,
|
||||
const SMDS_MeshEdge* edge3)
|
||||
{
|
||||
//MESSAGE("****************************************************** SMDS_FaceOfEdges");
|
||||
myNbEdges = 3;
|
||||
myEdges[0]=edge1;
|
||||
myEdges[1]=edge2;
|
||||
myEdges[2]=edge3;
|
||||
myEdges[3]=0;
|
||||
}
|
||||
|
||||
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
||||
const SMDS_MeshEdge* edge2,
|
||||
const SMDS_MeshEdge* edge3,
|
||||
const SMDS_MeshEdge* edge4)
|
||||
{
|
||||
//MESSAGE("****************************************************** SMDS_FaceOfEdges");
|
||||
myNbEdges = 4;
|
||||
myEdges[0]=edge1;
|
||||
myEdges[1]=edge2;
|
||||
myEdges[2]=edge3;
|
||||
myEdges[3]=edge4;
|
||||
}
|
||||
|
||||
/*bool operator<(const SMDS_FaceOfEdges& f1, const SMDS_FaceOfEdges& f2)
|
||||
{
|
||||
set<SMDS_MeshNode> set1,set2;
|
||||
SMDS_ElemIteratorPtr it;
|
||||
const SMDS_MeshNode * n;
|
||||
|
||||
it=f1.nodesIterator();
|
||||
|
||||
while(it->more())
|
||||
{
|
||||
n=static_cast<const SMDS_MeshNode *>(it->next());
|
||||
set1.insert(*n);
|
||||
}
|
||||
|
||||
delete it;
|
||||
it=f2.nodesIterator();
|
||||
|
||||
while(it->more())
|
||||
{
|
||||
n=static_cast<const SMDS_MeshNode *>(it->next());
|
||||
set2.insert(*n);
|
||||
}
|
||||
|
||||
delete it;
|
||||
return set1<set2;
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
int SMDS_FaceOfEdges::NbNodes() const
|
||||
{
|
||||
return myEdges[0]->NbNodes() + myEdges[1]->NbNodes() + myEdges[2]->NbNodes() +
|
||||
( myNbEdges == 4 ? myEdges[3]->NbNodes() : 0 ) - myNbEdges;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
const SMDS_MeshNode* SMDS_FaceOfEdges::GetNode(const int ind) const
|
||||
{
|
||||
int index = ind;
|
||||
for ( int i = 0; i < myNbEdges; ++i ) {
|
||||
if ( index >= myEdges[ i ]->NbNodes() )
|
||||
index -= myEdges[ i ]->NbNodes();
|
||||
else
|
||||
return myEdges[ i ]->GetNode( index );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const
|
||||
{
|
||||
return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
|
||||
}
|
||||
|
||||
SMDSAbs_GeometryType SMDS_FaceOfEdges::GetGeomType() const
|
||||
{
|
||||
return myNbEdges == 3 ? SMDSGeom_TRIANGLE : SMDSGeom_QUADRANGLE;
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
//
|
||||
#ifndef _SMDS_FaceOfEdges_HeaderFile
|
||||
#define _SMDS_FaceOfEdges_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
#include "SMDS_MeshEdge.hxx"
|
||||
#include "SMDS_Iterator.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class SMDS_EXPORT SMDS_FaceOfEdges:public SMDS_MeshFace
|
||||
{
|
||||
public:
|
||||
void Print(std::ostream & OS) const;
|
||||
SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
||||
const SMDS_MeshEdge* edge2,
|
||||
const SMDS_MeshEdge* edge3);
|
||||
SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
|
||||
const SMDS_MeshEdge* edge2,
|
||||
const SMDS_MeshEdge* edge3,
|
||||
const SMDS_MeshEdge* edge4);
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes) {return false;}
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
|
||||
protected:
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
|
||||
private:
|
||||
const SMDS_MeshEdge* myEdges[4];
|
||||
int myNbEdges;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -26,15 +26,15 @@
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_FaceOfNodes.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
#include <utilities.h>
|
||||
|
||||
using namespace std;
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
@ -43,17 +43,25 @@ using namespace std;
|
||||
|
||||
int SMDS_FaceOfNodes::NbEdges() const
|
||||
{
|
||||
return NbNodes();
|
||||
return NbNodes();
|
||||
}
|
||||
|
||||
int SMDS_FaceOfNodes::NbFaces() const
|
||||
{
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SMDS_FaceOfNodes::NbNodes() const
|
||||
{
|
||||
return myNbNodes;
|
||||
return myNbNodes;
|
||||
}
|
||||
|
||||
int SMDS_FaceOfNodes::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
for ( int i = 0; i < myNbNodes; ++i )
|
||||
if ( myNodes[i] == node )
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -63,81 +71,31 @@ int SMDS_FaceOfNodes::NbNodes() const
|
||||
|
||||
void SMDS_FaceOfNodes::Print(ostream & OS) const
|
||||
{
|
||||
OS << "face <" << GetID() << " > : ";
|
||||
int i;
|
||||
for (i = 0; i < NbNodes() - 1; i++) OS << myNodes[i] << ",";
|
||||
OS << myNodes[i] << ") " << endl;
|
||||
OS << "face <" << GetID() << " > : ";
|
||||
int i;
|
||||
for (i = 0; i < NbNodes() - 1; i++) OS << myNodes[i] << ",";
|
||||
OS << myNodes[i] << ") " << endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class SMDS_FaceOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
|
||||
SMDS_ElemIteratorPtr SMDS_FaceOfNodes::nodesIterator() const
|
||||
{
|
||||
public:
|
||||
SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
|
||||
SMDS_NodeArrayElemIterator( s, & s[ l ] ) {}
|
||||
};
|
||||
return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
||||
/// ===================================================================
|
||||
/*!
|
||||
* \brief Iterator on edges of face
|
||||
*/
|
||||
/// ===================================================================
|
||||
|
||||
class _MyEdgeIterator : public SMDS_ElemIterator
|
||||
SMDS_NodeIteratorPtr SMDS_FaceOfNodes::nodeIterator() const
|
||||
{
|
||||
vector< const SMDS_MeshElement* > myElems;
|
||||
size_t myIndex;
|
||||
public:
|
||||
_MyEdgeIterator(const SMDS_FaceOfNodes* face):myIndex(0) {
|
||||
myElems.reserve( face->NbNodes() );
|
||||
for ( int i = 0; i < face->NbNodes(); ++i ) {
|
||||
const SMDS_MeshElement* edge =
|
||||
SMDS_Mesh::FindEdge( face->GetNode( i ), face->GetNodeWrap( i + 1 ));
|
||||
if ( edge )
|
||||
myElems.push_back( edge );
|
||||
}
|
||||
}
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more() { return myIndex < myElems.size(); }
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator( SMDSAbs_ElementType type ) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes));
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new _MyEdgeIterator( this ));
|
||||
break;
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type,SMDS_ElemIteratorPtr
|
||||
(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes))));
|
||||
}
|
||||
return SMDS_ElemIteratorPtr();
|
||||
return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
||||
SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
const SMDS_MeshNode* node2,
|
||||
const SMDS_MeshNode* node3)
|
||||
{
|
||||
//MESSAGE("******************************************************* SMDS_FaceOfNodes");
|
||||
myNbNodes = 3;
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=0;
|
||||
myNbNodes = 3;
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=0;
|
||||
}
|
||||
|
||||
SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
@ -145,12 +103,11 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
const SMDS_MeshNode* node3,
|
||||
const SMDS_MeshNode* node4)
|
||||
{
|
||||
//MESSAGE("******************************************************* SMDS_FaceOfNodes");
|
||||
myNbNodes = 4;
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNbNodes = 4;
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
}
|
||||
bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes)
|
||||
|
@ -27,46 +27,43 @@
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Iterator.hxx"
|
||||
#include "SMDS_CellOfNodes.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class SMDS_EXPORT SMDS_FaceOfNodes:public SMDS_MeshFace
|
||||
class SMDS_EXPORT SMDS_FaceOfNodes: public SMDS_CellOfNodes
|
||||
{
|
||||
public:
|
||||
void Print(std::ostream & OS) const;
|
||||
SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
const SMDS_MeshNode* node2,
|
||||
const SMDS_MeshNode* node3);
|
||||
SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
const SMDS_MeshNode* node2,
|
||||
const SMDS_MeshNode* node3,
|
||||
const SMDS_MeshNode* node4);
|
||||
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
int NbEdges() const;
|
||||
int NbFaces() const;
|
||||
int NbNodes() const;
|
||||
public:
|
||||
void Print(std::ostream & OS) const;
|
||||
SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
const SMDS_MeshNode* node2,
|
||||
const SMDS_MeshNode* node3);
|
||||
SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
|
||||
const SMDS_MeshNode* node2,
|
||||
const SMDS_MeshNode* node3,
|
||||
const SMDS_MeshNode* node4);
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
virtual int NbNodes() const;
|
||||
|
||||
virtual int NbCornerNodes() const { return NbNodes(); }
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
|
||||
virtual bool IsPoly() const { return false; }
|
||||
virtual bool IsQuadratic() const { return false; }
|
||||
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
|
||||
/*!
|
||||
* \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;
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
|
||||
protected:
|
||||
SMDS_ElemIteratorPtr
|
||||
elementsIterator(SMDSAbs_ElementType type) const;
|
||||
|
||||
private:
|
||||
const SMDS_MeshNode* myNodes[4];
|
||||
int myNbNodes;
|
||||
private:
|
||||
const SMDS_MeshNode* myNodes[4];
|
||||
int myNbNodes;
|
||||
|
||||
};
|
||||
|
||||
|
@ -26,63 +26,62 @@
|
||||
// Module : SMESH
|
||||
//
|
||||
#include "SMDS_FacePosition.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
#include "SMDS_EdgePosition.hxx"
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_FacePosition
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_FacePosition::SMDS_FacePosition(const double aUParam,
|
||||
const double aVParam)
|
||||
: myUParameter(aUParam),myVParameter(aVParam)
|
||||
{
|
||||
//MESSAGE("******************************************************** SMDS_FacePosition");
|
||||
SetParameters( aUParam,aVParam );
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
//=======================================================================
|
||||
//function : GetTypeOfPosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_TypeOfPosition SMDS_FacePosition::GetTypeOfPosition() const
|
||||
{
|
||||
return SMDS_TOP_FACE;
|
||||
return SMDS_TOP_FACE;
|
||||
}
|
||||
|
||||
void SMDS_FacePosition::SetUParameter(double aUparam)
|
||||
{
|
||||
myUParameter = aUparam;
|
||||
myParameter[0] = aUparam;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetVParameter
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_FacePosition::SetVParameter(double aVparam)
|
||||
{
|
||||
myVParameter = aVparam;
|
||||
myParameter[1] = aVparam;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetUParameter
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
double SMDS_FacePosition::GetUParameter() const
|
||||
double SMDS_FacePosition::GetUParameter() const
|
||||
{
|
||||
return myUParameter;
|
||||
return myParameter[0];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetVParameter
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
double SMDS_FacePosition::GetVParameter() const
|
||||
double SMDS_FacePosition::GetVParameter() const
|
||||
{
|
||||
return myVParameter;
|
||||
return myParameter[1];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -92,6 +91,6 @@ double SMDS_FacePosition::GetVParameter() const
|
||||
|
||||
void SMDS_FacePosition::SetParameters(double aUparam, double aVparam)
|
||||
{
|
||||
myUParameter = aUparam;
|
||||
myVParameter = aVparam;
|
||||
myParameter[0] = aUparam;
|
||||
myParameter[1] = aVparam;
|
||||
}
|
||||
|
@ -33,18 +33,17 @@
|
||||
|
||||
class SMDS_EXPORT SMDS_FacePosition:public SMDS_Position
|
||||
{
|
||||
public:
|
||||
SMDS_FacePosition(double aUParam=0, double aVParam=0);
|
||||
SMDS_TypeOfPosition GetTypeOfPosition() const;
|
||||
virtual void SetUParameter(double aUparam);
|
||||
virtual void SetVParameter(double aVparam);
|
||||
virtual void SetParameters(double aUparam, double aVparam);
|
||||
virtual double GetUParameter() const;
|
||||
virtual double GetVParameter() const;
|
||||
virtual const double* GetParameters() const { return &myParameter[0]; }
|
||||
|
||||
public:
|
||||
SMDS_FacePosition(double aUParam=0, double aVParam=0);
|
||||
SMDS_TypeOfPosition GetTypeOfPosition() const;
|
||||
void SetUParameter(double aUparam);
|
||||
void SetVParameter(double aVparam);
|
||||
void SetParameters(double aUparam, double aVparam);
|
||||
double GetUParameter() const;
|
||||
double GetVParameter() const;
|
||||
|
||||
private:
|
||||
double myUParameter;
|
||||
double myVParameter;
|
||||
private:
|
||||
double myParameter[2];
|
||||
};
|
||||
#endif
|
||||
|
@ -25,27 +25,28 @@
|
||||
#ifndef _SMDS_Iterator_HeaderFile
|
||||
#define _SMDS_Iterator_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///Abstract class for iterators
|
||||
///@author Jerome Robert
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template<typename VALUE> class SMDS_Iterator
|
||||
{
|
||||
public:
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more()=0;
|
||||
public:
|
||||
|
||||
typedef VALUE value_type;
|
||||
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more()=0;
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual VALUE next()=0;
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual VALUE next()=0;
|
||||
/// Delete the current element and step to the next one
|
||||
virtual void remove(){}
|
||||
|
||||
/// Delete the current element and step to the next one
|
||||
virtual void remove(){}
|
||||
|
||||
/// Provide virtual destructor just for case if some derived iterator
|
||||
/// must have a destructor
|
||||
virtual ~SMDS_Iterator(){}
|
||||
/// Provide virtual destructor just for case if some derived iterator
|
||||
/// must have a destructor
|
||||
virtual ~SMDS_Iterator(){}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,109 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
|
||||
bool SMDS_IteratorOfElements::subMore()
|
||||
{
|
||||
if((t2Iterator.get()==NULL)||(!t2Iterator->more()))
|
||||
{
|
||||
if(t1Iterator->more())
|
||||
{
|
||||
t2Iterator=t1Iterator->next()->elementsIterator(myType);
|
||||
return subMore();
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
const SMDS_MeshElement * SMDS_IteratorOfElements::subNext()
|
||||
{
|
||||
if((t2Iterator.get()==NULL)||(!t2Iterator->more()))
|
||||
if(t1Iterator->more())
|
||||
t2Iterator=t1Iterator->next()->elementsIterator(myType);
|
||||
return t2Iterator->next();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which look for elements of type type which are linked
|
||||
/// to the element element. it is the iterator to get connectivity of element
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_IteratorOfElements::SMDS_IteratorOfElements(const SMDS_MeshElement * element,
|
||||
SMDSAbs_ElementType type,
|
||||
const SMDS_ElemIteratorPtr& it)
|
||||
: t1Iterator(it),
|
||||
t2Iterator(SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL)),
|
||||
myType(type), myElement(element),
|
||||
myProxyElement(NULL)
|
||||
{
|
||||
while(subMore())
|
||||
alreadyReturnedElements.insert(subNext());
|
||||
itAlreadyReturned= alreadyReturnedElements.begin();
|
||||
switch(myElement->GetType())
|
||||
{
|
||||
case SMDSAbs_Node:
|
||||
case SMDSAbs_Edge: myReverseIteration=true; break;
|
||||
case SMDSAbs_Face: myReverseIteration=(type==SMDSAbs_Volume); break;
|
||||
default: myReverseIteration=false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SMDS_IteratorOfElements::more()
|
||||
{
|
||||
if(myProxyElement==NULL)
|
||||
{
|
||||
while(itAlreadyReturned!=alreadyReturnedElements.end())
|
||||
{
|
||||
myProxyElement=*itAlreadyReturned;
|
||||
itAlreadyReturned++;
|
||||
|
||||
if(myReverseIteration)
|
||||
{
|
||||
SMDS_ElemIteratorPtr it=
|
||||
myProxyElement->elementsIterator(myElement->GetType());
|
||||
while(it->more())
|
||||
{
|
||||
if(it->next()==myElement) return true;
|
||||
}
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
myProxyElement=NULL;
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
const SMDS_MeshElement * SMDS_IteratorOfElements::next()
|
||||
{
|
||||
more();
|
||||
const SMDS_MeshElement *e=myProxyElement;
|
||||
myProxyElement=NULL;
|
||||
return e;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
//
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_Iterator.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include <set>
|
||||
|
||||
|
||||
class SMDS_EXPORT SMDS_IteratorOfElements:public SMDS_ElemIterator
|
||||
{
|
||||
public:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which look for elements of type type which are linked
|
||||
/// to the element element. it is the iterator to get connectivity of element
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_IteratorOfElements(const SMDS_MeshElement * element,
|
||||
SMDSAbs_ElementType type,
|
||||
const SMDS_ElemIteratorPtr& it);
|
||||
bool more();
|
||||
const SMDS_MeshElement * next();
|
||||
|
||||
private:
|
||||
SMDS_ElemIteratorPtr t1Iterator;
|
||||
SMDS_ElemIteratorPtr t2Iterator;
|
||||
SMDSAbs_ElementType myType;
|
||||
const SMDS_MeshElement * myElement;
|
||||
const SMDS_MeshElement * myProxyElement;
|
||||
bool myReverseIteration;
|
||||
|
||||
std::set<const SMDS_MeshElement*> alreadyReturnedElements;
|
||||
std::set<const SMDS_MeshElement*>::iterator itAlreadyReturned;
|
||||
bool subMore();
|
||||
const SMDS_MeshElement * subNext();
|
||||
};
|
@ -28,11 +28,10 @@
|
||||
#endif
|
||||
|
||||
#include "SMDS_LinearEdge.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "utilities.h"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
|
||||
using namespace std;
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_LinearEdge
|
||||
@ -42,22 +41,10 @@ using namespace std;
|
||||
SMDS_LinearEdge::SMDS_LinearEdge(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2)
|
||||
{
|
||||
//MESSAGE("SMDS_LinearEdge " << GetID());
|
||||
myNodes[0] = node1;
|
||||
myNodes[1] = node2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_LinearEdge::Print(ostream & OS) const
|
||||
{
|
||||
OS << "edge <" << GetID() << "> : (" << myNodes[0] << " , " << myNodes[1]
|
||||
<< ") " << endl;
|
||||
}
|
||||
|
||||
int SMDS_LinearEdge::NbNodes() const
|
||||
{
|
||||
return 2;
|
||||
@ -68,75 +55,29 @@ int SMDS_LinearEdge::NbEdges() const
|
||||
return 1;
|
||||
}
|
||||
|
||||
class SMDS_LinearEdge_MyNodeIterator: public SMDS_ElemIterator
|
||||
int SMDS_LinearEdge::NbFaces() const
|
||||
{
|
||||
const SMDS_MeshNode * const * myNodes;
|
||||
int myIndex;
|
||||
public:
|
||||
SMDS_LinearEdge_MyNodeIterator(const SMDS_MeshNode * const * nodes) :
|
||||
myNodes(nodes), myIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool more()
|
||||
{
|
||||
return myIndex < 2;
|
||||
}
|
||||
|
||||
const SMDS_MeshElement* next()
|
||||
{
|
||||
myIndex++;
|
||||
return myNodes[myIndex - 1];
|
||||
}
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_LinearEdge::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_LinearEdge_MyNodeIterator(myNodes));
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements(this,
|
||||
type,
|
||||
SMDS_ElemIteratorPtr
|
||||
(new SMDS_LinearEdge_MyNodeIterator(myNodes))));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool operator<(const SMDS_LinearEdge & e1, const SMDS_LinearEdge & e2)
|
||||
int SMDS_LinearEdge::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
int id11 = e1.myNodes[0]->getVtkId();
|
||||
int id21 = e2.myNodes[0]->getVtkId();
|
||||
int id12 = e1.myNodes[1]->getVtkId();
|
||||
int id22 = e2.myNodes[1]->getVtkId();
|
||||
int tmp;
|
||||
|
||||
if (id11 >= id12)
|
||||
{
|
||||
tmp = id11;
|
||||
id11 = id12;
|
||||
id12 = tmp;
|
||||
}
|
||||
if (id21 >= id22)
|
||||
{
|
||||
tmp = id21;
|
||||
id21 = id22;
|
||||
id22 = tmp;
|
||||
}
|
||||
|
||||
if (id11 < id21)
|
||||
return true;
|
||||
else if (id11 == id21)
|
||||
return (id21 < id22);
|
||||
else
|
||||
return false;
|
||||
if ( node == myNodes[0] ) return 0;
|
||||
if ( node == myNodes[1] ) return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
SMDS_ElemIteratorPtr SMDS_LinearEdge::nodesIterator() const
|
||||
{
|
||||
return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_LinearEdge::nodeIterator() const
|
||||
{
|
||||
return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
@ -151,10 +92,9 @@ const SMDS_MeshNode* SMDS_LinearEdge::GetNode(const int ind) const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_LinearEdge::ChangeNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2)
|
||||
bool SMDS_LinearEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
myNodes[0] = node1;
|
||||
myNodes[1] = node2;
|
||||
return true;
|
||||
myNodes[0] = nodes[0];
|
||||
myNodes[1] = nodes[1];
|
||||
return nbNodes == 2;
|
||||
}
|
||||
|
@ -27,42 +27,34 @@
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshEdge.hxx"
|
||||
#include <iostream>
|
||||
#include "SMDS_CellOfNodes.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_LinearEdge: public SMDS_MeshEdge
|
||||
class SMDS_EXPORT SMDS_LinearEdge: public SMDS_CellOfNodes
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_LinearEdge(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
|
||||
bool ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
|
||||
void Print(std::ostream & OS) const;
|
||||
|
||||
virtual SMDSAbs_EntityType GetEntityType() const
|
||||
{
|
||||
return SMDSEntity_Edge;
|
||||
}
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int NbNodes() const;
|
||||
int NbEdges() const;
|
||||
friend bool operator<(const SMDS_LinearEdge& e1, const SMDS_LinearEdge& e2);
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Edge; }
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_EDGE; }
|
||||
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Edge; }
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
|
||||
virtual int NbCornerNodes() const { return NbNodes(); }
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
|
||||
virtual bool IsPoly() const { return false; }
|
||||
virtual bool IsQuadratic() const { return false; }
|
||||
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
|
||||
/*!
|
||||
* \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* myNodes[3];
|
||||
const SMDS_MeshNode* myNodes[2];
|
||||
|
||||
};
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,62 +29,46 @@
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
#include "SMDS_BallElement.hxx"
|
||||
#include "SMDS_ElemIterator.hxx"
|
||||
#include "SMDS_Mesh0DElement.hxx"
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
#include "SMDS_MeshEdge.hxx"
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_MeshNodeIDFactory.hxx"
|
||||
#include "SMDS_MeshElementIDFactory.hxx"
|
||||
#include "SMDS_MeshInfo.hxx"
|
||||
#include "SMDS_ElemIterator.hxx"
|
||||
#include "SMDS_VolumeOfNodes.hxx"
|
||||
#include "SMDS_VtkEdge.hxx"
|
||||
#include "SMDS_VtkFace.hxx"
|
||||
#include "SMDS_VtkVolume.hxx"
|
||||
#include "ObjectPool.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_UnstructuredGrid.hxx"
|
||||
#include "SMDS_BallElement.hxx"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <vtkSystemIncludes.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
#define MYASSERT(val) if (!(val)) throw SALOME_Exception(LOCALIZED("assertion not verified"));
|
||||
class SMDS_ElementHolder;
|
||||
class SMDS_ElementFactory;
|
||||
class SMDS_NodeFactory;
|
||||
|
||||
class SMDS_EXPORT SMDS_Mesh : public SMDS_MeshObject
|
||||
{
|
||||
public:
|
||||
friend class SMDS_MeshIDFactory;
|
||||
friend class SMDS_MeshNodeIDFactory;
|
||||
friend class SMDS_MeshElementIDFactory;
|
||||
friend class SMDS_MeshVolumeVtkNodes;
|
||||
friend class SMDS_MeshNode;
|
||||
|
||||
SMDS_Mesh();
|
||||
|
||||
//! to retrieve this SMDS_Mesh instance from its elements (index stored in SMDS_Elements)
|
||||
static std::vector<SMDS_Mesh*> _meshList;
|
||||
|
||||
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
|
||||
inline SMDS_UnstructuredGrid* getGrid() { return myGrid; }
|
||||
inline int getMeshId() { return myMeshId; }
|
||||
inline SMDS_UnstructuredGrid* GetGrid() { return myGrid; }
|
||||
|
||||
virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const;
|
||||
virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const;
|
||||
virtual SMDS_FaceIteratorPtr facesIterator (bool idInceasingOrder=false) const;
|
||||
virtual SMDS_VolumeIteratorPtr volumesIterator (bool idInceasingOrder=false) const;
|
||||
virtual SMDS_NodeIteratorPtr nodesIterator () const;
|
||||
virtual SMDS_EdgeIteratorPtr edgesIterator () const;
|
||||
virtual SMDS_FaceIteratorPtr facesIterator () const;
|
||||
virtual SMDS_VolumeIteratorPtr volumesIterator() const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
|
||||
virtual SMDS_ElemIteratorPtr elementGeomIterator(SMDSAbs_GeometryType type) const;
|
||||
virtual SMDS_ElemIteratorPtr elementEntityIterator(SMDSAbs_EntityType type) const;
|
||||
|
||||
virtual SMDS_NodeIteratorPtr shapeNodesIterator (int shapeID, size_t nbElemsToReturn=-1) const;
|
||||
virtual SMDS_ElemIteratorPtr shapeElementsIterator(int shapeID, size_t nbElemsToReturn=-1) const;
|
||||
|
||||
SMDSAbs_ElementType GetElementType( const int id, const bool iselem ) const;
|
||||
|
||||
SMDS_Mesh *AddSubMesh();
|
||||
@ -137,21 +121,6 @@ public:
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4);
|
||||
|
||||
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
|
||||
const SMDS_MeshEdge * e2,
|
||||
const SMDS_MeshEdge * e3, int ID);
|
||||
virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
|
||||
const SMDS_MeshEdge * e2,
|
||||
const SMDS_MeshEdge * e3);
|
||||
|
||||
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
|
||||
const SMDS_MeshEdge * e2,
|
||||
const SMDS_MeshEdge * e3,
|
||||
const SMDS_MeshEdge * e4, int ID);
|
||||
virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
|
||||
const SMDS_MeshEdge * e2,
|
||||
const SMDS_MeshEdge * e3,
|
||||
const SMDS_MeshEdge * e4);
|
||||
|
||||
// 2d order triangle of 6 nodes
|
||||
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
|
||||
@ -293,38 +262,6 @@ public:
|
||||
const SMDS_MeshNode * n7,
|
||||
const SMDS_MeshNode * n8);
|
||||
|
||||
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
|
||||
const SMDS_MeshFace * f2,
|
||||
const SMDS_MeshFace * f3,
|
||||
const SMDS_MeshFace * f4, int ID);
|
||||
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
|
||||
const SMDS_MeshFace * f2,
|
||||
const SMDS_MeshFace * f3,
|
||||
const SMDS_MeshFace * f4);
|
||||
|
||||
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
|
||||
const SMDS_MeshFace * f2,
|
||||
const SMDS_MeshFace * f3,
|
||||
const SMDS_MeshFace * f4,
|
||||
const SMDS_MeshFace * f5, int ID);
|
||||
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
|
||||
const SMDS_MeshFace * f2,
|
||||
const SMDS_MeshFace * f3,
|
||||
const SMDS_MeshFace * f4,
|
||||
const SMDS_MeshFace * f5);
|
||||
|
||||
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
|
||||
const SMDS_MeshFace * f2,
|
||||
const SMDS_MeshFace * f3,
|
||||
const SMDS_MeshFace * f4,
|
||||
const SMDS_MeshFace * f5,
|
||||
const SMDS_MeshFace * f6, int ID);
|
||||
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
|
||||
const SMDS_MeshFace * f2,
|
||||
const SMDS_MeshFace * f3,
|
||||
const SMDS_MeshFace * f4,
|
||||
const SMDS_MeshFace * f5,
|
||||
const SMDS_MeshFace * f6);
|
||||
|
||||
// hexagonal prism
|
||||
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6,
|
||||
@ -639,33 +576,24 @@ public:
|
||||
virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
|
||||
(const std::vector<const SMDS_MeshNode*> & nodes,
|
||||
const std::vector<int> & quantities,
|
||||
const int ID);
|
||||
const int ID);
|
||||
|
||||
virtual SMDS_MeshVolume* AddPolyhedralVolume
|
||||
(const std::vector<const SMDS_MeshNode*> & nodes,
|
||||
const std::vector<int> & quantities);
|
||||
(const std::vector<const SMDS_MeshNode*> & nodes,
|
||||
const std::vector<int> & quantities);
|
||||
|
||||
virtual SMDS_MeshVolume* AddVolumeFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
|
||||
|
||||
virtual SMDS_MeshVolume* AddVolumeFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
|
||||
const int ID);
|
||||
|
||||
virtual SMDS_MeshFace* AddFaceFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
|
||||
|
||||
virtual SMDS_MeshFace* AddFaceFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
|
||||
const int ID);
|
||||
virtual void MoveNode(const SMDS_MeshNode *n, double x, double y, double z);
|
||||
|
||||
virtual void RemoveElement(const SMDS_MeshElement * elem,
|
||||
std::list<const SMDS_MeshElement *>& removedElems,
|
||||
std::list<const SMDS_MeshElement *>& removedNodes,
|
||||
const bool removenodes = false);
|
||||
virtual void RemoveElement(const SMDS_MeshElement * elem,
|
||||
std::vector<const SMDS_MeshElement *>& removedElems,
|
||||
std::vector<const SMDS_MeshElement *>& removedNodes,
|
||||
const bool removenodes = false);
|
||||
virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
|
||||
virtual void RemoveNode(const SMDS_MeshNode * node);
|
||||
virtual void Remove0DElement(const SMDS_Mesh0DElement * elem0d);
|
||||
virtual void RemoveEdge(const SMDS_MeshEdge * edge);
|
||||
virtual void RemoveFace(const SMDS_MeshFace * face);
|
||||
virtual void RemoveVolume(const SMDS_MeshVolume * volume);
|
||||
|
||||
/*! Remove only the given element and only if it is free.
|
||||
* Method does not work for meshes with descendants.
|
||||
@ -681,27 +609,23 @@ public:
|
||||
bool ChangeElementNodes(const SMDS_MeshElement * elem,
|
||||
const SMDS_MeshNode * nodes[],
|
||||
const int nbnodes);
|
||||
bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
|
||||
const std::vector<const SMDS_MeshNode*>& nodes,
|
||||
const std::vector<int> & quantities);
|
||||
|
||||
virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
|
||||
//virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
|
||||
// Renumber all nodes or elements.
|
||||
virtual void compactMesh();
|
||||
virtual void CompactMesh() { compactMesh(); }
|
||||
|
||||
virtual void CompactMesh();
|
||||
bool IsCompacted();
|
||||
|
||||
template<class ELEMTYPE>
|
||||
static const ELEMTYPE* DownCast( const SMDS_MeshElement* e )
|
||||
{
|
||||
return (( e && !e->IsNull() && ELEMTYPE::Type() == e->GetType() ) ?
|
||||
static_cast<const ELEMTYPE*>(e) : 0 );
|
||||
}
|
||||
|
||||
const SMDS_MeshNode *FindNode(int idnode) const;
|
||||
const SMDS_MeshNode *FindNodeVtk(int idnode) const;
|
||||
const SMDS_Mesh0DElement* Find0DElement(int idnode) const;
|
||||
const SMDS_BallElement* FindBall(int idnode) const;
|
||||
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) 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, int idnode4) const;
|
||||
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
|
||||
int idnode4, int idnode5, int idnode6) const;
|
||||
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
|
||||
int idnode5, int idnode6, int idnode7, int idnode8) const;
|
||||
const SMDS_MeshElement *FindElementVtk(int IDelem) const;
|
||||
virtual const SMDS_MeshElement * FindElement(int IDelem) const;
|
||||
static const SMDS_Mesh0DElement* Find0DElement(const SMDS_MeshNode * n);
|
||||
static const SMDS_BallElement* FindBall(const SMDS_MeshNode * n);
|
||||
@ -732,8 +656,7 @@ public:
|
||||
const SMDS_MeshNode *n7,
|
||||
const SMDS_MeshNode *n8);
|
||||
|
||||
const SMDS_MeshFace *FindFace(const std::vector<int>& nodes_ids) const;
|
||||
static const SMDS_MeshFace* FindFace(const std::vector<const SMDS_MeshNode *>& nodes);
|
||||
static const SMDS_MeshFace* FindFace (const std::vector<const SMDS_MeshNode *>& nodes);
|
||||
static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
|
||||
const SMDSAbs_ElementType type=SMDSAbs_All,
|
||||
const bool noMedium=true);
|
||||
@ -741,6 +664,8 @@ public:
|
||||
std::vector<const SMDS_MeshElement *>& foundElems,
|
||||
const SMDSAbs_ElementType type=SMDSAbs_All);
|
||||
|
||||
virtual bool Contains( const SMDS_MeshElement* elem ) const;
|
||||
|
||||
/*!
|
||||
* \brief Raise an exception if free memory (ram+swap) too low
|
||||
* \param doNotRaise - if true, suppres exception, just return free memory size
|
||||
@ -764,36 +689,10 @@ public:
|
||||
virtual int NbVolumes() const;
|
||||
virtual int NbSubMesh() const;
|
||||
|
||||
void DumpNodes() const;
|
||||
void Dump0DElements() const;
|
||||
void DumpEdges() const;
|
||||
void DumpFaces() const;
|
||||
void DumpVolumes() const;
|
||||
void DebugStats() const;
|
||||
|
||||
virtual ~SMDS_Mesh();
|
||||
|
||||
bool hasConstructionEdges();
|
||||
bool hasConstructionFaces();
|
||||
bool hasInverseElements();
|
||||
void setConstructionEdges(bool);
|
||||
void setConstructionFaces(bool);
|
||||
void setInverseElements(bool);
|
||||
|
||||
/*!
|
||||
* Checks if the element is present in mesh.
|
||||
* Useful to determine dead pointers.
|
||||
* Use this function for debug purpose only! Do not check in the code
|
||||
* using it even in _DEBUG_ mode
|
||||
*/
|
||||
bool Contains (const SMDS_MeshElement* elem) const;
|
||||
|
||||
typedef std::vector<SMDS_MeshNode *> SetOfNodes;
|
||||
typedef std::vector<SMDS_MeshCell *> SetOfCells;
|
||||
|
||||
//void updateBoundingBox();
|
||||
double getMaxDim();
|
||||
int fromVtkToSmds(int vtkid);
|
||||
int FromVtkToSmds(int vtkid) const;
|
||||
|
||||
void dumpGrid(std::string ficdump="dumpGrid");
|
||||
static int chunkSize;
|
||||
@ -803,44 +702,14 @@ public:
|
||||
|
||||
void Modified();
|
||||
vtkMTimeType GetMTime() const;
|
||||
bool isCompacted();
|
||||
|
||||
protected:
|
||||
SMDS_Mesh(SMDS_Mesh * parent);
|
||||
|
||||
SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
int ID);
|
||||
SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
int ID);
|
||||
SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2);
|
||||
SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
|
||||
const SMDS_MeshNode *n2,
|
||||
const SMDS_MeshNode *n3);
|
||||
SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
|
||||
const SMDS_MeshNode *n2,
|
||||
const SMDS_MeshNode *n3,
|
||||
const SMDS_MeshNode *n4);
|
||||
|
||||
bool registerElement(int ID, SMDS_MeshElement * element);
|
||||
|
||||
void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
|
||||
const SMDS_MeshElement * element,
|
||||
std::set<const SMDS_MeshElement*>& nodes);
|
||||
|
||||
inline void adjustmyCellsCapacity(int ID)
|
||||
{
|
||||
assert(ID >= 0);
|
||||
myElementIDFactory->adjustMaxId(ID);
|
||||
if (ID >= (int)myCells.size())
|
||||
myCells.resize(ID+SMDS_Mesh::chunkSize,0);
|
||||
}
|
||||
|
||||
inline void adjustBoundingBox(double x, double y, double z)
|
||||
{
|
||||
if (x > xmax) xmax = x;
|
||||
@ -851,47 +720,29 @@ protected:
|
||||
else if (z < zmin) zmin = z;
|
||||
}
|
||||
|
||||
void setNbShapes( size_t nbShapes );
|
||||
|
||||
|
||||
// Fields PRIVATE
|
||||
|
||||
//! index of this SMDS_mesh in the static vector<SMDS_Mesh*> _meshList
|
||||
int myMeshId;
|
||||
|
||||
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
|
||||
SMDS_UnstructuredGrid* myGrid;
|
||||
SMDS_UnstructuredGrid* myGrid;
|
||||
|
||||
//! Small objects like SMDS_MeshNode are allocated by chunks to limit memory costs of new
|
||||
ObjectPool<SMDS_MeshNode>* myNodePool;
|
||||
SMDS_NodeFactory* myNodeFactory;
|
||||
SMDS_ElementFactory* myCellFactory;
|
||||
|
||||
//! Small objects like SMDS_VtkVolume are allocated by chunks to limit memory costs of new
|
||||
ObjectPool<SMDS_VtkVolume>* myVolumePool;
|
||||
ObjectPool<SMDS_VtkFace>* myFacePool;
|
||||
ObjectPool<SMDS_VtkEdge>* myEdgePool;
|
||||
ObjectPool<SMDS_BallElement>* myBallPool;
|
||||
|
||||
//! SMDS_MeshNodes refer to vtk nodes (vtk id != index in myNodes),store reference to this mesh, and sub-shape
|
||||
SetOfNodes myNodes;
|
||||
SetOfCells myCells;
|
||||
|
||||
//! a buffer to speed up elements addition by excluding some memory allocation
|
||||
std::vector<vtkIdType> myNodeIds;
|
||||
|
||||
//! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
|
||||
std::vector<int> myCellIdVtkToSmds;
|
||||
|
||||
SMDS_Mesh * myParent;
|
||||
std::list<SMDS_Mesh *> myChildren;
|
||||
SMDS_MeshNodeIDFactory * myNodeIDFactory;
|
||||
SMDS_MeshElementIDFactory * myElementIDFactory;
|
||||
SMDS_MeshInfo myInfo;
|
||||
SMDS_Mesh * myParent;
|
||||
std::list<SMDS_Mesh *> myChildren;
|
||||
SMDS_MeshInfo myInfo;
|
||||
|
||||
//! any add, remove or change of node or cell
|
||||
bool myModified;
|
||||
bool myModified;
|
||||
//! use a counter to keep track of modifications
|
||||
unsigned long myModifTime, myCompactTime;
|
||||
unsigned long myModifTime, myCompactTime;
|
||||
|
||||
bool myHasConstructionEdges;
|
||||
bool myHasConstructionFaces;
|
||||
bool myHasInverseElements;
|
||||
friend class SMDS_ElementHolder;
|
||||
std::set< SMDS_ElementHolder* > myElemHolders;
|
||||
|
||||
double xmin;
|
||||
double xmax;
|
||||
|
@ -1,164 +0,0 @@
|
||||
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_Mesh0DElement.cxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_Mesh0DElement.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
vtkIdType SMDS_Mesh0DElement::GetVtkType() const
|
||||
{
|
||||
return VTK_VERTEX;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//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))));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \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::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
if ( nbNodes == 1 )
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
if (nbNodes != npts)
|
||||
{
|
||||
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
|
||||
return false;
|
||||
}
|
||||
myNode = nodes[0];
|
||||
pts[0] = myNode->getVtkId();
|
||||
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -28,28 +28,15 @@
|
||||
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*!
|
||||
* \brief 0D mesh element. This type is not allocated.
|
||||
* It is only used as function argument type to provide more clear semantic.
|
||||
*/
|
||||
class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshCell
|
||||
{
|
||||
public:
|
||||
SMDS_Mesh0DElement (const SMDS_MeshNode * node);
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
virtual void Print (std::ostream & OS) const;
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_0D;}
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_POINT; }
|
||||
virtual const SMDS_MeshNode* GetNode (const int ind) const;
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
|
||||
protected:
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
|
||||
|
||||
protected:
|
||||
const SMDS_MeshNode* myNode;
|
||||
static SMDSAbs_ElementType Type() { return SMDSAbs_0DElement; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -18,21 +18,383 @@
|
||||
//
|
||||
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
int SMDS_MeshCell::nbCells = 0;
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
|
||||
SMDS_MeshCell::SMDS_MeshCell() :
|
||||
SMDS_MeshElement(-1)
|
||||
#include <utilities.h>
|
||||
|
||||
#include <vtkCell.h>
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
nbCells++;
|
||||
myVtkID = -1;
|
||||
/*!
|
||||
* \brief Cell type features
|
||||
*/
|
||||
struct CellProps
|
||||
{
|
||||
SMDSAbs_EntityType myEntity;
|
||||
SMDSAbs_ElementType myType;
|
||||
SMDSAbs_GeometryType myGeom;
|
||||
bool myIsPoly;
|
||||
int myNbCornerNodes;
|
||||
int myNbNodes;
|
||||
int myNbEdges;
|
||||
int myNbFaces;
|
||||
|
||||
CellProps() :
|
||||
myEntity( SMDSEntity_Last ), myType( SMDSAbs_All ), myGeom( SMDSGeom_NONE ),
|
||||
myIsPoly( 0 ), myNbCornerNodes( 0 ),
|
||||
myNbNodes( 0 ), myNbEdges( 0 ), myNbFaces ( 0 )
|
||||
{
|
||||
}
|
||||
void Set( SMDSAbs_EntityType Entity,
|
||||
SMDSAbs_ElementType Type,
|
||||
SMDSAbs_GeometryType Geom,
|
||||
bool IsPoly,
|
||||
int NbCornerNodes,
|
||||
int NbNodes,
|
||||
int NbEdges,
|
||||
int NbFaces)
|
||||
{
|
||||
myEntity = Entity;
|
||||
myType = Type;
|
||||
myGeom = Geom;
|
||||
myIsPoly = IsPoly;
|
||||
myNbCornerNodes = NbCornerNodes;
|
||||
myNbNodes = NbNodes;
|
||||
myNbEdges = NbEdges;
|
||||
myNbFaces = NbFaces;
|
||||
}
|
||||
bool IsQuadratic() const { return myNbNodes > myNbCornerNodes; }
|
||||
};
|
||||
|
||||
//! return vector a CellProps
|
||||
const CellProps& getCellProps( VTKCellType vtkType )
|
||||
{
|
||||
static std::vector< CellProps > theCellProps;
|
||||
if ( theCellProps.empty() )
|
||||
{
|
||||
theCellProps.resize( VTK_NUMBER_OF_CELL_TYPES );
|
||||
CellProps* p = & theCellProps[0];
|
||||
p[ VTK_VERTEX ].
|
||||
Set( SMDSEntity_0D, SMDSAbs_0DElement, SMDSGeom_POINT,
|
||||
/*isPoly=*/0,/*nbCN=*/1,/*nbN=*/1,/*nbE=*/0,/*nbF=*/0 );
|
||||
p[ VTK_LINE ].
|
||||
Set( SMDSEntity_Edge, SMDSAbs_Edge, SMDSGeom_EDGE,
|
||||
/*isPoly=*/0,/*nbCN=*/2,/*nbN=*/2,/*nbE=*/1,/*nbF=*/0 );
|
||||
p[ VTK_QUADRATIC_EDGE ].
|
||||
Set( SMDSEntity_Quad_Edge, SMDSAbs_Edge, SMDSGeom_EDGE,
|
||||
/*isPoly=*/0,/*nbCN=*/2,/*nbN=*/3,/*nbE=*/1,/*nbF=*/0 );
|
||||
p[ VTK_TRIANGLE ].
|
||||
Set( SMDSEntity_Triangle, SMDSAbs_Face, SMDSGeom_TRIANGLE,
|
||||
/*isPoly=*/0,/*nbCN=*/3,/*nbN=*/3,/*nbE=*/3,/*nbF=*/1 );
|
||||
p[ VTK_QUADRATIC_TRIANGLE ].
|
||||
Set( SMDSEntity_Quad_Triangle, SMDSAbs_Face, SMDSGeom_TRIANGLE,
|
||||
/*isPoly=*/0,/*nbCN=*/3,/*nbN=*/6,/*nbE=*/3,/*nbF=*/1 );
|
||||
p[ VTK_BIQUADRATIC_TRIANGLE ].
|
||||
Set( SMDSEntity_BiQuad_Triangle, SMDSAbs_Face, SMDSGeom_TRIANGLE,
|
||||
/*isPoly=*/0,/*nbCN=*/3,/*nbN=*/7,/*nbE=*/3,/*nbF=*/1 );
|
||||
p[ VTK_QUAD].
|
||||
Set( SMDSEntity_Quadrangle, SMDSAbs_Face, SMDSGeom_QUADRANGLE,
|
||||
/*isPoly=*/0,/*nbCN=*/4,/*nbN=*/4,/*nbE=*/4,/*nbF=*/1 );
|
||||
p[ VTK_QUADRATIC_QUAD].
|
||||
Set( SMDSEntity_Quad_Quadrangle, SMDSAbs_Face, SMDSGeom_QUADRANGLE,
|
||||
/*isPoly=*/0,/*nbCN=*/4,/*nbN=*/8,/*nbE=*/4,/*nbF=*/1 );
|
||||
p[ VTK_BIQUADRATIC_QUAD].
|
||||
Set( SMDSEntity_BiQuad_Quadrangle, SMDSAbs_Face, SMDSGeom_QUADRANGLE,
|
||||
/*isPoly=*/0,/*nbCN=*/4,/*nbN=*/9,/*nbE=*/4,/*nbF=*/1 );
|
||||
p[ VTK_POLYGON ].
|
||||
Set( SMDSEntity_Polygon, SMDSAbs_Face, SMDSGeom_POLYGON,
|
||||
/*isPoly=*/1,/*nbCN=*/-1,/*nbN=*/-1,/*nbE=*/-1,/*nbF=*/1 );
|
||||
p[ VTK_QUADRATIC_POLYGON ].
|
||||
Set( SMDSEntity_Quad_Polygon, SMDSAbs_Face, SMDSGeom_POLYGON,
|
||||
/*isPoly=*/1,/*nbCN=*/-2,/*nbN=*/-1,/*nbE=*/-1,/*nbF=*/1 );
|
||||
p[ VTK_TETRA ].
|
||||
Set( SMDSEntity_Tetra, SMDSAbs_Volume, SMDSGeom_TETRA,
|
||||
/*isPoly=*/0,/*nbCN=*/4,/*nbN=*/4,/*nbE=*/6,/*nbF=*/4 );
|
||||
p[ VTK_QUADRATIC_TETRA ].
|
||||
Set( SMDSEntity_Quad_Tetra, SMDSAbs_Volume, SMDSGeom_TETRA,
|
||||
/*isPoly=*/0,/*nbCN=*/4,/*nbN=*/10,/*nbE=*/6,/*nbF=*/4 );
|
||||
p[ VTK_PYRAMID ].
|
||||
Set( SMDSEntity_Pyramid, SMDSAbs_Volume, SMDSGeom_PYRAMID,
|
||||
/*isPoly=*/0,/*nbCN=*/5,/*nbN=*/5,/*nbE=*/8,/*nbF=*/5 );
|
||||
p[ VTK_QUADRATIC_PYRAMID].
|
||||
Set( SMDSEntity_Quad_Pyramid, SMDSAbs_Volume, SMDSGeom_PYRAMID,
|
||||
/*isPoly=*/0,/*nbCN=*/5,/*nbN=*/13,/*nbE=*/8,/*nbF=*/5 );
|
||||
p[ VTK_HEXAHEDRON ].
|
||||
Set( SMDSEntity_Hexa, SMDSAbs_Volume, SMDSGeom_HEXA,
|
||||
/*isPoly=*/0,/*nbCN=*/8,/*nbN=*/8,/*nbE=*/12,/*nbF=*/6 );
|
||||
p[ VTK_QUADRATIC_HEXAHEDRON ].
|
||||
Set( SMDSEntity_Quad_Hexa, SMDSAbs_Volume, SMDSGeom_HEXA,
|
||||
/*isPoly=*/0,/*nbCN=*/8,/*nbN=*/20,/*nbE=*/12,/*nbF=*/6 );
|
||||
p[ VTK_TRIQUADRATIC_HEXAHEDRON ].
|
||||
Set( SMDSEntity_TriQuad_Hexa, SMDSAbs_Volume, SMDSGeom_HEXA,
|
||||
/*isPoly=*/0,/*nbCN=*/8,/*nbN=*/27,/*nbE=*/12,/*nbF=*/6 );
|
||||
p[ VTK_WEDGE ].
|
||||
Set( SMDSEntity_Penta, SMDSAbs_Volume, SMDSGeom_PENTA,
|
||||
/*isPoly=*/0,/*nbCN=*/6,/*nbN=*/6,/*nbE=*/9,/*nbF=*/5 );
|
||||
p[ VTK_QUADRATIC_WEDGE ].
|
||||
Set( SMDSEntity_Quad_Penta, SMDSAbs_Volume, SMDSGeom_PENTA,
|
||||
/*isPoly=*/0,/*nbCN=*/6,/*nbN=*/15,/*nbE=*/9,/*nbF=*/5 );
|
||||
p[ VTK_BIQUADRATIC_QUADRATIC_WEDGE ].
|
||||
Set( SMDSEntity_BiQuad_Penta, SMDSAbs_Volume, SMDSGeom_PENTA,
|
||||
/*isPoly=*/0,/*nbCN=*/6,/*nbN=*/21,/*nbE=*/9,/*nbF=*/5 );
|
||||
p[ VTK_HEXAGONAL_PRISM].
|
||||
Set( SMDSEntity_Hexagonal_Prism, SMDSAbs_Volume, SMDSGeom_HEXAGONAL_PRISM,
|
||||
/*isPoly=*/0,/*nbCN=*/12,/*nbN=*/12,/*nbE=*/18,/*nbF=*/8 );
|
||||
p[ VTK_POLYHEDRON ].
|
||||
Set( SMDSEntity_Polyhedra, SMDSAbs_Volume, SMDSGeom_POLYHEDRA,
|
||||
/*isPoly=*/1,/*nbCN=*/-1,/*nbN=*/-1,/*nbE=*/-1,/*nbF=*/-1 );
|
||||
p[ VTK_POLY_VERTEX].
|
||||
Set( SMDSEntity_Ball, SMDSAbs_Ball, SMDSGeom_BALL,
|
||||
/*isPoly=*/0,/*nbCN=*/1,/*nbN=*/1,/*nbE=*/0,/*nbF=*/0 );
|
||||
}
|
||||
return theCellProps[ vtkType ];
|
||||
|
||||
} // getCellProps()
|
||||
|
||||
//! return vector a CellProps
|
||||
const CellProps& getCellProps( SMDSAbs_EntityType entity )
|
||||
{
|
||||
return getCellProps( SMDS_MeshCell::toVtkType( entity ));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void SMDS_MeshCell::InitStaticMembers()
|
||||
{
|
||||
getCellProps( SMDSEntity_Ball );
|
||||
toVtkOrder( SMDSEntity_Ball );
|
||||
reverseSmdsOrder( SMDSEntity_Ball, 1 );
|
||||
interlacedSmdsOrder( SMDSEntity_Ball, 1 );
|
||||
fromVtkOrder( SMDSEntity_Ball );
|
||||
}
|
||||
|
||||
SMDS_MeshCell::~SMDS_MeshCell()
|
||||
void SMDS_MeshCell::init( SMDSAbs_EntityType theEntity, int theNbNodes, ... )
|
||||
{
|
||||
nbCells--;
|
||||
ASSERT( getCellProps( theEntity ).myNbNodes == theNbNodes ||
|
||||
getCellProps( theEntity ).myIsPoly);
|
||||
|
||||
va_list vl;
|
||||
va_start( vl, theNbNodes );
|
||||
|
||||
vtkIdType vtkIds[ VTK_CELL_SIZE ];
|
||||
typedef const SMDS_MeshNode* node_t;
|
||||
|
||||
const std::vector<int>& interlace = toVtkOrder( theEntity );
|
||||
if ((int) interlace.size() == theNbNodes )
|
||||
{
|
||||
const SMDS_MeshNode* nodes[ VTK_CELL_SIZE ];
|
||||
for ( int i = 0; i < theNbNodes; i++ )
|
||||
nodes[i] = va_arg( vl, node_t );
|
||||
|
||||
for ( int i = 0; i < theNbNodes; i++ )
|
||||
vtkIds[i] = nodes[ interlace[i] ]->GetVtkID();
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < theNbNodes; i++ )
|
||||
vtkIds[i] = va_arg( vl, node_t )->GetVtkID();
|
||||
}
|
||||
va_end( vl );
|
||||
|
||||
int vtkType = toVtkType( theEntity );
|
||||
int vtkID = getGrid()->InsertNextLinkedCell( vtkType, theNbNodes, vtkIds );
|
||||
setVtkID( vtkID );
|
||||
}
|
||||
|
||||
void SMDS_MeshCell::init( SMDSAbs_EntityType theEntity,
|
||||
const std::vector<const SMDS_MeshNode*>& nodes )
|
||||
{
|
||||
std::vector< vtkIdType > vtkIds( nodes.size() );
|
||||
for ( size_t i = 0; i < nodes.size(); ++i )
|
||||
vtkIds[i] = nodes[i]->GetVtkID();
|
||||
|
||||
int vtkType = toVtkType( theEntity );
|
||||
int vtkID = getGrid()->InsertNextLinkedCell( vtkType, nodes.size(), &vtkIds[0] );
|
||||
setVtkID( vtkID );
|
||||
}
|
||||
|
||||
void SMDS_MeshCell::init( SMDSAbs_EntityType theEntity,
|
||||
const std::vector<vtkIdType>& vtkNodeIds )
|
||||
{
|
||||
int vtkType = toVtkType( theEntity );
|
||||
int vtkID = getGrid()->InsertNextLinkedCell( vtkType, vtkNodeIds.size(),
|
||||
const_cast< vtkIdType* > ( &vtkNodeIds[0] ));
|
||||
setVtkID( vtkID );
|
||||
}
|
||||
|
||||
bool SMDS_MeshCell::ChangeNodes(const SMDS_MeshNode* nodes[], const int theNbNodes)
|
||||
{
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
getGrid()->GetCellPoints( GetVtkID(), npts, pts );
|
||||
if ( theNbNodes != npts )
|
||||
{
|
||||
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << theNbNodes);
|
||||
return false;
|
||||
}
|
||||
const std::vector<int>& interlace = toVtkOrder((VTKCellType) GetVtkType() );
|
||||
if ((int) interlace.size() != theNbNodes )
|
||||
for ( int i = 0; i < theNbNodes; i++ )
|
||||
{
|
||||
pts[i] = nodes[i]->GetVtkID();
|
||||
}
|
||||
else
|
||||
for ( int i = 0; i < theNbNodes; i++ )
|
||||
{
|
||||
pts[i] = nodes[ interlace[i] ]->GetVtkID();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///Return The number of nodes owned by the current element
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int SMDS_MeshCell::NbNodes() const
|
||||
{
|
||||
if ( GetEntityType() == SMDSEntity_Polyhedra )
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbNodes();
|
||||
vtkIdType *pts, npts;
|
||||
getGrid()->GetCellPoints( GetVtkID(), npts, pts );
|
||||
return npts;
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbFaces() const
|
||||
{
|
||||
if ( GetEntityType() == SMDSEntity_Polyhedra )
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbFaces();
|
||||
return getCellProps( GetVtkType() ).myNbFaces;
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbEdges() const
|
||||
{
|
||||
switch ( GetEntityType() )
|
||||
{
|
||||
case SMDSEntity_Polyhedra:
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbEdges();
|
||||
case SMDSEntity_Polygon:
|
||||
return NbNodes();
|
||||
case SMDSEntity_Quad_Polygon:
|
||||
return NbNodes() / 2;
|
||||
default:;
|
||||
}
|
||||
return getCellProps( GetVtkType() ).myNbEdges;
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbCornerNodes() const
|
||||
{
|
||||
switch ( GetEntityType() )
|
||||
{
|
||||
case SMDSEntity_Polyhedra:
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbCornerNodes();
|
||||
case SMDSEntity_Polygon:
|
||||
return NbNodes();
|
||||
case SMDSEntity_Quad_Polygon:
|
||||
return NbNodes() / 2;
|
||||
default:;
|
||||
}
|
||||
return getCellProps( GetVtkType() ).myNbCornerNodes;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on nodes owned by the element.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_ElemIteratorPtr SMDS_MeshCell::nodesIterator() const
|
||||
{
|
||||
if ( GetEntityType() == SMDSEntity_Polyhedra )
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::nodesIterator();
|
||||
|
||||
return boost::make_shared< SMDS_VtkCellIterator<> >( GetMesh(), GetVtkID(), GetEntityType());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on nodes owned by the element.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_NodeIteratorPtr SMDS_MeshCell::nodeIterator() const
|
||||
{
|
||||
if ( GetEntityType() == SMDSEntity_Polyhedra )
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::nodeIterator();
|
||||
|
||||
return SMDS_NodeIteratorPtr
|
||||
(new SMDS_VtkCellIterator<SMDS_NodeIterator>( GetMesh(), GetVtkID(), GetEntityType()));
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_MeshCell::interlacedNodesIterator() const
|
||||
{
|
||||
bool canInterlace = ( GetType() == SMDSAbs_Face || GetType() == SMDSAbs_Edge );
|
||||
return canInterlace ? nodesIteratorToUNV() : nodeIterator();
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_MeshCell::nodesIteratorToUNV() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr
|
||||
(new SMDS_VtkCellIteratorToUNV<SMDS_NodeIterator>( GetMesh(), GetVtkID(), GetEntityType()));
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshCell::GetType() const
|
||||
{
|
||||
return ElemType( GetEntityType() );
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_MeshCell::GetEntityType() const
|
||||
{
|
||||
return toSmdsType( (VTKCellType) GetVtkType() );
|
||||
}
|
||||
|
||||
SMDSAbs_GeometryType SMDS_MeshCell::GetGeomType() const
|
||||
{
|
||||
return getCellProps( GetVtkType() ).myGeom;
|
||||
}
|
||||
|
||||
VTKCellType SMDS_MeshCell::GetVtkType() const
|
||||
{
|
||||
return (VTKCellType) getGrid()->GetCellType( GetVtkID() );
|
||||
}
|
||||
|
||||
bool SMDS_MeshCell::IsPoly() const
|
||||
{
|
||||
return getCellProps( GetVtkType() ).myIsPoly;
|
||||
}
|
||||
|
||||
bool SMDS_MeshCell::IsQuadratic() const
|
||||
{
|
||||
return getCellProps( GetVtkType() ).IsQuadratic();
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_MeshCell::GetNode(const int ind) const
|
||||
{
|
||||
if ( GetEntityType() == SMDSEntity_Polyhedra )
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::GetNode( ind );
|
||||
|
||||
vtkIdType npts, *pts;
|
||||
getGrid()->GetCellPoints( GetVtkID(), npts, pts );
|
||||
const std::vector<int>& interlace = SMDS_MeshCell::fromVtkOrder( VTKCellType( GetVtkType() ));
|
||||
return GetMesh()->FindNodeVtk( pts[ interlace.empty() ? ind : interlace[ ind ]]);
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
if ( GetEntityType() == SMDSEntity_Polyhedra )
|
||||
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::GetNodeIndex( node );
|
||||
|
||||
vtkIdType npts, *pts;
|
||||
getGrid()->GetCellPoints( GetVtkID(), npts, pts );
|
||||
for ( vtkIdType i = 0; i < npts; ++i )
|
||||
if ( pts[i] == node->GetVtkID() )
|
||||
{
|
||||
const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( GetVtkType() ));
|
||||
return interlace.empty() ? i : interlace[i];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return VTKCellType corresponding to SMDSAbs_EntityType
|
||||
@ -262,7 +624,7 @@ const std::vector<int>& SMDS_MeshCell::reverseSmdsOrder(SMDSAbs_EntityType smdsT
|
||||
const int ids[] = {0,2,1,3,5,4, 8,7,6,11,10,9,12,14,13,15,16,17};
|
||||
reverseInterlaces[SMDSEntity_BiQuad_Penta].assign( &ids[0], &ids[0]+18 );
|
||||
}
|
||||
{
|
||||
{
|
||||
const int ids[] = {0,5,4,3,2,1,6,11,10,9,8,7};
|
||||
reverseInterlaces[SMDSEntity_Hexagonal_Prism].assign( &ids[0], &ids[0]+12 );
|
||||
}
|
||||
@ -348,14 +710,7 @@ const std::vector<int>& SMDS_MeshCell::interlacedSmdsOrder(SMDSAbs_EntityType sm
|
||||
|
||||
SMDSAbs_EntityType SMDS_MeshCell::toSmdsType(VTKCellType vtkType)
|
||||
{
|
||||
static std::vector< SMDSAbs_EntityType > smdsTypes;
|
||||
if ( smdsTypes.empty() )
|
||||
{
|
||||
smdsTypes.resize( VTK_NUMBER_OF_CELL_TYPES, SMDSEntity_Last );
|
||||
for ( int iSMDS = 0; iSMDS < SMDSEntity_Last; ++iSMDS )
|
||||
smdsTypes[ toVtkType( SMDSAbs_EntityType( iSMDS ))] = SMDSAbs_EntityType( iSMDS );
|
||||
}
|
||||
return smdsTypes[ vtkType ];
|
||||
return getCellProps( vtkType ).myEntity;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -364,7 +719,7 @@ SMDSAbs_EntityType SMDS_MeshCell::toSmdsType(VTKCellType vtkType)
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshCell::toSmdsType(SMDSAbs_GeometryType geomType)
|
||||
SMDSAbs_ElementType SMDS_MeshCell::ElemType(SMDSAbs_GeometryType geomType)
|
||||
{
|
||||
switch ( geomType ) {
|
||||
case SMDSGeom_POINT: return SMDSAbs_0DElement;
|
||||
@ -395,46 +750,45 @@ SMDSAbs_ElementType SMDS_MeshCell::toSmdsType(SMDSAbs_GeometryType geomType)
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshCell::toSmdsType(SMDSAbs_EntityType entityType)
|
||||
SMDSAbs_ElementType SMDS_MeshCell::ElemType(SMDSAbs_EntityType entityType)
|
||||
{
|
||||
switch ( entityType ) {
|
||||
case SMDSEntity_Node: return SMDSAbs_Node;
|
||||
|
||||
case SMDSEntity_0D: return SMDSAbs_0DElement;
|
||||
|
||||
case SMDSEntity_Edge:
|
||||
case SMDSEntity_Quad_Edge: return SMDSAbs_Edge;
|
||||
|
||||
case SMDSEntity_Triangle:
|
||||
case SMDSEntity_Quad_Triangle:
|
||||
case SMDSEntity_BiQuad_Triangle:
|
||||
case SMDSEntity_Quadrangle:
|
||||
case SMDSEntity_Quad_Quadrangle:
|
||||
case SMDSEntity_BiQuad_Quadrangle:
|
||||
case SMDSEntity_Polygon:
|
||||
case SMDSEntity_Quad_Polygon: return SMDSAbs_Face;
|
||||
|
||||
case SMDSEntity_Tetra:
|
||||
case SMDSEntity_Quad_Tetra:
|
||||
case SMDSEntity_Pyramid:
|
||||
case SMDSEntity_Quad_Pyramid:
|
||||
case SMDSEntity_Hexa:
|
||||
case SMDSEntity_Quad_Hexa:
|
||||
case SMDSEntity_TriQuad_Hexa:
|
||||
case SMDSEntity_Penta:
|
||||
case SMDSEntity_Quad_Penta:
|
||||
case SMDSEntity_BiQuad_Penta:
|
||||
case SMDSEntity_Hexagonal_Prism:
|
||||
case SMDSEntity_Polyhedra:
|
||||
case SMDSEntity_Quad_Polyhedra: return SMDSAbs_Volume;
|
||||
|
||||
case SMDSEntity_Ball: return SMDSAbs_Ball;
|
||||
|
||||
case SMDSEntity_Last:;
|
||||
}
|
||||
return SMDSAbs_All;
|
||||
return getCellProps( entityType ).myType;
|
||||
}
|
||||
|
||||
SMDSAbs_GeometryType SMDS_MeshCell::GeomType( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).myGeom;
|
||||
}
|
||||
|
||||
bool SMDS_MeshCell::IsPoly( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).myIsPoly;
|
||||
}
|
||||
|
||||
bool SMDS_MeshCell::IsQuadratic( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).IsQuadratic();
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbCornerNodes( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).myNbCornerNodes;
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbNodes( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).myNbNodes;
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbEdges( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).myNbEdges;
|
||||
}
|
||||
|
||||
int SMDS_MeshCell::NbFaces( SMDSAbs_EntityType entityType )
|
||||
{
|
||||
return getCellProps( entityType ).myNbFaces;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
|
@ -28,17 +28,52 @@
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshCell: public SMDS_MeshElement
|
||||
{
|
||||
public:
|
||||
SMDS_MeshCell();
|
||||
virtual ~SMDS_MeshCell();
|
||||
protected:
|
||||
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)= 0;
|
||||
virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) { return true; }
|
||||
void init( SMDSAbs_EntityType entityType, int nbNodes, ... );
|
||||
|
||||
static VTKCellType toVtkType (SMDSAbs_EntityType vtkType);
|
||||
static SMDSAbs_EntityType toSmdsType(VTKCellType vtkType);
|
||||
static SMDSAbs_ElementType toSmdsType(SMDSAbs_GeometryType geomType);
|
||||
static SMDSAbs_ElementType toSmdsType(SMDSAbs_EntityType entityType);
|
||||
void init( SMDSAbs_EntityType entityType, const std::vector<const SMDS_MeshNode*>& nodes );
|
||||
|
||||
void init( SMDSAbs_EntityType entityType, const std::vector<vtkIdType>& vtkNodeIds );
|
||||
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
public:
|
||||
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbCornerNodes() const;
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
virtual VTKCellType GetVtkType() const;
|
||||
|
||||
virtual bool IsPoly() const;
|
||||
virtual bool IsQuadratic() const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;
|
||||
|
||||
|
||||
static void InitStaticMembers();
|
||||
static VTKCellType toVtkType ( SMDSAbs_EntityType entityType );
|
||||
static SMDSAbs_EntityType toSmdsType ( VTKCellType vtkType );
|
||||
static SMDSAbs_ElementType ElemType ( SMDSAbs_GeometryType geomType );
|
||||
static SMDSAbs_ElementType ElemType ( SMDSAbs_EntityType entityType );
|
||||
static SMDSAbs_GeometryType GeomType ( SMDSAbs_EntityType entityType );
|
||||
static bool IsPoly ( SMDSAbs_EntityType entityType );
|
||||
static bool IsQuadratic ( SMDSAbs_EntityType entityType );
|
||||
static int NbCornerNodes( SMDSAbs_EntityType entityType );
|
||||
static int NbNodes ( SMDSAbs_EntityType entityType );
|
||||
static int NbEdges ( SMDSAbs_EntityType entityType );
|
||||
static int NbFaces ( SMDSAbs_EntityType entityType );
|
||||
|
||||
static const std::vector<int>& toVtkOrder(VTKCellType vtkType);
|
||||
static const std::vector<int>& toVtkOrder(SMDSAbs_EntityType smdsType);
|
||||
@ -50,6 +85,7 @@ public:
|
||||
static const std::vector<int>& interlacedSmdsOrder(SMDSAbs_EntityType smdsType,
|
||||
const size_t nbNodes=0);
|
||||
|
||||
|
||||
template< class VECT > // interlacedIDs[i] = smdsIDs[ indices[ i ]]
|
||||
static void applyInterlace( const std::vector<int>& interlace, VECT & data)
|
||||
{
|
||||
@ -69,15 +105,6 @@ public:
|
||||
data.swap( tmpData );
|
||||
}
|
||||
|
||||
static int nbCells;
|
||||
|
||||
protected:
|
||||
inline void exchange(const SMDS_MeshNode* nodes[],int a, int b)
|
||||
{
|
||||
const SMDS_MeshNode* noda = nodes[a];
|
||||
nodes[a] = nodes[b];
|
||||
nodes[b] = noda;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,30 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "SMDS_MeshEdge.hxx"
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshEdge::GetType() const
|
||||
{
|
||||
return SMDSAbs_Edge;
|
||||
}
|
||||
|
||||
vtkIdType SMDS_MeshEdge::GetVtkType() const
|
||||
{
|
||||
return VTK_POLY_VERTEX; // --- must be reimplemented in derived classes
|
||||
}
|
@ -28,12 +28,16 @@
|
||||
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
|
||||
/*!
|
||||
* \brief Edge mesh element. This type is not allocated.
|
||||
* It is only used as function argument type to provide more clear semantic.
|
||||
*/
|
||||
class SMDS_EXPORT SMDS_MeshEdge: public SMDS_MeshCell
|
||||
{
|
||||
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Edge; }
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_EDGE; }
|
||||
|
||||
static SMDSAbs_ElementType Type() { return SMDSAbs_Edge; }
|
||||
};
|
||||
#endif
|
||||
|
@ -27,267 +27,59 @@
|
||||
#endif
|
||||
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_MeshEdge.hxx"
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_ElementFactory.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Constructor of a non-used element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_MeshElement::SMDS_MeshElement(int ID)
|
||||
SMDS_MeshElement::SMDS_MeshElement(): myHolder(0)
|
||||
{
|
||||
init(ID);
|
||||
}
|
||||
|
||||
SMDS_MeshElement::SMDS_MeshElement(int id, ShortType meshId, LongType shapeId)
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Check if a node is a medium node of a quadratic cell
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool SMDS_MeshElement::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
init(id, meshId, shapeId);
|
||||
return !( GetNodeIndex( node ) < NbCornerNodes() );
|
||||
}
|
||||
|
||||
void SMDS_MeshElement::init(int id, ShortType meshId, LongType shapeId )
|
||||
{
|
||||
myID = id;
|
||||
myMeshId = meshId;
|
||||
myShapeId = shapeId;
|
||||
myIdInShape = -1;
|
||||
}
|
||||
|
||||
void SMDS_MeshElement::Print(ostream & OS) const
|
||||
{
|
||||
OS << "dump of mesh element" << endl;
|
||||
}
|
||||
|
||||
ostream & operator <<(ostream & OS, const SMDS_MeshElement * ME)
|
||||
{
|
||||
ME->Print(OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on nodes owned by the element.
|
||||
/// This method call elementsIterator().
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIterator() const
|
||||
{
|
||||
return elementsIterator(SMDSAbs_Node);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on edges linked with or owned by the element.
|
||||
/// This method call elementsIterator().
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_ElemIteratorPtr SMDS_MeshElement::edgesIterator() const
|
||||
{
|
||||
return elementsIterator(SMDSAbs_Edge);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on faces linked with or owned by the element.
|
||||
/// This method call elementsIterator().
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_ElemIteratorPtr SMDS_MeshElement::facesIterator() const
|
||||
{
|
||||
return elementsIterator(SMDSAbs_Face);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///Return The number of nodes owned by the current element
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int SMDS_MeshElement::NbNodes() const
|
||||
{
|
||||
int nbnodes=0;
|
||||
SMDS_ElemIteratorPtr it=nodesIterator();
|
||||
while(it->more())
|
||||
{
|
||||
it->next();
|
||||
nbnodes++;
|
||||
}
|
||||
return nbnodes;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///Return the number of edges owned by or linked with the current element
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int SMDS_MeshElement::NbEdges() const
|
||||
{
|
||||
int nbedges=0;
|
||||
SMDS_ElemIteratorPtr it=edgesIterator();
|
||||
while(it->more())
|
||||
{
|
||||
it->next();
|
||||
nbedges++;
|
||||
}
|
||||
return nbedges;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///Return the number of faces owned by or linked with the current element
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int SMDS_MeshElement::NbFaces() const
|
||||
{
|
||||
int nbfaces=0;
|
||||
SMDS_ElemIteratorPtr it=facesIterator();
|
||||
while(it->more())
|
||||
{
|
||||
it->next();
|
||||
nbfaces++;
|
||||
}
|
||||
return nbfaces;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///Create an iterator which iterate on elements linked with the current element.
|
||||
///@param type The of elements on which you want to iterate
|
||||
///@return A smart pointer to iterator, you are not to take care of freeing memory
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class SMDS_MeshElement_MyIterator:public SMDS_ElemIterator
|
||||
{
|
||||
const SMDS_MeshElement * myElement;
|
||||
bool myMore;
|
||||
public:
|
||||
SMDS_MeshElement_MyIterator(const SMDS_MeshElement * element):
|
||||
myElement(element),myMore(true) {}
|
||||
|
||||
bool more()
|
||||
{
|
||||
return myMore;
|
||||
}
|
||||
|
||||
const SMDS_MeshElement* next()
|
||||
{
|
||||
myMore=false;
|
||||
return myElement;
|
||||
}
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr
|
||||
SMDS_MeshElement::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
/** @todo Check that iterator in the child classes return elements
|
||||
in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
|
||||
and SMDS_VolumeOfFaces */
|
||||
if(type==GetType())
|
||||
return SMDS_ElemIteratorPtr(new SMDS_MeshElement_MyIterator(this));
|
||||
else
|
||||
{
|
||||
MESSAGE("Iterator not implemented");
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
|
||||
SMDS_NodeIteratorPtr SMDS_MeshElement::nodesIteratorToUNV() const
|
||||
{
|
||||
return nodeIterator();
|
||||
}
|
||||
|
||||
//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
|
||||
SMDS_NodeIteratorPtr SMDS_MeshElement::interlacedNodesIterator() const
|
||||
{
|
||||
return nodeIterator();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//=======================================================================
|
||||
//class : _MyNodeIteratorFromElemIterator
|
||||
//=======================================================================
|
||||
class _MyNodeIteratorFromElemIterator : public SMDS_NodeIterator
|
||||
{
|
||||
SMDS_ElemIteratorPtr myItr;
|
||||
public:
|
||||
_MyNodeIteratorFromElemIterator(SMDS_ElemIteratorPtr elemItr):myItr( elemItr ) {}
|
||||
bool more() { return myItr->more(); }
|
||||
const SMDS_MeshNode* next() { return static_cast< const SMDS_MeshNode*>( myItr->next() ); }
|
||||
};
|
||||
//=======================================================================
|
||||
//class : _MyElemIteratorFromNodeIterator
|
||||
//=======================================================================
|
||||
class _MyElemIteratorFromNodeIterator : public SMDS_ElemIterator
|
||||
{
|
||||
SMDS_NodeIteratorPtr myItr;
|
||||
public:
|
||||
_MyElemIteratorFromNodeIterator(SMDS_NodeIteratorPtr nodeItr): myItr( nodeItr ) {}
|
||||
bool more() { return myItr->more(); }
|
||||
const SMDS_MeshElement* next() { return myItr->next(); }
|
||||
};
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_MeshElement::interlacedNodesElemIterator() const
|
||||
{
|
||||
return SMDS_ElemIteratorPtr
|
||||
( new _MyElemIteratorFromNodeIterator( interlacedNodesIterator() ));
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_MeshElement::nodeIterator() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr
|
||||
( new _MyNodeIteratorFromElemIterator( nodesIterator() ));
|
||||
}
|
||||
|
||||
bool operator<(const SMDS_MeshElement& e1, const SMDS_MeshElement& e2)
|
||||
{
|
||||
if(e1.GetType()!=e2.GetType()) return false;
|
||||
switch(e1.GetType())
|
||||
{
|
||||
case SMDSAbs_Node:
|
||||
return static_cast<const SMDS_MeshNode &>(e1) <
|
||||
static_cast<const SMDS_MeshNode &>(e2);
|
||||
|
||||
case SMDSAbs_Edge:
|
||||
return static_cast<const SMDS_MeshEdge &>(e1) <
|
||||
static_cast<const SMDS_MeshEdge &>(e2);
|
||||
|
||||
case SMDSAbs_Face:
|
||||
return static_cast<const SMDS_MeshFace &>(e1) <
|
||||
static_cast<const SMDS_MeshFace &>(e2);
|
||||
|
||||
case SMDSAbs_Volume:
|
||||
return static_cast<const SMDS_MeshVolume &>(e1) <
|
||||
static_cast<const SMDS_MeshVolume &>(e2);
|
||||
|
||||
default : MESSAGE("Internal Error");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return true if index of node is valid (0 <= ind < NbNodes())
|
||||
* \param ind - node index
|
||||
* \retval bool - index check result
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool SMDS_MeshElement::IsValidIndex(const int ind) const
|
||||
{
|
||||
return ( ind>-1 && ind<NbNodes() );
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_MeshElement::GetNode(const int ind) const
|
||||
{
|
||||
if ( ind >= 0 ) {
|
||||
SMDS_ElemIteratorPtr it = nodesIterator();
|
||||
for ( int i = 0; i < ind; ++i )
|
||||
it->next();
|
||||
if ( it->more() )
|
||||
return static_cast<const SMDS_MeshNode*> (it->next());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SMDS_MeshElement::IsQuadratic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SMDS_MeshElement::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return number of nodes excluding medium ones
|
||||
* \brief Return a valid corner node index, fixing the given one if necessary
|
||||
* \param ind - node index
|
||||
* \retval int - valid node index
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_MeshElement::NbCornerNodes() const
|
||||
int SMDS_MeshElement::WrappedIndex(const int ind) const
|
||||
{
|
||||
return IsQuadratic() ? NbNodes() - NbEdges() : NbNodes();
|
||||
if ( ind < 0 ) return NbCornerNodes() + ind % NbCornerNodes();
|
||||
if ( ind >= NbCornerNodes() ) return ind % NbCornerNodes();
|
||||
return ind;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -306,3 +98,119 @@ int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return ID of an element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_MeshElement::GetID() const
|
||||
{
|
||||
return myHolder ? myHolder->GetID( this ) : -1;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set ID of a shape this element was generated on
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_MeshElement::setShapeID( const int shapeID ) const
|
||||
{
|
||||
const_cast<SMDS_ElementChunk*>( myHolder )->SetShapeID( this, shapeID );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return ID of a shape this element was generated on
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_MeshElement::GetShapeID() const
|
||||
{
|
||||
return myHolder->GetShapeID( this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return VTK ID of this element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_MeshElement::GetVtkID() const
|
||||
{
|
||||
return myHolder->GetVtkID( this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Mark this element
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_MeshElement::setIsMarked( bool is ) const
|
||||
{
|
||||
const_cast<SMDS_ElementChunk*>( myHolder )->SetIsMarked( this, is );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Check if this element is marked
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool SMDS_MeshElement::isMarked() const
|
||||
{
|
||||
return myHolder->IsMarked( this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Store VTK ID
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_MeshElement::setVtkID( const int vtkID )
|
||||
{
|
||||
myHolder->SetVTKID( this, vtkID );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return the mesh this element belongs to
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_Mesh* SMDS_MeshElement::GetMesh() const
|
||||
{
|
||||
return const_cast<SMDS_ElementChunk*>( myHolder )->GetMesh();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return a SMDS_UnstructuredGrid
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_UnstructuredGrid* SMDS_MeshElement::getGrid() const
|
||||
{
|
||||
return const_cast<SMDS_ElementChunk*>( myHolder )->GetMesh()->GetGrid();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Print self
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_MeshElement::Print(ostream & OS) const
|
||||
{
|
||||
OS << "dump of mesh element" << endl;
|
||||
}
|
||||
|
||||
ostream & operator <<(ostream & OS, const SMDS_MeshElement * e)
|
||||
{
|
||||
e->Print(OS);
|
||||
return OS;
|
||||
}
|
||||
|
@ -32,23 +32,17 @@
|
||||
#include "SMDSAbs_ElementType.hxx"
|
||||
#include "SMDS_MeshObject.hxx"
|
||||
#include "SMDS_ElemIterator.hxx"
|
||||
#include "SMDS_MeshElementIDFactory.hxx"
|
||||
#include "SMDS_StdIterator.hxx"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include <vtkType.h>
|
||||
#include <vtkCellType.h>
|
||||
|
||||
//typedef unsigned short UShortType;
|
||||
typedef short ShortType;
|
||||
typedef int LongType;
|
||||
|
||||
class SMDS_MeshNode;
|
||||
class SMDS_MeshEdge;
|
||||
class SMDS_MeshFace;
|
||||
class SMDS_ElementChunk;
|
||||
class SMDS_Mesh;
|
||||
class SMDS_MeshNode;
|
||||
class SMDS_UnstructuredGrid;
|
||||
|
||||
// ============================================================
|
||||
/*!
|
||||
@ -61,43 +55,36 @@ class SMDS_EXPORT SMDS_MeshElement : public SMDS_MeshObject
|
||||
{
|
||||
public:
|
||||
|
||||
SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
SMDS_ElemIteratorPtr edgesIterator() const;
|
||||
SMDS_ElemIteratorPtr facesIterator() const;
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
|
||||
// ===========================
|
||||
// Access to nodes
|
||||
// ===========================
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const = 0;
|
||||
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const = 0;
|
||||
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const { return nodeIterator(); }
|
||||
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const { return nodeIterator(); }
|
||||
|
||||
// std-like iteration on nodes
|
||||
typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_ElemIteratorPtr > iterator;
|
||||
iterator begin_nodes() const { return iterator( nodesIterator() ); }
|
||||
typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_NodeIteratorPtr > iterator;
|
||||
iterator begin_nodes() const { return iterator( nodeIterator() ); }
|
||||
iterator end_nodes() const { return iterator(); }
|
||||
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
inline int GetID() const { return myID; }
|
||||
// ===========================
|
||||
// Type of element
|
||||
// ===========================
|
||||
virtual int NbNodes() const = 0;
|
||||
virtual int NbEdges() const = 0;
|
||||
virtual int NbFaces() const = 0;
|
||||
|
||||
///Return the type of the current element
|
||||
virtual SMDSAbs_ElementType GetType() const = 0;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const = 0;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const = 0;
|
||||
virtual vtkIdType GetVtkType() const = 0;
|
||||
virtual VTKCellType GetVtkType() const = 0;
|
||||
|
||||
virtual bool IsPoly() const { return false; }
|
||||
virtual bool IsQuadratic() const;
|
||||
virtual bool IsPoly() const = 0;
|
||||
virtual bool IsQuadratic() const = 0;
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
virtual int NbCornerNodes() const;
|
||||
|
||||
friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
|
||||
friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement* elem);
|
||||
friend class SMDS_Mesh;
|
||||
friend class SMESHDS_Mesh;
|
||||
friend class SMESHDS_SubMesh;
|
||||
friend class SMDS_MeshElementIDFactory;
|
||||
virtual int NbCornerNodes() const = 0;
|
||||
|
||||
// ===========================
|
||||
// Access to nodes by index
|
||||
@ -107,14 +94,14 @@ public:
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*
|
||||
* Index is wrapped if it is out of a valid range
|
||||
* Index is wrapped if it is out of a valid range of corner nodes
|
||||
*/
|
||||
const SMDS_MeshNode* GetNodeWrap(const int ind) const { return GetNode( WrappedIndex( ind )); }
|
||||
|
||||
@ -126,15 +113,11 @@ public:
|
||||
virtual bool IsValidIndex(const int ind) const;
|
||||
|
||||
/*!
|
||||
* \brief Return a valid node index, fixing the given one if necessary
|
||||
* \brief Return a valid corner node index, fixing the given one if necessary
|
||||
* \param ind - node index
|
||||
* \retval int - valid node index
|
||||
*/
|
||||
int WrappedIndex(const int ind) const {
|
||||
if ( ind < 0 ) return NbNodes() + ind % NbNodes();
|
||||
if ( ind >= NbNodes() ) return ind % NbNodes();
|
||||
return ind;
|
||||
}
|
||||
int WrappedIndex(const int ind) const;
|
||||
|
||||
/*!
|
||||
* \brief Check if a node belongs to the element
|
||||
@ -143,14 +126,26 @@ public:
|
||||
*/
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
|
||||
inline ShortType getMeshId() const { return myMeshId; }
|
||||
inline LongType getshapeId() const { return myShapeId >> BITS_SHIFT; }
|
||||
inline int getIdInShape() const { return myIdInShape; }
|
||||
inline int getVtkId() const { return myVtkID; }
|
||||
|
||||
virtual int GetID() const;
|
||||
virtual int GetVtkID() const;
|
||||
virtual int getshapeId() const { return GetShapeID(); }
|
||||
virtual int GetShapeID() const;
|
||||
|
||||
// mark this element; to be used in algos
|
||||
inline void setIsMarked( bool is ) const;
|
||||
inline bool isMarked() const;
|
||||
virtual void setIsMarked( bool is ) const;
|
||||
virtual bool isMarked() const;
|
||||
|
||||
// element can be allocated but "not used"
|
||||
bool IsNull() const { return myHolder == 0; }
|
||||
|
||||
SMDS_Mesh* GetMesh() const;
|
||||
|
||||
void Print(std::ostream & OS) const;
|
||||
|
||||
friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
|
||||
friend class SMDS_ElementFactory;
|
||||
friend class SMESHDS_SubMesh;
|
||||
|
||||
/*!
|
||||
* \brief Filters of elements, to be used with SMDS_SetIterator
|
||||
@ -183,42 +178,20 @@ public:
|
||||
bool operator()(const SMDS_MeshElement* e) const { return e && e->GetGeomType() == _type; }
|
||||
};
|
||||
|
||||
protected:
|
||||
inline void setId(int id) { myID = id; }
|
||||
inline void setVtkId(int vtkId) { myVtkID = vtkId; }
|
||||
inline void setIdInShape(int id) { myIdInShape = id; }
|
||||
inline void setShapeId(LongType shapeId) { myShapeId = ( shapeId << BITS_SHIFT ) | ( myShapeId & BIT_IS_MARKED ); }
|
||||
SMDS_MeshElement(int ID=-1);
|
||||
SMDS_MeshElement(int id, ShortType meshId, LongType shapeId = 0);
|
||||
virtual void init(int id = -1, ShortType meshId = -1, LongType shapeId = 0);
|
||||
virtual void Print(std::ostream & OS) const;
|
||||
protected:
|
||||
|
||||
//! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells
|
||||
int myID;
|
||||
//! index in vtkUnstructuredGrid
|
||||
int myVtkID;
|
||||
//! SMDS_Mesh identification in SMESH
|
||||
ShortType myMeshId;
|
||||
//! SubShape and SubMesh identification in SMESHDS; one bit is used to mark the element
|
||||
LongType myShapeId;
|
||||
//! Element index in SMESHDS_SubMesh vector
|
||||
int myIdInShape;
|
||||
SMDS_MeshElement();
|
||||
|
||||
enum Bits { // use the 1st right bit of myShapeId to set/unset a mark
|
||||
BIT_IS_MARKED = 1,
|
||||
BITS_SHIFT = 1
|
||||
};
|
||||
void setVtkID(const int vtkID );
|
||||
virtual void setShapeID( const int shapeID ) const;
|
||||
|
||||
SMDS_UnstructuredGrid* getGrid() const;
|
||||
|
||||
protected:
|
||||
|
||||
SMDS_ElementChunk* myHolder;
|
||||
};
|
||||
|
||||
inline void SMDS_MeshElement::setIsMarked( bool is ) const
|
||||
{
|
||||
const_cast< SMDS_MeshElement* >( this )->myShapeId = ( myShapeId & ~BIT_IS_MARKED ) | is;
|
||||
}
|
||||
inline bool SMDS_MeshElement::isMarked() const
|
||||
{
|
||||
return myShapeId & BIT_IS_MARKED;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
/*!
|
||||
* \brief Comparator of elements by ID for usage in std containers
|
||||
|
@ -1,176 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_MeshElementIDFactory.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_MeshElementIDFactory.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include "SMDS_UnstructuredGrid.hxx"
|
||||
#include <vtkCellType.h>
|
||||
|
||||
#include <climits>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_MeshElementIDFactory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
|
||||
SMDS_MeshNodeIDFactory()
|
||||
{
|
||||
}
|
||||
|
||||
int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
|
||||
{
|
||||
// --- retrieve nodes ID
|
||||
|
||||
SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
|
||||
assert(cell);
|
||||
vector<vtkIdType> nodeIds( elem->NbNodes() );
|
||||
SMDS_ElemIteratorPtr it = elem->nodesIterator();
|
||||
for( int i = 0; it->more(); ++i )
|
||||
{
|
||||
int nodeId = (static_cast<const SMDS_MeshNode*>(it->next()))->getVtkId();
|
||||
nodeIds[i] = nodeId;
|
||||
}
|
||||
|
||||
// --- insert cell in vtkUnstructuredGrid
|
||||
|
||||
int typ = VTK_VERTEX;
|
||||
int cellId = myMesh->getGrid()->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
|
||||
cell->setVtkId(cellId);
|
||||
return cellId;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BindID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
|
||||
{
|
||||
SetInVtkGrid(elem);
|
||||
return myMesh->registerElement(ID, elem);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MeshElement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
|
||||
{
|
||||
if ( ID<1 || ID >= (int) myMesh->myCells.size() )
|
||||
return NULL;
|
||||
const SMDS_MeshElement* elem = GetMesh()->FindElement(ID);
|
||||
return (SMDS_MeshElement*)(elem);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFreeID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_MeshElementIDFactory::GetFreeID()
|
||||
{
|
||||
int ID;
|
||||
do {
|
||||
ID = SMDS_MeshIDFactory::GetFreeID();
|
||||
} while ( MeshElement( ID ));
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReleaseID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId)
|
||||
{
|
||||
if (ID < 1) // TODO check case ID == O
|
||||
{
|
||||
MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
|
||||
return;
|
||||
}
|
||||
if (vtkId >= 0)
|
||||
{
|
||||
assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size());
|
||||
myMesh->myCellIdVtkToSmds[vtkId] = -1;
|
||||
myMesh->setMyModified();
|
||||
}
|
||||
SMDS_MeshIDFactory::ReleaseID(ID);
|
||||
if (ID == myMax)
|
||||
myMax = 0;
|
||||
if (ID == myMin)
|
||||
myMax = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : updateMinMax
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_MeshElementIDFactory::updateMinMax() const
|
||||
{
|
||||
myMin = INT_MAX;
|
||||
myMax = 0;
|
||||
for (size_t i = 0; i < myMesh->myCells.size(); i++)
|
||||
{
|
||||
if (myMesh->myCells[i])
|
||||
{
|
||||
int id = myMesh->myCells[i]->GetID();
|
||||
if (id > myMax)
|
||||
myMax = id;
|
||||
if (id < myMin)
|
||||
myMin = id;
|
||||
}
|
||||
}
|
||||
if (myMin == INT_MAX)
|
||||
myMin = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose : Return an iterator on elements of the factory
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
|
||||
{
|
||||
return myMesh->elementsIterator(SMDSAbs_All);
|
||||
}
|
||||
|
||||
void SMDS_MeshElementIDFactory::Clear()
|
||||
{
|
||||
myMesh->myCellIdVtkToSmds.clear();
|
||||
myMin = myMax = 0;
|
||||
SMDS_MeshIDFactory::Clear();
|
||||
}
|
@ -31,11 +31,37 @@
|
||||
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshFace:public SMDS_MeshCell
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
/*!
|
||||
* \brief Mesh face. This type is not allocated.
|
||||
* It is only used as function argument type to provide more clear semantic.
|
||||
*/
|
||||
class SMDS_EXPORT SMDS_MeshFace : public SMDS_MeshCell
|
||||
{
|
||||
public:
|
||||
SMDSAbs_ElementType GetType() const;
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
void init( const std::vector<vtkIdType>& vtkNodeIds )
|
||||
{
|
||||
SMDSAbs_EntityType entity = SMDSEntity_Triangle;
|
||||
switch ( vtkNodeIds.size())
|
||||
{
|
||||
case 3: entity = SMDSEntity_Triangle; break;
|
||||
case 4: entity = SMDSEntity_Quadrangle; break;
|
||||
case 6: entity = SMDSEntity_Quad_Triangle; break;
|
||||
case 8: entity = SMDSEntity_Quad_Quadrangle; break;
|
||||
case 7: entity = SMDSEntity_BiQuad_Triangle; break;
|
||||
case 9: entity = SMDSEntity_BiQuad_Quadrangle; break;
|
||||
default: throw SALOME_Exception("wrong face nodes");
|
||||
}
|
||||
SMDS_MeshCell::init( entity, vtkNodeIds );
|
||||
}
|
||||
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
public:
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
|
||||
|
||||
static SMDSAbs_ElementType Type() { return SMDSAbs_Face; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,89 +30,33 @@
|
||||
#endif
|
||||
|
||||
#include "SMDS_MeshGroup.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "ObjectPool.hxx"
|
||||
|
||||
#include <utilities.h>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_MeshGroup
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
|
||||
SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
|
||||
const SMDSAbs_ElementType theType)
|
||||
:myMesh(theMesh),myType(theType), myParent(NULL), myTic(0)
|
||||
: SMDS_ElementHolder( theMesh ), myType(theType), myTic(0)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_MeshGroup
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * theParent,
|
||||
const SMDSAbs_ElementType theType)
|
||||
:myMesh(theParent->myMesh),myType(theType), myParent(theParent)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddSubGroup
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup
|
||||
(const SMDSAbs_ElementType theType)
|
||||
{
|
||||
const SMDS_MeshGroup * subgroup = new SMDS_MeshGroup(this,theType);
|
||||
myChildren.insert(myChildren.end(),subgroup);
|
||||
return subgroup;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveSubGroup
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_MeshGroup::RemoveSubGroup(const SMDS_MeshGroup * theGroup)
|
||||
{
|
||||
bool found = false;
|
||||
list<const SMDS_MeshGroup*>::iterator itgroup;
|
||||
for(itgroup=myChildren.begin(); itgroup!=myChildren.end(); itgroup++)
|
||||
{
|
||||
const SMDS_MeshGroup* subgroup=*itgroup;
|
||||
if (subgroup == theGroup)
|
||||
{
|
||||
found = true;
|
||||
myChildren.erase(itgroup);
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveFromParent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_MeshGroup::RemoveFromParent()
|
||||
{
|
||||
|
||||
if (myParent==NULL) return false;
|
||||
else
|
||||
{
|
||||
return (myParent->RemoveSubGroup(this));
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_MeshGroup::Clear()
|
||||
{
|
||||
myElements.clear();
|
||||
clearVector( myElements );
|
||||
myType = SMDSAbs_All;
|
||||
++myTic;
|
||||
}
|
||||
@ -132,8 +76,8 @@ bool SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
|
||||
MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
|
||||
return false;
|
||||
}
|
||||
|
||||
myElements.insert(myElements.end(), theElem);
|
||||
|
||||
myElements.insert(theElem);
|
||||
++myTic;
|
||||
|
||||
return true;
|
||||
@ -141,12 +85,12 @@ bool SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
|
||||
|
||||
//=======================================================================
|
||||
//function : Remove
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
|
||||
{
|
||||
set<const SMDS_MeshElement *>::iterator found = myElements.find(theElem);
|
||||
TElementSet::iterator found = myElements.find(theElem);
|
||||
if ( found != myElements.end() ) {
|
||||
myElements.erase(found);
|
||||
if (myElements.empty()) myType = SMDSAbs_All;
|
||||
@ -176,3 +120,38 @@ void SMDS_MeshGroup::SetType(const SMDSAbs_ElementType theType)
|
||||
if (IsEmpty())
|
||||
myType = theType;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetElements
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_MeshGroup::GetElements() const
|
||||
{
|
||||
typedef SMDS_SetIterator< const SMDS_MeshElement*, TIterator > TSetIterator;
|
||||
return boost::make_shared< TSetIterator >( myElements.begin(), myElements.end() );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Move contents of another group
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_MeshGroup::operator=( SMDS_MeshGroup && other )
|
||||
{
|
||||
myMesh = other.myMesh;
|
||||
myType = other.myType;
|
||||
myElements = std::move( other.myElements );
|
||||
++myTic;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : tmpClear
|
||||
//purpose : temporary remove its elements before mesh compacting
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_MeshGroup::tmpClear()
|
||||
{
|
||||
compact();
|
||||
myElements.clear();
|
||||
}
|
||||
|
@ -29,65 +29,49 @@
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_ElementHolder.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include <set>
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshGroup:public SMDS_MeshObject
|
||||
#include <boost/container/flat_set.hpp>
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshGroup: public SMDS_MeshObject, SMDS_ElementHolder
|
||||
{
|
||||
public:
|
||||
SMDS_MeshGroup(const SMDS_Mesh * theMesh,
|
||||
const SMDSAbs_ElementType theType = SMDSAbs_All);
|
||||
const SMDS_MeshGroup * AddSubGroup
|
||||
(const SMDSAbs_ElementType theType = SMDSAbs_All);
|
||||
virtual bool RemoveSubGroup(const SMDS_MeshGroup* theGroup);
|
||||
virtual bool RemoveFromParent();
|
||||
public:
|
||||
SMDS_MeshGroup(const SMDS_Mesh * theMesh,
|
||||
const SMDSAbs_ElementType theType = SMDSAbs_All);
|
||||
|
||||
const SMDS_Mesh* GetMesh() const { return myMesh; }
|
||||
void SetType (const SMDSAbs_ElementType theType);
|
||||
void Clear();
|
||||
void Reserve(size_t nbElems) { myElements.reserve( nbElems ); }
|
||||
bool Add(const SMDS_MeshElement * theElem);
|
||||
bool Remove(const SMDS_MeshElement * theElem);
|
||||
bool IsEmpty() const { return myElements.empty(); }
|
||||
int Extent() const { return myElements.size(); }
|
||||
int Tic() const { return myTic; }
|
||||
bool Contains(const SMDS_MeshElement * theElem) const;
|
||||
|
||||
void SetType (const SMDSAbs_ElementType theType);
|
||||
void Clear();
|
||||
bool Add(const SMDS_MeshElement * theElem);
|
||||
bool Remove(const SMDS_MeshElement * theElem);
|
||||
bool IsEmpty() const { return myElements.empty(); }
|
||||
int Extent() const { return myElements.size(); }
|
||||
int Tic() const { return myTic; }
|
||||
const SMDS_Mesh* GetMesh() const { return myMesh; }
|
||||
SMDSAbs_ElementType GetType() const { return myType; }
|
||||
SMDS_ElemIteratorPtr GetElements() const; // WARNING: iterator becomes invalid if group changes
|
||||
|
||||
int SubGroupsNb() const { return myChildren.size(); }
|
||||
void operator=( SMDS_MeshGroup && other );
|
||||
|
||||
SMDSAbs_ElementType GetType() const { return myType; }
|
||||
protected: // methods of SMDS_ElementHolder
|
||||
|
||||
bool Contains(const SMDS_MeshElement * theElem) const;
|
||||
virtual SMDS_ElemIteratorPtr getElements() { return GetElements(); }
|
||||
virtual void tmpClear();
|
||||
virtual void add( const SMDS_MeshElement* element ) { Add( element ); }
|
||||
virtual void compact() { myElements.shrink_to_fit(); }
|
||||
|
||||
void InitIterator() const
|
||||
{ const_cast<TIterator&>(myIterator) = myElements.begin(); }
|
||||
private:
|
||||
|
||||
bool More() const { return myIterator != myElements.end(); }
|
||||
typedef boost::container::flat_set< const SMDS_MeshElement* > TElementSet;
|
||||
typedef TElementSet::const_iterator TIterator;
|
||||
|
||||
const SMDS_MeshElement* Next() const
|
||||
{ return *(const_cast<TIterator&>(myIterator))++; }
|
||||
|
||||
void InitSubGroupsIterator() const
|
||||
{ const_cast<TGroupIterator&>(myGroupIterator) = myChildren.begin(); }
|
||||
|
||||
bool MoreSubGroups() const { return myGroupIterator != myChildren.end(); }
|
||||
|
||||
const SMDS_MeshGroup* NextSubGroup() const
|
||||
{ return *(const_cast<TGroupIterator&>(myGroupIterator))++; }
|
||||
|
||||
private:
|
||||
SMDS_MeshGroup(SMDS_MeshGroup* theParent,
|
||||
const SMDSAbs_ElementType theType = SMDSAbs_All);
|
||||
|
||||
typedef std::set<const SMDS_MeshElement *>::const_iterator TIterator;
|
||||
typedef std::list<const SMDS_MeshGroup *>::const_iterator TGroupIterator;
|
||||
|
||||
const SMDS_Mesh * myMesh;
|
||||
SMDSAbs_ElementType myType;
|
||||
std::set<const SMDS_MeshElement*> myElements; /* - not sorted by ID because it */
|
||||
SMDS_MeshGroup * myParent; /* can contain deleted elements */
|
||||
std::list<const SMDS_MeshGroup*> myChildren;
|
||||
TIterator myIterator;
|
||||
TGroupIterator myGroupIterator;
|
||||
int myTic; // to track changes
|
||||
const SMDS_Mesh * myMesh;
|
||||
SMDSAbs_ElementType myType;
|
||||
TElementSet myElements; // not sorted by ID because it can contain deleted elements
|
||||
int myTic; // to track changes
|
||||
};
|
||||
#endif
|
||||
|
@ -1,113 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_MeshIDFactory.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#include "SMDS_MeshIDFactory.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_MeshIDFactory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(0), myMesh(0)
|
||||
{
|
||||
}
|
||||
|
||||
int SMDS_MeshIDFactory::GetFreeID()
|
||||
{
|
||||
int newid;
|
||||
if (myPoolOfID.empty())
|
||||
{
|
||||
newid = ++myMaxID;
|
||||
}
|
||||
else
|
||||
{
|
||||
set<int>::iterator i = myPoolOfID.begin();
|
||||
newid = *i;
|
||||
myPoolOfID.erase( i );
|
||||
}
|
||||
return newid;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReleaseID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId)
|
||||
{
|
||||
if ( ID > 0 )
|
||||
{
|
||||
if ( ID < myMaxID )
|
||||
{
|
||||
myPoolOfID.insert(ID);
|
||||
}
|
||||
else if ( ID == myMaxID )
|
||||
{
|
||||
--myMaxID;
|
||||
if ( !myPoolOfID.empty() ) // assure that myMaxID is not in myPoolOfID
|
||||
{
|
||||
set<int>::iterator i = --myPoolOfID.end();
|
||||
while ( i != myPoolOfID.begin() && myMaxID == *i ) {
|
||||
--myMaxID; --i;
|
||||
}
|
||||
if ( myMaxID == *i ) {
|
||||
--myMaxID; // begin of myPoolOfID reached
|
||||
myPoolOfID.clear();
|
||||
}
|
||||
else if ( myMaxID < ID-1 ) {
|
||||
myPoolOfID.erase( ++i, myPoolOfID.end() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SMDS_MeshIDFactory::Clear()
|
||||
{
|
||||
myMaxID = 0;
|
||||
myPoolOfID.clear();
|
||||
}
|
||||
|
||||
void SMDS_MeshIDFactory::SetMesh(SMDS_Mesh *mesh)
|
||||
{
|
||||
myMesh = mesh;
|
||||
}
|
||||
|
||||
SMDS_Mesh* SMDS_MeshIDFactory::GetMesh()
|
||||
{
|
||||
return myMesh;
|
||||
}
|
||||
|
||||
void SMDS_MeshIDFactory::emptyPool(int maxId)
|
||||
{
|
||||
myMaxID = maxId;
|
||||
myPoolOfID.clear();
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_MeshIDFactory.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_MeshIDFactory_HeaderFile
|
||||
#define _SMDS_MeshIDFactory_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshObject.hxx"
|
||||
#include <set>
|
||||
|
||||
class SMDS_Mesh;
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshIDFactory:public SMDS_MeshObject
|
||||
{
|
||||
public:
|
||||
int GetFreeID();
|
||||
virtual void ReleaseID(int ID, int vtkId = -1);
|
||||
virtual void Clear();
|
||||
|
||||
void SetMesh(SMDS_Mesh *mesh);
|
||||
SMDS_Mesh* GetMesh();
|
||||
inline bool isPoolIdEmpty() { return myPoolOfID.empty(); };
|
||||
virtual void emptyPool(int maxId);
|
||||
inline void adjustMaxId(int ID) { if (ID > myMaxID) myMaxID = ID;};
|
||||
protected:
|
||||
SMDS_MeshIDFactory();
|
||||
int myMaxID;
|
||||
std::set<int> myPoolOfID;
|
||||
SMDS_Mesh *myMesh;
|
||||
};
|
||||
|
||||
#endif
|
@ -27,55 +27,25 @@
|
||||
#endif
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_SpacePosition.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
|
||||
#include "utilities.h"
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
#include "SMDS_ElementFactory.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_SpacePosition.hxx"
|
||||
|
||||
#include <utilities.h>
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
int SMDS_MeshNode::nbNodes =0;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_MeshNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDS_MeshNode::SMDS_MeshNode() :
|
||||
SMDS_MeshElement(-1, -1, 0),
|
||||
myPosition(SMDS_SpacePosition::originSpacePosition())
|
||||
void SMDS_MeshNode::init(double x, double y, double z)
|
||||
{
|
||||
nbNodes++;
|
||||
}
|
||||
|
||||
SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z):
|
||||
SMDS_MeshElement(id, meshId, shapeId),
|
||||
myPosition(SMDS_SpacePosition::originSpacePosition())
|
||||
{
|
||||
nbNodes++;
|
||||
init(id, meshId, shapeId, x, y ,z);
|
||||
}
|
||||
|
||||
void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
|
||||
{
|
||||
SMDS_MeshElement::init(id, meshId, shapeId);
|
||||
myVtkID = id - 1;
|
||||
assert(myVtkID >= 0);
|
||||
SMDS_UnstructuredGrid * grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
SMDS_UnstructuredGrid * grid = getGrid();
|
||||
vtkPoints *points = grid->GetPoints();
|
||||
points->InsertPoint(myVtkID, x, y, z);
|
||||
points->InsertPoint( GetVtkID(), x, y, z );
|
||||
if ( grid->HasLinks() )
|
||||
grid->GetLinks()->ResizeForPoint( myVtkID );
|
||||
}
|
||||
|
||||
SMDS_MeshNode::~SMDS_MeshNode()
|
||||
{
|
||||
nbNodes--;
|
||||
if ( myPosition && myPosition != SMDS_SpacePosition::originSpacePosition() )
|
||||
delete myPosition, myPosition = 0;
|
||||
grid->GetLinks()->ResizeForPoint( GetVtkID() );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -85,8 +55,8 @@ SMDS_MeshNode::~SMDS_MeshNode()
|
||||
|
||||
void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * elem)
|
||||
{
|
||||
if ( SMDS_Mesh::_meshList[myMeshId]->getGrid()->HasLinks() )
|
||||
SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, elem->getVtkId());
|
||||
if ( getGrid()->HasLinks() )
|
||||
getGrid()->RemoveReferenceToCell( GetVtkID(), elem->GetVtkID());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -96,7 +66,7 @@ void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * elem)
|
||||
|
||||
void SMDS_MeshNode::Print(ostream & OS) const
|
||||
{
|
||||
OS << "Node <" << myID << "> : X = " << X() << " Y = "
|
||||
OS << "Node <" << GetID() << "> : X = " << X() << " Y = "
|
||||
<< Y() << " Z = " << Z() << endl;
|
||||
}
|
||||
|
||||
@ -105,23 +75,20 @@ void SMDS_MeshNode::Print(ostream & OS) const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_MeshNode::SetPosition(const SMDS_PositionPtr& aPos)
|
||||
void SMDS_MeshNode::SetPosition(const SMDS_PositionPtr& aPos, int shapeID)
|
||||
{
|
||||
if ( myPosition &&
|
||||
myPosition != SMDS_SpacePosition::originSpacePosition() &&
|
||||
myPosition != aPos )
|
||||
delete myPosition;
|
||||
myPosition = aPos;
|
||||
myHolder->SetPosition( this, aPos, shapeID );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetPosition
|
||||
//purpose :
|
||||
//purpose : Return a position of this node on shape
|
||||
//warning : result is std::unique_ptr !
|
||||
//=======================================================================
|
||||
|
||||
const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
|
||||
SMDS_PositionPtr SMDS_MeshNode::GetPosition() const
|
||||
{
|
||||
return myPosition;
|
||||
return myHolder->GetPosition( this );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -130,94 +97,120 @@ const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
|
||||
*/
|
||||
//=======================================================================
|
||||
|
||||
class SMDS_MeshNode_MyInvIterator: public SMDS_ElemIterator
|
||||
namespace
|
||||
{
|
||||
private:
|
||||
SMDS_Mesh* myMesh;
|
||||
vtkIdType* myCells;
|
||||
int myNcells;
|
||||
SMDSAbs_ElementType myType;
|
||||
int iter;
|
||||
vector<vtkIdType> cellList;
|
||||
|
||||
public:
|
||||
SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) :
|
||||
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
|
||||
struct InverseIterator: public SMDS_ElemIterator
|
||||
{
|
||||
if ( ncells )
|
||||
const SMDS_Mesh* myMesh;
|
||||
size_t myIter;
|
||||
std::vector<vtkIdType> myCellList;
|
||||
|
||||
InverseIterator(const SMDS_Mesh * mesh = 0,
|
||||
const vtkIdType* cells = 0,
|
||||
const int ncells = 0,
|
||||
SMDSAbs_ElementType type = SMDSAbs_All)
|
||||
: myMesh(mesh), myIter(0)
|
||||
{
|
||||
cellList.reserve( ncells );
|
||||
if (type == SMDSAbs_All)
|
||||
if ( ncells )
|
||||
{
|
||||
cellList.assign( cells, cells + ncells );
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < ncells; i++)
|
||||
myCellList.reserve( ncells );
|
||||
if (type == SMDSAbs_All)
|
||||
{
|
||||
int vtkId = cells[i];
|
||||
int smdsId = myMesh->fromVtkToSmds(vtkId);
|
||||
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
|
||||
if (elem->GetType() == type)
|
||||
myCellList.assign( cells, cells + ncells );
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < ncells; i++)
|
||||
{
|
||||
cellList.push_back(vtkId);
|
||||
int vtkId = cells[i];
|
||||
int smdsId = myMesh->FromVtkToSmds( vtkId );
|
||||
const SMDS_MeshElement* elem = myMesh->FindElement( smdsId );
|
||||
if ( elem->GetType() == type )
|
||||
{
|
||||
myCellList.push_back(vtkId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myCells = cellList.empty() ? 0 : &cellList[0];
|
||||
myNcells = cellList.size();
|
||||
}
|
||||
}
|
||||
|
||||
bool more()
|
||||
{
|
||||
return (iter < myNcells);
|
||||
}
|
||||
|
||||
const SMDS_MeshElement* next()
|
||||
{
|
||||
int vtkId = myCells[iter];
|
||||
int smdsId = myMesh->fromVtkToSmds(vtkId);
|
||||
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
|
||||
if (!elem)
|
||||
bool more()
|
||||
{
|
||||
MESSAGE("SMDS_MeshNode_MyInvIterator problem Null element");
|
||||
throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
|
||||
return ( myIter < myCellList.size() );
|
||||
}
|
||||
iter++;
|
||||
return elem;
|
||||
}
|
||||
};
|
||||
|
||||
const SMDS_MeshElement* next()
|
||||
{
|
||||
int vtkId = myCellList[ myIter++ ];
|
||||
int smdsId = myMesh->FromVtkToSmds( vtkId );
|
||||
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
|
||||
if (!elem)
|
||||
{
|
||||
MESSAGE("InverseIterator problem Null element");
|
||||
throw SALOME_Exception("InverseIterator problem Null element");
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
/*!
|
||||
* \brief Iterator on a node
|
||||
*/
|
||||
//=======================================================================
|
||||
|
||||
template< class ELEM_ITERATOR >
|
||||
struct Iterator : public ELEM_ITERATOR
|
||||
{
|
||||
typedef typename ELEM_ITERATOR::value_type element_type;
|
||||
const SMDS_MeshNode* myNode;
|
||||
|
||||
Iterator( const SMDS_MeshNode* n ): myNode( n ) {}
|
||||
|
||||
virtual bool more()
|
||||
{
|
||||
return myNode;
|
||||
}
|
||||
virtual element_type next()
|
||||
{
|
||||
element_type res = static_cast<element_type>( myNode );
|
||||
myNode = 0;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
if ( SMDS_Mesh::_meshList[myMeshId]->NbElements() > 0 ) // avoid building links
|
||||
if ( GetMesh()->NbElements() > 0 ) // avoid building links
|
||||
{
|
||||
vtkCellLinks::Link& l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
|
||||
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
|
||||
vtkCellLinks::Link& l = getGrid()->GetLinks()->GetLink( GetVtkID() );
|
||||
return boost::make_shared< InverseIterator >( GetMesh(), l.cells, l.ncells, type );
|
||||
}
|
||||
else
|
||||
{
|
||||
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], 0, 0, type));
|
||||
return boost::make_shared< InverseIterator >();
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_MeshNode::elementsIterator(SMDSAbs_ElementType type) const
|
||||
SMDS_ElemIteratorPtr SMDS_MeshNode::nodesIterator() const
|
||||
{
|
||||
if ( type == SMDSAbs_Node )
|
||||
return SMDS_MeshElement::elementsIterator( SMDSAbs_Node );
|
||||
else
|
||||
return GetInverseElementIterator( type );
|
||||
return boost::make_shared< Iterator< SMDS_ElemIterator > >( this );
|
||||
}
|
||||
|
||||
int SMDS_MeshNode::NbNodes() const
|
||||
SMDS_NodeIteratorPtr SMDS_MeshNode::nodeIterator() const
|
||||
{
|
||||
return 1;
|
||||
return boost::make_shared< Iterator< SMDS_NodeIterator > >( this );
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_MeshNode::GetNode(const int ind) const
|
||||
{
|
||||
return ind == 0 ? this : 0;
|
||||
}
|
||||
|
||||
double* SMDS_MeshNode::getCoord() const
|
||||
{
|
||||
return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID);
|
||||
return getGrid()->GetPoint( GetVtkID() );
|
||||
}
|
||||
|
||||
double SMDS_MeshNode::X() const
|
||||
@ -246,41 +239,30 @@ double SMDS_MeshNode::Z() const
|
||||
|
||||
void SMDS_MeshNode::GetXYZ(double xyz[3]) const
|
||||
{
|
||||
return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID,xyz);
|
||||
return getGrid()->GetPoint( GetVtkID(), xyz );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
void SMDS_MeshNode::setXYZ(double x, double y, double z)
|
||||
void SMDS_MeshNode::setXYZ( double x, double y, double z )
|
||||
{
|
||||
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
|
||||
vtkPoints *points = mesh->getGrid()->GetPoints();
|
||||
points->InsertPoint(myVtkID, x, y, z);
|
||||
mesh->adjustBoundingBox(x, y, z);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshNode::GetType() const
|
||||
{
|
||||
return SMDSAbs_Node;
|
||||
}
|
||||
|
||||
vtkIdType SMDS_MeshNode::GetVtkType() const
|
||||
{
|
||||
return VTK_VERTEX;
|
||||
vtkPoints *points = getGrid()->GetPoints();
|
||||
points->InsertPoint( GetVtkID(), x, y, z );
|
||||
//GetMesh()->adjustBoundingBox(x, y, z);
|
||||
GetMesh()->setMyModified();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddInverseElement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
||||
void SMDS_MeshNode::AddInverseElement( const SMDS_MeshElement* elem )
|
||||
{
|
||||
SMDS_UnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
SMDS_UnstructuredGrid* grid = getGrid();
|
||||
if ( grid->HasLinks() )
|
||||
{
|
||||
vtkCellLinks *Links = grid->GetLinks();
|
||||
Links->ResizeCellList(myVtkID, 1);
|
||||
Links->AddCellReference(ME->getVtkId(), myVtkID);
|
||||
Links->ResizeCellList( GetVtkID(), 1 );
|
||||
Links->AddCellReference( elem->GetVtkID(), GetVtkID() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,7 +272,7 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
||||
//=======================================================================
|
||||
void SMDS_MeshNode::ClearInverseElements()
|
||||
{
|
||||
SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myVtkID, 0);
|
||||
getGrid()->ResizeCellList( GetVtkID(), 0);
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -302,17 +284,17 @@ void SMDS_MeshNode::ClearInverseElements()
|
||||
int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const
|
||||
{
|
||||
int nb = 0;
|
||||
if ( SMDS_Mesh::_meshList[myMeshId]->NbElements() > 0 ) // avoid building links
|
||||
SMDS_Mesh *mesh = GetMesh();
|
||||
if ( mesh->NbElements() > 0 ) // avoid building links
|
||||
{
|
||||
vtkCellLinks::Link& l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
|
||||
vtkCellLinks::Link& l = mesh->GetGrid()->GetLinks()->GetLink( GetVtkID() );
|
||||
|
||||
if ( type == SMDSAbs_All )
|
||||
return l.ncells;
|
||||
|
||||
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
|
||||
for ( int i = 0; i < l.ncells; i++ )
|
||||
{
|
||||
const SMDS_MeshElement* elem = mesh->FindElement( mesh->fromVtkToSmds( l.cells[i] ));
|
||||
const SMDS_MeshElement* elem = mesh->FindElement( mesh->FromVtkToSmds( l.cells[i] ));
|
||||
nb += ( elem->GetType() == type );
|
||||
}
|
||||
}
|
||||
|
@ -31,50 +31,53 @@
|
||||
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_Position.hxx"
|
||||
#include "ObjectPool.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshNode: public SMDS_MeshElement
|
||||
{
|
||||
public:
|
||||
friend class SMESHDS_Mesh;
|
||||
friend class SMDS_Mesh;
|
||||
friend class ObjectPool<SMDS_MeshNode>;
|
||||
friend class SMDS_VtkFace;
|
||||
public:
|
||||
|
||||
void Print(std::ostream & OS) const;
|
||||
void setXYZ(double x, double y, double z);
|
||||
double X() const; // ! NOT thread safe methods !
|
||||
double Y() const;
|
||||
double Z() const;
|
||||
void GetXYZ(double xyz[3]) const; // thread safe getting coords
|
||||
|
||||
SMDS_ElemIteratorPtr GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
|
||||
int NbInverseElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
|
||||
const SMDS_PositionPtr& GetPosition() const;
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
|
||||
SMDS_PositionPtr GetPosition() const; // WARNING result is std::unique_ptr !
|
||||
void SetPosition(const SMDS_PositionPtr& aPos, int shapeID = 0 );
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Node; }
|
||||
virtual VTKCellType GetVtkType() const { return VTK_VERTEX; }
|
||||
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Node;}
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_NONE; }
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbNodes() const { return 1; }
|
||||
virtual int NbEdges() const { return 0; }
|
||||
virtual int NbFaces() const { return 0; }
|
||||
|
||||
void SetPosition(const SMDS_PositionPtr& aPos);
|
||||
void setXYZ(double x, double y, double z);
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
|
||||
static int nbNodes;
|
||||
virtual bool IsPoly() const { return false; }
|
||||
virtual bool IsQuadratic() const { return false; }
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const { return false; }
|
||||
virtual int NbCornerNodes() const { return 1; }
|
||||
|
||||
void Print(std::ostream & OS) const;
|
||||
|
||||
private:
|
||||
|
||||
void init(double x=0, double y=0, double z=0);
|
||||
|
||||
protected:
|
||||
SMDS_MeshNode();
|
||||
SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
|
||||
virtual ~SMDS_MeshNode();
|
||||
void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
|
||||
double* getCoord() const;
|
||||
void AddInverseElement(const SMDS_MeshElement * ME);
|
||||
void RemoveInverseElement(const SMDS_MeshElement * parent);
|
||||
void AddInverseElement (const SMDS_MeshElement * elem);
|
||||
void RemoveInverseElement(const SMDS_MeshElement * elem);
|
||||
void ClearInverseElements();
|
||||
|
||||
SMDS_ElemIteratorPtr
|
||||
elementsIterator(SMDSAbs_ElementType type) const;
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
private:
|
||||
SMDS_PositionPtr myPosition;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,161 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// File : SMDS_MeshNodeIDFactory.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_MeshNodeIDFactory.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
#include <vtkCellType.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_MeshNodeIDFactory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDS_MeshNodeIDFactory::SMDS_MeshNodeIDFactory() :
|
||||
SMDS_MeshIDFactory(), myMin(0), myMax(0)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BindID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool SMDS_MeshNodeIDFactory::BindID(int ID, SMDS_MeshElement * elem)
|
||||
{
|
||||
updateMinMax(ID);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MeshElement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
|
||||
{
|
||||
// commented since myMax can be 0 after ReleaseID()
|
||||
// if ((ID < 1) || (ID > myMax))
|
||||
// return NULL;
|
||||
const SMDS_MeshElement* elem = GetMesh()->FindNode(ID);
|
||||
return (SMDS_MeshElement*) (elem);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFreeID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_MeshNodeIDFactory::GetFreeID()
|
||||
{
|
||||
int ID;
|
||||
do {
|
||||
ID = SMDS_MeshIDFactory::GetFreeID();
|
||||
} while ( MeshElement( ID ));
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReleaseID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_MeshNodeIDFactory::ReleaseID(const int ID, int vtkId)
|
||||
{
|
||||
SMDS_MeshIDFactory::ReleaseID(ID);
|
||||
myMesh->setMyModified();
|
||||
if (ID == myMax)
|
||||
myMax = 0; // --- force updateMinMax
|
||||
if (ID == myMin)
|
||||
myMax = 0; // --- force updateMinMax
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMaxID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_MeshNodeIDFactory::GetMaxID() const
|
||||
{
|
||||
if (myMax == 0)
|
||||
updateMinMax();
|
||||
return myMax;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMinID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_MeshNodeIDFactory::GetMinID() const
|
||||
{
|
||||
if (myMax == 0)
|
||||
updateMinMax();
|
||||
return myMin;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : updateMinMax
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_MeshNodeIDFactory::updateMinMax() const
|
||||
{
|
||||
myMin = INT_MAX;
|
||||
myMax = 0;
|
||||
for (size_t i = 0; i < myMesh->myNodes.size(); i++)
|
||||
{
|
||||
if (myMesh->myNodes[i])
|
||||
{
|
||||
int id = myMesh->myNodes[i]->GetID();
|
||||
if (id > myMax)
|
||||
myMax = id;
|
||||
if (id < myMin)
|
||||
myMin = id;
|
||||
}
|
||||
}
|
||||
if (myMin == INT_MAX)
|
||||
myMin = 0;
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_MeshNodeIDFactory::elementsIterator() const
|
||||
{
|
||||
return myMesh->elementsIterator(SMDSAbs_Node);
|
||||
}
|
||||
|
||||
void SMDS_MeshNodeIDFactory::Clear()
|
||||
{
|
||||
myMin = myMax = 0;
|
||||
SMDS_MeshIDFactory::Clear();
|
||||
}
|
||||
|
||||
void SMDS_MeshNodeIDFactory::emptyPool(int maxId)
|
||||
{
|
||||
SMDS_MeshIDFactory::emptyPool(maxId);
|
||||
myMax = maxId;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// File : SMDS_MeshElementIDFactory.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_MeshNodeIDFactory_HeaderFile
|
||||
#define _SMDS_MeshNodeIDFactory_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshIDFactory.hxx"
|
||||
#include "SMDS_ElemIterator.hxx"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class SMDS_MeshElement;
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshNodeIDFactory: public SMDS_MeshIDFactory
|
||||
{
|
||||
public:
|
||||
SMDS_MeshNodeIDFactory();
|
||||
bool BindID(int ID, SMDS_MeshElement * elem);
|
||||
SMDS_MeshElement * MeshElement(int ID);
|
||||
virtual int GetFreeID();
|
||||
virtual void ReleaseID(int ID, int vtkId = -1);
|
||||
int GetMaxID() const;
|
||||
int GetMinID() const;
|
||||
SMDS_ElemIteratorPtr elementsIterator() const;
|
||||
virtual void Clear();
|
||||
virtual void emptyPool(int maxId);
|
||||
|
||||
protected:
|
||||
virtual void updateMinMax() const;
|
||||
void updateMinMax(int id) const
|
||||
{
|
||||
if (id > myMax)
|
||||
myMax = id;
|
||||
if (id < myMin)
|
||||
myMin = id;
|
||||
}
|
||||
|
||||
mutable int myMin, myMax;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -25,18 +25,244 @@
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDSAbs_ElementType SMDS_MeshVolume::GetType() const
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
// init a polyherdon
|
||||
void SMDS_MeshVolume::init( const std::vector<const SMDS_MeshNode*>& nodes,
|
||||
const std::vector<int>& nbNodesPerFace )
|
||||
{
|
||||
return SMDSAbs_Volume;
|
||||
std::vector<vtkIdType> ptIds;
|
||||
ptIds.reserve( nodes.size() + nbNodesPerFace.size() + 1 );
|
||||
|
||||
size_t nbFaces = nbNodesPerFace.size();
|
||||
for ( size_t iN = 0, iF = 0; iF < nbFaces; iF++ )
|
||||
{
|
||||
int nf = nbNodesPerFace[iF];
|
||||
ptIds.push_back(nf);
|
||||
for (int n = 0; n < nf; n++)
|
||||
ptIds.push_back( nodes[ iN++ ]->GetVtkID() );
|
||||
}
|
||||
|
||||
int vtkID = getGrid()->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
|
||||
setVtkID( vtkID );
|
||||
}
|
||||
|
||||
vtkIdType SMDS_MeshVolume::GetVtkType() const
|
||||
void SMDS_MeshVolume::init( const std::vector<vtkIdType>& vtkNodeIds )
|
||||
{
|
||||
return VTK_CONVEX_POINT_SET; // --- must be reimplemented in derived classes
|
||||
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
|
||||
switch ( vtkNodeIds.size()) // cases are in order of usage frequency
|
||||
{
|
||||
case 4: aType = SMDSEntity_Tetra; break;
|
||||
case 5: aType = SMDSEntity_Pyramid; break;
|
||||
case 8: aType = SMDSEntity_Hexa; break;
|
||||
case 6: aType = SMDSEntity_Penta; break;
|
||||
case 10: aType = SMDSEntity_Quad_Tetra; break;
|
||||
case 20: aType = SMDSEntity_Quad_Hexa; break;
|
||||
case 13: aType = SMDSEntity_Quad_Pyramid; break;
|
||||
case 27: aType = SMDSEntity_TriQuad_Hexa; break;
|
||||
case 15: aType = SMDSEntity_Quad_Penta; break;
|
||||
case 18: aType = SMDSEntity_BiQuad_Penta; break;
|
||||
case 12: aType = SMDSEntity_Hexagonal_Prism; break;
|
||||
default: throw SALOME_Exception("wrong volume nodes");
|
||||
}
|
||||
SMDS_MeshCell::init( aType, vtkNodeIds );
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_MeshVolume::GetNode(const int ind) const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::GetNode( ind );
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
int id = 0, nbPoints = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
if ( ind < nbPoints + nodesInFace )
|
||||
return GetMesh()->FindNodeVtk( ptIds[ ind + i ]);
|
||||
nbPoints += nodesInFace;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int SMDS_MeshVolume::NbNodes() const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::NbNodes();
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
int id = 0, nbPoints = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
nbPoints += nodesInFace;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
return nbPoints;
|
||||
}
|
||||
|
||||
int SMDS_MeshVolume::NbFaces() const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::NbFaces();
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
return nFaces;
|
||||
|
||||
}
|
||||
int SMDS_MeshVolume::NbEdges() const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::NbEdges();
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
int id = 0, nbEdges = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int edgesInFace = ptIds[id];
|
||||
id += (edgesInFace + 1);
|
||||
nbEdges += edgesInFace;
|
||||
}
|
||||
nbEdges = nbEdges / 2;
|
||||
return nbEdges;
|
||||
}
|
||||
|
||||
int SMDS_MeshVolume::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::GetNodeIndex( node );
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
int id = 0;
|
||||
for (int iF = 0; iF < nFaces; iF++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
for ( vtkIdType i = 0; i < nodesInFace; ++i )
|
||||
if ( ptIds[id+i+1] == node->GetVtkID() )
|
||||
return id+i-iF;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
bool SMDS_MeshVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SMDS_MeshVolume::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::IsMediumNode( node );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int SMDS_MeshVolume::NbCornerNodes() const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::NbCornerNodes();
|
||||
|
||||
return NbNodes();
|
||||
}
|
||||
|
||||
int SMDS_MeshVolume::NbFaceNodes (const int face_ind) const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_VolumeTool( this ).NbFaceNodes( face_ind-1 );
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
int id = 0, nbNodes = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
id += (nodesInFace + 1);
|
||||
if (i == face_ind - 1)
|
||||
{
|
||||
nbNodes = nodesInFace;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nbNodes;
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_MeshVolume::GetFaceNode (const int face_ind, const int node_ind) const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_VolumeTool( this ).GetFaceNodes( face_ind-1 )[ node_ind - 1 ];
|
||||
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds);
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
|
||||
if (i == face_ind - 1) // first face is number 1
|
||||
{
|
||||
if ((node_ind > 0) && (node_ind <= nodesInFace))
|
||||
return GetMesh()->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node
|
||||
}
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<int> SMDS_MeshVolume::GetQuantities() const
|
||||
{
|
||||
std::vector<int> quantities;
|
||||
if ( IsPoly() )
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
|
||||
quantities.push_back( nodesInFace );
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
}
|
||||
return quantities;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on nodes owned by the element.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_ElemIteratorPtr SMDS_MeshVolume::nodesIterator() const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::nodesIterator();
|
||||
|
||||
return boost::make_shared< SMDS_VtkCellIteratorPolyH<> >( GetMesh(), GetVtkID(), GetEntityType());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an iterator which iterate on nodes owned by the element.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_NodeIteratorPtr SMDS_MeshVolume::nodeIterator() const
|
||||
{
|
||||
if ( !IsPoly() )
|
||||
return SMDS_MeshCell::nodeIterator();
|
||||
|
||||
return boost::make_shared< SMDS_VtkCellIteratorPolyH< SMDS_NodeIterator> >( GetMesh(), GetVtkID(), GetEntityType());
|
||||
}
|
||||
|
@ -31,11 +31,42 @@
|
||||
|
||||
#include "SMDS_MeshCell.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshVolume:public SMDS_MeshCell
|
||||
/*!
|
||||
* \brief Mesh volume. This type is not allocated.
|
||||
* It is only used as function argument type to provide more clear semantic
|
||||
* and to provide API specific to polyherdal volume
|
||||
*/
|
||||
class SMDS_EXPORT SMDS_MeshVolume : public SMDS_MeshCell
|
||||
{
|
||||
|
||||
public:
|
||||
SMDSAbs_ElementType GetType() const;
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
void init( const std::vector<const SMDS_MeshNode*>& nodes,
|
||||
const std::vector<int>& nbNodesPerFace ); // init a polyherdon
|
||||
|
||||
void init( const std::vector<vtkIdType>& vtkNodeIds );
|
||||
|
||||
friend class SMDS_Mesh;
|
||||
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbFaces() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
virtual int NbCornerNodes() const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const = 0;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const = 0;
|
||||
|
||||
// 1 <= face_ind <= NbFaces()
|
||||
int NbFaceNodes (const int face_ind) const;
|
||||
// 1 <= face_ind <= NbFaces()
|
||||
// 1 <= node_ind <= NbFaceNodes()
|
||||
const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
|
||||
|
||||
std::vector<int> GetQuantities() const;
|
||||
|
||||
static SMDSAbs_ElementType Type() { return SMDSAbs_Volume; }
|
||||
};
|
||||
#endif
|
||||
|
@ -28,22 +28,20 @@
|
||||
|
||||
#include "SMDS_PolygonalFaceOfNodes.hxx"
|
||||
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
using namespace std;
|
||||
#include <utilities.h>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes
|
||||
(const std::vector<const SMDS_MeshNode *>& nodes)
|
||||
SMDS_PolygonalFaceOfNodes::
|
||||
SMDS_PolygonalFaceOfNodes (const std::vector<const SMDS_MeshNode *>& nodes)
|
||||
{
|
||||
//MESSAGE("******************************************** SMDS_PolygonalFaceOfNodes");
|
||||
myNodes = nodes;
|
||||
}
|
||||
|
||||
@ -54,41 +52,40 @@ SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes
|
||||
SMDSAbs_ElementType SMDS_PolygonalFaceOfNodes::GetType() const
|
||||
{
|
||||
return SMDSAbs_Face;
|
||||
//return SMDSAbs_PolygonalFace;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool SMDS_PolygonalFaceOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes)
|
||||
{
|
||||
if (nodes.size() < 3)
|
||||
return false;
|
||||
// bool SMDS_PolygonalFaceOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes)
|
||||
// {
|
||||
// if (nodes.size() < 3)
|
||||
// return false;
|
||||
|
||||
myNodes = nodes;
|
||||
// myNodes = nodes;
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose : to support the same interface, as SMDS_FaceOfNodes
|
||||
//=======================================================================
|
||||
bool SMDS_PolygonalFaceOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes)
|
||||
{
|
||||
if (nbNodes < 3)
|
||||
return false;
|
||||
// bool SMDS_PolygonalFaceOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
|
||||
// const int nbNodes)
|
||||
// {
|
||||
// if (nbNodes < 3)
|
||||
// return false;
|
||||
|
||||
myNodes.resize(nbNodes);
|
||||
int i = 0;
|
||||
for (; i < nbNodes; i++) {
|
||||
myNodes[i] = nodes[i];
|
||||
}
|
||||
// myNodes.resize(nbNodes);
|
||||
// int i = 0;
|
||||
// for (; i < nbNodes; i++) {
|
||||
// myNodes[i] = nodes[i];
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : NbNodes
|
||||
@ -130,65 +127,12 @@ void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const
|
||||
OS << myNodes[i] << ") " << endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_NodeVectorElemIterator
|
||||
{
|
||||
public:
|
||||
SMDS_PolygonalFaceOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
|
||||
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
|
||||
};
|
||||
|
||||
/// ===================================================================
|
||||
/*!
|
||||
* \brief Iterator on edges of face
|
||||
*/
|
||||
/// ===================================================================
|
||||
|
||||
class _MyEdgeIterator : public SMDS_ElemIterator
|
||||
{
|
||||
vector< const SMDS_MeshElement* > myElems;
|
||||
size_t myIndex;
|
||||
public:
|
||||
_MyEdgeIterator(const SMDS_MeshFace* face):myIndex(0) {
|
||||
myElems.reserve( face->NbNodes() );
|
||||
for ( int i = 0; i < face->NbNodes(); ++i ) {
|
||||
const SMDS_MeshElement* edge =
|
||||
SMDS_Mesh::FindEdge( face->GetNode( i ), face->GetNodeWrap( i + 1 ));
|
||||
if ( edge )
|
||||
myElems.push_back( edge );
|
||||
}
|
||||
}
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more() { return myIndex < myElems.size(); }
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
|
||||
(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes));
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new _MyEdgeIterator( this ));
|
||||
break;
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type,SMDS_ElemIteratorPtr
|
||||
(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes))));
|
||||
}
|
||||
return SMDS_ElemIteratorPtr();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
@ -198,3 +142,13 @@ const SMDS_MeshNode* SMDS_PolygonalFaceOfNodes::GetNode(const int ind) const
|
||||
{
|
||||
return myNodes[ WrappedIndex( ind )];
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::nodesIterator() const
|
||||
{
|
||||
return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_PolygonalFaceOfNodes::nodeIterator() const
|
||||
{
|
||||
return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
@ -27,15 +27,9 @@
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
//#include "SMDS_FaceOfNodes.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Iterator.hxx"
|
||||
#include "SMDS_CellOfNodes.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//class SMDS_PolygonalFaceOfNodes:public SMDS_FaceOfNodes
|
||||
class SMDS_EXPORT SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
|
||||
class SMDS_EXPORT SMDS_PolygonalFaceOfNodes : public SMDS_CellOfNodes
|
||||
{
|
||||
public:
|
||||
SMDS_PolygonalFaceOfNodes (const std::vector<const SMDS_MeshNode *>& nodes);
|
||||
@ -43,13 +37,10 @@ class SMDS_EXPORT SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Polygon; }
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_POLYGON; }
|
||||
virtual bool IsPoly() const { return true; };
|
||||
|
||||
bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes);
|
||||
|
||||
bool ChangeNodes (const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
// to support the same interface, as SMDS_FaceOfNodes
|
||||
virtual bool IsPoly() const { return true; }
|
||||
virtual bool IsQuadratic() const { return false; }
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const { return false; }
|
||||
virtual int NbCornerNodes() const { return NbNodes(); }
|
||||
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
@ -57,15 +48,12 @@ class SMDS_EXPORT SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
|
||||
|
||||
virtual void Print (std::ostream & OS) const;
|
||||
|
||||
/*!
|
||||
* \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;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
|
||||
protected:
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
|
||||
|
||||
std::vector<const SMDS_MeshNode *> myNodes;
|
||||
};
|
||||
|
@ -1,265 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Create a volume of many faces
|
||||
//=======================================================================
|
||||
SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes
|
||||
(vector<const SMDS_MeshNode *> nodes,
|
||||
vector<int> quantities)
|
||||
: SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL)
|
||||
{
|
||||
//MESSAGE("****************************************** SMDS_PolyhedralVolumeOfNodes");
|
||||
ChangeNodes(nodes, quantities);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetType
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
SMDSAbs_ElementType SMDS_PolyhedralVolumeOfNodes::GetType() const
|
||||
{
|
||||
// return SMDSAbs_PolyhedralVolume;
|
||||
return SMDSAbs_Volume;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (const vector<const SMDS_MeshNode *>& nodes,
|
||||
const vector<int>& quantities)
|
||||
{
|
||||
myNodesByFaces = nodes;
|
||||
myQuantities = quantities;
|
||||
|
||||
// Init fields of parent class, it allows to get only unique nodes(?)
|
||||
|
||||
set<const SMDS_MeshNode *> aSet;
|
||||
aSet.insert( nodes.begin(), nodes.end());
|
||||
//SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes);
|
||||
delete [] myNodes;
|
||||
myNbNodes = aSet.size();
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
set<const SMDS_MeshNode *>::iterator anIter = aSet.begin();
|
||||
for (int k=0; anIter != aSet.end(); anIter++, k++)
|
||||
myNodes[k] = *anIter;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_PolyhedralVolumeOfNodes::NbNodes() const
|
||||
{
|
||||
return myNodesByFaces.size();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_PolyhedralVolumeOfNodes::NbEdges() const
|
||||
{
|
||||
int nbEdges = 0;
|
||||
|
||||
for ( size_t ifa = 0; ifa < myQuantities.size(); ifa++) {
|
||||
nbEdges += myQuantities[ifa];
|
||||
}
|
||||
nbEdges /= 2;
|
||||
|
||||
return nbEdges;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_PolyhedralVolumeOfNodes::NbFaces() const
|
||||
{
|
||||
return myQuantities.size();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFaceNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_PolyhedralVolumeOfNodes::NbFaceNodes (const int face_ind) const
|
||||
{
|
||||
if (face_ind < 1 || (int)myQuantities.size() < face_ind)
|
||||
return 0;
|
||||
return myQuantities[face_ind - 1];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFaceNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const SMDS_MeshNode* SMDS_PolyhedralVolumeOfNodes::GetFaceNode (const int face_ind,
|
||||
const int node_ind) const
|
||||
{
|
||||
if (node_ind < 1 || NbFaceNodes(face_ind) < node_ind)
|
||||
return NULL;
|
||||
|
||||
int i, first_node = 0;
|
||||
for (i = 0; i < face_ind - 1; i++) {
|
||||
first_node += myQuantities[i];
|
||||
}
|
||||
|
||||
return myNodesByFaces[first_node + node_ind - 1];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_PolyhedralVolumeOfNodes::Print (ostream & OS) const
|
||||
{
|
||||
OS << "polyhedral volume <" << GetID() << "> : ";
|
||||
|
||||
int faces_len = myQuantities.size();
|
||||
//int nodes_len = myNodesByFaces.size();
|
||||
int cur_first_node = 0;
|
||||
|
||||
int i, j;
|
||||
for (i = 0; i < faces_len; i++) {
|
||||
OS << "face_" << i << " (";
|
||||
for (j = 0; j < myQuantities[i] - 1; j++) {
|
||||
OS << myNodesByFaces[cur_first_node + j] << ",";
|
||||
}
|
||||
OS << myNodesByFaces[cur_first_node + j] << ") ";
|
||||
cur_first_node += myQuantities[i];
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose : usage disabled
|
||||
//=======================================================================
|
||||
bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ===================================================================
|
||||
/*!
|
||||
* \brief Iterator on node of volume
|
||||
*/
|
||||
/// ===================================================================
|
||||
|
||||
struct _MyIterator:public SMDS_NodeVectorElemIterator
|
||||
{
|
||||
_MyIterator(const vector<const SMDS_MeshNode *>& nodes):
|
||||
SMDS_NodeVectorElemIterator( nodes.begin(), nodes.end()) {}
|
||||
};
|
||||
|
||||
/// ===================================================================
|
||||
/*!
|
||||
* \brief Iterator on faces or edges of volume
|
||||
*/
|
||||
/// ===================================================================
|
||||
|
||||
class _MySubIterator : public SMDS_ElemIterator
|
||||
{
|
||||
vector< const SMDS_MeshElement* > myElems;
|
||||
size_t myIndex;
|
||||
public:
|
||||
_MySubIterator(const SMDS_MeshVolume* vol, SMDSAbs_ElementType type):myIndex(0) {
|
||||
SMDS_VolumeTool vTool(vol);
|
||||
if (type == SMDSAbs_Face)
|
||||
vTool.GetAllExistingFaces( myElems );
|
||||
else
|
||||
vTool.GetAllExistingEdges( myElems );
|
||||
}
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more() { return myIndex < myElems.size(); }
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
|
||||
};
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return Iterator of sub elements
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_PolyhedralVolumeOfNodes::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Volume:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new _MyIterator(myNodesByFaces));
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_ElemIteratorPtr(new _MySubIterator(this,SMDSAbs_Face));
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new _MySubIterator(this,SMDSAbs_Edge));
|
||||
default:
|
||||
MESSAGE("ERROR : Iterator not implemented");
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return iterator on unique nodes
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_PolyhedralVolumeOfNodes::uniqueNodesIterator() const
|
||||
{
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_NodeArrayElemIterator( myNodes, & myNodes[ myNbNodes ]));
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
const SMDS_MeshNode* SMDS_PolyhedralVolumeOfNodes::GetNode(const int ind) const
|
||||
{
|
||||
return myNodesByFaces[ ind ];
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_PolyhedralVolumeOfNodes.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_PolyhedralVolumeOfNodes_HeaderFile
|
||||
#define _SMDS_PolyhedralVolumeOfNodes_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_VolumeOfNodes.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_PolyhedralVolumeOfNodes:public SMDS_VolumeOfNodes
|
||||
{
|
||||
public:
|
||||
SMDS_PolyhedralVolumeOfNodes (std::vector<const SMDS_MeshNode *> nodes,
|
||||
std::vector<int> quantities);
|
||||
|
||||
//virtual ~SMDS_PolyhedralVolumeOfNodes();
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Polyhedra; }
|
||||
virtual bool IsPoly() const { return true; };
|
||||
|
||||
bool ChangeNodes (const std::vector<const SMDS_MeshNode *> & nodes,
|
||||
const std::vector<int> & quantities);
|
||||
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
|
||||
int NbFaceNodes (const int face_ind) const;
|
||||
// 1 <= face_ind <= NbFaces()
|
||||
|
||||
const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
|
||||
// 1 <= face_ind <= NbFaces()
|
||||
// 1 <= node_ind <= NbFaceNodes()
|
||||
|
||||
const std::vector<int> & GetQuanities() const { return myQuantities; }
|
||||
|
||||
virtual void Print (std::ostream & OS) const;
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
*/
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
|
||||
/*!
|
||||
* \brief Return iterator on unique nodes
|
||||
*/
|
||||
SMDS_ElemIteratorPtr uniqueNodesIterator() const;
|
||||
/*!
|
||||
* \brief Return nb of unique nodes
|
||||
*/
|
||||
int NbUniqueNodes() const { return myNbNodes; }
|
||||
|
||||
protected:
|
||||
SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
|
||||
private:
|
||||
// usage disabled
|
||||
bool ChangeNodes (const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
|
||||
private:
|
||||
std::vector<const SMDS_MeshNode *> myNodesByFaces;
|
||||
std::vector<int> myQuantities;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,58 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_Position.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#include "SMDS_Position.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_Position
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_Position::SMDS_Position()
|
||||
{
|
||||
//MESSAGE("########################## SMDS_Position ");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDim
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_Position::GetDim() const
|
||||
{
|
||||
// switch ( GetTypeOfPosition() ) {
|
||||
// case SMDS_TOP_UNSPEC: return -1;
|
||||
// case SMDS_TOP_VERTEX: return 0;
|
||||
// case SMDS_TOP_EDGE: return 1;
|
||||
// case SMDS_TOP_FACE: return 2;
|
||||
// case SMDS_TOP_3DSPACE: return 3;
|
||||
// }
|
||||
return GetTypeOfPosition();
|
||||
}
|
||||
|
||||
|
@ -30,23 +30,68 @@
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_TypeOfPosition.hxx"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <memory>
|
||||
|
||||
class SMDS_Position;
|
||||
//class SMDS_Position;
|
||||
//typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
|
||||
typedef SMDS_Position* SMDS_PositionPtr;
|
||||
//typedef SMDS_Position* SMDS_PositionPtr;
|
||||
|
||||
class SMDS_EXPORT SMDS_Position
|
||||
{
|
||||
|
||||
public:
|
||||
virtual SMDS_TypeOfPosition GetTypeOfPosition() const = 0;
|
||||
virtual int GetDim() const;
|
||||
virtual ~SMDS_Position() {}
|
||||
|
||||
protected:
|
||||
SMDS_Position();
|
||||
public:
|
||||
virtual SMDS_TypeOfPosition GetTypeOfPosition() const = 0;
|
||||
int GetDim() const { return GetTypeOfPosition(); }
|
||||
virtual const double* GetParameters() const = 0;
|
||||
virtual ~SMDS_Position() {}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Replace "typedef SMDS_Position* SMDS_PositionPtr" by a smart
|
||||
* pointer allowing implicit casting to derived types; e.g.
|
||||
* if ( SMDS_FacePositionPtr fPos = node->GetPosition() )
|
||||
* fPos->SetUParameter(0);
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
class SMDS_EXPORT SMDS_Ptr : public std::unique_ptr< T >
|
||||
{
|
||||
bool myIsOwner;
|
||||
|
||||
public:
|
||||
SMDS_Ptr( T * pos = (T *) 0, bool isOwner=true ):
|
||||
std::unique_ptr< T >( pos ), myIsOwner( isOwner ) {}
|
||||
|
||||
SMDS_Ptr( const SMDS_Ptr& from ) : myIsOwner( from.myIsOwner )
|
||||
{ this->swap( const_cast<SMDS_Ptr&>( from )); }
|
||||
|
||||
SMDS_Ptr& operator=( const SMDS_Ptr& from )
|
||||
{
|
||||
myIsOwner = from.myIsOwner;
|
||||
this->swap( const_cast<SMDS_Ptr&>( from ));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Y>
|
||||
SMDS_Ptr( const SMDS_Ptr< Y >& base ): myIsOwner( true )
|
||||
{
|
||||
if ( const T* p = dynamic_cast<const T*>( base.get() ))
|
||||
{
|
||||
this->reset( const_cast<T*>( p ));
|
||||
this->myIsOwner = base.IsOwner();
|
||||
const_cast< SMDS_Ptr< Y >& >( base ).release();
|
||||
}
|
||||
}
|
||||
~SMDS_Ptr() { if ( !myIsOwner ) this->release(); }
|
||||
|
||||
operator bool () const { return bool( this->get() ); }
|
||||
bool IsOwner() const { return myIsOwner; }
|
||||
};
|
||||
|
||||
class SMDS_EdgePosition;
|
||||
class SMDS_FacePosition;
|
||||
typedef SMDS_Ptr< SMDS_Position > SMDS_PositionPtr;
|
||||
typedef SMDS_Ptr< SMDS_EdgePosition > SMDS_EdgePositionPtr;
|
||||
typedef SMDS_Ptr< SMDS_FacePosition > SMDS_FacePositionPtr;
|
||||
|
||||
#endif
|
||||
|
@ -1,160 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File: SMDS_QuadraticEdge.cxx
|
||||
// Created: 16.01.06 16:25:42
|
||||
// Author: Sergey KUUL
|
||||
//
|
||||
#include "SMDS_QuadraticEdge.hxx"
|
||||
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticEdge::SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node12)
|
||||
:SMDS_LinearEdge(node1,node2)
|
||||
{
|
||||
//MESSAGE("******************************************************* SMDS_QuadraticEdge");
|
||||
myNodes[2]=node12;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_QuadraticEdge::Print(ostream & OS) const
|
||||
{
|
||||
OS << "quadratic edge <" << GetID() << "> : ( first-" << myNodes[0]
|
||||
<< " , last-" << myNodes[1] << " , medium-" << myNodes[2] << ") " << endl;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_QuadraticEdge::NbNodes() const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node12)
|
||||
{
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node12;
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMediumNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_QuadraticEdge::IsMediumNode(const SMDS_MeshNode * node) const
|
||||
{
|
||||
return (myNodes[2]==node);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//=======================================================================
|
||||
//class : _MyInterlacedNodeIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class _MyInterlacedNodeIterator: public SMDS_NodeArrayIterator
|
||||
{
|
||||
const SMDS_MeshNode * myNodes[3];
|
||||
public:
|
||||
_MyInterlacedNodeIterator(const SMDS_MeshNode * const * nodes):
|
||||
SMDS_NodeArrayIterator( myNodes, & myNodes[3] )
|
||||
{
|
||||
myNodes[0] = nodes[0];
|
||||
myNodes[1] = nodes[2];
|
||||
myNodes[2] = nodes[1];
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//class : _MyNodeIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class _MyNodeIterator:public SMDS_NodeArrayElemIterator
|
||||
{
|
||||
public:
|
||||
_MyNodeIterator(const SMDS_MeshNode * const * nodes):
|
||||
SMDS_NodeArrayElemIterator( nodes, & nodes[3] ) {}
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : interlacedNodesIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_QuadraticEdge::interlacedNodesIterator() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr (new _MyInterlacedNodeIterator (myNodes));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_QuadraticEdge::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes))));
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_QuadraticEdge.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_QuadraticEdge_HeaderFile
|
||||
#define _SMDS_QuadraticEdge_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_LinearEdge.hxx"
|
||||
#include <iostream>
|
||||
|
||||
class SMDS_EXPORT SMDS_QuadraticEdge: public SMDS_LinearEdge
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node12);
|
||||
|
||||
bool ChangeNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node12);
|
||||
|
||||
void Print(std::ostream & OS) const;
|
||||
|
||||
int NbNodes() const;
|
||||
|
||||
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Quad_Edge; }
|
||||
|
||||
virtual bool IsQuadratic() const { return true; }
|
||||
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
|
||||
SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
|
||||
protected:
|
||||
SMDS_ElemIteratorPtr
|
||||
elementsIterator(SMDSAbs_ElementType type) const;
|
||||
|
||||
};
|
||||
#endif
|
@ -1,290 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File: SMDS_QuadraticFaceOfNodes.cxx
|
||||
// Created: 16.01.06 17:12:58
|
||||
// Author: Sergey KUUL
|
||||
//
|
||||
#include "SMDS_QuadraticFaceOfNodes.hxx"
|
||||
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticFaceOfNodes()
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n31)
|
||||
{
|
||||
//MESSAGE("********************************************** SMDS_QuadraticFaceOfNodes 1");
|
||||
myNodes.resize( 6 );
|
||||
myNodes[ 0 ] = n1;
|
||||
myNodes[ 1 ] = n2;
|
||||
myNodes[ 2 ] = n3;
|
||||
myNodes[ 3 ] = n12;
|
||||
myNodes[ 4 ] = n23;
|
||||
myNodes[ 5 ] = n31;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticFaceOfNodes()
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n34,
|
||||
const SMDS_MeshNode * n41)
|
||||
{
|
||||
//MESSAGE("********************************************* SMDS_QuadraticFaceOfNodes 2");
|
||||
myNodes.resize( 8 );
|
||||
myNodes[ 0 ] = n1;
|
||||
myNodes[ 1 ] = n2;
|
||||
myNodes[ 2 ] = n3;
|
||||
myNodes[ 3 ] = n4;
|
||||
myNodes[ 4 ] = n12;
|
||||
myNodes[ 5 ] = n23;
|
||||
myNodes[ 6 ] = n34;
|
||||
myNodes[ 7 ] = n41;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMediumNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_QuadraticFaceOfNodes::IsMediumNode(const SMDS_MeshNode * node) const
|
||||
{
|
||||
int i=NbNodes()/2;
|
||||
for(; i<NbNodes(); i++) {
|
||||
if(myNodes[i]==node) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_QuadraticFaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes)
|
||||
{
|
||||
if( nbNodes==6 || nbNodes==8 ) {
|
||||
myNodes.resize(nbNodes);
|
||||
int i=0;
|
||||
for(; i<nbNodes; i++) {
|
||||
myNodes[i] = nodes[i];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_QuadraticFaceOfNodes::NbNodes() const
|
||||
{
|
||||
return myNodes.size();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_QuadraticFaceOfNodes::NbEdges() const
|
||||
{
|
||||
return NbNodes()/2;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_QuadraticFaceOfNodes::NbFaces() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_QuadraticFaceOfNodes::Print(ostream & OS) const
|
||||
{
|
||||
OS << "quadratic face <" << GetID() << " > : ";
|
||||
int i, nbNodes = myNodes.size();
|
||||
for (i = 0; i < nbNodes - 1; i++)
|
||||
OS << myNodes[i] << ",";
|
||||
OS << myNodes[i] << ") " << endl;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
//=======================================================================
|
||||
//class : _MyInterlacedNodeIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class _MyInterlacedNodeIterator:public SMDS_NodeIterator
|
||||
{
|
||||
const vector<const SMDS_MeshNode *>& mySet;
|
||||
size_t myIndex;
|
||||
const int * myInterlace;
|
||||
public:
|
||||
_MyInterlacedNodeIterator(const vector<const SMDS_MeshNode *>& s,
|
||||
const int * interlace):
|
||||
mySet(s),myIndex(0),myInterlace(interlace) {}
|
||||
|
||||
bool more()
|
||||
{
|
||||
return myIndex < mySet.size();
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* next()
|
||||
{
|
||||
return mySet[ myInterlace[ myIndex++ ]];
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//class : _MyNodeIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class _MyNodeIterator : public SMDS_NodeVectorElemIterator
|
||||
{
|
||||
public:
|
||||
_MyNodeIterator(const vector<const SMDS_MeshNode *>& s):
|
||||
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : interlacedNodesIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_QuadraticFaceOfNodes::interlacedNodesIterator() const
|
||||
{
|
||||
static int triaInterlace [] = { 0, 3, 1, 4, 2, 5 };
|
||||
static int quadInterlace [] = { 0, 4, 1, 5, 2, 6, 3, 7 };
|
||||
return SMDS_NodeIteratorPtr
|
||||
(new _MyInterlacedNodeIterator (myNodes, myNodes.size()==6 ? triaInterlace : quadInterlace));
|
||||
}
|
||||
|
||||
/// ===================================================================
|
||||
/*!
|
||||
* \brief Iterator on edges of face
|
||||
*/
|
||||
/// ===================================================================
|
||||
|
||||
class _MyEdgeIterator : public SMDS_ElemIterator
|
||||
{
|
||||
vector< const SMDS_MeshElement* > myElems;
|
||||
size_t myIndex;
|
||||
public:
|
||||
_MyEdgeIterator(const SMDS_QuadraticFaceOfNodes* face):myIndex(0) {
|
||||
myElems.reserve( face->NbNodes() );
|
||||
SMDS_NodeIteratorPtr nIt = face->interlacedNodesIterator();
|
||||
const SMDS_MeshNode* n0 = face->GetNodeWrap( -1 );
|
||||
while ( nIt->more() ) {
|
||||
const SMDS_MeshNode* n1 = nIt->next();
|
||||
const SMDS_MeshElement* edge = SMDS_Mesh::FindEdge( n0, n1 );
|
||||
if ( edge )
|
||||
myElems.push_back( edge );
|
||||
n0 = n1;
|
||||
}
|
||||
}
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more() { return myIndex < myElems.size(); }
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::elementsIterator
|
||||
(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new _MyEdgeIterator( this ));
|
||||
break;
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type,SMDS_ElemIteratorPtr (new _MyNodeIterator(myNodes))));
|
||||
}
|
||||
return SMDS_ElemIteratorPtr();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
const SMDS_MeshNode* SMDS_QuadraticFaceOfNodes::GetNode(const int ind) const
|
||||
{
|
||||
return myNodes[ ind ];
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_QuadraticFaceOfNodes::GetEntityType() const
|
||||
{
|
||||
return NbNodes() == 6 ? SMDSEntity_Quad_Triangle : SMDSEntity_Quad_Quadrangle;
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_QuadraticVolumeOfNodes.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_QuadraticFaceOfNodes_HeaderFile
|
||||
#define _SMDS_QuadraticFaceOfNodes_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_QuadraticFaceOfNodes:public SMDS_MeshFace
|
||||
{
|
||||
public:
|
||||
SMDS_QuadraticFaceOfNodes (const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n31);
|
||||
|
||||
SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n34,
|
||||
const SMDS_MeshNode * n41);
|
||||
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual bool IsQuadratic() const { return true; }
|
||||
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
|
||||
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
|
||||
virtual void Print (std::ostream & OS) const;
|
||||
|
||||
SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
|
||||
/*!
|
||||
* \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:
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
|
||||
|
||||
private:
|
||||
std::vector<const SMDS_MeshNode *> myNodes;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,389 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File: SMDS_QuadraticVolumeOfNodes.cxx
|
||||
// Created: 17.01.06 09:46:11
|
||||
// Author: Sergey KUUL
|
||||
//
|
||||
#include "SMDS_QuadraticVolumeOfNodes.hxx"
|
||||
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticVolumeOfNodes()
|
||||
//purpose : Constructor tetrahedron of 10 nodes
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
|
||||
(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n31,
|
||||
const SMDS_MeshNode * n14,
|
||||
const SMDS_MeshNode * n24,
|
||||
const SMDS_MeshNode * n34)
|
||||
{
|
||||
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
|
||||
myNodes.resize( 10 );
|
||||
myNodes[ 0 ] = n1;
|
||||
myNodes[ 1 ] = n2;
|
||||
myNodes[ 2 ] = n3;
|
||||
myNodes[ 3 ] = n4;
|
||||
myNodes[ 4 ] = n12;
|
||||
myNodes[ 5 ] = n23;
|
||||
myNodes[ 6 ] = n31;
|
||||
myNodes[ 7 ] = n14;
|
||||
myNodes[ 8 ] = n24;
|
||||
myNodes[ 9 ] = n34;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticVolumeOfNodes()
|
||||
//purpose : Constructor pyramid of 13 nodes
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
|
||||
(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n5,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n34,
|
||||
const SMDS_MeshNode * n41,
|
||||
const SMDS_MeshNode * n15,
|
||||
const SMDS_MeshNode * n25,
|
||||
const SMDS_MeshNode * n35,
|
||||
const SMDS_MeshNode * n45)
|
||||
{
|
||||
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
|
||||
myNodes.resize( 13 );
|
||||
myNodes[ 0 ] = n1;
|
||||
myNodes[ 1 ] = n2;
|
||||
myNodes[ 2 ] = n3;
|
||||
myNodes[ 3 ] = n4;
|
||||
myNodes[ 4 ] = n5;
|
||||
myNodes[ 5 ] = n12;
|
||||
myNodes[ 6 ] = n23;
|
||||
myNodes[ 7 ] = n34;
|
||||
myNodes[ 8 ] = n41;
|
||||
myNodes[ 9 ] = n15;
|
||||
myNodes[ 10 ] = n25;
|
||||
myNodes[ 11 ] = n35;
|
||||
myNodes[ 12 ] = n45;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticVolumeOfNodes()
|
||||
//purpose : Constructor Pentahedron with 15 nodes
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
|
||||
(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n5,
|
||||
const SMDS_MeshNode * n6,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n31,
|
||||
const SMDS_MeshNode * n45,
|
||||
const SMDS_MeshNode * n56,
|
||||
const SMDS_MeshNode * n64,
|
||||
const SMDS_MeshNode * n14,
|
||||
const SMDS_MeshNode * n25,
|
||||
const SMDS_MeshNode * n36)
|
||||
{
|
||||
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
|
||||
myNodes.resize( 15 );
|
||||
myNodes[ 0 ] = n1;
|
||||
myNodes[ 1 ] = n2;
|
||||
myNodes[ 2 ] = n3;
|
||||
myNodes[ 3 ] = n4;
|
||||
myNodes[ 4 ] = n5;
|
||||
myNodes[ 5 ] = n6;
|
||||
myNodes[ 6 ] = n12;
|
||||
myNodes[ 7 ] = n23;
|
||||
myNodes[ 8 ] = n31;
|
||||
myNodes[ 9 ] = n45;
|
||||
myNodes[ 10 ] = n56;
|
||||
myNodes[ 11 ] = n64;
|
||||
myNodes[ 12 ] = n14;
|
||||
myNodes[ 13 ] = n25;
|
||||
myNodes[ 14 ] = n36;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_QuadraticVolumeOfNodes()
|
||||
//purpose : Constructor Hexahedrons with 20 nodes
|
||||
//=======================================================================
|
||||
|
||||
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
|
||||
(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n5,
|
||||
const SMDS_MeshNode * n6,
|
||||
const SMDS_MeshNode * n7,
|
||||
const SMDS_MeshNode * n8,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n34,
|
||||
const SMDS_MeshNode * n41,
|
||||
const SMDS_MeshNode * n56,
|
||||
const SMDS_MeshNode * n67,
|
||||
const SMDS_MeshNode * n78,
|
||||
const SMDS_MeshNode * n85,
|
||||
const SMDS_MeshNode * n15,
|
||||
const SMDS_MeshNode * n26,
|
||||
const SMDS_MeshNode * n37,
|
||||
const SMDS_MeshNode * n48)
|
||||
{
|
||||
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
|
||||
myNodes.resize( 20 );
|
||||
myNodes[ 0 ] = n1;
|
||||
myNodes[ 1 ] = n2;
|
||||
myNodes[ 2 ] = n3;
|
||||
myNodes[ 3 ] = n4;
|
||||
myNodes[ 4 ] = n5;
|
||||
myNodes[ 5 ] = n6;
|
||||
myNodes[ 6 ] = n7;
|
||||
myNodes[ 7 ] = n8;
|
||||
myNodes[ 8 ] = n12;
|
||||
myNodes[ 9 ] = n23;
|
||||
myNodes[ 10 ] = n34;
|
||||
myNodes[ 11 ] = n41;
|
||||
myNodes[ 12 ] = n56;
|
||||
myNodes[ 13 ] = n67;
|
||||
myNodes[ 14 ] = n78;
|
||||
myNodes[ 15 ] = n85;
|
||||
myNodes[ 16 ] = n15;
|
||||
myNodes[ 17 ] = n26;
|
||||
myNodes[ 18 ] = n37;
|
||||
myNodes[ 19 ] = n48;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMediumNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_QuadraticVolumeOfNodes::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
int nbCorners = 0;
|
||||
switch (myNodes.size()) {
|
||||
case 10: nbCorners = 4; break;
|
||||
case 13: nbCorners = 5; break;
|
||||
case 15: nbCorners = 6; break;
|
||||
default: nbCorners = 8;
|
||||
}
|
||||
for ( size_t i = nbCorners; i<myNodes.size(); i++) {
|
||||
if(myNodes[i]==node) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ChangeNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_QuadraticVolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes)
|
||||
{
|
||||
if( nbNodes==10 || nbNodes==13 || nbNodes==15 || nbNodes==20 ) {
|
||||
myNodes.resize(nbNodes);
|
||||
int i=0;
|
||||
for(; i<nbNodes; i++) {
|
||||
myNodes[i] = nodes[i];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_QuadraticVolumeOfNodes::NbNodes() const
|
||||
{
|
||||
return myNodes.size();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_QuadraticVolumeOfNodes::NbEdges() const
|
||||
{
|
||||
if(myNodes.size()==10)
|
||||
return 6;
|
||||
else if(myNodes.size()==13)
|
||||
return 8;
|
||||
else if(myNodes.size()==15)
|
||||
return 9;
|
||||
else
|
||||
return 12;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
int SMDS_QuadraticVolumeOfNodes::NbFaces() const
|
||||
{
|
||||
if(myNodes.size()==10)
|
||||
return 4;
|
||||
else if(myNodes.size()==20)
|
||||
return 6;
|
||||
else
|
||||
return 5;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMDS_QuadraticVolumeOfNodes::Print(ostream & OS) const
|
||||
{
|
||||
OS << "quadratic volume <" << GetID() << " > : ";
|
||||
int i, nbNodes = myNodes.size();
|
||||
for (i = 0; i < nbNodes - 1; i++)
|
||||
OS << myNodes[i] << ",";
|
||||
OS << myNodes[i] << ") " << endl;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//private class : SMDS_QuadraticVolumeOfNodes_MyIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
class SMDS_QuadraticVolumeOfNodes_MyIterator : public SMDS_NodeVectorElemIterator
|
||||
{
|
||||
public:
|
||||
SMDS_QuadraticVolumeOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
|
||||
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
|
||||
};
|
||||
|
||||
/// ===================================================================
|
||||
/*!
|
||||
* \brief Iterator on faces or edges of volume
|
||||
*/
|
||||
/// ===================================================================
|
||||
|
||||
class _MySubIterator : public SMDS_ElemIterator
|
||||
{
|
||||
vector< const SMDS_MeshElement* > myElems;
|
||||
size_t myIndex;
|
||||
public:
|
||||
_MySubIterator(const SMDS_MeshVolume* vol, SMDSAbs_ElementType type):myIndex(0) {
|
||||
SMDS_VolumeTool vTool(vol);
|
||||
if (type == SMDSAbs_Face)
|
||||
vTool.GetAllExistingFaces( myElems );
|
||||
else
|
||||
vTool.GetAllExistingFaces( myElems );
|
||||
}
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more() { return myIndex < myElems.size(); }
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : elementsIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_QuadraticVolumeOfNodes::elementsIterator
|
||||
(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Volume:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_QuadraticVolumeOfNodes_MyIterator(myNodes));
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new _MySubIterator(this,SMDSAbs_Edge));
|
||||
break;
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_ElemIteratorPtr(new _MySubIterator(this,SMDSAbs_Face));
|
||||
break;
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type,SMDS_ElemIteratorPtr
|
||||
(new SMDS_QuadraticVolumeOfNodes_MyIterator(myNodes))));
|
||||
}
|
||||
return SMDS_ElemIteratorPtr();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
const SMDS_MeshNode* SMDS_QuadraticVolumeOfNodes::GetNode(const int ind) const
|
||||
{
|
||||
return myNodes[ ind ];
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_QuadraticVolumeOfNodes::GetEntityType() const
|
||||
{
|
||||
SMDSAbs_EntityType aType = SMDSEntity_Quad_Tetra;
|
||||
switch(NbNodes())
|
||||
{
|
||||
case 10: aType = SMDSEntity_Quad_Tetra; break;
|
||||
case 13: aType = SMDSEntity_Quad_Pyramid; break;
|
||||
case 15: aType = SMDSEntity_Quad_Penta; break;
|
||||
case 18: aType = SMDSEntity_BiQuad_Penta; break;
|
||||
case 20:
|
||||
default: aType = SMDSEntity_Quad_Hexa; break;
|
||||
}
|
||||
return aType;
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_QuadraticVolumeOfNodes.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_QuadraticVolumeOfNodes_HeaderFile
|
||||
#define _SMDS_QuadraticVolumeOfNodes_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_QuadraticVolumeOfNodes: public SMDS_MeshVolume
|
||||
{
|
||||
public:
|
||||
// tetrahedron of 10 nodes
|
||||
SMDS_QuadraticVolumeOfNodes (const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n31,
|
||||
const SMDS_MeshNode * n14,
|
||||
const SMDS_MeshNode * n24,
|
||||
const SMDS_MeshNode * n34);
|
||||
|
||||
// pyramid of 13 nodes
|
||||
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n5,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n34,
|
||||
const SMDS_MeshNode * n41,
|
||||
const SMDS_MeshNode * n15,
|
||||
const SMDS_MeshNode * n25,
|
||||
const SMDS_MeshNode * n35,
|
||||
const SMDS_MeshNode * n45);
|
||||
|
||||
// Pentahedron with 15 nodes
|
||||
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n5,
|
||||
const SMDS_MeshNode * n6,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n31,
|
||||
const SMDS_MeshNode * n45,
|
||||
const SMDS_MeshNode * n56,
|
||||
const SMDS_MeshNode * n64,
|
||||
const SMDS_MeshNode * n14,
|
||||
const SMDS_MeshNode * n25,
|
||||
const SMDS_MeshNode * n36);
|
||||
|
||||
// Hexahedrons with 20 nodes
|
||||
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
|
||||
const SMDS_MeshNode * n2,
|
||||
const SMDS_MeshNode * n3,
|
||||
const SMDS_MeshNode * n4,
|
||||
const SMDS_MeshNode * n5,
|
||||
const SMDS_MeshNode * n6,
|
||||
const SMDS_MeshNode * n7,
|
||||
const SMDS_MeshNode * n8,
|
||||
const SMDS_MeshNode * n12,
|
||||
const SMDS_MeshNode * n23,
|
||||
const SMDS_MeshNode * n34,
|
||||
const SMDS_MeshNode * n41,
|
||||
const SMDS_MeshNode * n56,
|
||||
const SMDS_MeshNode * n67,
|
||||
const SMDS_MeshNode * n78,
|
||||
const SMDS_MeshNode * n85,
|
||||
const SMDS_MeshNode * n15,
|
||||
const SMDS_MeshNode * n26,
|
||||
const SMDS_MeshNode * n37,
|
||||
const SMDS_MeshNode * n48);
|
||||
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual bool IsQuadratic() const { return true; }
|
||||
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
|
||||
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
|
||||
virtual void Print (std::ostream & OS) const;
|
||||
|
||||
/*!
|
||||
* \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:
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
|
||||
|
||||
private:
|
||||
std::vector<const SMDS_MeshNode *> myNodes;
|
||||
};
|
||||
|
||||
#endif
|
@ -27,19 +27,18 @@
|
||||
//
|
||||
|
||||
#include "SMDS_SpacePosition.hxx"
|
||||
#include "SMDS_VertexPosition.hxx"
|
||||
|
||||
SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition();
|
||||
|
||||
SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z)
|
||||
{
|
||||
}
|
||||
|
||||
SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
|
||||
{
|
||||
return SMDS_TOP_3DSPACE;
|
||||
}
|
||||
|
||||
SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
|
||||
{
|
||||
return _originPosition;
|
||||
return SMDS_PositionPtr( _originPosition, /*isOwner=*/false );
|
||||
}
|
||||
|
||||
SMDS_PositionPtr SMDS_VertexPosition::StaticPosition()
|
||||
{
|
||||
static SMDS_Position* _vertexPosition = new SMDS_VertexPosition;
|
||||
return SMDS_PositionPtr( _vertexPosition, /*isOwner=*/false );
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,15 @@
|
||||
|
||||
#include "SMDS_Position.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position
|
||||
class SMDS_EXPORT SMDS_SpacePosition : public SMDS_Position
|
||||
{
|
||||
public:
|
||||
|
||||
public:
|
||||
SMDS_SpacePosition(double x=0, double y=0, double z=0);
|
||||
virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
|
||||
static SMDS_PositionPtr originSpacePosition();
|
||||
private:
|
||||
virtual SMDS_TypeOfPosition GetTypeOfPosition() const { return SMDS_TOP_3DSPACE; }
|
||||
static SMDS_PositionPtr originSpacePosition();
|
||||
virtual const double* GetParameters() const { return 0; }
|
||||
|
||||
private:
|
||||
static SMDS_SpacePosition* _originPosition;
|
||||
};
|
||||
|
||||
|
@ -36,8 +36,6 @@
|
||||
#include <list>
|
||||
#include <climits>
|
||||
|
||||
using namespace std;
|
||||
|
||||
SMDS_CellLinks* SMDS_CellLinks::New()
|
||||
{
|
||||
return new SMDS_CellLinks();
|
||||
@ -150,7 +148,7 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p
|
||||
// --- type = VTK_POLYHEDRON
|
||||
int cellid = this->InsertNextCell(type, npts, pts);
|
||||
|
||||
set<vtkIdType> setOfNodes;
|
||||
std::set<vtkIdType> setOfNodes;
|
||||
setOfNodes.clear();
|
||||
int nbfaces = npts;
|
||||
int i = 0;
|
||||
@ -165,7 +163,7 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p
|
||||
}
|
||||
}
|
||||
|
||||
set<vtkIdType>::iterator it = setOfNodes.begin();
|
||||
std::set<vtkIdType>::iterator it = setOfNodes.begin();
|
||||
for (; it != setOfNodes.end(); ++it)
|
||||
{
|
||||
this->Links->ResizeCellList(*it, 1);
|
||||
@ -181,25 +179,24 @@ void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh)
|
||||
}
|
||||
|
||||
void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize,
|
||||
std::vector<int>& idCellsOldToNew, int newCellSize)
|
||||
std::vector<int>& idCellsNewToOld, int newCellSize)
|
||||
{
|
||||
int alreadyCopied = 0;
|
||||
|
||||
this->DeleteLinks();
|
||||
|
||||
// --- if newNodeSize, create a new compacted vtkPoints
|
||||
// IDs of VTK nodes always correspond to SMDS IDs but there can be "holes" in SMDS numeration.
|
||||
// We compact only if there were holes
|
||||
|
||||
if ( newNodeSize )
|
||||
int oldNodeSize = this->GetNumberOfPoints();
|
||||
bool updateNodes = ( oldNodeSize > newNodeSize );
|
||||
if ( true /*updateNodes*/ )
|
||||
{
|
||||
// rnv: to fix bug "21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion"
|
||||
// using double type for storing coordinates of nodes instead float.
|
||||
// 21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion
|
||||
// Use double type for storing coordinates of nodes instead float.
|
||||
vtkPoints *newPoints = vtkPoints::New();
|
||||
newPoints->SetDataType(VTK_DOUBLE);
|
||||
newPoints->SetNumberOfPoints(newNodeSize);
|
||||
newPoints->SetDataType( VTK_DOUBLE );
|
||||
newPoints->SetNumberOfPoints( newNodeSize );
|
||||
|
||||
int oldNodeSize = idNodesOldToNew.size();
|
||||
|
||||
int i = 0;
|
||||
int i = 0, alreadyCopied = 0;
|
||||
while ( i < oldNodeSize )
|
||||
{
|
||||
// skip a hole if any
|
||||
@ -215,13 +212,20 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
this->SetPoints(newPoints);
|
||||
newPoints->Delete();
|
||||
}
|
||||
this->Points->Squeeze();
|
||||
else
|
||||
{
|
||||
this->Points->Squeeze();
|
||||
this->Points->Modified();
|
||||
}
|
||||
|
||||
// --- create new compacted Connectivity, Locations and Types
|
||||
// Compact cells if VTK IDs do not correspond to SMDS IDs or nodes compacted
|
||||
|
||||
int oldCellSize = this->Types->GetNumberOfTuples();
|
||||
int oldCellSize = this->Types->GetNumberOfTuples();
|
||||
bool updateCells = ( updateNodes || newCellSize != oldCellSize );
|
||||
for ( int newID = 0, nbIDs = idCellsNewToOld.size(); newID < nbIDs && !updateCells; ++newID )
|
||||
updateCells = ( idCellsNewToOld[ newID ] != newID );
|
||||
|
||||
if ( !newNodeSize && oldCellSize == newCellSize ) // no holes in elements
|
||||
if ( false /*!updateCells*/ ) // no holes in elements
|
||||
{
|
||||
this->Connectivity->Squeeze();
|
||||
this->Locations->Squeeze();
|
||||
@ -231,14 +235,28 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
this->FaceLocations->Squeeze();
|
||||
this->Faces->Squeeze();
|
||||
}
|
||||
for ( int i = 0; i < oldCellSize; ++i )
|
||||
idCellsOldToNew[i] = i;
|
||||
this->Connectivity->Modified();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int) idNodesOldToNew.size() < oldNodeSize )
|
||||
{
|
||||
idNodesOldToNew.reserve( oldNodeSize );
|
||||
for ( int i = idNodesOldToNew.size(); i < oldNodeSize; ++i )
|
||||
idNodesOldToNew.push_back( i );
|
||||
}
|
||||
|
||||
// --- create new compacted Connectivity, Locations and Types
|
||||
|
||||
int newConnectivitySize = this->Connectivity->GetNumberOfConnectivityEntries();
|
||||
if ( newCellSize != oldCellSize )
|
||||
for ( int i = 0; i < oldCellSize - 1; ++i )
|
||||
if ( this->Types->GetValue( i ) == VTK_EMPTY_CELL )
|
||||
newConnectivitySize -= this->Locations->GetValue( i+1 ) - this->Locations->GetValue( i );
|
||||
|
||||
vtkCellArray *newConnectivity = vtkCellArray::New();
|
||||
newConnectivity->Initialize();
|
||||
int oldCellDataSize = this->Connectivity->GetData()->GetSize();
|
||||
newConnectivity->Allocate(oldCellDataSize);
|
||||
newConnectivity->Allocate( newConnectivitySize );
|
||||
|
||||
vtkUnsignedCharArray *newTypes = vtkUnsignedCharArray::New();
|
||||
newTypes->Initialize();
|
||||
@ -248,41 +266,24 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
newLocations->Initialize();
|
||||
newLocations->SetNumberOfValues(newCellSize);
|
||||
|
||||
// TODO some polyhedron may be huge (only in some tests)
|
||||
vtkIdType tmpid[NBMAXNODESINCELL];
|
||||
vtkIdType *pointsCell = &tmpid[0]; // --- points id to fill a new cell
|
||||
std::vector< vtkIdType > pointsCell(1024); // --- points id to fill a new cell
|
||||
|
||||
alreadyCopied = 0;
|
||||
int i = 0;
|
||||
while ( i < oldCellSize )
|
||||
{
|
||||
// skip a hole if any
|
||||
while ( i < oldCellSize && this->Types->GetValue(i) == VTK_EMPTY_CELL )
|
||||
++i;
|
||||
int startBloc = i;
|
||||
// look for a block end
|
||||
while ( i < oldCellSize && this->Types->GetValue(i) != VTK_EMPTY_CELL )
|
||||
++i;
|
||||
int endBloc = i;
|
||||
if ( endBloc > startBloc )
|
||||
copyBloc(newTypes,
|
||||
idCellsOldToNew, idNodesOldToNew,
|
||||
newConnectivity, newLocations,
|
||||
pointsCell, alreadyCopied,
|
||||
startBloc, endBloc);
|
||||
}
|
||||
newConnectivity->Squeeze();
|
||||
copyBloc(newTypes, idCellsNewToOld, idNodesOldToNew,
|
||||
newConnectivity, newLocations, pointsCell );
|
||||
|
||||
if (vtkDoubleArray* diameters =
|
||||
vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )) // Balls
|
||||
{
|
||||
for (int oldCellID = 0; oldCellID < oldCellSize; oldCellID++)
|
||||
vtkDoubleArray* newDiameters = vtkDoubleArray::New();
|
||||
newDiameters->SetNumberOfComponents(1);
|
||||
for ( int newCellID = 0; newCellID < newCellSize; newCellID++ )
|
||||
{
|
||||
if (this->Types->GetValue(oldCellID) == VTK_EMPTY_CELL)
|
||||
continue;
|
||||
int newCellId = idCellsOldToNew[ oldCellID ];
|
||||
if (newTypes->GetValue(newCellId) == VTK_POLY_VERTEX)
|
||||
diameters->SetValue( newCellId, diameters->GetValue( oldCellID ));
|
||||
if ( newTypes->GetValue( newCellID ) == VTK_POLY_VERTEX )
|
||||
{
|
||||
int oldCellID = idCellsNewToOld[ newCellID ];
|
||||
newDiameters->InsertValue( newCellID, diameters->GetValue( oldCellID ));
|
||||
}
|
||||
vtkDataSet::CellData->SetScalars( newDiameters );
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,25 +295,23 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
vtkIdTypeArray *newFaces = vtkIdTypeArray::New();
|
||||
newFaces->Initialize();
|
||||
newFaces->Allocate(this->Faces->GetSize());
|
||||
for (int i = 0; i < oldCellSize; i++)
|
||||
for ( int newCellID = 0; newCellID < newCellSize; newCellID++ )
|
||||
{
|
||||
if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
|
||||
continue;
|
||||
int newCellId = idCellsOldToNew[i];
|
||||
if (newTypes->GetValue(newCellId) == VTK_POLYHEDRON)
|
||||
if ( newTypes->GetValue( newCellID ) == VTK_POLYHEDRON )
|
||||
{
|
||||
newFaceLocations->InsertNextValue(newFaces->GetMaxId()+1);
|
||||
int oldFaceLoc = this->FaceLocations->GetValue(i);
|
||||
int nCellFaces = this->Faces->GetValue(oldFaceLoc++);
|
||||
newFaces->InsertNextValue(nCellFaces);
|
||||
for (int n=0; n<nCellFaces; n++)
|
||||
int oldCellId = idCellsNewToOld[ newCellID ];
|
||||
newFaceLocations->InsertNextValue( newFaces->GetMaxId()+1 );
|
||||
int oldFaceLoc = this->FaceLocations->GetValue( oldCellId );
|
||||
int nCellFaces = this->Faces->GetValue( oldFaceLoc++ );
|
||||
newFaces->InsertNextValue( nCellFaces );
|
||||
for ( int n = 0; n < nCellFaces; n++ )
|
||||
{
|
||||
int nptsInFace = this->Faces->GetValue(oldFaceLoc++);
|
||||
newFaces->InsertNextValue(nptsInFace);
|
||||
for (int k=0; k<nptsInFace; k++)
|
||||
int nptsInFace = this->Faces->GetValue( oldFaceLoc++ );
|
||||
newFaces->InsertNextValue( nptsInFace );
|
||||
for ( int k = 0; k < nptsInFace; k++ )
|
||||
{
|
||||
int oldpt = this->Faces->GetValue(oldFaceLoc++);
|
||||
newFaces->InsertNextValue(idNodesOldToNew[oldpt]);
|
||||
int oldpt = this->Faces->GetValue( oldFaceLoc++ );
|
||||
newFaces->InsertNextValue( idNodesOldToNew[ oldpt ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,13 +322,13 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
}
|
||||
newFaceLocations->Squeeze();
|
||||
newFaces->Squeeze();
|
||||
this->SetCells(newTypes, newLocations, newConnectivity, newFaceLocations, newFaces);
|
||||
this->SetCells( newTypes, newLocations, newConnectivity, newFaceLocations, newFaces );
|
||||
newFaceLocations->Delete();
|
||||
newFaces->Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
|
||||
this->SetCells( newTypes, newLocations, newConnectivity, FaceLocations, Faces );
|
||||
}
|
||||
|
||||
newTypes->Delete();
|
||||
@ -349,39 +348,35 @@ void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints,
|
||||
if (nbPoints > 0)
|
||||
{
|
||||
memcpy(target, source, 3 * sizeof(double) * nbPoints);
|
||||
for (int j = start; j < end; j++)
|
||||
idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId
|
||||
alreadyCopied += nbPoints;
|
||||
}
|
||||
}
|
||||
|
||||
void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
|
||||
std::vector<int>& idCellsOldToNew,
|
||||
std::vector<int>& idNodesOldToNew,
|
||||
vtkCellArray* newConnectivity,
|
||||
vtkIdTypeArray* newLocations,
|
||||
vtkIdType* pointsCell,
|
||||
int& alreadyCopied,
|
||||
int start,
|
||||
int end)
|
||||
void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray * newTypes,
|
||||
const std::vector<int>& idCellsNewToOld,
|
||||
const std::vector<int>& idNodesOldToNew,
|
||||
vtkCellArray* newConnectivity,
|
||||
vtkIdTypeArray* newLocations,
|
||||
std::vector<vtkIdType>& pointsCell)
|
||||
{
|
||||
for (int j = start; j < end; j++)
|
||||
for ( size_t iNew = 0; iNew < idCellsNewToOld.size(); iNew++ )
|
||||
{
|
||||
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
|
||||
idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId
|
||||
vtkIdType oldLoc = this->Locations->GetValue(j);
|
||||
int iOld = idCellsNewToOld[ iNew ];
|
||||
newTypes->SetValue( iNew, this->Types->GetValue( iOld ));
|
||||
vtkIdType oldLoc = this->Locations->GetValue( iOld );
|
||||
vtkIdType nbpts;
|
||||
vtkIdType *oldPtsCell = 0;
|
||||
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
|
||||
assert(nbpts < NBMAXNODESINCELL);
|
||||
for (int l = 0; l < nbpts; l++)
|
||||
this->Connectivity->GetCell( oldLoc, nbpts, oldPtsCell );
|
||||
if ((vtkIdType) pointsCell.size() < nbpts )
|
||||
pointsCell.resize( nbpts );
|
||||
for ( int l = 0; l < nbpts; l++ )
|
||||
{
|
||||
int oldval = oldPtsCell[l];
|
||||
pointsCell[l] = idNodesOldToNew[oldval];
|
||||
}
|
||||
/*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell);
|
||||
int newLoc = newConnectivity->GetInsertLocation(nbpts);
|
||||
newLocations->SetValue(alreadyCopied, newLoc);
|
||||
alreadyCopied++;
|
||||
/*int newcnt = */newConnectivity->InsertNextCell( nbpts, pointsCell.data() );
|
||||
int newLoc = newConnectivity->GetInsertLocation( nbpts );
|
||||
newLocations->SetValue( iNew, newLoc );
|
||||
}
|
||||
}
|
||||
|
||||
@ -656,7 +651,7 @@ void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges)
|
||||
int connEdgeId = _downArray[vtkEdgeType]->addCell(vtkEdgeId);
|
||||
SMDS_Down1D* downEdge = static_cast<SMDS_Down1D*> (_downArray[vtkEdgeType]);
|
||||
downEdge->setNodes(connEdgeId, vtkEdgeId);
|
||||
vector<int> vtkIds;
|
||||
std::vector<int> vtkIds;
|
||||
int nbVtkCells = downEdge->computeVtkCells(connEdgeId, vtkIds);
|
||||
int downFaces[1000];
|
||||
unsigned char downTypes[1000];
|
||||
@ -705,7 +700,7 @@ void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges)
|
||||
// --- check if the edge is already registered by exploration of the faces
|
||||
|
||||
//CHRONO(41);
|
||||
vector<int> vtkIds;
|
||||
std::vector<int> vtkIds;
|
||||
unsigned char vtkEdgeType = edgesWithNodes.elems[iedge].vtkType;
|
||||
int *pts = &edgesWithNodes.elems[iedge].nodeIds[0];
|
||||
SMDS_Down1D* downEdge = static_cast<SMDS_Down1D*> (_downArray[vtkEdgeType]);
|
||||
@ -759,7 +754,7 @@ void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges)
|
||||
|
||||
CHRONOSTOP(23);CHRONO(24);
|
||||
|
||||
// compact downward connectivity structure: adjust downward arrays size, replace vector<vector int>> by a single vector<int>
|
||||
// compact downward connectivity structure: adjust downward arrays size, replace std::vector<vector int>> by a single std::vector<int>
|
||||
// 3D first then 2D and last 1D to release memory before edge upCells reorganization, (temporary memory use)
|
||||
|
||||
for (int vtkType = VTK_QUADRATIC_PYRAMID; vtkType >= 0; vtkType--)
|
||||
@ -1073,15 +1068,11 @@ SMDS_UnstructuredGrid::extrudeVolumeFromFace(int vtkVolId,
|
||||
std::map<int, std::map<long, int> >& nodeQuadDomains)
|
||||
{
|
||||
//MESSAGE("extrudeVolumeFromFace " << vtkVolId);
|
||||
vector<vtkIdType> orderedOriginals;
|
||||
orderedOriginals.clear();
|
||||
set<int>::const_iterator it = originalNodes.begin();
|
||||
for (; it != originalNodes.end(); ++it)
|
||||
orderedOriginals.push_back(*it);
|
||||
std::vector<vtkIdType> orderedOriginals( originalNodes.begin(), originalNodes.end() );
|
||||
|
||||
int dim = 0;
|
||||
int nbNodes = this->getOrderedNodesOfFace(vtkVolId, dim, orderedOriginals);
|
||||
vector<vtkIdType> orderedNodes;
|
||||
std::vector<vtkIdType> orderedNodes;
|
||||
|
||||
bool isQuadratic = false;
|
||||
switch (orderedOriginals.size())
|
||||
@ -1130,7 +1121,7 @@ SMDS_UnstructuredGrid::extrudeVolumeFromFace(int vtkVolId,
|
||||
{
|
||||
double *coords = this->GetPoint(oldId);
|
||||
SMDS_MeshNode *newNode = _mesh->AddNode(coords[0], coords[1], coords[2]);
|
||||
newId = newNode->getVtkId();
|
||||
newId = newNode->GetVtkID();
|
||||
if (! nodeQuadDomains.count(oldId))
|
||||
{
|
||||
std::map<long, int> emptyMap;
|
||||
|
@ -116,9 +116,12 @@ protected:
|
||||
SMDS_UnstructuredGrid();
|
||||
~SMDS_UnstructuredGrid();
|
||||
void copyNodes(vtkPoints *newPoints, std::vector<int>& idNodesOldToNew, int& alreadyCopied, int start, int end);
|
||||
void copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew, std::vector<int>& idNodesOldToNew,
|
||||
vtkCellArray* newConnectivity, vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
|
||||
int start, int end);
|
||||
void copyBloc(vtkUnsignedCharArray *newTypes,
|
||||
const std::vector<int>& idCellsOldToNew,
|
||||
const std::vector<int>& idNodesOldToNew,
|
||||
vtkCellArray* newConnectivity,
|
||||
vtkIdTypeArray* newLocations,
|
||||
std::vector<vtkIdType>& pointsCell);
|
||||
|
||||
std::vector<int> _cellIdToDownId; //!< convert vtk Id to downward[vtkType] id, initialized with -1
|
||||
std::vector<unsigned char> _downTypes;
|
||||
|
@ -1,48 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_VertexPosition.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#include "SMDS_VertexPosition.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : SMDS_VertexPosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMDS_VertexPosition:: SMDS_VertexPosition()
|
||||
{
|
||||
//MESSAGE("*********************************************** SMDS_VertexPosition " << aVertexId);
|
||||
}
|
||||
|
||||
SMDS_TypeOfPosition SMDS_VertexPosition::GetTypeOfPosition() const
|
||||
{
|
||||
//MESSAGE("################################################# GetTypeOfPosition");
|
||||
return SMDS_TOP_VERTEX;
|
||||
}
|
@ -31,12 +31,12 @@
|
||||
|
||||
#include "SMDS_Position.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_VertexPosition:public SMDS_Position
|
||||
class SMDS_EXPORT SMDS_VertexPosition : public SMDS_Position
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_TypeOfPosition GetTypeOfPosition() const;
|
||||
SMDS_VertexPosition();
|
||||
public:
|
||||
SMDS_TypeOfPosition GetTypeOfPosition() const { return SMDS_TOP_VERTEX; }
|
||||
virtual const double* GetParameters() const { return 0; }
|
||||
static SMDS_PositionPtr StaticPosition();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,169 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_VolumeOfFaces.cxx
|
||||
// Author : Jean-Michel BOULCOURT
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "SMDS_VolumeOfFaces.hxx"
|
||||
#include "SMDS_IteratorOfElements.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=======================================================================
|
||||
//function : Print
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMDS_VolumeOfFaces::Print(ostream & OS) const
|
||||
{
|
||||
OS << "volume <" << GetID() << "> : ";
|
||||
int i;
|
||||
for (i = 0; i < NbFaces()-1; ++i) OS << myFaces[i] << ",";
|
||||
OS << myFaces[i]<< ") " << endl;
|
||||
}
|
||||
|
||||
|
||||
int SMDS_VolumeOfFaces::NbFaces() const
|
||||
{
|
||||
return myNbFaces;
|
||||
}
|
||||
|
||||
class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
|
||||
{
|
||||
const SMDS_MeshFace* const *mySet;
|
||||
int myLength;
|
||||
int index;
|
||||
public:
|
||||
SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l):
|
||||
mySet(s),myLength(l),index(0) {}
|
||||
|
||||
bool more()
|
||||
{
|
||||
return index<myLength;
|
||||
}
|
||||
|
||||
const SMDS_MeshElement* next()
|
||||
{
|
||||
index++;
|
||||
return mySet[index-1];
|
||||
}
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_VolumeOfFaces::
|
||||
elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SMDSAbs_Volume:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces));
|
||||
default:
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_IteratorOfElements
|
||||
(this,type,SMDS_ElemIteratorPtr
|
||||
(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces))));
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||
const SMDS_MeshFace * face2,
|
||||
const SMDS_MeshFace * face3,
|
||||
const SMDS_MeshFace * face4)
|
||||
{
|
||||
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
|
||||
myNbFaces = 4;
|
||||
myFaces[0]=face1;
|
||||
myFaces[1]=face2;
|
||||
myFaces[2]=face3;
|
||||
myFaces[3]=face4;
|
||||
myFaces[4]=0;
|
||||
myFaces[5]=0;
|
||||
}
|
||||
|
||||
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||
const SMDS_MeshFace * face2,
|
||||
const SMDS_MeshFace * face3,
|
||||
const SMDS_MeshFace * face4,
|
||||
const SMDS_MeshFace * face5)
|
||||
{
|
||||
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
|
||||
myNbFaces = 5;
|
||||
myFaces[0]=face1;
|
||||
myFaces[1]=face2;
|
||||
myFaces[2]=face3;
|
||||
myFaces[3]=face4;
|
||||
myFaces[4]=face5;
|
||||
myFaces[5]=0;
|
||||
}
|
||||
|
||||
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||
const SMDS_MeshFace * face2,
|
||||
const SMDS_MeshFace * face3,
|
||||
const SMDS_MeshFace * face4,
|
||||
const SMDS_MeshFace * face5,
|
||||
const SMDS_MeshFace * face6)
|
||||
{
|
||||
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
|
||||
myNbFaces = 6;
|
||||
myFaces[0]=face1;
|
||||
myFaces[1]=face2;
|
||||
myFaces[2]=face3;
|
||||
myFaces[3]=face4;
|
||||
myFaces[4]=face5;
|
||||
myFaces[5]=face6;
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_VolumeOfFaces::GetEntityType() const
|
||||
{
|
||||
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
|
||||
switch(myNbFaces)
|
||||
{
|
||||
case 4: aType = SMDSEntity_Tetra; break;
|
||||
case 5: aType = SMDSEntity_Pyramid; break;
|
||||
case 6: aType = SMDSEntity_Penta; break;
|
||||
case 8:
|
||||
default: aType = SMDSEntity_Hexa; break;
|
||||
}
|
||||
return aType;
|
||||
}
|
||||
|
||||
SMDSAbs_GeometryType SMDS_VolumeOfFaces::GetGeomType() const
|
||||
{
|
||||
SMDSAbs_GeometryType aType = SMDSGeom_NONE;
|
||||
switch(myNbFaces)
|
||||
{
|
||||
case 4: aType = SMDSGeom_TETRA; break;
|
||||
case 5: aType = SMDSGeom_PYRAMID; break;
|
||||
case 6: aType = SMDSGeom_PENTA; break;
|
||||
case 8:
|
||||
default: aType = SMDSGeom_HEXA; break;
|
||||
}
|
||||
return aType;
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
// Copyright (C) 2007-2016 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_VolumeOfFaces.hxx
|
||||
// Module : SMESH
|
||||
//
|
||||
#ifndef _SMDS_VolumeOfFaces_HeaderFile
|
||||
#define _SMDS_VolumeOfFaces_HeaderFile
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
#include "SMDS_Iterator.hxx"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class SMDS_EXPORT SMDS_VolumeOfFaces:public SMDS_MeshVolume
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||
const SMDS_MeshFace * face2,
|
||||
const SMDS_MeshFace * face3,
|
||||
const SMDS_MeshFace * face4);
|
||||
SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||
const SMDS_MeshFace * face2,
|
||||
const SMDS_MeshFace * face3,
|
||||
const SMDS_MeshFace * face4,
|
||||
const SMDS_MeshFace * face5);
|
||||
SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
|
||||
const SMDS_MeshFace * face2,
|
||||
const SMDS_MeshFace * face3,
|
||||
const SMDS_MeshFace * face4,
|
||||
const SMDS_MeshFace * face5,
|
||||
const SMDS_MeshFace * face6);
|
||||
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes) {return false;}
|
||||
virtual void Print(std::ostream & OS) const;
|
||||
|
||||
virtual int NbFaces() const;
|
||||
|
||||
protected:
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
const SMDS_MeshFace * myFaces[6];
|
||||
int myNbFaces;
|
||||
};
|
||||
#endif
|
@ -27,90 +27,82 @@
|
||||
#endif
|
||||
|
||||
#include "SMDS_VolumeOfNodes.hxx"
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include <utilities.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Create an hexahedron. node 1,2,3,4 and 5,6,7,8 are quadrangle and
|
||||
/// 5,1 and 7,3 are an edges.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6,
|
||||
const SMDS_MeshNode * node7,
|
||||
const SMDS_MeshNode * node8)
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6,
|
||||
const SMDS_MeshNode * node7,
|
||||
const SMDS_MeshNode * node8)
|
||||
{
|
||||
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
|
||||
myNbNodes = 8;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNodes[4]=node5;
|
||||
myNodes[5]=node6;
|
||||
myNodes[6]=node7;
|
||||
myNodes[7]=node8;
|
||||
myNbNodes = 8;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNodes[4]=node5;
|
||||
myNodes[5]=node6;
|
||||
myNodes[6]=node7;
|
||||
myNodes[7]=node8;
|
||||
}
|
||||
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4)
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4)
|
||||
{
|
||||
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
|
||||
myNbNodes = 4;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNbNodes = 4;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
}
|
||||
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5)
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5)
|
||||
{
|
||||
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
|
||||
myNbNodes = 5;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNodes[4]=node5;
|
||||
myNbNodes = 5;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNodes[4]=node5;
|
||||
}
|
||||
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6)
|
||||
SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6)
|
||||
{
|
||||
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
|
||||
myNbNodes = 6;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNodes[4]=node5;
|
||||
myNodes[5]=node6;
|
||||
myNbNodes = 6;
|
||||
myNodes = new const SMDS_MeshNode* [myNbNodes];
|
||||
myNodes[0]=node1;
|
||||
myNodes[1]=node2;
|
||||
myNodes[2]=node3;
|
||||
myNodes[3]=node4;
|
||||
myNodes[4]=node5;
|
||||
myNodes[5]=node6;
|
||||
}
|
||||
|
||||
bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
@ -136,98 +128,49 @@ SMDS_VolumeOfNodes::~SMDS_VolumeOfNodes()
|
||||
}
|
||||
}
|
||||
|
||||
void SMDS_VolumeOfNodes::Print(ostream & OS) const
|
||||
void SMDS_VolumeOfNodes::Print(std::ostream & OS) const
|
||||
{
|
||||
OS << "volume <" << GetID() << "> : ";
|
||||
int i;
|
||||
for (i = 0; i < NbNodes()-1; ++i) OS << myNodes[i] << ",";
|
||||
OS << myNodes[NbNodes()-1]<< ") " << endl;
|
||||
OS << "volume <" << GetID() << "> : ";
|
||||
int i;
|
||||
for (i = 0; i < NbNodes()-1; ++i) OS << myNodes[i] << ",";
|
||||
OS << myNodes[NbNodes()-1]<< ") " << std::endl;
|
||||
}
|
||||
|
||||
int SMDS_VolumeOfNodes::NbFaces() const
|
||||
{
|
||||
switch(NbNodes())
|
||||
{
|
||||
case 4: return 4;
|
||||
case 5: return 5;
|
||||
case 6: return 5;
|
||||
case 8: return 6;
|
||||
default: MESSAGE("invalid number of nodes");
|
||||
}
|
||||
return 0;
|
||||
switch(NbNodes())
|
||||
{
|
||||
case 4: return 4;
|
||||
case 5: return 5;
|
||||
case 6: return 5;
|
||||
case 8: return 6;
|
||||
default: MESSAGE("invalid number of nodes");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SMDS_VolumeOfNodes::NbNodes() const
|
||||
{
|
||||
return myNbNodes;
|
||||
return myNbNodes;
|
||||
}
|
||||
|
||||
int SMDS_VolumeOfNodes::NbEdges() const
|
||||
{
|
||||
switch(NbNodes())
|
||||
{
|
||||
case 4: return 6;
|
||||
case 5: return 8;
|
||||
case 6: return 9;
|
||||
case 8: return 12;
|
||||
default: MESSAGE("invalid number of nodes");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Iterator on node of volume
|
||||
*/
|
||||
class SMDS_VolumeOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
|
||||
{
|
||||
public:
|
||||
SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l):
|
||||
SMDS_NodeArrayElemIterator( s, & s[ l ]) {}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Iterator on faces or edges of volume
|
||||
*/
|
||||
class _MySubIterator : public SMDS_ElemIterator
|
||||
{
|
||||
vector< const SMDS_MeshElement* > myElems;
|
||||
size_t myIndex;
|
||||
public:
|
||||
_MySubIterator(const SMDS_VolumeOfNodes* vol, SMDSAbs_ElementType type):myIndex(0) {
|
||||
SMDS_VolumeTool vTool(vol);
|
||||
if (type == SMDSAbs_Face)
|
||||
vTool.GetAllExistingFaces( myElems );
|
||||
else
|
||||
vTool.GetAllExistingFaces( myElems );
|
||||
}
|
||||
/// Return true if and only if there are other object in this iterator
|
||||
virtual bool more() { return myIndex < myElems.size(); }
|
||||
|
||||
/// Return the current object and step to the next one
|
||||
virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
|
||||
};
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch(type)
|
||||
switch(NbNodes())
|
||||
{
|
||||
case SMDSAbs_Volume:
|
||||
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VolumeOfNodes_MyIterator(myNodes,myNbNodes));
|
||||
case SMDSAbs_Face:
|
||||
return SMDS_ElemIteratorPtr(new _MySubIterator(this,SMDSAbs_Face));
|
||||
case SMDSAbs_Edge:
|
||||
return SMDS_ElemIteratorPtr(new _MySubIterator(this,SMDSAbs_Edge));
|
||||
default:
|
||||
MESSAGE("ERROR : Iterator not implemented");
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
|
||||
case 4: return 6;
|
||||
case 5: return 8;
|
||||
case 6: return 9;
|
||||
case 8: return 12;
|
||||
default: MESSAGE("invalid number of nodes");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
SMDSAbs_ElementType SMDS_VolumeOfNodes::GetType() const
|
||||
{
|
||||
return SMDSAbs_Volume;
|
||||
return SMDSAbs_Volume;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -269,3 +212,20 @@ SMDSAbs_GeometryType SMDS_VolumeOfNodes::GetGeomType() const
|
||||
return aType;
|
||||
}
|
||||
|
||||
int SMDS_VolumeOfNodes::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
for ( int i = 0; i < myNbNodes; ++i )
|
||||
if ( myNodes[i] == node )
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::nodesIterator() const
|
||||
{
|
||||
return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VolumeOfNodes::nodeIterator() const
|
||||
{
|
||||
return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
|
||||
}
|
||||
|
@ -29,63 +29,66 @@
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_CellOfNodes.hxx"
|
||||
|
||||
class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
|
||||
class SMDS_EXPORT SMDS_VolumeOfNodes: public SMDS_CellOfNodes
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4);
|
||||
SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5);
|
||||
SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6);
|
||||
SMDS_VolumeOfNodes(
|
||||
const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6,
|
||||
const SMDS_MeshNode * node7,
|
||||
const SMDS_MeshNode * node8);
|
||||
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
~SMDS_VolumeOfNodes();
|
||||
public:
|
||||
SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4);
|
||||
SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5);
|
||||
SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6);
|
||||
SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
|
||||
const SMDS_MeshNode * node2,
|
||||
const SMDS_MeshNode * node3,
|
||||
const SMDS_MeshNode * node4,
|
||||
const SMDS_MeshNode * node5,
|
||||
const SMDS_MeshNode * node6,
|
||||
const SMDS_MeshNode * node7,
|
||||
const SMDS_MeshNode * node8);
|
||||
bool ChangeNodes(const SMDS_MeshNode* nodes[],
|
||||
const int nbNodes);
|
||||
~SMDS_VolumeOfNodes();
|
||||
|
||||
void Print(std::ostream & OS) const;
|
||||
int NbFaces() const;
|
||||
int NbNodes() const;
|
||||
int NbEdges() const;
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
void Print(std::ostream & OS) const;
|
||||
int NbFaces() const;
|
||||
int NbNodes() const;
|
||||
int NbEdges() const;
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
|
||||
virtual bool IsPoly() const { return false; }
|
||||
virtual bool IsQuadratic() const { return false; }
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
* \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;
|
||||
const SMDS_MeshNode** myNodes;
|
||||
int myNbNodes;
|
||||
virtual int NbCornerNodes() const { return NbNodes(); }
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr nodesIterator() const;
|
||||
virtual SMDS_NodeIteratorPtr nodeIterator() const;
|
||||
|
||||
protected:
|
||||
|
||||
const SMDS_MeshNode** myNodes;
|
||||
int myNbNodes;
|
||||
|
||||
};
|
||||
|
||||
|
@ -32,10 +32,9 @@
|
||||
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_VtkVolume.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
#include <utilities.h>
|
||||
|
||||
#include <map>
|
||||
#include <limits>
|
||||
@ -43,8 +42,6 @@
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
// ======================================================
|
||||
@ -506,7 +503,7 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume,
|
||||
myNbFaces = theVolume->NbFaces();
|
||||
if ( myVolume->IsPoly() )
|
||||
{
|
||||
myPolyedre = dynamic_cast<const SMDS_VtkVolume*>( myVolume );
|
||||
myPolyedre = SMDS_Mesh::DownCast<SMDS_MeshVolume>( myVolume );
|
||||
myPolyFacetOri.resize( myNbFaces, 0 );
|
||||
}
|
||||
|
||||
@ -522,10 +519,7 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume,
|
||||
}
|
||||
else
|
||||
{
|
||||
int iNode = 0;
|
||||
SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator();
|
||||
while ( nodeIt->more() )
|
||||
myVolumeNodes[ iNode++ ] = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
|
||||
myVolumeNodes.assign( myVolume->begin_nodes(), myVolume->end_nodes() );
|
||||
}
|
||||
|
||||
// check validity
|
||||
@ -954,8 +948,8 @@ const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex ) const
|
||||
//purpose : Return a set of face nodes.
|
||||
//=======================================================================
|
||||
|
||||
bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
|
||||
set<const SMDS_MeshNode*>& theFaceNodes ) const
|
||||
bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
|
||||
std::set<const SMDS_MeshNode*>& theFaceNodes ) const
|
||||
{
|
||||
if ( !setFace( faceIndex ))
|
||||
return false;
|
||||
@ -1060,7 +1054,7 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) const
|
||||
{
|
||||
ori = ( -minProj < maxProj ? -1 : +1 );
|
||||
double convexity = std::min( -minProj, maxProj ) / std::max( -minProj, maxProj );
|
||||
convexity2face.insert( make_pair( convexity, iF * ori ));
|
||||
convexity2face.insert( std::make_pair( convexity, iF * ori ));
|
||||
}
|
||||
}
|
||||
if ( faceMostConvex < 0 ) // none facet has nodes on the same side
|
||||
@ -1089,7 +1083,7 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) const
|
||||
// compare orientation of links of the facet with myFwdLinks
|
||||
ori = 0;
|
||||
setFace( faceIndex );
|
||||
vector< NLink > links( myCurFace.myNbNodes ), links2;
|
||||
std::vector< NLink > links( myCurFace.myNbNodes ), links2;
|
||||
for ( int i = 0; i < myCurFace.myNbNodes && !ori; ++i )
|
||||
{
|
||||
NLink link( myCurFace.myNodes[i], myCurFace.myNodes[i+1] );
|
||||
@ -1210,7 +1204,7 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub
|
||||
}
|
||||
|
||||
double size = cross.Magnitude();
|
||||
if ( size <= numeric_limits<double>::min() )
|
||||
if ( size <= std::numeric_limits<double>::min() )
|
||||
return false;
|
||||
|
||||
X = cross.x / size;
|
||||
@ -1382,7 +1376,7 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1,
|
||||
} else {
|
||||
d2 = 0;
|
||||
}
|
||||
vector<const SMDS_MeshNode*>::const_iterator i;
|
||||
std::vector<const SMDS_MeshNode*>::const_iterator i;
|
||||
for (int iface = 0; iface < myNbFaces; iface++)
|
||||
{
|
||||
from = to;
|
||||
@ -1429,8 +1423,8 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
|
||||
return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]);
|
||||
}
|
||||
|
||||
int minInd = min( theNode1Index, theNode2Index );
|
||||
int maxInd = max( theNode1Index, theNode2Index );
|
||||
int minInd = std::min( theNode1Index, theNode2Index );
|
||||
int maxInd = std::max( theNode1Index, theNode2Index );
|
||||
|
||||
if ( minInd < 0 || maxInd > (int)myVolumeNodes.size() - 1 || maxInd == minInd )
|
||||
return false;
|
||||
@ -1565,7 +1559,7 @@ int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_VolumeTool::GetAllExistingFaces(vector<const SMDS_MeshElement*> & faces) const
|
||||
int SMDS_VolumeTool::GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces) const
|
||||
{
|
||||
faces.clear();
|
||||
SaveFacet savedFacet( myCurFace );
|
||||
@ -1606,7 +1600,7 @@ int SMDS_VolumeTool::GetAllExistingFaces(vector<const SMDS_MeshElement*> & faces
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMDS_VolumeTool::GetAllExistingEdges(vector<const SMDS_MeshElement*> & edges) const
|
||||
int SMDS_VolumeTool::GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const
|
||||
{
|
||||
edges.clear();
|
||||
edges.reserve( myVolumeNodes.size() * 2 );
|
||||
@ -1717,7 +1711,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV
|
||||
// int nb = myCurFace.myNbNodes;
|
||||
// if ( myVolume->GetEntityType() != vol->GetEntityType() )
|
||||
// nb -= ( GetCenterNodeIndex(0) > 0 );
|
||||
// set<const SMDS_MeshNode*> faceNodes( nodes, nodes + nb );
|
||||
// std::set<const SMDS_MeshNode*> faceNodes( nodes, nodes + nb );
|
||||
// if ( SMDS_VolumeTool( vol ).GetFaceIndex( faceNodes ) < 0 )
|
||||
// continue;
|
||||
// }
|
||||
@ -1747,7 +1741,7 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth
|
||||
|
||||
// evaluate nb of face nodes shared by other volumes
|
||||
int maxNbShared = -1;
|
||||
typedef map< const SMDS_MeshElement*, int > TElemIntMap;
|
||||
typedef std::map< const SMDS_MeshElement*, int > TElemIntMap;
|
||||
TElemIntMap volNbShared;
|
||||
TElemIntMap::iterator vNbIt;
|
||||
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
|
||||
@ -1756,7 +1750,7 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth
|
||||
while ( eIt->more() ) {
|
||||
const SMDS_MeshElement* elem = eIt->next();
|
||||
if ( elem != myVolume ) {
|
||||
vNbIt = volNbShared.insert( make_pair( elem, 0 )).first;
|
||||
vNbIt = volNbShared.insert( std::make_pair( elem, 0 )).first;
|
||||
(*vNbIt).second++;
|
||||
if ( vNbIt->second > maxNbShared )
|
||||
maxNbShared = vNbIt->second;
|
||||
@ -1855,7 +1849,7 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth
|
||||
//purpose : Return index of a face formed by theFaceNodes
|
||||
//=======================================================================
|
||||
|
||||
int SMDS_VolumeTool::GetFaceIndex( const set<const SMDS_MeshNode*>& theFaceNodes,
|
||||
int SMDS_VolumeTool::GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes,
|
||||
const int theFaceIndexHint ) const
|
||||
{
|
||||
if ( theFaceIndexHint >= 0 )
|
||||
@ -1898,12 +1892,12 @@ int SMDS_VolumeTool::GetFaceIndex( const set<const SMDS_MeshNode*>& theFaceNodes
|
||||
//purpose : Return index of a face formed by theFaceNodes
|
||||
//=======================================================================
|
||||
|
||||
/*int SMDS_VolumeTool::GetFaceIndex( const set<int>& theFaceNodesIndices )
|
||||
/*int SMDS_VolumeTool::GetFaceIndex( const std::set<int>& theFaceNodesIndices )
|
||||
{
|
||||
for ( int iFace = 0; iFace < myNbFaces; iFace++ ) {
|
||||
const int* nodes = GetFaceNodesIndices( iFace );
|
||||
int nbFaceNodes = NbFaceNodes( iFace );
|
||||
set<int> nodeSet;
|
||||
std::set<int> nodeSet;
|
||||
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
|
||||
nodeSet.insert( nodes[ iNode ] );
|
||||
if ( theFaceNodesIndices == nodeSet )
|
||||
@ -1932,7 +1926,7 @@ bool SMDS_VolumeTool::setFace( int faceIndex ) const
|
||||
|
||||
if (myVolume->IsPoly())
|
||||
{
|
||||
if (!myPolyedre) {
|
||||
if ( !myPolyedre ) {
|
||||
MESSAGE("Warning: bad volumic element");
|
||||
return false;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
class SMDS_MeshElement;
|
||||
class SMDS_MeshNode;
|
||||
class SMDS_VtkVolume;
|
||||
class SMDS_MeshVolume;
|
||||
|
||||
#include <vector>
|
||||
@ -252,7 +251,7 @@ class SMDS_EXPORT SMDS_VolumeTool
|
||||
bool projectNodesToNormal( int faceIndex, double& minProj, double& maxProj ) const;
|
||||
|
||||
const SMDS_MeshElement* myVolume;
|
||||
const SMDS_VtkVolume* myPolyedre;
|
||||
const SMDS_MeshVolume* myPolyedre;
|
||||
bool myIgnoreCentralNodes;
|
||||
|
||||
bool myVolForward;
|
||||
|
@ -20,59 +20,40 @@
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
#include "utilities.h"
|
||||
|
||||
SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
|
||||
_mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType)
|
||||
#include <vtkCell.h>
|
||||
#include <vtkIdList.h>
|
||||
|
||||
_GetVtkNodes::_GetVtkNodes( vtkIdList* _vtkIdList,
|
||||
SMDS_Mesh* mesh,
|
||||
int vtkCellId,
|
||||
SMDSAbs_EntityType aType )
|
||||
{
|
||||
vtkUnstructuredGrid* grid = _mesh->getGrid();
|
||||
_vtkIdList = vtkIdList::New();
|
||||
vtkUnstructuredGrid* grid = mesh->GetGrid();
|
||||
const std::vector<int>& interlace = SMDS_MeshCell::fromVtkOrder( aType );
|
||||
if ( interlace.empty() )
|
||||
{
|
||||
grid->GetCellPoints(_cellId, _vtkIdList);
|
||||
_nbNodes = _vtkIdList->GetNumberOfIds();
|
||||
grid->GetCellPoints( vtkCellId, _vtkIdList );
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( _cellId, npts, pts );
|
||||
_vtkIdList->SetNumberOfIds( _nbNodes = npts );
|
||||
for (int i = 0; i < _nbNodes; i++)
|
||||
grid->GetCellPoints( vtkCellId, npts, pts );
|
||||
_vtkIdList->SetNumberOfIds( npts );
|
||||
for (int i = 0; i < npts; i++)
|
||||
_vtkIdList->SetId(i, pts[interlace[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_VtkCellIterator::~SMDS_VtkCellIterator()
|
||||
_GetVtkNodesToUNV::_GetVtkNodesToUNV( vtkIdList* _vtkIdList,
|
||||
SMDS_Mesh* mesh,
|
||||
int vtkCellId,
|
||||
SMDSAbs_EntityType aType )
|
||||
{
|
||||
_vtkIdList->Delete();
|
||||
}
|
||||
|
||||
bool SMDS_VtkCellIterator::more()
|
||||
{
|
||||
return (_index < _nbNodes);
|
||||
}
|
||||
|
||||
const SMDS_MeshElement* SMDS_VtkCellIterator::next()
|
||||
{
|
||||
vtkIdType id = _vtkIdList->GetId(_index++);
|
||||
return _mesh->FindNodeVtk(id);
|
||||
}
|
||||
|
||||
SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
|
||||
SMDS_VtkCellIterator()
|
||||
{
|
||||
_mesh = mesh;
|
||||
_cellId = vtkCellId;
|
||||
_index = 0;
|
||||
_type = aType;
|
||||
//MESSAGE("SMDS_VtkCellInterlacedIterator (UNV)" << _type);
|
||||
|
||||
_vtkIdList = vtkIdList::New();
|
||||
vtkIdType* pts;
|
||||
vtkUnstructuredGrid* grid = _mesh->getGrid();
|
||||
grid->GetCellPoints((vtkIdType)_cellId, (vtkIdType&)_nbNodes, pts);
|
||||
_vtkIdList->SetNumberOfIds(_nbNodes);
|
||||
vtkIdType * pts, npts;
|
||||
vtkUnstructuredGrid* grid = mesh->GetGrid();
|
||||
grid->GetCellPoints( (vtkIdType)vtkCellId, npts, pts );
|
||||
const int *ids = 0;
|
||||
switch (_type)
|
||||
switch (aType)
|
||||
{
|
||||
case SMDSEntity_Quad_Edge:
|
||||
{
|
||||
@ -85,7 +66,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel
|
||||
{
|
||||
static int id[] = { 0, 3, 1, 4, 2, 5 };
|
||||
ids = id;
|
||||
_nbNodes = 6;
|
||||
npts = 6;
|
||||
break;
|
||||
}
|
||||
case SMDSEntity_Quad_Quadrangle:
|
||||
@ -93,7 +74,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel
|
||||
{
|
||||
static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
|
||||
ids = id;
|
||||
_nbNodes = 8;
|
||||
npts = 8;
|
||||
break;
|
||||
}
|
||||
case SMDSEntity_Quad_Tetra:
|
||||
@ -126,7 +107,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel
|
||||
{
|
||||
static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 };
|
||||
ids = id;
|
||||
_nbNodes = 20;
|
||||
npts = 20;
|
||||
break;
|
||||
}
|
||||
case SMDSEntity_Polygon:
|
||||
@ -134,62 +115,42 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel
|
||||
case SMDSEntity_Polyhedra:
|
||||
case SMDSEntity_Quad_Polyhedra:
|
||||
default:
|
||||
const std::vector<int>& i = SMDS_MeshCell::interlacedSmdsOrder(aType, _nbNodes);
|
||||
const std::vector<int>& i = SMDS_MeshCell::interlacedSmdsOrder( aType, npts );
|
||||
if ( !i.empty() )
|
||||
ids = & i[0];
|
||||
}
|
||||
|
||||
_vtkIdList->SetNumberOfIds( npts );
|
||||
|
||||
if ( ids )
|
||||
for (int i = 0; i < _nbNodes; i++)
|
||||
for (int i = 0; i < npts; i++)
|
||||
_vtkIdList->SetId(i, pts[ids[i]]);
|
||||
else
|
||||
for (int i = 0; i < _nbNodes; i++)
|
||||
for (int i = 0; i < npts; i++)
|
||||
_vtkIdList->SetId(i, pts[i]);
|
||||
}
|
||||
|
||||
bool SMDS_VtkCellIteratorToUNV::more()
|
||||
_GetVtkNodesPolyh::_GetVtkNodesPolyh( vtkIdList* _vtkIdList,
|
||||
SMDS_Mesh* mesh,
|
||||
int vtkCellId,
|
||||
SMDSAbs_EntityType aType )
|
||||
{
|
||||
return SMDS_VtkCellIterator::more();
|
||||
}
|
||||
|
||||
const SMDS_MeshNode* SMDS_VtkCellIteratorToUNV::next()
|
||||
{
|
||||
return static_cast< const SMDS_MeshNode* >( SMDS_VtkCellIterator::next() );
|
||||
}
|
||||
|
||||
SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV()
|
||||
{
|
||||
}
|
||||
|
||||
SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
|
||||
SMDS_VtkCellIterator()
|
||||
{
|
||||
_mesh = mesh;
|
||||
_cellId = vtkCellId;
|
||||
_index = 0;
|
||||
_type = aType;
|
||||
//MESSAGE("SMDS_VtkCellIteratorPolyH " << _type);
|
||||
_vtkIdList = vtkIdList::New();
|
||||
vtkUnstructuredGrid* grid = _mesh->getGrid();
|
||||
grid->GetCellPoints(_cellId, _vtkIdList);
|
||||
_nbNodes = _vtkIdList->GetNumberOfIds();
|
||||
switch (_type)
|
||||
vtkUnstructuredGrid* grid = mesh->GetGrid();
|
||||
switch (aType)
|
||||
{
|
||||
case SMDSEntity_Polyhedra:
|
||||
{
|
||||
//MESSAGE("SMDS_VtkCellIterator Polyhedra");
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(_cellId, nFaces, ptIds);
|
||||
int id = 0;
|
||||
_nbNodesInFaces = 0;
|
||||
grid->GetFaceStream( vtkCellId, nFaces, ptIds );
|
||||
int id = 0, nbNodesInFaces = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
|
||||
_nbNodesInFaces += nodesInFace;
|
||||
nbNodesInFaces += nodesInFace;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
_vtkIdList->SetNumberOfIds(_nbNodesInFaces);
|
||||
_vtkIdList->SetNumberOfIds( nbNodesInFaces );
|
||||
id = 0;
|
||||
int n = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
@ -205,12 +166,3 @@ SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCel
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_VtkCellIteratorPolyH::~SMDS_VtkCellIteratorPolyH()
|
||||
{
|
||||
}
|
||||
|
||||
bool SMDS_VtkCellIteratorPolyH::more()
|
||||
{
|
||||
return (_index < _nbNodesInFaces);
|
||||
}
|
||||
|
@ -27,48 +27,68 @@
|
||||
#include <vtkCell.h>
|
||||
#include <vtkIdList.h>
|
||||
|
||||
class SMDS_VtkCellIterator: public SMDS_ElemIterator
|
||||
//--------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Retrieve nodes of a cell
|
||||
*/
|
||||
struct _GetVtkNodes
|
||||
{
|
||||
_GetVtkNodes( vtkIdList* nodeIds, SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type);
|
||||
};
|
||||
struct _GetVtkNodesToUNV
|
||||
{
|
||||
_GetVtkNodesToUNV( vtkIdList* nodeIds, SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type);
|
||||
};
|
||||
struct _GetVtkNodesPolyh
|
||||
{
|
||||
_GetVtkNodesPolyh( vtkIdList* nodeIds, SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Iterator on nodes of a cell
|
||||
*/
|
||||
template< class SMDS_ITERATOR = SMDS_ElemIterator, class GET_VTK_NODES = _GetVtkNodes >
|
||||
class SMDS_VtkCellIterator: public SMDS_ITERATOR
|
||||
{
|
||||
public:
|
||||
SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
|
||||
virtual ~SMDS_VtkCellIterator();
|
||||
virtual bool more();
|
||||
virtual const SMDS_MeshElement* next();
|
||||
inline void exchange(vtkIdType a, vtkIdType b)
|
||||
typedef typename SMDS_ITERATOR::value_type result_type;
|
||||
|
||||
SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType)
|
||||
: _mesh(mesh), _index(0), _vtkIdList( vtkIdList::New() )
|
||||
{
|
||||
vtkIdType t = _vtkIdList->GetId(a);
|
||||
_vtkIdList->SetId(a, _vtkIdList->GetId(b));
|
||||
_vtkIdList->SetId(b, t);
|
||||
GET_VTK_NODES getNodes( _vtkIdList, mesh, vtkCellId, aType );
|
||||
}
|
||||
virtual ~SMDS_VtkCellIterator() { _vtkIdList->Delete(); }
|
||||
virtual bool more() { return ( _index < _vtkIdList->GetNumberOfIds() ); }
|
||||
virtual result_type next() {
|
||||
vtkIdType id = _vtkIdList->GetId( _index++ );
|
||||
return static_cast<result_type>( _mesh->FindNodeVtk( id ));
|
||||
}
|
||||
|
||||
protected:
|
||||
SMDS_VtkCellIterator() {};
|
||||
|
||||
SMDS_Mesh* _mesh;
|
||||
int _cellId;
|
||||
int _index;
|
||||
int _nbNodes;
|
||||
SMDSAbs_EntityType _type;
|
||||
int _index;
|
||||
vtkIdList* _vtkIdList;
|
||||
};
|
||||
|
||||
class SMDS_VtkCellIteratorToUNV: public SMDS_NodeIterator, protected SMDS_VtkCellIterator
|
||||
//--------------------------------------------------------------------------------
|
||||
template< class SMDS_ITERATOR = SMDS_ElemIterator >
|
||||
class SMDS_VtkCellIteratorToUNV: public SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesToUNV >
|
||||
{
|
||||
typedef SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesToUNV > parent_t;
|
||||
public:
|
||||
SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
|
||||
virtual const SMDS_MeshNode* next();
|
||||
virtual bool more();
|
||||
virtual ~SMDS_VtkCellIteratorToUNV();
|
||||
SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type):
|
||||
parent_t( mesh, vtkCellId, type ) {}
|
||||
};
|
||||
|
||||
class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator
|
||||
//--------------------------------------------------------------------------------
|
||||
template< class SMDS_ITERATOR = SMDS_ElemIterator >
|
||||
class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesPolyh >
|
||||
{
|
||||
typedef SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesPolyh > parent_t;
|
||||
public:
|
||||
SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
|
||||
virtual ~SMDS_VtkCellIteratorPolyH();
|
||||
virtual bool more();
|
||||
protected:
|
||||
int _nbNodesInFaces;
|
||||
SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type):
|
||||
parent_t( mesh, vtkCellId, type ) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,167 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "SMDS_VtkEdge.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
|
||||
SMDS_VtkEdge::SMDS_VtkEdge()
|
||||
{
|
||||
}
|
||||
|
||||
SMDS_VtkEdge::SMDS_VtkEdge(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
init(nodeIds, mesh);
|
||||
}
|
||||
|
||||
SMDS_VtkEdge::~SMDS_VtkEdge()
|
||||
{
|
||||
}
|
||||
|
||||
void SMDS_VtkEdge::init(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshEdge::init();
|
||||
myMeshId = mesh->getMeshId();
|
||||
vtkIdType aType = ( nodeIds.size() == 3 ) ? VTK_QUADRATIC_EDGE : VTK_LINE;
|
||||
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2)
|
||||
{
|
||||
const SMDS_MeshNode* nodes[] = { node1, node2 };
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
return ChangeNodes(nodes, 2);
|
||||
}
|
||||
|
||||
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
if (nbNodes != npts)
|
||||
{
|
||||
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < nbNodes; i++)
|
||||
{
|
||||
pts[i] = nodes[i]->getVtkId();
|
||||
}
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
return ((npts == 3) && (node->getVtkId() == pts[2]));
|
||||
}
|
||||
|
||||
void SMDS_VtkEdge::Print(std::ostream & OS) const
|
||||
{
|
||||
OS << "edge <" << GetID() << "> : ";
|
||||
}
|
||||
|
||||
int SMDS_VtkEdge::NbNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType *pts, npts;
|
||||
grid->GetCellPoints( myVtkID, npts, pts );
|
||||
assert(npts >= 2);
|
||||
return npts;
|
||||
}
|
||||
|
||||
int SMDS_VtkEdge::NbEdges() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_VtkEdge::GetEntityType() const
|
||||
{
|
||||
if (NbNodes() == 2)
|
||||
return SMDSEntity_Edge;
|
||||
else
|
||||
return SMDSEntity_Quad_Edge;
|
||||
}
|
||||
|
||||
vtkIdType SMDS_VtkEdge::GetVtkType() const
|
||||
{
|
||||
if (NbNodes() == 2)
|
||||
return VTK_LINE;
|
||||
else
|
||||
return VTK_QUADRATIC_EDGE;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
const SMDS_MeshNode*
|
||||
SMDS_VtkEdge::GetNode(const int ind) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( this->myVtkID, npts, pts );
|
||||
return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ ind ]);
|
||||
}
|
||||
|
||||
bool SMDS_VtkEdge::IsQuadratic() const
|
||||
{
|
||||
if (this->NbNodes() > 2)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_VtkEdge::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
default:
|
||||
MESSAGE("ERROR : Iterator not implemented");
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VtkEdge::nodesIteratorToUNV() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VtkEdge::interlacedNodesIterator() const
|
||||
{
|
||||
return nodesIteratorToUNV();
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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 : implementation of Salome mesh data structure
|
||||
// File : SMDS_VtkEdge.hxx
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMDS_VTKEDGE_HXX_
|
||||
#define _SMDS_VTKEDGE_HXX_
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshEdge.hxx"
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
#include <vector>
|
||||
|
||||
class SMDS_EXPORT SMDS_VtkEdge: public SMDS_MeshEdge
|
||||
{
|
||||
|
||||
public:
|
||||
SMDS_VtkEdge();
|
||||
SMDS_VtkEdge(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
~SMDS_VtkEdge();
|
||||
void init(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
bool ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
|
||||
virtual void Print(std::ostream & OS) const;
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
virtual bool IsQuadratic() const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;
|
||||
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
protected:
|
||||
};
|
||||
#endif
|
@ -1,334 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "SMDS_VtkFace.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
SMDS_VtkFace::SMDS_VtkFace()
|
||||
{
|
||||
}
|
||||
|
||||
SMDS_VtkFace::SMDS_VtkFace(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
init(nodeIds, mesh);
|
||||
}
|
||||
|
||||
SMDS_VtkFace::~SMDS_VtkFace()
|
||||
{
|
||||
}
|
||||
|
||||
void SMDS_VtkFace::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshFace::init();
|
||||
myMeshId = mesh->getMeshId();
|
||||
vtkIdType aType = VTK_TRIANGLE;
|
||||
switch (nodeIds.size())
|
||||
{
|
||||
case 3: aType = VTK_TRIANGLE; break;
|
||||
case 4: aType = VTK_QUAD; break;
|
||||
case 6: aType = VTK_QUADRATIC_TRIANGLE; break;
|
||||
case 8: aType = VTK_QUADRATIC_QUAD; break;
|
||||
case 9: aType = VTK_BIQUADRATIC_QUAD; break;
|
||||
case 7: aType = VTK_BIQUADRATIC_TRIANGLE;break;
|
||||
default: aType = VTK_POLYGON;
|
||||
}
|
||||
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
void SMDS_VtkFace::initPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshFace::init();
|
||||
myMeshId = mesh->getMeshId();
|
||||
vtkIdType aType = VTK_POLYGON;
|
||||
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
void SMDS_VtkFace::initQuadPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshFace::init();
|
||||
myMeshId = mesh->getMeshId();
|
||||
vtkIdType aType = VTK_QUADRATIC_POLYGON;
|
||||
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
if (nbNodes != npts)
|
||||
{
|
||||
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < nbNodes; i++)
|
||||
{
|
||||
pts[i] = nodes[i]->getVtkId();
|
||||
}
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SMDS_VtkFace::Print(std::ostream & OS) const
|
||||
{
|
||||
OS << "face <" << GetID() << "> : ";
|
||||
}
|
||||
|
||||
int SMDS_VtkFace::NbEdges() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int nbEdges = 3;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_TRIANGLE:
|
||||
case VTK_QUADRATIC_TRIANGLE:
|
||||
case VTK_BIQUADRATIC_TRIANGLE:
|
||||
nbEdges = 3;
|
||||
break;
|
||||
case VTK_QUAD:
|
||||
case VTK_QUADRATIC_QUAD:
|
||||
case VTK_BIQUADRATIC_QUAD:
|
||||
nbEdges = 4;
|
||||
break;
|
||||
case VTK_QUADRATIC_POLYGON:
|
||||
nbEdges = NbNodes() / 2;
|
||||
break;
|
||||
case VTK_POLYGON:
|
||||
default:
|
||||
nbEdges = NbNodes();
|
||||
break;
|
||||
}
|
||||
return nbEdges;
|
||||
}
|
||||
|
||||
int SMDS_VtkFace::NbFaces() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SMDS_VtkFace::NbNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType *pts, npts;
|
||||
grid->GetCellPoints( myVtkID, npts, pts );
|
||||
return npts;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
const SMDS_MeshNode*
|
||||
SMDS_VtkFace::GetNode(const int ind) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( this->myVtkID, npts, pts );
|
||||
return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ ind ]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Check if a node belongs to the element
|
||||
* \param node - the node to check
|
||||
* \retval int - node index within the element, -1 if not found
|
||||
*/
|
||||
int SMDS_VtkFace::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( this->myVtkID, npts, pts );
|
||||
for ( vtkIdType i = 0; i < npts; ++i )
|
||||
if ( pts[i] == node->getVtkId() )
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool SMDS_VtkFace::IsQuadratic() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
// TODO quadratic polygons ?
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_QUADRATIC_TRIANGLE:
|
||||
case VTK_QUADRATIC_QUAD:
|
||||
case VTK_QUADRATIC_POLYGON:
|
||||
case VTK_BIQUADRATIC_QUAD:
|
||||
case VTK_BIQUADRATIC_TRIANGLE:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SMDS_VtkFace::IsPoly() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
return ( aVtkType == VTK_POLYGON || aVtkType == VTK_QUADRATIC_POLYGON );
|
||||
}
|
||||
|
||||
bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int rankFirstMedium = 0;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_QUADRATIC_TRIANGLE:
|
||||
case VTK_BIQUADRATIC_TRIANGLE:
|
||||
rankFirstMedium = 3; // medium nodes are of rank 3,4,5
|
||||
break;
|
||||
case VTK_QUADRATIC_QUAD:
|
||||
case VTK_BIQUADRATIC_QUAD:
|
||||
rankFirstMedium = 4; // medium nodes are of rank 4,5,6,7
|
||||
break;
|
||||
case VTK_QUADRATIC_POLYGON:
|
||||
rankFirstMedium = npts / 2;
|
||||
break;
|
||||
default:
|
||||
//MESSAGE("wrong element type " << aVtkType);
|
||||
return false;
|
||||
}
|
||||
vtkIdType nodeId = node->getVtkId();
|
||||
for (int rank = 0; rank < npts; rank++)
|
||||
{
|
||||
if (pts[rank] == nodeId)
|
||||
{
|
||||
//MESSAGE("rank " << rank << " is medium node " << (rank < rankFirstMedium));
|
||||
if (rank < rankFirstMedium)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//throw SALOME_Exception(LOCALIZED("node does not belong to this element"));
|
||||
MESSAGE("======================================================");
|
||||
MESSAGE("= IsMediumNode: node does not belong to this element =");
|
||||
MESSAGE("======================================================");
|
||||
return false;
|
||||
}
|
||||
|
||||
int SMDS_VtkFace::NbCornerNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
int nbPoints = NbNodes();
|
||||
vtkIdType aVtkType = grid->GetCellType(myVtkID);
|
||||
switch ( aVtkType )
|
||||
{
|
||||
case VTK_POLYGON:
|
||||
break;
|
||||
case VTK_QUADRATIC_POLYGON:
|
||||
nbPoints /= 2;
|
||||
break;
|
||||
default:
|
||||
if ( nbPoints > 4 )
|
||||
nbPoints /= 2;
|
||||
}
|
||||
return nbPoints;
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
return SMDS_MeshCell::toSmdsType( VTKCellType( aVtkType ));
|
||||
}
|
||||
|
||||
SMDSAbs_GeometryType SMDS_VtkFace::GetGeomType() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
switch ( aVtkType ) {
|
||||
case VTK_TRIANGLE:
|
||||
case VTK_QUADRATIC_TRIANGLE:
|
||||
case VTK_BIQUADRATIC_TRIANGLE: return SMDSGeom_TRIANGLE;
|
||||
|
||||
case VTK_QUAD:
|
||||
case VTK_QUADRATIC_QUAD:
|
||||
case VTK_BIQUADRATIC_QUAD: return SMDSGeom_QUADRANGLE;
|
||||
|
||||
case VTK_POLYGON:
|
||||
case VTK_QUADRATIC_POLYGON: return SMDSGeom_POLYGON;
|
||||
default:;
|
||||
}
|
||||
return SMDSGeom_NONE;
|
||||
}
|
||||
|
||||
vtkIdType SMDS_VtkFace::GetVtkType() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
return aVtkType;
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SMDSAbs_Node:
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
default:
|
||||
MESSAGE("ERROR : Iterator not implemented")
|
||||
;
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VtkFace::nodesIteratorToUNV() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VtkFace::interlacedNodesIterator() const
|
||||
{
|
||||
return nodesIteratorToUNV();
|
||||
}
|
||||
|
||||
//! change only the first node, used for temporary triangles in quadrangle to triangle adaptor
|
||||
void SMDS_VtkFace::ChangeApex(SMDS_MeshNode* node)
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
grid->RemoveReferenceToCell(pts[0], myVtkID);
|
||||
pts[0] = node->getVtkId();
|
||||
node->AddInverseElement(this),
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _SMDS_VTKFACE_HXX_
|
||||
#define _SMDS_VTKFACE_HXX_
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshFace.hxx"
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
#include <vector>
|
||||
|
||||
class SMDS_EXPORT SMDS_VtkFace: public SMDS_MeshFace
|
||||
{
|
||||
public:
|
||||
SMDS_VtkFace();
|
||||
SMDS_VtkFace(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
~SMDS_VtkFace();
|
||||
void init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
void initPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
void initQuadPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
|
||||
bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
void ChangeApex(SMDS_MeshNode* node); // to use only for tmp triangles
|
||||
|
||||
virtual void Print(std::ostream & OS) const;
|
||||
virtual int NbEdges() const;
|
||||
virtual int NbFaces() const;
|
||||
virtual int NbNodes() const;
|
||||
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
|
||||
virtual bool IsQuadratic() const;
|
||||
virtual bool IsPoly() const;
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
virtual int NbCornerNodes() const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;
|
||||
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
@ -1,698 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "SMDS_VtkVolume.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_Mesh.hxx"
|
||||
#include "SMDS_VtkCellIterator.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
SMDS_VtkVolume::SMDS_VtkVolume()
|
||||
{
|
||||
}
|
||||
|
||||
SMDS_VtkVolume::SMDS_VtkVolume(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
init(nodeIds, mesh);
|
||||
}
|
||||
/*!
|
||||
* typed used are vtk types (@see vtkCellType.h)
|
||||
* see GetEntityType() for conversion in SMDS type (@see SMDSAbs_ElementType.hxx)
|
||||
*/
|
||||
void SMDS_VtkVolume::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshVolume::init();
|
||||
myMeshId = mesh->getMeshId();
|
||||
vtkIdType aType = VTK_TETRA;
|
||||
switch (nodeIds.size()) // cases are in order of usage frequency
|
||||
{
|
||||
case 4: aType = VTK_TETRA; break;
|
||||
case 8: aType = VTK_HEXAHEDRON; break;
|
||||
case 5: aType = VTK_PYRAMID; break;
|
||||
case 6: aType = VTK_WEDGE; break;
|
||||
case 10: aType = VTK_QUADRATIC_TETRA; break;
|
||||
case 20: aType = VTK_QUADRATIC_HEXAHEDRON; break;
|
||||
case 13: aType = VTK_QUADRATIC_PYRAMID; break;
|
||||
case 15: aType = VTK_QUADRATIC_WEDGE; break;
|
||||
case 18: aType = VTK_BIQUADRATIC_QUADRATIC_WEDGE; break;
|
||||
case 12: aType = VTK_HEXAGONAL_PRISM; break;
|
||||
case 27: aType = VTK_TRIQUADRATIC_HEXAHEDRON; break;
|
||||
default: aType = VTK_HEXAHEDRON;
|
||||
}
|
||||
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
|
||||
const std::vector<int>& nbNodesPerFace,
|
||||
SMDS_Mesh* mesh)
|
||||
{
|
||||
SMDS_MeshVolume::init();
|
||||
SMDS_UnstructuredGrid* grid = mesh->getGrid();
|
||||
//double center[3];
|
||||
//this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), ¢er[0]);
|
||||
std::vector<vtkIdType> ptIds;
|
||||
vtkIdType nbFaces = nbNodesPerFace.size();
|
||||
int k = 0;
|
||||
for (int i = 0; i < nbFaces; i++)
|
||||
{
|
||||
int nf = nbNodesPerFace[i];
|
||||
ptIds.push_back(nf);
|
||||
// EAP: a right approach is:
|
||||
// - either the user should care of order of nodes or
|
||||
// - the user should use a service method arranging nodes if he
|
||||
// don't want or can't to do it by him-self
|
||||
// The method below works OK only with planar faces and convex polyhedrones
|
||||
//
|
||||
// double a[3];
|
||||
// double b[3];
|
||||
// double c[3];
|
||||
// grid->GetPoints()->GetPoint(nodeIds[k], a);
|
||||
// grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
|
||||
// grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
|
||||
// bool isFaceForward = this->isForward(a, b, c, center);
|
||||
const vtkIdType *facePts = &nodeIds[k];
|
||||
//if (isFaceForward)
|
||||
for (int n = 0; n < nf; n++)
|
||||
ptIds.push_back(facePts[n]);
|
||||
// else
|
||||
// for (int n = nf - 1; n >= 0; n--)
|
||||
// ptIds.push_back(facePts[n]);
|
||||
k += nf;
|
||||
}
|
||||
myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
|
||||
mesh->setMyModified();
|
||||
}
|
||||
|
||||
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
if (nbNodes != npts)
|
||||
{
|
||||
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < nbNodes; i++)
|
||||
{
|
||||
pts[i] = nodes[i]->getVtkId();
|
||||
}
|
||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Reorder in VTK order a list of nodes given in SMDS order.
|
||||
* To be used before ChangeNodes: lists are given or computed in SMDS order.
|
||||
*/
|
||||
bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes)
|
||||
{
|
||||
if (nbNodes != this->NbNodes())
|
||||
{
|
||||
MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes());
|
||||
return false;
|
||||
}
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( aVtkType ));
|
||||
if ( !interlace.empty() )
|
||||
{
|
||||
ASSERT( (int)interlace.size() == nbNodes );
|
||||
std::vector<const SMDS_MeshNode*> initNodes( nodes, nodes+nbNodes );
|
||||
for ( size_t i = 0; i < interlace.size(); ++i )
|
||||
nodes[i] = initNodes[ interlace[i] ];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SMDS_VtkVolume::~SMDS_VtkVolume()
|
||||
{
|
||||
}
|
||||
|
||||
void SMDS_VtkVolume::Print(ostream & OS) const
|
||||
{
|
||||
OS << "volume <" << GetID() << "> : ";
|
||||
}
|
||||
|
||||
int SMDS_VtkVolume::NbFaces() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int nbFaces = 4;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_TETRA:
|
||||
case VTK_QUADRATIC_TETRA:
|
||||
nbFaces = 4;
|
||||
break;
|
||||
case VTK_PYRAMID:
|
||||
case VTK_WEDGE:
|
||||
case VTK_QUADRATIC_PYRAMID:
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
|
||||
nbFaces = 5;
|
||||
break;
|
||||
case VTK_HEXAHEDRON:
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON:
|
||||
nbFaces = 6;
|
||||
break;
|
||||
case VTK_POLYHEDRON:
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
nbFaces = nFaces;
|
||||
break;
|
||||
}
|
||||
case VTK_HEXAGONAL_PRISM:
|
||||
nbFaces = 8;
|
||||
break;
|
||||
default:
|
||||
MESSAGE("invalid volume type")
|
||||
;
|
||||
nbFaces = 0;
|
||||
break;
|
||||
}
|
||||
return nbFaces;
|
||||
}
|
||||
|
||||
int SMDS_VtkVolume::NbNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
vtkIdType nbPoints = 0;
|
||||
if (aVtkType != VTK_POLYHEDRON)
|
||||
{
|
||||
vtkIdType *pts;
|
||||
grid->GetCellPoints( myVtkID, nbPoints, pts );
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
nbPoints += nodesInFace;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
}
|
||||
return nbPoints;
|
||||
}
|
||||
|
||||
int SMDS_VtkVolume::NbEdges() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int nbEdges = 6;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_TETRA:
|
||||
case VTK_QUADRATIC_TETRA:
|
||||
nbEdges = 6;
|
||||
break;
|
||||
case VTK_PYRAMID:
|
||||
case VTK_QUADRATIC_PYRAMID:
|
||||
nbEdges = 8;
|
||||
break;
|
||||
case VTK_WEDGE:
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
|
||||
nbEdges = 9;
|
||||
break;
|
||||
case VTK_HEXAHEDRON:
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON:
|
||||
nbEdges = 12;
|
||||
break;
|
||||
case VTK_POLYHEDRON:
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
nbEdges = 0;
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int edgesInFace = ptIds[id];
|
||||
id += (edgesInFace + 1);
|
||||
nbEdges += edgesInFace;
|
||||
}
|
||||
nbEdges = nbEdges / 2;
|
||||
break;
|
||||
}
|
||||
case VTK_HEXAGONAL_PRISM:
|
||||
nbEdges = 18;
|
||||
break;
|
||||
default:
|
||||
MESSAGE("invalid volume type")
|
||||
;
|
||||
nbEdges = 0;
|
||||
break;
|
||||
}
|
||||
return nbEdges;
|
||||
}
|
||||
|
||||
/*! polyhedron only,
|
||||
* 1 <= face_ind <= NbFaces()
|
||||
*/
|
||||
int SMDS_VtkVolume::NbFaceNodes(const int face_ind) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int nbNodes = 0;
|
||||
if (aVtkType == VTK_POLYHEDRON)
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
id += (nodesInFace + 1);
|
||||
if (i == face_ind - 1)
|
||||
{
|
||||
nbNodes = nodesInFace;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nbNodes;
|
||||
}
|
||||
|
||||
/*! polyhedron only,
|
||||
* 1 <= face_ind <= NbFaces()
|
||||
* 1 <= node_ind <= NbFaceNodes()
|
||||
*/
|
||||
const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int node_ind) const
|
||||
{
|
||||
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
|
||||
vtkUnstructuredGrid* grid = mesh->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
const SMDS_MeshNode* node = 0;
|
||||
if (aVtkType == VTK_POLYHEDRON)
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
|
||||
if (i == face_ind - 1) // first face is number 1
|
||||
{
|
||||
if ((node_ind > 0) && (node_ind <= nodesInFace))
|
||||
node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node
|
||||
break;
|
||||
}
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/*! polyhedron only,
|
||||
* return number of nodes for each face
|
||||
*/
|
||||
std::vector<int> SMDS_VtkVolume::GetQuantities() const
|
||||
{
|
||||
std::vector<int> quantities;
|
||||
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
|
||||
vtkUnstructuredGrid* grid = mesh->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
if (aVtkType == VTK_POLYHEDRON)
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
int id = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
|
||||
quantities.push_back(nodesInFace);
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
}
|
||||
return quantities;
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr SMDS_VtkVolume::elementsIterator(SMDSAbs_ElementType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SMDSAbs_Node:
|
||||
{
|
||||
SMDSAbs_EntityType aType = this->GetEntityType();
|
||||
if (aType == SMDSEntity_Polyhedra)
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorPolyH(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType));
|
||||
else
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType));
|
||||
}
|
||||
default:
|
||||
MESSAGE("ERROR : Iterator not implemented");
|
||||
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VtkVolume::nodesIteratorToUNV() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
}
|
||||
|
||||
SMDS_NodeIteratorPtr SMDS_VtkVolume::interlacedNodesIterator() const
|
||||
{
|
||||
return SMDS_NodeIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
|
||||
{
|
||||
return SMDSAbs_Volume;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return node by its index
|
||||
* \param ind - node index
|
||||
* \retval const SMDS_MeshNode* - the node
|
||||
*/
|
||||
const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
if ( aVtkType == VTK_POLYHEDRON)
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
int id = 0, nbPoints = 0;
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
if ( ind < nbPoints + nodesInFace )
|
||||
return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( ptIds[ ind + i ]);
|
||||
nbPoints += nodesInFace;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( this->myVtkID, npts, pts );
|
||||
const std::vector<int>& interlace = SMDS_MeshCell::fromVtkOrder( VTKCellType( aVtkType ));
|
||||
return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ interlace.empty() ? ind : interlace[ind]] );
|
||||
}
|
||||
/*!
|
||||
* \brief Check if a node belongs to the element
|
||||
* \param node - the node to check
|
||||
* \retval int - node index within the element, -1 if not found
|
||||
*/
|
||||
int SMDS_VtkVolume::GetNodeIndex( const SMDS_MeshNode* node ) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
const vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
if ( aVtkType == VTK_POLYHEDRON)
|
||||
{
|
||||
vtkIdType nFaces = 0;
|
||||
vtkIdType* ptIds = 0;
|
||||
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
|
||||
int id = 0;
|
||||
for (int iF = 0; iF < nFaces; iF++)
|
||||
{
|
||||
int nodesInFace = ptIds[id];
|
||||
for ( vtkIdType i = 0; i < nodesInFace; ++i )
|
||||
if ( ptIds[id+i+1] == node->getVtkId() )
|
||||
return id+i-iF;
|
||||
id += (nodesInFace + 1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
vtkIdType npts, *pts;
|
||||
grid->GetCellPoints( this->myVtkID, npts, pts );
|
||||
for ( vtkIdType i = 0; i < npts; ++i )
|
||||
if ( pts[i] == node->getVtkId() )
|
||||
{
|
||||
const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( aVtkType ));
|
||||
return interlace.empty() ? i : interlace[i];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool SMDS_VtkVolume::IsQuadratic() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
// TODO quadratic polyhedrons ?
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_QUADRATIC_TETRA:
|
||||
case VTK_QUADRATIC_PYRAMID:
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SMDS_VtkVolume::IsPoly() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
return (aVtkType == VTK_POLYHEDRON);
|
||||
}
|
||||
|
||||
bool SMDS_VtkVolume::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int rankFirstMedium = 0;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_QUADRATIC_TETRA:
|
||||
rankFirstMedium = 4; // medium nodes are of rank 4 to 9
|
||||
break;
|
||||
case VTK_QUADRATIC_PYRAMID:
|
||||
rankFirstMedium = 5; // medium nodes are of rank 5 to 12
|
||||
break;
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
|
||||
rankFirstMedium = 6; // medium nodes are of rank 6 to 14
|
||||
break;
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON:
|
||||
rankFirstMedium = 8; // medium nodes are of rank 8 to 19
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
vtkIdType nodeId = node->getVtkId();
|
||||
for (int rank = 0; rank < npts; rank++)
|
||||
{
|
||||
if (pts[rank] == nodeId)
|
||||
{
|
||||
if (rank < rankFirstMedium)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MESSAGE("======================================================");
|
||||
MESSAGE("= IsMediumNode: node does not belong to this element =");
|
||||
MESSAGE("======================================================");
|
||||
return false;
|
||||
}
|
||||
|
||||
int SMDS_VtkVolume::NbCornerNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(myVtkID);
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_QUADRATIC_TETRA: return 4;
|
||||
case VTK_QUADRATIC_PYRAMID: return 5;
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE: return 6;
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON: return 8;
|
||||
default:;
|
||||
}
|
||||
return NbNodes();
|
||||
}
|
||||
|
||||
SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
|
||||
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_TETRA:
|
||||
aType = SMDSEntity_Tetra;
|
||||
break;
|
||||
case VTK_PYRAMID:
|
||||
aType = SMDSEntity_Pyramid;
|
||||
break;
|
||||
case VTK_WEDGE:
|
||||
aType = SMDSEntity_Penta;
|
||||
break;
|
||||
case VTK_HEXAHEDRON:
|
||||
aType = SMDSEntity_Hexa;
|
||||
break;
|
||||
case VTK_QUADRATIC_TETRA:
|
||||
aType = SMDSEntity_Quad_Tetra;
|
||||
break;
|
||||
case VTK_QUADRATIC_PYRAMID:
|
||||
aType = SMDSEntity_Quad_Pyramid;
|
||||
break;
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
aType = SMDSEntity_Quad_Penta;
|
||||
break;
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
|
||||
aType = SMDSEntity_BiQuad_Penta;
|
||||
break;
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
aType = SMDSEntity_Quad_Hexa;
|
||||
break;
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON:
|
||||
aType = SMDSEntity_TriQuad_Hexa;
|
||||
break;
|
||||
case VTK_HEXAGONAL_PRISM:
|
||||
aType = SMDSEntity_Hexagonal_Prism;
|
||||
break;
|
||||
case VTK_POLYHEDRON:
|
||||
aType = SMDSEntity_Polyhedra;
|
||||
break;
|
||||
default:
|
||||
aType = SMDSEntity_Polyhedra;
|
||||
break;
|
||||
}
|
||||
return aType;
|
||||
}
|
||||
|
||||
SMDSAbs_GeometryType SMDS_VtkVolume::GetGeomType() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
|
||||
SMDSAbs_GeometryType aType = SMDSGeom_NONE;
|
||||
switch (aVtkType)
|
||||
{
|
||||
case VTK_TETRA:
|
||||
case VTK_QUADRATIC_TETRA:
|
||||
aType = SMDSGeom_TETRA;
|
||||
break;
|
||||
case VTK_PYRAMID:
|
||||
case VTK_QUADRATIC_PYRAMID:
|
||||
aType = SMDSGeom_PYRAMID;
|
||||
break;
|
||||
case VTK_WEDGE:
|
||||
case VTK_QUADRATIC_WEDGE:
|
||||
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
|
||||
aType = SMDSGeom_PENTA;
|
||||
break;
|
||||
case VTK_HEXAHEDRON:
|
||||
case VTK_QUADRATIC_HEXAHEDRON:
|
||||
case VTK_TRIQUADRATIC_HEXAHEDRON:
|
||||
aType = SMDSGeom_HEXA;
|
||||
break;
|
||||
case VTK_HEXAGONAL_PRISM:
|
||||
aType = SMDSGeom_HEXAGONAL_PRISM;
|
||||
break;
|
||||
case VTK_POLYHEDRON:
|
||||
aType = SMDSGeom_POLYHEDRA;
|
||||
break;
|
||||
default:
|
||||
aType = SMDSGeom_POLYHEDRA;
|
||||
break;
|
||||
}
|
||||
return aType;
|
||||
}
|
||||
|
||||
vtkIdType SMDS_VtkVolume::GetVtkType() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aType = grid->GetCellType(myVtkID);
|
||||
return aType;
|
||||
}
|
||||
|
||||
void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid,
|
||||
const vtkIdType * nodeIds,
|
||||
int nbNodes,
|
||||
double* result)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
result[j] = 0;
|
||||
if (nbNodes <= 0)
|
||||
return;
|
||||
for (int i = 0; i < nbNodes; i++)
|
||||
{
|
||||
double *coords = grid->GetPoint(nodeIds[i]);
|
||||
for (int j = 0; j < 3; j++)
|
||||
result[j] += coords[j];
|
||||
}
|
||||
for (int j = 0; j < 3; j++)
|
||||
result[j] = result[j] / nbNodes;
|
||||
return;
|
||||
}
|
||||
|
||||
bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d)
|
||||
{
|
||||
double u[3], v[3], w[3];
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
u[j] = b[j] - a[j];
|
||||
v[j] = c[j] - a[j];
|
||||
w[j] = d[j] - a[j];
|
||||
}
|
||||
double prodmixte = ((u[1]*v[2] - u[2]*v[1]) * w[0]
|
||||
+ (u[2]*v[0] - u[0]*v[2]) * w[1]
|
||||
+ (u[0]*v[1] - u[1]*v[0]) * w[2] );
|
||||
return (prodmixte < 0);
|
||||
}
|
||||
|
||||
/*! For polyhedron only
|
||||
* @return actual number of nodes (not the sum of nodes of all faces)
|
||||
*/
|
||||
int SMDS_VtkVolume::NbUniqueNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
return grid->GetCell(myVtkID)->GetNumberOfPoints();
|
||||
}
|
||||
|
||||
/*! For polyhedron use only
|
||||
* @return iterator on actual nodes (not through the faces)
|
||||
*/
|
||||
SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const
|
||||
{
|
||||
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _SMDS_VTKVOLUME_HXX_
|
||||
#define _SMDS_VTKVOLUME_HXX_
|
||||
|
||||
#include "SMESH_SMDS.hxx"
|
||||
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_UnstructuredGrid.hxx"
|
||||
#include <vector>
|
||||
|
||||
class SMDS_EXPORT SMDS_VtkVolume: public SMDS_MeshVolume
|
||||
{
|
||||
public:
|
||||
SMDS_VtkVolume();
|
||||
SMDS_VtkVolume(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
~SMDS_VtkVolume();
|
||||
void init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
|
||||
//#ifdef VTK_HAVE_POLYHEDRON
|
||||
void initPoly(const std::vector<vtkIdType>& nodeIds,
|
||||
const std::vector<int>& nbNodesPerFace, SMDS_Mesh* mesh);
|
||||
//#endif
|
||||
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||
|
||||
virtual void Print(std::ostream & OS) const;
|
||||
virtual int NbFaces() const;
|
||||
virtual int NbNodes() const;
|
||||
virtual int NbEdges() const;
|
||||
|
||||
// 1 <= face_ind <= NbFaces()
|
||||
int NbFaceNodes (const int face_ind) const;
|
||||
// 1 <= face_ind <= NbFaces()
|
||||
// 1 <= node_ind <= NbFaceNodes()
|
||||
const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
|
||||
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
virtual vtkIdType GetVtkType() const;
|
||||
virtual SMDSAbs_EntityType GetEntityType() const;
|
||||
virtual SMDSAbs_GeometryType GetGeomType() const;
|
||||
virtual const SMDS_MeshNode* GetNode(const int ind) const;
|
||||
virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
|
||||
virtual bool IsQuadratic() const;
|
||||
virtual bool IsPoly() const;
|
||||
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
|
||||
virtual int NbCornerNodes() const;
|
||||
static void gravityCenter(SMDS_UnstructuredGrid* grid,
|
||||
const vtkIdType *nodeIds,
|
||||
int nbNodes,
|
||||
double* result);
|
||||
static bool isForward(double* a,double* b,double* c,double* d);
|
||||
int NbUniqueNodes() const;
|
||||
SMDS_ElemIteratorPtr uniqueNodesIterator() const;
|
||||
std::vector<int> GetQuantities() const;
|
||||
|
||||
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
|
||||
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const;
|
||||
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
@ -358,12 +358,9 @@ bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
|
||||
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
|
||||
while ( nIt->more() )
|
||||
{
|
||||
const SMDS_MeshNode* node = nIt->next();
|
||||
const SMDS_PositionPtr& pos = node->GetPosition();
|
||||
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
|
||||
SMDS_EdgePositionPtr epos = nIt->next()->GetPosition();
|
||||
if ( !epos )
|
||||
return false;
|
||||
const SMDS_EdgePosition* epos =
|
||||
static_cast<const SMDS_EdgePosition*>(node->GetPosition());
|
||||
if ( !paramSet.insert( epos->GetUParameter() ).second )
|
||||
return false; // equal parameters
|
||||
}
|
||||
@ -424,11 +421,9 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM
|
||||
const SMDS_MeshNode* node = nIt->next();
|
||||
if ( ignoreMediumNodes && SMESH_MesherHelper::IsMedium( node, typeToCheck ))
|
||||
continue;
|
||||
const SMDS_PositionPtr& pos = node->GetPosition();
|
||||
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
|
||||
SMDS_EdgePositionPtr epos = node->GetPosition();
|
||||
if ( ! epos )
|
||||
return false;
|
||||
const SMDS_EdgePosition* epos =
|
||||
static_cast<const SMDS_EdgePosition*>(node->GetPosition());
|
||||
theNodes.insert( theNodes.end(), make_pair( epos->GetUParameter(), node ));
|
||||
++nbNodes;
|
||||
}
|
||||
@ -914,7 +909,12 @@ bool SMESH_Algo::error(SMESH_ComputeErrorPtr error)
|
||||
if ( error ) {
|
||||
_error = error->myName;
|
||||
_comment = error->myComment;
|
||||
_badInputElements = error->myBadElements;
|
||||
if ( error->HasBadElems() )
|
||||
{
|
||||
SMESH_BadInputElements* badElems = static_cast<SMESH_BadInputElements*>( error.get() );
|
||||
_badInputElements = badElems->GetElements();
|
||||
_mesh = badElems->GetMesh();
|
||||
}
|
||||
return error->IsOK();
|
||||
}
|
||||
return true;
|
||||
@ -928,11 +928,15 @@ bool SMESH_Algo::error(SMESH_ComputeErrorPtr error)
|
||||
|
||||
SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const
|
||||
{
|
||||
SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( _error, _comment, this );
|
||||
// hope this method is called by only SMESH_subMesh after this->Compute()
|
||||
err->myBadElements.splice( err->myBadElements.end(),
|
||||
(list<const SMDS_MeshElement*>&) _badInputElements );
|
||||
return err;
|
||||
if ( !_badInputElements.empty() && _mesh )
|
||||
{
|
||||
SMESH_BadInputElements* err = new SMESH_BadInputElements( _mesh, _error, _comment, this );
|
||||
// hope this method is called by only SMESH_subMesh after this->Compute()
|
||||
err->myBadElements.splice( err->myBadElements.end(),
|
||||
(list<const SMDS_MeshElement*>&) _badInputElements );
|
||||
return SMESH_ComputeErrorPtr( err );
|
||||
}
|
||||
return SMESH_ComputeError::New( _error, _comment, this );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -950,6 +954,7 @@ void SMESH_Algo::InitComputeError()
|
||||
if ( (*elem)->GetID() < 1 )
|
||||
delete *elem;
|
||||
_badInputElements.clear();
|
||||
_mesh = 0;
|
||||
|
||||
_computeCanceled = false;
|
||||
_progressTic = 0;
|
||||
@ -1243,7 +1248,7 @@ bool SMESH_2D_Algo::FixInternalNodes(const SMESH_ProxyMesh& mesh,
|
||||
gp_Pnt p = S->Value( uv.Coord(1), uv.Coord(2));
|
||||
const SMDS_MeshNode* n = nodeRows[iRow][iCol];
|
||||
meshDS->MoveNode( n, p.X(), p.Y(), p.Z() );
|
||||
if ( SMDS_FacePosition* pos = dynamic_cast< SMDS_FacePosition*>( n->GetPosition() ))
|
||||
if ( SMDS_FacePositionPtr pos = n->GetPosition() )
|
||||
pos->SetParameters( uv.Coord(1), uv.Coord(2) );
|
||||
}
|
||||
}
|
||||
|
@ -462,6 +462,7 @@ protected:
|
||||
int _error; //!< SMESH_ComputeErrorName or anything algo specific
|
||||
std::string _comment; //!< any text explaining what is wrong in Compute()
|
||||
std::list<const SMDS_MeshElement*> _badInputElements; //!< to explain COMPERR_BAD_INPUT_MESH
|
||||
const SMDS_Mesh* _mesh; //!< mesh being computed, needed to create SMESH_BadInputElements
|
||||
|
||||
volatile bool _computeCanceled; //!< is set to True while computing to stop it
|
||||
|
||||
|
@ -54,9 +54,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
//#include <vtkDebugLeaks.h>
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Constructor
|
||||
@ -68,9 +65,7 @@ SMESH_Gen::SMESH_Gen()
|
||||
_localId = 0;
|
||||
_hypId = 0;
|
||||
_segmentation = _nbSegments = 10;
|
||||
SMDS_Mesh::_meshList.clear();
|
||||
_compute_canceled = false;
|
||||
//vtkDebugLeaks::SetExitError(0);
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -407,8 +402,10 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
}
|
||||
|
||||
if ( aCompactMesh )
|
||||
aMesh.GetMeshDS()->compactMesh();
|
||||
|
||||
{
|
||||
aMesh.GetMeshDS()->Modified();
|
||||
aMesh.GetMeshDS()->CompactMesh();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user