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