mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-01 20:30:35 +05:00
PAL10953: add SetParametersByMesh()
This commit is contained in:
parent
917b87170a
commit
65f70369c2
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user