Version: 9.16.0
CurveCreator_Utils.hxx
Go to the documentation of this file.
1// Copyright (C) 2013-2026 CEA, EDF, 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
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#include <QColor>
36
37#include <list>
38#include <vector> // TODO: remove
39#include <NCollection_IndexedDataMap.hxx>
40
42
43
45{
46public:
47
56 CURVECREATOR_EXPORT static void ConvertPointToClick( const gp_Pnt& thePoint,
57 Handle(V3d_View) theView,
58 int& x, int& y );
59
63 CURVECREATOR_EXPORT static Quantity_Color getRandColor();
64
68 CURVECREATOR_EXPORT static Quantity_Color colorConv(QColor color);
69
73 CURVECREATOR_EXPORT static QColor colorConv(Quantity_Color color);
74
83 CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
84 Handle(V3d_View) theView );
85
92 CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
93 TopoDS_Shape& theShape,
94 NCollection_IndexedDataMap<int, TopoDS_Shape>* Sect2Shape = NULL);
95
105 (const TopoDS_Shape theShape,
106 CurveCreator_Curve *theCurve,
107 gp_Ax3 &theLocalCS);
108
114 CURVECREATOR_EXPORT static void getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
115 const CurveCreator_ICurve* theCurve,
117
125 Handle(AIS_InteractiveContext) theContext,
126 const CurveCreator_ICurve* theCurve,
129
137 const CurveCreator_ICurve* theCurve,
138 Handle(AIS_InteractiveContext) theContext,
139 const bool theOpen );
140
150 CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView,
151 Handle(AIS_InteractiveObject) theObject,
152 const int theX, const int theY,
153 gp_Pnt& thePoint, gp_Pnt& thePoint1,
154 gp_Pnt& thePoint2 );
155
166 CURVECREATOR_EXPORT static bool constructBSpline( const Handle(TColgp_HArray1OfPnt)& thePoints,
167 const Standard_Boolean theIsClosed,
168 Handle(Geom_BSplineCurve)& theBSpline );
169
173 CURVECREATOR_EXPORT static TopoDS_Wire ConstructWire(
174 Handle(TColgp_HArray1OfPnt) thePoints,
175 const bool theIsPolyline,
176 const bool theIsClosed);
177
178protected:
179 /*
180 * Returns whether the clicked point belong to the curve or has a very near projection
181 * \param theX the X coordinate of a point clicked in the OCC viewer
182 * \param theY the Y coordinate of a point clicked in the OCC viewer
183 * \param theCurve a geometry curve
184 * \param theOutPoint a found projected point on the curve
185 */
186 static bool hasProjectPointOnCurve(
187 Handle(V3d_View) theView,
188 const int theX, const int theY,
189 const Handle(Geom_Curve)& theCurve,
190 Standard_Real& theParameter,
191 int& theDelta );
192
193 /*
194 * Returns whether the X and Y coordinates is in the pixel tolerance
195 * \param theX the X coordinate of the first point
196 * \param theY the Y coordinate of the first point
197 * \param theOtherX the X coordinate of the second point
198 * \param theOtherY the Y coordinate of the second point
199 * \param theTolerance the tolerance to compare
200 * \param theDelta the sum of the a square of X and a square of Y
201 * \returns whether the points are provide to the pixel tolerance
202 */
203 static bool isEqualPixels( const int theX, const int theY,
204 const int theOtherX, const int theOtherY,
205 const double theTolerance, int& theDelta );
206
207
208 /*
209 * Returns whether the points are the same
210 * \param thePoint the first point
211 * \param theOtherPoint the second point
212 * \returns whether the points are provide to the pixel tolerance
213 */
214 static bool isEqualPoints( const gp_Pnt& thePoint,
215 const gp_Pnt& theOtherPoint );
216
227 static Handle(TColgp_HArray1OfPnt) getPoints
228 (const TopoDS_Shape &theShape,
229 bool &IsClosed,
230 bool &IsBSpline);
231
248 static void FindPlane(const Handle(TColgp_HArray1OfPnt) &thePoints,
249 gp_Pln &thePlane,
250 Standard_Integer &thePlnStatus);
251
252};
253
254#endif // CURVECREATOR_UTILS_H
#define CURVECREATOR_EXPORT
Definition: CurveCreator_Macro.hxx:41
The CurveCreator_Curve object is represented as one or more sets of connected points; thus CurveCreat...
Definition: CurveCreator_Curve.hxx:51
The CurveCreator_ICurve object is represented as one or more sets of connected points; thus CurveCrea...
Definition: CurveCreator_ICurve.hxx:73
std::deque< SectionToPoint > SectionToPointList
Definition: CurveCreator_ICurve.hxx:76
Definition: CurveCreator_Utils.hxx:45
static void setLocalPointContext(const CurveCreator_ICurve *theCurve, Handle(AIS_InteractiveContext) theContext, const bool theOpen)
Sets the local point context for the 3D viewer.
Definition: CurveCreator_Utils.cxx:700
static void constructShape(const CurveCreator_ICurve *theCurve, TopoDS_Shape &theShape, NCollection_IndexedDataMap< int, TopoDS_Shape > *Sect2Shape=NULL)
Generates shape on the curve.
Definition: CurveCreator_Utils.cxx:297
static void setSelectedPoints(Handle(AIS_InteractiveContext) theContext, const CurveCreator_ICurve *theCurve, const CurveCreator_ICurve::SectionToPointList &thePoints=CurveCreator_ICurve::SectionToPointList())
Set selected points to the context.
Definition: CurveCreator_Utils.cxx:628
static bool constructCurve(const TopoDS_Shape theShape, CurveCreator_Curve *theCurve, gp_Ax3 &theLocalCS)
Generates a curve from a shape.
Definition: CurveCreator_Utils.cxx:395
static Quantity_Color colorConv(QColor color)
Convert QColor to Quantity_Color.
Definition: CurveCreator_Utils.cxx:379
static void FindPlane(const Handle(TColgp_HArray1OfPnt) &thePoints, gp_Pln &thePlane, Standard_Integer &thePlnStatus)
This method computes a plane using the input points.
Definition: CurveCreator_Utils.cxx:1027
static void getSelectedPoints(Handle(AIS_InteractiveContext) theContext, const CurveCreator_ICurve *theCurve, CurveCreator_ICurve::SectionToPointList &thePoints)
Find selected points in the context.
Definition: CurveCreator_Utils.cxx:592
static bool & IsClosed
Definition: CurveCreator_Utils.hxx:229
static Handle(TColgp_HArray1OfPnt) getPoints(const TopoDS_Shape &theShape
Returns the array of points of a shape to construct a curve section.
static Quantity_Color getRandColor()
Generates a random color.
Definition: CurveCreator_Utils.cxx:363
static bool pointOnObject(Handle(V3d_View) theView, Handle(AIS_InteractiveObject) theObject, const int theX, const int theY, gp_Pnt &thePoint, gp_Pnt &thePoint1, gp_Pnt &thePoint2)
Checks whether the point belongs to the OCC object.
Definition: CurveCreator_Utils.cxx:726
static bool bool & IsBSpline
Definition: CurveCreator_Utils.hxx:230
static bool constructBSpline(const Handle(TColgp_HArray1OfPnt)&thePoints, const Standard_Boolean theIsClosed, Handle(Geom_BSplineCurve)&theBSpline)
The algorithm builds the cubic B-spline passing through the points that the tangent vector in each gi...
Definition: CurveCreator_Utils.cxx:190
static TopoDS_Wire ConstructWire(Handle(TColgp_HArray1OfPnt) thePoints, const bool theIsPolyline, const bool theIsClosed)
Constructs the wire corresponding to the section.
Definition: CurveCreator_Utils.cxx:256
static bool hasProjectPointOnCurve(Handle(V3d_View) theView, const int theX, const int theY, const Handle(Geom_Curve)&theCurve, Standard_Real &theParameter, int &theDelta)
Definition: CurveCreator_Utils.cxx:819
static gp_Pnt ConvertClickToPoint(int x, int y, Handle(V3d_View) theView)
Returns the point clicked in 3D view.
Definition: CurveCreator_Utils.cxx:140
static bool isEqualPixels(const int theX, const int theY, const int theOtherX, const int theOtherY, const double theTolerance, int &theDelta)
Definition: CurveCreator_Utils.cxx:847
static void ConvertPointToClick(const gp_Pnt &thePoint, Handle(V3d_View) theView, int &x, int &y)
Returns the point clicked in 3D view.
Definition: CurveCreator_Utils.cxx:128
static bool isEqualPoints(const gp_Pnt &thePoint, const gp_Pnt &theOtherPoint)
Definition: CurveCreator_Utils.cxx:858