Merge with OCC_development_generic_2006

This commit is contained in:
apo 2006-01-11 13:46:54 +00:00
parent bf88e44c8e
commit a5aa83a837
48 changed files with 2192 additions and 252 deletions

View File

@ -80,6 +80,19 @@ module SMESH
in string theLibName )
raises ( SALOME::SALOME_Exception );
/*!
* Return a hypothesis holding parameter values corresponding to the mesh
* existing on the given geometry.
* The returned hypothesis may be the one existing in a study and used
* to compute the mesh, or a temporary one created just to pass parameter
* values
*/
SMESH_Hypothesis GetHypothesisParameterValues( in string theHypName,
in string theLibName,
in SMESH_Mesh theMesh,
in GEOM::GEOM_Object theGeom)
raises ( SALOME::SALOME_Exception );
/*!
* Create a Mesh object, given a geometry shape.
* Mesh is created empty (no points, no elements).

View File

@ -32,6 +32,7 @@ using namespace std;
#include "SMESH_Mesh.hxx"
#include "SMESH_HypoFilter.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESHDS_Mesh.hxx"
@ -149,24 +150,24 @@ const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis(
double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
{
double UMin = 0, UMax = 0;
TopLoc_Location L;
if (BRep_Tool::Degenerated(E))
return 0;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C);
GCPnts_AbscissaPoint gabs;
double length = gabs.Length(AdaptCurve, UMin, UMax);
return length;
double UMin = 0, UMax = 0;
if (BRep_Tool::Degenerated(E))
return 0;
TopLoc_Location L;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C);
GCPnts_AbscissaPoint gabs;
double length = gabs.Length(AdaptCurve, UMin, UMax);
return length;
}
//================================================================================
/*!
* \brief Find out elements orientation on a geometrical face
* \param theFace - The face correctly oriented in the shape being meshed
* \param theMeshDS - The mesh data structure
* \retval bool - true if the face normal and the normal of first element
* in the correspoding submesh point in different directions
* \param theFace - The face correctly oriented in the shape being meshed
* \param theMeshDS - The mesh data structure
* \retval bool - true if the face normal and the normal of first element
* in the correspoding submesh point in different directions
*/
//================================================================================
@ -267,3 +268,79 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace,
return Ne * Nf < 0.;
}
//================================================================================
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as the algorithm does not hold parameters values
*/
//================================================================================
bool SMESH_Algo::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}
//================================================================================
/*!
* \brief Fill vector of node parameters on geometrical edge, including vertex nodes
* \param theMesh - The mesh containing nodes
* \param theEdge - The geometrical edge of interest
* \param theParams - The resulting vector of sorted node parameters
* \retval bool - false if not all parameters are OK
*/
//================================================================================
bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
vector< double > & theParams)
{
theParams.clear();
if ( !theMesh || theEdge.IsNull() )
return false;
SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
if ( !eSubMesh || !eSubMesh->GetElements()->more() )
return false; // edge is not meshed
int nbEdgeNodes = 0;
set < double > paramSet;
if ( eSubMesh )
{
// loop on nodes of an edge: sort them by param on edge
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
while ( nIt->more() )
{
const SMDS_MeshNode* node = nIt->next();
const SMDS_PositionPtr& pos = node->GetPosition();
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
paramSet.insert( epos->GetUParameter() );
++nbEdgeNodes;
}
}
// add vertex nodes params
Standard_Real f, l;
BRep_Tool::Range(theEdge, f, l);
paramSet.insert( f );
paramSet.insert( l );
if ( paramSet.size() != nbEdgeNodes + 2 )
return false; // there are equal parameters
// fill the vector
theParams.resize( paramSet.size() );
set < double >::iterator par = paramSet.begin();
vector< double >::iterator vecPar = theParams.begin();
for ( ; par != paramSet.end(); ++par, ++vecPar )
*vecPar = *par;
return theParams.size() > 1;
}

View File

@ -41,6 +41,7 @@
class SMESH_Gen;
class SMESH_Mesh;
class TopoDS_Face;
class TopoDS_Shape;
class SMESHDS_Mesh;
class SMESH_Algo:public SMESH_Hypothesis
@ -64,6 +65,19 @@ class SMESH_Algo:public SMESH_Hypothesis
static double EdgeLength(const TopoDS_Edge & E);
/*!
* \brief Fill vector of node parameters on geometrical edge, including vertex nodes
* \param theMesh - The mesh containing nodes
* \param theEdge - The geometrical edge of interest
* \param theParams - The resulting vector of sorted node parameters
* \retval bool - false if not all parameters are OK
*/
static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
std::vector< double > & theParams);
//static bool GetSegmentLengths();
/*!
* \brief Find out elements orientation on a geometrical face
* \param theFace - The face correctly oriented in the shape being meshed
@ -74,6 +88,16 @@ class SMESH_Algo:public SMESH_Hypothesis
static bool IsReversedSubMesh (const TopoDS_Face& theFace,
SMESHDS_Mesh* theMeshDS);
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as the algorithm does not hold parameters values
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
public:
// algo features

View File

@ -32,6 +32,8 @@
#include "SMESHDS_Hypothesis.hxx"
class SMESH_Gen;
class TopoDS_Shape;
class SMESH_Mesh;
class SMESH_Hypothesis: public SMESHDS_Hypothesis
{
@ -61,6 +63,14 @@ public:
const char* GetLibName() const;
void SetLibName(const char* theLibName);
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0;
protected:
SMESH_Gen* _gen;
int _studyId;

View File

@ -27,6 +27,16 @@ SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
{
}
void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
QWidget* parent)
{
MESSAGE( "Creation of hypothesis with initial params" );
if ( !CORBA::is_nil( initParamsHyp ) && hypType() == initParamsHyp->GetName() )
myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( initParamsHyp );
create( false, parent );
}
void SMESHGUI_GenericHypothesisCreator::create( const bool isAlgo, QWidget* parent )
{
MESSAGE( "Creation of hypothesis" );
@ -94,6 +104,7 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
bool res = true;
myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
QFrame* fr = buildFrame();
if( fr )
{
@ -105,12 +116,18 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
dlg->setType( type() );
retrieveParams();
res = dlg->exec()==QDialog::Accepted;
if( res )
storeParams();
if( res ) {
QString paramValues = storeParams();
if ( !paramValues.isEmpty() ) {
if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
SMESH::SetValue( SHyp, paramValues );
}
}
delete dlg;
}
changeWidgets().clear();
myHypo = SMESH::SMESH_Hypothesis::_nil();
myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
return res;
}
@ -144,37 +161,38 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
GroupC1Layout->addWidget( lab, i, 0 );
QWidget* w = 0;
switch( (*anIt).myValue.type() )
{
case QVariant::Int:
QWidget* w = getCustomWidget( *anIt, GroupC1 );
if ( !w )
switch( (*anIt).myValue.type() )
{
QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toInt() );
connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
w = sb;
case QVariant::Int:
{
QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toInt() );
connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
w = sb;
}
break;
case QVariant::Double:
{
QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toDouble() );
connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
w = sb;
}
break;
case QVariant::String:
{
QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
attuneStdWidget( le, i );
le->setText( (*anIt).myValue.toString() );
connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
w = le;
}
break;
}
break;
case QVariant::Double:
{
QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toDouble() );
connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
w = sb;
}
break;
case QVariant::String:
{
QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
attuneStdWidget( le, i );
le->setText( (*anIt).myValue.toString() );
connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
w = le;
}
break;
}
if( w )
{
@ -224,17 +242,56 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
params.append( item );
}
else
else if ( getParamFromCustomWidget( item, *anIt ))
{
params.append( item );
}
else
res = false;
}
return res;
}
QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
{
QString valueStr = "";
ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
for( int i=0; param!=aLast; param++, i++ )
{
if ( i > 0 )
valueStr += "; ";
switch( (*param).myValue.type() )
{
case QVariant::Int:
valueStr += valueStr.number( (*param).myValue.toInt() );
break;
case QVariant::Double:
valueStr += valueStr.number( (*param).myValue.toDouble() );
break;
case QVariant::String:
valueStr += (*param).myValue.toString();
break;
default:
QVariant valCopy = (*param).myValue;
valueStr += valCopy.asString();
}
}
return valueStr;
}
SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
{
return myHypo;
}
SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis() const
{
if ( CORBA::is_nil( myInitParamsHypo ))
return myHypo;
return myInitParamsHypo;
}
QString SMESHGUI_GenericHypothesisCreator::hypType() const
{
return myHypType;
@ -273,10 +330,15 @@ QString SMESHGUI_GenericHypothesisCreator::type() const
{
return QString();
}
QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
QWidget* /*parent*/) const
{
return 0;
}
bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam& , QWidget* ) const
{
return false;
}

View File

@ -50,6 +50,7 @@ public:
void create( const bool isAlgo, QWidget* );
void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
void create( SMESH::SMESH_Hypothesis_ptr, QWidget* );
virtual bool checkParams() const = 0;
QString hypType() const;
@ -67,16 +68,20 @@ protected:
typedef QPtrList<QWidget> ListOfWidgets;
SMESH::SMESH_Hypothesis_var hypothesis() const;
SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
const ListOfWidgets& widgets() const;
ListOfWidgets& changeWidgets();
virtual QFrame* buildFrame () = 0;
QFrame* buildStdFrame ();
virtual void retrieveParams() const = 0;
virtual void storeParams () const = 0;
virtual QString storeParams () const = 0;
virtual bool stdParams ( ListOfStdParams& ) const;
bool getStdParamFromDlg( ListOfStdParams& ) const;
static QString stdParamValues( const ListOfStdParams& );
virtual void attuneStdWidget( QWidget*, const int ) const;
virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const;
virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const;
virtual QString caption() const;
virtual QPixmap icon() const;
virtual QString type() const;
@ -88,7 +93,7 @@ private:
bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
private:
SMESH::SMESH_Hypothesis_var myHypo;
SMESH::SMESH_Hypothesis_var myHypo, myInitParamsHypo;
QString myHypType;
ListOfWidgets myParamWidgets;
bool myIsCreate;

