Salome HOME
Merge from V6_main (04/10/2012)
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IBlocksOperations.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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 #ifndef _GEOMImpl_IBlocksOperations_HXX_
23 #define _GEOMImpl_IBlocksOperations_HXX_
24
25 #include "GEOM_IOperations.hxx"
26
27 #include <TopTools_ListOfShape.hxx>
28 #include <TColStd_HSequenceOfTransient.hxx>
29
30 #include <list>
31
32 class GEOM_Engine;
33 class Handle(GEOM_Object);
34 class Handle(TColStd_HArray1OfInteger);
35
36 class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
37  public:
38   Standard_EXPORT GEOMImpl_IBlocksOperations(GEOM_Engine* theEngine, int theDocID);
39   Standard_EXPORT ~GEOMImpl_IBlocksOperations();
40
41   // Creation of blocks and block faces
42   Standard_EXPORT Handle(GEOM_Object) MakeQuad (Handle(GEOM_Object) theEdge1,
43                                                 Handle(GEOM_Object) theEdge2,
44                                                 Handle(GEOM_Object) theEdge3,
45                                                 Handle(GEOM_Object) theEdge4);
46
47   Standard_EXPORT Handle(GEOM_Object) MakeQuad2Edges (Handle(GEOM_Object) theEdge1,
48                                                       Handle(GEOM_Object) theEdge2);
49
50   Standard_EXPORT Handle(GEOM_Object) MakeQuad4Vertices (Handle(GEOM_Object) thePoint1,
51                                                          Handle(GEOM_Object) thePoint2,
52                                                          Handle(GEOM_Object) thePoint3,
53                                                          Handle(GEOM_Object) thePoint4);
54
55   Standard_EXPORT Handle(GEOM_Object) MakeHexa (Handle(GEOM_Object) theFace1,
56                                                 Handle(GEOM_Object) theFace2,
57                                                 Handle(GEOM_Object) theFace3,
58                                                 Handle(GEOM_Object) theFace4,
59                                                 Handle(GEOM_Object) theFace5,
60                                                 Handle(GEOM_Object) theFace6);
61
62   Standard_EXPORT Handle(GEOM_Object) MakeHexa2Faces (Handle(GEOM_Object) theFace1,
63                                                       Handle(GEOM_Object) theFace2);
64
65   Standard_EXPORT Handle(GEOM_Object) MakeBlockCompound (Handle(GEOM_Object) theCompound);
66
67   // Extract elements of blocks and blocks compounds
68   Standard_EXPORT Handle(GEOM_Object) GetPoint (Handle(GEOM_Object) theShape,
69                                                 const Standard_Real theX,
70                                                 const Standard_Real theY,
71                                                 const Standard_Real theZ,
72                                                 const Standard_Real theEpsilon);
73
74   Standard_EXPORT Handle(GEOM_Object) GetVertexNearPoint (Handle(GEOM_Object) theShape,
75                                                           Handle(GEOM_Object) thePoint);
76
77   Standard_EXPORT Handle(GEOM_Object) GetEdge (Handle(GEOM_Object) theShape,
78                                                Handle(GEOM_Object) thePoint1,
79                                                Handle(GEOM_Object) thePoint2);
80
81   Standard_EXPORT Handle(GEOM_Object) GetEdgeNearPoint (Handle(GEOM_Object) theBlock,
82                                                         Handle(GEOM_Object) thePoint);
83
84   Standard_EXPORT Handle(GEOM_Object) GetFaceByPoints (Handle(GEOM_Object) theShape,
85                                                        Handle(GEOM_Object) thePoint1,
86                                                        Handle(GEOM_Object) thePoint2,
87                                                        Handle(GEOM_Object) thePoint3,
88                                                        Handle(GEOM_Object) thePoint4);
89
90   Standard_EXPORT Handle(GEOM_Object) GetFaceByEdges (Handle(GEOM_Object) theShape,
91                                                       Handle(GEOM_Object) theEdge1,
92                                                       Handle(GEOM_Object) theEdge2);
93
94   Standard_EXPORT Handle(GEOM_Object) GetOppositeFace (Handle(GEOM_Object) theBlock,
95                                                        Handle(GEOM_Object) theFace);
96
97   Standard_EXPORT Handle(GEOM_Object) GetFaceNearPoint (Handle(GEOM_Object) theBlock,
98                                                         Handle(GEOM_Object) thePoint);
99
100   Standard_EXPORT Handle(GEOM_Object) GetFaceByNormale (Handle(GEOM_Object) theBlock,
101                                                         Handle(GEOM_Object) theVector);
102
103   Standard_EXPORT Handle(GEOM_Object) GetShapesNearPoint (Handle(GEOM_Object)    theShape,
104                                                           Handle(GEOM_Object)    thePoint,
105                                                           const Standard_Integer theShapeType,
106                                                           const Standard_Real    theTolerance);
107
108   // Check blocks compounds
109   Standard_EXPORT Standard_Boolean IsCompoundOfBlocks (Handle(GEOM_Object)    theCompound,
110                                                        const Standard_Integer theMinNbFaces,
111                                                        const Standard_Integer theMaxNbFaces,
112                                                        Standard_Integer&      theNbBlocks);
113
114   enum BCErrorType {
115     NOT_BLOCK,
116     EXTRA_EDGE,
117     INVALID_CONNECTION,
118     NOT_CONNECTED,
119     NOT_GLUED
120   };
121
122   struct BCError {
123     BCErrorType error;
124     std::list<int>   incriminated;
125   };
126
127   Standard_EXPORT Standard_Boolean CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound,
128                                                              std::list<BCError>& theErrors);
129
130   Standard_EXPORT Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound,
131                                                           std::list<BCError>& theErrors);
132
133   Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object)       theCompound,
134                                                          const std::list<BCError>& theErrors);
135
136   Standard_EXPORT Handle(GEOM_Object) GetNonBlocks (Handle(GEOM_Object) theShape,
137                                                     Handle(GEOM_Object)& theNonQuads);
138
139   Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
140                                                         const Standard_Integer theOptimumNbFaces = 6);
141
142   Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);
143
144   Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape&   theShape,
145                                              TopTools_ListOfShape& BLO,
146                                              TopTools_ListOfShape& NOT,
147                                              TopTools_ListOfShape& EXT,
148                                              TopTools_ListOfShape& NOQ);
149
150   // Extract blocks from blocks compounds
151   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks
152                                       (Handle(GEOM_Object)    theCompound,
153                                        const Standard_Integer theMinNbFaces,
154                                        const Standard_Integer theMaxNbFaces);
155
156   Standard_EXPORT Handle(GEOM_Object) GetBlockNearPoint (Handle(GEOM_Object) theCompound,
157                                                          Handle(GEOM_Object) thePoint);
158
159   Standard_EXPORT Handle(GEOM_Object) GetBlockByParts
160                      (Handle(GEOM_Object)                         theCompound,
161                       const Handle(TColStd_HSequenceOfTransient)& theParts);
162
163   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetBlocksByParts
164                      (Handle(GEOM_Object)                         theCompound,
165                       const Handle(TColStd_HSequenceOfTransient)& theParts);
166
167   // Operations on blocks with gluing of result
168   Standard_EXPORT Handle(GEOM_Object) MakeMultiTransformation1D (Handle(GEOM_Object)    theBlock,
169                                                                  const Standard_Integer theDirFace1,
170                                                                  const Standard_Integer theDirFace2,
171                                                                  const Standard_Integer theNbTimes);
172
173   Standard_EXPORT Handle(GEOM_Object) MakeMultiTransformation2D (Handle(GEOM_Object)    theBlock,
174                                                                  const Standard_Integer theDirFace1U,
175                                                                  const Standard_Integer theDirFace2U,
176                                                                  const Standard_Integer theNbTimesU,
177                                                                  const Standard_Integer theDirFace1V,
178                                                                  const Standard_Integer theDirFace2V,
179                                                                  const Standard_Integer theNbTimesV);
180
181   // Build groups for Propagation of 1D hypotheses
182   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Propagate (Handle(GEOM_Object) theShape);
183 };
184
185 #endif