Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CurveCreator_Utils.hxx
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 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, or (at your option) any later version.
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 
20 #ifndef CURVECREATOR_UTILS_H
21 #define CURVECREATOR_UTILS_H
22 
23 #include "CurveCreator_Macro.hxx"
24 #include "CurveCreator_ICurve.hxx"
25 
26 #include <AIS_InteractiveContext.hxx>
27 #include <AIS_InteractiveObject.hxx> // TODO: remove
28 #include <V3d_View.hxx>
29 #include <gp_Pnt.hxx>
30 #include <Geom_Curve.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Wire.hxx>
33 #include <TColgp_HArray1OfPnt.hxx>
34 #include <Geom_BSplineCurve.hxx>
35 
36 #include <list>
37 #include <vector> // TODO: remove
38 
39 class CurveCreator_Curve;
40 
41 
43 {
44 public:
45 
54  CURVECREATOR_EXPORT static void ConvertPointToClick( const gp_Pnt& thePoint,
55  Handle(V3d_View) theView,
56  int& x, int& y );
57 
66  CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
67  Handle(V3d_View) theView );
68 
74  CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
75  TopoDS_Shape& theShape );
76 
86  (const TopoDS_Shape theShape,
87  CurveCreator_Curve *theCurve,
88  gp_Ax3 &theLocalCS);
89 
95  CURVECREATOR_EXPORT static void getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
96  const CurveCreator_ICurve* theCurve,
98 
106  Handle(AIS_InteractiveContext) theContext,
107  const CurveCreator_ICurve* theCurve,
108  const CurveCreator_ICurve::SectionToPointList& thePoints =
110 
118  const CurveCreator_ICurve* theCurve,
119  Handle(AIS_InteractiveContext) theContext,
120  const bool theOpen );
121 
131  CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView,
132  Handle(AIS_InteractiveObject) theObject,
133  const int theX, const int theY,
134  gp_Pnt& thePoint, gp_Pnt& thePoint1,
135  gp_Pnt& thePoint2 );
136 
147  CURVECREATOR_EXPORT static bool constructBSpline( const Handle(TColgp_HArray1OfPnt)& thePoints,
148  const Standard_Boolean theIsClosed,
149  Handle(Geom_BSplineCurve)& theBSpline );
150 
154  CURVECREATOR_EXPORT static TopoDS_Wire ConstructWire(
155  Handle(TColgp_HArray1OfPnt) thePoints,
156  const bool theIsPolyline,
157  const bool theIsClosed);
158 
159 protected:
160  /*
161  * Returns whether the clicked point belong to the curve or has a very near projection
162  * \param theX the X coordinate of a point clicked in the OCC viewer
163  * \param theY the Y coordinate of a point clicked in the OCC viewer
164  * \param theCurve a geometry curve
165  * \param theOutPoint a found projected point on the curve
166  */
167  static bool hasProjectPointOnCurve(
168  Handle(V3d_View) theView,
169  const int theX, const int theY,
170  const Handle(Geom_Curve)& theCurve,
171  Standard_Real& theParameter,
172  int& theDelta );
173 
174  /*
175  * Returns whether the X and Y coordinates is in the pixel tolerance
176  * \param theX the X coordinate of the first point
177  * \param theY the Y coordinate of the first point
178  * \param theOtherX the X coordinate of the second point
179  * \param theOtherY the Y coordinate of the second point
180  * \param theTolerance the tolerance to compare
181  * \param theDelta the sum of the a square of X and a square of Y
182  * \returns whether the points are provide to the pixel tolerance
183  */
184  static bool isEqualPixels( const int theX, const int theY,
185  const int theOtherX, const int theOtherY,
186  const double theTolerance, int& theDelta );
187 
188 
189  /*
190  * Returns whether the points are the same
191  * \param thePoint the first point
192  * \param theOtherPoint the second point
193  * \returns whether the points are provide to the pixel tolerance
194  */
195  static bool isEqualPoints( const gp_Pnt& thePoint,
196  const gp_Pnt& theOtherPoint );
197 
208  static Handle(TColgp_HArray1OfPnt) getPoints
209  (const TopoDS_Shape &theShape,
210  bool &IsClosed,
211  bool &IsBSpline);
212 
229  static void FindPlane(const Handle(TColgp_HArray1OfPnt) &thePoints,
230  gp_Pln &thePlane,
231  Standard_Integer &thePlnStatus);
232 
233 };
234 
235 #endif // CURVECREATOR_UTILS_H