Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "StdMeshers_ProjectionSource1D.hxx"
00029
00030 #include "SMESH_Mesh.hxx"
00031
00032 #include "utilities.h"
00033
00034 #include <TopoDS.hxx>
00035
00036 using namespace std;
00037
00038
00039
00045
00046
00047 StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D(int hypId, int studyId,
00048 SMESH_Gen * gen)
00049 : SMESH_Hypothesis(hypId, studyId, gen)
00050 {
00051 _name = "ProjectionSource1D";
00052 _param_algo_dim = 1;
00053 _sourceMesh = 0;
00054 }
00055
00056
00062
00063
00064 StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D()
00065 {
00066 MESSAGE( "StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D" );
00067 }
00068
00069
00073
00074
00075 void StdMeshers_ProjectionSource1D::SetSourceEdge(const TopoDS_Shape& edge)
00076 throw ( SALOME_Exception )
00077 {
00078 if ( edge.IsNull() )
00079 throw SALOME_Exception(LOCALIZED("Null edge is not allowed"));
00080
00081 if ( edge.ShapeType() != TopAbs_EDGE && edge.ShapeType() != TopAbs_COMPOUND )
00082 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
00083
00084 if ( !_sourceEdge.IsSame( edge ) )
00085 {
00086 _sourceEdge = edge;
00087
00088 NotifySubMeshesHypothesisModification();
00089 }
00090 }
00091
00092
00097
00098
00099 void StdMeshers_ProjectionSource1D::SetVertexAssociation(const TopoDS_Shape& sourceVertex,
00100 const TopoDS_Shape& targetVertex)
00101 throw ( SALOME_Exception )
00102 {
00103 if ( sourceVertex.IsNull() != targetVertex.IsNull() )
00104 throw SALOME_Exception(LOCALIZED("Two or none vertices must be provided"));
00105
00106 if ( !sourceVertex.IsNull() ) {
00107 if ( sourceVertex.ShapeType() != TopAbs_VERTEX ||
00108 targetVertex.ShapeType() != TopAbs_VERTEX )
00109 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
00110 }
00111
00112 if ( !_sourceVertex.IsSame( sourceVertex ) ||
00113 !_targetVertex.IsSame( targetVertex ) )
00114 {
00115 _sourceVertex = TopoDS::Vertex( sourceVertex );
00116 _targetVertex = TopoDS::Vertex( targetVertex );
00117
00118 NotifySubMeshesHypothesisModification();
00119 }
00120 }
00121
00122
00126
00127
00128 void StdMeshers_ProjectionSource1D::SetSourceMesh(SMESH_Mesh* mesh)
00129 {
00130 if ( _sourceMesh != mesh ) {
00131 _sourceMesh = mesh;
00132 NotifySubMeshesHypothesisModification();
00133 }
00134 }
00135
00136
00140
00141
00142 ostream & StdMeshers_ProjectionSource1D::SaveTo(ostream & save)
00143 {
00144
00145 save << " " << _sourceEdge.TShape().operator->() ;
00146 save << " " << _sourceVertex.TShape().operator->();
00147 save << " " << _targetVertex.TShape().operator->();
00148 save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
00149 return save;
00150 }
00151
00152
00156
00157
00158 istream & StdMeshers_ProjectionSource1D::LoadFrom(istream & load)
00159 {
00160
00161 return load;
00162 }
00163
00164
00168
00169
00170 ostream & operator <<(ostream & save, StdMeshers_ProjectionSource1D & hyp)
00171 {
00172 return hyp.SaveTo( save );
00173 }
00174
00175
00179
00180
00181 istream & operator >>(istream & load, StdMeshers_ProjectionSource1D & hyp)
00182 {
00183 return hyp.LoadFrom( load );
00184 }
00185
00186
00193
00194
00195 bool StdMeshers_ProjectionSource1D::SetParametersByMesh(const SMESH_Mesh* ,
00196 const TopoDS_Shape& )
00197 {
00198 return false;
00199 }
00200
00201
00205
00206
00207 void StdMeshers_ProjectionSource1D::GetStoreParams(TopoDS_Shape& s1,
00208 TopoDS_Shape& s2,
00209 TopoDS_Shape& s3) const
00210 {
00211 s1 = _sourceEdge;
00212 s2 = _sourceVertex;
00213 s3 = _targetVertex;
00214 }
00215
00216
00220
00221
00222 void StdMeshers_ProjectionSource1D::RestoreParams(const TopoDS_Shape& s1,
00223 const TopoDS_Shape& s2,
00224 const TopoDS_Shape& s3,
00225 SMESH_Mesh* mesh)
00226 {
00227 _sourceEdge = s1;
00228 _sourceVertex = TopoDS::Vertex( s2 );
00229 _targetVertex = TopoDS::Vertex( s3 );
00230 _sourceMesh = mesh;
00231 }
00232
00233
00238
00239
00240 bool StdMeshers_ProjectionSource1D::SetParametersByDefaults(const TDefaults& ,
00241 const SMESH_Mesh* )
00242 {
00243 return false;
00244 }
00245