Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:18:11

0001 // Created by: Peter KURNEV
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _BOPTools_AlgoTools3D_HeaderFile
0016 #define _BOPTools_AlgoTools3D_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <Standard_Integer.hxx>
0023 class TopoDS_Edge;
0024 class TopoDS_Face;
0025 class gp_Dir;
0026 class Geom_Surface;
0027 class Geom2d_Curve;
0028 class gp_Pnt;
0029 class IntTools_Context;
0030 class gp_Pnt2d;
0031 class TopoDS_Shape;
0032 
0033 //! The class contains handy static functions
0034 //! dealing with the topology
0035 //! This is the copy of BOPTools_AlgoTools3D.cdl file
0036 class BOPTools_AlgoTools3D
0037 {
0038 public:
0039   DEFINE_STANDARD_ALLOC
0040 
0041   //! Makes the edge <theESplit> seam edge for the face <theFace> basing on the surface properties
0042   //! (U and V periods)
0043   Standard_EXPORT static bool DoSplitSEAMOnFace(const TopoDS_Edge& theESplit,
0044                                                 const TopoDS_Face& theFace);
0045 
0046   //! Makes the split edge <theESplit> seam edge for the face <theFace> basing on the positions
0047   //! of 2d curves of the original edge <theEOrigin>.
0048   Standard_EXPORT static bool DoSplitSEAMOnFace(const TopoDS_Edge& theEOrigin,
0049                                                 const TopoDS_Edge& theESplit,
0050                                                 const TopoDS_Face& theFace);
0051 
0052   //! Computes normal to the face <aF> for the point on the edge <aE>
0053   //! at parameter <aT>.
0054   //! <theContext> - storage for caching the geometrical tools
0055   Standard_EXPORT static void GetNormalToFaceOnEdge(
0056     const TopoDS_Edge&                   aE,
0057     const TopoDS_Face&                   aF,
0058     const double                         aT,
0059     gp_Dir&                              aD,
0060     const occ::handle<IntTools_Context>& theContext = occ::handle<IntTools_Context>());
0061 
0062   //! Computes normal to the face <aF> for the point on the edge <aE>
0063   //! at arbitrary intermediate parameter.
0064   //! <theContext> - storage for caching the geometrical tools
0065   Standard_EXPORT static void GetNormalToFaceOnEdge(
0066     const TopoDS_Edge&                   aE,
0067     const TopoDS_Face&                   aF,
0068     gp_Dir&                              aD,
0069     const occ::handle<IntTools_Context>& theContext = occ::handle<IntTools_Context>());
0070 
0071   //! Returns 1  if scalar product aNF1* aNF2>0.
0072   //! Returns 0  if directions aNF1 aNF2 coincide
0073   //! Returns -1 if scalar product aNF1* aNF2<0.
0074   Standard_EXPORT static int SenseFlag(const gp_Dir& aNF1, const gp_Dir& aNF2);
0075 
0076   //! Compute normal <aD> to surface <aS> in point (U,V)
0077   //! Returns TRUE if directions aD1U, aD1V coincide
0078   Standard_EXPORT static bool GetNormalToSurface(const occ::handle<Geom_Surface>& aS,
0079                                                  const double                     U,
0080                                                  const double                     V,
0081                                                  gp_Dir&                          aD);
0082 
0083   //! Computes normal to the face <aF> for the 3D-point that
0084   //! belongs to the edge <aE> at parameter <aT>.
0085   //! Output:
0086   //! aPx  -  the 3D-point where the normal computed
0087   //! aD   -  the normal;
0088   //! Warning:
0089   //! The normal is computed not exactly in the point on the
0090   //! edge, but in point that is near to the edge towards to
0091   //! the face material (so, we'll have approx. normal);
0092   //! The point is computed using PointNearEdge function,
0093   //! with the shifting value BOPTools_AlgoTools3D::MinStepIn2d(),
0094   //! from the edge, but if this value is too big,
0095   //! the point will be computed using Hatcher (PointInFace function).
0096   //! Returns TRUE in case of success.
0097   Standard_EXPORT static bool GetApproxNormalToFaceOnEdge(
0098     const TopoDS_Edge&                   aE,
0099     const TopoDS_Face&                   aF,
0100     const double                         aT,
0101     gp_Pnt&                              aPx,
0102     gp_Dir&                              aD,
0103     const occ::handle<IntTools_Context>& theContext);
0104 
0105   //! Computes normal to the face <aF> for the 3D-point that
0106   //! belongs to the edge <aE> at parameter <aT>.
0107   //! Output:
0108   //! aPx  -  the 3D-point where the normal computed
0109   //! aD   -  the normal;
0110   //! Warning:
0111   //! The normal is computed not exactly in the point on the
0112   //! edge, but in point that is near to the edge towards to
0113   //! the face material (so, we'll have approx. normal);
0114   //! The point is computed using PointNearEdge function
0115   //! with the shifting value <aDt2D> from the edge;
0116   //! No checks on this value will be done.
0117   //! Returns TRUE in case of success.
0118   Standard_EXPORT static bool GetApproxNormalToFaceOnEdge(const TopoDS_Edge& theE,
0119                                                           const TopoDS_Face& theF,
0120                                                           const double       aT,
0121                                                           gp_Pnt&            aP,
0122                                                           gp_Dir&            aDNF,
0123                                                           const double       aDt2D);
0124 
0125   //! Computes normal to the face <aF> for the 3D-point that
0126   //! belongs to the edge <aE> at parameter <aT>.
0127   //! Output:
0128   //! aPx  -  the 3D-point where the normal computed
0129   //! aD   -  the normal;
0130   //! Warning:
0131   //! The normal is computed not exactly in the point on the
0132   //! edge, but in point that is near to the edge towards to
0133   //! the face material (so, we'll have approx. normal);
0134   //! The point is computed using PointNearEdge function
0135   //! with the shifting value <aDt2D> from the edge,
0136   //! but if this value is too big the point will be
0137   //! computed using Hatcher (PointInFace function).
0138   //! Returns TRUE in case of success.
0139   Standard_EXPORT static bool GetApproxNormalToFaceOnEdge(
0140     const TopoDS_Edge&                   theE,
0141     const TopoDS_Face&                   theF,
0142     const double                         aT,
0143     const double                         aDt2D,
0144     gp_Pnt&                              aP,
0145     gp_Dir&                              aDNF,
0146     const occ::handle<IntTools_Context>& theContext);
0147 
0148   //! Compute the point <aPx>, (<aP2D>) that is near to
0149   //! the edge <aE> at parameter <aT> towards to the
0150   //! material of the face <aF>. The value of shifting in
0151   //! 2D is <aDt2D>
0152   //! If the value of shifting is too big the point
0153   //! will be computed using Hatcher (PointInFace function).
0154   //! Returns error status:
0155   //! 0 - in case of success;
0156   //! 1 - <aE> does not have 2d curve on the face <aF>;
0157   //! 2 - the computed point is out of the face.
0158   Standard_EXPORT static int PointNearEdge(const TopoDS_Edge&                   aE,
0159                                            const TopoDS_Face&                   aF,
0160                                            const double                         aT,
0161                                            const double                         aDt2D,
0162                                            gp_Pnt2d&                            aP2D,
0163                                            gp_Pnt&                              aPx,
0164                                            const occ::handle<IntTools_Context>& theContext);
0165 
0166   //! Compute the point <aPx>, (<aP2D>) that is near to
0167   //! the edge <aE> at parameter <aT> towards to the
0168   //! material of the face <aF>. The value of shifting in
0169   //! 2D is <aDt2D>. No checks on this value will be done.
0170   //! Returns error status:
0171   //! 0 - in case of success;
0172   //! 1 - <aE> does not have 2d curve on the face <aF>.
0173   Standard_EXPORT static int PointNearEdge(const TopoDS_Edge& aE,
0174                                            const TopoDS_Face& aF,
0175                                            const double       aT,
0176                                            const double       aDt2D,
0177                                            gp_Pnt2d&          aP2D,
0178                                            gp_Pnt&            aPx);
0179 
0180   //! Computes the point <aPx>, (<aP2D>) that is near to
0181   //! the edge <aE> at parameter <aT> towards to the
0182   //! material of the face <aF>. The value of shifting in
0183   //! 2D is dt2D=BOPTools_AlgoTools3D::MinStepIn2d()
0184   //! If the value of shifting is too big the point will be computed
0185   //! using Hatcher (PointInFace function).
0186   //! Returns error status:
0187   //! 0 - in case of success;
0188   //! 1 - <aE> does not have 2d curve on the face <aF>;
0189   //! 2 - the computed point is out of the face.
0190   Standard_EXPORT static int PointNearEdge(const TopoDS_Edge&                   aE,
0191                                            const TopoDS_Face&                   aF,
0192                                            const double                         aT,
0193                                            gp_Pnt2d&                            aP2D,
0194                                            gp_Pnt&                              aPx,
0195                                            const occ::handle<IntTools_Context>& theContext);
0196 
0197   //! Compute the point <aPx>, (<aP2D>) that is near to
0198   //! the edge <aE> at arbitrary parameter towards to the
0199   //! material of the face <aF>. The value of shifting in
0200   //! 2D is dt2D=BOPTools_AlgoTools3D::MinStepIn2d().
0201   //! If the value of shifting is too big the point will be computed
0202   //! using Hatcher (PointInFace function).
0203   //! Returns error status:
0204   //! 0 - in case of success;
0205   //! 1 - <aE> does not have 2d curve on the face <aF>;
0206   //! 2 - the computed point is out of the face.
0207   Standard_EXPORT static int PointNearEdge(const TopoDS_Edge&                   aE,
0208                                            const TopoDS_Face&                   aF,
0209                                            gp_Pnt2d&                            aP2D,
0210                                            gp_Pnt&                              aPx,
0211                                            const occ::handle<IntTools_Context>& theContext);
0212 
0213   //! Returns simple step value that is used in 2D-computations
0214   //! = 1.e-5
0215   Standard_EXPORT static double MinStepIn2d();
0216 
0217   //! Returns TRUE if the shape <aS> does not contain
0218   //! geometry information (e.g. empty compound)
0219   Standard_EXPORT static bool IsEmptyShape(const TopoDS_Shape& aS);
0220 
0221   //! Get the edge <aER> from the face <aF> that is the same as
0222   //! the edge <aE>
0223   Standard_EXPORT static void OrientEdgeOnFace(const TopoDS_Edge& aE,
0224                                                const TopoDS_Face& aF,
0225                                                TopoDS_Edge&       aER);
0226 
0227   //! Computes arbitrary point <theP> inside the face <theF>.
0228   //! <theP2D> - 2D representation of <theP>
0229   //! on the surface of <theF>
0230   //! Returns 0 in case of success.
0231   Standard_EXPORT static int PointInFace(const TopoDS_Face&                   theF,
0232                                          gp_Pnt&                              theP,
0233                                          gp_Pnt2d&                            theP2D,
0234                                          const occ::handle<IntTools_Context>& theContext);
0235 
0236   //! Computes a point <theP> inside the face <theF>
0237   //! using starting point taken by the parameter <theT>
0238   //! from the 2d curve of the edge <theE> on the face <theF>
0239   //! in the direction perpendicular to the tangent vector
0240   //! of the 2d curve of the edge.
0241   //! The point will be distanced on <theDt2D> from the 2d curve.
0242   //! <theP2D> - 2D representation of <theP>
0243   //! on the surface of <theF>
0244   //! Returns 0 in case of success.
0245   Standard_EXPORT static int PointInFace(const TopoDS_Face&                   theF,
0246                                          const TopoDS_Edge&                   theE,
0247                                          const double                         theT,
0248                                          const double                         theDt2D,
0249                                          gp_Pnt&                              theP,
0250                                          gp_Pnt2d&                            theP2D,
0251                                          const occ::handle<IntTools_Context>& theContext);
0252 
0253   //! Computes a point <theP> inside the face <theF>
0254   //! using the line <theL> so that 2D point
0255   //! <theP2D>, 2D representation of <theP>
0256   //! on the surface of <theF>, lies on that line.
0257   //! Returns 0 in case of success.
0258   Standard_EXPORT static int PointInFace(const TopoDS_Face&                   theF,
0259                                          const occ::handle<Geom2d_Curve>&     theL,
0260                                          gp_Pnt&                              theP,
0261                                          gp_Pnt2d&                            theP2D,
0262                                          const occ::handle<IntTools_Context>& theContext,
0263                                          const double                         theDt2D = 0.0);
0264 };
0265 
0266 #endif // _BOPTools_AlgoTools3D_HeaderFile