22355: EDF SMESH: New 1D hypothesis "Adaptive"

This commit is contained in:
eap 2013-11-11 11:07:44 +00:00
parent ea08a22955
commit 7b33bc39fd
25 changed files with 1845 additions and 58 deletions

View File

@ -63,6 +63,7 @@ SET(GOOD_TESTS
defining_hypotheses_ex14.py
defining_hypotheses_ex15.py
defining_hypotheses_ex16.py
defining_hypotheses_adaptive1d.py
filters_ex01.py
filters_ex03.py
filters_ex04.py

View File

@ -0,0 +1,30 @@
import salome, math
salome.salome_init()
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
box = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
tool = geompy.MakeTranslation( box, 50, 0, 10 )
axis = geompy.MakeVector( geompy.MakeVertex( 100, 0, 100 ),geompy.MakeVertex( 100, 10, 100 ),)
tool = geompy.Rotate( tool, axis, math.pi * 25 / 180. )
shape = geompy.MakeCut( box, tool )
cyl = geompy.MakeCylinder( geompy.MakeVertex( -10,5, 95 ), geompy.MakeVectorDXDYDZ(1,0,0), 2, 90)
shape = geompy.MakeCut( shape, cyl )
tool = geompy.MakeBoxTwoPnt( geompy.MakeVertex( -10, 2, 15 ), geompy.MakeVertex( 90, 5, 16 ))
shape = geompy.MakeCut( shape, tool, theName="shape" )
# Parameters of Adaptive hypothesis. minSize and maxSize are such that they do not limit
# size of segments because size of geometrical features lies within [2.-100.] range, hence
# size of segments is defined by deflection parameter and size of geometrical features only.
minSize = 0.1
maxSize = 200
deflection = 0.05
mesh = smesh.Mesh( shape )
mesh.Segment().Adaptive( minSize, maxSize, deflection )
mesh.Triangle( smeshBuilder.NETGEN_2D )
mesh.Compute()

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -4,6 +4,7 @@
<br>
<ul>
<li>\ref adaptive_1d_anchor "Adaptive"</li>
<li>\ref arithmetic_1d_anchor "Arithmetic 1D"</li>
<li>\ref average_length_anchor "Local Length"</li>
<li>\ref max_length_anchor "Max Size"</li>
@ -14,6 +15,28 @@
<li>\ref fixed_points_1d_anchor "Fixed points 1D"</li>
</ul>
<br>
\anchor adaptive_1d_anchor
<h2>Adaptive hypothesis</h2>
<b>Adaptive</b> hypothesis allows to split edges into segments with a
length that depends on curvature of edges and faces and is limited
from up and down. In addition length of a segment depends on lengths
of adjacent segments (that can't differ more than twice) and on
distance to close geometrical entities (edges and faces) to avoid
creation of narrow 2D elements.
\image html adaptive1d.png
<b>Min size</b> parameter limits minimal segment size. <b>Max size</b>
parameter defines length of segments on stright edges. \b Deflection
parameter gives maximal distance of a segment from a curved edge.
\image html adaptive1d_sample_mesh.png "A geometry and a mesh generated on this geometry using Adaptive hypothesis and Netgen 2D algorithm - the size of mesh segments reflects size of geometrical features"
<b>See Also</b> a \ref tui_1d_adaptive "sample TUI Script" that
creates the mesh of the above image.
<br>
\anchor arithmetic_1d_anchor
<h2>Arithmetic 1D hypothesis</h2>
@ -26,7 +49,7 @@ The direction of the splitting is defined by the orientation of the underlying g
<b>"Reverse Edges"</b> list box allows to specify the edges for which the splitting should be made
in the direction opposing to their orientation. This list box is enabled only if the geometry object
is selected for the meshing. In this case the user can select edges to be reversed either directly
picking them in the 3D viewer or by selecting the edges or groups of edges in the Object browser.
picking them in the 3D viewer or by selecting the edges or groups of edges in the Object Browser.
\image html a-arithmetic1d.png
@ -117,7 +140,7 @@ The direction of the splitting is defined by the orientation of the underlying g
<b>"Reverse Edges"</b> list box allows to specify the edges for which the splitting should be made
in the direction opposing to their orientation. This list box is enabled only if the geometry object
is selected for the meshing. In this case the user can select edges to be reversed either directly
picking them in the 3D viewer or by selecting the edges or groups of edges in the Object browser.
picking them in the 3D viewer or by selecting the edges or groups of edges in the Object Browser.
\image html image46.gif
@ -166,7 +189,7 @@ The direction of the splitting is defined by the orientation of the underlying g
<b>"Reverse Edges"</b> list box allows to specify the edges for which the splitting should be made
in the direction opposing to their orientation. This list box is enabled only if the geometry object
is selected for the meshing. In this case the user can select edges to be reversed either directly
picking them in the 3D viewer or by selecting the edges or groups of edges in the Object browser.
picking them in the 3D viewer or by selecting the edges or groups of edges in the Object Browser.
\image html a-startendlength.png
@ -215,7 +238,7 @@ direction opposite to their orientation. This list box is enabled only
if the geometrical object is selected for meshing. In this case it is
possible to select the edges to be reversed either directly picking them in
the 3D viewer or selecting the edges or groups of edges in the
Object browser.
Object Browser.
\image html mesh_fixedpnt.png "Example of a submesh on the edge built using Fixed points 1D hypothesis"

View File

@ -3,8 +3,8 @@
\page about_hypo_page About Hypotheses
\b Hypotheses represent boundary conditions which will be taken into
account at calculations of meshes or sub-meshes basing on geometrical
objects. These hypotheses allow you to manage the level of detail of
account at calculations of meshes or sub-meshes.
These hypotheses allow you to manage the level of detail of
the resulting meshes or sub-meshes: when applying different hypotheses
with different parameters you can preset the quantity or size of
elements which will compose your mesh. So, it will be possible to
@ -15,12 +15,13 @@ In \b MESH there are the following Basic Hypotheses:
<li>\subpage a1d_meshing_hypo_page "1D Hypotheses" (for meshing of
<b>edges</b>):</li>
<ul>
<li>\ref arithmetic_1d_anchor "Arithmetic 1D"</li>
<li>\ref number_of_segments_anchor "Number of segments"</li>
<li>\ref average_length_anchor "Local Length"</li>
<li>\ref max_length_anchor "Max Size"</li>
<li>\ref deflection_1d_anchor "Deflection 1D"</li>
<li>\ref number_of_segments_anchor "Number of segments"</li>
<li>\ref adaptive_1d_anchor "Adaptive"</li>
<li>\ref arithmetic_1d_anchor "Arithmetic 1D"</li>
<li>\ref start_and_end_length_anchor "Start and end length"</li>
<li>\ref deflection_1d_anchor "Deflection 1D"</li>
<li>\ref automatic_length_anchor "Automatic Length"</li>
</ul>
<li>\subpage a2d_meshing_hypo_page "2D Hypotheses" (for meshing of <b>faces</b>):</li>

View File

@ -7,6 +7,7 @@ This page provides example codes of \ref tui_defining_meshing_algos
<ul>
<li>Wire discretisation 1D algorithm
<ul>
<li>\ref tui_1d_adaptive "Adaptive 1D" hypothesis</li>
<li>\ref tui_1d_arithmetic "Arithmetic 1D" hypothesis</li>
<li>\ref tui_deflection_1d "Deflection 1D and Number of Segments" hypotheses</li>
<li>\ref tui_start_and_end_length "Start and End Length" hypotheses</li>
@ -46,6 +47,11 @@ This page provides example codes of \ref tui_defining_meshing_algos
<h3>Arithmetic 1D</h3>
\tui_script{defining_hypotheses_ex01.py}
<br>
\anchor tui_1d_adaptive
<h3>Adaptive</h3>
\tui_script{defining_hypotheses_adaptive1d.py}
<br>
\anchor tui_deflection_1d
<h3>Deflection 1D and Number of Segments</h3>

View File

@ -385,7 +385,6 @@ module StdMeshers
double GetDeflection();
};
/*!
* StdMeshers_FixedPoints1D: interface of "Fixed points 1D" hypothesis
*/
@ -433,6 +432,30 @@ module StdMeshers
string GetObjectEntry();
};
/*!
* StdMeshers_Adaptive1D: interface of "Adaptive" hypothesis
*/
interface StdMeshers_Adaptive1D : SMESH::SMESH_Hypothesis
{
/*!
* Sets minimal allowed segment length
*/
void SetMinSize(in double minSegLen) raises (SALOME::SALOME_Exception);
double GetMinSize();
/*!
* Sets maximal allowed segment length
*/
void SetMaxSize(in double maxSegLen) raises (SALOME::SALOME_Exception);
double GetMaxSize();
/*!
* Sets <deflection> parameter value,
* i.e. a maximal allowed distance between a segment and an edge.
*/
void SetDeflection(in double deflection) raises (SALOME::SALOME_Exception);
double GetDeflection();
};
/*!
* StdMeshers_MaxElementVolume: interface of "Max. Hexahedron or Tetrahedron Volume" hypothesis

View File

@ -75,6 +75,11 @@
icon-id ="mesh_hypo_length.png"
dim ="1"/>
<hypothesis type ="Adaptive1D"
label-id ="Adaptive"
icon-id ="mesh_hypo_length.png"
dim ="1"/>
<hypothesis type ="Propagation"
label-id ="Propagation of 1D Hyp. on Opposite Edges"
icon-id ="mesh_hypo_length.png"
@ -200,7 +205,7 @@
<algorithm type ="Regular_1D"
label-id ="Wire Discretisation"
icon-id ="mesh_algo_regular.png"
hypos ="LocalLength,MaxLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength,FixedPoints1D"
hypos ="Adaptive1D,LocalLength,MaxLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength,FixedPoints1D"
opt-hypos="Propagation,QuadraticMesh"
input ="VERTEX"
output ="EDGE"
@ -212,6 +217,7 @@
<hypo>Arithmetic1D=Arithmetic1D(SetStartLength(),SetEndLength(),SetReversedEdges())</hypo>
<hypo>StartEndLength=StartEndLength(SetStartLength(),SetEndLength(),SetReversedEdges())</hypo>
<hypo>Deflection1D=Deflection1D(SetDeflection())</hypo>
<hypo>Adaptive1D=Adaptive(SetMinSize(),SetMaxSize(),SetDeflection())</hypo>
<hypo>AutomaticLength=AutomaticLength(SetFineness())</hypo>
<hypo>FixedPoints1D=FixedPoints1D(SetPoints(),SetNbSegments(),SetReversedEdges())</hypo>
<hypo>Propagation=Propagation()</hypo>
@ -222,7 +228,7 @@
<algorithm type ="CompositeSegment_1D"
label-id ="Composite Side Discretisation"
icon-id ="mesh_algo_regular.png"
hypos ="LocalLength,MaxLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength,FixedPoints1D"
hypos ="Adaptive1D,LocalLength,MaxLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength,FixedPoints1D"
opt-hypos="Propagation,QuadraticMesh"
input ="VERTEX"
output ="EDGE"
@ -234,6 +240,7 @@
<hypo>Arithmetic1D=Arithmetic1D(SetStartLength(),SetEndLength(),SetReversedEdges())</hypo>
<hypo>StartEndLength=StartEndLength(SetStartLength(),SetEndLength(),SetReversedEdges())</hypo>
<hypo>Deflection1D=Deflection1D(SetDeflection())</hypo>
<hypo>Adaptive1D=Adaptive(SetMinSize(),SetMaxSize(),SetDeflection())</hypo>
<hypo>AutomaticLength=AutomaticLength(SetFineness())</hypo>
<hypo>FixedPoints1D=FixedPoints1D(SetPoints(),SetNbSegments(),SetReversedEdges())</hypo>
<hypo>Propagation=Propagation()</hypo>

View File

@ -876,7 +876,7 @@ SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const
{
StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
return false;
return NULL;
SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
return anHyp;

View File

@ -561,6 +561,8 @@ QString SMESHGUI_GenericHypothesisCreator::helpPage() const
aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
else if ( aHypType == "Deflection1D")
aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
else if ( aHypType == "Adaptive1D")
aHelpFileName = "a1d_meshing_hypo_page.html#adaptive_1d_anchor";
else if ( aHypType == "AutomaticLength")
aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
else if ( aHypType == "NumberOfSegments")

View File

@ -486,8 +486,8 @@ public:
// SIMAN-related functions (check out/check in) : import data to study
virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId,
Engines::DataContainer_ptr data,
const Engines::ListOfOptions& options);
Engines::DataContainer_ptr data,
const Engines::ListOfOptions& options);
// SIMAN-related functions (check out/check in) : get modified data
virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);

View File

@ -178,6 +178,28 @@ class StdMeshersBuilder_Segment(Mesh_Algorithm):
return True
return False
## Defines "Adaptive" hypothesis to cut an edge into segments keeping segment size
# within the given range and considering (1) deflection of segments from the edge
# and (2) distance from segments to closest edges and faces to have segment length
# not longer than two times shortest distances to edges and faces.
# @param minSize defines the minimal allowed segment length
# @param maxSize defines the maximal allowed segment length
# @param deflection defines the maximal allowed distance from a segment to an edge
# @param UseExisting if ==true - searches for an existing hypothesis created with
# the same parameters, else (default) - creates a new one
# @return an instance of StdMeshers_Adaptive1D hypothesis
# @ingroup l3_hypos_1dhyps
def Adaptive(self, minSize, maxSize, deflection, UseExisting=False):
compFun = lambda hyp, args: ( IsEqual(hyp.GetMinSize(), args[0]) and \
IsEqual(hyp.GetMaxSize(), args[1]) and \
IsEqual(hyp.GetDeflection(), args[2]))
hyp = self.Hypothesis("Adaptive1D", [minSize, maxSize, deflection],
UseExisting=UseExisting, CompareMethod=compFun)
hyp.SetMinSize(minSize)
hyp.SetMaxSize(maxSize)
hyp.SetDeflection(deflection)
return hyp
## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
# @param start defines the length of the first segment
# @param end defines the length of the last segment

View File

@ -186,6 +186,7 @@ SET(StdMeshers_SOURCES
StdMeshers_Projection_1D2D.cxx
StdMeshers_CartesianParameters3D.cxx
StdMeshers_Cartesian_3D.cxx
StdMeshers_Adaptive1D.cxx
)
IF(SALOME_SMESH_ENABLE_MEFISTO)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : StdMeshers_Adaptive1D.hxx
// Module : SMESH
//
#ifndef _StdMeshers_Adaptive1D_HXX_
#define _StdMeshers_Adaptive1D_HXX_
#include "SMESH_StdMeshers.hxx"
#include "StdMeshers_Regular_1D.hxx"
#include "Utils_SALOME_Exception.hxx"
class StdMeshers_AdaptiveAlgo_1D;
/*!
* \brief Adaptive 1D hypothesis
*/
class STDMESHERS_EXPORT StdMeshers_Adaptive1D : public SMESH_Hypothesis
{
public:
StdMeshers_Adaptive1D(int hypId, int studyId, SMESH_Gen * gen);
~StdMeshers_Adaptive1D();
/*!
* Sets minimal allowed segment length
*/
void SetMinSize( double minSegLen ) throw (SALOME_Exception);
double GetMinSize() const { return myMinSize; }
/*!
* Sets maximal allowed segment length
*/
void SetMaxSize( double maxSegLen ) throw (SALOME_Exception);
double GetMaxSize() const { return myMaxSize; }
/*!
* Sets <deflection> parameter value,
* i.e. a maximal allowed distance between a segment and an edge.
*/
void SetDeflection(double value) throw(SALOME_Exception);
double GetDeflection() const { return myDeflection; }
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
/*!
* \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);
/*!
* \brief Initialize my parameter values by default parameters.
* \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
/*!
* \brief Returns an algorithm that works using this hypothesis
*/
StdMeshers_AdaptiveAlgo_1D* GetAlgo() const;
protected:
double myMinSize, myMaxSize, myDeflection;
StdMeshers_AdaptiveAlgo_1D* myAlgo;
};
/*!
* \brief Adaptive wire discertizator.
* This algorithm is not used directly by via StdMeshers_Regular_1D
*/
class StdMeshers_AdaptiveAlgo_1D : public StdMeshers_Regular_1D
{
public:
StdMeshers_AdaptiveAlgo_1D(int hypId, int studyId, SMESH_Gen* gen);
void SetHypothesis( const StdMeshers_Adaptive1D* hyp );
bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
double* progress, int* progressTic );
virtual bool Evaluate(SMESH_Mesh & theMesh,
const TopoDS_Shape & theShape,
MapShapeNbElems& theResMap);
private:
const StdMeshers_Adaptive1D* myHyp;
};
#endif

