Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:40

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 
0043   DEFINE_STANDARD_ALLOC
0044 
0045   //! Returns the nearest point in a shape. This is used by
0046   //! several classes in calculation of dimensions.
0047   Standard_EXPORT static gp_Pnt Nearest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
0048 
0049   //! @return the nearest point on the line.
0050   Standard_EXPORT static gp_Pnt Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint);
0051 
0052   //! For the given point finds nearest point on the curve,
0053   //! @return TRUE if found point is belongs to the curve
0054   //! and FALSE otherwise.
0055   Standard_EXPORT static Standard_Boolean Nearest (const Handle(Geom_Curve)& theCurve, const gp_Pnt& thePoint, const gp_Pnt& theFirstPoint, const gp_Pnt& theLastPoint, gp_Pnt& theNearestPoint);
0056   
0057   Standard_EXPORT static gp_Pnt Farest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
0058   
0059   //! Used by 2d Relation only
0060   //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
0061   //! and the extremities if any
0062   //! Return TRUE if ok.
0063   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt);
0064   
0065   //! Used by dimensions only.
0066   //! Computes the 3d geometry of <anEdge>.
0067   //! Return TRUE if ok.
0068   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Standard_Boolean& theIsInfinite);
0069   
0070   //! Used by 2d Relation only
0071   //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
0072   //! and the extremities if any.
0073   //! If <aCurve> is not in the current plane, <extCurve> contains
0074   //! the not projected curve associated to <anEdge>.
0075   //! If <anEdge> is infinite, <isinfinite> = true and the 2
0076   //! parameters <FirstPnt> and <LastPnt> have no signification.
0077   //! Return TRUE if ok.
0078   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsInfinite, Standard_Boolean& theIsOnPlane, const Handle(Geom_Plane)& thePlane);
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   //! Return TRUE if ok.
0084   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, const Handle(Geom_Plane)& thePlane);
0085   
0086   //! Used  by  dimensions  only.Computes  the  3d geometry
0087   //! of<anEdge1> and <anEdge2> and checks if they are infinite.
0088   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2);
0089   
0090   //! Used  by  2d Relation  only Computes  the  3d geometry
0091   //! of<anEdge1> and <anEdge2> in the current Plane and the
0092   //! extremities if any.   Return in ExtCurve  the 3d curve
0093   //! (not projected  in the  plane)  of the  first edge  if
0094   //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If
0095   //! <indexExt> = 0, ExtCurve is Null.  if there is an edge
0096   //! external to the  plane,  <isinfinite> is true if  this
0097   //! edge is infinite.  So, the extremities of it are not
0098   //! significant.  Return TRUE if ok
0099   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Standard_Integer& theExtIndex, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2, const Handle(Geom_Plane)& thePlane);
0100   
0101   //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
0102   //! and returns aCurve;
0103   //! Return TRUE if ok
0104   Standard_EXPORT static Standard_Boolean ComputeGeomCurve (Handle(Geom_Curve)& aCurve, const Standard_Real first1, const Standard_Real last1, gp_Pnt& FirstPnt1, gp_Pnt& LastPnt1, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
0105   
0106   Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Vertex& aVertex, gp_Pnt& point, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
0107   
0108   //! Tryes to get Plane from Face.  Returns Surface of Face
0109   //! in aSurf.  Returns Standard_True  and Plane of Face in
0110   //! aPlane in following  cases:
0111   //! Face is Plane, Offset of Plane,
0112   //! Extrusion of Line  and Offset of  Extrusion of Line
0113   //! Returns pure type of Surface which can be:
0114   //! Plane, Cylinder, Cone, Sphere, Torus,
0115   //! SurfaceOfRevolution, SurfaceOfExtrusion
0116   Standard_EXPORT static Standard_Boolean GetPlaneFromFace (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurf, PrsDim_KindOfSurface& aSurfType, Standard_Real& Offset);
0117   
0118   Standard_EXPORT static void InitFaceLength (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurface, PrsDim_KindOfSurface& aSurfaceType, Standard_Real& anOffset);
0119   
0120   //! Finds attachment points on two curvilinear faces for length dimension.
0121   //! @param thePlaneDir [in] the direction on the dimension plane to
0122   //! compute the plane automatically. It will not be taken into account if
0123   //! plane is defined by user.
0124   Standard_EXPORT static void InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, Handle(Geom_Surface)& theFirstSurf, Handle(Geom_Surface)& theSecondSurf, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, gp_Dir& theDirOnPlane);
0125   
0126   //! Finds three points for the angle dimension between
0127   //! two planes.
0128   Standard_EXPORT static Standard_Boolean InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
0129   
0130   //! Finds three points for the angle dimension between
0131   //! two curvilinear surfaces.
0132   Standard_EXPORT static Standard_Boolean InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const PrsDim_KindOfSurface theFirstSurfType, const PrsDim_KindOfSurface theSecondSurfType, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
0133   
0134   Standard_EXPORT static gp_Pnt ProjectPointOnPlane (const gp_Pnt& aPoint, const gp_Pln& aPlane);
0135   
0136   Standard_EXPORT static gp_Pnt ProjectPointOnLine (const gp_Pnt& aPoint, const gp_Lin& aLine);
0137   
0138   Standard_EXPORT static gp_Pnt TranslatePointToBound (const gp_Pnt& aPoint, const gp_Dir& aDir, const Bnd_Box& aBndBox);
0139   
0140   //! returns  True  if  point  with anAttachPar  is
0141   //! in  domain  of  arc
0142   Standard_EXPORT static Standard_Boolean InDomain (const Standard_Real aFirstPar, const Standard_Real aLastPar, const Standard_Real anAttachPar);
0143   
0144   //! computes  nearest  to  ellipse  arc  apex
0145   Standard_EXPORT static gp_Pnt NearestApex (const gp_Elips& elips, const gp_Pnt& pApex, const gp_Pnt& nApex, const Standard_Real fpara, const Standard_Real lpara, Standard_Boolean& IsInDomain);
0146   
0147   //! computes  length  of  ellipse  arc  in  parametric  units
0148   Standard_EXPORT static Standard_Real DistanceFromApex (const gp_Elips& elips, const gp_Pnt& Apex, const Standard_Real par);
0149   
0150   Standard_EXPORT static void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
0151   
0152   Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
0153 
0154 };
0155 
0156 #endif // _PrsDim_HeaderFile