View File

@ -511,6 +511,66 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
}
}
//================================================================================
/*!
* \brief If create or edit a submesh, return a hypothesis holding parameters used
* to mesh a subshape
* \param aHypType - The hypothesis type name
* \param aServerLib - Server library name
* \param hypData - The structure holding the hypothesis type etc.
* \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
*/
//================================================================================
SMESH::SMESH_Hypothesis_var
SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
const QString& aServerLib ) const
{
if ( aHypType.isEmpty() || aServerLib.isEmpty() )
return SMESH::SMESH_Hypothesis::_nil();
const int nbColonsInMeshEntry = 3;
bool isSubMesh = myToCreate ?
!myIsMesh :
myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry;
if ( isSubMesh )
{
// get mesh and geom object
SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
QString anEntry = myDlg->selectedObject
( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.latin1() ))
{
CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
if ( myToCreate ) // mesh and geom may be selected
{
aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.latin1() ))
aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
}
else // edition: sub-mesh may be selected
{
SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
if ( !sm->_is_nil() ) {
aMeshVar = sm->GetFather();
aGeomVar = sm->GetSubShape();
}
}
}
if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType,
aServerLib,
aMeshVar,
aGeomVar );
}
return SMESH::SMESH_Hypothesis::_nil();
}
//================================================================================
/*!
* \brief Calls plugin methods for hypothesis creation
@ -560,8 +620,22 @@ void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHypTypeName );
// Create hypothesis
if( aCreator )
aCreator->create( false, myDlg );
if ( aCreator )
{
// When create or edit a submesh, try to initialize a new hypothesis
// with values used to mesh a subshape
SMESH::SMESH_Hypothesis_var initParamHyp =
getInitParamsHypothesis( aHypTypeName, aData->ServerLibName );
if ( initParamHyp->_is_nil() )
aCreator->create( false, myDlg );
else
aCreator->create( initParamHyp, myDlg );
}
else
{
SMESH::CreateHypothesis( aHypTypeName, aData->Label, false );
}
}
QStringList aNewHyps;
@ -650,18 +724,18 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
{
// try to find an existing hypo
QValueList<SMESH::SMESH_Hypothesis_var> & aList = myExistingHyps[ aDim ][ aHypType ];
int iHyp = 0, nbHyp = aList.count();
for ( ; iHyp < nbHyp; ++iHyp )
{
SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
index = iHyp;
break;
}
}
int /*iHyp = 0,*/ nbHyp = aList.count();
// for ( ; iHyp < nbHyp; ++iHyp )
// {
// SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
// if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
// index = iHyp;
// break;
// }
// }
if ( index >= 0 ) // found
{
// select an algorithm
// select the found hypothesis
setCurrentHyp ( aDim, aHypType, index );
}
else
@ -676,7 +750,18 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
// Get hypotheses creator client (GUI)
SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator( aHypoTypeName );
aCreator->create( false, myDlg );
if ( aCreator )
{
// When create or edit a submesh, try to initialize a new hypothesis
// with values used to mesh a subshape
SMESH::SMESH_Hypothesis_var initParamHyp =
getInitParamsHypothesis( aHypoTypeName, aHypData->ServerLibName );
aCreator->create( initParamHyp, myDlg );
}
else
{
SMESH::CreateHypothesis( aHypoTypeName, aHypData->Label, isAlgo );
}
}
QStringList aNewHyps;
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );

View File