View File

@ -26,11 +26,21 @@
// Module : SMESH
//
#include "StdMeshers_Regular_1D.hxx"
#include "StdMeshers_Distribution.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESH_Comment.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_HypoFilter.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx"
#include "StdMeshers_Adaptive1D.hxx"
#include "StdMeshers_Arithmetic1D.hxx"
#include "StdMeshers_AutomaticLength.hxx"
#include "StdMeshers_Deflection1D.hxx"
#include "StdMeshers_Distribution.hxx"
#include "StdMeshers_FixedPoints1D.hxx"
#include "StdMeshers_LocalLength.hxx"
#include "StdMeshers_MaxLength.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
@ -38,16 +48,6 @@
#include "StdMeshers_SegmentLengthAroundVertex.hxx"
#include "StdMeshers_StartEndLength.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_HypoFilter.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx"
#include "SMESH_Comment.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "utilities.h"
@ -75,24 +75,26 @@ using namespace std;
//=============================================================================
StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen)
SMESH_Gen * gen)
:SMESH_1D_Algo(hypId, studyId, gen)
{
MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D");
_name = "Regular_1D";
_shapeType = (1 << TopAbs_EDGE);
_fpHyp = 0;
MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D");
_name = "Regular_1D";
_shapeType = (1 << TopAbs_EDGE);
_fpHyp = 0;
_compatibleHypothesis.push_back("LocalLength");
_compatibleHypothesis.push_back("MaxLength");
_compatibleHypothesis.push_back("NumberOfSegments");
_compatibleHypothesis.push_back("StartEndLength");
_compatibleHypothesis.push_back("Deflection1D");
_compatibleHypothesis.push_back("Arithmetic1D");
_compatibleHypothesis.push_back("FixedPoints1D");
_compatibleHypothesis.push_back("AutomaticLength");
_compatibleHypothesis.push_back("LocalLength");
_compatibleHypothesis.push_back("MaxLength");
_compatibleHypothesis.push_back("NumberOfSegments");
_compatibleHypothesis.push_back("StartEndLength");
_compatibleHypothesis.push_back("Deflection1D");
_compatibleHypothesis.push_back("Arithmetic1D");
_compatibleHypothesis.push_back("FixedPoints1D");
_compatibleHypothesis.push_back("AutomaticLength");
_compatibleHypothesis.push_back("Adaptive1D");
_compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!!
_compatibleHypothesis.push_back("Propagation"); // auxiliary !!!
_compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!!
_compatibleHypothesis.push_back("Propagation"); // auxiliary !!!
}
//=============================================================================
@ -111,13 +113,13 @@ StdMeshers_Regular_1D::~StdMeshers_Regular_1D()
*/
//=============================================================================
bool StdMeshers_Regular_1D::CheckHypothesis
(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus)
bool StdMeshers_Regular_1D::CheckHypothesis( SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
Hypothesis_Status& aStatus )
{
_hypType = NONE;
_quadraticMesh = false;
_onlyUnaryInput = true;
const list <const SMESHDS_Hypothesis * > & hyps =
GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false);
@ -263,12 +265,17 @@ bool StdMeshers_Regular_1D::CheckHypothesis
(dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
ASSERT(hyp);
_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
// _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
// _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero?
ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
_hypType = MAX_LENGTH;
aStatus = SMESH_Hypothesis::HYP_OK;
}
else if (hypName == "Adaptive1D")
{
_adaptiveHyp = dynamic_cast < const StdMeshers_Adaptive1D* >(theHyp);
ASSERT(_adaptiveHyp);
_hypType = ADAPTIVE;
_onlyUnaryInput = false;
}
else
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
@ -950,6 +957,13 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
if ( _hypType == NONE )
return false;
if ( _hypType == ADAPTIVE )
{
_adaptiveHyp->GetAlgo()->InitComputeError();
_adaptiveHyp->GetAlgo()->Compute( theMesh, theShape, &_progress, &_progressTic );
return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
}
SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
const TopoDS_Edge & EE = TopoDS::Edge(theShape);
@ -1128,11 +1142,15 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
if ( _hypType == NONE )
return false;
//SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
if ( _hypType == ADAPTIVE )
{
_adaptiveHyp->GetAlgo()->InitComputeError();
_adaptiveHyp->GetAlgo()->Evaluate( theMesh, theShape, aResMap );
return error( _adaptiveHyp->GetAlgo()->GetComputeError() );
}
const TopoDS_Edge & EE = TopoDS::Edge(theShape);
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
// int shapeID = meshDS->ShapeToIndex( E );
double f, l;
Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
@ -1237,3 +1255,16 @@ StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh,
return _usedHypList;
}
//================================================================================
/*!
* \brief Pass CancelCompute() to a child algorithm
*/
//================================================================================
void StdMeshers_Regular_1D::CancelCompute()
{
SMESH_Algo::CancelCompute();
if ( _hypType == ADAPTIVE )
_adaptiveHyp->GetAlgo()->CancelCompute();
}

