Added support for polygones and polyhedres

This commit is contained in:
enk 2005-02-18 07:42:46 +00:00
parent 81a42f6507
commit 9b4762cb6b
8 changed files with 185 additions and 65 deletions

View File

@ -58,14 +58,17 @@ module SMESH
ADD_EDGE, ADD_EDGE,
ADD_TRIANGLE, ADD_TRIANGLE,
ADD_QUADRANGLE, ADD_QUADRANGLE,
ADD_POLYGON,
ADD_TETRAHEDRON, ADD_TETRAHEDRON,
ADD_PYRAMID, ADD_PYRAMID,
ADD_PRISM, ADD_PRISM,
ADD_HEXAHEDRON, ADD_HEXAHEDRON,
ADD_POLYHEDRON,
REMOVE_NODE, REMOVE_NODE,
REMOVE_ELEMENT, REMOVE_ELEMENT,
MOVE_NODE, MOVE_NODE,
CHANGE_ELEMENT_NODES, CHANGE_ELEMENT_NODES,
CHANGE_POLYHEDRON_NODES,
RENUMBER RENUMBER
}; };
@ -375,6 +378,9 @@ module SMESH
long NbQuadrangles() long NbQuadrangles()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbPolygones()
raises (SALOME::SALOME_Exception);
long NbVolumes() long NbVolumes()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
@ -390,6 +396,9 @@ module SMESH
long NbPrisms() long NbPrisms()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbPolyhedrones()
raises (SALOME::SALOME_Exception);
long NbSubMesh() long NbSubMesh()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
@ -461,7 +470,7 @@ module SMESH
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
}; };
/* /*!
* This interface makes modifications on the Mesh - removing elements and nodes etc. * This interface makes modifications on the Mesh - removing elements and nodes etc.
*/ */
interface NumericalFunctor; interface NumericalFunctor;
@ -480,6 +489,25 @@ module SMESH
boolean AddVolume(in long_array IDsOfNodes); boolean AddVolume(in long_array IDsOfNodes);
//boolean AddPolygonalFace (in long_array IdsOfNodes);
/*!
* Create volume of many faces, giving nodes for each face.
* \param IdsOfNodes List of node IDs for volume creation face by face.
* \param Quantities List of integer values, Quantities[i]
* gives quantity of nodes in face number i.
*/
boolean AddPolyhedralVolume (in long_array IdsOfNodes,
in long_array Quantities);
/*!
* Create volume of many faces, giving IDs of existing faces.
* \param IdsOfFaces List of face IDs for volume creation.
* \note The created volume will refer only to nodes
* of the given faces, not to the faces itself.
*/
boolean AddPolyhedralVolumeByFaces (in long_array IdsOfFaces);
boolean MoveNode(in long NodeID, in double x, in double y, in double z); boolean MoveNode(in long NodeID, in double x, in double y, in double z);
boolean InverseDiag(in long NodeID1, in long NodeID2); boolean InverseDiag(in long NodeID1, in long NodeID2);

View File

