1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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
23 // SMESH SMESH : idl implementation based on 'SMESH' unit's classes
24 // File : StdMeshers_ProjectionSource1D.cxx
25 // Author : Edward AGAPOV
28 #include "StdMeshers_ProjectionSource1D.hxx"
30 #include "SMESH_Mesh.hxx"
32 #include "utilities.h"
39 //=============================================================================
41 * StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D
45 //=============================================================================
47 StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D(int hypId,
49 : SMESH_Hypothesis(hypId, gen)
51 _name = "ProjectionSource1D"; // used by Projection_1D
52 _param_algo_dim = 1; // 1D
56 //=============================================================================
58 * StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D
62 //=============================================================================
64 StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D()
68 //=============================================================================
70 * Sets source <edge> to take a mesh pattern from
72 //=============================================================================
74 void StdMeshers_ProjectionSource1D::SetSourceEdge(const TopoDS_Shape& edge)
75 throw ( SALOME_Exception )
78 throw SALOME_Exception(LOCALIZED("Null edge is not allowed"));
80 if ( edge.ShapeType() != TopAbs_EDGE && edge.ShapeType() != TopAbs_COMPOUND )
81 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
83 if ( !_sourceEdge.IsSame( edge ) )
87 NotifySubMeshesHypothesisModification();
91 //=============================================================================
93 * Sets vertex association between the source edge and the target one.
94 * This parameter is optional
96 //=============================================================================
98 void StdMeshers_ProjectionSource1D::SetVertexAssociation(const TopoDS_Shape& sourceVertex,
99 const TopoDS_Shape& targetVertex)
100 throw ( SALOME_Exception )
102 if ( sourceVertex.IsNull() != targetVertex.IsNull() )
103 throw SALOME_Exception(LOCALIZED("Two or none vertices must be provided"));
105 if ( !sourceVertex.IsNull() ) {
106 if ( sourceVertex.ShapeType() != TopAbs_VERTEX ||
107 targetVertex.ShapeType() != TopAbs_VERTEX )
108 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
111 if ( !_sourceVertex.IsSame( sourceVertex ) ||
112 !_targetVertex.IsSame( targetVertex ) )
114 _sourceVertex = TopoDS::Vertex( sourceVertex );
115 _targetVertex = TopoDS::Vertex( targetVertex );
117 NotifySubMeshesHypothesisModification();
121 //=============================================================================
123 * Sets source <mesh> to take a mesh pattern from
125 //=============================================================================
127 void StdMeshers_ProjectionSource1D::SetSourceMesh(SMESH_Mesh* mesh)
129 if ( _sourceMesh != mesh ) {
131 NotifySubMeshesHypothesisModification();
135 //=============================================================================
139 //=============================================================================
141 ostream & StdMeshers_ProjectionSource1D::SaveTo(ostream & save)
143 // we store it in order to be able to detect that hypo is really modified
144 save << " " << _sourceEdge.TShape().operator->() ;
145 save << " " << _sourceVertex.TShape().operator->();
146 save << " " << _targetVertex.TShape().operator->();
147 save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
151 //=============================================================================
155 //=============================================================================
157 istream & StdMeshers_ProjectionSource1D::LoadFrom(istream & load)
159 // impossible to restore w/o any context
163 //=============================================================================
167 //=============================================================================
169 ostream & operator <<(ostream & save, StdMeshers_ProjectionSource1D & hyp)
171 return hyp.SaveTo( save );
174 //=============================================================================
178 //=============================================================================
180 istream & operator >>(istream & load, StdMeshers_ProjectionSource1D & hyp)
182 return hyp.LoadFrom( load );
185 //================================================================================
187 * \brief Initialize start and end length by the mesh built on the geometry
188 * \param theMesh - the built mesh
189 * \param theShape - the geometry of interest
190 * \retval bool - true if parameter values have been successfully defined
192 //================================================================================
194 bool StdMeshers_ProjectionSource1D::SetParametersByMesh(const SMESH_Mesh* ,
195 const TopoDS_Shape& )
200 //================================================================================
202 * \brief Return all parameters
204 //================================================================================
206 void StdMeshers_ProjectionSource1D::GetStoreParams(TopoDS_Shape& s1,
208 TopoDS_Shape& s3) const
215 //================================================================================
217 * \brief Set all parameters without notifying on modification
219 //================================================================================
221 void StdMeshers_ProjectionSource1D::RestoreParams(const TopoDS_Shape& s1,
222 const TopoDS_Shape& s2,
223 const TopoDS_Shape& s3,
227 _sourceVertex = TopoDS::Vertex( s2 );
228 _targetVertex = TopoDS::Vertex( s3 );
232 //================================================================================
234 * \brief Initialize my parameter values by default parameters.
235 * \retval bool - true if parameter values have been successfully defined
237 //================================================================================
239 bool StdMeshers_ProjectionSource1D::SetParametersByDefaults(const TDefaults& /*dflts*/,
240 const SMESH_Mesh* /*theMesh*/)