View File

@ -33,11 +33,12 @@
#include "SMESH_Algo.hxx"
#include "StdMeshers_FixedPoints1D.hxx"
class Adaptor3d_Curve;
class TopoDS_Vertex;
class StdMeshers_Adaptive1D;
class StdMeshers_AdaptiveAlgo_1D;
class StdMeshers_FixedPoints1D;
class StdMeshers_SegmentLengthAroundVertex;
class TopoDS_Vertex;
class STDMESHERS_EXPORT StdMeshers_Regular_1D: public SMESH_1D_Algo
{
@ -55,6 +56,8 @@ public:
virtual bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
MapShapeNbElems& aResMap);
virtual void CancelCompute();
virtual const std::list <const SMESHDS_Hypothesis *> &
GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, const bool=true);
@ -100,7 +103,7 @@ protected:
StdMeshers_SegmentLengthAroundVertex* getVertexHyp(SMESH_Mesh & theMesh,
const TopoDS_Vertex & theV);
enum HypothesisType { LOCAL_LENGTH, MAX_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, FIXED_POINTS_1D, NONE };
enum HypothesisType { LOCAL_LENGTH, MAX_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, FIXED_POINTS_1D, ADAPTIVE, NONE };
enum ValueIndex {
SCALE_FACTOR_IND = 0,
@ -111,9 +114,9 @@ protected:
};
enum IValueIndex {
NB_SEGMENTS_IND = 0,
DISTR_TYPE_IND = 1,
CONV_MODE_IND = 2
NB_SEGMENTS_IND = 0,
DISTR_TYPE_IND = 1,
CONV_MODE_IND = 2
};
enum VValueIndex {
@ -127,6 +130,8 @@ protected:
HypothesisType _hypType;
const StdMeshers_FixedPoints1D* _fpHyp;
const StdMeshers_Adaptive1D* _adaptiveHyp;
StdMeshers_AdaptiveAlgo_1D* getAdaptiveAlgo();
double _value[2];
int _ivalue[3];

View File

@ -582,6 +582,17 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
h->SetVarParameter( params[0].text(), "SetDeflection" );
h->SetDeflection( params[0].myValue.toDouble() );
}
else if( hypType()=="Adaptive1D" )
{
StdMeshers::StdMeshers_Adaptive1D_var h =
StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
h->SetVarParameter( params[0].text(), "SetMinSize" );
h->SetMinSize( params[0].myValue.toDouble() );
h->SetVarParameter( params[0].text(), "SetMaxSize" );
h->SetMaxSize( params[1].myValue.toDouble() );
h->SetVarParameter( params[0].text(), "SetDeflection" );
h->SetDeflection( params[2].myValue.toDouble() );
}
else if( hypType()=="AutomaticLength" )
{
StdMeshers::StdMeshers_AutomaticLength_var h =
@ -966,6 +977,26 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
item.myValue = h->GetDeflection();
p.append( item );
}
else if( hypType()=="Adaptive1D" )
{
StdMeshers::StdMeshers_Adaptive1D_var h =
StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
item.myName = tr( "SMESH_MIN_SIZE" );
if(!initVariableName( hyp, item, "SetMinSize" ))
item.myValue = h->GetMinSize();
p.append( item );
item.myName = tr( "SMESH_MAX_SIZE" );
if(!initVariableName( hyp, item, "SetMaxSize" ))
item.myValue = h->GetMaxSize();
p.append( item );
item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
if(!initVariableName( hyp, item, "SetDeflection" ))
item.myValue = h->GetDeflection();
p.append( item );
}
else if( hypType()=="AutomaticLength" )
{
StdMeshers::StdMeshers_AutomaticLength_var h =
@ -1315,6 +1346,10 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int)
{
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
}
else if( hypType()=="Adaptive1D" )
{
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
}
else if( hypType().startsWith( "ViscousLayers" ))
{
if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
@ -1386,6 +1421,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons
types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
types.insert( "StartEndLength", "START_END_LENGTH" );
types.insert( "Deflection1D", "DEFLECTION1D" );
types.insert( "Adaptive1D", "ADAPTIVE1D" );
types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );

