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