@ -97,6 +97,8 @@ private:
QString name( _PTR(SObject) ) const;
int find( const SMESH::SMESH_Hypothesis_var&,
const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
SMESH::SMESH_Hypothesis_var getInitParamsHypothesis( const QString& aHypType,
const QString& aServerLib ) const;
private:
typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;

View File

@ -941,7 +941,10 @@ bool SMESHGUI_MultiEditDlg::onApply()
bool aResult = process(aMeshEditor, anIds.inout());
if (aResult) {
if (myActor) {
//mySelectionMgr->clearSelected();
SALOME_ListIO sel;
mySelectionMgr->selectedObjects( sel );
mySelector->ClearIndex();
mySelectionMgr->setSelectedObjects( sel );
SMESH::UpdateView();
}

View File

@ -41,6 +41,8 @@
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
#include <TCollection_AsciiString.hxx>
@ -64,6 +66,8 @@
#include "SMESHDS_Document.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_GroupOnGeom.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_Hypothesis.hxx"
#include "SMESH_Group.hxx"
#include "SMDS_EdgePosition.hxx"
@ -490,6 +494,84 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam
return hyp._retn();
}
//================================================================================
/*!
* \brief Return hypothesis of given type holding parameter values of the existing mesh
* \param theHypType - hypothesis type name
* \param theLibName - plugin library name
* \param theMesh - The mesh of interest
* \param theGeom - The shape to get parameter values from
* \retval SMESH::SMESH_Hypothesis_ptr - The returned hypothesis may be the one existing
* in a study and used to compute the mesh, or a temporary one created just to pass
* parameter values
*/
//================================================================================
SMESH::SMESH_Hypothesis_ptr
SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
const char* theLibName,
SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theGeom)
throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
if ( CORBA::is_nil( theMesh ) )
THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
if ( CORBA::is_nil( theGeom ) )
THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
// -----------------------------------------------
// find hypothesis used to mesh theGeom
// -----------------------------------------------
// get mesh and shape
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
TopoDS_Shape shape = GeomObjectToShape( theGeom );
if ( !meshServant || shape.IsNull() )
return SMESH::SMESH_Hypothesis::_nil();
::SMESH_Mesh& mesh = meshServant->GetImpl();
if ( mesh.NbNodes() == 0 ) // empty mesh
return SMESH::SMESH_Hypothesis::_nil();
// create a temporary hypothesis to know its dimention
SMESH::SMESH_Hypothesis_var tmpHyp = this->createHypothesis( theHypType, theLibName );
SMESH_Hypothesis_i* hypServant = SMESH::DownCast<SMESH_Hypothesis_i*>( tmpHyp );
if ( !hypServant )
return SMESH::SMESH_Hypothesis::_nil();
::SMESH_Hypothesis* hyp = hypServant->GetImpl();
// look for a hypothesis of theHypType used to mesh the shape
if ( myGen.GetShapeDim( shape ) == hyp->GetDim() )
{
// check local shape
SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( theGeom );
int nbLocalHyps = aHypList->length();
for ( int i = 0; i < nbLocalHyps; i++ )
if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local!
return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
// check super shapes
TopTools_ListIteratorOfListOfShape itShape( mesh.GetAncestors( shape ));
while ( nbLocalHyps == 0 && itShape.More() ) {
GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() );
if ( ! CORBA::is_nil( geomObj )) {
SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( geomObj );
nbLocalHyps = aHypList->length();
for ( int i = 0; i < nbLocalHyps; i++ )
if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND global!
return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
}
itShape.Next();
}
}
// let the temporary hypothesis find out some how parameter values
if ( hyp->SetParametersByMesh( &mesh, shape ))
return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
return SMESH::SMESH_Hypothesis::_nil();
}
//=============================================================================
/*!
* SMESH_Gen_i::CreateMesh
@ -506,7 +588,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
// create mesh
SMESH::SMESH_Mesh_var mesh = this->createMesh();
// set shape
SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
ASSERT( meshServant );
meshServant->SetShape( theShapeObject );

View File

@ -176,6 +176,13 @@ public:
const char* theLibName)
throw ( SALOME::SALOME_Exception );
// Return hypothesis of given type holding parameter values of the existing mesh
SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char* theHypType,
const char* theLibName,
SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theGeom)
throw ( SALOME::SALOME_Exception );
// Create empty mesh on a shape
SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
throw ( SALOME::SALOME_Exception );

View File

@ -380,7 +380,7 @@ SMESH_Hypothesis::Hypothesis_Status
int hypId = myHyp->GetId();
status = _impl->AddHypothesis(myLocSubShape, hypId);
if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
_mapHypo[hypId] = myHyp;
_mapHypo[hypId] = SMESH::SMESH_Hypothesis::_duplicate( myHyp );
// assure there is a corresponding submesh
if ( !_impl->IsMainShape( myLocSubShape )) {
int shapeId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );

View File

@ -26,20 +26,34 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_Arithmetic1D.hxx"
#include "SMESH_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
using namespace std;
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId,
SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
:SMESH_Hypothesis(hypId, studyId, gen)
{
_begLength = 1.;
_endLength = 1.;
_endLength = 10.;
_name = "Arithmetic1D";
_param_algo_dim = 1;
}
@ -137,3 +151,49 @@ istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize start and end length by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_Arithmetic1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_begLength = _endLength = 0.;
Standard_Real UMin, UMax;
TopLoc_Location L;
int nbEdges = 0;
TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
for ( int i = 1; i <= edgeMap.Extent(); ++i )
{
const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
Handle(Geom_Curve) C = BRep_Tool::Curve(edge, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C);
vector< double > params;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
{
nbEdges++;
_begLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[0], params[1]);
int nb = params.size();
_endLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[nb-2], params[nb-1]);
}
}
if ( nbEdges ) {
_begLength /= nbEdges;
_endLength /= nbEdges;
}
return nbEdges;
}

View File

@ -43,10 +43,18 @@ public:
double GetLength(bool isStartLength) const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream& operator << (ostream & save, StdMeshers_Arithmetic1D & hyp);
friend istream& operator >> (istream & load, StdMeshers_Arithmetic1D & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp);
friend std::istream& operator >> (std::istream & load, StdMeshers_Arithmetic1D & hyp);
/*!
* \brief Initialize start and end length by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _begLength, _endLength;

View File

@ -31,6 +31,7 @@
#include "SMESH_Mesh.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_Algo.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "utilities.h"
@ -47,8 +48,8 @@ using namespace std;
*/
//=============================================================================
StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId,
SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen)
:SMESH_Hypothesis(hypId, studyId, gen)
{
_name = "AutomaticLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
@ -80,6 +81,9 @@ StdMeshers_AutomaticLength::~StdMeshers_AutomaticLength()
*/
//================================================================================
const double theCoarseConst = 0.5;
const double theFineConst = 4.5;
void StdMeshers_AutomaticLength::SetFineness(double theFineness)
throw(SALOME_Exception)
{
@ -113,12 +117,11 @@ inline const TopoDS_TShape* getTShape(const TopoDS_Shape& theShape)
*/
//================================================================================
static void computeLengths( const SMESH_Mesh* theMesh,
static void computeLengths( SMESHDS_Mesh* aMesh,
map<const TopoDS_TShape*, double> & theTShapeToLengthMap)
{
theTShapeToLengthMap.clear();
SMESHDS_Mesh* aMesh = const_cast< SMESH_Mesh* > ( theMesh )->GetMeshDS();
TopoDS_Shape aMainShape = aMesh->ShapeToMesh();
// Find length of longest and shortest edge
@ -197,8 +200,10 @@ double StdMeshers_AutomaticLength::GetLength(const SMESH_Mesh* theMesh,
if ( anEdge.IsNull() || anEdge.ShapeType() != TopAbs_EDGE )
throw SALOME_Exception(LOCALIZED("Bad edge shape"));
if ( theMesh != _mesh ) {
computeLengths( theMesh, _TShapeToLength );
if ( theMesh != _mesh )
{
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* > ( theMesh )->GetMeshDS();
computeLengths( aMeshDS, _TShapeToLength );
_mesh = theMesh;
}
@ -208,7 +213,7 @@ double StdMeshers_AutomaticLength::GetLength(const SMESH_Mesh* theMesh,
if ( tshape_length == _TShapeToLength.end() )
return 1; // it is a dgenerated edge
return tshape_length->second / (0.5 + 4.5 * _fineness);
return tshape_length->second / (theCoarseConst + theFineConst * _fineness);
}
//=============================================================================
@ -257,3 +262,65 @@ istream & operator >>(istream & load, StdMeshers_AutomaticLength & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize Fineness by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_AutomaticLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_fineness = 0;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
int nbEdges = 0;
TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
for ( int i = 1; i <= edgeMap.Extent(); ++i )
{
const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
// assure the base automatic length is stored in _TShapeToLength
if ( i == 1 )
GetLength( theMesh, edge );
// get current segment length
double L = SMESH_Algo::EdgeLength( edge );
if ( L <= DBL_MIN )
continue;
SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edge );
if ( !eSubMesh )
return false;
double segLen = L / eSubMesh->NbElements();
// get segment length from _TShapeToLength
map<const TopoDS_TShape*, double>::iterator tshape_length =
_TShapeToLength.find( getTShape( edge ));
if ( tshape_length == _TShapeToLength.end() )
continue;
double autoLen = tshape_length->second;
// segLen = autoLen / (theCoarseConst + theFineConst * _fineness) -->
_fineness += ( autoLen / segLen - theCoarseConst ) / theFineConst;
++nbEdges;
}
if ( nbEdges )
_fineness /= nbEdges;
if (_fineness > 1.0)
_fineness = 1.0;
else if (_fineness < 0.0)
_fineness = 0.0;
return nbEdges;
}

View File

@ -78,6 +78,14 @@ public:
friend std::ostream & operator <<(std::ostream & save, StdMeshers_AutomaticLength & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_AutomaticLength & hyp);
/*!
* \brief Initialize Fineness by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
std::map<const TopoDS_TShape*, double> _TShapeToLength;
const SMESH_Mesh* _mesh;

View File

@ -30,6 +30,19 @@ using namespace std;
#include "StdMeshers_Deflection1D.hxx"
#include "utilities.h"
#include "SMESH_Mesh.hxx"
#include "SMESH_Algo.hxx"
#include <BRep_Tool.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
//=============================================================================
/*!
@ -134,3 +147,78 @@ istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Evaluate curve deflection between two points
* \param theCurve - the curve
* \param theU1 - the parameter of the first point
* \param theU2 - the parameter of the second point
* \retval double - deflection value
*/
//================================================================================
static double deflection(const GeomAdaptor_Curve & theCurve,
double theU1,
double theU2)
{
if ( theCurve.GetType() == GeomAbs_Line )
return 0;
// line between theU1 and theU2
gp_Pnt p1 = theCurve.Value( theU1 ), p2 = theCurve.Value( theU2 );
gp_Lin segment( p1, gp_Vec( p1, p2 ));
// evaluate square distance of theCurve from the segment
Standard_Real dist2 = 0;
const int nbPnt = 7;
const double step = ( theU2 - theU1 ) / nbPnt;
while (( theU1 += step ) < theU2 )
dist2 = Max( dist2, segment.SquareDistance( theCurve.Value( theU1 )));
return sqrt( dist2 );
}
//================================================================================
/*!
* \brief Initialize deflection value by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_Deflection1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_value = 0.;
Standard_Real UMin, UMax;
TopLoc_Location L;
int nbEdges = 0;
TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
{
const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
GeomAdaptor_Curve AdaptCurve(C);
if ( AdaptCurve.GetType() != GeomAbs_Line )
{
vector< double > params;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
{
nbEdges++;
for ( int i = 1; i < params.size(); ++i )
_value = Max( _value, deflection( AdaptCurve, params[ i-1 ], params[ i ]));
}
}
else
nbEdges++;
}
return nbEdges;
}

View File

@ -41,10 +41,18 @@ class StdMeshers_Deflection1D:public SMESH_Hypothesis
double GetDeflection() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_Deflection1D & hyp);
friend istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_Deflection1D & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_Deflection1D & hyp);
/*!
* \brief Initialize deflection value by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _value;

View File

@ -27,10 +27,12 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_LengthFromEdges.hxx"
#include "utilities.h"
using namespace std;
//=============================================================================
/*!
*
@ -42,8 +44,6 @@ StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, int studyId, S
{
_mode =1;
_name = "LengthFromEdges";
// SCRUTE(_name);
// SCRUTE(&_name);
_param_algo_dim = 2; // is used by SMESH_MEFISTO_2D
}
@ -137,3 +137,19 @@ istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp)
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
//================================================================================
bool StdMeshers_LengthFromEdges::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}

View File

@ -45,10 +45,20 @@ public:
int GetMode();
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp);
friend istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator << (std::ostream & save, StdMeshers_LengthFromEdges & hyp);
friend std::istream & operator >> (std::istream & load, StdMeshers_LengthFromEdges & hyp);
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
int _mode;

View File

@ -27,24 +27,37 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_LocalLength.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_Algo.hxx"
#include "utilities.h"
#include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
using namespace std;
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId,
SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen)
:SMESH_Hypothesis(hypId, studyId, gen)
{
_length = 1.;
_name = "LocalLength";
// SCRUTE(_name);
// SCRUTE(&_name);
_param_algo_dim = 1; // is used by SMESH_Regular_1D
_length = 1.;
_name = "LocalLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
}
//=============================================================================
@ -135,3 +148,47 @@ istream & operator >>(istream & load, StdMeshers_LocalLength & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize segment length by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_LocalLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_length = 0.;
Standard_Real UMin, UMax;
TopLoc_Location L;
int nbEdges = 0;
TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
{
const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
GeomAdaptor_Curve AdaptCurve(C);
vector< double > params;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
{
for ( int i = 1; i < params.size(); ++i )
_length += GCPnts_AbscissaPoint::Length( AdaptCurve, params[ i-1 ], params[ i ]);
nbEdges += params.size() - 1;
}
}
if ( nbEdges )
_length /= nbEdges;
return nbEdges;
}

View File

@ -35,21 +35,29 @@
class StdMeshers_LocalLength:public SMESH_Hypothesis
{
public:
StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_LocalLength();
public:
StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_LocalLength();
void SetLength(double length) throw(SALOME_Exception);
void SetLength(double length) throw(SALOME_Exception);
double GetLength() const;
double GetLength() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp);
friend istream & operator >>(istream & load, StdMeshers_LocalLength & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_LocalLength & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_LocalLength & hyp);
protected:
double _length;
/*!
* \brief Initialize segment length by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _length;
};
#endif

View File

@ -27,10 +27,20 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_MaxElementArea.hxx"
#include "SMESH_ControlsDef.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "SMESH_Mesh.hxx"
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include "utilities.h"
using namespace std;
//=============================================================================
/*!
*
@ -42,8 +52,6 @@ StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, int studyId, SME
{
_maxArea =1.;
_name = "MaxElementArea";
// SCRUTE(_name);
// SCRUTE(&_name);
_param_algo_dim = 2;
}
@ -137,3 +145,44 @@ istream & operator >> (istream & load, StdMeshers_MaxElementArea & hyp)
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize maximal area by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_MaxElementArea::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_maxArea = 0;
SMESH::Controls::Area areaControl;
SMESH::Controls::TSequenceOfXYZ nodesCoords;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
TopTools_IndexedMapOfShape faceMap;
TopExp::MapShapes( theShape, TopAbs_FACE, faceMap );
for ( int iF = 1; iF <= faceMap.Extent(); ++iF )
{
SMESHDS_SubMesh * subMesh = aMeshDS->MeshElements( faceMap( iF ));
if ( !subMesh )
return false;
SMDS_ElemIteratorPtr fIt = subMesh->GetElements();
while ( fIt->more() )
{
const SMDS_MeshElement* elem = fIt->next();
if ( elem->GetType() == SMDSAbs_Face ) {
areaControl.GetPoints( elem, nodesCoords );
_maxArea = max( _maxArea, areaControl.GetValue( nodesCoords ));
}
}
}
return _maxArea > 0;
}

View File

@ -35,21 +35,29 @@
class StdMeshers_MaxElementArea:public SMESH_Hypothesis
{
public:
StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_MaxElementArea();
public:
StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_MaxElementArea();
void SetMaxArea(double maxArea) throw(SALOME_Exception);
void SetMaxArea(double maxArea) throw(SALOME_Exception);
double GetMaxArea() const;
double GetMaxArea() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_MaxElementArea & hyp);
friend istream & operator >>(istream & load, StdMeshers_MaxElementArea & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_MaxElementArea & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_MaxElementArea & hyp);
protected:
double _maxArea;
/*!
* \brief Initialize maximal area by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _maxArea;
};
#endif

View File

@ -30,8 +30,18 @@
using namespace std;
#include "StdMeshers_MaxElementVolume.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "SMESH_ControlsDef.hxx"
#include "SMESH_Mesh.hxx"
#include "utilities.h"
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
//=============================================================================
/*!
*
@ -41,10 +51,8 @@ using namespace std;
StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
{
_maxVolume =1.;
_maxVolume = 1.;
_name = "MaxElementVolume";
// SCRUTE(_name);
SCRUTE(&_name);
_param_algo_dim = 3;
}
@ -139,3 +147,54 @@ istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp)
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize maximal area by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_MaxElementVolume::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_maxVolume = 0;
SMESH::Controls::Volume volumeControl;
TopTools_IndexedMapOfShape volMap;
TopExp::MapShapes( theShape, TopAbs_SOLID, volMap );
if ( volMap.IsEmpty() )
TopExp::MapShapes( theShape, TopAbs_SHELL, volMap );
if ( volMap.IsEmpty() )
return false;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
for ( int iV = 1; iV <= volMap.Extent(); ++iV )
{
const TopoDS_Shape& S = volMap( iV );
SMESHDS_SubMesh * subMesh = aMeshDS->MeshElements( S );
if ( !subMesh && S.ShapeType() == TopAbs_SOLID ) {
TopExp_Explorer shellExp( S, TopAbs_SHELL );
if ( shellExp.More() )
subMesh = aMeshDS->MeshElements( shellExp.Current() );
}
if ( !subMesh)
return false;
SMDS_ElemIteratorPtr vIt = subMesh->GetElements();
while ( vIt->more() )
{
const SMDS_MeshElement* elem = vIt->next();
if ( elem->GetType() == SMDSAbs_Volume ) {
_maxVolume = max( _maxVolume, volumeControl.GetValue( elem->GetID() ));
}
}
}
return _maxVolume > 0;
}

View File

@ -45,10 +45,18 @@ public:
double GetMaxVolume() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp);
friend istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator << (std::ostream & save, StdMeshers_MaxElementVolume & hyp);
friend std::istream & operator >> (std::istream & load, StdMeshers_MaxElementVolume & hyp);
/*!
* \brief Initialize maximal volume by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _maxVolume;

View File

@ -96,3 +96,19 @@ istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp)
{
return load;
}
//================================================================================
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
//================================================================================
bool StdMeshers_NotConformAllowed::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}

View File

@ -39,10 +39,21 @@ public:
StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_NotConformAllowed();
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp);
friend istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator << (std::ostream & save, StdMeshers_NotConformAllowed & hyp);
friend std::istream & operator >> (std::istream & load, StdMeshers_NotConformAllowed & hyp);
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
};
#endif

View File

@ -27,20 +27,27 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Distribution.hxx"
#include <Standard_ErrorHandler.hxx>
#include <TCollection_AsciiString.hxx>
#include <ExprIntrp_GenExp.hxx>
#include <Expr_NamedUnknown.hxx>
#include <CASCatch_CatchSignals.hxx>
#include <CASCatch_Failure.hxx>
#include <CASCatch_ErrorHandler.hxx>
#include <OSD.hxx>
#include <Expr_Array1OfNamedUnknown.hxx>
#include <TColStd_Array1OfReal.hxx>
#include "StdMeshers_Distribution.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "SMESH_Mesh.hxx"
#include <CASCatch_CatchSignals.hxx>
#include <CASCatch_ErrorHandler.hxx>
#include <CASCatch_Failure.hxx>
#include <ExprIntrp_GenExp.hxx>
#include <Expr_Array1OfNamedUnknown.hxx>
#include <Expr_NamedUnknown.hxx>
#include <OSD.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_ErrorHandler.hxx>
using namespace std;
const double PRECISION = 1e-7;
@ -640,3 +647,40 @@ istream & operator >>(istream & load, StdMeshers_NumberOfSegments & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize number of segments by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_NumberOfSegments::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_numberOfSegments = 0;
_distrType = DT_Regular;
int nbEdges = 0;
TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
for ( int i = 1; i <= edgeMap.Extent(); ++i )
{
// get current segment length
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edgeMap( i ));
if ( eSubMesh && eSubMesh->NbElements())
_numberOfSegments += eSubMesh->NbElements();
++nbEdges;
}
if ( nbEdges )
_numberOfSegments /= nbEdges;
return nbEdges;
}

View File

@ -161,10 +161,19 @@ public:
int ConversionMode() const
throw (SALOME_Exception);
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream& operator << (ostream & save, StdMeshers_NumberOfSegments & hyp);
friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
/*!
* \brief Initialize number of segments by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream& operator << (std::ostream & save, StdMeshers_NumberOfSegments & hyp);
friend std::istream& operator >> (std::istream & load, StdMeshers_NumberOfSegments & hyp);
protected:
int _numberOfSegments; //!< an edge will be split on to this number of segments

View File

@ -24,10 +24,12 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_Propagation.hxx"
#include "utilities.h"
using namespace std;
//=============================================================================
/*!
*
@ -100,3 +102,19 @@ std::string StdMeshers_Propagation::GetName ()
{
return "Propagation";
}
//================================================================================
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
//================================================================================
bool StdMeshers_Propagation::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}

View File

@ -36,12 +36,22 @@ class StdMeshers_Propagation:public SMESH_Hypothesis
StdMeshers_Propagation(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_Propagation();
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_Propagation & hyp);
friend istream & operator >>(istream & load, StdMeshers_Propagation & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_Propagation & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_Propagation & hyp);
static std::string GetName ();
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
};
#endif

View File

@ -98,3 +98,19 @@ istream & operator >>(istream & load, StdMeshers_QuadranglePreference & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
//================================================================================
bool StdMeshers_QuadranglePreference::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}

View File

@ -47,6 +47,17 @@ class StdMeshers_QuadranglePreference:public SMESH_Hypothesis
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_QuadranglePreference & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_QuadranglePreference & hyp);
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*
* Just return false as this hypothesis does not have parameters values
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
};
#endif

View File

@ -51,10 +51,21 @@ using namespace std;
#include <Precision.hxx>
#include <gp_Pnt2d.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <TColgp_SequenceOfXY.hxx>
#include "utilities.h"
#include "Utils_ExceptHandlers.hxx"
#ifndef StdMeshers_Array2OfNode_HeaderFile
#define StdMeshers_Array2OfNode_HeaderFile
typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
#include <NCollection_DefineArray2.hxx>
DEFINE_BASECOLLECTION (StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
DEFINE_ARRAY2(StdMeshers_Array2OfNode,
StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
#endif
//=============================================================================
/*!
@ -117,7 +128,28 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape);
FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
//FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
if (!quad)
return false;
if(myQuadranglePreference) {
int n1 = quad->nbPts[0];
int n2 = quad->nbPts[1];
int n3 = quad->nbPts[2];
int n4 = quad->nbPts[3];
int nfull = n1+n2+n3+n4;
int ntmp = nfull/2;
ntmp = ntmp*2;
if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) {
// special path for using only quandrangle faces
return ComputeQuadPref(aMesh, aShape, quad);
}
}
// set normalized grid on unit square in parametric domain
SetNormalizedGrid(aMesh, aShape, quad);
if (!quad)
return false;
@ -490,6 +522,56 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
const TopoDS_Face & F = TopoDS::Face(aShape);
// verify 1 wire only, with 4 edges
if (NumberOfWires(F) != 1) {
INFOS("only 1 wire by face (quadrangles)");
return 0;
}
const TopoDS_Wire& W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp (W, F);
FaceQuadStruct* quad = new FaceQuadStruct;
for (int i = 0; i < 4; i++)
quad->uv_edges[i] = 0;
quad->uv_grid = 0;
int nbEdges = 0;
for (wexp.Init(W, F); wexp.More(); wexp.Next()) {
const TopoDS_Edge& E = wexp.Current();
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4) {
quad->edge[nbEdges] = E;
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
}
nbEdges++;
}
if (nbEdges != 4) {
INFOS("face must have 4 edges /quadrangles");
QuadDelete(quad);
return 0;
}
return quad;
}
//=============================================================================
/*!
*
@ -501,46 +583,12 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
{
Unexpect aCatch(SalomeException);
const TopoDS_Face & F = TopoDS::Face(aShape);
FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
// verify 1 wire only, with 4 edges
if (NumberOfWires(F) != 1)
{
INFOS("only 1 wire by face (quadrangles)");
return 0;
}
const TopoDS_Wire& W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp (W, F);
FaceQuadStruct *quad = new FaceQuadStruct;
for (int i = 0; i < 4; i++)
quad->uv_edges[i] = 0;
quad->uv_grid = 0;
int nbEdges = 0;
for (wexp.Init(W, F); wexp.More(); wexp.Next())
{
const TopoDS_Edge& E = wexp.Current();
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4)
{
quad->edge[nbEdges] = E;
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
}
nbEdges++;
}
if (nbEdges != 4)
{
INFOS("face must have 4 edges /quadrangles");
QuadDelete(quad);
return 0;
}
if(!quad) return 0;
// set normalized grid on unit square in parametric domain
SetNormalizedGrid(aMesh, F, quad);
SetNormalizedGrid(aMesh, aShape, quad);
return quad;
}
@ -789,6 +837,654 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
}
}
//=======================================================================
//function : ShiftQuad
//purpose : auxilary function for ComputeQuadPref
//=======================================================================
static void ShiftQuad(FaceQuadStruct* quad, const int num, bool WisF)
{
if(num>3) return;
int i;
for(i=1; i<=num; i++) {
int nbPts3 = quad->nbPts[0];
quad->nbPts[0] = quad->nbPts[1];
quad->nbPts[1] = quad->nbPts[2];
quad->nbPts[2] = quad->nbPts[3];
quad->nbPts[3] = nbPts3;
TopoDS_Edge edge3 = quad->edge[0];
quad->edge[0] = quad->edge[1];
quad->edge[1] = quad->edge[2];
quad->edge[2] = quad->edge[3];
quad->edge[3] = edge3;
double first3 = quad->first[0];
quad->first[0] = quad->first[1];
quad->first[1] = quad->first[2];
quad->first[2] = quad->first[3];
quad->first[3] = first3;
double last3 = quad->last[0];
quad->last[0] = quad->last[1];
quad->last[1] = quad->last[2];
quad->last[2] = quad->last[3];
quad->last[3] = last3;
bool isEdgeForward3 = quad->isEdgeForward[0];
quad->isEdgeForward[0] = quad->isEdgeForward[1];
quad->isEdgeForward[1] = quad->isEdgeForward[2];
quad->isEdgeForward[2] = quad->isEdgeForward[3];
quad->isEdgeForward[3] = isEdgeForward3;
bool isEdgeOut3 = quad->isEdgeOut[0];
quad->isEdgeOut[0] = quad->isEdgeOut[1];
quad->isEdgeOut[1] = quad->isEdgeOut[2];
quad->isEdgeOut[2] = quad->isEdgeOut[3];
quad->isEdgeOut[3] = isEdgeOut3;
UVPtStruct* uv_edges3 = quad->uv_edges[0];
quad->uv_edges[0] = quad->uv_edges[1];
quad->uv_edges[1] = quad->uv_edges[2];
quad->uv_edges[2] = quad->uv_edges[3];
quad->uv_edges[3] = uv_edges3;
}
if(!WisF) {
// replacement left and right edges
int nbPts3 = quad->nbPts[1];
quad->nbPts[1] = quad->nbPts[3];
quad->nbPts[3] = nbPts3;
TopoDS_Edge edge3 = quad->edge[1];
quad->edge[1] = quad->edge[3];
quad->edge[3] = edge3;
double first3 = quad->first[1];
quad->first[1] = quad->first[3];
quad->first[3] = first3;
double last3 = quad->last[1];
quad->last[1] = quad->last[2];
quad->last[3] = last3;
bool isEdgeForward3 = quad->isEdgeForward[1];
quad->isEdgeForward[1] = quad->isEdgeForward[3];
quad->isEdgeForward[3] = isEdgeForward3;
bool isEdgeOut3 = quad->isEdgeOut[1];
quad->isEdgeOut[1] = quad->isEdgeOut[3];
quad->isEdgeOut[3] = isEdgeOut3;
UVPtStruct* uv_edges3 = quad->uv_edges[1];
quad->uv_edges[1] = quad->uv_edges[3];
quad->uv_edges[3] = uv_edges3;
}
}
//=======================================================================
//function : CalcUV
//purpose : auxilary function for ComputeQuadPref
//=======================================================================
static gp_XY CalcUV(double x0, double x1, double y0, double y1,
FaceQuadStruct* quad,
const gp_Pnt2d& a0, const gp_Pnt2d& a1,
const gp_Pnt2d& a2, const gp_Pnt2d& a3,
const Handle(Geom2d_Curve)& c2db,
const Handle(Geom2d_Curve)& c2dr,
const Handle(Geom2d_Curve)& c2dt,
const Handle(Geom2d_Curve)& c2dl)
{
int nb = quad->nbPts[0];
int nr = quad->nbPts[1];
int nt = quad->nbPts[2];
int nl = quad->nbPts[3];
UVPtStruct* uv_eb = quad->uv_edges[0];
UVPtStruct* uv_er = quad->uv_edges[1];
UVPtStruct* uv_et = quad->uv_edges[2];
UVPtStruct* uv_el = quad->uv_edges[3];
double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
double y = y0 + x * (y1 - y0);
double param_b = uv_eb[0].param + x * (uv_eb[nb-1].param - uv_eb[0].param);
double param_t = uv_et[0].param + x * (uv_et[nt-1].param - uv_et[0].param);
double param_r = uv_er[0].param + y * (uv_er[nr-1].param - uv_er[0].param);
double param_l = uv_el[0].param + y * (uv_el[nl-1].param - uv_el[0].param);
gp_Pnt2d p0 = c2db->Value(param_b);
gp_Pnt2d p1 = c2dr->Value(param_r);
gp_Pnt2d p2 = c2dt->Value(param_t);
gp_Pnt2d p3 = c2dl->Value(param_l);
double u = (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
double v = (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
x * y * a2.X() + (1 - x) * y * a3.X();
v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
x * y * a2.Y() + (1 - x) * y * a3.Y();
//cout<<"x0="<<x0<<" x1="<<x1<<" y0="<<y0<<" y1="<<y1<<endl;
//cout<<"x="<<x<<" y="<<y<<endl;
//cout<<"param_b="<<param_b<<" param_t="<<param_t<<" param_r="<<param_r<<" param_l="<<param_l<<endl;
//cout<<"u="<<u<<" v="<<v<<endl;
return gp_XY(u,v);
}
//=======================================================================
//function : ComputeQuadPref
//purpose :
//=======================================================================
/*!
* Special function for creation only quandrangle faces
*/
bool StdMeshers_Quadrangle_2D::ComputeQuadPref
(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape,
FaceQuadStruct* quad) throw (SALOME_Exception)
{
Unexpect aCatch(SalomeException);
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
const TopoDS_Face& F = TopoDS::Face(aShape);
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
const TopoDS_Wire& W = BRepTools::OuterWire(F);
bool WisF = false;
if(W.Orientation()==TopAbs_FORWARD)
WisF = true;
//if(WisF) cout<<"W is FORWARD"<<endl;
//else cout<<"W is REVERSED"<<endl;
bool FisF = (F.Orientation()==TopAbs_FORWARD);
if(!FisF) WisF = !WisF;
int i,j,geomFaceID = meshDS->ShapeToIndex( F );
int nb = quad->nbPts[0];
int nr = quad->nbPts[1];
int nt = quad->nbPts[2];
int nl = quad->nbPts[3];
int dh = abs(nb-nt);
int dv = abs(nr-nl);
if( dh>=dv ) {
if( nt>nb ) {
// it is a base case => not shift quad but me be replacement is need
ShiftQuad(quad,0,WisF);
}
else {
// we have to shift quad on 2
ShiftQuad(quad,2,WisF);
}
}
else {
if( nr>nl ) {
// we have to shift quad on 3
ShiftQuad(quad,3,WisF);
}
else {
// we have to shift quad on 1
ShiftQuad(quad,1,WisF);
}
}
nb = quad->nbPts[0];
nr = quad->nbPts[1];
nt = quad->nbPts[2];
nl = quad->nbPts[3];
dh = abs(nb-nt);
dv = abs(nr-nl);
int nbh = Max(nb,nt);
int nbv = Max(nr,nl);
int addh = 0;
int addv = 0;
// orientation of face and 3 main domain for future faces
// 0 top 1
// 1------------1
// | | | |
// | | | |
// | L | | R |
// left | | | | rigth
// | / \ |
// | / C \ |
// |/ \|
// 0------------0
// 0 bottom 1
if(dh>dv) {
addv = (dh-dv)/2;
nbv = nbv + addv;
}
else { // dv>=dh
addh = (dv-dh)/2;
nbh = nbh + addh;
}
Handle(Geom2d_Curve) c2d[4];
for(i=0; i<4; i++) {
c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], F,
quad->first[i], quad->last[i]);
}
bool loadOk = true;
for(i=0; i<2; i++) {
quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], false);
if(!quad->uv_edges[i]) loadOk = false;
}
for(i=2; i<4; i++) {
quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], true);
if (!quad->uv_edges[i]) loadOk = false;
}
if (!loadOk) {
INFOS("StdMeshers_Quadrangle_2D::ComputeQuadPref - LoadEdgePoints failed");
QuadDelete( quad );
quad = 0;
return false;
}
UVPtStruct* uv_eb = quad->uv_edges[0];
UVPtStruct* uv_er = quad->uv_edges[1];
UVPtStruct* uv_et = quad->uv_edges[2];
UVPtStruct* uv_el = quad->uv_edges[3];
// arrays for normalized params
//cout<<"Dump B:"<<endl;
TColStd_SequenceOfReal npb, npr, npt, npl;
for(i=0; i<nb; i++) {
npb.Append(uv_eb[i].normParam);
//cout<<"i="<<i<<" par="<<uv_eb[i].param<<" npar="<<uv_eb[i].normParam;
//const SMDS_MeshNode* N = uv_eb[i].node;
//cout<<" node("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
}
for(i=0; i<nr; i++) {
npr.Append(uv_er[i].normParam);
}
for(i=0; i<nt; i++) {
npt.Append(uv_et[i].normParam);
}
for(i=0; i<nl; i++) {
npl.Append(uv_el[i].normParam);
}
// we have to add few values of params to right and left
// insert them after first param
// insert to right
int dr = nbv - nr;
double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
for(i=1; i<=dr; i++) {
npr.InsertAfter(1,npr.Value(2)-dpr);
}
// insert to left
int dl = nbv - nl;
dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
for(i=1; i<=dl; i++) {
npl.InsertAfter(1,npl.Value(2)-dpr);
}
//cout<<"npb:";
//for(i=1; i<=npb.Length(); i++) {
// cout<<" "<<npb.Value(i);
//}
//cout<<endl;
gp_Pnt2d a[4];
c2d[0]->D0(uv_eb[0].param,a[0]);
c2d[0]->D0(uv_eb[nb-1].param,a[1]);
c2d[2]->D0(uv_et[nt-1].param,a[2]);
c2d[2]->D0(uv_et[0].param,a[3]);
//cout<<" a[0]("<<a[0].X()<<","<<a[0].Y()<<")"<<" a[1]("<<a[1].X()<<","<<a[1].Y()<<")"
// <<" a[2]("<<a[2].X()<<","<<a[2].Y()<<")"<<" a[3]("<<a[3].X()<<","<<a[3].Y()<<")"<<endl;
int nnn = Min(nr,nl);
// auxilary sequence of XY for creation nodes
// in the bottom part of central domain
// it's length must be == nbv-nnn-1
TColgp_SequenceOfXY UVL;
TColgp_SequenceOfXY UVR;
// step1: create faces for left domain
StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
// add left nodes
for(j=1; j<=nl; j++)
NodesL.SetValue(1,j,uv_el[j-1].node);
if(dl>0) {
// add top nodes
for(i=1; i<=dl; i++)
NodesL.SetValue(i+1,nl,uv_et[i].node);
// create and add needed nodes
TColgp_SequenceOfXY UVtmp;
for(i=1; i<=dl; i++) {
double x0 = npt.Value(i+1);
double x1 = x0;
// diagonal node
double y0 = npl.Value(i+1);
double y1 = npr.Value(i+1);
gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
c2d[0], c2d[1], c2d[2], c2d[3]);
gp_Pnt P = S->Value(UV.X(),UV.Y());
SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
NodesL.SetValue(i+1,1,N);
if(UVL.Length()<nbv-nnn-1) UVL.Append(UV);
// internal nodes
for(j=2; j<nl; j++) {
double y0 = npl.Value(dl+j);
double y1 = npr.Value(dl+j);
gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
c2d[0], c2d[1], c2d[2], c2d[3]);
gp_Pnt P = S->Value(UV.X(),UV.Y());
SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
NodesL.SetValue(i+1,j,N);
if( i==dl ) UVtmp.Append(UV);
}
}
for(i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn-1; i++) {
UVL.Append(UVtmp.Value(i));
}
//cout<<"Dump NodesL:"<<endl;
//for(i=1; i<=dl+1; i++) {
// cout<<"i="<<i;
// for(j=1; j<=nl; j++) {
// cout<<" ("<<NodesL.Value(i,j)->X()<<","<<NodesL.Value(i,j)->Y()<<","<<NodesL.Value(i,j)->Z()<<")";
// }
// cout<<endl;
//}
// create faces
for(i=1; i<=dl; i++) {
for(j=1; j<nl; j++) {
if(WisF) {
SMDS_MeshFace* F =
meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
else {
SMDS_MeshFace* F =
meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
}
}
}
else {
// fill UVL using c2d
for(i=1; i<npl.Length() && UVL.Length()<nbv-nnn-1; i++) {
gp_Pnt2d p2d;
c2d[3]->D0(uv_el[i].param,p2d);
UVL.Append(p2d.XY());
}
}
// step2: create faces for right domain
StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
// add right nodes
for(j=1; j<=nr; j++)
NodesR.SetValue(1,j,uv_er[nr-j].node);
if(dr>0) {
// add top nodes
for(i=1; i<=dr; i++)
NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
// create and add needed nodes
TColgp_SequenceOfXY UVtmp;
for(i=1; i<=dr; i++) {
double x0 = npt.Value(nt-i);
double x1 = x0;
// diagonal node
double y0 = npl.Value(i+1);
double y1 = npr.Value(i+1);
gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
c2d[0], c2d[1], c2d[2], c2d[3]);
gp_Pnt P = S->Value(UV.X(),UV.Y());
SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
NodesR.SetValue(i+1,nr,N);
if(UVR.Length()<nbv-nnn-1) UVR.Append(UV);
// internal nodes
for(j=2; j<nr; j++) {
double y0 = npl.Value(nbv-j+1);
double y1 = npr.Value(nbv-j+1);
gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
c2d[0], c2d[1], c2d[2], c2d[3]);
gp_Pnt P = S->Value(UV.X(),UV.Y());
SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
NodesR.SetValue(i+1,j,N);
if( i==dr ) UVtmp.Prepend(UV);
}
}
for(i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn-1; i++) {
UVR.Append(UVtmp.Value(i));
}
// create faces
for(i=1; i<=dr; i++) {
for(j=1; j<nr; j++) {
if(WisF) {
SMDS_MeshFace* F =
meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
else {
SMDS_MeshFace* F =
meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
}
}
}
else {
// fill UVR using c2d
for(i=1; i<npr.Length() && UVR.Length()<nbv-nnn-1; i++) {
gp_Pnt2d p2d;
c2d[1]->D0(uv_er[i].param,p2d);
UVR.Append(p2d.XY());
}
}
// step3: create faces for central domain
StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
// add first string using NodesL
for(i=1; i<=dl+1; i++)
NodesC.SetValue(1,i,NodesL(i,1));
for(i=2; i<=nl; i++)
NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
// add last string using NodesR
for(i=1; i<=dr+1; i++)
NodesC.SetValue(nb,i,NodesR(i,nr));
for(i=1; i<nr; i++)
NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
// add top nodes (last columns)
for(i=dl+2; i<nbh-dr; i++)
NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
// add bottom nodes (first columns)
for(i=2; i<nb; i++) {
NodesC.SetValue(i,1,uv_eb[i-1].node);
gp_Pnt2d p2d;
c2d[0]->D0(uv_eb[i-1].param,p2d);
}
// create and add needed nodes
// add linear layers
for(i=2; i<nb; i++) {
double x0 = npt.Value(dl+i);
double x1 = x0;
for(j=1; j<nnn; j++) {
double y0 = npl.Value(nbv-nnn+j);
double y1 = npr.Value(nbv-nnn+j);
gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
c2d[0], c2d[1], c2d[2], c2d[3]);
gp_Pnt P = S->Value(UV.X(),UV.Y());
SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
NodesC.SetValue(i,nbv-nnn+j,N);
}
}
// add diagonal layers
//cout<<"UVL.Length()="<<UVL.Length()<<" UVR.Length()="<<UVR.Length()<<endl;
//cout<<"Dump UVL:"<<endl;
//for(i=1; i<=UVL.Length(); i++) {
// cout<<" ("<<UVL.Value(i).X()<<","<<UVL.Value(i).Y()<<")";
//}
//cout<<endl;
for(i=1; i<nbv-nnn; i++) {
double du = UVR.Value(i).X() - UVL.Value(i).X();
double dv = UVR.Value(i).Y() - UVL.Value(i).Y();
for(j=2; j<nb; j++) {
double u = UVL.Value(i).X() + du*npb.Value(j);
double v = UVL.Value(i).Y() + dv*npb.Value(j);
gp_Pnt P = S->Value(u,v);
SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(N, geomFaceID, u, v);
NodesC.SetValue(j,i+1,N);
}
}
// create faces
for(i=1; i<nb; i++) {
for(j=1; j<nbv; j++) {
if(WisF) {
SMDS_MeshFace* F =
meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
else {
SMDS_MeshFace* F =
meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
}
}
QuadDelete(quad);
bool isOk = true;
return isOk;
}
//=============================================================================
/*!
* LoadEdgePoints2
*/
//=============================================================================
UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
const TopoDS_Face& F,
const TopoDS_Edge& E,
bool IsReverse)
{
//MESSAGE("StdMeshers_Quadrangle_2D::LoadEdgePoints");
// --- IDNodes of first and last Vertex
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMDS_NodeIteratorPtr lid = aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
if (!lid->more()) {
MESSAGE ( "NO NODE BUILT ON VERTEX" );
return 0;
}
const SMDS_MeshNode* idFirst = lid->next();
ASSERT(!VLast.IsNull());
lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
if (!lid->more()) {
MESSAGE ( "NO NODE BUILT ON VERTEX" );
return 0;
}
const SMDS_MeshNode* idLast = lid->next();
// --- edge internal IDNodes (relies on good order storage, not checked)
map<double, const SMDS_MeshNode *> params;
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbPoints != params.size()) {
MESSAGE( "BAD NODE ON EDGE POSITIONS" );
return 0;
}
UVPtStruct* uvslf = new UVPtStruct[nbPoints + 2];
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const TopoDS_Wire& W = BRepTools::OuterWire(F);
bool FisF = (F.Orientation()==TopAbs_FORWARD);
bool WisF = (W.Orientation()==TopAbs_FORWARD);
bool isForward = (E.Orientation()==TopAbs_FORWARD);
//if(isForward) cout<<"E is FORWARD"<<endl;
//else cout<<"E is REVERSED"<<endl;
if(!WisF) isForward = !isForward;
if(!FisF) isForward = !isForward;
//bool isForward = !(E.Orientation()==TopAbs_FORWARD);
if(IsReverse) isForward = !isForward;
double paramin = 0;
double paramax = 0;
if (isForward) {
paramin = f;
paramax = l;
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf[0].x = p.X();
uvslf[0].y = p.Y();
uvslf[0].param = f;
uvslf[0].node = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) { // nbPoints internal
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf[i].x = p.X();
uvslf[i].y = p.Y();
uvslf[i].param = param;
uvslf[i].node = (*itp).second;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++;
}
p = C2d->Value(l); // last point = Vertex Reversed
uvslf[nbPoints + 1].x = p.X();
uvslf[nbPoints + 1].y = p.Y();
uvslf[nbPoints + 1].param = l;
uvslf[nbPoints + 1].node = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
}
else {
paramin = l;
paramax = f;
gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
uvslf[0].x = p.X();
uvslf[0].y = p.Y();
uvslf[0].param = l;
uvslf[0].node = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
for (int j = nbPoints; j >= 1; j--) { // nbPoints internal
double param = (*itp).first;
int i = nbPoints + 1 - j;
gp_Pnt2d p = C2d->Value(param);
uvslf[i].x = p.X();
uvslf[i].y = p.Y();
uvslf[i].param = param;
uvslf[i].node = (*itp).second;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++;
}
p = C2d->Value(f); // last point = Vertex Forward
uvslf[nbPoints + 1].x = p.X();
uvslf[nbPoints + 1].y = p.Y();
uvslf[nbPoints + 1].param = f;
uvslf[nbPoints + 1].node = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
}
ASSERT(paramin != paramax);
for (int i = 0; i < nbPoints + 2; i++) {
uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
}
return uvslf;
}
//=============================================================================
/*!
* LoadEdgePoints

View File

@ -87,11 +87,27 @@ public:
protected:
FaceQuadStruct* CheckNbEdges(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
void SetNormalizedGrid(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
FaceQuadStruct* quad)
throw (SALOME_Exception);
/**
* Special function for creation only quandrangle faces
*/
bool ComputeQuadPref(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
FaceQuadStruct* quad)
throw (SALOME_Exception);
UVPtStruct* LoadEdgePoints2(SMESH_Mesh& aMesh,
const TopoDS_Face& F, const TopoDS_Edge& E,
bool IsReverse);
UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh,
const TopoDS_Face& F, const TopoDS_Edge& E,
double first, double last);

