mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-27 20:50:32 +05:00
IPAL53401: BelongToGeom is very long on multiple lines
More optimization of octree + parallel update of GroupOnFilter Remove useless warnings
This commit is contained in:
parent
b582abf7fa
commit
911ca90c3d
@ -40,6 +40,7 @@
|
||||
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
@ -3950,9 +3951,9 @@ SMDSAbs_ElementType BelongToMeshGroup::GetType() const
|
||||
return myGroup ? myGroup->GetType() : SMDSAbs_All;
|
||||
}
|
||||
|
||||
/*
|
||||
ElementsOnSurface
|
||||
*/
|
||||
//================================================================================
|
||||
// ElementsOnSurface
|
||||
//================================================================================
|
||||
|
||||
ElementsOnSurface::ElementsOnSurface()
|
||||
{
|
||||
@ -4086,18 +4087,27 @@ bool ElementsOnSurface::isOnSurface( const SMDS_MeshNode* theNode )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
ElementsOnShape
|
||||
*/
|
||||
//================================================================================
|
||||
// ElementsOnShape
|
||||
//================================================================================
|
||||
|
||||
namespace {
|
||||
const int theIsCheckedFlag = 0x0000100;
|
||||
}
|
||||
|
||||
struct ElementsOnShape::Classifier
|
||||
{
|
||||
Classifier(const TopoDS_Shape& s, double tol) { Init(s,tol); }
|
||||
void Init(const TopoDS_Shape& s, double tol);
|
||||
bool IsOut(const gp_Pnt& p) { return myIsChecked = true, (this->*myIsOutFun)( p ); }
|
||||
//Classifier(const TopoDS_Shape& s, double tol) { Init(s,tol); }
|
||||
void Init(const TopoDS_Shape& s, double tol, const Bnd_B3d* box = 0 );
|
||||
bool IsOut(const gp_Pnt& p) { return SetChecked( true ), (this->*myIsOutFun)( p ); }
|
||||
TopAbs_ShapeEnum ShapeType() const { return myShape.ShapeType(); }
|
||||
Bnd_B3d* GetBndBox() { return & myBox; }
|
||||
bool& IsChecked() { return myIsChecked; }
|
||||
const TopoDS_Shape& Shape() const { return myShape; }
|
||||
const Bnd_B3d* GetBndBox() const { return & myBox; }
|
||||
bool IsChecked() { return myFlags & theIsCheckedFlag; }
|
||||
bool IsSetFlag( int flag ) const { return myFlags & flag; }
|
||||
void SetChecked( bool is ) { is ? SetFlag( theIsCheckedFlag ) : UnsetFlag( theIsCheckedFlag ); }
|
||||
void SetFlag ( int flag ) { myFlags |= flag; }
|
||||
void UnsetFlag( int flag ) { myFlags &= ~flag; }
|
||||
private:
|
||||
bool isOutOfSolid (const gp_Pnt& p);
|
||||
bool isOutOfBox (const gp_Pnt& p);
|
||||
@ -4106,7 +4116,7 @@ private:
|
||||
bool isOutOfVertex(const gp_Pnt& p);
|
||||
bool isBox (const TopoDS_Shape& s);
|
||||
|
||||
bool (Classifier::* myIsOutFun)(const gp_Pnt& p);
|
||||
bool (Classifier::* myIsOutFun)(const gp_Pnt& p);
|
||||
BRepClass3d_SolidClassifier mySolidClfr;
|
||||
Bnd_B3d myBox;
|
||||
GeomAPI_ProjectPointOnSurf myProjFace;
|
||||
@ -4114,12 +4124,15 @@ private:
|
||||
gp_Pnt myVertexXYZ;
|
||||
TopoDS_Shape myShape;
|
||||
double myTol;
|
||||
bool myIsChecked;
|
||||
int myFlags;
|
||||
};
|
||||
|
||||
struct ElementsOnShape::OctreeClassifier : public SMESH_Octree
|
||||
{
|
||||
OctreeClassifier( const std::vector< ElementsOnShape::Classifier* >& classifiers );
|
||||
OctreeClassifier( const OctreeClassifier* otherTree,
|
||||
const std::vector< ElementsOnShape::Classifier >& clsOther,
|
||||
std::vector< ElementsOnShape::Classifier >& cls );
|
||||
void GetClassifiersAtPoint( const gp_XYZ& p,
|
||||
std::vector< ElementsOnShape::Classifier* >& classifiers );
|
||||
protected:
|
||||
@ -4145,6 +4158,25 @@ ElementsOnShape::~ElementsOnShape()
|
||||
clearClassifiers();
|
||||
}
|
||||
|
||||
Predicate* ElementsOnShape::clone() const
|
||||
{
|
||||
ElementsOnShape* cln = new ElementsOnShape();
|
||||
cln->SetAllNodes ( myAllNodesFlag );
|
||||
cln->SetTolerance( myToler );
|
||||
cln->SetMesh ( myMeshModifTracer.GetMesh() );
|
||||
cln->myShape = myShape; // avoid creation of myClassifiers
|
||||
cln->SetShape ( myShape, myType );
|
||||
cln->myClassifiers.resize( myClassifiers.size() );
|
||||
for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||
cln->myClassifiers[ i ].Init( BRepBuilderAPI_Copy( myClassifiers[ i ].Shape()),
|
||||
myToler, myClassifiers[ i ].GetBndBox() );
|
||||
if ( myOctree ) // copy myOctree
|
||||
{
|
||||
cln->myOctree = new OctreeClassifier( myOctree, myClassifiers, cln->myClassifiers );
|
||||
}
|
||||
return cln;
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType ElementsOnShape::GetType() const
|
||||
{
|
||||
return myType;
|
||||
@ -4233,7 +4265,7 @@ void ElementsOnShape::SetShape (const TopoDS_Shape& theShape,
|
||||
clearClassifiers();
|
||||
myClassifiers.resize( shapesMap.Extent() );
|
||||
for ( int i = 0; i < shapesMap.Extent(); ++i )
|
||||
myClassifiers[ i ] = new Classifier( shapesMap( i+1 ), myToler );
|
||||
myClassifiers[ i ].Init( shapesMap( i+1 ), myToler );
|
||||
}
|
||||
|
||||
if ( theType == SMDSAbs_Node )
|
||||
@ -4249,15 +4281,15 @@ void ElementsOnShape::SetShape (const TopoDS_Shape& theShape,
|
||||
|
||||
void ElementsOnShape::clearClassifiers()
|
||||
{
|
||||
for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||
delete myClassifiers[ i ];
|
||||
// for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||
// delete myClassifiers[ i ];
|
||||
myClassifiers.clear();
|
||||
|
||||
delete myOctree;
|
||||
myOctree = 0;
|
||||
}
|
||||
|
||||
bool ElementsOnShape::IsSatisfy (long elemId)
|
||||
bool ElementsOnShape::IsSatisfy( long elemId )
|
||||
{
|
||||
const SMDS_Mesh* mesh = myMeshModifTracer.GetMesh();
|
||||
const SMDS_MeshElement* elem =
|
||||
@ -4270,9 +4302,12 @@ bool ElementsOnShape::IsSatisfy (long elemId)
|
||||
gp_XYZ centerXYZ (0, 0, 0);
|
||||
|
||||
if ( !myOctree && myClassifiers.size() > 5 )
|
||||
myOctree = new OctreeClassifier( myClassifiers );
|
||||
|
||||
std::vector< Classifier* >& classifiers = myOctree ? myWorkClassifiers : myClassifiers;
|
||||
{
|
||||
myWorkClassifiers.resize( myClassifiers.size() );
|
||||
for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||
myWorkClassifiers[ i ] = & myClassifiers[ i ];
|
||||
myOctree = new OctreeClassifier( myWorkClassifiers );
|
||||
}
|
||||
|
||||
SMDS_ElemIteratorPtr aNodeItr = elem->nodesIterator();
|
||||
while (aNodeItr->more() && (isSatisfy == myAllNodesFlag))
|
||||
@ -4287,34 +4322,45 @@ bool ElementsOnShape::IsSatisfy (long elemId)
|
||||
{
|
||||
myWorkClassifiers.clear();
|
||||
myOctree->GetClassifiersAtPoint( aPnt, myWorkClassifiers );
|
||||
|
||||
for ( size_t i = 0; i < myWorkClassifiers.size(); ++i )
|
||||
myWorkClassifiers[i]->SetChecked( false );
|
||||
|
||||
for ( size_t i = 0; i < myWorkClassifiers.size() && isNodeOut; ++i )
|
||||
if ( !myWorkClassifiers[i]->IsChecked() )
|
||||
isNodeOut = myWorkClassifiers[i]->IsOut( aPnt );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( size_t i = 0; i < myClassifiers.size() && isNodeOut; ++i )
|
||||
isNodeOut = myClassifiers[i].IsOut( aPnt );
|
||||
}
|
||||
for ( size_t i = 0; i < classifiers.size(); ++i )
|
||||
classifiers[i]->IsChecked() = false;
|
||||
|
||||
for ( size_t i = 0; i < classifiers.size() && isNodeOut; ++i )
|
||||
if ( !classifiers[i]->IsChecked() )
|
||||
isNodeOut = classifiers[i]->IsOut( aPnt );
|
||||
|
||||
setNodeIsOut( aPnt._node, isNodeOut );
|
||||
}
|
||||
isSatisfy = !isNodeOut;
|
||||
}
|
||||
|
||||
// Check the center point for volumes MantisBug 0020168
|
||||
if (isSatisfy &&
|
||||
myAllNodesFlag &&
|
||||
myClassifiers[0]->ShapeType() == TopAbs_SOLID)
|
||||
if ( isSatisfy &&
|
||||
myAllNodesFlag &&
|
||||
myClassifiers[0].ShapeType() == TopAbs_SOLID )
|
||||
{
|
||||
centerXYZ /= elem->NbNodes();
|
||||
isSatisfy = false;
|
||||
for ( size_t i = 0; i < classifiers.size() && !isSatisfy; ++i )
|
||||
isSatisfy = ! classifiers[i]->IsOut( centerXYZ );
|
||||
if ( myOctree )
|
||||
for ( size_t i = 0; i < myWorkClassifiers.size() && !isSatisfy; ++i )
|
||||
isSatisfy = ! myWorkClassifiers[i]->IsOut( centerXYZ );
|
||||
else
|
||||
for ( size_t i = 0; i < myClassifiers.size() && !isSatisfy; ++i )
|
||||
isSatisfy = ! myClassifiers[i].IsOut( centerXYZ );
|
||||
}
|
||||
|
||||
return isSatisfy;
|
||||
}
|
||||
|
||||
void ElementsOnShape::Classifier::Init (const TopoDS_Shape& theShape, double theTol)
|
||||
void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
|
||||
double theTol,
|
||||
const Bnd_B3d* theBox )
|
||||
{
|
||||
myShape = theShape;
|
||||
myTol = theTol;
|
||||
@ -4364,18 +4410,25 @@ void ElementsOnShape::Classifier::Init (const TopoDS_Shape& theShape, double the
|
||||
|
||||
if ( !isShapeBox )
|
||||
{
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add( myShape, box );
|
||||
myBox.Clear();
|
||||
myBox.Add( box.CornerMin() );
|
||||
myBox.Add( box.CornerMax() );
|
||||
gp_XYZ halfSize = 0.5 * ( box.CornerMax().XYZ() - box.CornerMin().XYZ() );
|
||||
for ( int iDim = 1; iDim <= 3; ++iDim )
|
||||
if ( theBox )
|
||||
{
|
||||
double x = halfSize.Coord( iDim );
|
||||
halfSize.SetCoord( iDim, x + Max( myTol, 1e-2 * x ));
|
||||
myBox = *theBox;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add( myShape, box );
|
||||
myBox.Clear();
|
||||
myBox.Add( box.CornerMin() );
|
||||
myBox.Add( box.CornerMax() );
|
||||
gp_XYZ halfSize = 0.5 * ( box.CornerMax().XYZ() - box.CornerMin().XYZ() );
|
||||
for ( int iDim = 1; iDim <= 3; ++iDim )
|
||||
{
|
||||
double x = halfSize.Coord( iDim );
|
||||
halfSize.SetCoord( iDim, x + Max( myTol, 1e-2 * x ));
|
||||
}
|
||||
myBox.SetHSize( halfSize );
|
||||
}
|
||||
myBox.SetHSize( halfSize );
|
||||
}
|
||||
}
|
||||
|
||||
@ -4452,6 +4505,33 @@ OctreeClassifier::OctreeClassifier( const std::vector< ElementsOnShape::Classifi
|
||||
compute();
|
||||
}
|
||||
|
||||
ElementsOnShape::
|
||||
OctreeClassifier::OctreeClassifier( const OctreeClassifier* otherTree,
|
||||
const std::vector< ElementsOnShape::Classifier >& clsOther,
|
||||
std::vector< ElementsOnShape::Classifier >& cls )
|
||||
:SMESH_Octree( new SMESH_TreeLimit )
|
||||
{
|
||||
myBox = new Bnd_B3d( *otherTree->getBox() );
|
||||
|
||||
if (( myIsLeaf = otherTree->isLeaf() ))
|
||||
{
|
||||
myClassifiers.resize( otherTree->myClassifiers.size() );
|
||||
for ( size_t i = 0; i < otherTree->myClassifiers.size(); ++i )
|
||||
{
|
||||
int ind = otherTree->myClassifiers[i] - & clsOther[0];
|
||||
myClassifiers[ i ] = & cls[ ind ];
|
||||
}
|
||||
}
|
||||
else if ( otherTree->myChildren )
|
||||
{
|
||||
myChildren = new SMESH_Tree*[ 8 ];
|
||||
for ( int i = 0; i < nbChildren(); i++ )
|
||||
myChildren[i] =
|
||||
new OctreeClassifier( static_cast<const OctreeClassifier*>( otherTree->myChildren[i]),
|
||||
clsOther, cls );
|
||||
}
|
||||
}
|
||||
|
||||
void ElementsOnShape::
|
||||
OctreeClassifier::GetClassifiersAtPoint( const gp_XYZ& point,
|
||||
std::vector< ElementsOnShape::Classifier* >& result )
|
||||
@ -4475,26 +4555,50 @@ OctreeClassifier::GetClassifiersAtPoint( const gp_XYZ& point,
|
||||
void ElementsOnShape::OctreeClassifier::buildChildrenData()
|
||||
{
|
||||
// distribute myClassifiers among myChildren
|
||||
|
||||
const int childFlag[8] = { 0x0000001,
|
||||
0x0000002,
|
||||
0x0000004,
|
||||
0x0000008,
|
||||
0x0000010,
|
||||
0x0000020,
|
||||
0x0000040,
|
||||
0x0000080 };
|
||||
int nbInChild[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
for ( size_t i = 0; i < myClassifiers.size(); ++i )
|
||||
{
|
||||
for (int j = 0; j < nbChildren(); j++)
|
||||
for ( int j = 0; j < nbChildren(); j++ )
|
||||
{
|
||||
if ( !myClassifiers[i]->GetBndBox()->IsOut( *myChildren[j]->getBox() ))
|
||||
{
|
||||
((OctreeClassifier*)myChildren[j])->myClassifiers.push_back( myClassifiers[i]);
|
||||
myClassifiers[i]->SetFlag( childFlag[ j ]);
|
||||
++nbInChild[ j ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( int j = 0; j < nbChildren(); j++ )
|
||||
{
|
||||
OctreeClassifier* child = static_cast<OctreeClassifier*>( myChildren[ j ]);
|
||||
child->myClassifiers.resize( nbInChild[ j ]);
|
||||
for ( size_t i = 0; nbInChild[ j ] && i < myClassifiers.size(); ++i )
|
||||
{
|
||||
if ( myClassifiers[ i ]->IsSetFlag( childFlag[ j ]))
|
||||
{
|
||||
--nbInChild[ j ];
|
||||
child->myClassifiers[ nbInChild[ j ]] = myClassifiers[ i ];
|
||||
myClassifiers[ i ]->UnsetFlag( childFlag[ j ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
SMESHUtils::FreeVector( myClassifiers );
|
||||
|
||||
// define if a child isLeaf()
|
||||
for (int i = 0; i < nbChildren(); i++)
|
||||
for ( int i = 0; i < nbChildren(); i++ )
|
||||
{
|
||||
OctreeClassifier* child = static_cast<OctreeClassifier*>( myChildren[i]);
|
||||
OctreeClassifier* child = static_cast<OctreeClassifier*>( myChildren[ i ]);
|
||||
child->myIsLeaf = ( child->myClassifiers.size() <= 5 );
|
||||
|
||||
if ( child->myClassifiers.capacity() - child->myClassifiers.size() > 100 )
|
||||
SMESHUtils::CompactVector( child->myClassifiers );
|
||||
}
|
||||
}
|
||||
|
||||
@ -4514,25 +4618,38 @@ Bnd_B3d* ElementsOnShape::OctreeClassifier::buildRootBox()
|
||||
|
||||
BelongToGeom::BelongToGeom()
|
||||
: myMeshDS(NULL),
|
||||
myType(SMDSAbs_All),
|
||||
myType(SMDSAbs_NbElementTypes),
|
||||
myIsSubshape(false),
|
||||
myTolerance(Precision::Confusion())
|
||||
{}
|
||||
|
||||
Predicate* BelongToGeom::clone() const
|
||||
{
|
||||
BelongToGeom* cln = new BelongToGeom( *this );
|
||||
cln->myElementsOnShapePtr.reset( static_cast<ElementsOnShape*>( myElementsOnShapePtr->clone() ));
|
||||
return cln;
|
||||
}
|
||||
|
||||
void BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
|
||||
{
|
||||
myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
|
||||
init();
|
||||
if ( myMeshDS != theMesh )
|
||||
{
|
||||
myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
void BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
|
||||
{
|
||||
myShape = theShape;
|
||||
init();
|
||||
if ( myShape != theShape )
|
||||
{
|
||||
myShape = theShape;
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
|
||||
const TopoDS_Shape& theShape)
|
||||
const TopoDS_Shape& theShape)
|
||||
{
|
||||
if (theMap.Contains(theShape)) return true;
|
||||
|
||||
@ -4554,7 +4671,7 @@ static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
|
||||
|
||||
void BelongToGeom::init()
|
||||
{
|
||||
if (!myMeshDS || myShape.IsNull()) return;
|
||||
if ( !myMeshDS || myShape.IsNull() ) return;
|
||||
|
||||
// is sub-shape of main shape?
|
||||
TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
|
||||
@ -4563,8 +4680,20 @@ void BelongToGeom::init()
|
||||
}
|
||||
else {
|
||||
TopTools_IndexedMapOfShape aMap;
|
||||
TopExp::MapShapes(aMainShape, aMap);
|
||||
myIsSubshape = IsSubShape(aMap, myShape);
|
||||
TopExp::MapShapes( aMainShape, aMap );
|
||||
myIsSubshape = IsSubShape( aMap, myShape );
|
||||
if ( myIsSubshape )
|
||||
{
|
||||
aMap.Clear();
|
||||
TopExp::MapShapes( myShape, aMap );
|
||||
mySubShapesIDs.Clear();
|
||||
for ( int i = 1; i <= aMap.Extent(); ++i )
|
||||
{
|
||||
int subID = myMeshDS->ShapeToIndex( aMap( i ));
|
||||
if ( subID > 0 )
|
||||
mySubShapesIDs.Add( subID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (!myIsSubshape) // to be always ready to check an element not bound to geometry
|
||||
@ -4578,26 +4707,6 @@ void BelongToGeom::init()
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsContains( const SMESHDS_Mesh* theMeshDS,
|
||||
const TopoDS_Shape& theShape,
|
||||
const SMDS_MeshElement* theElem,
|
||||
TopAbs_ShapeEnum theFindShapeEnum,
|
||||
TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE )
|
||||
{
|
||||
TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum );
|
||||
|
||||
while( anExp.More() )
|
||||
{
|
||||
const TopoDS_Shape& aShape = anExp.Current();
|
||||
if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
|
||||
if( aSubMesh->Contains( theElem ) )
|
||||
return true;
|
||||
}
|
||||
anExp.Next();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BelongToGeom::IsSatisfy (long theId)
|
||||
{
|
||||
if (myMeshDS == 0 || myShape.IsNull())
|
||||
@ -4612,48 +4721,24 @@ bool BelongToGeom::IsSatisfy (long theId)
|
||||
|
||||
if (myType == SMDSAbs_Node)
|
||||
{
|
||||
if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
|
||||
if ( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ))
|
||||
{
|
||||
if ( aNode->getshapeId() < 1 )
|
||||
return myElementsOnShapePtr->IsSatisfy(theId);
|
||||
|
||||
const SMDS_PositionPtr& aPosition = aNode->GetPosition();
|
||||
SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
|
||||
switch( aTypeOfPosition )
|
||||
{
|
||||
case SMDS_TOP_VERTEX : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX ));
|
||||
case SMDS_TOP_EDGE : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE ));
|
||||
case SMDS_TOP_FACE : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_FACE ));
|
||||
case SMDS_TOP_3DSPACE: return ( IsContains( myMeshDS,myShape,aNode,TopAbs_SOLID ) ||
|
||||
IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL ));
|
||||
default:;
|
||||
}
|
||||
else
|
||||
return mySubShapesIDs.Contains( aNode->getshapeId() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ))
|
||||
{
|
||||
if ( anElem->getshapeId() < 1 )
|
||||
return myElementsOnShapePtr->IsSatisfy(theId);
|
||||
|
||||
if( myType == SMDSAbs_All )
|
||||
if ( anElem->GetType() == myType )
|
||||
{
|
||||
return ( IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
|
||||
IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
|
||||
IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID )||
|
||||
IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL ));
|
||||
}
|
||||
else if( myType == anElem->GetType() )
|
||||
{
|
||||
switch( myType )
|
||||
{
|
||||
case SMDSAbs_Edge : return ( IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ));
|
||||
case SMDSAbs_Face : return ( IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ));
|
||||
case SMDSAbs_Volume: return ( IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID )||
|
||||
IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL ));
|
||||
default:;
|
||||
}
|
||||
if ( anElem->getshapeId() < 1 )
|
||||
return myElementsOnShapePtr->IsSatisfy(theId);
|
||||
else
|
||||
return mySubShapesIDs.Contains( anElem->getshapeId() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4663,8 +4748,11 @@ bool BelongToGeom::IsSatisfy (long theId)
|
||||
|
||||
void BelongToGeom::SetType (SMDSAbs_ElementType theType)
|
||||
{
|
||||
myType = theType;
|
||||
init();
|
||||
if ( myType != theType )
|
||||
{
|
||||
myType = theType;
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType BelongToGeom::GetType() const
|
||||
@ -4685,8 +4773,7 @@ const SMESHDS_Mesh* BelongToGeom::GetMeshDS() const
|
||||
void BelongToGeom::SetTolerance (double theTolerance)
|
||||
{
|
||||
myTolerance = theTolerance;
|
||||
if (!myIsSubshape)
|
||||
init();
|
||||
init();
|
||||
}
|
||||
|
||||
double BelongToGeom::GetTolerance()
|
||||
@ -4697,26 +4784,39 @@ double BelongToGeom::GetTolerance()
|
||||
/*
|
||||
Class : LyingOnGeom
|
||||
Description : Predicate for verifying whether entiy lying or partially lying on
|
||||
specified geometrical support
|
||||
specified geometrical support
|
||||
*/
|
||||
|
||||
LyingOnGeom::LyingOnGeom()
|
||||
: myMeshDS(NULL),
|
||||
myType(SMDSAbs_All),
|
||||
myType(SMDSAbs_NbElementTypes),
|
||||
myIsSubshape(false),
|
||||
myTolerance(Precision::Confusion())
|
||||
{}
|
||||
|
||||
Predicate* LyingOnGeom::clone() const
|
||||
{
|
||||
LyingOnGeom* cln = new LyingOnGeom( *this );
|
||||
cln->myElementsOnShapePtr.reset( static_cast<ElementsOnShape*>( myElementsOnShapePtr->clone() ));
|
||||
return cln;
|
||||
}
|
||||
|
||||
void LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
|
||||
{
|
||||
myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
|
||||
init();
|
||||
if ( myMeshDS != theMesh )
|
||||
{
|
||||
myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
void LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
|
||||
{
|
||||
myShape = theShape;
|
||||
init();
|
||||
if ( myShape != theShape )
|
||||
{
|
||||
myShape = theShape;
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
void LyingOnGeom::init()
|
||||
@ -4773,7 +4873,7 @@ bool LyingOnGeom::IsSatisfy( long theId )
|
||||
if ( mySubShapesIDs.Contains( elem->getshapeId() ))
|
||||
return true;
|
||||
|
||||
if ( elem->GetType() != SMDSAbs_Node )
|
||||
if ( elem->GetType() != SMDSAbs_Node && elem->GetType() == myType )
|
||||
{
|
||||
SMDS_ElemIteratorPtr nodeItr = elem->nodesIterator();
|
||||
while ( nodeItr->more() )
|
||||
@ -4789,8 +4889,11 @@ bool LyingOnGeom::IsSatisfy( long theId )
|
||||
|
||||
void LyingOnGeom::SetType( SMDSAbs_ElementType theType )
|
||||
{
|
||||
myType = theType;
|
||||
init();
|
||||
if ( myType != theType )
|
||||
{
|
||||
myType = theType;
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
SMDSAbs_ElementType LyingOnGeom::GetType() const
|
||||
@ -4811,8 +4914,7 @@ const SMESHDS_Mesh* LyingOnGeom::GetMeshDS() const
|
||||
void LyingOnGeom::SetTolerance (double theTolerance)
|
||||
{
|
||||
myTolerance = theTolerance;
|
||||
if (!myIsSubshape)
|
||||
init();
|
||||
init();
|
||||
}
|
||||
|
||||
double LyingOnGeom::GetTolerance()
|
||||
@ -4820,39 +4922,6 @@ double LyingOnGeom::GetTolerance()
|
||||
return myTolerance;
|
||||
}
|
||||
|
||||
bool LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
|
||||
const TopoDS_Shape& theShape,
|
||||
const SMDS_MeshElement* theElem,
|
||||
TopAbs_ShapeEnum theFindShapeEnum,
|
||||
TopAbs_ShapeEnum theAvoidShapeEnum )
|
||||
{
|
||||
// if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
|
||||
// return true;
|
||||
|
||||
// TopTools_MapOfShape aSubShapes;
|
||||
// TopExp_Explorer exp( theShape, theFindShapeEnum, theAvoidShapeEnum );
|
||||
// for ( ; exp.More(); exp.Next() )
|
||||
// {
|
||||
// const TopoDS_Shape& aShape = exp.Current();
|
||||
// if ( !aSubShapes.Add( aShape )) continue;
|
||||
|
||||
// if ( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ))
|
||||
// {
|
||||
// if ( aSubMesh->Contains( theElem ))
|
||||
// return true;
|
||||
|
||||
// SMDS_ElemIteratorPtr nodeItr = theElem->nodesIterator();
|
||||
// while ( nodeItr->more() )
|
||||
// {
|
||||
// const SMDS_MeshElement* aNode = nodeItr->next();
|
||||
// if ( aSubMesh->Contains( aNode ))
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
TSequenceOfXYZ::TSequenceOfXYZ(): myElem(0)
|
||||
{}
|
||||
|
||||
|
@ -364,6 +364,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
|
||||
public:
|
||||
CoincidentNodes();
|
||||
//virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -395,14 +396,17 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
//virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
|
||||
};
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
//virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
|
||||
};
|
||||
class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
|
||||
public:
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
//virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
|
||||
};
|
||||
|
||||
/*
|
||||
@ -412,6 +416,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
|
||||
public:
|
||||
FreeBorders();
|
||||
//virtual Predicate* clone() const { return new FreeBorders( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -428,6 +433,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
|
||||
public:
|
||||
BadOrientedVolume();
|
||||
//virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -443,6 +449,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
|
||||
public:
|
||||
ElemEntityType();
|
||||
//virtual Predicate* clone() const { return new ElemEntityType( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
void SetType( SMDSAbs_ElementType theType );
|
||||
@ -465,6 +472,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
BareBorderVolume():myMesh(0) {}
|
||||
virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
@ -480,6 +488,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
BareBorderFace():myMesh(0) {}
|
||||
//virtual Predicate* clone() const { return new BareBorderFace( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
@ -496,6 +505,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
OverConstrainedVolume():myMesh(0) {}
|
||||
virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
@ -511,6 +521,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
OverConstrainedFace():myMesh(0) {}
|
||||
//virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
|
||||
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
@ -526,6 +537,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
|
||||
public:
|
||||
FreeEdges();
|
||||
//virtual Predicate* clone() const { return new FreeEdges( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -553,6 +565,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
|
||||
public:
|
||||
FreeNodes();
|
||||
//virtual Predicate* clone() const { return new FreeNodes( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theNodeId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -573,7 +586,8 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
|
||||
{
|
||||
public:
|
||||
RangeOfIds();
|
||||
RangeOfIds();
|
||||
//virtual Predicate* clone() const { return new RangeOfIds( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theNodeId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -625,6 +639,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
|
||||
public:
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
//virtual Predicate* clone() const { return new LessThan( *this ); }
|
||||
};
|
||||
|
||||
|
||||
@ -635,6 +650,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
|
||||
public:
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
//virtual Predicate* clone() const { return new MoreThan( *this ); }
|
||||
};
|
||||
|
||||
|
||||
@ -645,6 +661,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
|
||||
public:
|
||||
EqualTo();
|
||||
//virtual Predicate* clone() const { return new EqualTo( *this ); }
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual void SetTolerance( double theTol );
|
||||
virtual double GetTolerance();
|
||||
@ -662,6 +679,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
|
||||
public:
|
||||
LogicalNOT();
|
||||
//virtual Predicate* clone() const { return new LogicalNOT( *this ); }
|
||||
virtual ~LogicalNOT();
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
@ -701,6 +719,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
|
||||
public:
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
//virtual Predicate* clone() const { return new LogicalAND( *this ); }
|
||||
};
|
||||
|
||||
|
||||
@ -711,6 +730,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
|
||||
public:
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
//virtual Predicate* clone() const { return new LogicalOR( *this ); }
|
||||
};
|
||||
|
||||
|
||||
@ -747,6 +767,7 @@ namespace SMESH{
|
||||
|
||||
ManifoldPart();
|
||||
~ManifoldPart();
|
||||
//virtual Predicate* clone() const { return new ManifoldPart( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
// inoke when all parameters already set
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
@ -795,6 +816,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
BelongToMeshGroup();
|
||||
//virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -818,6 +840,7 @@ namespace SMESH{
|
||||
public:
|
||||
ElementsOnSurface();
|
||||
~ElementsOnSurface();
|
||||
//virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -852,12 +875,13 @@ namespace SMESH{
|
||||
Description : Predicate elements that lying on indicated shape
|
||||
(1D, 2D or 3D)
|
||||
*/
|
||||
class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
|
||||
class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
|
||||
{
|
||||
public:
|
||||
ElementsOnShape();
|
||||
~ElementsOnShape();
|
||||
|
||||
virtual Predicate* clone() const;
|
||||
virtual void SetMesh (const SMDS_Mesh* theMesh);
|
||||
virtual bool IsSatisfy (long theElementId);
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -878,16 +902,17 @@ namespace SMESH{
|
||||
bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
|
||||
void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
|
||||
|
||||
std::vector< Classifier* > myClassifiers, myWorkClassifiers;
|
||||
OctreeClassifier* myOctree;
|
||||
SMDSAbs_ElementType myType;
|
||||
TopoDS_Shape myShape;
|
||||
double myToler;
|
||||
bool myAllNodesFlag;
|
||||
std::vector< Classifier > myClassifiers;
|
||||
std::vector< Classifier* > myWorkClassifiers;
|
||||
OctreeClassifier* myOctree;
|
||||
SMDSAbs_ElementType myType;
|
||||
TopoDS_Shape myShape;
|
||||
double myToler;
|
||||
bool myAllNodesFlag;
|
||||
|
||||
TMeshModifTracer myMeshModifTracer;
|
||||
std::vector<bool> myNodeIsChecked;
|
||||
std::vector<bool> myNodeIsOut;
|
||||
TMeshModifTracer myMeshModifTracer;
|
||||
std::vector<bool> myNodeIsChecked;
|
||||
std::vector<bool> myNodeIsOut;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
|
||||
@ -902,6 +927,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
BelongToGeom();
|
||||
virtual Predicate* clone() const;
|
||||
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual void SetGeom( const TopoDS_Shape& theShape );
|
||||
@ -921,6 +947,7 @@ namespace SMESH{
|
||||
virtual void init();
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
TColStd_MapOfInteger mySubShapesIDs;
|
||||
const SMESHDS_Mesh* myMeshDS;
|
||||
SMDSAbs_ElementType myType;
|
||||
bool myIsSubshape;
|
||||
@ -938,6 +965,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
LyingOnGeom();
|
||||
virtual Predicate* clone() const;
|
||||
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual void SetGeom( const TopoDS_Shape& theShape );
|
||||
@ -953,12 +981,7 @@ namespace SMESH{
|
||||
void SetTolerance( double );
|
||||
double GetTolerance();
|
||||
|
||||
virtual bool Contains( const SMESHDS_Mesh* theMeshDS,
|
||||
const TopoDS_Shape& theShape,
|
||||
const SMDS_MeshElement* theElem,
|
||||
TopAbs_ShapeEnum theFindShapeEnum,
|
||||
TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
|
||||
private:
|
||||
private:
|
||||
virtual void init();
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
@ -978,6 +1001,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
|
||||
public:
|
||||
FreeFaces();
|
||||
//virtual Predicate* clone() const { return new FreeFaces( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
virtual SMDSAbs_ElementType GetType() const;
|
||||
@ -993,6 +1017,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
|
||||
public:
|
||||
LinearOrQuadratic();
|
||||
//virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
void SetType( SMDSAbs_ElementType theType );
|
||||
@ -1011,6 +1036,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
|
||||
public:
|
||||
GroupColor();
|
||||
//virtual Predicate* clone() const { return new GroupColor( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
void SetType( SMDSAbs_ElementType theType );
|
||||
@ -1034,6 +1060,7 @@ namespace SMESH{
|
||||
class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
|
||||
public:
|
||||
ElemGeomType();
|
||||
//virtual Predicate* clone() const { return new ElemGeomType( *this ); }
|
||||
virtual void SetMesh( const SMDS_Mesh* theMesh );
|
||||
virtual bool IsSatisfy( long theElementId );
|
||||
void SetType( SMDSAbs_ElementType theType );
|
||||
@ -1056,6 +1083,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
CoplanarFaces();
|
||||
//virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
|
||||
void SetFace( long theID ) { myFaceID = theID; }
|
||||
long GetFace() const { return myFaceID; }
|
||||
void SetTolerance (const double theToler) { myToler = theToler; }
|
||||
@ -1081,6 +1109,7 @@ namespace SMESH{
|
||||
{
|
||||
public:
|
||||
ConnectedElements();
|
||||
//virtual Predicate* clone() const { return new ConnectedElements( *this ); }
|
||||
void SetNode( int nodeID );
|
||||
void SetPoint( double x, double y, double z );
|
||||
int GetNode() const;
|
||||
|
@ -172,7 +172,7 @@ namespace
|
||||
{
|
||||
for ( int t = 0; t < NofValidBCTypes; ++t )
|
||||
{
|
||||
CGNS_ENUMT( BCType_t ) type = CGNS_ENUMT( BCType_t)( t );
|
||||
CGNS_ENUMT( BCType_t ) type = CGNS_ENUMT( BCType_t )( t );
|
||||
string typeName = cg_BCTypeName( type );
|
||||
if ( typeName == &groupName[0] + bcBeg )
|
||||
{
|
||||
@ -251,20 +251,20 @@ Driver_Mesh::Status DriverCGNS_Write::Perform()
|
||||
// --------------
|
||||
|
||||
const int spaceDim = 3;
|
||||
int meshDim = 1;
|
||||
if ( myMesh->NbFaces() > 0 ) meshDim = 2;
|
||||
int meshDim = 1;
|
||||
if ( myMesh->NbFaces() > 0 ) meshDim = 2;
|
||||
if ( myMesh->NbVolumes() > 0 ) meshDim = 3;
|
||||
|
||||
if ( myMeshName.empty() )
|
||||
{
|
||||
int nbases = 0;
|
||||
if ( cg_nbases( _fn, &nbases) == CG_OK)
|
||||
if ( cg_nbases( _fn, &nbases) == CG_OK )
|
||||
myMeshName = ( SMESH_Comment("Base_") << nbases+1 );
|
||||
else
|
||||
myMeshName = "Base_0";
|
||||
}
|
||||
int iBase;
|
||||
if ( cg_base_write( _fn, myMeshName.c_str(), meshDim, spaceDim, &iBase))
|
||||
if ( cg_base_write( _fn, myMeshName.c_str(), meshDim, spaceDim, &iBase ))
|
||||
return addMessage( cg_get_error(), /*fatal = */true );
|
||||
|
||||
// create a Zone
|
||||
@ -330,7 +330,7 @@ Driver_Mesh::Status DriverCGNS_Write::Perform()
|
||||
// write into a section all successive elements of one geom type
|
||||
int iSec;
|
||||
vector< cgsize_t > elemData;
|
||||
SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator();
|
||||
SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator();
|
||||
const SMDS_MeshElement* elem = elemIt->next();
|
||||
while ( elem )
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ using namespace std;
|
||||
|
||||
|
||||
#ifdef _DEBUG_
|
||||
static int MYDEBUG = 1;
|
||||
static int MYDEBUG = 0;
|
||||
#else
|
||||
static int MYDEBUG = 0;
|
||||
#endif
|
||||
|
@ -99,9 +99,10 @@ void SMDS_VtkEdge::Print(std::ostream & OS) const
|
||||
int SMDS_VtkEdge::NbNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
|
||||
assert(nbPoints >= 2);
|
||||
return nbPoints;
|
||||
vtkIdType *pts, npts;
|
||||
grid->GetCellPoints( myVtkID, npts, pts );
|
||||
assert(npts >= 2);
|
||||
return npts;
|
||||
}
|
||||
|
||||
int SMDS_VtkEdge::NbEdges() const
|
||||
|
@ -136,11 +136,11 @@ int SMDS_VtkFace::NbEdges() const
|
||||
nbEdges = 4;
|
||||
break;
|
||||
case VTK_QUADRATIC_POLYGON:
|
||||
nbEdges = grid->GetCell(myVtkID)->GetNumberOfPoints() / 2;
|
||||
nbEdges = NbNodes() / 2;
|
||||
break;
|
||||
case VTK_POLYGON:
|
||||
default:
|
||||
nbEdges = grid->GetCell(myVtkID)->GetNumberOfPoints();
|
||||
nbEdges = NbNodes();
|
||||
break;
|
||||
}
|
||||
return nbEdges;
|
||||
@ -154,8 +154,9 @@ int SMDS_VtkFace::NbFaces() const
|
||||
int SMDS_VtkFace::NbNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
|
||||
return nbPoints;
|
||||
vtkIdType *pts, npts;
|
||||
grid->GetCellPoints( myVtkID, npts, pts );
|
||||
return npts;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -217,6 +218,10 @@ bool SMDS_VtkFace::IsPoly() const
|
||||
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)
|
||||
@ -230,15 +235,12 @@ bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
rankFirstMedium = 4; // medium nodes are of rank 4,5,6,7
|
||||
break;
|
||||
case VTK_QUADRATIC_POLYGON:
|
||||
rankFirstMedium = grid->GetCell(myVtkID)->GetNumberOfPoints() / 2;
|
||||
rankFirstMedium = npts / 2;
|
||||
break;
|
||||
default:
|
||||
//MESSAGE("wrong element type " << aVtkType);
|
||||
return false;
|
||||
}
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType* pts = 0;
|
||||
grid->GetCellPoints(myVtkID, npts, pts);
|
||||
vtkIdType nodeId = node->getVtkId();
|
||||
for (int rank = 0; rank < npts; rank++)
|
||||
{
|
||||
@ -261,7 +263,7 @@ bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const
|
||||
int SMDS_VtkFace::NbCornerNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
|
||||
int nbPoints = NbNodes();
|
||||
vtkIdType aVtkType = grid->GetCellType(myVtkID);
|
||||
switch ( aVtkType )
|
||||
{
|
||||
|
@ -228,10 +228,11 @@ int SMDS_VtkVolume::NbNodes() const
|
||||
{
|
||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
|
||||
int nbPoints = 0;
|
||||
vtkIdType nbPoints = 0;
|
||||
if (aVtkType != VTK_POLYHEDRON)
|
||||
{
|
||||
nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
|
||||
vtkIdType *pts;
|
||||
grid->GetCellPoints( myVtkID, nbPoints, pts );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -19,13 +19,18 @@
|
||||
|
||||
# --- options ---
|
||||
# additional include directories
|
||||
|
||||
IF(SALOME_SMESH_USE_TBB)
|
||||
SET(TBB_INCLUDES ${TBB_INCLUDE_DIRS})
|
||||
ENDIF(SALOME_SMESH_USE_TBB)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${KERNEL_INCLUDE_DIRS}
|
||||
${CAS_INCLUDE_DIRS}
|
||||
${VTK_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PROJECT_SOURCE_DIR}/src/SMDS
|
||||
|
||||
${TBB_INCLUDES}
|
||||
)
|
||||
|
||||
# additional preprocessor / compiler flags
|
||||
@ -34,12 +39,17 @@ ADD_DEFINITIONS(
|
||||
${BOOST_DEFINITIONS}
|
||||
)
|
||||
|
||||
IF(SALOME_SMESH_USE_TBB)
|
||||
SET(TBB_LIBS ${TBB_LIBRARIES})
|
||||
ENDIF(SALOME_SMESH_USE_TBB)
|
||||
|
||||
# libraries to link to
|
||||
SET(_link_LIBRARIES
|
||||
${CAS_KERNEL}
|
||||
${CAS_TKBRep}
|
||||
${KERNEL_SALOMELocalTrace}
|
||||
SMDS
|
||||
${TBB_LIBS}
|
||||
)
|
||||
|
||||
# --- headers ---
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
//#undef WITH_TBB
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Creates a group based on thePredicate
|
||||
@ -245,6 +247,9 @@ SMDS_ElemIteratorPtr SMESHDS_GroupOnFilter::GetElements() const
|
||||
{
|
||||
myPredicate->SetMesh( GetMesh() ); // hope myPredicate updates self here if necessary
|
||||
|
||||
if ( !IsUpToDate() )
|
||||
updateParallel();
|
||||
|
||||
elemIt = GetMesh()->elementsIterator( GetType() );
|
||||
if ( IsUpToDate() )
|
||||
{
|
||||
@ -360,18 +365,132 @@ void SMESHDS_GroupOnFilter::update() const
|
||||
if ( !IsUpToDate() )
|
||||
{
|
||||
me->setChanged();
|
||||
SMDS_ElemIteratorPtr elIt = GetElements();
|
||||
if ( elIt->more() ) {
|
||||
// find out nb of elements to skip w/o check before the 1st OK element
|
||||
const SMDS_MeshElement* e = me->setNbElemToSkip( elIt );
|
||||
++me->myMeshInfo[ e->GetEntityType() ];
|
||||
while ( elIt->more() )
|
||||
++me->myMeshInfo[ elIt->next()->GetEntityType() ];
|
||||
if ( !updateParallel() )
|
||||
{
|
||||
SMDS_ElemIteratorPtr elIt = GetElements();
|
||||
if ( elIt->more() ) {
|
||||
// find out nb of elements to skip w/o check before the 1st OK element
|
||||
const SMDS_MeshElement* e = me->setNbElemToSkip( elIt );
|
||||
++me->myMeshInfo[ e->GetEntityType() ];
|
||||
while ( elIt->more() )
|
||||
++me->myMeshInfo[ elIt->next()->GetEntityType() ];
|
||||
}
|
||||
}
|
||||
me->setChanged( false );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Updates myElements in parallel
|
||||
*/
|
||||
//================================================================================
|
||||
#ifdef WITH_TBB
|
||||
|
||||
#include <tbb/parallel_for.h>
|
||||
#include "tbb/enumerable_thread_specific.h"
|
||||
|
||||
// a predicate per a thread
|
||||
typedef tbb::enumerable_thread_specific<SMESH_PredicatePtr> TLocalPredicat;
|
||||
|
||||
struct IsSatisfyParallel
|
||||
{
|
||||
vector< char >& myIsElemOK;
|
||||
SMESH_PredicatePtr myPredicate;
|
||||
TLocalPredicat& myLocalPredicates;
|
||||
IsSatisfyParallel( SMESH_PredicatePtr mainPred, TLocalPredicat& locPred, vector< char >& isOk )
|
||||
: myIsElemOK(isOk), myPredicate( mainPred ), myLocalPredicates( locPred )
|
||||
{}
|
||||
void operator() ( const tbb::blocked_range<size_t>& r ) const
|
||||
{
|
||||
SMESH_PredicatePtr& pred = myLocalPredicates.local();
|
||||
if ( !pred )
|
||||
{
|
||||
if ( r.begin() == 0 )
|
||||
pred = myPredicate;
|
||||
else
|
||||
pred.reset( myPredicate->clone() );
|
||||
}
|
||||
for ( size_t i = r.begin(); i != r.end(); ++i )
|
||||
myIsElemOK[ i ] = char( pred->IsSatisfy( i ));
|
||||
}
|
||||
};
|
||||
|
||||
bool SMESHDS_GroupOnFilter::updateParallel() const
|
||||
{
|
||||
// if ( !getenv("updateParallel"))
|
||||
// return false;
|
||||
size_t nbElemsOfType = GetMesh()->GetMeshInfo().NbElements( GetType() );
|
||||
if ( nbElemsOfType == 0 )
|
||||
return true;
|
||||
if ( nbElemsOfType < 1000000 )
|
||||
return false; // no sense in parallel work
|
||||
|
||||
SMDS_ElemIteratorPtr elemIt = GetMesh()->elementsIterator( GetType() );
|
||||
const int minID = elemIt->next()->GetID();
|
||||
myPredicate->IsSatisfy( minID ); // make myPredicate fully initialized for clone()
|
||||
SMESH_PredicatePtr clone( myPredicate->clone() );
|
||||
if ( !clone )
|
||||
return false;
|
||||
|
||||
TLocalPredicat threadPredicates;
|
||||
threadPredicates.local() = clone;
|
||||
|
||||
int maxID = ( GetType() == SMDSAbs_Node ) ? GetMesh()->MaxNodeID() : GetMesh()->MaxElementID();
|
||||
vector< char > isElemOK( 1 + maxID );
|
||||
|
||||
tbb::parallel_for ( tbb::blocked_range<size_t>( 0, isElemOK.size() ),
|
||||
IsSatisfyParallel( myPredicate, threadPredicates, isElemOK ),
|
||||
tbb::simple_partitioner());
|
||||
|
||||
SMESHDS_GroupOnFilter* me = const_cast<SMESHDS_GroupOnFilter*>( this );
|
||||
|
||||
int nbOkElems = 0;
|
||||
for ( size_t i = minID; i < isElemOK.size(); ++i )
|
||||
nbOkElems += ( isElemOK[ i ]);
|
||||
me->myElements.resize( nbOkElems );
|
||||
|
||||
const SMDS_MeshElement* e;
|
||||
size_t iElem = 0;
|
||||
if ( GetType() == SMDSAbs_Node )
|
||||
{
|
||||
for ( size_t i = minID; i < isElemOK.size(); ++i )
|
||||
if (( isElemOK[ i ] ) &&
|
||||
( e = GetMesh()->FindNode( i )))
|
||||
{
|
||||
me->myElements[ iElem++ ] = e;
|
||||
}
|
||||
me->myMeshInfo[ SMDSEntity_Node ] = myElements.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( size_t i = minID; i < isElemOK.size(); ++i )
|
||||
if (( isElemOK[ i ] ) &&
|
||||
( e = GetMesh()->FindElement( i )) &&
|
||||
( e->GetType() == GetType() ))
|
||||
{
|
||||
me->myElements[ iElem++ ] = e;
|
||||
++me->myMeshInfo[ e->GetEntityType() ];
|
||||
}
|
||||
}
|
||||
me->myElementsOK = ( iElem < nbElemsOfType );
|
||||
if ( !myElementsOK )
|
||||
clearVector( me->myElements ); // all elements satisfy myPredicate
|
||||
else
|
||||
me->myElements.resize( iElem );
|
||||
|
||||
me->setChanged( false );
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
|
||||
bool SMESHDS_GroupOnFilter::updateParallel() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Sets myMeshModifTime and clear fields according to modification state
|
||||
|
@ -72,6 +72,7 @@ class SMESHDS_EXPORT SMESHDS_GroupOnFilter: public SMESHDS_GroupBase
|
||||
private:
|
||||
|
||||
void update() const;
|
||||
bool updateParallel() const;
|
||||
void setChanged(bool changed=true);
|
||||
const SMDS_MeshElement* setNbElemToSkip( SMDS_ElemIteratorPtr& elIt );
|
||||
int getElementIds( void* ids, size_t idSize ) const;
|
||||
|
@ -43,8 +43,8 @@
|
||||
|
||||
class SMDS_Mesh;
|
||||
|
||||
namespace SMESH{
|
||||
namespace Controls{
|
||||
namespace SMESH {
|
||||
namespace Controls {
|
||||
|
||||
/*
|
||||
Class : Functor
|
||||
@ -67,10 +67,11 @@ namespace SMESH{
|
||||
Class : Predicate
|
||||
Description : Base class for all predicates
|
||||
*/
|
||||
class SMESHCONTROLS_EXPORT Predicate: public virtual Functor{
|
||||
class SMESHCONTROLS_EXPORT Predicate: public virtual Functor {
|
||||
public:
|
||||
virtual bool IsSatisfy( long theElementId ) = 0;
|
||||
virtual SMDSAbs_ElementType GetType() const = 0;
|
||||
virtual Predicate* clone() const { return 0; } // return a thread-safe copy of this
|
||||
};
|
||||
typedef boost::shared_ptr<Predicate> PredicatePtr;
|
||||
|
||||
|
@ -85,7 +85,6 @@ void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr init
|
||||
const QString& theHypName,
|
||||
QWidget* parent, QObject* obj, const QString& slot )
|
||||
{
|
||||
MESSAGE( "Creation of hypothesis with initial params" );
|
||||
setInitParamsHypothesis( initParamsHyp );
|
||||
create( false, theHypName, parent, obj, slot );
|
||||
}
|
||||
@ -94,8 +93,6 @@ void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
|
||||
const QString& theHypName,
|
||||
QWidget* theParent, QObject* obj, const QString& slot )
|
||||
{
|
||||
MESSAGE( "Creation of hypothesis" );
|
||||
|
||||
myIsCreate = true;
|
||||
|
||||
// Create hypothesis/algorithm
|
||||
|
@ -24,14 +24,9 @@
|
||||
// File : SMESH_1D_Algo_i.cxx
|
||||
// Author : Paul RASCLE, EDF
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
//
|
||||
#include "SMESH_1D_Algo_i.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_1D_Algo_i::SMESH_1D_Algo_i
|
||||
@ -45,7 +40,6 @@ SMESH_1D_Algo_i::SMESH_1D_Algo_i( PortableServer::POA_ptr thePOA )
|
||||
SMESH_Hypothesis_i( thePOA ),
|
||||
SMESH_Algo_i( thePOA )
|
||||
{
|
||||
MESSAGE( "SMESH_1D_Algo_i::SMESH_1D_Algo_i" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -58,7 +52,6 @@ SMESH_1D_Algo_i::SMESH_1D_Algo_i( PortableServer::POA_ptr thePOA )
|
||||
|
||||
SMESH_1D_Algo_i::~SMESH_1D_Algo_i()
|
||||
{
|
||||
MESSAGE( "SMESH_1D_Algo_i::~SMESH_1D_Algo_i" );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
|
@ -353,7 +353,6 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
|
||||
{
|
||||
// PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside
|
||||
//Unexpect aCatch(SalomeException);
|
||||
MESSAGE("StdMeshers_Hexa_3D::Compute");
|
||||
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
|
||||
|
||||
// Shape verification
|
||||
|
@ -52,7 +52,6 @@ StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i( PortableServer::POA_ptr
|
||||
SMESH_Algo_i( thePOA ),
|
||||
SMESH_2D_Algo_i( thePOA )
|
||||
{
|
||||
MESSAGE( "StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i" );
|
||||
myBaseImpl = new ::StdMeshers_Quadrangle_2D( theGenImpl->GetANewId(),
|
||||
theStudyId,
|
||||
theGenImpl );
|
||||
@ -69,7 +68,6 @@ StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i( PortableServer::POA_ptr
|
||||
|
||||
StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i()
|
||||
{
|
||||
MESSAGE( "StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -82,7 +80,6 @@ StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i()
|
||||
|
||||
::StdMeshers_Quadrangle_2D* StdMeshers_Quadrangle_2D_i::GetImpl()
|
||||
{
|
||||
MESSAGE( "StdMeshers_Quadrangle_2D_i::GetImpl" );
|
||||
return ( ::StdMeshers_Quadrangle_2D* )myBaseImpl;
|
||||
}
|
||||
|
||||
@ -117,7 +114,6 @@ StdMeshers_QuadFromMedialAxis_1D2D_i( PortableServer::POA_ptr thePOA,
|
||||
SMESH_Algo_i( thePOA ),
|
||||
SMESH_2D_Algo_i( thePOA )
|
||||
{
|
||||
MESSAGE( "StdMeshers_QuadFromMedialAxis_1D2D_i::StdMeshers_QuadFromMedialAxis_1D2D_i" );
|
||||
myBaseImpl = new ::StdMeshers_QuadFromMedialAxis_1D2D( theGenImpl->GetANewId(),
|
||||
theStudyId,
|
||||
theGenImpl );
|
||||
@ -134,7 +130,6 @@ StdMeshers_QuadFromMedialAxis_1D2D_i( PortableServer::POA_ptr thePOA,
|
||||
|
||||
StdMeshers_QuadFromMedialAxis_1D2D_i::~StdMeshers_QuadFromMedialAxis_1D2D_i()
|
||||
{
|
||||
MESSAGE( "StdMeshers_QuadFromMedialAxis_1D2D_i::~StdMeshers_QuadFromMedialAxis_1D2D_i" );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
|
@ -50,7 +50,6 @@ StdMeshers_Regular_1D_i::StdMeshers_Regular_1D_i( PortableServer::POA_ptr thePOA
|
||||
SMESH_Algo_i( thePOA ),
|
||||
SMESH_1D_Algo_i( thePOA )
|
||||
{
|
||||
MESSAGE( "StdMeshers_Regular_1D_i::StdMeshers_Regular_1D_i" );
|
||||
myBaseImpl = new ::StdMeshers_Regular_1D( theGenImpl->GetANewId(),
|
||||
theStudyId,
|
||||
theGenImpl );
|
||||
@ -66,7 +65,6 @@ StdMeshers_Regular_1D_i::StdMeshers_Regular_1D_i( PortableServer::POA_ptr thePOA
|
||||
|
||||
StdMeshers_Regular_1D_i::~StdMeshers_Regular_1D_i()
|
||||
{
|
||||
MESSAGE( "StdMeshers_Regular_1D_i::~StdMeshers_Regular_1D_i" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -79,7 +77,6 @@ StdMeshers_Regular_1D_i::~StdMeshers_Regular_1D_i()
|
||||
|
||||
::StdMeshers_Regular_1D* StdMeshers_Regular_1D_i::GetImpl()
|
||||
{
|
||||
MESSAGE( "StdMeshers_Regular_1D_i::GetImpl" );
|
||||
return ( ::StdMeshers_Regular_1D* )myBaseImpl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user