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_ProjectionSource2D.hxx"
00029
00030 #include "SMESH_Mesh.hxx"
00031
00032 #include "utilities.h"
00033
00034 #include <TopoDS.hxx>
00035
00036 using namespace std;
00037
00038
00044
00045
00046 StdMeshers_ProjectionSource2D::StdMeshers_ProjectionSource2D(int hypId, int studyId,
00047 SMESH_Gen * gen)
00048 : SMESH_Hypothesis(hypId, studyId, gen)
00049 {
00050 _name = "ProjectionSource2D";
00051 _param_algo_dim = 2;
00052 _sourceMesh = 0;
00053 }
00054
00055
00061
00062
00063 StdMeshers_ProjectionSource2D::~StdMeshers_ProjectionSource2D()
00064 {
00065 MESSAGE( "StdMeshers_ProjectionSource2D::~StdMeshers_ProjectionSource2D" );
00066 }
00067
00068
00072
00073
00074 void StdMeshers_ProjectionSource2D::SetSourceFace(const TopoDS_Shape& Face)
00075 throw ( SALOME_Exception )
00076 {
00077 if ( Face.IsNull() )
00078 throw SALOME_Exception(LOCALIZED("Null Face is not allowed"));
00079
00080 if ( Face.ShapeType() != TopAbs_FACE && Face.ShapeType() != TopAbs_COMPOUND )
00081 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
00082
00083 if ( !_sourceFace.IsSame( Face ) )
00084 {
00085 _sourceFace = Face;
00086
00087 NotifySubMeshesHypothesisModification();
00088 }
00089 }
00090
00091
00097
00098
00099 void StdMeshers_ProjectionSource2D::SetVertexAssociation(const TopoDS_Shape& sourceVertex1,
00100 const TopoDS_Shape& sourceVertex2,
00101 const TopoDS_Shape& targetVertex1,
00102 const TopoDS_Shape& targetVertex2)
00103 throw ( SALOME_Exception )
00104 {
00105 if ( sourceVertex1.IsNull() != targetVertex1.IsNull() ||
00106 sourceVertex2.IsNull() != targetVertex2.IsNull() ||
00107 sourceVertex1.IsNull() != targetVertex2.IsNull() )
00108 throw SALOME_Exception(LOCALIZED("Two or none pairs of vertices must be provided"));
00109
00110 if ( !sourceVertex1.IsNull() ) {
00111 if ( sourceVertex1.ShapeType() != TopAbs_VERTEX ||
00112 sourceVertex2.ShapeType() != TopAbs_VERTEX ||
00113 targetVertex1.ShapeType() != TopAbs_VERTEX ||
00114 targetVertex2.ShapeType() != TopAbs_VERTEX )
00115 throw SALOME_Exception(LOCALIZED("Wrong shape type"));
00116 }
00117
00118 if ( !_sourceVertex1.IsSame( sourceVertex1 ) ||
00119 !_sourceVertex2.IsSame( sourceVertex2 ) ||
00120 !_targetVertex1.IsSame( targetVertex1 ) ||
00121 !_targetVertex2.IsSame( targetVertex2 ) )
00122 {
00123 _sourceVertex1 = TopoDS::Vertex( sourceVertex1 );
00124 _sourceVertex2 = TopoDS::Vertex( sourceVertex2 );
00125 _targetVertex1 = TopoDS::Vertex( targetVertex1 );
00126 _targetVertex2 = TopoDS::Vertex( targetVertex2 );
00127
00128 NotifySubMeshesHypothesisModification();
00129 }
00130 }
00131
00132
00136
00137
00138 void StdMeshers_ProjectionSource2D::SetSourceMesh(SMESH_Mesh* mesh)
00139 {
00140 if ( _sourceMesh != mesh ) {
00141 _sourceMesh = mesh;
00142 NotifySubMeshesHypothesisModification();
00143 }
00144 }
00145
00146
00150
00151
00152 TopoDS_Shape StdMeshers_ProjectionSource2D::GetSourceFace() const
00153 {
00154 return _sourceFace;
00155 }
00156
00157
00162
00163
00164 TopoDS_Vertex StdMeshers_ProjectionSource2D::GetSourceVertex(int i) const
00165 throw ( SALOME_Exception )
00166 {
00167 if ( i == 1 )
00168 return _sourceVertex1;
00169 else if ( i == 2 )
00170 return _sourceVertex2;
00171 else
00172 throw SALOME_Exception(LOCALIZED("Wrong vertex index"));
00173 }
00174
00175
00180
00181
00182 TopoDS_Vertex StdMeshers_ProjectionSource2D::GetTargetVertex(int i) const
00183 throw ( SALOME_Exception )
00184 {
00185 if ( i == 1 )
00186 return _targetVertex1;
00187 else if ( i == 2 )
00188 return _targetVertex2;
00189 else
00190 throw SALOME_Exception(LOCALIZED("Wrong vertex index"));
00191 }
00192
00193
00197
00198
00199 ostream & StdMeshers_ProjectionSource2D::SaveTo(ostream & save)
00200 {
00201
00202 save << " " << _sourceFace.TShape().operator->() ;
00203 save << " " << _sourceVertex1.TShape().operator->();
00204 save << " " << _targetVertex1.TShape().operator->();
00205 save << " " << _sourceVertex2.TShape().operator->();
00206 save << " " << _targetVertex2.TShape().operator->();
00207 save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
00208 return save;
00209 }
00210
00211
00215
00216
00217 istream & StdMeshers_ProjectionSource2D::LoadFrom(istream & load)
00218 {
00219
00220
00221 return load;
00222 }
00223
00224
00228
00229
00230 ostream & operator <<(ostream & save, StdMeshers_ProjectionSource2D & hyp)
00231 {
00232 return hyp.SaveTo( save );
00233 }
00234
00235
00239
00240
00241 istream & operator >>(istream & load, StdMeshers_ProjectionSource2D & hyp)
00242 {
00243 return hyp.LoadFrom( load );
00244 }
00245
00246
00253
00254
00255 bool StdMeshers_ProjectionSource2D::SetParametersByMesh(const SMESH_Mesh* ,
00256 const TopoDS_Shape& )
00257 {
00258 return false;
00259 }
00260
00261
00265
00266
00267 void StdMeshers_ProjectionSource2D::GetStoreParams(TopoDS_Shape& s1,
00268 TopoDS_Shape& s2,
00269 TopoDS_Shape& s3,
00270 TopoDS_Shape& s4,
00271 TopoDS_Shape& s5) const
00272 {
00273 s1 = _sourceFace;
00274 s2 = _sourceVertex1;
00275 s3 = _sourceVertex2;
00276 s4 = _targetVertex1;
00277 s5 = _targetVertex2;
00278 }
00279
00280
00284
00285
00286 void StdMeshers_ProjectionSource2D::RestoreParams(const TopoDS_Shape& s1,
00287 const TopoDS_Shape& s2,
00288 const TopoDS_Shape& s3,
00289 const TopoDS_Shape& s4,
00290 const TopoDS_Shape& s5,
00291 SMESH_Mesh* mesh)
00292 {
00293 _sourceFace = s1;
00294 _sourceVertex1 = TopoDS::Vertex( s2 );
00295 _sourceVertex2 = TopoDS::Vertex( s3 );
00296 _targetVertex1 = TopoDS::Vertex( s4 );
00297 _targetVertex2 = TopoDS::Vertex( s5 );
00298 _sourceMesh = mesh;
00299 }
00300
00301
00306
00307
00308 bool StdMeshers_ProjectionSource2D::SetParametersByDefaults(const TDefaults& ,
00309 const SMESH_Mesh* )
00310 {
00311 return false;
00312 }
00313