From: skl Date: Wed, 22 Jul 2009 09:13:29 +0000 (+0000) Subject: Implementation of Quadrangle (Mapping) for faces built on 3 edges (0018911 from Mantis). X-Git-Tag: V5_1_3rc1~135 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=55510e5ccd337f72bb1caa755b131cf0916d91b3 Implementation of Quadrangle (Mapping) for faces built on 3 edges (0018911 from Mantis). --- diff --git a/doc/salome/gui/SMESH/images/hypo_quad_params_1.png b/doc/salome/gui/SMESH/images/hypo_quad_params_1.png new file mode 100755 index 000000000..de1d7df0a Binary files /dev/null and b/doc/salome/gui/SMESH/images/hypo_quad_params_1.png differ diff --git a/doc/salome/gui/SMESH/images/hypo_quad_params_res.png b/doc/salome/gui/SMESH/images/hypo_quad_params_res.png new file mode 100644 index 000000000..aed006ca3 Binary files /dev/null and b/doc/salome/gui/SMESH/images/hypo_quad_params_res.png differ diff --git a/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc b/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc index 6d89e53d5..31538fc42 100644 --- a/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc +++ b/doc/salome/gui/SMESH/input/2d_meshing_hypo.doc @@ -6,6 +6,7 @@ @@ -38,6 +39,21 @@ length calculated as an average edge length for a given wire. See Also a sample TUI Script of a \ref tui_length_from_edges "Length from Edges" hypothesis operation. +
+\anchor hypo_quad_params_anchor +

Quadrangle parameters

+ +Quadrangle parameters is a general hypothesis for +Quadrangle (Mapping). This hypothesis gives a possibility +of using Quadrangle (Mapping) mechanism for faces built on 3 edges. +The hypothesis requires some vertex to be selected from the face; this vertex will be +used as degenerated edge. The resulting mesh will include several triangles near this +vertex. Hypothesis construction and resulting mesh is displayed at the following figures: + +\image html hypo_quad_params_1.png + +\image html hypo_quad_params_res.png +
\anchor quadrangle_preference_anchor

Quadrangle Preference

diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index e8b0824a4..37db80292 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -681,6 +681,32 @@ module StdMeshers double GetLength(); }; + /*! + * StdMeshers_QuadrangleParams: interface of "Quadrangle Params" hypothesis + */ + interface StdMeshers_QuadrangleParams : SMESH::SMESH_Hypothesis + { + /*! + * Set base vertex for triangles + */ + void SetTriaVertex( in long vertID ); + + /*! + * Returns base vertex for triangles + */ + long GetTriaVertex(); + + /*! + * Set entry of the main object + */ + void SetObjectEntry( in string entry ); + + /*! + * Get the entry of the main object + */ + string GetObjectEntry(); + }; + /*! * StdMeshers_SegmentAroundVertex_0D: interface of "SegmentAroundVertex" algorithm */ diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 356457cd2..eb138d2ed 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -727,6 +727,10 @@ SMDS_MeshFace* SMESH_MesherHelper::AddFace(const SMDS_MeshNode* n1, { SMESHDS_Mesh * meshDS = GetMeshDS(); SMDS_MeshFace* elem = 0; + + if( n1==n2 || n2==n3 || n3==n1 ) + return elem; + if(!myCreateQuadratic) { if(id) elem = meshDS->AddFaceWithID(n1, n2, n3, id); @@ -764,6 +768,26 @@ SMDS_MeshFace* SMESH_MesherHelper::AddFace(const SMDS_MeshNode* n1, { SMESHDS_Mesh * meshDS = GetMeshDS(); SMDS_MeshFace* elem = 0; + + if( n1==n2 ) { + return AddFace(n1,n3,n4,id,force3d); + } + if( n1==n3 ) { + return AddFace(n1,n2,n4,id,force3d); + } + if( n1==n4 ) { + return AddFace(n1,n2,n3,id,force3d); + } + if( n2==n3 ) { + return AddFace(n1,n2,n4,id,force3d); + } + if( n2==n4 ) { + return AddFace(n1,n2,n3,id,force3d); + } + if( n3==n4 ) { + return AddFace(n1,n2,n3,id,force3d); + } + if(!myCreateQuadratic) { if(id) elem = meshDS->AddFaceWithID(n1, n2, n3, n4, id); diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 4561074f7..7cbec92d7 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -2077,6 +2077,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 1100: // EDIT HYPOTHESIS { + cout<<"EDIT HYPOTHESIS"<GetMeshDS(); @@ -155,6 +156,34 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, //dump(); } +//================================================================================ +/*! + * \brief Constructor of a side for vertex using data from other FaceSide + * \param theVertex - the vertex + * \param theSide - the side + */ +//================================================================================ + +StdMeshers_FaceSide::StdMeshers_FaceSide(const SMDS_MeshNode* theNode, + const gp_Pnt2d thePnt2d, + const StdMeshers_FaceSide* theSide) +{ + myC2d.resize(1); + myLength = 0; + myMesh = theSide->GetMesh(); + myDefaultPnt2d = thePnt2d; + + myPoints = theSide->GetUVPtStruct(); + myNbPonits = myNbSegments = myPoints.size(); + std::vector::iterator it = myPoints.begin(); + for(; it!=myPoints.end(); it++) { + (*it).u = thePnt2d.X(); + (*it).v = thePnt2d.Y(); + (*it).y = 0.0; + (*it).node = theNode; + } +} + //================================================================================ /*! * \brief Return info on nodes on the side @@ -175,8 +204,7 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, map< double, const SMDS_MeshNode*> u2node; //int nbOnDegen = 0; - for ( int i = 0; i < myEdge.size(); ++i ) - { + for ( int i = 0; i < myEdge.size(); ++i ) { // put 1st vertex node TopoDS_Vertex VFirst, VLast; TopExp::Vertices( myEdge[i], VFirst, VLast, true); @@ -184,7 +212,8 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, double prevNormPar = ( i == 0 ? 0 : myNormPar[ i-1 ]); // normalized param if ( node ) { // internal nodes may be missing u2node.insert( make_pair( prevNormPar, node )); - } else if ( i == 0 ) { + } + else if ( i == 0 ) { MESSAGE(" NO NODE on VERTEX" ); return myPoints; } @@ -470,7 +499,8 @@ gp_Pnt2d StdMeshers_FaceSide::Value2d(double U) const double r = ( U - prevU )/ ( myNormPar[ i ] - prevU ); return myC2d[ i ]->Value( myFirst[i] * ( 1 - r ) + myLast[i] * r ); } - return gp_Pnt2d( 1e+100, 1e+100 ); + //return gp_Pnt2d( 1e+100, 1e+100 ); + return myDefaultPnt2d; } //================================================================================ diff --git a/src/StdMeshers/StdMeshers_FaceSide.hxx b/src/StdMeshers/StdMeshers_FaceSide.hxx index 202b6a6d4..f340dad04 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.hxx +++ b/src/StdMeshers/StdMeshers_FaceSide.hxx @@ -93,7 +93,12 @@ public: SMESH_Mesh* theMesh, const bool theIsForward, const bool theIgnoreMediumNodes); - + /*! + * \brief Wrap for vertex using data from other FaceSide + */ + StdMeshers_FaceSide(const SMDS_MeshNode* theNode, + const gp_Pnt2d thePnt2d, + const StdMeshers_FaceSide* theSide); /*! * \brief Return wires of a face as StdMeshers_FaceSide's */ @@ -202,6 +207,7 @@ protected: int myNbPonits, myNbSegments; SMESH_Mesh* myMesh; bool myMissingVertexNodes, myIgnoreMediumNodes; + gp_Pnt2d myDefaultPnt2d; }; diff --git a/src/StdMeshers/StdMeshers_QuadrangleParams.cxx b/src/StdMeshers/StdMeshers_QuadrangleParams.cxx new file mode 100644 index 000000000..ad3fee841 --- /dev/null +++ b/src/StdMeshers/StdMeshers_QuadrangleParams.cxx @@ -0,0 +1,165 @@ +// Copyright (C) 2007-2008 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 +// +// SMESH SMESH : implementaion of SMESH idl descriptions +// File : StdMeshers_QuadrangleParams.cxx +// Author : Sergey KUUL, OCC +// Module : SMESH +// +#include "StdMeshers_QuadrangleParams.hxx" + +#include "SMESH_Algo.hxx" +#include "SMESH_Mesh.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_QuadrangleParams::StdMeshers_QuadrangleParams(int hypId, int studyId, + SMESH_Gen * gen) + :SMESH_Hypothesis(hypId, studyId, gen) +{ + _name = "QuadrangleParams"; + _param_algo_dim = 2; + _triaVertexID = -1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_QuadrangleParams::~StdMeshers_QuadrangleParams() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_QuadrangleParams::SetTriaVertex(int id) +{ + if ( id != _triaVertexID ) { + _triaVertexID = id; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_QuadrangleParams::SaveTo(ostream & save) +{ + save << _triaVertexID << " " << _objEntry; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_QuadrangleParams::LoadFrom(istream & load) +{ + bool isOK = true; + isOK = (load >> _triaVertexID); + if (!isOK) + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> _objEntry); + + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_QuadrangleParams & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_QuadrangleParams & hyp) +{ + return hyp.LoadFrom( load ); +} + +//================================================================================ +/*! + * \brief Redifined method + * \param theMesh - the built mesh + * \param theShape - the geometry of interest + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_QuadrangleParams::SetParametersByMesh(const SMESH_Mesh* theMesh, + const TopoDS_Shape& theShape) +{ + if ( !theMesh || theShape.IsNull() ) + return false; + + return true; +} + +//================================================================================ +/*! + * \brief Initialize my parameter values by default parameters. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_QuadrangleParams::SetParametersByDefaults(const TDefaults& dflts, + const SMESH_Mesh* /*mesh*/) +{ + return true; +} + diff --git a/src/StdMeshers/StdMeshers_QuadrangleParams.hxx b/src/StdMeshers/StdMeshers_QuadrangleParams.hxx new file mode 100644 index 000000000..ab1c56fab --- /dev/null +++ b/src/StdMeshers/StdMeshers_QuadrangleParams.hxx @@ -0,0 +1,80 @@ +// Copyright (C) 2007-2008 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 +// +// SMESH SMESH : implementaion of SMESH idl descriptions +// File : StdMeshers_QuadrangleParams.hxx +// Author : Sergey KUUL, OCC +// Module : SMESH +// +#ifndef _SMESH_QUADRANGLEPARAMS_HXX_ +#define _SMESH_QUADRANGLEPARAMS_HXX_ + + + +#include "SMESH_StdMeshers.hxx" + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class STDMESHERS_EXPORT StdMeshers_QuadrangleParams: + public SMESH_Hypothesis +{ +public: + StdMeshers_QuadrangleParams(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_QuadrangleParams(); + + void SetTriaVertex(int id); + + void SetObjectEntry( const char* entry ) { _objEntry = entry; } + + const char* GetObjectEntry() { return _objEntry.c_str(); } + + int GetTriaVertex() const { return _triaVertexID; } + + virtual std::ostream & SaveTo(std::ostream & save); + virtual std::istream & LoadFrom(std::istream & load); + friend std::ostream& operator << (std::ostream & save, + StdMeshers_QuadrangleParams & hyp); + friend std::istream& operator >> (std::istream & load, + StdMeshers_QuadrangleParams & 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); + + /*! + * \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); + +protected: + int _triaVertexID; + std::string _objEntry; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 0a13e88ea..bd55a02c4 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -29,6 +29,8 @@ #include "StdMeshers_FaceSide.hxx" +#include "StdMeshers_QuadrangleParams.hxx" + #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_subMesh.hxx" @@ -74,12 +76,14 @@ typedef SMESH_Comment TComm; */ //============================================================================= -StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMESH_Gen* gen) +StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, + SMESH_Gen* gen) : SMESH_2D_Algo(hypId, studyId, gen) { MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); _name = "Quadrangle_2D"; _shapeType = (1 << TopAbs_FACE); + _compatibleHypothesis.push_back("QuadrangleParams"); _compatibleHypothesis.push_back("QuadranglePreference"); _compatibleHypothesis.push_back("TrianglePreference"); myTool = 0; @@ -110,25 +114,69 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis bool isOk = true; aStatus = SMESH_Hypothesis::HYP_OK; - - const list &hyps = GetUsedHypothesis(aMesh, aShape, false); + const list &hyps = + GetUsedHypothesis(aMesh, aShape, false); const SMESHDS_Hypothesis *theHyp = 0; - if(hyps.size() > 0){ - theHyp = *hyps.begin(); + if( hyps.size() == 1 ) { + myTriaVertexID = -1; + theHyp = hyps.front(); + if(strcmp("QuadrangleParams", theHyp->GetName()) == 0) { + const StdMeshers_QuadrangleParams* theHyp1 = + (const StdMeshers_QuadrangleParams*)theHyp; + myTriaVertexID = theHyp1->GetTriaVertex(); + myQuadranglePreference= false; + myTrianglePreference= false; + } if(strcmp("QuadranglePreference", theHyp->GetName()) == 0) { myQuadranglePreference= true; myTrianglePreference= false; + myTriaVertexID = -1; } else if(strcmp("TrianglePreference", theHyp->GetName()) == 0){ myQuadranglePreference= false; myTrianglePreference= true; + myTriaVertexID = -1; } } + + else if( hyps.size() > 1 ) { + theHyp = hyps.front(); + if(strcmp("QuadrangleParams", theHyp->GetName()) == 0) { + const StdMeshers_QuadrangleParams* theHyp1 = + (const StdMeshers_QuadrangleParams*)theHyp; + myTriaVertexID = theHyp1->GetTriaVertex(); + theHyp = hyps.back(); + if(strcmp("QuadranglePreference", theHyp->GetName()) == 0) { + myQuadranglePreference= true; + myTrianglePreference= false; + } + else if(strcmp("TrianglePreference", theHyp->GetName()) == 0){ + myQuadranglePreference= false; + myTrianglePreference= true; + } + } + else { + if(strcmp("QuadranglePreference", theHyp->GetName()) == 0) { + myQuadranglePreference= true; + myTrianglePreference= false; + } + else if(strcmp("TrianglePreference", theHyp->GetName()) == 0){ + myQuadranglePreference= false; + myTrianglePreference= true; + } + const StdMeshers_QuadrangleParams* theHyp2 = + (const StdMeshers_QuadrangleParams*)hyps.back(); + myTriaVertexID = theHyp2->GetTriaVertex(); + } + } + else { myQuadranglePreference = false; myTrianglePreference = false; + myTriaVertexID = -1; } + return isOk; } @@ -237,7 +285,9 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node; d = quad->uv_grid[(j + 1) * nbhoriz + i].node; SMDS_MeshFace* face = myTool->AddFace(a, b, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) { + meshDS->SetMeshElementOnShape(face, geomFaceID); + } } } @@ -311,9 +361,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, } if (near == g) { // make triangle - //SMDS_MeshFace* face = meshDS->AddFace(a, b, c); SMDS_MeshFace* face = myTool->AddFace(a, b, c); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { // make quadrangle if (near - 1 < ilow) @@ -324,7 +373,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, if(!myTrianglePreference){ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { SplitQuad(meshDS, geomFaceID, a, b, c, d); @@ -338,9 +387,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, d = uv_e3[1].node; else d = quad->uv_grid[nbhoriz + k - 1].node; - //SMDS_MeshFace* face = meshDS->AddFace(a, c, d); SMDS_MeshFace* face = myTool->AddFace(a, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } } g = near; @@ -401,9 +449,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, } if (near == g) { // make triangle - //SMDS_MeshFace* face = meshDS->AddFace(a, b, c); SMDS_MeshFace* face = myTool->AddFace(a, b, c); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { // make quadrangle if (near + 1 > iup) @@ -413,7 +460,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, //SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d); if(!myTrianglePreference){ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { SplitQuad(meshDS, geomFaceID, a, b, c, d); @@ -426,9 +473,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, d = uv_e1[nbright - 2].node; else d = quad->uv_grid[nbhoriz*(nbvertic - 2) + k + 1].node; - //SMDS_MeshFace* face = meshDS->AddFace(a, c, d); SMDS_MeshFace* face = myTool->AddFace(a, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } } g = near; @@ -475,9 +521,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, } if (near == g) { // make triangle - //SMDS_MeshFace* face = meshDS->AddFace(a, b, c); SMDS_MeshFace* face = myTool->AddFace(a, b, c); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { // make quadrangle if (near - 1 < jlow) @@ -488,7 +533,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, if(!myTrianglePreference){ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { SplitQuad(meshDS, geomFaceID, a, b, c, d); @@ -501,9 +546,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, d = uv_e0[nbdown - 2].node; else d = quad->uv_grid[nbhoriz*k - 2].node; - //SMDS_MeshFace* face = meshDS->AddFace(a, c, d); SMDS_MeshFace* face = myTool->AddFace(a, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } } g = near; @@ -547,9 +591,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, } if (near == g) { // make triangle - //SMDS_MeshFace* face = meshDS->AddFace(a, b, c); SMDS_MeshFace* face = myTool->AddFace(a, b, c); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { // make quadrangle if (near + 1 > jup) @@ -559,7 +602,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, //SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d); if(!myTrianglePreference){ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { SplitQuad(meshDS, geomFaceID, a, b, c, d); @@ -572,9 +615,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, d = uv_e2[1].node; else d = quad->uv_grid[nbhoriz*(k + 1) + 1].node; - //SMDS_MeshFace* face = meshDS->AddFace(a, c, d); SMDS_MeshFace* face = myTool->AddFace(a, c, d); - meshDS->SetMeshElementOnShape(face, geomFaceID); + if(face) meshDS->SetMeshElementOnShape(face, geomFaceID); } } g = near; @@ -640,15 +682,18 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh, int dh = Max(nbdown, nbup) - nbhoriz; int dv = Max(nbright, nbleft) - nbvertic; - int kdh = 0; - if(dh>0) kdh = 1; - int kdv = 0; - if(dv>0) kdv = 1; + //int kdh = 0; + //if(dh>0) kdh = 1; + //int kdv = 0; + //if(dv>0) kdv = 1; int nbNodes = (nbhoriz-2)*(nbvertic-2); - int nbFaces3 = dh + dv + kdh*(nbvertic-1)*2 + kdv*(nbhoriz-1)*2; - if( kdh==1 && kdv==1 ) nbFaces3 -= 2; - int nbFaces4 = (nbhoriz-1-kdh)*(nbvertic-1-kdv); + //int nbFaces3 = dh + dv + kdh*(nbvertic-1)*2 + kdv*(nbhoriz-1)*2; + int nbFaces3 = dh + dv; + //if( kdh==1 && kdv==1 ) nbFaces3 -= 2; + //if( dh>0 && dv>0 ) nbFaces3 -= 2; + //int nbFaces4 = (nbhoriz-1-kdh)*(nbvertic-1-kdv); + int nbFaces4 = (nbhoriz-1)*(nbvertic-1); std::vector aVec(17); for(int i=0; i<17; i++) aVec[i] = 0; @@ -658,11 +703,19 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh, int nbbndedges = nbdown + nbup + nbright + nbleft -4; int nbintedges = ( nbFaces4*4 + nbFaces3*3 - nbbndedges ) / 2; aVec[0] = nbNodes + nbintedges; + if( aNbNodes.size()==5 ) { + aVec[4] = nbFaces3 + aNbNodes[3] -1; + aVec[6] = nbFaces4 - aNbNodes[3] +1; + } } else { aVec[0] = nbNodes; aVec[3] = nbFaces3; aVec[5] = nbFaces4; + if( aNbNodes.size()==5 ) { + aVec[3] = nbFaces3 + aNbNodes[3] - 1; + aVec[5] = nbFaces4 - aNbNodes[3] + 1; + } } SMESH_subMesh * sm = aMesh.GetSubMesh(aShape); aResMap.insert(std::make_pair(sm,aVec)); @@ -720,7 +773,41 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMes int nbSides = 0; list< TopoDS_Edge >::iterator edgeIt = edges.begin(); - if ( nbEdgesInWire.front() == 4 ) { // exactly 4 edges + if ( nbEdgesInWire.front() == 3 ) { // exactly 3 edges + if(myTriaVertexID>0) { + SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); + TopoDS_Vertex V = TopoDS::Vertex(meshDS->IndexToShape(myTriaVertexID)); + if(!V.IsNull()) { + TopoDS_Edge E1,E2,E3; + for(; edgeIt != edges.end(); ++edgeIt) { + TopoDS_Edge E = TopoDS::Edge(*edgeIt); + TopoDS_Vertex VF, VL; + TopExp::Vertices(E, VF, VL, true); + if( VF.IsSame(V) ) + E1 = E; + else if( VL.IsSame(V) ) + E3 = E; + else + E2 = E; + } + quad->side.reserve(4); + quad->side.push_back( new StdMeshers_FaceSide(F, E1, &aMesh, true, ignoreMediumNodes)); + quad->side.push_back( new StdMeshers_FaceSide(F, E2, &aMesh, true, ignoreMediumNodes)); + quad->side.push_back( new StdMeshers_FaceSide(F, E3, &aMesh, false, ignoreMediumNodes)); + std::vector UVPSleft = quad->side[0]->GetUVPtStruct(true,0); + std::vector UVPStop = quad->side[1]->GetUVPtStruct(false,1); + std::vector UVPSright = quad->side[2]->GetUVPtStruct(true,1); + const SMDS_MeshNode* aNode = UVPSleft[0].node; + gp_Pnt2d aPnt2d( UVPSleft[0].u, UVPSleft[0].v ); + StdMeshers_FaceSide* VertFS = + new StdMeshers_FaceSide(aNode, aPnt2d, quad->side[1]); + quad->side.push_back(VertFS); + return quad; + } + } + return 0; + } + else if ( nbEdgesInWire.front() == 4 ) { // exactly 4 edges for ( ; edgeIt != edges.end(); ++edgeIt, nbSides++ ) quad->side.push_back( new StdMeshers_FaceSide(F, *edgeIt, &aMesh, nbSides aVec = (*anIt).second; IsQuadratic = (aVec[2] > aVec[1]); + if ( nbEdgesInWire.front() == 3 ) { // exactly 3 edges + if(myTriaVertexID>0) { + SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); + TopoDS_Vertex V = TopoDS::Vertex(meshDS->IndexToShape(myTriaVertexID)); + if(!V.IsNull()) { + TopoDS_Edge E1,E2,E3; + for(; edgeIt != edges.end(); ++edgeIt) { + TopoDS_Edge E = TopoDS::Edge(*edgeIt); + TopoDS_Vertex VF, VL; + TopExp::Vertices(E, VF, VL, true); + if( VF.IsSame(V) ) + E1 = E; + else if( VL.IsSame(V) ) + E3 = E; + else + E2 = E; + } + SMESH_subMesh * sm = aMesh.GetSubMesh(E1); + MapShapeNbElemsItr anIt = aResMap.find(sm); + if(anIt==aResMap.end()) return false; + std::vector aVec = (*anIt).second; + if(IsQuadratic) + aNbNodes[0] = (aVec[0]-1)/2 + 2; + else + aNbNodes[0] = aVec[0] + 2; + sm = aMesh.GetSubMesh(E2); + anIt = aResMap.find(sm); + if(anIt==aResMap.end()) return false; + aVec = (*anIt).second; + if(IsQuadratic) + aNbNodes[1] = (aVec[0]-1)/2 + 2; + else + aNbNodes[1] = aVec[0] + 2; + sm = aMesh.GetSubMesh(E3); + anIt = aResMap.find(sm); + if(anIt==aResMap.end()) return false; + aVec = (*anIt).second; + if(IsQuadratic) + aNbNodes[2] = (aVec[0]-1)/2 + 2; + else + aNbNodes[2] = aVec[0] + 2; + aNbNodes[3] = aNbNodes[1]; + aNbNodes.resize(5); + nbSides = 4; + } + } + } if ( nbEdgesInWire.front() == 4 ) { // exactly 4 edges for(; edgeIt != edges.end(); edgeIt++) { SMESH_subMesh * sm = aMesh.GetSubMesh( *edgeIt ); @@ -1083,10 +1217,8 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, } // normalized 2d values on grid - for (int i = 0; i < nbhoriz; i++) - { - for (int j = 0; j < nbvertic; j++) - { + for (int i = 0; i < nbhoriz; i++) { + for (int j = 0; j < nbvertic; j++) { int ij = j * nbhoriz + i; // --- droite i cste : x = x0 + y(x1-x0) double x0 = uv_e0[i].normParam; // bas - sud @@ -1110,10 +1242,8 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, gp_UV a2( uv_e2.back().u, uv_e2.back().v ); gp_UV a3( uv_e2.front().u, uv_e2.front().v ); - for (int i = 0; i < nbhoriz; i++) - { - for (int j = 0; j < nbvertic; j++) - { + for (int i = 0; i < nbhoriz; i++) { + for (int j = 0; j < nbvertic; j++) { int ij = j * nbhoriz + i; double x = uv_grid[ij].x; double y = uv_grid[ij].y; @@ -1446,13 +1576,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, SMDS_MeshFace* F = myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j), NodesL.Value(i+1,j+1), NodesL.Value(i,j+1)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } else { SMDS_MeshFace* F = myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1), NodesL.Value(i+1,j+1), NodesL.Value(i+1,j)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } } @@ -1509,13 +1639,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, SMDS_MeshFace* F = myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j), NodesR.Value(i+1,j+1), NodesR.Value(i,j+1)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } else { SMDS_MeshFace* F = myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1), NodesR.Value(i+1,j+1), NodesR.Value(i+1,j)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } } @@ -1587,13 +1717,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, SMDS_MeshFace* F = myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j), NodesC.Value(i+1,j+1), NodesC.Value(i,j+1)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } else { SMDS_MeshFace* F = myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1), NodesC.Value(i+1,j+1), NodesC.Value(i+1,j)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } } @@ -1629,13 +1759,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, SMDS_MeshFace* F = myTool->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i+1,j), NodesBRD.Value(i+1,j+1), NodesBRD.Value(i,j+1)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } else { SMDS_MeshFace* F = myTool->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i,j+1), NodesBRD.Value(i+1,j+1), NodesBRD.Value(i+1,j)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } } @@ -1742,13 +1872,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, SMDS_MeshFace* F = myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j), NodesC.Value(i+1,j+1), NodesC.Value(i,j+1)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } else { SMDS_MeshFace* F = myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1), NodesC.Value(i+1,j+1), NodesC.Value(i+1,j)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } } // end nrAddFace(NodesLast.Value(i,1), NodesLast.Value(i+1,1), NodesLast.Value(i+1,2), NodesLast.Value(i,2)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } else { SMDS_MeshFace* F = myTool->AddFace(NodesLast.Value(i,1), NodesLast.Value(i,2), NodesLast.Value(i+1,2), NodesLast.Value(i+1,2)); - meshDS->SetMeshElementOnShape(F, geomFaceID); + if(F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } } // if( (drl+addv) > 0 ) @@ -1907,10 +2037,18 @@ bool StdMeshers_Quadrangle_2D::EvaluateQuadPref(SMESH_Mesh & aMesh, if(IsQuadratic) { aVec[6] = nbFaces; aVec[0] = nbNodes + nbFaces*4; + if( aNbNodes.size()==5 ) { + aVec[4] = aNbNodes[3] - 1; + aVec[6] = nbFaces - aNbNodes[3] + 1; + } } else { aVec[0] = nbNodes; aVec[5] = nbFaces; + if( aNbNodes.size()==5 ) { + aVec[3] = aNbNodes[3] - 1; + aVec[5] = nbFaces - aNbNodes[3] + 1; + } } SMESH_subMesh * sm = aMesh.GetSubMesh(aShape); aResMap.insert(std::make_pair(sm,aVec)); @@ -1938,15 +2076,17 @@ void StdMeshers_Quadrangle_2D::SplitQuad(SMESHDS_Mesh *theMeshDS, SMDS_MeshFace* face; if(a.Distance(c) > b.Distance(d)){ face = myTool->AddFace(theNode2, theNode4 , theNode1); - theMeshDS->SetMeshElementOnShape(face, theFaceID ); + if(face) theMeshDS->SetMeshElementOnShape(face, theFaceID ); face = myTool->AddFace(theNode2, theNode3, theNode4); - theMeshDS->SetMeshElementOnShape(face, theFaceID ); + if(face) theMeshDS->SetMeshElementOnShape(face, theFaceID ); } else{ face = myTool->AddFace(theNode1, theNode2 ,theNode3); - theMeshDS->SetMeshElementOnShape(face, theFaceID ); + if(face) theMeshDS->SetMeshElementOnShape(face, theFaceID ); face = myTool->AddFace(theNode1, theNode3, theNode4); - theMeshDS->SetMeshElementOnShape(face, theFaceID ); + if(face) theMeshDS->SetMeshElementOnShape(face, theFaceID ); } } + + diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx index 6c26fde4a..25083af32 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx @@ -121,11 +121,14 @@ protected: // 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 + // is not the same in the case where the global number of nodes on edges + // is even bool myQuadranglePreference; bool myTrianglePreference; + int myTriaVertexID; + SMESH_MesherHelper* myTool; // tool for working with quadratic elements }; diff --git a/src/StdMeshersGUI/Makefile.am b/src/StdMeshersGUI/Makefile.am index 6d1ceae87..8e31360dc 100644 --- a/src/StdMeshersGUI/Makefile.am +++ b/src/StdMeshersGUI/Makefile.am @@ -36,7 +36,8 @@ salomeinclude_HEADERS = \ StdMeshersGUI_NbSegmentsCreator.h \ StdMeshersGUI_ObjectReferenceParamWdg.h \ StdMeshersGUI_LayerDistributionParamWdg.h \ - StdMeshersGUI_EdgeDirectionParamWdg.h + StdMeshersGUI_EdgeDirectionParamWdg.h \ + StdMeshersGUI_SubShapeSelectorWdg.h # Libraries targets lib_LTLIBRARIES = libStdMeshersGUI.la @@ -48,7 +49,8 @@ dist_libStdMeshersGUI_la_SOURCES = \ StdMeshersGUI_NbSegmentsCreator.cxx \ StdMeshersGUI_ObjectReferenceParamWdg.cxx \ StdMeshersGUI_LayerDistributionParamWdg.cxx \ - StdMeshersGUI_EdgeDirectionParamWdg.cxx + StdMeshersGUI_EdgeDirectionParamWdg.cxx \ + StdMeshersGUI_SubShapeSelectorWdg.cxx MOC_FILES = \ StdMeshersGUI_StdHypothesisCreator_moc.cxx \ @@ -57,7 +59,8 @@ MOC_FILES = \ StdMeshersGUI_NbSegmentsCreator_moc.cxx \ StdMeshersGUI_ObjectReferenceParamWdg_moc.cxx \ StdMeshersGUI_LayerDistributionParamWdg_moc.cxx \ - StdMeshersGUI_EdgeDirectionParamWdg_moc.cxx + StdMeshersGUI_EdgeDirectionParamWdg_moc.cxx \ + StdMeshersGUI_SubShapeSelectorWdg_moc.cxx nodist_libStdMeshersGUI_la_SOURCES= \ $(MOC_FILES) diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx index d89746054..93b3ca60a 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx @@ -26,7 +26,7 @@ #include "StdMeshersGUI_NbSegmentsCreator.h" #include "StdMeshersGUI_DistrTable.h" #include "StdMeshersGUI_DistrPreview.h" -#include "StdMeshersGUI_EdgeDirectionParamWdg.h" +#include "StdMeshersGUI_SubShapeSelectorWdg.h" #include #include @@ -200,7 +200,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERCE_EDGES" ), fr); QHBoxLayout* edgeLay = new QHBoxLayout( myReversedEdgesBox ); - myDirectionWidget = new StdMeshersGUI_EdgeDirectionParamWdg(); + myDirectionWidget = new StdMeshersGUI_SubShapeSelectorWdg(); QString anEntry = getShapeEntry(); if ( anEntry == "" ) anEntry = h->GetObjectEntry(); diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h index 188674497..6053e8d34 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h @@ -44,7 +44,7 @@ class QButtonGroup; class QGroupBox; class QGridLayout; class QRadioButton; -class StdMeshersGUI_EdgeDirectionParamWdg; +class StdMeshersGUI_SubShapeSelectorWdg; typedef struct { @@ -94,7 +94,7 @@ private: QRadioButton* myCutNeg; QGroupBox* myReversedEdgesBox; - StdMeshersGUI_EdgeDirectionParamWdg* myDirectionWidget; + StdMeshersGUI_SubShapeSelectorWdg* myDirectionWidget; }; #endif // STDMESHERSGUI_NBSEGMENTSCREATOR_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 66976e317..43563ea45 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -33,7 +33,8 @@ #include #include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include "StdMeshersGUI_LayerDistributionParamWdg.h" -#include "StdMeshersGUI_EdgeDirectionParamWdg.h" +//#include "StdMeshersGUI_EdgeDirectionParamWdg.h" +#include "StdMeshersGUI_SubShapeSelectorWdg.h" #include // SALOME GUI includes @@ -445,8 +446,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_Arithmetic1D_var h = StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() ); - StdMeshersGUI_EdgeDirectionParamWdg* w = - widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 ); + //StdMeshersGUI_EdgeDirectionParamWdg* w = + // widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 ); + StdMeshersGUI_SubShapeSelectorWdg* w = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 ); h->SetStartLength( params[0].myValue.toDouble() ); h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); @@ -478,8 +481,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_StartEndLength_var h = StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() ); - StdMeshersGUI_EdgeDirectionParamWdg* w = - widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 ); + StdMeshersGUI_SubShapeSelectorWdg* w = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 ); h->SetStartLength( params[0].myValue.toDouble() ); h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); @@ -557,6 +560,20 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const geomFromWdg ( getWidgetForParam( 3 )), // tgt1 geomFromWdg ( getWidgetForParam( 5 ))); // tgt2 } + else if( hypType()=="QuadrangleParams" ) + { + StdMeshers::StdMeshers_QuadrangleParams_var h = + StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() ); + StdMeshersGUI_SubShapeSelectorWdg* w = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 ); + if (w) { + if( w->GetListOfIDs()->length()>0 ) { + h->SetTriaVertex( w->GetListOfIDs()[0] ); + } + const char * entry = w->GetMainShapeEntry(); + h->SetObjectEntry( entry ); + } + } } return valueStr; } @@ -678,7 +695,10 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myName = tr( "SMESH_REVERCE_EDGES" ); p.append( item ); - StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget = new StdMeshersGUI_EdgeDirectionParamWdg(); + //StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget = + // new StdMeshersGUI_EdgeDirectionParamWdg(); + StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget = + new StdMeshersGUI_SubShapeSelectorWdg(); QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); if ( anEntry == "" ) anEntry = h->GetObjectEntry(); @@ -729,7 +749,10 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myName = tr( "SMESH_REVERCE_EDGES" ); p.append( item ); - StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget = new StdMeshersGUI_EdgeDirectionParamWdg(); + //StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget = + // new StdMeshersGUI_EdgeDirectionParamWdg(); + StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget = + new StdMeshersGUI_SubShapeSelectorWdg(); QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); if ( anEntry == "" ) anEntry = h->GetObjectEntry(); @@ -854,6 +877,32 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), h->GetTargetVertex( 2 ))); } + else if( hypType()=="QuadrangleParams" ) + { + StdMeshers::StdMeshers_QuadrangleParams_var h = + StdMeshers::StdMeshers_QuadrangleParams::_narrow( hyp ); + + item.myName = tr( "SMESH_BASE_VERTEX" ); + p.append( item ); + + StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget = + new StdMeshersGUI_SubShapeSelectorWdg(); + aDirectionWidget->SetMaxSize(1); + aDirectionWidget->SetSubShType(TopAbs_VERTEX); + QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); + if ( anEntry == "" ) + anEntry = h->GetObjectEntry(); + aDirectionWidget->SetMainShapeEntry( anEntry ); + SMESH::long_array_var aVec = new SMESH::long_array; + int vertID = h->GetTriaVertex(); + if(vertID>0) { + aVec->length(1); + aVec[0] = vertID; + } + aDirectionWidget->SetListOfIDs( aVec ); + aDirectionWidget->showPreview( true ); + customWidgets()->append ( aDirectionWidget ); + } else res = false; return res; @@ -974,6 +1023,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" ); types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" ); types.insert( "MaxLength", "MAX_LENGTH" ); + types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" ); } QString res; @@ -1046,10 +1096,17 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa param.myValue = w->GetValue(); return true; } - if ( widget->inherits( "StdMeshersGUI_EdgeDirectionParamWdg" )) + //if ( widget->inherits( "StdMeshersGUI_EdgeDirectionParamWdg" )) + //{ + // const StdMeshersGUI_EdgeDirectionParamWdg * w = + // static_cast( widget ); + // param.myValue = w->GetValue(); + // return true; + //} + if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" )) { - const StdMeshersGUI_EdgeDirectionParamWdg * w = - static_cast( widget ); + const StdMeshersGUI_SubShapeSelectorWdg * w = + static_cast( widget ); param.myValue = w->GetValue(); return true; } diff --git a/src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.cxx new file mode 100644 index 000000000..b5b8b6490 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.cxx @@ -0,0 +1,427 @@ +// Copyright (C) 2007-2008 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 : StdMeshersGUI_SubShapeSelectorWdg.cxx +// Author : Open CASCADE S.A.S. (dmv) +// SMESH includes +// +#include "StdMeshersGUI_SubShapeSelectorWdg.h" + +// SMESH Includes +#include +#include "SMESHGUI_MeshUtils.h" +#include +#include +#include +#include "SMESHGUI_GroupUtils.h" +#include "SMESH_Gen_i.hxx" +#include "SMESHGUI_GEOMGenUtils.h" + +// SVTK Includes +#include +#include +#include +#include + +// SALOME GUI includes +#include +#include +#include + +// SUIT Includes +#include + +// GEOM Includes +#include + +// Qt includes +#include +#include +#include +#include +#include + +// OCCT includes +#include +#include +#include +#include +#include + +// SALOME KERNEL includes +#include + +#define SPACING 6 +#define MARGIN 0 + +//================================================================================ +/*! + * Constructor + */ +//================================================================================ + +StdMeshersGUI_SubShapeSelectorWdg +::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent ): + QWidget( parent ) +{ + QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); + + QGridLayout* edgesLayout = new QGridLayout( this ); + edgesLayout->setMargin( MARGIN ); + edgesLayout->setSpacing( SPACING ); + + myListWidget = new QListWidget( this ); + myAddButton = new QPushButton( tr( "SMESH_BUT_ADD" ), this ); + myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this ); + myListWidget->setSelectionMode( QListWidget::ExtendedSelection ); + + edgesLayout->addWidget(myListWidget, 0, 0, 3, 3); + edgesLayout->addWidget(myAddButton, 0, 4); + edgesLayout->addWidget(myRemoveButton, 1, 4); + + edgesLayout->setRowStretch(2, 5); + edgesLayout->setColumnStretch(2, 5); + + setLayout( edgesLayout ); + setMinimumWidth( 300 ); + + myMaxSize = 1000; + mySubShType = TopAbs_EDGE; + + init(); +} + +//================================================================================ +/*! + * Destructor + */ +//================================================================================ + +StdMeshersGUI_SubShapeSelectorWdg::~StdMeshersGUI_SubShapeSelectorWdg() +{ + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) { + myPreviewActor->RemoveFromRender( myRenderer ); + aViewWindow->Repaint(); + } + myEntry = ""; + myParamValue = ""; + myMainShape.Nullify(); + + delete myPreviewActor; +} + +//================================================================================ +/*! + * Create a layout, initialize fields + */ +//================================================================================ + +void StdMeshersGUI_SubShapeSelectorWdg::init() +{ + myParamValue = ""; + myListOfIDs.clear(); + mySelectedIDs.clear(); + + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI ); + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( ActorSelection ); + + connect( myAddButton, SIGNAL(clicked()), SLOT(onAdd())); + connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove())); + + connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect( myListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged())); + + updateState(); +} + +//================================================================================ +/*! + * Create a layout, initialize fields + */ +//================================================================================ + +void StdMeshersGUI_SubShapeSelectorWdg::showPreview( bool visible) +{ + if ( myIsShown != visible ) { + myPreviewActor->SetShown( visible ); + + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->Repaint(); + + myIsShown = visible; + } +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument() +{ + mySelectedIDs.clear(); + + // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int nbSel = aList.Extent(); + + if (nbSel < 1) + return; + + SALOME_ListIteratorOfListIO anIt (aList); + + for ( ; anIt.More(); anIt.Next()) { // Loop on selected objects + Handle(SALOME_InteractiveObject) IO = anIt.Value(); + + GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( IO->getEntry() ); + if ( !CORBA::is_nil( aGeomObj ) ) { // Selected Object From Study + GEOM::GEOM_Object_ptr aGeomFatherObj = aGeomObj->GetMainShape(); + QString aFatherEntry = ""; + QString aMainFatherEntry = ""; + TopoDS_Shape shape; + if ( !CORBA::is_nil( aGeomFatherObj ) ) { + // Get Main Shape + GEOM::GEOM_Object_var aGeomMain = GetGeomObjectByEntry( myEntry ); + if ( !CORBA::is_nil( aGeomMain ) && aGeomMain->GetType() == 37 ) { // Main Shape is a Group + GEOM::GEOM_Object_ptr aMainFatherObj = aGeomMain->GetMainShape(); + if ( !CORBA::is_nil( aMainFatherObj ) ) + aMainFatherEntry = aMainFatherObj->GetStudyEntry(); + } + aFatherEntry = aGeomFatherObj->GetStudyEntry(); + } + + if ( aFatherEntry != "" && ( aFatherEntry == myEntry || aFatherEntry == aMainFatherEntry ) ) { + if ( aGeomObj->GetType() == 37 /*GEOM_GROUP*/ ) { // Selected Group that belongs the main object + GEOMBase::GetShape(aGeomObj, shape); + if ( !shape.IsNull() ) { + TopExp_Explorer exp( shape, mySubShType ); + for ( ; exp.More(); exp.Next() ) { + int index = myPreviewActor->GetIndexByShape( exp.Current() ); + if ( index ) { + mySelectedIDs.append( index ); + myPreviewActor->HighlightID( index ); + } + } + } + } else if ( aGeomObj->GetType() == 28 /*GEOM_SUBSHAPE*/ ) { + GEOMBase::GetShape(aGeomObj, shape); + if ( !shape.IsNull() && shape.ShapeType() == mySubShType ) { + int index = myPreviewActor->GetIndexByShape( shape ); + if ( index ) { + mySelectedIDs.append( index ); + myPreviewActor->HighlightID( index ); + } + } + } + } + } else { // Selected Actor from Actor Collection + QString anEntry = IO->getEntry(); + QString str = "_"; + int index = anEntry.lastIndexOf( str ); + anEntry.remove(0, index+1); + int ind = anEntry.toInt(); + if ( ind ) + mySelectedIDs.append( ind ); + } + } +} + +//================================================================================= +// function : onAdd() +// purpose : Called when Add Button Clicked +//================================================================================= +void StdMeshersGUI_SubShapeSelectorWdg::onAdd() +{ + if ( mySelectedIDs.size() < 1 ) + return; + + myListWidget->blockSignals( true ); + for (int i = 0; i < mySelectedIDs.size(); i++) { + if ( myListOfIDs.indexOf( mySelectedIDs.at(i) ) == -1 ) { + QString anID = QString(" %1").arg( mySelectedIDs.at(i) ); + + QListWidgetItem* anItem = new QListWidgetItem( anID, myListWidget ); + anItem->setSelected(true); + + myListOfIDs.append( mySelectedIDs.at(i) ); + } + } + onListSelectionChanged(); + + myListWidget->blockSignals( false ); + + if( myListOfIDs.size() >= myMaxSize ) + myAddButton->setEnabled( false ); +} + +//================================================================================= +// function : onRemove() +// purpose : Called when Remove Button Clicked +//================================================================================= +void StdMeshersGUI_SubShapeSelectorWdg::onRemove() +{ + if ( myListWidget->count() < 1 ) + return; + + myListWidget->blockSignals( true ); + QList selItems = myListWidget->selectedItems(); + QListWidgetItem* item; + foreach(item, selItems) { + QString idStr = item->text(); + int id = idStr.toInt(); + + int index = myListOfIDs.indexOf( id ); + myListOfIDs.removeAt( index ); + delete item; + } + + onListSelectionChanged(); + myListWidget->blockSignals( false ); + + myAddButton->setEnabled( true ); +} + +//================================================================================= +// function : onListSelectionChanged() +// purpose : Called when selection in element list is changed +//================================================================================= +void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged() +{ + mySelectionMgr->clearSelected(); + TColStd_MapOfInteger aIndexes; + QList selItems = myListWidget->selectedItems(); + QListWidgetItem* anItem; + foreach(anItem, selItems) + myPreviewActor->HighlightID( anItem->text().toInt() ); +} + +//================================================================================= +// function : setGeomShape +// purpose : Called to set geometry +//================================================================================ +void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry ) +{ + if ( theEntry != "") { + myParamValue = theEntry; + myEntry = theEntry; + myMainShape = GetTopoDSByEntry( theEntry ); + updateState(); + } +} + +//================================================================================= +// function : updateState +// purpose : update Widget state +//================================================================================= +void StdMeshersGUI_SubShapeSelectorWdg::updateState() +{ + bool state = false; + if ( !myMainShape.IsNull() ) + state = true; + + myListWidget->setEnabled( state ); + myAddButton->setEnabled( state ); + myRemoveButton->setEnabled( state ); + + if (state = true) { + myPreviewActor = new SMESH_PreviewActorsCollection(); + myPreviewActor->SetSelector( mySelector ); + //myPreviewActor->Init( myMainShape, TopAbs_EDGE, myEntry ); + myPreviewActor->Init( myMainShape, mySubShType, myEntry ); + myPreviewActor->SetShown( false ); + myIsShown = false; + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) { + myRenderer = aViewWindow->getRenderer(); + myPreviewActor->AddToRender( myRenderer ); + aViewWindow->Repaint(); + } + } +} + +//================================================================================= +// function : GetGeomObjectByEntry +// purpose : Called to get GeomObject +//================================================================================= +GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( const QString& theEntry ) +{ + GEOM::GEOM_Object_var aGeomObj; + SALOMEDS::Study_var aStudy = SMESHGUI::GetSMESHGen()->GetCurrentStudy(); + if (aStudy != 0) { + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( theEntry.toLatin1().data() ); + SALOMEDS::GenericAttribute_var anAttr; + + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal); + aGeomObj = GEOM::GEOM_Object::_narrow(obj); + } + } + return aGeomObj; +} + +//================================================================================= +// function : setObjectByEntry +// purpose : Called to get GeomObject +//================================================================================= +TopoDS_Shape StdMeshersGUI_SubShapeSelectorWdg::GetTopoDSByEntry( const QString& theEntry ) +{ + TopoDS_Shape shape; + GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( theEntry ); + GEOMBase::GetShape(aGeomObj, shape); + return shape; +} + +//================================================================================= +// function : GetListOfIds +// purpose : Called to get the list of SubShapes IDs +//================================================================================= +SMESH::long_array_var StdMeshersGUI_SubShapeSelectorWdg::GetListOfIDs() +{ + SMESH::long_array_var anArray = new SMESH::long_array; + int size = myListOfIDs.size(); + anArray->length( size ); + if ( size ) { + for (int i = 0; i < size; i++) { + anArray[i] = myListOfIDs.at(i); + } + } + return anArray; +} + +//================================================================================= +// function : SetListOfIds +// purpose : Called to set the list of SubShapes IDs +//================================================================================= +void StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theIds) +{ + mySelectedIDs.clear(); + myListOfIDs.clear(); + int size = theIds->length(); + for ( int i = 0; i < size; i++ ) + mySelectedIDs.append( theIds[ i ] ); + onAdd(); +} + diff --git a/src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.h b/src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.h new file mode 100644 index 000000000..6447516fb --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.h @@ -0,0 +1,115 @@ +// Copyright (C) 2007-2008 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 : StdMeshersGUI_SubShapeSelectorWdg.h +// Author : Open CASCADE S.A.S. (dmv) +// +#ifndef STDMESHERSGUI_SUBSHAPESELECTORWDG_H +#define STDMESHERSGUI_SUBSHAPESELECTORWDG_H + +// SMESH includes +#include +#include "SMESH_StdMeshersGUI.hxx" +#include "SMESH_SMESHGUI.hxx" + +// Qt includes +#include +#include +#include + +#include + +class SMESHGUI; +class LightApp_SelectionMgr; +class SVTK_Selector; +class QPushButton; +class QLineEdit; +class QCheckBox; +class QListWidget; +class SMESH_Actor; +class SMESH_PreviewActorsCollection; +class vtkRenderer; + +class STDMESHERSGUI_EXPORT StdMeshersGUI_SubShapeSelectorWdg : public QWidget +{ + Q_OBJECT + +public: + StdMeshersGUI_SubShapeSelectorWdg( QWidget* parent = 0 ); + ~StdMeshersGUI_SubShapeSelectorWdg(); + + SMESH::long_array_var GetListOfIDs(); + void SetListOfIDs( SMESH::long_array_var ); + + void SetMainShapeEntry( const QString& theEntry ); + const char* GetMainShapeEntry() { return myEntry.toLatin1().data();} + + TopoDS_Shape GetMainShape() { return myMainShape; } + + static GEOM::GEOM_Object_var GetGeomObjectByEntry( const QString& ); + static TopoDS_Shape GetTopoDSByEntry( const QString& ); + + QString GetValue() const { return myParamValue; } + + void showPreview ( bool ); + + void SetMaxSize(int aMaxSize) { myMaxSize = aMaxSize; } + void SetSubShType(TopAbs_ShapeEnum aSubShType) { mySubShType = aSubShType; } + +private: + void updateState(); + +private slots: + void onAdd(); + void onRemove(); + void SelectionIntoArgument(); + void onListSelectionChanged(); + +private: + void init(); + +private: + SMESHGUI* mySMESHGUI; + LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + SVTK_Selector* mySelector; + SMESH::SMESH_Mesh_var myMesh; + TopoDS_Shape myMainShape; + QString myEntry; + vtkRenderer* myRenderer; + + QListWidget* myListWidget; + QPushButton* myAddButton; + QPushButton* myRemoveButton; + QList mySelectedIDs; + QList myListOfIDs; + + QString myParamValue; + bool myIsShown; + + // for manage possible size of myListOfIDs + int myMaxSize; + // for manage type of selected subshape + TopAbs_ShapeEnum mySubShType; + + SMESH_PreviewActorsCollection* myPreviewActor; +}; + +#endif // STDMESHERSGUI_SUBSHAPESELECTORWDG_H diff --git a/src/StdMeshersGUI/StdMeshers_images.ts b/src/StdMeshersGUI/StdMeshers_images.ts index 132661aa0..cb63c4f18 100644 --- a/src/StdMeshersGUI/StdMeshers_images.ts +++ b/src/StdMeshersGUI/StdMeshers_images.ts @@ -217,5 +217,9 @@ ICON_SMESH_TREE_HYPO_StartEndLength mesh_tree_hypo_length.png + + ICON_DLG_QUADRANGLE_PARAMS + mesh_hypo_length.png + diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.ts b/src/StdMeshersGUI/StdMeshers_msg_en.ts index 30651e813..e49d525e8 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.ts +++ b/src/StdMeshersGUI/StdMeshers_msg_en.ts @@ -249,6 +249,10 @@ SMESH_REVERCE_EDGES Reverce Edges + + SMESH_BASE_VERTEX + Base vertex + SMESH_SEGMENT_LENGTH_AROUND_VERTEX_HYPOTHESIS Segment Length Around Vertex @@ -317,6 +321,14 @@ SMESH_TARGET_VERTEX2 Target Vertex 2 + + SMESH_QUADRANGLE_PARAMS_HYPOTHESIS + Quadrangle parameters + + + SMESH_QUADRANGLE_PARAMS_TITLE + Hypothesis Construction + StdMeshersGUI_LayerDistributionParamWdg diff --git a/src/StdMeshers_I/Makefile.am b/src/StdMeshers_I/Makefile.am index 526d71fc5..0238db867 100644 --- a/src/StdMeshers_I/Makefile.am +++ b/src/StdMeshers_I/Makefile.am @@ -60,6 +60,7 @@ salomeinclude_HEADERS = \ StdMeshers_UseExisting_1D2D_i.hxx \ StdMeshers_TrianglePreference_i.hxx \ StdMeshers_MaxLength_i.hxx \ + StdMeshers_QuadrangleParams_i.hxx \ SMESH_StdMeshers_I.hxx # Libraries targets @@ -97,7 +98,8 @@ dist_libStdMeshersEngine_la_SOURCES = \ StdMeshers_SegmentLengthAroundVertex_i.cxx \ StdMeshers_UseExisting_1D2D_i.cxx \ StdMeshers_TrianglePreference_i.cxx \ - StdMeshers_MaxLength_i.cxx + StdMeshers_MaxLength_i.cxx \ + StdMeshers_QuadrangleParams_i.cxx # additionnal information to compil and link file libStdMeshersEngine_la_CPPFLAGS = \ diff --git a/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx new file mode 100644 index 000000000..9113359b6 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx @@ -0,0 +1,188 @@ +// Copyright (C) 2007-2008 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 +// +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// File : StdMeshers_QuadrangleParams_i.cxx +// Author : Sergey KUUL, OCC +// Module : SMESH +// $Header$ +// +#include "StdMeshers_QuadrangleParams_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +using namespace std; + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i + (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::StdMeshers_QuadrangleParams_i" ); + myBaseImpl = new ::StdMeshers_QuadrangleParams(theGenImpl->GetANewId(), + theStudyId, + theGenImpl); +} + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i() +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::~StdMeshers_QuadrangleParams_i" ); +} + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::SetTriaVertex + * + * Set base vertex for triangles + */ +//============================================================================= + +void StdMeshers_QuadrangleParams_i::SetTriaVertex(CORBA::Long vertID) +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::SetTriaVertex" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetTriaVertex( vertID ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + + // Update Python script + /* SMESH::TPythonDump() << _this() << ".SetEdgesToReverse( " + << theList << " )";*/ +} + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::SetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +void StdMeshers_QuadrangleParams_i::SetObjectEntry( const char* entry ) +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + + try { + this->GetImpl()->SetObjectEntry( entry ); + // Update Python script + // SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )"; + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::GetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +char* StdMeshers_QuadrangleParams_i::GetObjectEntry() +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + const char* entry; + try { + entry = this->GetImpl()->GetObjectEntry(); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + return CORBA::string_dup( entry ); +} + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::GetTriaVertex + * + * Get base vertex for triangles + */ +//============================================================================= + +CORBA::Long StdMeshers_QuadrangleParams_i::GetTriaVertex() +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::GetTriaVertex" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetTriaVertex(); +} + +//============================================================================= +/*! + * StdMeshers_QuadrangleParams_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_QuadrangleParams* StdMeshers_QuadrangleParams_i::GetImpl() +{ + MESSAGE( "StdMeshers_QuadrangleParams_i::GetImpl" ); + return ( ::StdMeshers_QuadrangleParams* )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_QuadrangleParams_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_2D; +} + diff --git a/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx new file mode 100644 index 000000000..ed2977f19 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx @@ -0,0 +1,80 @@ +// Copyright (C) 2007-2008 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 +// +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// File : StdMeshers_QuadrangleParams_i.hxx +// Author : Sergey KUUL, OCC +// Module : SMESH +// $Header$ +// +#ifndef _SMESH_QUADRANGLEPARAMS_I_HXX_ +#define _SMESH_QUADRANGLEPARAMS_I_HXX_ + +#include "SMESH_StdMeshers_I.hxx" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_QuadrangleParams.hxx" + +// ====================================================== +// QuadrangleParams hypothesis +// ====================================================== +class STDMESHERS_I_EXPORT StdMeshers_QuadrangleParams_i: + public virtual POA_StdMeshers::StdMeshers_QuadrangleParams, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_QuadrangleParams_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_QuadrangleParams_i(); + + // Set length + //void SetLength( CORBA::Double theLength, CORBA::Boolean theIsStart ) + // throw ( SALOME::SALOME_Exception ); + + // Get length + //CORBA::Double GetLength(CORBA::Boolean theIsStart); + + //Set base vertex for triangles + void SetTriaVertex(CORBA::Long vertID); + + //Get base vertex for triangles + CORBA::Long GetTriaVertex(); + + //Set the Entry of the Object + void SetObjectEntry(const char* theEntry); + + //Get Object Entry + char* GetObjectEntry(); + + // Get implementation + ::StdMeshers_QuadrangleParams* 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 8d73b56d8..c17dfa98b 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -51,6 +51,7 @@ #include "StdMeshers_LayerDistribution_i.hxx" #include "StdMeshers_SegmentLengthAroundVertex_i.hxx" #include "StdMeshers_MaxLength_i.hxx" +#include "StdMeshers_QuadrangleParams_i.hxx" #include "StdMeshers_Regular_1D_i.hxx" #include "StdMeshers_MEFISTO_2D_i.hxx" @@ -127,6 +128,8 @@ STDMESHERS_I_EXPORT aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "SegmentLengthAroundVertex") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "QuadrangleParams") == 0) + aCreator = new StdHypothesisCreator_i; // Algorithms else if (strcmp(aHypName, "Regular_1D") == 0)