#include "SMDS_Iterator.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
+#include "SMDS_VolumeTool.hxx"
/*
return aDist;
}
- int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId )
+ int getNbMultiConnection( const SMDS_Mesh* theMesh, const int theId )
{
if ( theMesh == 0 )
return 0;
myPrecision = -1;
}
-void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh )
+void NumericalFunctor::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
{
double aMin;
- if ( P.size() == 3 )
- {
- double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) );
- double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
- double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) );
-
- aMin = Min( A0, Min( A1, A2 ) );
- }
- else if ( P.size() == 4 )
- {
- double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) );
- double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
- double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) );
- double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) );
-
- aMin = Min( Min( A0, A1 ), Min( A2, A3 ) );
- }
- else
+ if (P.size() <3)
return 0.;
+
+ aMin = getAngle(P( P.size() ), P( 1 ), P( 2 ));
+ aMin = Min(aMin,getAngle(P( P.size()-1 ), P( P.size() ), P( 1 )));
+ for (int i=2; i<P.size();i++){
+ double A0 = getAngle( P( i-1 ), P( i ), P( i+1 ) );
+ aMin = Min(aMin,A0);
+ }
+
return aMin * 180 / PI;
}
gp_Vec aVec2( P( 3 ) - P( 1 ) );
gp_Vec aVec3( P( 4 ) - P( 1 ) );
gp_Vec anAreaVec( aVec1 ^ aVec2 );
- return abs(aVec3 * anAreaVec) / 6.0;
+ return fabs(aVec3 * anAreaVec) / 6.0;
}
inline double getMaxHeight(double theLen[6])
if ( L < Precision::Confusion())
return 0.;
- gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG;
- gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG;
+ gp_XYZ GI = ( thePnt2 + thePnt1 ) / 2. - theG;
+ gp_XYZ GJ = ( thePnt3 + thePnt2 ) / 2. - theG;
gp_XYZ N = GI.Crossed( GJ );
if ( N.Modulus() < gp::Resolution() )
*/
double Area::GetValue( const TSequenceOfXYZ& P )
{
+ double aArea = 0;
if ( P.size() == 3 )
return getArea( P( 1 ), P( 2 ), P( 3 ) );
- else if ( P.size() == 4 )
- return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) );
+ else if (P.size() > 3)
+ aArea = getArea( P( 1 ), P( 2 ), P( 3 ) );
else
return 0;
+
+ for (int i=4; i<=P.size(); i++)
+ aArea += getArea(P(1),P(i-1),P(i));
+ return aArea;
}
double Area::GetBadRate( double Value, int /*nbNodes*/ ) const
int aResult = 0;
if (GetPoints(theElementId,P)){
- double aVal;
const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId );
SMDSAbs_ElementType aType = anFaceElem->GetType();
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next();
- long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
long aNodeId[3];
PREDICATES
*/
+/*
+ Class : BadOrientedVolume
+ Description : Predicate bad oriented volumes
+*/
+
+BadOrientedVolume::BadOrientedVolume()
+{
+ myMesh = 0;
+}
+
+void BadOrientedVolume::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myMesh = theMesh;
+}
+
+bool BadOrientedVolume::IsSatisfy( long theId )
+{
+ if ( myMesh == 0 )
+ return false;
+
+ SMDS_VolumeTool vTool( myMesh->FindElement( theId ));
+ return !vTool.IsForward();
+}
+
+SMDSAbs_ElementType BadOrientedVolume::GetType() const
+{
+ return SMDSAbs_Volume;
+}
+
+
+
/*
Class : FreeBorders
Description : Predicate for free borders
myMesh = 0;
}
-void FreeBorders::SetMesh( SMDS_Mesh* theMesh )
+void FreeBorders::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
myMesh = 0;
}
-void FreeEdges::SetMesh( SMDS_Mesh* theMesh )
+void FreeEdges::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
// name : SetMesh
// Purpose : Set mesh
//=======================================================================
-void RangeOfIds::SetMesh( SMDS_Mesh* theMesh )
+void RangeOfIds::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
}
Comparator::~Comparator()
{}
-void Comparator::SetMesh( SMDS_Mesh* theMesh )
+void Comparator::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myFunctor )
myFunctor->SetMesh( theMesh );
return myPredicate && !myPredicate->IsSatisfy( theId );
}
-void LogicalNOT::SetMesh( SMDS_Mesh* theMesh )
+void LogicalNOT::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myPredicate )
myPredicate->SetMesh( theMesh );
LogicalBinary::~LogicalBinary()
{}
-void LogicalBinary::SetMesh( SMDS_Mesh* theMesh )
+void LogicalBinary::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myPredicate1 )
myPredicate1->SetMesh( theMesh );
myPredicate = thePredicate;
}
-
template<class TElement, class TIterator, class TPredicate>
-void FillSequence(const TIterator& theIterator,
- TPredicate& thePredicate,
- Filter::TIdSequence& theSequence)
+inline void FillSequence(const TIterator& theIterator,
+ TPredicate& thePredicate,
+ Filter::TIdSequence& theSequence)
{
if ( theIterator ) {
while( theIterator->more() ) {
}
}
-Filter::TIdSequence
-Filter::GetElementsId( SMDS_Mesh* theMesh )
+void
+Filter::
+GetElementsId( const SMDS_Mesh* theMesh,
+ PredicatePtr thePredicate,
+ TIdSequence& theSequence )
{
- TIdSequence aSequence;
- if ( !theMesh || !myPredicate ) return aSequence;
+ theSequence.clear();
+
+ if ( !theMesh || !thePredicate )
+ return;
- myPredicate->SetMesh( theMesh );
+ thePredicate->SetMesh( theMesh );
- SMDSAbs_ElementType aType = myPredicate->GetType();
+ SMDSAbs_ElementType aType = thePredicate->GetType();
switch(aType){
- case SMDSAbs_Node:{
- FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Node:
+ FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_Edge:{
- FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Edge:
+ FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_Face:{
- FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Face:
+ FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_Volume:{
- FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
+ case SMDSAbs_Volume:
+ FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
- }
- case SMDSAbs_All:{
- FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
- FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
- FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
+ 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;
}
- }
- return aSequence;
+}
+
+void
+Filter::GetElementsId( const SMDS_Mesh* theMesh,
+ Filter::TIdSequence& theSequence )
+{
+ GetElementsId(theMesh,myPredicate,theSequence);
}
/*
myMesh = 0;
}
-void ManifoldPart::SetMesh( SMDS_Mesh* theMesh )
+void ManifoldPart::SetMesh( const SMDS_Mesh* theMesh )
{
myMesh = theMesh;
process();
myMesh = 0;
}
-void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh )
+void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh )
{
if ( myMesh == theMesh )
return;