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

+    class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
This commit is contained in:
eap 2012-07-19 12:47:14 +00:00
parent e3fea174fd
commit 61cd810fbe
2 changed files with 82 additions and 102 deletions

View File

@ -22,31 +22,36 @@
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include <set> #include "SMDS_BallElement.hxx"
#include <limits> #include "SMDS_Iterator.hxx"
#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_Mesh.hxx"
#include "SMESH_OctreeNode.hxx"
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepClass_FaceClassifier.hxx> #include <BRepClass_FaceClassifier.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Iterator.hxx>
#include <Geom_CylindricalSurface.hxx> #include <Geom_CylindricalSurface.hxx>
#include <Geom_Plane.hxx> #include <Geom_Plane.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx> #include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_SequenceOfAsciiString.hxx> #include <TColStd_SequenceOfAsciiString.hxx>
#include <TColgp_Array1OfXYZ.hxx> #include <TColgp_Array1OfXYZ.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Ax3.hxx> #include <gp_Ax3.hxx>
#include <gp_Cylinder.hxx> #include <gp_Cylinder.hxx>
#include <gp_Dir.hxx> #include <gp_Dir.hxx>
@ -55,21 +60,12 @@
#include <gp_Vec.hxx> #include <gp_Vec.hxx>
#include <gp_XYZ.hxx> #include <gp_XYZ.hxx>
#include "SMDS_Mesh.hxx"
#include "SMDS_Iterator.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_QuadraticEdge.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESHDS_GroupBase.hxx"
#include "SMESH_OctreeNode.hxx"
#include <vtkMeshQuality.h> #include <vtkMeshQuality.h>
#include <set>
#include <limits>
/* /*
AUXILIARY METHODS AUXILIARY METHODS
*/ */
@ -1966,6 +1962,34 @@ void MultiConnection2D::GetValues(MValues& theValues){
} }
/*
Class : BallDiameter
Description : Functor returning diameter of a ball element
*/
double BallDiameter::GetValue( long theId )
{
double diameter = 0;
if ( const SMDS_BallElement* ball =
dynamic_cast<const SMDS_BallElement*>( myMesh->FindElement( theId )))
{
diameter = ball->GetDiameter();
}
return diameter;
}
double BallDiameter::GetBadRate( double Value, int /*nbNodes*/ ) const
{
// meaningless as it is not a quality control functor
return Value;
}
SMDSAbs_ElementType BallDiameter::GetType() const
{
return SMDSAbs_Ball;
}
/* /*
PREDICATES PREDICATES
*/ */
@ -3156,24 +3180,7 @@ void Filter::SetPredicate( PredicatePtr thePredicate )
myPredicate = thePredicate; myPredicate = thePredicate;
} }
template<class TElement, class TIterator, class TPredicate> void Filter::GetElementsId( const SMDS_Mesh* theMesh,
inline void FillSequence(const TIterator& theIterator,
TPredicate& thePredicate,
Filter::TIdSequence& theSequence)
{
if ( theIterator ) {
while( theIterator->more() ) {
TElement anElem = theIterator->next();
long anId = anElem->GetID();
if ( thePredicate->IsSatisfy( anId ) )
theSequence.push_back( anId );
}
}
}
void
Filter::
GetElementsId( const SMDS_Mesh* theMesh,
PredicatePtr thePredicate, PredicatePtr thePredicate,
TIdSequence& theSequence ) TIdSequence& theSequence )
{ {
@ -3184,30 +3191,18 @@ GetElementsId( const SMDS_Mesh* theMesh,
thePredicate->SetMesh( theMesh ); thePredicate->SetMesh( theMesh );
SMDSAbs_ElementType aType = thePredicate->GetType(); SMDS_ElemIteratorPtr elemIt = theMesh->elementsIterator( thePredicate->GetType() );
switch(aType){ if ( elemIt ) {
case SMDSAbs_Node: while ( elemIt->more() ) {
FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),thePredicate,theSequence); const SMDS_MeshElement* anElem = elemIt->next();
break; long anId = anElem->GetID();
case SMDSAbs_Edge: if ( thePredicate->IsSatisfy( anId ) )
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence); theSequence.push_back( anId );
break; }
case SMDSAbs_Face:
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_Volume:
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_All:
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
} }
} }
void void Filter::GetElementsId( const SMDS_Mesh* theMesh,
Filter::GetElementsId( const SMDS_Mesh* theMesh,
Filter::TIdSequence& theSequence ) Filter::TIdSequence& theSequence )
{ {
GetElementsId(theMesh,myPredicate,theSequence); GetElementsId(theMesh,myPredicate,theSequence);
@ -3872,36 +3867,9 @@ void ElementsOnShape::process()
if (myShape.IsNull() || myMesh == 0) if (myShape.IsNull() || myMesh == 0)
return; return;
if (myType == SMDSAbs_Node) SMDS_ElemIteratorPtr anIter = myMesh->elementsIterator(myType);
{
SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
while (anIter->more()) while (anIter->more())
process(anIter->next()); process(anIter->next());
}
else
{
if (myType == SMDSAbs_Edge || myType == SMDSAbs_All)
{
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
while (anIter->more())
process(anIter->next());
}
if (myType == SMDSAbs_Face || myType == SMDSAbs_All)
{
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
while (anIter->more()) {
process(anIter->next());
}
}
if (myType == SMDSAbs_Volume || myType == SMDSAbs_All)
{
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
while (anIter->more())
process(anIter->next());
}
}
} }
void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr) void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr)
@ -3916,9 +3884,8 @@ void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr)
while (aNodeItr->more() && (isSatisfy == myAllNodesFlag)) while (aNodeItr->more() && (isSatisfy == myAllNodesFlag))
{ {
SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next(); SMESH_TNodeXYZ aPnt ( aNodeItr->next() );
gp_Pnt aPnt (aNode->X(), aNode->Y(), aNode->Z()); centerXYZ += aPnt;
centerXYZ += aPnt.XYZ();
switch (myCurShapeType) switch (myCurShapeType)
{ {
@ -3951,7 +3918,7 @@ void ElementsOnShape::process (const SMDS_MeshElement* theElemPtr)
break; break;
case TopAbs_VERTEX: case TopAbs_VERTEX:
{ {
isSatisfy = (aPnt.Distance(myCurPnt) <= myToler); isSatisfy = (myCurPnt.Distance(aPnt) <= myToler);
} }
break; break;
default: default:

View File

@ -331,6 +331,19 @@ namespace SMESH{
void GetValues(MValues& theValues); void GetValues(MValues& theValues);
}; };
typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr; typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
/*
Class : BallDiameter
Description : Functor returning diameter of a ball element
*/
class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
public:
virtual double GetValue( long theElementId );
virtual double GetBadRate( double Value, int nbNodes ) const;
virtual SMDSAbs_ElementType GetType() const;
};
/* /*
PREDICATES PREDICATES
*/ */