1 // SMESH SMESH : idl implementation based on 'SMESH' unit's classes
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : StdMeshers_ProjectionSource1D.cxx
25 // Author : Edward AGAPOV
29 #include "StdMeshers_ProjectionSource1D.hxx"
31 #include "SMESH_Mesh.hxx"
33 #include "utilities.h"
40 //=============================================================================
42 * StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D
46 //=============================================================================
48 StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D(int hypId, int studyId,
50 : SMESH_Hypothesis(hypId, studyId, gen)
52 _name = "ProjectionSource1D"; // used by Projection_1D
53 _param_algo_dim = 1; // 1D
57 //=============================================================================
59 * StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D
63 //=============================================================================
65 StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D()
67 MESSAGE( "StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D" );
70 //=============================================================================
72 * Sets source <edge> to take a mesh pattern from
74 //=============================================================================
76 void StdMeshers_ProjectionSource1D::SetSourceEdge(const TopoDS_Shape& edge)
77 throw ( SALOME_Exception )
80 throw SALOME_Exception(LOCALIZED("Null edge is not allowed"));
82 if ( edge.ShapeType() != TopAbs_EDGE )
83 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
85 if ( !_sourceEdge.IsSame( edge ) )
87 _sourceEdge = TopoDS::Edge( edge );
89 NotifySubMeshesHypothesisModification();
93 //=============================================================================
95 * Sets vertex association between the source edge and the target one.
96 * This parameter is optional
98 //=============================================================================
100 void StdMeshers_ProjectionSource1D::SetVertexAssociation(const TopoDS_Shape& sourceVertex,
101 const TopoDS_Shape& targetVertex)
102 throw ( SALOME_Exception )
104 if ( sourceVertex.IsNull() != targetVertex.IsNull() )
105 throw SALOME_Exception(LOCALIZED("Two or none vertices must be provided"));
107 if ( !sourceVertex.IsNull() ) {
108 if ( sourceVertex.ShapeType() != TopAbs_VERTEX ||
109 targetVertex.ShapeType() != TopAbs_VERTEX )
110 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
113 if ( !_sourceVertex.IsSame( sourceVertex ) ||
114 !_targetVertex.IsSame( targetVertex ) )
116 _sourceVertex = TopoDS::Vertex( sourceVertex );
117 _targetVertex = TopoDS::Vertex( targetVertex );
119 NotifySubMeshesHypothesisModification();
123 //=============================================================================
127 //=============================================================================
129 ostream & StdMeshers_ProjectionSource1D::SaveTo(ostream & save)
131 // we store it in order to be able to detect that hypo is really modified
132 save << " " << _sourceEdge.TShape().operator->() ;
133 save << " " << _sourceVertex.TShape().operator->();
134 save << " " << _targetVertex.TShape().operator->();
135 save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
139 //=============================================================================
143 //=============================================================================
145 istream & StdMeshers_ProjectionSource1D::LoadFrom(istream & load)
147 // impossible to restore w/o any context
151 //=============================================================================
155 //=============================================================================
157 ostream & operator <<(ostream & save, StdMeshers_ProjectionSource1D & hyp)
159 return hyp.SaveTo( save );
162 //=============================================================================
166 //=============================================================================
168 istream & operator >>(istream & load, StdMeshers_ProjectionSource1D & hyp)
170 return hyp.LoadFrom( load );
173 //================================================================================
175 * \brief Initialize start and end length by the mesh built on the geometry
176 * \param theMesh - the built mesh
177 * \param theShape - the geometry of interest
178 * \retval bool - true if parameter values have been successfully defined
180 //================================================================================
182 bool StdMeshers_ProjectionSource1D::SetParametersByMesh(const SMESH_Mesh* ,
183 const TopoDS_Shape& )
188 //================================================================================
190 * \brief Return all parameters
192 //================================================================================
194 void StdMeshers_ProjectionSource1D::GetStoreParams(TopoDS_Shape& s1,
196 TopoDS_Shape& s3) const
203 //================================================================================
205 * \brief Set all parameters without notifying on modification
207 //================================================================================
209 void StdMeshers_ProjectionSource1D::RestoreParams(const TopoDS_Shape& s1,
210 const TopoDS_Shape& s2,
211 const TopoDS_Shape& s3,
214 _sourceEdge = TopoDS::Edge( s1 );
215 _sourceVertex = TopoDS::Vertex( s2 );
216 _targetVertex = TopoDS::Vertex( s3 );