View File

@ -27,21 +27,17 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_Regular_1D.hxx"
#include "StdMeshers_Distribution.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include <OSD.hxx>
#include "StdMeshers_LocalLength.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Arithmetic1D.hxx"
#include "StdMeshers_StartEndLength.hxx"
#include "StdMeshers_Deflection1D.hxx"
#include <StdMeshers_AutomaticLength.hxx>
#include "StdMeshers_AutomaticLength.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
@ -66,10 +62,13 @@ using namespace std;
#include <Expr_Array1OfNamedUnknown.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <ExprIntrp_GenExp.hxx>
#include <OSD.hxx>
#include <string>
#include <math.h>
using namespace std;
//=============================================================================
/*!
*

View File

@ -25,11 +25,22 @@
// Module : SMESH
// $Header$
using namespace std;
#include "StdMeshers_StartEndLength.hxx"
#include "utilities.h"
#include "SMESH_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
using namespace std;
//=============================================================================
/*!
@ -43,7 +54,7 @@ StdMeshers_StartEndLength::StdMeshers_StartEndLength(int hypId,
:SMESH_Hypothesis(hypId, studyId, gen)
{
_begLength = 1.;
_endLength = 1.;
_endLength = 10.;
_name = "StartEndLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
}
@ -141,3 +152,49 @@ istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp)
{
return hyp.LoadFrom( load );
}
//================================================================================
/*!
* \brief Initialize start and end length by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
//================================================================================
bool StdMeshers_StartEndLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
{
if ( !theMesh || theShape.IsNull() )
return false;
_begLength = _endLength = 0.;
Standard_Real UMin, UMax;
TopLoc_Location L;
int nbEdges = 0;
TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
for ( int i = 1; i <= edgeMap.Extent(); ++i )
{
const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
Handle(Geom_Curve) C = BRep_Tool::Curve(edge, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C);
vector< double > params;
SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
{
nbEdges++;
_begLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[0], params[1]);
int nb = params.size();
_endLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[nb-2], params[nb-1]);
}
}
if ( nbEdges ) {
_begLength /= nbEdges;
_endLength /= nbEdges;
}
return nbEdges;
}

View File

@ -41,12 +41,21 @@ class StdMeshers_StartEndLength:public SMESH_Hypothesis
double GetLength(bool isStartLength) const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp);
friend istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp);
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_StartEndLength & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_StartEndLength & hyp);
protected:
/*!
* \brief Initialize start and end length by the mesh built on the geometry
* \param theMesh - the built mesh
* \param theShape - the geometry of interest
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _begLength, _endLength;
};

View File

@ -19,8 +19,8 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
{
myHypo = StdMeshers::StdMeshers_NumberOfSegments::_duplicate( h );
myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
myCurve1 = insertCurve( QString() );
myCurve2 = insertCurve( QString() );
myDensity = insertCurve( QString() );
myDistr = insertCurve( QString() );
myMsg = insertMarker( new QwtPlotMarker( this ) );
setMarkerPos( myMsg, 0.5, 0.5 );
setMarkerLabelPen( myMsg, QPen( Qt::red, 1 ) );
@ -28,11 +28,16 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
f.setPointSize( 14 );
f.setBold( true );
setMarkerFont( myMsg, f );
setCurvePen( myCurve1, QPen( Qt::red, 1 ) );
setCurvePen( myDensity, QPen( Qt::red, 1 ) );
QColor dc = Qt::blue;
setCurvePen( myCurve2, QPen( dc, 1 ) );
setCurveSymbol( myCurve2, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
setCurvePen( myDistr, QPen( dc, 1 ) );
setCurveSymbol( myDistr, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
setAutoLegend( true );
enableLegend( true );
setLegendPos( Qwt::Bottom );
setCurveTitle( myDensity, tr( "SMESH_DENSITY_FUNC" ) );
setCurveTitle( myDistr, tr( "SMESH_DISTR" ) );
}
StdMeshersGUI_DistrPreview::~StdMeshersGUI_DistrPreview()
@ -196,9 +201,9 @@ void StdMeshersGUI_DistrPreview::update()
max_x = x[i];
}
setAxisScale( curveXAxis( myCurve1 ), min_x, max_x );
setAxisScale( curveYAxis( myCurve1 ), min( 0.0, min_y ), max( 0.0, max_y ) );
setCurveData( myCurve1, x, y, size );
setAxisScale( curveXAxis( myDensity ), min_x, max_x );
setAxisScale( curveYAxis( myDensity ), min( 0.0, min_y ), max( 0.0, max_y ) );
setCurveData( myDensity, x, y, size );
if( x )
delete[] x;
if( y )
@ -213,19 +218,33 @@ void StdMeshersGUI_DistrPreview::update()
x[i] = distr[i];
y[i] = 0;
}
setCurveData( myCurve2, x, y, size );
setCurveData( myDistr, x, y, size );
delete[] x;
delete[] y;
x = y = 0;
replot();
OSD::SetSignal( true );
CASCatch_CatchSignals aCatchSignals;
aCatchSignals.Activate();
CASCatch_TRY
{
replot();
}
CASCatch_CATCH(CASCatch_Failure)
{
aCatchSignals.Deactivate();
Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
}
aCatchSignals.Deactivate();
}
void StdMeshersGUI_DistrPreview::showError()
{
setAxisScale( curveXAxis( myCurve1 ), 0.0, 1.0 );
setAxisScale( curveYAxis( myCurve1 ), 0.0, 1.0 );
setCurveData( myCurve1, 0, 0, 0 );
setCurveData( myCurve2, 0, 0, 0 );
setAxisScale( curveXAxis( myDensity ), 0.0, 1.0 );
setAxisScale( curveYAxis( myDensity ), 0.0, 1.0 );
setCurveData( myDensity, 0, 0, 0 );
setCurveData( myDistr, 0, 0, 0 );
setMarkerLabel( myMsg, tr( "SMESH_INVALID_FUNCTION" ) );
replot();
}

View File

@ -48,7 +48,7 @@ private:
bool myIsTable;
Conversion myConv;
SMESH::double_array myTableFunc;
long myCurve1, myCurve2, myMsg;
long myDensity, myDistr, myMsg;
Handle(ExprIntrp_GenExp) myExpr;
Expr_Array1OfNamedUnknown myVars;
TColStd_Array1OfReal myValues;

View File

@ -26,9 +26,10 @@
// $Header$
#include "StdMeshersGUI_DistrTable.h"
#include <QtxDblValidator.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qvalidator.h>
#include <qlineedit.h>
//=================================================================================
@ -40,8 +41,8 @@ StdMeshersGUI_DistrTable::StdMeshersGUI_DistrTable( const int rows, QWidget* par
{
horizontalHeader()->setLabel( 0, "t" );
horizontalHeader()->setLabel( 1, "f(t)" );
myArgV = new QDoubleValidator( 0.0, 1.0, 3, this );
myFuncV = new QDoubleValidator( 0.0, 1E10, 3, this );
myArgV = new QtxDblValidator( 0.0, 1.0, 3, this );
myFuncV = new QtxDblValidator( 0.0, 1E20, 3, this );
}
StdMeshersGUI_DistrTable::~StdMeshersGUI_DistrTable()
@ -70,6 +71,14 @@ void StdMeshersGUI_DistrTable::stopEditing( const bool accept )
endEdit( currEditRow(), currEditCol(), accept, false );
}
QWidget* StdMeshersGUI_DistrTable::beginEdit( int row, int col, bool replace )
{
QWidget* w = QTable::beginEdit( row, col, replace );
if( w && w->inherits( "QLineEdit" ) )
( ( QLineEdit* )w )->selectAll();
return w;
}
void StdMeshersGUI_DistrTable::edit( const int r, const int c )
{
if( isEditing() )
@ -265,8 +274,24 @@ void StdMeshersGUI_DistrTable::setData( const SMESH::double_array& d )
{
stopEditing( false );
setNumRows( d.length()/2 );
QString val;
for( int i=0; i<d.length(); i++ )
setText( i/2, i%2, QString( "%1" ).arg( d[i] ) );
{
QtxDblValidator* v = i%2==0 ? myArgV : myFuncV;
val = QString::number( d[i] );
v->fixup( val );
setText( i/2, i%2, val );
}
}
QtxDblValidator* StdMeshersGUI_DistrTable::argValidator() const
{
return myArgV;
}
QtxDblValidator* StdMeshersGUI_DistrTable::funcValidator() const
{
return myFuncV;
}
//=================================================================================
@ -346,3 +371,4 @@ void StdMeshersGUI_DistrTableFrame::onButtonClicked()
else if( sender()==button( REMOVE_ROW ) )
emit toEdit( REMOVE_ROW, table()->currentRow() );
}

View File

@ -34,7 +34,7 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QButton;
class QDoubleValidator;
class QtxDblValidator;
/*!
* \brief Values corresponding to buttons for table resize
@ -65,17 +65,21 @@ public:
void data( SMESH::double_array& );
void setData( const SMESH::double_array& );
QtxDblValidator* argValidator() const;
QtxDblValidator* funcValidator() const;
protected:
virtual QWidget* createEditor( int, int, bool ) const;
virtual bool eventFilter( QObject*, QEvent* );
virtual void keyPressEvent( QKeyEvent* );
virtual QWidget* beginEdit( int row, int col, bool replace );
virtual void edit( const int, const int );
private slots:
void onEdit( TableButton, int );
private:
QDoubleValidator *myArgV, *myFuncV;
QtxDblValidator *myArgV, *myFuncV;
};
@ -122,6 +126,5 @@ private:
StdMeshersGUI_DistrTable *myTable;
};
#endif

View File

@ -12,6 +12,7 @@
#include <QtxIntSpinBox.h>
#include <QtxComboBox.h>
#include <QtxDblValidator.h>
#include <SMESHGUI_SpinBox.h>
#include <qlabel.h>
@ -142,7 +143,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
myConv->setColumnLayout( 0, Qt::Vertical );
QGridLayout* convLay = new QGridLayout( myConv->layout() );
convLay->addWidget( new QRadioButton( tr( "SMESH_EXP_MODE" ), myConv ), 0, 0 );
convLay->addWidget( new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
convLay->addWidget( myCutNeg = new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
myGroupLayout->addWidget( myConv, row, 1 );
row++;
@ -176,17 +177,59 @@ void StdMeshersGUI_NbSegmentsCreator::retrieveParams() const
myExpr->setText( data.myExpr );
}
void StdMeshersGUI_NbSegmentsCreator::storeParams() const
QString StdMeshersGUI_NbSegmentsCreator::storeParams() const
{
NbSegmentsHypothesisData data;
readParamsFromWidgets( data );
storeParamsToHypo( data );
QString valStr = QString::number( data.myNbSeg ) += "; ";
enum DistrType
{
Regular, //!< equidistant distribution
Scale, //!< scale distribution
TabFunc, //!< distribution with density function presented by table
ExprFunc //!< distribution with density function presented by expression
};
bool hasConv = false;
switch ( data.myDistrType ) {
case Regular :
valStr += tr("SMESH_DISTR_REGULAR");
break;
case Scale :
valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );
break;
case TabFunc : {
//valStr += tr("SMESH_TAB_FUNC");
bool param = true;
for( int i=0; i < data.myTable.length(); i++, param = !param ) {
if ( param )
valStr += "[";
valStr += QString::number( data.myTable[ i ]);
valStr += ( param ? "," : "]" );
}
hasConv = true;
break;
}
case ExprFunc:
valStr += data.myExpr;
hasConv = true;
break;
}
if ( hasConv )
if ( data.myConv )
valStr += "; " + tr("SMESH_CUT_NEG_MODE");
else
valStr += "; " + tr("SMESH_EXP_MODE");
return valStr;
}
bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisData& h_data ) const
{
StdMeshers::StdMeshers_NumberOfSegments_var h =
StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
StdMeshers::StdMeshers_NumberOfSegments::_narrow( initParamsHypothesis() );
HypothesisData* data = SMESH::GetHypothesisData( hypType() );
h_data.myName = isCreation() && data ? data->Label : "";
@ -270,6 +313,19 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged()
{
int distr = myDistr->currentItem();
/* if( distr==2 ) //table func
myCutNeg->setText( tr( "SMESH_NO_CONV" ) );
else if( distr==3 )
myCutNeg->setText( tr( "SMESH_CUT_NEG_MODE" ) );*/
if( distr==2 && sender()==myConv ) //table func
{
myTable->table()->funcValidator()->setBottom( myConv->id( myConv->selected() )==0 ? -1E20 : 0 );
SMESH::double_array arr;
myTable->table()->data( arr );
myTable->table()->setData( arr ); //update data in table
}
myScale->setShown( distr==1 );
myLScale->setShown( distr==1 );

