From: eap Date: Tue, 20 Feb 2007 07:06:16 +0000 (+0000) Subject: PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis") X-Git-Tag: V3_2_6a1~70 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=602d60e4d198a7703d12d2fa69f21a23a32a15b9;p=modules%2Fsmesh.git PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis") PAL13615 (EDF PAL 315/31 GEOM SMESH : meshing of a "5 edges quadrangle") create new hypothesis --- diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index 94472e81b..cf2984bb3 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -507,6 +507,32 @@ module StdMeshers raises (SALOME::SALOME_Exception); }; + /*! + * interface of "SegmentLengthAroundVertex" hypothesis. + * This hypothesis specifies length of segments adjacent to the vertex the + * hypothesis is assigned to + */ + interface StdMeshers_SegmentLengthAroundVertex : SMESH::SMESH_Hypothesis + { + /*! + * Sets parameter value + */ + void SetLength(in double length) + raises (SALOME::SALOME_Exception); + + /*! + * Returns parameter value + */ + double GetLength(); + }; + + /*! + * StdMeshers_SegmentAroundVertex_0D: interface of "SegmentAroundVertex" algorithm + */ + interface StdMeshers_SegmentAroundVertex_0D : SMESH::SMESH_0D_Algo + { + }; + /*! * StdMeshers_Regular_1D: interface of "Wire discretisation" algorithm */ @@ -514,6 +540,13 @@ module StdMeshers { }; + /*! + * StdMeshers_CompositeSegment_1D: interface of "Composite side discretisation" algorithm + */ + interface StdMeshers_CompositeSegment_1D : SMESH::SMESH_1D_Algo + { + }; + /*! * StdMeshers_MEFISTO_2D: interface of "Triangle (Mefisto)" algorithm */ diff --git a/src/StdMeshers/Makefile.in b/src/StdMeshers/Makefile.in index dac525277..46927e7c0 100644 --- a/src/StdMeshers/Makefile.in +++ b/src/StdMeshers/Makefile.in @@ -62,7 +62,10 @@ EXPORT_HEADERS = \ StdMeshers_Projection_3D.hxx \ StdMeshers_RadialPrism_3D.hxx \ StdMeshers_ProjectionUtils.hxx \ - StdMeshers_LayerDistribution.hxx + StdMeshers_LayerDistribution.hxx \ + StdMeshers_SegmentAroundVertex_0D.hxx \ + StdMeshers_SegmentLengthAroundVertex.hxx \ + StdMeshers_CompositeSegment_1D.hxx \ EXPORT_PYSCRIPTS = @@ -100,7 +103,11 @@ LIB_SRC = \ StdMeshers_Projection_3D.cxx \ StdMeshers_RadialPrism_3D.cxx \ StdMeshers_ProjectionUtils.cxx \ - StdMeshers_LayerDistribution.cxx + StdMeshers_LayerDistribution.cxx \ + StdMeshers_SegmentAroundVertex_0D.cxx \ + StdMeshers_SegmentLengthAroundVertex.cxx \ + StdMeshers_FaceSide.cxx \ + StdMeshers_CompositeSegment_1D.cxx LIB_SERVER_IDL = diff --git a/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx b/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx new file mode 100644 index 000000000..4540ef2a4 --- /dev/null +++ b/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx @@ -0,0 +1,413 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_Regular_1D.cxx +// Moved here from SMESH_Regular_1D.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#include "StdMeshers_CompositeSegment_1D.hxx" +#include "StdMeshers_FaceSide.hxx" +#include "StdMeshers_AutomaticLength.hxx" + +#include "SMESH_Gen.hxx" +#include "SMESH_Mesh.hxx" +#include "SMESH_HypoFilter.hxx" +#include "SMESH_subMesh.hxx" +#include "SMESH_subMeshEventListener.hxx" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + + +namespace { + + //================================================================================ + /*! + * \brief Search for an edge conjunct to the given one by the vertex + * Return NULL if more than 2 edges share the vertex or edges + * continuity is less than C1 + */ + //================================================================================ + + TopoDS_Edge nextC1Edge(const TopoDS_Edge& edge, + SMESH_Mesh & aMesh, + const bool forward) + { + TopoDS_Edge eNext; + TopTools_MapOfShape edgeCounter; + edgeCounter.Add( edge ); + TopoDS_Vertex v; + v = forward ? TopExp::LastVertex( edge,1 ) : TopExp::FirstVertex( edge,1 ); + TopTools_ListIteratorOfListOfShape ancestIt = aMesh.GetAncestors( v ); + for ( ; ancestIt.More(); ancestIt.Next() ) + { + const TopoDS_Shape & ancestor = ancestIt.Value(); + if ( ancestor.ShapeType() == TopAbs_EDGE && edgeCounter.Add( ancestor )) + eNext = TopoDS::Edge( ancestor ); + } + if ( edgeCounter.Extent() < 3 && !eNext.IsNull() ) { + GeomAbs_Shape cont = SMESH_Algo::Continuity( edge, eNext ); + if (cont >= GeomAbs_C1) { + // care of orientation + bool reverse; + if ( forward ) + reverse = ( !v.IsSame( TopExp::FirstVertex( eNext, true ))); + else + reverse = ( !v.IsSame( TopExp::LastVertex( eNext, true ))); + if ( reverse ) + eNext.Reverse(); + return eNext; + } + } + return TopoDS_Edge(); + } + + //================================================================================ + /*! + * \brief Update submeshes state for all edges and internal vertices, + * make them look computed even if none edge or node is set on them + */ + //================================================================================ + + void careOfSubMeshes( StdMeshers_FaceSide& side, EventListener* eListener) + { + if ( side.NbEdges() < 2) + return; + for ( int iE = 0; iE < side.NbEdges(); ++iE ) + { + // set listener and its data + EventListenerData * listenerData = new EventListenerData(true); + const TopoDS_Edge& edge = side.Edge( iE ); + SMESH_subMesh * sm = side.GetMesh()->GetSubMesh( edge ); + sm->SetEventListener( eListener, listenerData, sm ); + // add edge submesh to the data + sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + if ( !sm->GetComputeState() != SMESH_subMesh::COMPUTE_OK ) { + sm->SetIsAlwaysComputed( true ); + listenerData->mySubMeshes.push_back( sm ); + } + // add internal vertex submesh to the data + if ( iE ) + { + TopoDS_Vertex V = side.FirstVertex( iE ); + sm = side.GetMesh()->GetSubMesh( V ); + sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + if ( !sm->GetComputeState() != SMESH_subMesh::COMPUTE_OK ) + sm->SetIsAlwaysComputed( true ); + listenerData->mySubMeshes.push_back( sm ); + } + } + } + + //================================================================================ + /*! + * \brief Class used to restore nodes on internal vertices of a complex side + * when StdMeshers_CompositeSegment_1D algorithm is removed + */ + //================================================================================ + + struct VertexNodesRestoringListener : public SMESH_subMeshEventListener + { + VertexNodesRestoringListener():SMESH_subMeshEventListener(0) // won't be deleted by submesh + {} + /*! + * \brief Restore nodes on internal vertices of a complex side + * \param event - algo_event or compute_event itself (of SMESH_subMesh) + * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh) + * \param subMesh - the submesh where the event occures + * \param data - listener data stored in the subMesh + * \param hyp - hypothesis, if eventType is algo_event + */ + void ProcessEvent(const int event, + const int eventType, + SMESH_subMesh* subMesh, + EventListenerData* data, + SMESH_Hypothesis* /*hyp*/) + { + bool hypRemoved = ( eventType == SMESH_subMesh::ALGO_EVENT && + subMesh->GetAlgoState() != SMESH_subMesh::HYP_OK ); + if ( hypRemoved && data ) + { + list::iterator smIt = data->mySubMeshes.begin(); + for ( ; smIt != data->mySubMeshes.end(); ++smIt ) + { + if ( SMESH_subMesh* sm = *smIt ) { + sm->SetIsAlwaysComputed( false ); + if ( sm->GetSubShape().ShapeType() == TopAbs_VERTEX ) + sm->GetFather()->GetGen()->Compute( *sm ); + else // edge + sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + } + } + } + // at study restoration: + // check if edge submesh must have _alwaysComputed flag + else if ( eventType == SMESH_subMesh::COMPUTE_EVENT && + event == SMESH_subMesh::SUBMESH_RESTORED ) + { + if ( !subMesh->GetEventListenerData( this )) { // not yet checked + SMESHDS_Mesh * meshDS = subMesh->GetFather()->GetMeshDS(); + TopoDS_Edge edge = TopoDS::Edge( subMesh->GetSubShape() ); + TopoDS_Vertex V1, V2; + TopExp::Vertices( edge, V1, V2 ); + bool noVertexNode1 = ( !SMESH_Algo::VertexNode( V1, meshDS )); + bool noVertexNode2 = ( !SMESH_Algo::VertexNode( V2, meshDS )); + if ( noVertexNode1 || noVertexNode2 ) { + TopoDS_Face face; + auto_ptr< StdMeshers_FaceSide > side + ( StdMeshers_CompositeSegment_1D::GetFaceSide(*subMesh->GetFather(), + edge, face, false )); + if ( side->NbSegments() ) + careOfSubMeshes( *side, this ); + } + } + } + } + }; // struct VertexNodesRestoringListener +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D(int hypId, + int studyId, + SMESH_Gen * gen) + :StdMeshers_Regular_1D(hypId, studyId, gen) +{ + MESSAGE("StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D"); + _name = "CompositeSegment_1D"; + _EventListener = new VertexNodesRestoringListener(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_CompositeSegment_1D::~StdMeshers_CompositeSegment_1D() +{ + delete _EventListener; +} + +//============================================================================= +/*! + * \brief Sets event listener to submeshes if necessary + * \param subMesh - submesh where algo is set + * + * This method is called when a submesh gets HYP_OK algo_state. + * After being set, event listener is notified on each event of a submesh. + */ +//============================================================================= + +void StdMeshers_CompositeSegment_1D::SetEventListener(SMESH_subMesh* subMesh) +{ + subMesh->SetEventListener( _EventListener, 0, subMesh); + StdMeshers_Regular_1D::SetEventListener( subMesh ); +} + +//============================================================================= +/*! + * \brief Return a face side the edge belongs to + */ +//============================================================================= + +StdMeshers_FaceSide * +StdMeshers_CompositeSegment_1D::GetFaceSide(SMESH_Mesh& aMesh, + const TopoDS_Edge& anEdge, + const TopoDS_Face& aFace, + const bool ignoreMeshed) +{ + list< TopoDS_Edge > edges; + edges.push_back( anEdge ); + + list hypList; + SMESH_Algo* theAlgo = aMesh.GetGen()->GetAlgo( aMesh, anEdge ); + if ( theAlgo ) hypList = theAlgo->GetUsedHypothesis(aMesh, anEdge, false); + for ( int forward = 0; forward < 2; ++forward ) + { + TopoDS_Edge eNext = nextC1Edge( anEdge, aMesh, forward ); + while ( !eNext.IsNull() ) { + if ( ignoreMeshed ) { + // eNext must not have computed mesh + if ( SMESHDS_SubMesh* sm = aMesh.GetMeshDS()->MeshElements(eNext) ) + if ( sm->NbNodes() || sm->NbElements() ) + break; + } + // eNext must have same hypotheses + SMESH_Algo* algo = aMesh.GetGen()->GetAlgo( aMesh, eNext ); + if ( !algo || + string(theAlgo->GetName()) != algo->GetName() || + hypList != algo->GetUsedHypothesis(aMesh, eNext, false)) + break; + if ( forward ) + edges.push_back( eNext ); + else + edges.push_front( eNext ); + eNext = nextC1Edge( eNext, aMesh, forward ); + } + } + return new StdMeshers_FaceSide( aFace, edges, &aMesh, true ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_CompositeSegment_1D::Compute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape) +{ + TopoDS_Edge edge = TopoDS::Edge( aShape ); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + + // Get edges to be discretized as a whole + TopoDS_Face nullFace; + auto_ptr< StdMeshers_FaceSide > side( GetFaceSide(aMesh, edge, nullFace, true )); + //side->dump("IN COMPOSITE SEG"); + + if ( side->NbEdges() < 2 ) + return StdMeshers_Regular_1D::Compute( aMesh, aShape ); + + // update segment lenght computed by StdMeshers_AutomaticLength + const list & hyps = GetUsedHypothesis(aMesh, aShape); + if ( !hyps.empty() ) { + StdMeshers_AutomaticLength * autoLenHyp = const_cast + (dynamic_cast (hyps.front())); + if ( autoLenHyp ) + _value[ BEG_LENGTH_IND ]= autoLenHyp->GetLength( &aMesh, side->Length() ); + } + + // Compute node parameters + auto_ptr< BRepAdaptor_CompCurve > C3d ( side->GetCurve3d() ); + double f = C3d->FirstParameter(), l = C3d->LastParameter(); + list< double > params; + if ( !computeInternalParameters ( *C3d, side->Length(), f, l, params, false )) + return false; + + // Redistribute parameters near ends + TopoDS_Vertex VFirst = side->FirstVertex(); + TopoDS_Vertex VLast = side->LastVertex(); + redistributeNearVertices( aMesh, *C3d, side->Length(), params, VFirst, VLast ); + + params.push_front(f); + params.push_back(l); + int nbNodes = params.size(); + + // Create mesh + + const SMDS_MeshNode * nFirst = SMESH_Algo::VertexNode( VFirst, meshDS ); + if (!nFirst) { + MESSAGE (" NO NODE BUILT ON VERTEX "); + return false; + } + const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS ); + if (!nLast) { + MESSAGE (" NO NODE BUILT ON VERTEX "); + return false; + } + vector nodes( nbNodes, (const SMDS_MeshNode*)0 ); + nodes.front() = nFirst; + nodes.back() = nLast; + + // create internal nodes + list< double >::iterator parIt = params.begin(); + double prevPar = *parIt; + Standard_Real u; + for ( int iN = 0; parIt != params.end(); ++iN, ++parIt) + { + if ( !nodes[ iN ] ) { + gp_Pnt p = C3d->Value( *parIt ); + SMDS_MeshNode* n = meshDS->AddNode( p.X(), p.Y(), p.Z()); + C3d->Edge( *parIt, edge, u ); + meshDS->SetNodeOnEdge( n, edge, u ); +// cout << "new NODE: par="<<*parIt<<" ePar="<Value( mPar ); + SMDS_MeshNode* n = meshDS->AddNode( p.X(), p.Y(), p.Z()); + //cout << "new NODE "<< n << endl; + meshDS->SetNodeOnEdge( n, edge, u ); + SMDS_MeshEdge * seg = meshDS->AddEdge(nodes[ iN-1 ], nodes[ iN ], n); + meshDS->SetMeshElementOnShape(seg, edge); + } + else { + C3d->Edge( mPar, edge, u ); + SMDS_MeshEdge * seg = meshDS->AddEdge(nodes[ iN-1 ], nodes[ iN ]); + meshDS->SetMeshElementOnShape(seg, edge); + } + } + prevPar = *parIt; + } + + // remove nodes on internal vertices + for ( int iE = 0; iE < side->NbEdges()-1; ++iE ) + { + TopoDS_Vertex V = side->LastVertex( iE ); + while ( const SMDS_MeshNode * n = SMESH_Algo::VertexNode( V, meshDS )) + meshDS->RemoveNode( n ); + } + + // Update submeshes state for all edges and internal vertices, + // make them look computed even if none edge or node is set on them + careOfSubMeshes( *side, _EventListener ); + + return true; +} + diff --git a/src/StdMeshers/StdMeshers_CompositeSegment_1D.hxx b/src/StdMeshers/StdMeshers_CompositeSegment_1D.hxx new file mode 100644 index 000000000..66b87ecdf --- /dev/null +++ b/src/StdMeshers/StdMeshers_CompositeSegment_1D.hxx @@ -0,0 +1,68 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_CompositeSegment_1D.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESH_CompositeSegment_1D_HXX_ +#define _SMESH_CompositeSegment_1D_HXX_ + +#include "StdMeshers_Regular_1D.hxx" + +class SMESH_subMeshEventListener; +class SMESH_Mesh; +class StdMeshers_FaceSide; +class TopoDS_Edge; +class TopoDS_Face; + +class StdMeshers_CompositeSegment_1D: public StdMeshers_Regular_1D +{ +public: + StdMeshers_CompositeSegment_1D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_CompositeSegment_1D(); + + virtual bool Compute(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape); + /*! + * \brief Sets event listener to submeshes if necessary + * \param subMesh - submesh where algo is set + * + * This method is called when a submesh gets HYP_OK algo_state. + * After being set, event listener is notified on each event of a submesh. + */ + virtual void SetEventListener(SMESH_subMesh* subMesh); + + /*! + * \brief Return a face side the edge belongs to + */ + static StdMeshers_FaceSide * GetFaceSide(SMESH_Mesh& aMesh, + const TopoDS_Edge& anEdge, + const TopoDS_Face& aFace, + const bool ignoreMeshed); + +protected: + SMESH_subMeshEventListener* _EventListener; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx new file mode 100644 index 000000000..583fccebb --- /dev/null +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -0,0 +1,477 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_FaceSide.hxx +// Created : Wed Jan 31 18:41:25 2007 +// Author : Edward AGAPOV (eap) +// Module : SMESH + +#include "StdMeshers_FaceSide.hxx" + +#include "SMDS_EdgePosition.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESHDS_SubMesh.hxx" +#include "SMESH_Algo.hxx" +#include "SMESH_Mesh.hxx" +#include "SMESH_MeshEditor.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "utilities.h" + +//================================================================================ +/*! + * \brief Constructor of a side of one edge + * \param theFace - the face + * \param theEdge - the edge + */ +//================================================================================ + +StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + SMESH_Mesh* theMesh, + const bool theIsForward) +{ + list edges(1,theEdge); + *this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward ); +} + +//================================================================================ +/*! + * \brief Constructor of a side of several edges + * \param theFace - the face + * \param theEdge - the edge + */ +//================================================================================ + +StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, + list& theEdges, + SMESH_Mesh* theMesh, + const bool theIsForward) +{ + int nbEdges = theEdges.size(); + myEdge.resize( nbEdges ); + myC2d.resize( nbEdges ); + myFirst.resize( nbEdges ); + myLast.resize( nbEdges ); + myNormPar.resize( nbEdges ); + myLength = 0; + myNbPonits = myNbSegments = 0; + myMesh = theMesh; + myMissingVertexNodes = false; + if ( nbEdges == 0 ) return; + + SMESHDS_Mesh* meshDS = theMesh->GetMeshDS(); + vector len( nbEdges ); + + list::iterator edge = theEdges.begin(); + for ( int index = 0; edge != theEdges.end(); ++index, ++edge ) + { + int i = theIsForward ? index : nbEdges - index - 1; + len[i] = SMESH_Algo::EdgeLength( *edge ); + myLength += len[i]; + myEdge[i] = *edge; + if ( !theIsForward ) myEdge[i].Reverse(); + + if ( theFace.IsNull() ) + BRep_Tool::Range( *edge, myFirst[i], myLast[i] ); + else + myC2d[i] = BRep_Tool::CurveOnSurface( *edge, theFace, myFirst[i], myLast[i] ); + if ( myEdge[i].Orientation() == TopAbs_REVERSED ) + std::swap( myFirst[i], myLast[i] ); + + if ( SMESHDS_SubMesh* sm = meshDS->MeshElements( *edge )) { + int nbN = sm->NbNodes(); + SMDS_ElemIteratorPtr elemIt = sm->GetElements(); + if ( elemIt->more() && elemIt->next()->IsQuadratic() ) + nbN -= sm->NbElements(); + myNbPonits += nbN; + myNbSegments += sm->NbElements(); + } + if ( SMESH_Algo::VertexNode( TopExp::FirstVertex( *edge, 1), meshDS )) + myNbPonits += 1; // for the first end + else + myMissingVertexNodes = true; + } + if ( SMESH_Algo::VertexNode( TopExp::LastVertex( theEdges.back(), 1), meshDS )) + myNbPonits++; // for the last end + else + myMissingVertexNodes = true; + + if ( nbEdges > 1 && myLength > DBL_MIN ) { + for ( int i = 0; i < nbEdges; ++i ) { + myNormPar[ i ] = len[i]/myLength; + if ( i > 0 ) + myNormPar[ i ] += myNormPar[ i-1 ]; + } + } + myNormPar[nbEdges-1] = 1.; + //dump(); +} +//================================================================================ +/*! + * \brief First curve parameter + * \retval double - parameter value + */ +//================================================================================ + +// double StdMeshers_FaceSide::First() const +// { +// return 0; +// } +// //================================================================================ +// /*! +// * \brief Last curve parameter +// * \retval double - parameter value +// */ +// //================================================================================ + +// double StdMeshers_FaceSide::Last() const +// { +// return 1; +// } + +// //================================================================================ +// /*! +// * \brief +// * \retval bool - +// */ +// //================================================================================ + +// bool StdMeshers_FaceSide::IsForward() const +// { +// return myIsForward; +// } + +//================================================================================ +/*! + * \brief Return info on nodes on the side + * \retval UVPtStruct* - array of data structures + */ +//================================================================================ + +const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, + double constValue) const +{ + if ( myPoints.empty() ) { + + if ( NbEdges() == 0 ) return myPoints; + + SMESHDS_Mesh* meshDS = myMesh->GetMeshDS(); + + // sort nodes of all edges putting them into a map + + map< double, const SMDS_MeshNode*> u2node; + for ( int i = 0; i < myEdge.size(); ++i ) + { + // put 1st vertex node + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices( myEdge[i], VFirst, VLast, true); + const SMDS_MeshNode* node = SMESH_Algo::VertexNode( VFirst, meshDS ); + 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 ) { + MESSAGE(" NO NODE on VERTEX" ); + return myPoints; + } + + // put 2nd vertex node for a last edge + if ( i+1 == myEdge.size() ) { + node = SMESH_Algo::VertexNode( VLast, meshDS ); + if ( !node ) { + MESSAGE(" NO NODE on VERTEX" ); + return myPoints; + } + u2node.insert( make_pair( 1., node )); + } + + // put internal nodes + SMESHDS_SubMesh* sm = meshDS->MeshElements( myEdge[i] ); + if ( !sm ) continue; + SMDS_NodeIteratorPtr nItr = sm->GetNodes(); + double paramSize = myLast[i] - myFirst[i], r = myNormPar[i] - prevNormPar; + while ( nItr->more() ) { + const SMDS_MeshNode* node = nItr->next(); + if ( SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge )) + continue; + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double u = epos->GetUParameter(); + // paramSize is signed so orientation is taken into account + double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize; +#ifdef _DEBUG_ + if ( normPar > 1 || normPar < 0) { + dump("DEBUG"); + cout << "WRONG normPar: "<* points = const_cast*>( &myPoints ); + points->resize( myNbPonits ); + + int EdgeIndex = 0; + double prevNormPar = 0, paramSize = myNormPar[ EdgeIndex ]; + map< double, const SMDS_MeshNode*>::iterator u_node = u2node.begin(); + for (int i = 0 ; u_node != u2node.end(); ++u_node, ++i ) { + UVPtStruct & uvPt = (*points)[i]; + uvPt.node = u_node->second; + uvPt.x = uvPt.y = uvPt.normParam = u_node->first; + if ( isXConst ) uvPt.x = constValue; + else uvPt.y = constValue; + if ( myNormPar[ EdgeIndex ] < uvPt.normParam ) { + prevNormPar = myNormPar[ EdgeIndex ]; + ++EdgeIndex; +#ifdef _DEBUG_ + if ( EdgeIndex >= myEdge.size() ) { + dump("DEBUG"); + cout << "WRONg EdgeIndex " << 1+EdgeIndex + << " myNormPar.size()="<()<() + << " V2: " << TopExp::LastVertex( myEdge[i], 1).TShape().operator->() << endl; + } + cout << "\tC2d: "; + if (myC2d[i].IsNull()) cout<<"NULL"<()<Value2d( U ); } + Standard_Real FirstParameter() const { return 0; } + Standard_Real LastParameter() const { return 1; } +}; + +Adaptor2d_Curve2d* StdMeshers_FaceSide::GetCurve2d() const +{ + return new Adaptor2dCurve2d( this ); +} + +//================================================================================ +/*! + * \brief Creates a fully functional Adaptor_Curve + */ +//================================================================================ + +BRepAdaptor_CompCurve* StdMeshers_FaceSide::GetCurve3d() const +{ + if ( myEdge.empty() ) + return 0; + +// if ( myEdge.size() == 1 ) +// return new BRepAdaptor_Curve( myEdge[0] ); + + TopoDS_Wire aWire; + BRep_Builder aBuilder; + aBuilder.MakeWire(aWire); + for ( int i=0; iValue( myFirst[i] * ( 1 - r ) + myLast[i] * r ); + } + return gp_Pnt2d( 1e+100, 1e+100 ); +} diff --git a/src/StdMeshers/StdMeshers_FaceSide.hxx b/src/StdMeshers/StdMeshers_FaceSide.hxx new file mode 100644 index 000000000..4320bccdc --- /dev/null +++ b/src/StdMeshers/StdMeshers_FaceSide.hxx @@ -0,0 +1,269 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_FaceSide.hxx +// Created : Wed Jan 31 18:41:25 2007 +// Author : Edward AGAPOV (eap) +// Module : SMESH + +#ifndef StdMeshers_FaceSide_HeaderFile +#define StdMeshers_FaceSide_HeaderFile + +#include +#include +#include +#include +#include + +#include +#include +#include + +class SMDS_MeshNode; +class SMESH_Mesh; +class Adaptor2d_Curve2d; +class Adaptor3d_Curve; +class BRepAdaptor_CompCurve; +class TopoDS_Face; + +typedef struct uvPtStruct +{ + double param; + //int curvIndex; + double normParam; + double u; // original 2d parameter + double v; + double x; // 2d parameter, normalized [0,1] + double y; + const SMDS_MeshNode * node; +} UVPtStruct; + +class StdMeshers_FaceSide; +typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr; +typedef boost::shared_ptr< uvPtStruct > UVPtStructPtr; + +//================================================================================ +/*! + * \brief Represents a side of a quasi quadrilateral face. + * It can be composed of several edges. Gives access to geometry and 1D mesh of a side. + */ +//================================================================================ + +class StdMeshers_FaceSide +{ +public: + /*! + * \brief Wrap one edge + */ + StdMeshers_FaceSide(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + SMESH_Mesh* theMesh, + const bool theIsForward); + /*! + * \brief Wrap several edges. Edges must be properly ordered and oriented. + */ + StdMeshers_FaceSide(const TopoDS_Face& theFace, + list& theEdges, + SMESH_Mesh* theMesh, + const bool theIsForward); + /*! + * \brief Change orientation of side geometry + */ + void Reverse(); + /*! + * \brief Return nb nodes on edges including ones on vertices + */ + int NbPoints() const { return myNbPonits; } + /*! + * \brief Return nb nodes on edges including ones on vertices + */ + int NbSegments() const { return myNbSegments; } + /*! + * \brief Return mesh + */ + SMESH_Mesh* GetMesh() const { return myMesh; } + /*! + * \brief Return true if there vertices without nodes + */ + bool MissVertexNode() const { return myMissingVertexNodes; } + /*! + * \brief Return detailed data on nodes + * \param isXConst - true if normalized parameter X is constant + * \param constValue - constant parameter value + * + * Missing nodes are allowed only on internal vertices + */ + const vector& GetUVPtStruct(bool isXConst, double constValue) const; + /*! + * \brief Simulates detailed data on nodes + * \param isXConst - true if normalized parameter X is constant + * \param constValue - constant parameter value + */ + const vector& SimulateUVPtStruct(int nbSeg, + bool isXConst, + double constValue) const; + /*! + * \brief Return edge and parameter on edge by normalized parameter + */ + inline double Parameter(double U, TopoDS_Edge & edge) const; + /*! + * \brief Return UV by normalized parameter + */ + gp_Pnt2d Value2d(double U) const; + /*! + * \brief Creates a Adaptor2d_Curve2d to be used in SMESH_Block + */ + Adaptor2d_Curve2d* GetCurve2d() const; + /*! + * \brief Creates a fully functional Adaptor_Curve + */ + BRepAdaptor_CompCurve* GetCurve3d() const; + /*! + * \brief Return nb of wrapped edges + */ + int NbEdges() const { return myEdge.size(); } + /*! + * \brief Return i-th wrapped edge (count starts from zero) + */ + const TopoDS_Edge& Edge(int i) const { return myEdge[i]; } + /*! + * \brief Return 1st vertex of the i-the edge (count starts from zero) + */ + inline TopoDS_Vertex FirstVertex(int i=0) const; + /*! + * \brief Return last vertex of the i-the edge (count starts from zero) + */ + inline TopoDS_Vertex LastVertex(int i=-1) const; + /*! + * \brief Return first normalized parameter of the i-the edge (count starts from zero) + */ + inline double FirstParameter(int i) const; + /*! + * \brief Return ast normalized parameter of the i-the edge (count starts from zero) + */ + inline double LastParameter(int i) const; + /*! + * \brief Return side length + */ + double Length() const { return myLength; } + /*! + * \brief Return edge index corresponding to normalized parameter + */ + inline int EdgeIndex( double U ) const; + + //virtual gp_Pnt Value(double U) const; + + void dump(const char* msg=0) const; + + +protected: + vector myPoints, myFalsePoints; + vector myEdge; + vector myC2d; + vector myFirst; + vector myLast; + vector myNormPar; + double myLength; + int myNbPonits, myNbSegments; + SMESH_Mesh* myMesh; + bool myMissingVertexNodes; +}; + + +//================================================================================ +/*! + * \brief Return edge index corresponding to normalized parameter + * \param U - the parameter + * \retval int - index + */ +//================================================================================ + +inline int StdMeshers_FaceSide::EdgeIndex( double U ) const +{ + int i = myNormPar.size() - 1; + while ( i > 0 && U < myNormPar[ i-1 ] ) --i; + return i; +} + +//================================================================================ +/*! + * \brief Return edge and parameter on edge by normalized parameter + * \param U - the parameter + * \retval double - pameter on a curve + */ +//================================================================================ + +inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const +{ + int i = EdgeIndex( U ); + edge = myEdge[ i ]; + double prevU = i ? myNormPar[ i-1 ] : 0; + double r = ( U - prevU )/ ( myNormPar[ i ] - prevU ); + return myFirst[i] * ( 1 - r ) + myLast[i] * r; +} + +//================================================================================ +/*! + * \brief Return 1st vertex of the i-the edge + */ +//================================================================================ + +inline TopoDS_Vertex StdMeshers_FaceSide::FirstVertex(int i) const +{ + return i < myEdge.size() ? TopExp::FirstVertex( myEdge[i], 1 ) : TopoDS_Vertex(); +} + +//================================================================================ +/*! + * \brief Return last vertex of the i-the edge + */ +//================================================================================ + +inline TopoDS_Vertex StdMeshers_FaceSide::LastVertex(int i) const +{ + return i<0 ? TopExp::LastVertex( myEdge.back(), 1) : i::const_iterator itl; + + const list &hyps = GetUsedHypothesis(aMesh, aShape); + if ( hyps.size() == 0 ) + { + aStatus = SMESH_Hypothesis::HYP_MISSING; + return false; // can't work with no hypothesis + } + + if ( hyps.size() > 1 ) + { + aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST; + } + else + { + aStatus = SMESH_Hypothesis::HYP_OK; + } + return ( aStatus == HYP_OK ); +} + +//======================================================================= +//function : Compute +//purpose : +//======================================================================= + +bool StdMeshers_SegmentAroundVertex_0D::Compute(SMESH_Mesh&, const TopoDS_Shape&) +{ + // This algorithm exists in order just to enable assignation of + // StdMeshers_SegmentLengthAroundVertex hypothesis + return true; +} diff --git a/src/StdMeshers/StdMeshers_SegmentAroundVertex_0D.hxx b/src/StdMeshers/StdMeshers_SegmentAroundVertex_0D.hxx new file mode 100644 index 000000000..01bf758c7 --- /dev/null +++ b/src/StdMeshers/StdMeshers_SegmentAroundVertex_0D.hxx @@ -0,0 +1,50 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_SegmentAroundVertex_0D.hxx +// Module : SMESH + +#ifndef _SMESH_SegmentAroundVertex_0D_HXX_ +#define _SMESH_SegmentAroundVertex_0D_HXX_ + +#include "SMESH_0D_Algo.hxx" + +/*! + * \brief Algorithm existing in order just to enable assignation of + * StdMeshers_SegmentLengthAroundVertex hypothesis + */ +class StdMeshers_SegmentAroundVertex_0D: public SMESH_0D_Algo +{ +public: + StdMeshers_SegmentAroundVertex_0D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_SegmentAroundVertex_0D(); + + virtual bool CheckHypothesis(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus); + + virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); + +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx new file mode 100644 index 000000000..f44b75574 --- /dev/null +++ b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx @@ -0,0 +1,204 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_SegmentLengthAroundVertex.cxx +// Module : SMESH +// $Header$ + +#include "StdMeshers_SegmentLengthAroundVertex.hxx" + +#include "SMESH_Mesh.hxx" +#include "SMESH_Algo.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESHDS_SubMesh.hxx" +#include "SMESH_MeshEditor.hxx" +#include "SMESH_MesherHelper.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include + +using namespace std; + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_SegmentLengthAroundVertex::StdMeshers_SegmentLengthAroundVertex + (int hypId, int studyId, SMESH_Gen * gen) + :SMESH_Hypothesis(hypId, studyId, gen) +{ + _length = 1.; + _name = "SegmentLengthAroundVertex"; + _param_algo_dim = 0; // is used by StdMeshers_SegmentAroundVertex_0D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_SegmentLengthAroundVertex::~StdMeshers_SegmentLengthAroundVertex() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_SegmentLengthAroundVertex::SetLength(double length) throw(SALOME_Exception) +{ + if (length <= 0) + throw SALOME_Exception(LOCALIZED("length must be positive")); + if (_length != length) { + _length = length; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_SegmentLengthAroundVertex::GetLength() const +{ + return _length; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_SegmentLengthAroundVertex::SaveTo(ostream & save) +{ + save << this->_length; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_SegmentLengthAroundVertex::LoadFrom(istream & load) +{ + bool isOK = true; + double a; + isOK = (load >> a); + if (isOK) + this->_length = a; + else + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_SegmentLengthAroundVertex & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_SegmentLengthAroundVertex & hyp) +{ + return hyp.LoadFrom( load ); +} + +//================================================================================ +/*! + * \brief Initialize segment length by the mesh built on the geometry + * \param theMesh - the built mesh + * \param theShape - the geometry of interest + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_SegmentLengthAroundVertex::SetParametersByMesh(const SMESH_Mesh* theMesh, + const TopoDS_Shape& theShape) +{ + if ( !theMesh || theShape.IsNull() || theShape.ShapeType() != TopAbs_VERTEX ) + return false; + + SMESH_MeshEditor editor( const_cast( theMesh ) ); + SMESH_MesherHelper helper( *editor.GetMesh() ); + + // get node built on theShape vertex + SMESHDS_Mesh* meshDS = editor.GetMeshDS(); + SMESHDS_SubMesh* smV = meshDS->MeshElements( theShape ); + if ( !smV || smV->NbNodes() == 0 ) + return false; + const SMDS_MeshNode* vNode = smV->GetNodes()->next(); + + // calculate average length of segments sharing vNode + + _length = 0.; + int nbSegs = 0; + + SMDS_ElemIteratorPtr segIt = vNode->GetInverseElementIterator(SMDSAbs_Edge); + while ( segIt->more() ) { + const SMDS_MeshElement* seg = segIt->next(); + // get geom edge + int shapeID = editor.FindShape( seg ); + if (!shapeID) continue; + const TopoDS_Shape& s = meshDS->IndexToShape( shapeID ); + if ( s.IsNull() || s.ShapeType() != TopAbs_EDGE ) continue; + const TopoDS_Edge& edge = TopoDS::Edge( s ); + // params of edge ends + double u0 = helper.GetNodeU( edge, seg->GetNode(0) ); + double u1 = helper.GetNodeU( edge, seg->GetNode(1) ); + // length + BRepAdaptor_Curve AdaptCurve( edge ); + _length += GCPnts_AbscissaPoint::Length( AdaptCurve, u0, u1); + nbSegs++; + } + + if ( nbSegs > 1 ) + _length /= nbSegs; + + return nbSegs; +} diff --git a/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx new file mode 100644 index 000000000..a1297c815 --- /dev/null +++ b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx @@ -0,0 +1,66 @@ +// SMESH SMESH : 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_SegmentLengthAroundVertex.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_SegmentLengthAroundVertex_HXX_ +#define _SMESH_SegmentLengthAroundVertex_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +/*! + * \brief This hypothesis specifies length of segments adjacent to the vertex the + * hypothesis is assigned to + */ +class StdMeshers_SegmentLengthAroundVertex:public SMESH_Hypothesis +{ + public: + StdMeshers_SegmentLengthAroundVertex(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_SegmentLengthAroundVertex(); + + void SetLength(double length) throw(SALOME_Exception); + + double GetLength() const; + + virtual std::ostream & SaveTo(std::ostream & save); + virtual std::istream & LoadFrom(std::istream & load); + friend std::ostream & operator <<(std::ostream & save, StdMeshers_SegmentLengthAroundVertex & hyp); + friend std::istream & operator >>(std::istream & load, StdMeshers_SegmentLengthAroundVertex & hyp); + + /*! + * \brief Initialize segment length by the mesh built on the geometry + * \param theMesh - the built mesh + * \param theShape - the geometry of interest + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + + protected: + double _length; +}; + +#endif diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 76a946c65..1be50e5d1 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -172,36 +172,36 @@ void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const } } -//================================================================================ -/*! - * \brief Widget: slider with left and right labels - */ -//================================================================================ +namespace { -class TDoubleSliderWith2Lables: public QHBox -{ -public: - TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel, - const double initValue, const double bottom, - const double top , const double precision, - QWidget * parent=0 , const char * name=0 ) - :QHBox(parent,name), _bottom(bottom), _precision(precision) - { - if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel ); - _slider = new QSlider( Horizontal, this ); - _slider->setRange( 0, toInt( top )); - _slider->setValue( toInt( initValue )); - if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel ); - } - double value() const { return _bottom + _slider->value() * _precision; } - QSlider * getSlider() const { return _slider; } - int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); } -private: - double _bottom, _precision; - QSlider * _slider; -}; + //================================================================================ + /*! + * \brief Widget: slider with left and right labels + */ + //================================================================================ -namespace { + class TDoubleSliderWith2Lables: public QHBox + { + public: + TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel, + const double initValue, const double bottom, + const double top , const double precision, + QWidget * parent=0 , const char * name=0 ) + :QHBox(parent,name), _bottom(bottom), _precision(precision) + { + if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel ); + _slider = new QSlider( Horizontal, this ); + _slider->setRange( 0, toInt( top )); + _slider->setValue( toInt( initValue )); + if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel ); + } + double value() const { return _bottom + _slider->value() * _precision; } + QSlider * getSlider() const { return _slider; } + int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); } + private: + double _bottom, _precision; + QSlider * _slider; + }; //================================================================================ /*! @@ -381,6 +381,13 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetLength( params[0].myValue.toDouble() ); } + else if( hypType()=="SegmentLengthAroundVertex" ) + { + StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h = + StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() ); + + h->SetLength( params[0].myValue.toDouble() ); + } else if( hypType()=="Arithmetic1D" ) { StdMeshers::StdMeshers_Arithmetic1D_var h = @@ -521,6 +528,15 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myValue = h->GetLength(); p.append( item ); } + else if( hypType()=="SegmentLengthAroundVertex" ) + { + StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h = + StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp ); + + item.myName = tr("SMESH_LOCAL_LENGTH_PARAM"); + item.myValue = h->GetLength(); + p.append( item ); + } else if( hypType()=="Arithmetic1D" ) { StdMeshers::StdMeshers_Arithmetic1D_var h = @@ -777,6 +793,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" ); types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" ); types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" ); + types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" ); } QString res; diff --git a/src/StdMeshersGUI/StdMeshers_images.po b/src/StdMeshersGUI/StdMeshers_images.po index 5c8ff756a..05a570ec9 100644 --- a/src/StdMeshersGUI/StdMeshers_images.po +++ b/src/StdMeshersGUI/StdMeshers_images.po @@ -41,6 +41,9 @@ msgstr "select1.png" msgid "ICON_DLG_LOCAL_LENGTH" msgstr "mesh_hypo_length.png" +msgid "ICON_DLG_SEGMENT_LENGTH_AROUND_VERTEX" +msgstr "mesh_hypo_length.png" + msgid "ICON_DLG_NB_SEGMENTS" msgstr "mesh_hypo_segment.png" @@ -88,6 +91,9 @@ msgstr "mesh_hypo_source_3d.png" msgid "ICON_SMESH_TREE_ALGO_Regular_1D" msgstr "mesh_tree_algo_regular.png" +msgid "ICON_SMESH_TREE_ALGO_CompositeSegment_1D" +msgstr "mesh_tree_algo_regular.png" + msgid "ICON_SMESH_TREE_ALGO_Hexa_3D" msgstr "mesh_tree_algo_hexa.png" @@ -166,3 +172,9 @@ msgstr "mesh_tree_hypo_source_face.png" msgid "ICON_SMESH_TREE_HYPO_ProjectionSource3D" msgstr "mesh_tree_hypo_source_3d_shape.png" + +msgid "ICON_SMESH_TREE_ALGO_SegmentAroundVertex_0D" +msgstr "mesh_tree_algo_regular.png" + +msgid "ICON_SMESH_TREE_HYPO_SegmentLengthAroundVertex" +msgstr "mesh_tree_hypo_length.png" diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.po b/src/StdMeshersGUI/StdMeshers_msg_en.po index b1842159e..922119e14 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.po +++ b/src/StdMeshersGUI/StdMeshers_msg_en.po @@ -256,3 +256,15 @@ msgstr "Create" msgid "StdMeshersGUI_LayerDistributionParamWdg::EDIT" msgstr "Edit" + +# -------------- Segment Length Around Vertex -------------- + +msgid "SMESH_SEGMENT_LENGTH_AROUND_VERTEX_HYPOTHESIS" +msgstr "Segment Length Around Vertex" + +msgid "SMESH_SEGMENT_LENGTH_AROUND_VERTEX_PARAM" +msgstr "Length" + +msgid "SMESH_SEGMENT_LENGTH_AROUND_VERTEX_TITLE" +msgstr "Hypothesis Construction" + diff --git a/src/StdMeshers_I/Makefile.in b/src/StdMeshers_I/Makefile.in index ad995c7e1..f96b813b5 100644 --- a/src/StdMeshers_I/Makefile.in +++ b/src/StdMeshers_I/Makefile.in @@ -61,7 +61,8 @@ EXPORT_HEADERS = \ StdMeshers_ProjectionSource3D_i.hxx \ StdMeshers_Projection_1D_2D_3D_i.hxx \ StdMeshers_ObjRefUlils.hxx \ - StdMeshers_LayerDistribution_i.hxx + StdMeshers_LayerDistribution_i.hxx \ + StdMeshers_CompositeSegment_1D_i.hxx # Libraries targets @@ -93,7 +94,10 @@ LIB_SRC = \ StdMeshers_ProjectionSource3D_i.cxx \ StdMeshers_Projection_1D_2D_3D_i.cxx \ StdMeshers_ObjRefUlils.cxx \ - StdMeshers_LayerDistribution_i.cxx + StdMeshers_LayerDistribution_i.cxx \ + StdMeshers_SegmentAroundVertex_0D_i.cxx \ + StdMeshers_SegmentLengthAroundVertex_i.cxx \ + StdMeshers_CompositeSegment_1D_i.cxx LIB_SERVER_IDL = SMESH_BasicHypothesis.idl diff --git a/src/StdMeshers_I/StdMeshers_CompositeSegment_1D_i.cxx b/src/StdMeshers_I/StdMeshers_CompositeSegment_1D_i.cxx new file mode 100644 index 000000000..b8b0126f2 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_CompositeSegment_1D_i.cxx @@ -0,0 +1,85 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_CompositeSegment_1D_i.cxx +// Module : SMESH +// $Header$ + +#include "StdMeshers_CompositeSegment_1D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +using namespace std; + +//============================================================================= +/*! + * StdMeshers_CompositeSegment_1D_i::StdMeshers_CompositeSegment_1D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_CompositeSegment_1D_i::StdMeshers_CompositeSegment_1D_i + ( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_1D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_CompositeSegment_1D_i::StdMeshers_CompositeSegment_1D_i" ); + myBaseImpl = new ::StdMeshers_CompositeSegment_1D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_CompositeSegment_1D_i::~StdMeshers_CompositeSegment_1D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_CompositeSegment_1D_i::~StdMeshers_CompositeSegment_1D_i() +{ + MESSAGE( "StdMeshers_CompositeSegment_1D_i::~StdMeshers_CompositeSegment_1D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_CompositeSegment_1D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_CompositeSegment_1D* StdMeshers_CompositeSegment_1D_i::GetImpl() +{ + MESSAGE( "StdMeshers_CompositeSegment_1D_i::GetImpl" ); + return ( ::StdMeshers_CompositeSegment_1D* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_CompositeSegment_1D_i.hxx b/src/StdMeshers_I/StdMeshers_CompositeSegment_1D_i.hxx new file mode 100644 index 000000000..d2d3ddc80 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_CompositeSegment_1D_i.hxx @@ -0,0 +1,56 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_CompositeSegment_1D_i.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESH_CompositeSegment_1D_I_HXX_ +#define _SMESH_CompositeSegment_1D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_1D_Algo_i.hxx" +#include "StdMeshers_CompositeSegment_1D.hxx" + +// ====================================================== +// Wire Discretization 1d algorithm +// ====================================================== +class StdMeshers_CompositeSegment_1D_i: + public virtual POA_StdMeshers::StdMeshers_CompositeSegment_1D, + public virtual SMESH_1D_Algo_i +{ +public: + // Constructor + StdMeshers_CompositeSegment_1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_CompositeSegment_1D_i(); + + // Get implementation + ::StdMeshers_CompositeSegment_1D* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_SegmentAroundVertex_0D_i.cxx b/src/StdMeshers_I/StdMeshers_SegmentAroundVertex_0D_i.cxx new file mode 100644 index 000000000..8e4ff3001 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_SegmentAroundVertex_0D_i.cxx @@ -0,0 +1,71 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_Projection_3D_i.cxx +// Moved here from SMESH_Projection_3D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#include "StdMeshers_SegmentAroundVertex_0D_i.hxx" + +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +using namespace std; + +//============================================================================= +/*! + * StdMeshers_SegmentAroundVertex_0D_i::StdMeshers_SegmentAroundVertex_0D_i + */ +//============================================================================= + +StdMeshers_SegmentAroundVertex_0D_i::StdMeshers_SegmentAroundVertex_0D_i + ( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_0D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_SegmentAroundVertex_0D_i::StdMeshers_SegmentAroundVertex_0D_i" ); + myBaseImpl = new ::StdMeshers_SegmentAroundVertex_0D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} +//----------------------------------------------------------------------------- + +StdMeshers_SegmentAroundVertex_0D_i::~StdMeshers_SegmentAroundVertex_0D_i() +{ + MESSAGE( "StdMeshers_SegmentAroundVertex_0D_i::~StdMeshers_SegmentAroundVertex_0D_i" ); +} +//----------------------------------------------------------------------------- + +::StdMeshers_SegmentAroundVertex_0D* StdMeshers_SegmentAroundVertex_0D_i::GetImpl() +{ + MESSAGE( "StdMeshers_SegmentAroundVertex_0D_i::GetImpl" ); + return ( ::StdMeshers_SegmentAroundVertex_0D* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_SegmentAroundVertex_0D_i.hxx b/src/StdMeshers_I/StdMeshers_SegmentAroundVertex_0D_i.hxx new file mode 100644 index 000000000..5f42d62e8 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_SegmentAroundVertex_0D_i.hxx @@ -0,0 +1,57 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_SegmentAroundVertex_0D.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESH_SegmentAroundVertex_0D_I_HXX_ +#define _SMESH_SegmentAroundVertex_0D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_0D_Algo_i.hxx" +#include "StdMeshers_SegmentAroundVertex_0D.hxx" + +class SMESH_Gen; + +class StdMeshers_SegmentAroundVertex_0D_i: + public virtual POA_StdMeshers::StdMeshers_SegmentAroundVertex_0D, + public virtual SMESH_0D_Algo_i +{ +public: + // Constructor + StdMeshers_SegmentAroundVertex_0D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_SegmentAroundVertex_0D_i(); + + // Get implementation + ::StdMeshers_SegmentAroundVertex_0D* GetImpl(); +}; + + +#endif diff --git a/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx new file mode 100644 index 000000000..42a5c4199 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx @@ -0,0 +1,140 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_SegmentLengthAroundVertex_i.cxx +// Module : SMESH +// $Header$ + +#include "StdMeshers_SegmentLengthAroundVertex_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +using namespace std; + +//============================================================================= +/*! + * StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i + ( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i" ); + myBaseImpl = new ::StdMeshers_SegmentLengthAroundVertex( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_SegmentLengthAroundVertex_i::~StdMeshers_SegmentLengthAroundVertex_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_SegmentLengthAroundVertex_i::~StdMeshers_SegmentLengthAroundVertex_i() +{ + MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::~StdMeshers_SegmentLengthAroundVertex_i" ); +} + +//============================================================================= +/*! + * StdMeshers_SegmentLengthAroundVertex_i::SetLength + * + * Set length + */ +//============================================================================= + +void StdMeshers_SegmentLengthAroundVertex_i::SetLength( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::SetLength" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetLength( theLength ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM ); + } + + // Update Python script + SMESH::TPythonDump() << _this() << ".SetLength( " << theLength << " )"; +} + +//============================================================================= +/*! + * StdMeshers_SegmentLengthAroundVertex_i::GetLength + * + * Get length + */ +//============================================================================= + +CORBA::Double StdMeshers_SegmentLengthAroundVertex_i::GetLength() +{ + MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::GetLength" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetLength(); +} + +//============================================================================= +/*! + * StdMeshers_SegmentLengthAroundVertex_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_SegmentLengthAroundVertex* StdMeshers_SegmentLengthAroundVertex_i::GetImpl() +{ + MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::GetImpl" ); + return ( ::StdMeshers_SegmentLengthAroundVertex* )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_SegmentLengthAroundVertex_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_1D; +} + diff --git a/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx new file mode 100644 index 000000000..f7be90303 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx @@ -0,0 +1,70 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_SegmentLengthAroundVertex_i.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESH_SegmentLengthAroundVertex_I_HXX_ +#define _SMESH_SegmentLengthAroundVertex_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_SegmentLengthAroundVertex.hxx" + +class SMESH_Gen; + +/*! + * \brief This hypothesis specifies length of segments adjacent to the vertex the + * hypothesis is assigned to + */ +class StdMeshers_SegmentLengthAroundVertex_i: + public virtual POA_StdMeshers::StdMeshers_SegmentLengthAroundVertex, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_SegmentLengthAroundVertex_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_SegmentLengthAroundVertex_i(); + + // Set length + void SetLength( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ); + + // Get length + CORBA::Double GetLength(); + + // Get implementation + ::StdMeshers_SegmentLengthAroundVertex* 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 00ffe482f..de71171cf 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -43,20 +43,21 @@ using namespace std; #include "StdMeshers_MaxElementArea_i.hxx" #include "StdMeshers_MaxElementVolume_i.hxx" #include "StdMeshers_NotConformAllowed_i.hxx" - #include "StdMeshers_ProjectionSource3D_i.hxx" #include "StdMeshers_ProjectionSource2D_i.hxx" #include "StdMeshers_ProjectionSource1D_i.hxx" #include "StdMeshers_NumberOfLayers_i.hxx" #include "StdMeshers_LayerDistribution_i.hxx" +#include "StdMeshers_SegmentLengthAroundVertex_i.hxx" #include "StdMeshers_Regular_1D_i.hxx" #include "StdMeshers_MEFISTO_2D_i.hxx" #include "StdMeshers_Quadrangle_2D_i.hxx" #include "StdMeshers_Hexa_3D_i.hxx" - #include "StdMeshers_Projection_1D_2D_3D_i.hxx" #include "StdMeshers_Prism_3D_i.hxx" +#include "StdMeshers_SegmentAroundVertex_0D_i.hxx" +#include "StdMeshers_CompositeSegment_1D_i.hxx" template class StdHypothesisCreator_i:public HypothesisCreator_i @@ -116,6 +117,8 @@ extern "C" aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "LayerDistribution") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "SegmentLengthAroundVertex") == 0) + aCreator = new StdHypothesisCreator_i; // Algorithms else if (strcmp(aHypName, "Regular_1D") == 0) @@ -136,6 +139,10 @@ extern "C" aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "RadialPrism_3D") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "SegmentAroundVertex_0D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "CompositeSegment_1D") == 0) + aCreator = new StdHypothesisCreator_i; else ; return aCreator;