Salome HOME
653d0f532882a5a43c16007c4de84226d9e585c1
[modules/hexablock.git] / src / HEXABLOCK / HexNewShape.hxx
1
2 // class : Gestion des formes associees (Hexa 5)
3
4 // Copyright (C) 2009-2023  CEA, EDF
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, or (at your option) any later version.
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 SWIG
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 HexaExport 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    NewShape (Document* dad, EnumShape type=SH_NONE);
53
54 #ifndef SWIG
55 public :         // for GUI
56    cpchar              getBrep ();
57    const TopoDS_Shape& getShape ();
58
59    EnumShape    getOrigin ()        { return sh_origin ; }
60    VertexShape* getVertexShape (int nro);
61    EdgeShape*   getEdgeShape (int nro);
62    FaceShape*   getFaceShape (int nro);
63
64 public :         // for Others
65    void  setShape (const TopoDS_Shape& shape, EnumShape type=SH_IMPORT);
66    void  setBrep  (rcstring brep);
67    int   addPoint (double* coord);
68    void  addAssociation (Vertex* elt, int subid, double param);
69    void  addAssociation (Edge*   elt, int subid, double pmin, double pmax);
70    void  addAssociation (Quad*   elt, int subid);
71
72    VertexShape* findVertex   (int subid);
73    VertexShape* findVertex   (double point[]);
74    EdgeShape*   findEdge     (int subid);
75    EdgeShape*   findEdge     (double p1[], double p2[]);
76    FaceShape*   findFace     (int subid);
77
78    SubShape*    findSubShape (int subid);
79
80
81    const TopoDS_Shape& getGeoShape (int subid);
82
83    int   saveBrep ();
84    void  saveXml  (XmlWriter* xml);
85
86    void openShape ();
87    int  addCircle (double* center, double rad, double* norm, double* base);
88    int  addSphere (double* center, double radius);
89    int  transfoShape   (Matrix& matrix, SubShape* shape);
90    int  translateShape (double  dir[],  SubShape* shape);
91    void closeShape();
92
93 private :
94    int  updateShape ();
95    int  updateBrep  ();
96                                 // ---------------------------- Parcours
97    void parseShape  (const TopoDS_Shape& shape);
98    void push_level  ()     { sh_level ++ ; }
99    void pop_level   ()     { sh_level -- ; }
100    void addSubShape (const TopoDS_Shape& shape);
101
102 private :     // ________________________________________________________
103    TopoDS_Shape    geo_shape;
104
105    EnumShape    sh_origin;
106    std::string  geo_brep;
107    bool         brep_defined, shape_defined;
108
109    TopTools_IndexedMapOfShape map_shape;
110    std::vector <FaceShape*>    tab_face;
111    std::vector <EdgeShape*>    tab_edge;
112    std::vector <VertexShape*>  tab_vertex;
113
114                          // Pour Construire les shapes internes
115    int curr_subid;
116    TopoDS_Compound geo_compound;
117    BRep_Builder    geo_builder;
118
119    std::vector <Vertex*>  asso_vertex;
120    Quads      asso_quad;
121    Edges      asso_edge;
122    RealVector asso_pmin, asso_pmax, asso_param;
123    IntVector  asso_edid, asso_quid, asso_vxid;
124                          // Pour le parsing
125    int sh_level;
126    int sh_indice;
127    int sh_face_max;
128    int sh_edge_max;
129    int sh_vertex_max;
130 #endif
131 };
132 END_NAMESPACE_HEXA
133 #endif