View File

@ -19,6 +19,10 @@
<source>ICON_DLG_DEFLECTION1D</source>
<translation>mesh_hypo_length.png</translation>
</message>
<message>
<source>ICON_DLG_ADAPTIVE1D</source>
<translation>mesh_hypo_length.png</translation>
</message>
<message>
<source>ICON_DLG_GEOMETRIC_1D</source>
<translation>mesh_hypo_length.png</translation>
@ -167,6 +171,10 @@
<source>ICON_SMESH_TREE_HYPO_Deflection1D</source>
<translation>mesh_tree_hypo_length.png</translation>
</message>
<message>
<source>ICON_SMESH_TREE_HYPO_Adaptive1D</source>
<translation>mesh_tree_hypo_length.png</translation>
</message>
<message>
<source>ICON_SMESH_TREE_HYPO_LayerDistribution</source>
<translation>mesh_tree_hypo_layers_distribution.png</translation>

View File

@ -46,6 +46,22 @@
<source>SMESH_CUT_NEG_MODE</source>
<translation>Cut negative</translation>
</message>
<message>
<source>SMESH_ADAPTIVE1D_HYPOTHESIS</source>
<translation>Adaptive</translation>
</message>
<message>
<source>SMESH_MIN_SIZE</source>
<translation>Min size</translation>
</message>
<message>
<source>SMESH_MAX_SIZE</source>
<translation>Max size</translation>
</message>
<message>
<source>SMESH_ADAPTIVE1D_TITLE</source>
<translation>Hypothesis Construction</translation>
</message>
<message>
<source>SMESH_DEFLECTION1D_HYPOTHESIS</source>
<translation>Deflection 1D</translation>

