Salome HOME
Merge from V6_main 01/04/2013
[modules/hexablock.git] / src / HEXABLOCK / HexNewShape.hxx
1
2 // class : Gestion des formes associees (Hexa 5)
3
4 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef __NEW_SHAPE_H_
24 #define __NEW_SHAPE_H_
25
26 #include "HexEltBase.hxx"
27
28 #ifndef NO_CASCADE
29 #include <TopTools_IndexedMapOfShape.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopoDS_Compound.hxx>
32 #include <BRep_Builder.hxx>
33 #endif
34
35 BEGIN_NAMESPACE_HEXA
36
37 class NewShape : public EltBase
38 {
39 public :         // for TUI
40    virtual int countVertex ()   { return tab_vertex.size ();  }
41    virtual int countEdge   ()   { return tab_edge.size ();    }
42    virtual int countFace   ()   { return tab_face.size ();    }
43
44    int getVertex (int nro);
45    int getEdge   (int nro);
46    int getFace   (int nro);
47
48    cpchar getNameVertex  (int nro);
49    cpchar getNameEdge    (int nro);
50    cpchar getNameFace    (int nro);
51
52    const string&       getBrep ();
53    const TopoDS_Shape& getShape ();
54
55 public :         // for GUI
56    EnumShape    getOrigin ()        { return sh_origin ; }
57    VertexShape* getVertexShape (int nro);
58    EdgeShape*   getEdgeShape (int nro);
59    FaceShape*   getFaceShape (int nro);
60
61 public :         // for Others
62    NewShape (Document* dad, EnumShape type=SH_NONE);
63    void  setShape (const TopoDS_Shape& shape, EnumShape type=SH_IMPORT);
64    void  setBrep  (rcstring brep);
65    int   addPoint (double* coord);
66    void  addAssociation (Vertex* elt, int subid, double param);
67    void  addAssociation (Edge*   elt, int subid, double pmin, double pmax);
68    void  addAssociation (Quad*   elt, int subid);
69
70    VertexShape* findVertex   (int subid);
71    EdgeShape*   findEdge     (int subid);
72    FaceShape*   findFace     (int subid);
73
74    SubShape*    findSubShape (int subid);
75
76    const TopoDS_Shape& getGeoShape (int subid);
77
78    int   saveBrep ();
79    void  saveXml  (XmlWriter* xml);
80
81    void openShape ();
82    int  addCircle (double* center, double rad, double* norm, double* base);
83    int  addSphere (double* center, double radius);
84    void closeShape();
85
86 private :
87    int  updateShape ();
88    int  updateBrep  ();
89                                 // ---------------------------- Parcours
90    void parseShape  (const TopoDS_Shape& shape);
91    void push_level  ()     { sh_level ++ ; }
92    void pop_level   ()     { sh_level -- ; }
93    void addSubShape (const TopoDS_Shape& shape);
94
95 private :     // ________________________________________________________
96    TopoDS_Shape    geo_shape;
97
98    EnumShape    sh_origin;
99    string       geo_brep;
100    bool         brep_defined, shape_defined;
101
102    TopTools_IndexedMapOfShape map_shape;
103    std::vector <FaceShape*>    tab_face;
104    std::vector <EdgeShape*>    tab_edge;
105    std::vector <VertexShape*>  tab_vertex;
106
107                          // Pour Construire les shapes internes
108    int curr_subid;
109    TopoDS_Compound geo_compound;
110    BRep_Builder    geo_builder;
111
112    std::vector <Vertex*>  asso_vertex;
113    Quads      asso_quad;
114    Edges      asso_edge;
115    RealVector asso_pmin, asso_pmax, asso_param;
116    IntVector  asso_edid, asso_quid, asso_vxid;
117                          // Pour le parsing
118    int sh_level;
119    int sh_indice;
120    int sh_face_max;
121    int sh_edge_max;
122    int sh_vertex_max;
123 };
124 END_NAMESPACE_HEXA
125 #endif