Salome HOME
c0e106364bfd9c4f44f25efd20ae83a2a9d590a3
[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 //  SMESH SMESH : implementaion of SMESH idl descriptions
20 //  File   : StdMeshers_QuadrangleParams.cxx
21 //  Author : Sergey KUUL, OCC
22 //  Module : SMESH
23
24 #include "StdMeshers_QuadrangleParams.hxx"
25
26 #include "SMESH_Algo.hxx"
27 #include "SMESH_Mesh.hxx"
28
29 #include <BRep_Tool.hxx>
30 #include <GCPnts_AbscissaPoint.hxx>
31 #include <GeomAdaptor_Curve.hxx>
32 #include <Geom_Curve.hxx>
33 #include <TopExp.hxx>
34 #include <TopLoc_Location.hxx>
35 #include <TopTools_IndexedMapOfShape.hxx>
36 #include <TopoDS.hxx>
37 #include <TopoDS_Edge.hxx>
38
39 using namespace std;
40
41 //=============================================================================
42 /*!
43  *
44  */
45 //=============================================================================
46 StdMeshers_QuadrangleParams::StdMeshers_QuadrangleParams(int hypId, int studyId,
47                                                          SMESH_Gen * gen)
48   : SMESH_Hypothesis(hypId, studyId, gen)
49 {
50   _name = "QuadrangleParams";
51   _param_algo_dim = 2;
52   _triaVertexID = -1;
53   _quadType = QUAD_STANDARD;
54 }
55
56 //=============================================================================
57 /*!
58  *
59  */
60 //=============================================================================
61 StdMeshers_QuadrangleParams::~StdMeshers_QuadrangleParams()
62 {
63 }
64
65 //=============================================================================
66 /*!
67  *
68  */
69 //=============================================================================
70 void StdMeshers_QuadrangleParams::SetTriaVertex (int id)
71 {
72   if (id != _triaVertexID) {
73     _triaVertexID = id;
74     NotifySubMeshesHypothesisModification();
75   }
76 }
77
78 //=============================================================================
79 /*!
80  *
81  */
82 //=============================================================================
83 void StdMeshers_QuadrangleParams::SetQuadType (StdMeshers_QuadType type)
84 {
85   if (type != _quadType) {
86     _quadType = type;
87     NotifySubMeshesHypothesisModification();
88   }
89 }
90
91 //=============================================================================
92 /*!
93  *
94  */
95 //=============================================================================
96 ostream & StdMeshers_QuadrangleParams::SaveTo(ostream & save)
97 {
98   if (_objEntry.size() == 0)
99     save << _triaVertexID << " UNDEFINED " << int(_quadType);
100   else
101     save << _triaVertexID << " " << _objEntry << " " << int(_quadType);
102   return save;
103 }
104
105 //=============================================================================
106 /*!
107  *
108  */
109 //=============================================================================
110 istream & StdMeshers_QuadrangleParams::LoadFrom(istream & load)
111 {
112   bool isOK = true;
113   isOK = (load >> _triaVertexID);
114   if (!isOK)
115     load.clear(ios::badbit | load.rdstate());
116
117   isOK = (load >> _objEntry);
118   if (!isOK)
119     load.clear(ios::badbit | load.rdstate());
120
121   int type;
122   isOK = (load >> type);
123   if (isOK)
124     _quadType = StdMeshers_QuadType(type);
125
126   return load;
127 }
128
129 //=============================================================================
130 /*!
131  *
132  */
133 //=============================================================================
134 ostream & operator <<(ostream & save, StdMeshers_QuadrangleParams & hyp)
135 {
136   return hyp.SaveTo( save );
137 }
138
139 //=============================================================================
140 /*!
141  *
142  */
143 //=============================================================================
144 istream & operator >>(istream & load, StdMeshers_QuadrangleParams & hyp)
145 {
146   return hyp.LoadFrom( load );
147 }
148
149 //================================================================================
150 /*!
151  * \brief Redifined method
152  * \param theMesh - the built mesh
153  * \param theShape - the geometry of interest
154  * \retval bool - true if parameter values have been successfully defined
155  */
156 //================================================================================
157 bool StdMeshers_QuadrangleParams::SetParametersByMesh(const SMESH_Mesh* theMesh,
158                                                       const TopoDS_Shape& theShape)
159 {
160   if ( !theMesh || theShape.IsNull() )
161     return false;
162
163   return true;
164 }
165
166 //================================================================================
167 /*!
168  * \brief Initialize my parameter values by default parameters.
169  *  \retval bool - true if parameter values have been successfully defined
170  */
171 //================================================================================
172 bool StdMeshers_QuadrangleParams::SetParametersByDefaults(const TDefaults&  dflts,
173                                                           const SMESH_Mesh* /*mesh*/)
174 {
175   return true;
176 }