View File

@ -170,6 +170,7 @@ SET(StdMeshersEngine_SOURCES
StdMeshers_ViscousLayers2D_i.cxx
StdMeshers_CartesianParameters3D_i.cxx
StdMeshers_Cartesian_3D_i.cxx
StdMeshers_Adaptive1D_i.cxx
)
IF(SALOME_SMESH_ENABLE_MEFISTO)

View File

@ -0,0 +1,173 @@
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : StdMeshers_Adaptive1D_i.cxx
// Module : SMESH
//
#include "StdMeshers_Adaptive1D_i.hxx"
#include "SMESH_Gen_i.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_PythonDump.hxx"
#include "StdMeshers_Adaptive1D.hxx"
#include "Utils_CorbaException.hxx"
#include "utilities.h"
//=======================================================================
//function : StdMeshers_Adaptive1D_i
//purpose : Constructor
//=======================================================================
StdMeshers_Adaptive1D_i::StdMeshers_Adaptive1D_i( PortableServer::POA_ptr thePOA,
int theStudyId,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA )
{
myBaseImpl = new ::StdMeshers_Adaptive1D( theGenImpl->GetANewId(),
theStudyId,
theGenImpl );
}
//=======================================================================
//function : ~StdMeshers_Adaptive1D_i
//purpose : Destructor
//=======================================================================
StdMeshers_Adaptive1D_i::~StdMeshers_Adaptive1D_i()
{
MESSAGE( "StdMeshers_Adaptive1D_i::~StdMeshers_Adaptive1D_i" );
}
//=======================================================================
//function : SetMinSize
//purpose : Sets minimal allowed segment length
//=======================================================================
void StdMeshers_Adaptive1D_i::SetMinSize( CORBA::Double minSegLen )
throw (SALOME::SALOME_Exception)
{
ASSERT( myBaseImpl );
try {
this->GetImpl()->SetMinSize( minSegLen );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetMinSize( " << SMESH::TVar(minSegLen) << " )";
}
//=======================================================================
//function : GetMinSize
//purpose : Returns minimal allowed segment length
//=======================================================================
CORBA::Double StdMeshers_Adaptive1D_i::GetMinSize()
{
ASSERT( myBaseImpl );
return this->GetImpl()->GetMinSize();
}
//=======================================================================
//function : SetMaxSize
//purpose : Sets maximal allowed segment length
//=======================================================================
void StdMeshers_Adaptive1D_i::SetMaxSize( CORBA::Double maxSegLen )
throw (SALOME::SALOME_Exception)
{
ASSERT( myBaseImpl );
try {
this->GetImpl()->SetMaxSize( maxSegLen );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetMaxSize( " << SMESH::TVar(maxSegLen) << " )";
}
//=======================================================================
//function : GetMaxSize
//purpose : Returns maximal allowed segment length
//=======================================================================
CORBA::Double StdMeshers_Adaptive1D_i::GetMaxSize()
{
ASSERT( myBaseImpl );
return this->GetImpl()->GetMaxSize();
}
//=======================================================================
//function : SetDeflection
//purpose : Sets a maximal allowed distance between a segment and an edge.
//=======================================================================
void StdMeshers_Adaptive1D_i::SetDeflection( CORBA::Double theValue )
throw ( SALOME::SALOME_Exception )
{
ASSERT( myBaseImpl );
try {
this->GetImpl()->SetDeflection( theValue );
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
}
// Update Python script
SMESH::TPythonDump() << _this() << ".SetDeflection( " << SMESH::TVar(theValue) << " )";
}
//=======================================================================
//function : GetDeflection
//purpose : Returns deflection
//=======================================================================
CORBA::Double StdMeshers_Adaptive1D_i::GetDeflection()
{
ASSERT( myBaseImpl );
return this->GetImpl()->GetDeflection();
}
//=======================================================================
//function : GetImpl
//purpose : Get implementation
//=======================================================================
::StdMeshers_Adaptive1D* StdMeshers_Adaptive1D_i::GetImpl()
{
return ( ::StdMeshers_Adaptive1D* )myBaseImpl;
}
//=======================================================================
//function : IsDimSupported
//purpose : Verify whether hypothesis supports given entity type
//=======================================================================
CORBA::Boolean StdMeshers_Adaptive1D_i::IsDimSupported( SMESH::Dimension type )
{
return type == SMESH::DIM_1D;
}

View File

@ -0,0 +1,89 @@
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : StdMeshers_Adaptive1D_i.hxx
// Module : SMESH
//
#ifndef _SMESH_Adaptive1D_I_HXX_
#define _SMESH_Adaptive1D_I_HXX_
#include "SMESH_StdMeshers_I.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include "SMESH_Hypothesis_i.hxx"
class StdMeshers_Adaptive1D;
class SMESH_Gen;
// ======================================================
// Adaptive1D hypothesis
// ======================================================
class STDMESHERS_I_EXPORT StdMeshers_Adaptive1D_i:
public virtual POA_StdMeshers::StdMeshers_Adaptive1D,
public virtual SMESH_Hypothesis_i
{
public:
// Constructor
StdMeshers_Adaptive1D_i( PortableServer::POA_ptr thePOA,
int theStudyId,
::SMESH_Gen* theGenImpl );
// Destructor
virtual ~StdMeshers_Adaptive1D_i();
/*!
* Sets minimal allowed segment length
*/
void SetMinSize( CORBA::Double minSegLen ) throw (SALOME::SALOME_Exception);
CORBA::Double GetMinSize();
/*!
* Sets maximal allowed segment length
*/
void SetMaxSize( CORBA::Double maxSegLen ) throw (SALOME::SALOME_Exception);
CORBA::Double GetMaxSize();
/*!
* Sets <deflection> parameter value,
* i.e. a maximal allowed distance between a segment and an edge.
*/
void SetDeflection( CORBA::Double theLength ) throw (SALOME::SALOME_Exception);
CORBA::Double GetDeflection();
/*!
* Returns implementation
*/
::StdMeshers_Adaptive1D* GetImpl();
/*!
* \brief Verify whether hypothesis supports given entity type
* \param type - dimension (see SMESH::Dimension enumeration)
* \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
*
* Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
*/
CORBA::Boolean IsDimSupported( SMESH::Dimension type );
};
#endif

View File

@ -38,6 +38,7 @@
#include "StdMeshers_FixedPoints1D_i.hxx"
#include "StdMeshers_NumberOfSegments_i.hxx"
#include "StdMeshers_Deflection1D_i.hxx"
#include "StdMeshers_Adaptive1D_i.hxx"
#include "StdMeshers_Propagation_i.hxx"
#include "StdMeshers_LengthFromEdges_i.hxx"
#include "StdMeshers_QuadranglePreference_i.hxx"
@ -143,6 +144,8 @@ STDMESHERS_I_EXPORT
aCreator = new StdHypothesisCreator_i<StdMeshers_StartEndLength_i>;
else if (strcmp(aHypName, "Deflection1D") == 0)
aCreator = new StdHypothesisCreator_i<StdMeshers_Deflection1D_i>;
else if (strcmp(aHypName, "Adaptive1D") == 0)
aCreator = new StdHypothesisCreator_i<StdMeshers_Adaptive1D_i>;
else if (strcmp(aHypName, "FixedPoints1D") == 0)
aCreator = new StdHypothesisCreator_i<StdMeshers_FixedPoints1D_i>;
else if (strcmp(aHypName, "Arithmetic1D") == 0)