Salome HOME
Merge from V5_1_main 14/05/2010
[modules/smesh.git] / src / StdMeshers / StdMeshers_QuadrangleParams.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  SMESH SMESH : implementaion of SMESH idl descriptions
21 //  File   : StdMeshers_QuadrangleParams.cxx
22 //  Author : Sergey KUUL, OCC
23 //  Module : SMESH
24 //
25 #include "StdMeshers_QuadrangleParams.hxx"
26
27 #include "SMESH_Algo.hxx"
28 #include "SMESH_Mesh.hxx"
29
30 #include <BRep_Tool.hxx>
31 #include <GCPnts_AbscissaPoint.hxx>
32 #include <GeomAdaptor_Curve.hxx>
33 #include <Geom_Curve.hxx>
34 #include <TopExp.hxx>
35 #include <TopLoc_Location.hxx>
36 #include <TopTools_IndexedMapOfShape.hxx>
37 #include <TopoDS.hxx>
38 #include <TopoDS_Edge.hxx>
39
40 using namespace std;
41
42 //=============================================================================
43 /*!
44  *  
45  */
46 //=============================================================================
47
48 StdMeshers_QuadrangleParams::StdMeshers_QuadrangleParams(int hypId, int studyId,
49                                                          SMESH_Gen * gen)
50   :SMESH_Hypothesis(hypId, studyId, gen)
51 {
52   _name = "QuadrangleParams";
53   _param_algo_dim = 2;
54   _triaVertexID = -1;
55 }
56
57 //=============================================================================
58 /*!
59  *  
60  */
61 //=============================================================================
62
63 StdMeshers_QuadrangleParams::~StdMeshers_QuadrangleParams()
64 {
65 }
66
67 //=============================================================================
68 /*!
69  *  
70  */
71 //=============================================================================
72
73 void StdMeshers_QuadrangleParams::SetTriaVertex(int id)
74 {
75   if ( id != _triaVertexID ) {
76     _triaVertexID = id;
77     NotifySubMeshesHypothesisModification();
78   }
79 }
80
81 //=============================================================================
82 /*!
83  *  
84  */
85 //=============================================================================
86
87 ostream & StdMeshers_QuadrangleParams::SaveTo(ostream & save)
88 {
89   save << _triaVertexID << " " << _objEntry;
90   return save;
91 }
92
93 //=============================================================================
94 /*!
95  *  
96  */
97 //=============================================================================
98
99 istream & StdMeshers_QuadrangleParams::LoadFrom(istream & load)
100 {
101   bool isOK = true;
102   isOK = (load >> _triaVertexID);
103   if (!isOK)
104     load.clear(ios::badbit | load.rdstate());
105
106   isOK = (load >> _objEntry);
107
108   return load;
109 }
110
111 //=============================================================================
112 /*!
113  *  
114  */
115 //=============================================================================
116
117 ostream & operator <<(ostream & save, StdMeshers_QuadrangleParams & hyp)
118 {
119   return hyp.SaveTo( save );
120 }
121
122 //=============================================================================
123 /*!
124  *  
125  */
126 //=============================================================================
127
128 istream & operator >>(istream & load, StdMeshers_QuadrangleParams & hyp)
129 {
130   return hyp.LoadFrom( load );
131 }
132
133 //================================================================================
134 /*!
135  * \brief Redifined method
136  * \param theMesh - the built mesh
137  * \param theShape - the geometry of interest
138  * \retval bool - true if parameter values have been successfully defined
139  */
140 //================================================================================
141
142 bool StdMeshers_QuadrangleParams::SetParametersByMesh(const SMESH_Mesh* theMesh,
143                                                       const TopoDS_Shape& theShape)
144 {
145   if ( !theMesh || theShape.IsNull() )
146     return false;
147
148   return true;
149 }
150
151 //================================================================================
152 /*!
153  * \brief Initialize my parameter values by default parameters.
154  *  \retval bool - true if parameter values have been successfully defined
155  */
156 //================================================================================
157
158 bool StdMeshers_QuadrangleParams::SetParametersByDefaults(const TDefaults&  dflts,
159                                                           const SMESH_Mesh* /*mesh*/)
160 {
161   return true;
162 }
163