From 236b583d315b14278bda28e118748016d0e4f709 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 23 Dec 2005 10:00:03 +0000 Subject: [PATCH] PAL10467. Add "Quadrangle Preference" hypothesis for "Quadrangle(Mapping)" algo --- idl/SMESH_BasicHypothesis.idl | 12 +++ resources/StdMeshers.xml | 5 + src/SMESH_I/SMESH_2smeshpy.cxx | 5 + src/SMESH_I/SMESH_2smeshpy.hxx | 17 ++- src/SMESH_SWIG/smesh.py | 9 ++ src/StdMeshers/Makefile.in | 6 +- .../StdMeshers_QuadranglePreference.cxx | 100 ++++++++++++++++++ .../StdMeshers_QuadranglePreference.hxx | 52 +++++++++ src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 9 +- src/StdMeshers/StdMeshers_Quadrangle_2D.hxx | 5 + src/StdMeshersGUI/StdMeshers_images.po | 6 +- src/StdMeshers_I/Makefile.in | 6 +- .../StdMeshers_QuadranglePreference_i.cxx | 98 +++++++++++++++++ .../StdMeshers_QuadranglePreference_i.hxx | 64 +++++++++++ src/StdMeshers_I/StdMeshers_i.cxx | 3 + 15 files changed, 388 insertions(+), 9 deletions(-) create mode 100644 src/StdMeshers/StdMeshers_QuadranglePreference.cxx create mode 100644 src/StdMeshers/StdMeshers_QuadranglePreference.hxx create mode 100644 src/StdMeshers_I/StdMeshers_QuadranglePreference_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index 65124b02c..2405cd4b2 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -258,6 +258,18 @@ module StdMeshers { }; + /*! + * StdMeshers_QuadranglePreference: interface of "QuadranglePreference" hypothesis. + * This hypothesis is used by StdMeshers_Quadrangle_2D algorithm. + * Presence of this hypothesis forces construction of quadrangles if the number + * of nodes on opposite edges is not the same in the case where the global number + * of nodes on edges is even + */ + interface StdMeshers_QuadranglePreference : SMESH::SMESH_Hypothesis + { + }; + + /*! * StdMeshers_Regular_1D: interface of "Wire discretisation" algorithm */ diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml index 92d94b8f3..2c1cd12cc 100644 --- a/resources/StdMeshers.xml +++ b/resources/StdMeshers.xml @@ -52,6 +52,11 @@ icon-id="mesh_hypo_length.png" dim="2"/> + + myDim = 2; algo->myCreationMethod = "Quadrangle"; } + else if ( hypType == "QuadranglePreference" ) { + hyp->myDim = 2; + hyp->myCreationMethod = "QuadranglePreference"; + hyp->myType = "MEFISTO_2D"; + } // 3D ---------- else if ( hypType == "NETGEN_3D") { algo->myDim = 3; diff --git a/src/SMESH_I/SMESH_2smeshpy.hxx b/src/SMESH_I/SMESH_2smeshpy.hxx index 71500c7b5..ac92276c3 100644 --- a/src/SMESH_I/SMESH_2smeshpy.hxx +++ b/src/SMESH_I/SMESH_2smeshpy.hxx @@ -27,6 +27,8 @@ * * The only API method here is SMESH_2smeshpy::ConvertScript(), the rest ones are * for internal usage + * + * See comments to _pyHypothesis class to know how to assure convertion of a new hypothesis */ class Resource_DataMapOfAsciiStringAsciiString; @@ -187,7 +189,20 @@ private: }; /*! - * \brief Root class for smesh.Mesh_Algorithm + * \brief Root class for hypothesis + * + * HOWTO assure convertion of a new hypothesis + * In NewHypothesis(): + * 1. add a case for the name of the new hypothesis and + * 2. initialize _pyHypothesis fields: + * . myDim - hypothesis dimention; + * . myType - type name of the algorithm creating the hypothesis; + * . myCreationMethod - method name of the algorithm creating the hypothesis; + * . append to myArgMethods interface methods setting param values in the + * order they are used when myCreationMethod is called. It is supposed that + * each interface method sets only one parameter, if it is not so, you are + * to derive a specific class from _pyHypothesis that would redefine Process(), + * see _pyComplexParamHypo for example */ class _pyHypothesis: public _pyObject { diff --git a/src/SMESH_SWIG/smesh.py b/src/SMESH_SWIG/smesh.py index 92fefeda2..776ee83c7 100644 --- a/src/SMESH_SWIG/smesh.py +++ b/src/SMESH_SWIG/smesh.py @@ -281,6 +281,15 @@ class Mesh_Quadrangle(Mesh_Algorithm): """ self.Create(mesh, geom, "Quadrangle_2D") + def QuadranglePreference(self): + """ + Define "QuadranglePreference" hypothesis, forcing construction + of quadrangles if the number of nodes on opposite edges is not the same + in the case where the global number of nodes on edges is even + """ + hyp = self.Hypothesis("QuadranglePreference") + return hyp + # Public class: Mesh_Tetrahedron # ------------------------------ diff --git a/src/StdMeshers/Makefile.in b/src/StdMeshers/Makefile.in index 9b2f65b61..d44d4cc68 100644 --- a/src/StdMeshers/Makefile.in +++ b/src/StdMeshers/Makefile.in @@ -49,7 +49,8 @@ EXPORT_HEADERS = \ StdMeshers_Quadrangle_2D.hxx \ StdMeshers_MEFISTO_2D.hxx \ StdMeshers_Hexa_3D.hxx \ - StdMeshers_AutomaticLength.hxx + StdMeshers_AutomaticLength.hxx \ + StdMeshers_QuadranglePreference.hxx EXPORT_PYSCRIPTS = @@ -73,7 +74,8 @@ LIB_SRC = \ StdMeshers_MEFISTO_2D.cxx \ StdMeshers_Penta_3D.cxx \ StdMeshers_Hexa_3D.cxx \ - StdMeshers_AutomaticLength.cxx + StdMeshers_AutomaticLength.cxx \ + StdMeshers_QuadranglePreference.cxx LIB_SERVER_IDL = diff --git a/src/StdMeshers/StdMeshers_QuadranglePreference.cxx b/src/StdMeshers/StdMeshers_QuadranglePreference.cxx new file mode 100644 index 000000000..4ba3dd8ed --- /dev/null +++ b/src/StdMeshers/StdMeshers_QuadranglePreference.cxx @@ -0,0 +1,100 @@ +// SMESH StdMeshers_QuadranglePreference : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_QuadranglePreference.cxx +// Module : SMESH +// $Header$ + +#include "StdMeshers_QuadranglePreference.hxx" +#include "utilities.h" + +using namespace std; + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_QuadranglePreference::StdMeshers_QuadranglePreference(int hypId, + int studyId, + SMESH_Gen * gen) + :SMESH_Hypothesis(hypId, studyId, gen) +{ + _name = "QuadranglePreference"; + _param_algo_dim = 2; // is used by StdMeshers_Quadrangle_2D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_QuadranglePreference::~StdMeshers_QuadranglePreference() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_QuadranglePreference::SaveTo(ostream & save) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_QuadranglePreference::LoadFrom(istream & load) +{ + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_QuadranglePreference & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_QuadranglePreference & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_QuadranglePreference.hxx b/src/StdMeshers/StdMeshers_QuadranglePreference.hxx new file mode 100644 index 000000000..eb2fdca04 --- /dev/null +++ b/src/StdMeshers/StdMeshers_QuadranglePreference.hxx @@ -0,0 +1,52 @@ +// SMESH StdMeshers : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_QuadranglePreference.hxx +// Module : SMESH +// $Header$ + +#ifndef _StdMeshers_QuadranglePreference_HXX_ +#define _StdMeshers_QuadranglePreference_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +/*! + * \brief Hypothesis for StdMeshers_Quadrangle_2D, forcing construction + * of quadrangles if the number of nodes on opposite edges is not the same. + * GIBI can do it if the global number of nodes is even (DALL operator). + * See PAL10467 + */ +class StdMeshers_QuadranglePreference:public SMESH_Hypothesis +{ + public: + StdMeshers_QuadranglePreference(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_QuadranglePreference(); + + virtual std::ostream & SaveTo(std::ostream & save); + 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); +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index d8131681d..e40390c6e 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -68,6 +68,7 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMES MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); _name = "Quadrangle_2D"; _shapeType = (1 << TopAbs_FACE); + _compatibleHypothesis.push_back("QuadranglePreference"); } //============================================================================= @@ -88,14 +89,16 @@ StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D() //============================================================================= bool StdMeshers_Quadrangle_2D::CheckHypothesis - (SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus) { bool isOk = true; aStatus = SMESH_Hypothesis::HYP_OK; - // nothing to check + // there is only one compatible Hypothesis so far + const list &hyps = GetUsedHypothesis(aMesh, aShape); + myQuadranglePreference = hyps.size() > 0; return isOk; } diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx index b54edea3f..4d02719b0 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx @@ -99,6 +99,11 @@ protected: UVPtStruct* MakeEdgePoints(SMESH_Mesh& aMesh, const TopoDS_Face& F, const TopoDS_Edge& E, double first, double last, int nb_segm); + + // true if QuadranglePreference hypothesis is assigned that forces + // construction of quadrangles if the number of nodes on opposite edges + // is not the same in the case where the global number of nodes on edges is even + bool myQuadranglePreference; }; #endif diff --git a/src/StdMeshersGUI/StdMeshers_images.po b/src/StdMeshersGUI/StdMeshers_images.po index 78c8bec86..afa51dab5 100644 --- a/src/StdMeshersGUI/StdMeshers_images.po +++ b/src/StdMeshersGUI/StdMeshers_images.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" -"PO-Revision-Date: 2005-11-01 12:58+0300\n" +"PO-Revision-Date: 2005-12-23 11:15+0300\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -80,6 +80,10 @@ msgstr "mesh_tree_algo_quad.png" msgid "ICON_SMESH_TREE_HYPO_MaxElementArea" msgstr "mesh_tree_hypo_area.png" +#mesh_tree_hypo_area +msgid "ICON_SMESH_TREE_HYPO_QuadranglePreference" +msgstr "mesh_tree_algo_quad.png" + #mesh_tree_hypo_length msgid "ICON_SMESH_TREE_HYPO_LocalLength" msgstr "mesh_tree_hypo_length.png" diff --git a/src/StdMeshers_I/Makefile.in b/src/StdMeshers_I/Makefile.in index 3f24a08a4..cb445cb85 100644 --- a/src/StdMeshers_I/Makefile.in +++ b/src/StdMeshers_I/Makefile.in @@ -51,7 +51,8 @@ EXPORT_HEADERS = \ StdMeshers_Quadrangle_2D_i.hxx \ StdMeshers_MEFISTO_2D_i.hxx \ StdMeshers_Hexa_3D_i.hxx \ - StdMeshers_AutomaticLength_i.hxx + StdMeshers_AutomaticLength_i.hxx \ + StdMeshers_QuadranglePreference_i.hxx # Libraries targets @@ -73,7 +74,8 @@ LIB_SRC = \ StdMeshers_Quadrangle_2D_i.cxx \ StdMeshers_MEFISTO_2D_i.cxx \ StdMeshers_Hexa_3D_i.cxx \ - StdMeshers_AutomaticLength_i.cxx + StdMeshers_AutomaticLength_i.cxx \ + StdMeshers_QuadranglePreference_i.cxx LIB_SERVER_IDL = SMESH_BasicHypothesis.idl diff --git a/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.cxx b/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.cxx new file mode 100644 index 000000000..a32ded986 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.cxx @@ -0,0 +1,98 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_QuadranglePreference_i.cxx +// Moved here from SMESH_LocalLength_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_QuadranglePreference_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +//============================================================================= +/*! + * StdMeshers_QuadranglePreference_i::StdMeshers_QuadranglePreference_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_QuadranglePreference_i::StdMeshers_QuadranglePreference_i +( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ): SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + myBaseImpl = new ::StdMeshers_QuadranglePreference( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_QuadranglePreference_i::~StdMeshers_QuadranglePreference_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_QuadranglePreference_i::~StdMeshers_QuadranglePreference_i() +{ +} + +//============================================================================= +/*! + * StdMeshers_QuadranglePreference_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_QuadranglePreference* StdMeshers_QuadranglePreference_i::GetImpl() +{ + return ( ::StdMeshers_QuadranglePreference* )myBaseImpl; +} + +//================================================================================ +/*! + * \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 StdMeshers_QuadranglePreference_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_2D; +} + diff --git a/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx b/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx new file mode 100644 index 000000000..cfa7968e1 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx @@ -0,0 +1,64 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_QuadranglePreference_i.hxx +// Moved here from SMESH_LocalLength_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_QuadranglePreference_I_HXX_ +#define _SMESH_QuadranglePreference_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_QuadranglePreference.hxx" + +class SMESH_Gen; + +// ====================================================== +// Local Length hypothesis +// ====================================================== +class StdMeshers_QuadranglePreference_i: + public virtual POA_StdMeshers::StdMeshers_QuadranglePreference, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_QuadranglePreference_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_QuadranglePreference_i(); + + // Get implementation + ::StdMeshers_QuadranglePreference* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_i.cxx b/src/StdMeshers_I/StdMeshers_i.cxx index e21d44d3d..768d2c4fb 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -38,6 +38,7 @@ using namespace std; #include "StdMeshers_Deflection1D_i.hxx" #include "StdMeshers_Propagation_i.hxx" #include "StdMeshers_LengthFromEdges_i.hxx" +#include "StdMeshers_QuadranglePreference_i.hxx" #include "StdMeshers_MaxElementArea_i.hxx" #include "StdMeshers_MaxElementVolume_i.hxx" #include "StdMeshers_NotConformAllowed_i.hxx" @@ -84,6 +85,8 @@ extern "C" aCreator = new HypothesisCreator_i; else if (strcmp(aHypName, "AutomaticLength") == 0) aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "QuadranglePreference") == 0) + aCreator = new HypothesisCreator_i; // Algorithms else if (strcmp(aHypName, "Regular_1D") == 0)