Salome HOME
1793f85214996753ff47773580d799c957f0c752
[modules/hexablock.git] / src / HEXABLOCK / HexNewShape.hxx
1
2 // class : Gestion des formes associees (Hexa 5)
3
4 #ifndef __NEW_SHAPE_H_
5 #define __NEW_SHAPE_H_
6
7 #include "HexEltBase.hxx"
8
9 #include <TopTools_IndexedMapOfShape.hxx>
10 #include <TopoDS_Shape.hxx>
11 #include <TopoDS_Compound.hxx>
12 #include <BRep_Builder.hxx>
13
14 BEGIN_NAMESPACE_HEXA
15
16 class NewShape : public EltBase
17 {
18 public :         // for TUI
19    virtual int countVertex ()   { return tab_vertex.size ();  }
20    virtual int countEdge   ()   { return tab_edge.size ();    }
21    virtual int countFace   ()   { return tab_face.size ();    }
22
23    int getVertex (int nro);
24    int getEdge   (int nro);
25    int getFace   (int nro);
26
27    cpchar getNameVertex  (int nro);
28    cpchar getNameEdge    (int nro);
29    cpchar getNameFace    (int nro);
30
31    const string&       getBrep ();
32    const TopoDS_Shape& getShape ();
33
34 public :         // for GUI
35    EnumShape    getOrigin ()        { return sh_origin ; }
36    VertexShape* getVertexShape (int nro);
37    EdgeShape*   getEdgeShape (int nro);
38    FaceShape*   getFaceShape (int nro);
39
40 public :         // for Others
41    NewShape (Document* dad, EnumShape type=SH_NONE);
42    void  setShape (const TopoDS_Shape& shape, EnumShape type=SH_IMPORT);
43    void  setBrep  (rcstring brep);
44    int   addPoint (double* coord);
45    void  addAssociation (Vertex* elt, int subid, double param);
46    void  addAssociation (Edge*   elt, int subid, double pmin, double pmax);
47    void  addAssociation (Quad*   elt, int subid);
48
49    VertexShape* findVertex   (int subid);
50    EdgeShape*   findEdge     (int subid);
51    FaceShape*   findFace     (int subid);
52
53    SubShape*    findSubShape (int subid);
54
55    const TopoDS_Shape& getGeoShape (int subid);
56
57    int   saveBrep ();
58    void  saveXml  (XmlWriter* xml);
59
60    void openShape ();
61    int  addCircle (double* center, double rad, double* norm, double* base);
62    int  addSphere (double* center, double radius);
63    int  transfoShape   (Matrix& matrix, SubShape* shape);
64    int  translateShape (double  dir[],  SubShape* shape);
65    void closeShape();
66
67 private :
68    int  updateShape ();
69    int  updateBrep  ();
70                                 // ---------------------------- Parcours
71    void parseShape  (const TopoDS_Shape& shape);
72    void push_level  ()     { sh_level ++ ; }
73    void pop_level   ()     { sh_level -- ; }
74    void addSubShape (const TopoDS_Shape& shape);
75
76 private :     // ________________________________________________________
77    TopoDS_Shape    geo_shape;
78
79    EnumShape    sh_origin;
80    string       geo_brep;
81    bool         brep_defined, shape_defined;
82
83    TopTools_IndexedMapOfShape map_shape;
84    std::vector <FaceShape*>    tab_face;
85    std::vector <EdgeShape*>    tab_edge;
86    std::vector <VertexShape*>  tab_vertex;
87
88                          // Pour Construire les shapes internes
89    int curr_subid;
90    TopoDS_Compound geo_compound;
91    BRep_Builder    geo_builder;
92
93    std::vector <Vertex*>  asso_vertex;
94    Quads      asso_quad;
95    Edges      asso_edge;
96    RealVector asso_pmin, asso_pmax, asso_param;
97    IntVector  asso_edid, asso_quid, asso_vxid;
98                          // Pour le parsing
99    int sh_level;
100    int sh_indice;
101    int sh_face_max;
102    int sh_edge_max;
103    int sh_vertex_max;
104 };
105 END_NAMESPACE_HEXA
106 #endif