}
else {
// --- retrieve nodes ID
+ myNodeIds.resize(12);
myNodeIds[0] = n1->getVtkId();
- myNodeIds[0] = n6->getVtkId();
- myNodeIds[0] = n5->getVtkId();
- myNodeIds[0] = n4->getVtkId();
- myNodeIds[0] = n3->getVtkId();
- myNodeIds[0] = n2->getVtkId();
-
- myNodeIds[0] = n7->getVtkId();
- myNodeIds[0] = n12->getVtkId();
- myNodeIds[0] = n11->getVtkId();
- myNodeIds[0] = n10->getVtkId();
- myNodeIds[0] = n9->getVtkId();
- myNodeIds[0] = n8->getVtkId();
+ myNodeIds[1] = n6->getVtkId();
+ myNodeIds[2] = n5->getVtkId();
+ myNodeIds[3] = n4->getVtkId();
+ myNodeIds[4] = n3->getVtkId();
+ myNodeIds[5] = n2->getVtkId();
+
+ myNodeIds[6] = n7->getVtkId();
+ myNodeIds[7] = n12->getVtkId();
+ myNodeIds[8] = n11->getVtkId();
+ myNodeIds[9] = n10->getVtkId();
+ myNodeIds[10] = n9->getVtkId();
+ myNodeIds[11] = n8->getVtkId();
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(myNodeIds, this);
SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil();
int aPrevBinary = SMESH::FT_Undefined;
+ aBinaries.back() = SMESH::FT_Undefined;
for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin();
aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end();
*/
//================================================================================
+ enum IDSource_Error { IDSource_OK, IDSource_INVALID, IDSource_EMPTY };
+
bool idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource,
const SMESHDS_Mesh* theMeshDS,
TIDSortedElemSet& theElemSet,
const SMDSAbs_ElementType theType,
- const bool emptyIfIsMesh=false)
+ const bool emptyIfIsMesh = false,
+ IDSource_Error* error = 0)
{
+ if ( error ) *error = IDSource_OK;
+
if ( CORBA::is_nil( theIDSource ) )
+ {
+ if ( error ) *error = IDSource_INVALID;
return false;
+ }
if ( emptyIfIsMesh && SMESH::DownCast<SMESH_Mesh_i*>( theIDSource ))
+ {
+ if ( error && theMeshDS->GetMeshInfo().NbElements( theType ) == 0 )
+ *error = IDSource_EMPTY;
return true;
-
+ }
SMESH::long_array_var anIDs = theIDSource->GetIDs();
if ( anIDs->length() == 0 )
+ {
+ if ( error ) *error = IDSource_EMPTY;
return false;
+ }
SMESH::array_of_ElementType_var types = theIDSource->GetTypes();
if ( types->length() == 1 && types[0] == SMESH::NODE ) // group of nodes
{
if ( theType == SMDSAbs_All || theType == SMDSAbs_Node )
+ {
arrayToSet( anIDs, theMeshDS, theElemSet, SMDSAbs_Node );
+ }
else
+ {
+ if ( error ) *error = IDSource_INVALID;
return false;
+ }
}
else
{
arrayToSet( anIDs, theMeshDS, theElemSet, theType);
- return bool(anIDs->length()) == bool(theElemSet.size());
+ if ( bool(anIDs->length()) != bool(theElemSet.size()))
+ {
+ if ( error ) *error = IDSource_INVALID;
+ return false;
+ }
}
return true;
}
TIDSortedElemSet elements;
prepareIdSource( the2Dgroup );
- if ( !idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1))
- return 0;//THROW_SALOME_CORBA_EXCEPTION("No faces in given group", SALOME::BAD_PARAM);
+ IDSource_Error error;
+ idSourceToSet( the2Dgroup, getMeshDS(), elements, SMDSAbs_Face, /*emptyIfIsMesh=*/1, &error );
+ if ( error == IDSource_EMPTY )
+ return 0;
+ if ( error == IDSource_INVALID )
+ THROW_SALOME_CORBA_EXCEPTION("No faces in given group", SALOME::BAD_PARAM);
const SMDS_MeshElement* face = 0;
TIDSortedElemSet volumes;
prepareIdSource( volumeGroup );
- if ( !idSourceToSet( volumeGroup, getMeshDS(), volumes, SMDSAbs_Volume, /*emptyIfIsMesh=*/1))
- THROW_SALOME_CORBA_EXCEPTION("No volumes in a given object", SALOME::BAD_PARAM);
+ IDSource_Error volsError;
+ idSourceToSet( volumeGroup, getMeshDS(), volumes, SMDSAbs_Volume, /*emptyIfMesh=*/1, &volsError);
int nbReori = 0;
for ( size_t i = 0; i < faceGroups.length(); ++i )
prepareIdSource( faceGrp );
TIDSortedElemSet faces;
- if ( !idSourceToSet( faceGrp, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/1) &&
- faceGroups.length() == 1 )
- ; //THROW_SALOME_CORBA_EXCEPTION("No faces in a given object", SALOME::BAD_PARAM);
+ IDSource_Error error;
+ idSourceToSet( faceGrp, getMeshDS(), faces, SMDSAbs_Face, /*emptyIfIsMesh=*/1, &error );
+ if ( error == IDSource_INVALID && faceGroups.length() == 1 )
+ THROW_SALOME_CORBA_EXCEPTION("No faces in a given object", SALOME::BAD_PARAM);
+ if ( error == IDSource_OK && volsError != IDSource_OK )
+ THROW_SALOME_CORBA_EXCEPTION("No volumes in a given object", SALOME::BAD_PARAM);
nbReori += getEditor().Reorient2DBy3D( faces, volumes, outsideNormal );
- if ( faces.empty() ) // all faces in the mesh treated
+ if ( error != IDSource_EMPTY && faces.empty() ) // all faces in the mesh treated
break;
}
# @return SMESH_GroupOnFilter
# @ingroup l2_grps_create
def MakeGroupByCriterion(self, groupName, Criterion):
- aFilterMgr = self.smeshpyD.CreateFilterManager()
- aFilter = aFilterMgr.CreateFilter()
- aCriteria = []
- aCriteria.append(Criterion)
- aFilter.SetCriteria(aCriteria)
- group = self.MakeGroupByFilter(groupName, aFilter)
- aFilterMgr.UnRegister()
- return group
+ return self.MakeGroupByCriteria( groupName, [Criterion] )
## Creates a mesh group by the given criteria (list of criteria)
# @param groupName the name of the mesh group
# @param theCriteria the list of criteria
+ # @param binOp binary operator used when binary operator of criteria is undefined
# @return SMESH_GroupOnFilter
# @ingroup l2_grps_create
- def MakeGroupByCriteria(self, groupName, theCriteria):
- aFilterMgr = self.smeshpyD.CreateFilterManager()
- aFilter = aFilterMgr.CreateFilter()
- aFilter.SetCriteria(theCriteria)
+ def MakeGroupByCriteria(self, groupName, theCriteria, binOp=SMESH.FT_LogicalAND):
+ aFilter = self.smeshpyD.GetFilterFromCriteria( theCriteria, binOp )
group = self.MakeGroupByFilter(groupName, aFilter)
- aFilterMgr.UnRegister()
return group
## Creates a mesh group by the given filter
## Get measure structure specifying bounding box data of the specified object(s)
# @param IDs single source object or list of source objects or list of nodes/elements IDs
- # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
+ # @param isElem if @a IDs is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
# @c False specifies that @a objects are nodes
# @return Measure structure
# @sa BoundingBox()
_compatibleHypothesis.push_back("ImportSource1D");
}
-//=============================================================================
-/*!
- * Check presence of a hypothesis
- */
-//=============================================================================
-
-bool StdMeshers_Import_1D::CheckHypothesis
- (SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
- SMESH_Hypothesis::Hypothesis_Status& aStatus)
-{
- _sourceHyp = 0;
-
- const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
- if ( hyps.size() == 0 )
- {
- aStatus = SMESH_Hypothesis::HYP_MISSING;
- return false; // can't work with no hypothesis
- }
-
- if ( hyps.size() > 1 )
- {
- aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
- return false;
- }
-
- const SMESHDS_Hypothesis *theHyp = hyps.front();
-
- string hypName = theHyp->GetName();
-
- if (hypName == _compatibleHypothesis.front())
- {
- _sourceHyp = (StdMeshers_ImportSource1D *)theHyp;
- aStatus = SMESH_Hypothesis::HYP_OK;
- return true;
- }
-
- aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
- return true;
-}
-
//================================================================================
namespace // INTERNAL STUFF
//================================================================================
bool rmGroups = (d->_copyGroupSubM.erase( sm ) && d->_copyGroupSubM.empty()) || rmMesh;
if ( rmMesh )
d->removeImportedMesh( sm->GetFather()->GetMeshDS() );
- if ( rmGroups && data )
+ if ( rmGroups && data && data->myType == SRC_HYP )
d->removeGroups( sm, data->_srcHyp );
}
}
// remove imported mesh and groups
d->removeImportedMesh( sm->GetFather()->GetMeshDS() );
- if ( data )
+ if ( data && data->myType == SRC_HYP )
d->removeGroups( sm, data->_srcHyp );
// clear the rest submeshes
{
SMESH_subMesh* subM = *sub;
_ListenerData* hypData = (_ListenerData*) subM->GetEventListenerData( get() );
- if ( hypData )
+ if ( hypData && hypData->myType == SRC_HYP )
d->removeGroups( sm, hypData->_srcHyp );
subM->ComputeStateEngine( SMESH_subMesh::CLEAN );
if ( sm->GetSubShape().ShapeType() == TopAbs_FACE )
sm->ComputeSubMeshStateEngine( SMESH_subMesh::CLEAN );
}
- if ( data )
+ if ( data && data->myType == SRC_HYP )
d->trackHypParams( sm, data->_srcHyp );
d->_n2n.clear();
d->_e2e.clear();
} // namespace
+//=============================================================================
+/*!
+ * Check presence of a hypothesis
+ */
+//=============================================================================
+
+bool StdMeshers_Import_1D::CheckHypothesis
+ (SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ SMESH_Hypothesis::Hypothesis_Status& aStatus)
+{
+ _sourceHyp = 0;
+
+ const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
+ if ( hyps.size() == 0 )
+ {
+ aStatus = SMESH_Hypothesis::HYP_MISSING;
+ return false; // can't work with no hypothesis
+ }
+
+ if ( hyps.size() > 1 )
+ {
+ aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
+ return false;
+ }
+
+ const SMESHDS_Hypothesis *theHyp = hyps.front();
+
+ string hypName = theHyp->GetName();
+
+ if (hypName == _compatibleHypothesis.front())
+ {
+ _sourceHyp = (StdMeshers_ImportSource1D *)theHyp;
+ aStatus = _sourceHyp->GetGroups().empty() ? HYP_BAD_PARAMETER : HYP_OK;
+ if ( aStatus == HYP_BAD_PARAMETER )
+ _Listener::waitHypModification( aMesh.GetSubMesh( aShape ));
+ return aStatus == HYP_OK;
+ }
+
+ aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+ return false;
+}
//=============================================================================
/*!
map<const SMDS_MeshNode* , const SMDS_MeshNode*> src2tgtNodes;
map<const SMDS_MeshNode* , const SMDS_MeshNode*>::iterator srcN_tgtN;
+ bool tgtEdgesMeshed = false;
for ( TopExp_Explorer srcExp( srcFace, TopAbs_EDGE); srcExp.More(); srcExp.Next() )
{
const TopoDS_Shape& srcEdge = srcExp.Current();
const TopoDS_Shape& tgtEdge = shape2ShapeMap( srcEdge, /*isSrc=*/true );
+ tgtEdgesMeshed != tgtMesh->GetSubMesh( tgtEdge )->IsEmpty();
+
if ( srcMesh->GetSubMesh( srcEdge )->IsEmpty() ||
tgtMesh->GetSubMesh( tgtEdge )->IsEmpty() )
continue;
src2tgtNodes.insert( make_pair( u_sn->second, u_tn->second ));
}
}
+ // check nodes on VERTEXes for a case of not meshes EDGEs
+ for ( TopExp_Explorer srcExp( srcFace, TopAbs_VERTEX); srcExp.More(); srcExp.Next() )
+ {
+ const TopoDS_Shape& srcV = srcExp.Current();
+ const TopoDS_Shape& tgtV = shape2ShapeMap( srcV, /*isSrc=*/true );
+ const SMDS_MeshNode* srcN = SMESH_Algo::VertexNode( TopoDS::Vertex( srcV ), srcMeshDS );
+ const SMDS_MeshNode* tgtN = SMESH_Algo::VertexNode( TopoDS::Vertex( tgtV ), srcMeshDS );
+ if ( !srcN )
+ continue;
+ if ( !tgtN || tgtV.ShapeType() != TopAbs_VERTEX )
+ return false;
+
+ if ( !tgtV.IsPartner( srcV ))
+ {
+ // check that transformation is OK by three nodes
+ gp_Pnt p0S = SMESH_TNodeXYZ( srcN );
+ gp_Pnt p0T = SMESH_TNodeXYZ( tgtN );
+ if ( p0T.SquareDistance( p0S.Transformed( trsf )) > tol )
+ {
+ return false;
+ }
+ }
+ src2tgtNodes.insert( make_pair( srcN, tgtN ));
+ }
+
// Make new faces
helper.SetSubShape( tgtFace );
helper.IsQuadraticSubMesh( tgtFace );
+ SMESHDS_SubMesh* srcSubDS = srcMeshDS->MeshElements( srcFace );
+ if ( !tgtEdgesMeshed && srcSubDS->NbElements() )
+ helper.SetIsQuadratic( srcSubDS->GetElements()->next()->IsQuadratic() );
+
SMESH_MesherHelper srcHelper( *srcMesh );
srcHelper.SetSubShape( srcFace );
if ( isReverse )
std::swap( tri1, tri2 ), std::swap( quad1, quad3 );
- SMESHDS_SubMesh* srcSubDS = srcMeshDS->MeshElements( srcFace );
SMDS_ElemIteratorPtr elemIt = srcSubDS->GetElements();
vector< const SMDS_MeshNode* > tgtNodes;
while ( elemIt->more() ) // loop on all mesh faces on srcFace
static SMESH_HypoFilter hypo;
hypo.Init( hypo.HasDim( 1 )).
AndNot ( hypo.IsAlgo() ).
+ AndNot ( hypo.HasName( StdMeshers_Propagation::GetName() )).
+ AndNot ( hypo.HasName( StdMeshers_PropagOfDistribution::GetName() )).
AndNot ( hypo.IsAssignedTo( theSubMesh->GetFather()->GetShapeToMesh() ));
return theSubMesh->GetFather()->GetHypothesis( theSubMesh, hypo, true, theSssignedTo );
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
- static std::string GetName ();
+ static std::string GetName();
/*!
* \brief Returns a filter selecting both StdMeshers_Propagation and
#include <cmath>
#include <limits>
-//#define __myDEBUG
+#define __myDEBUG
using namespace std;
}
}
avgThick /= data._edges.size();
- debugMsg( "-- Thickness " << avgThick*100 << "% reached" );
+ debugMsg( "-- Thickness " << curThick << " ("<< avgThick*100 << "%) reached" );
if ( distToIntersection < tgtThick*avgThick*1.5 )
{
( new SMESH_ComputeError (COMPERR_WARNING,
SMESH_Comment("Thickness ") << tgtThick <<
" of viscous layers not reached,"
- " average reached thickness is " << avgThick*100 << "%."));
+ " average reached thickness is " << avgThick*tgtThick));
}