Salome HOME
0020695: EDF 1076 GEOM: Add a new shape in GEOM: T-shape
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PipeTShapeDriver.hxx
1 //  Copyright (C) 2007-2008  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_PipeTShapeDriver_HXX
23 #define _GEOMImpl_PipeTShapeDriver_HXX
24
25 #include <TFunction_Driver.hxx>
26
27 #include "GEOMAlgo_State.hxx"
28
29 #include <TopTools_ListOfShape.hxx>
30 #include <TopTools_HSequenceOfShape.hxx>
31 #include <TopTools_IndexedMapOfShape.hxx>
32 #include <TopAbs_ShapeEnum.hxx>
33 #include <TColStd_HSequenceOfInteger.hxx>
34
35 #include <Handle_Geom_Surface.hxx>
36
37 class Handle_Standard_Type;
38 class GEOMImpl_PipeTShapeDriver;
39
40 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PipeTShapeDriver);
41
42 class Handle(GEOMImpl_PipeTShapeDriver) : public Handle(TFunction_Driver) {
43 public:
44   inline void* operator new(size_t,void* anAddress) 
45   {
46     return anAddress;
47   }
48   inline void* operator new(size_t size) 
49   { 
50     return Standard::Allocate(size); 
51   }
52   inline void  operator delete(void *anAddress) 
53   { 
54     if (anAddress) Standard::Free((Standard_Address&)anAddress); 
55   }
56   
57   Handle(GEOMImpl_PipeTShapeDriver)():Handle(TFunction_Driver)() {} 
58   Handle(GEOMImpl_PipeTShapeDriver)(const Handle(GEOMImpl_PipeTShapeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) 
59   {}
60
61   Handle(GEOMImpl_PipeTShapeDriver)(const GEOMImpl_PipeTShapeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) 
62   {}
63
64   Handle(GEOMImpl_PipeTShapeDriver)& operator=(const Handle(GEOMImpl_PipeTShapeDriver)& aHandle)
65   {
66     Assign(aHandle.Access());
67     return *this;
68   }
69   
70   Handle(GEOMImpl_PipeTShapeDriver)& operator=(const GEOMImpl_PipeTShapeDriver* anItem)
71   {
72     Assign((Standard_Transient *)anItem);
73     return *this;
74   }
75   
76   GEOMImpl_PipeTShapeDriver* operator->() 
77   {
78     return (GEOMImpl_PipeTShapeDriver *)ControlAccess();
79   }
80   
81   GEOMImpl_PipeTShapeDriver* operator->() const 
82   {
83     return (GEOMImpl_PipeTShapeDriver *)ControlAccess();
84   }
85   
86   Standard_EXPORT ~Handle(GEOMImpl_PipeTShapeDriver)() {};
87   
88   Standard_EXPORT static const Handle(GEOMImpl_PipeTShapeDriver) DownCast(const Handle(Standard_Transient)& AnObject);
89 };
90
91 class GEOMImpl_PipeTShapeDriver : public TFunction_Driver {
92 public:
93   inline void* operator new(size_t,void* anAddress) 
94   {
95     return anAddress;
96   }
97   inline void* operator new(size_t size) 
98   { 
99     return Standard::Allocate(size); 
100   }
101   inline void  operator delete(void *anAddress) 
102   { 
103     if (anAddress) Standard::Free((Standard_Address&)anAddress); 
104   }
105   
106   // Methods PUBLIC
107   // 
108   Standard_EXPORT GEOMImpl_PipeTShapeDriver();
109   Standard_EXPORT virtual  Standard_Integer Execute(TFunction_Logbook& log) const; 
110   Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
111   Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const
112   {
113     return Standard_True;
114   }
115   Standard_EXPORT static const Standard_GUID& GetID();
116   Standard_EXPORT ~GEOMImpl_PipeTShapeDriver() {};
117   
118   // Type management
119   //
120   Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PipeTShapeDriver_Type_();
121   Standard_EXPORT const Handle(Standard_Type)& DynamicType() const
122   {
123     return STANDARD_TYPE(GEOMImpl_PipeTShapeDriver);
124   }
125   Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
126   {
127     return (STANDARD_TYPE(GEOMImpl_PipeTShapeDriver) == AType || TFunction_Driver::IsKind(AType));
128   }
129 private:
130   /*!
131    * \brief Create a T-Shape based on pipes
132    * \param r1 - the internal radius of main pipe
133    * \param w1 - the thickness main pipe
134    * \param l1 - the half-length of main pipe
135    * \param r2 - the internal radius of incident pipe
136    * \param w2 - the thickness incident pipe
137    * \param l2 - the half-length of main pipe
138    * \retval TopoDS_Shape - Resulting shape
139    */
140   TopoDS_Shape MakePipeTShape(double r1, double w1, double l1, double r2, double w2, double l2) const;
141
142   /*!
143    * \brief Create a quarter of a T-Shape based on pipes
144    * \param r1 - the internal radius of main pipe
145    * \param w1 - the thickness main pipe
146    * \param l1 - the half-length of main pipe
147    * \param r2 - the internal radius of incident pipe
148    * \param w2 - the thickness incident pipe
149    * \param l2 - the half-length of main pipe
150    * \retval TopoDS_Shape - Resulting shape
151    */
152   TopoDS_Shape MakeQuarterPipeTShape(double r1, double w1, double l1, double r2, double w2, double l2) const;
153
154 //=======================================================================
155 //function : GetShapesOnSurfaceIDs
156   /*!
157    * \brief Find IDs of subshapes complying with given status about surface
158    * \param theSurface - the surface to check state of subshapes against
159    * \param theShape - the shape to explore
160    * \param theShapeType - type of subshape of theShape
161    * \param theState - required state
162    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
163    */
164   Handle(TColStd_HSequenceOfInteger)
165     GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
166                           const TopoDS_Shape&         theShape,
167                           TopAbs_ShapeEnum            theShapeType,
168                           GEOMAlgo_State              theState) const;
169 //=======================================================================
170 //function : getShapesOnBoxIDs
171   /*!
172    * \brief Find IDs of subshapes complying with given status about surface
173     * \param theBox - the box to check state of subshapes against
174     * \param theShape - the shape to explore
175     * \param theShapeType - type of subshape of theShape
176     * \param theState - required state
177     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
178    */
179 //=======================================================================
180   Handle(TColStd_HSequenceOfInteger)
181   GetShapesOnBoxIDs(const TopoDS_Shape& aBox,
182                  const TopoDS_Shape& aShape,
183                  const Standard_Integer theShapeType,
184                  GEOMAlgo_State theState) const;
185
186   //=======================================================================
187   //function : getCommonShapesOnCylinders
188   //purpose  : return the common edge between 2 cylindrical surfaces
189   //           along OX and OZ
190   //=======================================================================
191   void GetCommonShapesOnCylinders(const TopoDS_Shape& theShape,
192                                   TopAbs_ShapeEnum theShapeType,
193                   double r, double r2,
194                                   Handle(TopTools_HSequenceOfShape)& commonShapes) const;
195
196 };
197
198 #endif // _GEOMImpl_PipeTShapeDriver_HXX