Salome HOME
Abu : Mise a jour HEXABLOCK
[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 HexaExport 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    VertexShape* findVertex   (double point[]);
55    EdgeShape*   findEdge     (int subid);
56    EdgeShape*   findEdge     (double p1[], double p2[]);
57    FaceShape*   findFace     (int subid);
58
59    SubShape*    findSubShape (int subid);
60
61
62    const TopoDS_Shape& getGeoShape (int subid);
63
64    int   saveBrep ();
65    void  saveXml  (XmlWriter* xml);
66
67    void openShape ();
68    int  addCircle (double* center, double rad, double* norm, double* base);
69    int  addSphere (double* center, double radius);
70    int  transfoShape   (Matrix& matrix, SubShape* shape);
71    int  translateShape (double  dir[],  SubShape* shape);
72    void closeShape();
73
74 private :
75    int  updateShape ();
76    int  updateBrep  ();
77                                 // ---------------------------- Parcours
78    void parseShape  (const TopoDS_Shape& shape);
79    void push_level  ()     { sh_level ++ ; }
80    void pop_level   ()     { sh_level -- ; }
81    void addSubShape (const TopoDS_Shape& shape);
82
83 private :     // ________________________________________________________
84    TopoDS_Shape    geo_shape;
85
86    EnumShape    sh_origin;
87    string       geo_brep;
88    bool         brep_defined, shape_defined;
89
90    TopTools_IndexedMapOfShape map_shape;
91    std::vector <FaceShape*>    tab_face;
92    std::vector <EdgeShape*>    tab_edge;
93    std::vector <VertexShape*>  tab_vertex;
94
95                          // Pour Construire les shapes internes
96    int curr_subid;
97    TopoDS_Compound geo_compound;
98    BRep_Builder    geo_builder;
99
100    std::vector <Vertex*>  asso_vertex;
101    Quads      asso_quad;
102    Edges      asso_edge;
103    RealVector asso_pmin, asso_pmax, asso_param;
104    IntVector  asso_edid, asso_quid, asso_vxid;
105                          // Pour le parsing
106    int sh_level;
107    int sh_indice;
108    int sh_face_max;
109    int sh_edge_max;
110    int sh_vertex_max;
111 #endif
112 };
113 END_NAMESPACE_HEXA
114 #endif