#include "SMESHDS_Hypothesis.hxx"
class SMESH_Gen;
+class TopoDS_Shape;
+class SMESH_Mesh;
class SMESH_Hypothesis: public SMESHDS_Hypothesis
{
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;
// 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;
}
{
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;
+}
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;
#include "SMESH_Mesh.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_Algo.hxx"
+#include "SMESHDS_SubMesh.hxx"
#include "utilities.h"
*/
//=============================================================================
-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
*/
//================================================================================
+const double theCoarseConst = 0.5;
+const double theFineConst = 4.5;
+
void StdMeshers_AutomaticLength::SetFineness(double theFineness)
throw(SALOME_Exception)
{
*/
//================================================================================
-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
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;
}
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);
}
//=============================================================================
{
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;
+}
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;
#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>
//=============================================================================
/*!
{
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;
+}
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;
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_LengthFromEdges.hxx"
+
#include "utilities.h"
+using namespace std;
+
//=============================================================================
/*!
*
{
_mode =1;
_name = "LengthFromEdges";
-// SCRUTE(_name);
-// SCRUTE(&_name);
_param_algo_dim = 2; // is used by SMESH_MEFISTO_2D
}
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;
+}
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;
// 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
}
//=============================================================================
{
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;
+}
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
// 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;
+
//=============================================================================
/*!
*
{
_maxArea =1.;
_name = "MaxElementArea";
-// SCRUTE(_name);
-// SCRUTE(&_name);
_param_algo_dim = 2;
}
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;
+}
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
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>
+
//=============================================================================
/*!
*
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;
}
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;
+}
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;
{
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;
+}
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
// 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 "SMESHDS_SubMesh.hxx"
+#include "SMESH_Mesh.hxx"
+
#include <CASCatch_CatchSignals.hxx>
-#include <CASCatch_Failure.hxx>
#include <CASCatch_ErrorHandler.hxx>
-#include <OSD.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;
{
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;
+}
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
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_Propagation.hxx"
+
#include "utilities.h"
+using namespace std;
+
//=============================================================================
/*!
*
{
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;
+}
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
{
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;
+}
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
// 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"
#include <Expr_Array1OfNamedUnknown.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <ExprIntrp_GenExp.hxx>
+#include <OSD.hxx>
#include <string>
#include <math.h>
+using namespace std;
+
//=============================================================================
/*!
*
// 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;
//=============================================================================
/*!
:SMESH_Hypothesis(hypId, studyId, gen)
{
_begLength = 1.;
- _endLength = 1.;
+ _endLength = 10.;
_name = "StartEndLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
}
{
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;
+}
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;
};