Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:17:37

0001 // Created on: 1996-12-11
0002 // Created by: Robert COUBLANC
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _PrsDim_HeaderFile
0018 #define _PrsDim_HeaderFile
0019 
0020 #include <PrsDim_KindOfSurface.hxx>
0021 #include <gp_Elips.hxx>
0022 #include <gp_Pnt.hxx>
0023 #include <Prs3d_Drawer.hxx>
0024 #include <Prs3d_Presentation.hxx>
0025 #include <Standard.hxx>
0026 #include <Standard_DefineAlloc.hxx>
0027 #include <Standard_Handle.hxx>
0028 
0029 class Bnd_Box;
0030 class Geom_Curve;
0031 class Geom_Plane;
0032 class Geom_Surface;
0033 class TopoDS_Edge;
0034 class TopoDS_Face;
0035 class TopoDS_Shape;
0036 class TopoDS_Vertex;
0037 
0038 //! Auxiliary methods for computing dimensions.
0039 class PrsDim
0040 {
0041 public:
0042   DEFINE_STANDARD_ALLOC
0043 
0044   //! Returns the nearest point in a shape. This is used by
0045   //! several classes in calculation of dimensions.
0046   Standard_EXPORT static gp_Pnt Nearest(const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
0047 
0048   //! @return the nearest point on the line.
0049   Standard_EXPORT static gp_Pnt Nearest(const gp_Lin& theLine, const gp_Pnt& thePoint);
0050 
0051   //! For the given point finds nearest point on the curve,
0052   //! @return TRUE if found point is belongs to the curve
0053   //! and FALSE otherwise.
0054   Standard_EXPORT static bool Nearest(const occ::handle<Geom_Curve>& theCurve,
0055                                       const gp_Pnt&                  thePoint,
0056                                       const gp_Pnt&                  theFirstPoint,
0057                                       const gp_Pnt&                  theLastPoint,
0058                                       gp_Pnt&                        theNearestPoint);
0059 
0060   Standard_EXPORT static gp_Pnt Farest(const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
0061 
0062   //! Used by 2d Relation only
0063   //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
0064   //! and the extremities if any
0065   //! Return TRUE if ok.
0066   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Edge&       theEdge,
0067                                               occ::handle<Geom_Curve>& theCurve,
0068                                               gp_Pnt&                  theFirstPnt,
0069                                               gp_Pnt&                  theLastPnt);
0070 
0071   //! Used by dimensions only.
0072   //! Computes the 3d geometry of <anEdge>.
0073   //! Return TRUE if ok.
0074   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Edge&       theEdge,
0075                                               occ::handle<Geom_Curve>& theCurve,
0076                                               gp_Pnt&                  theFirstPnt,
0077                                               gp_Pnt&                  theLastPnt,
0078                                               bool&                    theIsInfinite);
0079 
0080   //! Used by 2d Relation only
0081   //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
0082   //! and the extremities if any.
0083   //! If <aCurve> is not in the current plane, <extCurve> contains
0084   //! the not projected curve associated to <anEdge>.
0085   //! If <anEdge> is infinite, <isinfinite> = true and the 2
0086   //! parameters <FirstPnt> and <LastPnt> have no signification.
0087   //! Return TRUE if ok.
0088   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Edge&             theEdge,
0089                                               occ::handle<Geom_Curve>&       theCurve,
0090                                               gp_Pnt&                        theFirstPnt,
0091                                               gp_Pnt&                        theLastPnt,
0092                                               occ::handle<Geom_Curve>&       theExtCurve,
0093                                               bool&                          theIsInfinite,
0094                                               bool&                          theIsOnPlane,
0095                                               const occ::handle<Geom_Plane>& thePlane);
0096 
0097   //! Used by 2d Relation only
0098   //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
0099   //! and the extremities if any
0100   //! Return TRUE if ok.
0101   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Edge&             theFirstEdge,
0102                                               const TopoDS_Edge&             theSecondEdge,
0103                                               occ::handle<Geom_Curve>&       theFirstCurve,
0104                                               occ::handle<Geom_Curve>&       theSecondCurve,
0105                                               gp_Pnt&                        theFirstPnt1,
0106                                               gp_Pnt&                        theLastPnt1,
0107                                               gp_Pnt&                        theFirstPnt2,
0108                                               gp_Pnt&                        theLastPnt2,
0109                                               const occ::handle<Geom_Plane>& thePlane);
0110 
0111   //! Used by dimensions only.Computes the 3d geometry
0112   //! of<anEdge1> and <anEdge2> and checks if they are infinite.
0113   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Edge&       theFirstEdge,
0114                                               const TopoDS_Edge&       theSecondEdge,
0115                                               occ::handle<Geom_Curve>& theFirstCurve,
0116                                               occ::handle<Geom_Curve>& theSecondCurve,
0117                                               gp_Pnt&                  theFirstPnt1,
0118                                               gp_Pnt&                  theLastPnt1,
0119                                               gp_Pnt&                  theFirstPnt2,
0120                                               gp_Pnt&                  theLastPnt2,
0121                                               bool&                    theIsinfinite1,
0122                                               bool&                    theIsinfinite2);
0123 
0124   //! Used by 2d Relation only Computes the 3d geometry
0125   //! of<anEdge1> and <anEdge2> in the current Plane and the
0126   //! extremities if any. Return in ExtCurve the 3d curve
0127   //! (not projected in the plane) of the first edge if
0128   //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If
0129   //! <indexExt> = 0, ExtCurve is Null. if there is an edge
0130   //! external to the plane, <isinfinite> is true if this
0131   //! edge is infinite. So, the extremities of it are not
0132   //! significant. Return TRUE if ok
0133   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Edge&             theFirstEdge,
0134                                               const TopoDS_Edge&             theSecondEdge,
0135                                               int&                           theExtIndex,
0136                                               occ::handle<Geom_Curve>&       theFirstCurve,
0137                                               occ::handle<Geom_Curve>&       theSecondCurve,
0138                                               gp_Pnt&                        theFirstPnt1,
0139                                               gp_Pnt&                        theLastPnt1,
0140                                               gp_Pnt&                        theFirstPnt2,
0141                                               gp_Pnt&                        theLastPnt2,
0142                                               occ::handle<Geom_Curve>&       theExtCurve,
0143                                               bool&                          theIsinfinite1,
0144                                               bool&                          theIsinfinite2,
0145                                               const occ::handle<Geom_Plane>& thePlane);
0146 
0147   //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
0148   //! and returns aCurve;
0149   //! Return TRUE if ok
0150   Standard_EXPORT static bool ComputeGeomCurve(occ::handle<Geom_Curve>&       aCurve,
0151                                                const double                   first1,
0152                                                const double                   last1,
0153                                                gp_Pnt&                        FirstPnt1,
0154                                                gp_Pnt&                        LastPnt1,
0155                                                const occ::handle<Geom_Plane>& aPlane,
0156                                                bool&                          isOnPlane);
0157 
0158   Standard_EXPORT static bool ComputeGeometry(const TopoDS_Vertex&           aVertex,
0159                                               gp_Pnt&                        point,
0160                                               const occ::handle<Geom_Plane>& aPlane,
0161                                               bool&                          isOnPlane);
0162 
0163   //! Tries to get Plane from Face. Returns Surface of Face
0164   //! in aSurf. Returns true and Plane of Face in
0165   //! aPlane in following cases:
0166   //! Face is Plane, Offset of Plane,
0167   //! Extrusion of Line and Offset of Extrusion of Line
0168   //! Returns pure type of Surface which can be:
0169   //! Plane, Cylinder, Cone, Sphere, Torus,
0170   //! SurfaceOfRevolution, SurfaceOfExtrusion
0171   Standard_EXPORT static bool GetPlaneFromFace(const TopoDS_Face&         aFace,
0172                                                gp_Pln&                    aPlane,
0173                                                occ::handle<Geom_Surface>& aSurf,
0174                                                PrsDim_KindOfSurface&      aSurfType,
0175                                                double&                    Offset);
0176 
0177   Standard_EXPORT static void InitFaceLength(const TopoDS_Face&         aFace,
0178                                              gp_Pln&                    aPlane,
0179                                              occ::handle<Geom_Surface>& aSurface,
0180                                              PrsDim_KindOfSurface&      aSurfaceType,
0181                                              double&                    anOffset);
0182 
0183   //! Finds attachment points on two curvilinear faces for length dimension.
0184   //! @param[in] thePlaneDir  the direction on the dimension plane to
0185   //! compute the plane automatically. It will not be taken into account if
0186   //! plane is defined by user.
0187   Standard_EXPORT static void InitLengthBetweenCurvilinearFaces(
0188     const TopoDS_Face&         theFirstFace,
0189     const TopoDS_Face&         theSecondFace,
0190     occ::handle<Geom_Surface>& theFirstSurf,
0191     occ::handle<Geom_Surface>& theSecondSurf,
0192     gp_Pnt&                    theFirstAttach,
0193     gp_Pnt&                    theSecondAttach,
0194     gp_Dir&                    theDirOnPlane);
0195 
0196   //! Finds three points for the angle dimension between
0197   //! two planes.
0198   Standard_EXPORT static bool InitAngleBetweenPlanarFaces(const TopoDS_Face& theFirstFace,
0199                                                           const TopoDS_Face& theSecondFace,
0200                                                           gp_Pnt&            theCenter,
0201                                                           gp_Pnt&            theFirstAttach,
0202                                                           gp_Pnt&            theSecondAttach,
0203                                                           const bool theIsFirstPointSet = false);
0204 
0205   //! Finds three points for the angle dimension between
0206   //! two curvilinear surfaces.
0207   Standard_EXPORT static bool InitAngleBetweenCurvilinearFaces(
0208     const TopoDS_Face&         theFirstFace,
0209     const TopoDS_Face&         theSecondFace,
0210     const PrsDim_KindOfSurface theFirstSurfType,
0211     const PrsDim_KindOfSurface theSecondSurfType,
0212     gp_Pnt&                    theCenter,
0213     gp_Pnt&                    theFirstAttach,
0214     gp_Pnt&                    theSecondAttach,
0215     const bool                 theIsFirstPointSet = false);
0216 
0217   Standard_EXPORT static gp_Pnt ProjectPointOnPlane(const gp_Pnt& aPoint, const gp_Pln& aPlane);
0218 
0219   Standard_EXPORT static gp_Pnt ProjectPointOnLine(const gp_Pnt& aPoint, const gp_Lin& aLine);
0220 
0221   Standard_EXPORT static gp_Pnt TranslatePointToBound(const gp_Pnt&  aPoint,
0222                                                       const gp_Dir&  aDir,
0223                                                       const Bnd_Box& aBndBox);
0224 
0225   //! returns True if point with anAttachPar is
0226   //! in domain of arc
0227   Standard_EXPORT static bool InDomain(const double aFirstPar,
0228                                        const double aLastPar,
0229                                        const double anAttachPar);
0230 
0231   //! computes nearest to ellipse arc apex
0232   Standard_EXPORT static gp_Pnt NearestApex(const gp_Elips& elips,
0233                                             const gp_Pnt&   pApex,
0234                                             const gp_Pnt&   nApex,
0235                                             const double    fpara,
0236                                             const double    lpara,
0237                                             bool&           IsInDomain);
0238 
0239   //! computes length of ellipse arc in parametric units
0240   Standard_EXPORT static double DistanceFromApex(const gp_Elips& elips,
0241                                                  const gp_Pnt&   Apex,
0242                                                  const double    par);
0243 
0244   Standard_EXPORT static void ComputeProjEdgePresentation(
0245     const occ::handle<Prs3d_Presentation>& aPres,
0246     const occ::handle<Prs3d_Drawer>&       aDrawer,
0247     const TopoDS_Edge&                     anEdge,
0248     const occ::handle<Geom_Curve>&         ProjCurve,
0249     const gp_Pnt&                          FirstP,
0250     const gp_Pnt&                          LastP,
0251     const Quantity_NameOfColor             aColor   = Quantity_NOC_PURPLE,
0252     const double                           aWidth   = 2,
0253     const Aspect_TypeOfLine                aProjTOL = Aspect_TOL_DASH,
0254     const Aspect_TypeOfLine                aCallTOL = Aspect_TOL_DOT);
0255 
0256   Standard_EXPORT static void ComputeProjVertexPresentation(
0257     const occ::handle<Prs3d_Presentation>& aPres,
0258     const occ::handle<Prs3d_Drawer>&       aDrawer,
0259     const TopoDS_Vertex&                   aVertex,
0260     const gp_Pnt&                          ProjPoint,
0261     const Quantity_NameOfColor             aColor   = Quantity_NOC_PURPLE,
0262     const double                           aWidth   = 2,
0263     const Aspect_TypeOfMarker              aProjTOM = Aspect_TOM_PLUS,
0264     const Aspect_TypeOfLine                aCallTOL = Aspect_TOL_DOT);
0265 };
0266 
0267 #endif // _PrsDim_HeaderFile