Salome HOME
19196fedff9fc45db852d8cd6cfd05029f1e9107
[modules/geom.git] / src / GEOMImpl / GEOMImpl_PipeTShapeDriver.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
19 #ifndef _GEOMImpl_PipeTShapeDriver_HXX
20 #define _GEOMImpl_PipeTShapeDriver_HXX
21
22 #include <TFunction_Driver.hxx>
23
24 #include "GEOMAlgo_State.hxx"
25
26 #include <TopAbs_ShapeEnum.hxx>
27 #include <TopTools_ListOfShape.hxx>
28 #include <TopTools_HSequenceOfShape.hxx>
29 #include <TopTools_IndexedMapOfShape.hxx>
30 #include <TColStd_HSequenceOfInteger.hxx>
31 #include <gp_Ax2.hxx>
32
33 #include <Handle_Geom_Surface.hxx>
34
35 class Handle_Standard_Type;
36 class GEOMImpl_PipeTShapeDriver;
37
38 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PipeTShapeDriver);
39
40 class Handle(GEOMImpl_PipeTShapeDriver) : public Handle(TFunction_Driver) {
41 public:
42   inline void* operator new(size_t,void* anAddress) 
43   {
44     return anAddress;
45   }
46   inline void* operator new(size_t size) 
47   { 
48     return Standard::Allocate(size); 
49   }
50   inline void  operator delete(void *anAddress) 
51   { 
52     if (anAddress) Standard::Free((Standard_Address&)anAddress); 
53   }
54   
55   Handle(GEOMImpl_PipeTShapeDriver)():Handle(TFunction_Driver)() {} 
56   Handle(GEOMImpl_PipeTShapeDriver)(const Handle(GEOMImpl_PipeTShapeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) 
57   {}
58
59   Handle(GEOMImpl_PipeTShapeDriver)(const GEOMImpl_PipeTShapeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) 
60   {}
61
62   Handle(GEOMImpl_PipeTShapeDriver)& operator=(const Handle(GEOMImpl_PipeTShapeDriver)& aHandle)
63   {
64     Assign(aHandle.Access());
65     return *this;
66   }
67   
68   Handle(GEOMImpl_PipeTShapeDriver)& operator=(const GEOMImpl_PipeTShapeDriver* anItem)
69   {
70     Assign((Standard_Transient *)anItem);
71     return *this;
72   }
73   
74   GEOMImpl_PipeTShapeDriver* operator->() 
75   {
76     return (GEOMImpl_PipeTShapeDriver *)ControlAccess();
77   }
78   
79   GEOMImpl_PipeTShapeDriver* operator->() const 
80   {
81     return (GEOMImpl_PipeTShapeDriver *)ControlAccess();
82   }
83   
84   Standard_EXPORT ~Handle(GEOMImpl_PipeTShapeDriver)() {};
85   
86   Standard_EXPORT static const Handle(GEOMImpl_PipeTShapeDriver) DownCast(const Handle(Standard_Transient)& AnObject);
87 };
88
89 class GEOMImpl_PipeTShapeDriver : public TFunction_Driver {
90 public:
91   inline void* operator new(size_t,void* anAddress) 
92   {
93     return anAddress;
94   }
95   inline void* operator new(size_t size) 
96   { 
97     return Standard::Allocate(size); 
98   }
99   inline void  operator delete(void *anAddress) 
100   { 
101     if (anAddress) Standard::Free((Standard_Address&)anAddress); 
102   }
103   
104   // Methods PUBLIC
105   // 
106   Standard_EXPORT GEOMImpl_PipeTShapeDriver();
107   Standard_EXPORT virtual  Standard_Integer Execute(TFunction_Logbook& log) const; 
108   Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
109   Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const
110   {
111     return Standard_True;
112   }
113   Standard_EXPORT static const Standard_GUID& GetID();
114   Standard_EXPORT ~GEOMImpl_PipeTShapeDriver() {};
115   
116   // Type management
117   //
118   Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PipeTShapeDriver_Type_();
119   Standard_EXPORT const Handle(Standard_Type)& DynamicType() const
120   {
121     return STANDARD_TYPE(GEOMImpl_PipeTShapeDriver);
122   }
123   Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
124   {
125     return (STANDARD_TYPE(GEOMImpl_PipeTShapeDriver) == AType || TFunction_Driver::IsKind(AType));
126   }
127 private:
128
129   /*!
130    * \brief Create a T-Shape based on pipes
131    * \param r1 - the internal radius of main pipe
132    * \param w1 - the thickness of main pipe
133    * \param l1 - the half-length of main pipe
134    * \param r2 - the internal radius of incident pipe
135    * \param w2 - the thickness of incident pipe
136    * \param l2 - the half-length of main pipe
137    * \retval TopoDS_Shape - Resulting shape
138    */
139   TopoDS_Shape MakePipeTShape(double r1, double w1, double l1,
140                               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 of 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 of 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,
153                                      double r2, double w2, double l2) const;
154
155   /*!
156    * \brief Find IDs of sub-shapes complying with given status about surface
157    * \param theSurface - the surface to check state of sub-shapes against
158    * \param theShape - the shape to explore
159    * \param theShapeType - type of sub-shape of theShape
160    * \param theState - required state
161    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
162    */
163   Handle(TColStd_HSequenceOfInteger)
164     GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
165                           const TopoDS_Shape&         theShape,
166                           TopAbs_ShapeEnum            theShapeType,
167                           GEOMAlgo_State              theState) const;
168
169   /*!
170    * \brief Find IDs of sub-shapes complying with given status about surface
171     * \param theBox - the box to check state of sub-shapes against
172     * \param theShape - the shape to explore
173     * \param theShapeType - type of sub-shape of theShape
174     * \param theState - required state
175     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
176    */
177   Handle(TColStd_HSequenceOfInteger)
178   GetShapesOnBoxIDs(const TopoDS_Shape& aBox,
179                  const TopoDS_Shape& aShape,
180                  const Standard_Integer theShapeType,
181                  GEOMAlgo_State theState) const;
182
183   //=======================================================================
184   //function : getCommonShapesOnCylinders
185   //purpose  : return the common edge between 2 cylindrical surfaces
186   //           along OX and OZ
187   //=======================================================================
188   void GetCommonShapesOnCylinders(const TopoDS_Shape& theShape,
189                                   TopAbs_ShapeEnum theShapeType,
190                                   double r, double r2,
191                                   Handle(TopTools_HSequenceOfShape)& commonShapes) const;
192
193 };
194
195 #endif // _GEOMImpl_PipeTShapeDriver_HXX