View File

@ -15,6 +15,7 @@ class StdMeshersGUI_DistrPreview;
class QLineEdit;
class QButtonGroup;
class QGridLayout;
class QRadioButton;
typedef struct
{
@ -38,7 +39,7 @@ public:
protected:
virtual QFrame* buildFrame();
virtual void retrieveParams() const;
virtual void storeParams() const;
virtual QString storeParams() const;
protected slots:
virtual void onValueChanged();
@ -59,6 +60,7 @@ private:
QLabel *myLScale, *myLTable, *myLExpr, *myLConv, *myInfo;
QGridLayout* myGroupLayout;
int myTableRow, myPreviewRow;
QRadioButton* myCutNeg;
};
#endif

View File

@ -39,6 +39,9 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include <qpixmap.h>
#include <qhbox.h>
#include <qslider.h>
#include <qlabel.h>
const double VALUE_MAX = 1.0e+15, // COORD_MAX
@ -72,7 +75,7 @@ void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
//here this method must be empty because buildStdParam sets values itself
}
void StdMeshersGUI_StdHypothesisCreator::storeParams() const
QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
{
ListOfStdParams params;
bool res = getStdParamFromDlg( params );
@ -82,6 +85,8 @@ void StdMeshersGUI_StdHypothesisCreator::storeParams() const
params.remove( params.begin() );
}
QString valueStr = stdParamValues( params );
if( res && !params.isEmpty() )
{
if( hypType()=="LocalLength" )
@ -128,7 +133,15 @@ void StdMeshersGUI_StdHypothesisCreator::storeParams() const
h->SetDeflection( params[0].myValue.toDouble() );
}
else if( hypType()=="AutomaticLength" )
{
StdMeshers::StdMeshers_AutomaticLength_var h =
StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
h->SetFineness( params[0].myValue.toDouble() );
}
}
return valueStr;
}
bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
@ -145,64 +158,75 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
p.append( item );
}
SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
if( hypType()=="LocalLength" )
{
StdMeshers::StdMeshers_LocalLength_var h =
StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
item.myValue = isCreation() ? 1.0 : h->GetLength();
item.myValue = h->GetLength();
p.append( item );
}
else if( hypType()=="Arithmetic1D" )
{
StdMeshers::StdMeshers_Arithmetic1D_var h =
StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
item.myValue = isCreation() ? 1.0 : h->GetLength( true );
item.myValue = h->GetLength( true );
p.append( item );
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
item.myValue = isCreation() ? 10.0 : h->GetLength( false );
item.myValue = h->GetLength( false );
p.append( item );
}
else if( hypType()=="MaxElementArea" )
{
StdMeshers::StdMeshers_MaxElementArea_var h =
StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
item.myValue = isCreation() ? 1.0 : h->GetMaxElementArea();
item.myValue = h->GetMaxElementArea();
p.append( item );
}
else if( hypType()=="MaxElementVolume" )
{
StdMeshers::StdMeshers_MaxElementVolume_var h =
StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
item.myValue = isCreation() ? 1.0 : h->GetMaxElementVolume();
item.myValue = h->GetMaxElementVolume();
p.append( item );
}
else if( hypType()=="StartEndLength" )
{
StdMeshers::StdMeshers_StartEndLength_var h =
StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
item.myValue = isCreation() ? 1.0 : h->GetLength( true );
item.myValue = h->GetLength( true );
p.append( item );
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
item.myValue = isCreation() ? 10.0 : h->GetLength( false );
item.myValue = h->GetLength( false );
p.append( item );
}
else if( hypType()=="Deflection1D" )
{
StdMeshers::StdMeshers_Deflection1D_var h =
StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
item.myValue = isCreation() ? 1.0 : h->GetDeflection();
item.myValue = h->GetDeflection();
p.append( item );
}
else if( hypType()=="AutomaticLength" )
{
StdMeshers::StdMeshers_AutomaticLength_var h =
StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
item.myName = tr( "SMESH_FINENESS_PARAM" );
item.myValue = h->GetFineness();
p.append( item );
}
else
@ -267,6 +291,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons
types.insert( "StartEndLength", "START_END_LENGTH" );
types.insert( "Deflection1D", "DEFLECTION1D" );
types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
}
QString res;
@ -275,3 +300,65 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons
return res;
}
//================================================================================
/*!
* \brief Widget: slider with left and right labels
*/
//================================================================================
class TDoubleSliderWith2Lables: public QHBox
{
public:
TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel,
const double initValue, const double bottom,
const double top , const double precision,
QWidget * parent=0 , const char * name=0 )
:QHBox(parent,name), _bottom(bottom), _precision(precision)
{
if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel );
_slider = new QSlider( Horizontal, this );
_slider->setRange( 0, toInt( top ));
_slider->setValue( toInt( initValue ));
if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel );
}
double value() const { return _bottom + _slider->value() * _precision; }
QSlider * getSlider() const { return _slider; }
int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
private:
double _bottom, _precision;
QSlider * _slider;
};
//=======================================================================
//function : getCustomWidget
//purpose :
//=======================================================================
QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
QWidget* parent) const
{
if ( hypType()=="AutomaticLength" && param.myValue.type() == QVariant::Double )
return new TDoubleSliderWith2Lables( "0 ", " 1", param.myValue.toDouble(),
0, 1, 0.01, parent );
return 0;
}
//=======================================================================
//function : getParamFromCustomWidget
//purpose :
//=======================================================================
bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
QWidget* widget) const
{
if ( hypType()=="AutomaticLength" ) {
TDoubleSliderWith2Lables* w = dynamic_cast<TDoubleSliderWith2Lables*>( widget );
if ( w ) {
param.myValue = w->value();
return true;
}
}
return false;
}

View File

@ -46,12 +46,14 @@ public:
protected:
virtual QFrame* buildFrame ();
virtual void retrieveParams() const;
virtual void storeParams () const;
virtual QString storeParams () const;
virtual bool stdParams ( ListOfStdParams& ) const;
virtual void attuneStdWidget( QWidget*, const int ) const;
virtual QString caption() const;
virtual QPixmap icon() const;
virtual QString type() const;
virtual QWidget* getCustomWidget( const StdParam&, QWidget* ) const;
virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const;
private:
QString hypTypeName( const QString& ) const;

View File

@ -47,6 +47,12 @@ msgstr "Distribution with analitic density"
msgid "SMESH_NB_SEGMENTS_SCALE_PARAM"
msgstr "Scale Factor"
msgid "SMESH_DENSITY_FUNC"
msgstr "Density function"
msgid "SMESH_DISTR"
msgstr "Distribution"
msgid "SMESH_TAB_FUNC"
msgstr "Table function"
@ -65,6 +71,9 @@ msgstr "Exponent"
msgid "SMESH_CUT_NEG_MODE"
msgstr "Cut negative"
msgid "SMESH_NO_CONV"
msgstr "No conversion"
msgid "SMESH_INSERT_ROW"
msgstr "Insert row"