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