@ -850,6 +850,19 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
return Nb; return Nb;
} }
///////////////////////////////////////////////////////////////////////////////
/// Return the number of polygone faces in the mesh. This method run in O(n)
///////////////////////////////////////////////////////////////////////////////
int SMESH_Mesh::NbPolygones() throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
int Nb = 0;
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->IsPoly()) Nb++;
return Nb;
}
//============================================================================= //=============================================================================
/*! /*!
* *
@ -897,6 +910,15 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
return Nb; return Nb;
} }
int SMESH_Mesh::NbPolyhedrones() throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->IsPoly()) Nb++;
return Nb;
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -165,6 +165,8 @@ public:
int NbTriangles() throw(SALOME_Exception); int NbTriangles() throw(SALOME_Exception);
int NbQuadrangles() throw(SALOME_Exception); int NbQuadrangles() throw(SALOME_Exception);
int NbPolygones() throw(SALOME_Exception);
int NbVolumes() throw(SALOME_Exception); int NbVolumes() throw(SALOME_Exception);
@ -173,6 +175,8 @@ public:
int NbHexas() throw(SALOME_Exception); int NbHexas() throw(SALOME_Exception);
int NbPyramids() throw(SALOME_Exception); int NbPyramids() throw(SALOME_Exception);
int NbPolyhedrones() throw(SALOME_Exception);
int NbPrisms() throw(SALOME_Exception); int NbPrisms() throw(SALOME_Exception);

View File

@ -792,18 +792,21 @@ SMESH_Hypothesis::Hypothesis_Status
ASSERT(algo); ASSERT(algo);
if (!algo->CheckHypothesis((*_father),_subShape, ret )) if (!algo->CheckHypothesis((*_father),_subShape, ret ))
{ {
//two applying algo on the same shape not allowed
_meshDS->RemoveHypothesis(_subShape, anHyp);
if ( !SMESH_Hypothesis::IsStatusFatal( ret )) if ( !SMESH_Hypothesis::IsStatusFatal( ret ))
// ret should be fatal: anHyp was not added // ret should be fatal: anHyp was not added
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
} }
else if (!_father->IsUsedHypothesis( anHyp, _subShape )) else if (SMESH_Hypothesis::IsStatusFatal( ret ))
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
if (SMESH_Hypothesis::IsStatusFatal( ret ))
{ {
MESSAGE("do not add extra hypothesis");
_meshDS->RemoveHypothesis(_subShape, anHyp); _meshDS->RemoveHypothesis(_subShape, anHyp);
} }
else if (!_father->IsUsedHypothesis( anHyp, _subShape ))
{
_meshDS->RemoveHypothesis(_subShape, anHyp);
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
}
else else
{ {
modifiedHyp = true; modifiedHyp = true;
@ -812,19 +815,11 @@ SMESH_Hypothesis::Hypothesis_Status
} }
case ADD_ALGO: { //already existing algo : on father ? case ADD_ALGO: { //already existing algo : on father ?
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo changes SetAlgoState(HYP_OK);
SMESH_HypoFilter f;
f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo ));
const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true );
if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
modifiedHyp = true;
break; break;
} }
case REMOVE_HYP: { case REMOVE_HYP: {
@ -845,13 +840,13 @@ SMESH_Hypothesis::Hypothesis_Status
} }
else else
{ {
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo remains SetAlgoState(HYP_OK);
if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
// check if same algo remains
if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) )
modifiedHyp = true;
} }
break; break;
} }
@ -860,6 +855,7 @@ SMESH_Hypothesis::Hypothesis_Status
ASSERT(algo); ASSERT(algo);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
{ {
SetAlgoState(HYP_OK);
if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp
modifiedHyp = true; modifiedHyp = true;
} }
@ -867,35 +863,27 @@ SMESH_Hypothesis::Hypothesis_Status
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
break; break;
} }
case ADD_FATHER_ALGO: { case ADD_FATHER_ALGO: { // a new algo on father
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
if ( algo == anHyp ) { // a new algo on father if ( algo == anHyp ) {
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo changes SetAlgoState(HYP_OK);
SMESH_HypoFilter f;
f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo ));
const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true );
if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
modifiedHyp = true;
} }
break; break;
} }
case REMOVE_FATHER_HYP: { case REMOVE_FATHER_HYP: {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// is there the same local hyp or maybe a new father algo applied? SetAlgoState(HYP_OK);
if ( !GetSimilarAttached( _subShape, anHyp ) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
// is there the same local hyp or maybe a new father algo applied?
if ( !GetSimilarAttached( _subShape, anHyp ) )
modifiedHyp = true;
break; break;
} }
case REMOVE_FATHER_ALGO: { case REMOVE_FATHER_ALGO: {
@ -906,13 +894,13 @@ SMESH_Hypothesis::Hypothesis_Status
} }
else else
{ {
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo changes SetAlgoState(HYP_OK);
if ( string(algo->GetName()) != string( anHyp->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
// is there the same local algo or maybe a new father algo applied?
if ( !GetSimilarAttached( _subShape, anHyp ))
modifiedHyp = true;
} }
break; break;
} }
@ -1497,21 +1485,21 @@ void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent)
void SMESH_subMesh::CleanDependants() void SMESH_subMesh::CleanDependants()
{ {
//MESSAGE("SMESH_subMesh::CleanDependants: shape type " << _subShape.ShapeType() );
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
for (; it.More(); it.Next()) for (; it.More(); it.Next())
{ {
const TopoDS_Shape& ancestor = it.Value(); const TopoDS_Shape& ancestor = it.Value();
// PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEANDEP) //MESSAGE("ancestor shape type " << ancestor.ShapeType() );
// will erase mesh on other shapes in a compound SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
if ( ancestor.ShapeType() >= TopAbs_SOLID ) { if (aSubMesh)
SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); aSubMesh->ComputeStateEngine(CLEANDEP);
if (aSubMesh)
aSubMesh->ComputeStateEngine(CLEANDEP);
}
} }
ComputeStateEngine(CLEAN); ComputeStateEngine(CLEAN);
} }
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -124,24 +124,36 @@ CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
//============================================================================= //=============================================================================
/*! /*!
* * AddFace
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
{ {
int NbNodes = IDsOfNodes.length(); int NbNodes = IDsOfNodes.length();
const SMDS_MeshNode* nodes[4]; if (NbNodes < 3)
for(int i=0;i<NbNodes;i++) nodes[i]=GetMeshDS()->FindNode(IDsOfNodes[i]); {
if (NbNodes == 3) return false;
{ }
GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
} std::vector<const SMDS_MeshNode*> nodes (NbNodes);
else if (NbNodes == 4) //const SMDS_MeshNode* nodes [NbNodes];
{ for (int i = 0; i < NbNodes; i++)
GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); nodes[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
}
return true; if (NbNodes == 3)
{
GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]);
}
else if (NbNodes == 4)
{
GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
}
else
{
GetMeshDS()->AddPolygonalFace(nodes);
}
return true;
}; };
//============================================================================= //=============================================================================
@ -167,6 +179,49 @@ CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
return true; return true;
}; };
//=============================================================================
/*!
* AddPolyhedralVolume
*/
//=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume
(const SMESH::long_array & IDsOfNodes,
const SMESH::long_array & Quantities)
{
int NbNodes = IDsOfNodes.length();
std::vector<const SMDS_MeshNode*> n (NbNodes);
//const SMDS_MeshNode* n [NbNodes];
for (int i = 0; i < NbNodes; i++)
n[i] = GetMeshDS()->FindNode(IDsOfNodes[i]);
int NbFaces = Quantities.length();
std::vector<int> q (NbFaces);
//int q [NbFaces];
for (int j = 0; j < NbFaces; j++)
q[j] = Quantities[j];
GetMeshDS()->AddPolyhedralVolume(n, q);
return true;
};
//=============================================================================
/*!
* AddPolyhedralVolumeByFaces
*/
//=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
(const SMESH::long_array & IdsOfFaces)
{
int NbFaces = IdsOfFaces.length();
std::vector<const SMDS_MeshFace*> faces (NbFaces);
for (int i = 0; i < NbFaces; i++)
faces[i] = (SMDS_MeshFace *)GetMeshDS()->FindElement(IdsOfFaces[i]);
//GetMeshDS()->AddPolyhedralVolumeByFaces(faces);
//return true;
return false;
};
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -51,6 +51,11 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes); CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes);
CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes); CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes);
CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes); CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes);
CORBA::Boolean AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes,
const SMESH::long_array & Quantities);
CORBA::Boolean AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
CORBA::Boolean MoveNode(CORBA::Long NodeID, CORBA::Boolean MoveNode(CORBA::Long NodeID,
CORBA::Double x, CORBA::Double y, CORBA::Double z); CORBA::Double x, CORBA::Double y, CORBA::Double z);

View File

@ -1193,6 +1193,12 @@ CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception)
return _impl->NbQuadrangles(); return _impl->NbQuadrangles();
} }
CORBA::Long SMESH_Mesh_i::NbPolygones()throw(SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
return _impl->NbPolygones();
}
//============================================================================= //=============================================================================
/*! /*!
* *
@ -1228,6 +1234,12 @@ CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception)
return _impl->NbPrisms(); return _impl->NbPrisms();
} }
CORBA::Long SMESH_Mesh_i::NbPolyhedrones()throw(SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
return _impl->NbPolyhedrones();
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -182,6 +182,9 @@ public:
CORBA::Long NbQuadrangles() CORBA::Long NbQuadrangles()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long NbPolygones()
throw (SALOME::SALOME_Exception);
CORBA::Long NbVolumes() CORBA::Long NbVolumes()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
@ -197,6 +200,9 @@ public:
CORBA::Long NbPrisms() CORBA::Long NbPrisms()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
CORBA::Long NbPolyhedrones()
throw (SALOME::SALOME_Exception);
CORBA::Long NbSubMesh() CORBA::Long NbSubMesh()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);