Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04: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 _IntTools_Context_HeaderFile
0016 #define _IntTools_Context_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_Type.hxx>
0020 
0021 #include <NCollection_BaseAllocator.hxx>
0022 #include <NCollection_DataMap.hxx>
0023 #include <TopTools_ShapeMapHasher.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <Precision.hxx>
0026 #include <Standard_Transient.hxx>
0027 #include <TopAbs_State.hxx>
0028 #include <BRepAdaptor_Surface.hxx>
0029 class IntTools_FClass2d;
0030 class TopoDS_Face;
0031 class GeomAPI_ProjectPointOnSurf;
0032 class GeomAPI_ProjectPointOnCurve;
0033 class TopoDS_Edge;
0034 class Geom_Curve;
0035 class IntTools_SurfaceRangeLocalizeData;
0036 class BRepClass3d_SolidClassifier;
0037 class TopoDS_Solid;
0038 class Geom2dHatch_Hatcher;
0039 class gp_Pnt;
0040 class TopoDS_Vertex;
0041 class gp_Pnt2d;
0042 class IntTools_Curve;
0043 class Bnd_Box;
0044 class Bnd_OBB;
0045 
0046 //! The intersection Context contains geometrical
0047 //! and topological toolkit (classifiers, projectors, etc).
0048 //! The intersection Context is for caching the tools
0049 //! to increase the performance.
0050 class IntTools_Context : public Standard_Transient
0051 {
0052 public:
0053 
0054   
0055   Standard_EXPORT IntTools_Context();
0056 Standard_EXPORT virtual  ~IntTools_Context();
0057   
0058   Standard_EXPORT IntTools_Context(const Handle(NCollection_BaseAllocator)& theAllocator);
0059   
0060 
0061   //! Returns a reference to point classifier
0062   //! for given face
0063   Standard_EXPORT IntTools_FClass2d& FClass2d (const TopoDS_Face& aF);
0064   
0065 
0066   //! Returns a reference to point projector
0067   //! for given face
0068   Standard_EXPORT GeomAPI_ProjectPointOnSurf& ProjPS (const TopoDS_Face& aF);
0069   
0070 
0071   //! Returns a reference to point projector
0072   //! for given edge
0073   Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPC (const TopoDS_Edge& aE);
0074   
0075 
0076   //! Returns a reference to point projector
0077   //! for given curve
0078   Standard_EXPORT GeomAPI_ProjectPointOnCurve& ProjPT (const Handle(Geom_Curve)& aC);
0079   
0080 
0081   //! Returns a reference to surface localization data
0082   //! for given face
0083   Standard_EXPORT IntTools_SurfaceRangeLocalizeData& SurfaceData (const TopoDS_Face& aF);
0084   
0085 
0086   //! Returns a reference to solid classifier
0087   //! for given solid
0088   Standard_EXPORT BRepClass3d_SolidClassifier& SolidClassifier (const TopoDS_Solid& aSolid);
0089   
0090 
0091   //! Returns a reference to 2D hatcher
0092   //! for given face
0093   Standard_EXPORT Geom2dHatch_Hatcher& Hatcher (const TopoDS_Face& aF);
0094   
0095   //! Returns a reference to surface adaptor for given face
0096   Standard_EXPORT BRepAdaptor_Surface& SurfaceAdaptor (const TopoDS_Face& theFace);
0097 
0098   //! Builds and stores an Oriented Bounding Box for the shape.
0099   //! Returns a reference to OBB.
0100   Standard_EXPORT Bnd_OBB& OBB(const TopoDS_Shape& theShape,
0101                                const Standard_Real theFuzzyValue = Precision::Confusion());
0102 
0103   //! Computes the boundaries of the face using surface adaptor
0104   Standard_EXPORT void UVBounds (const TopoDS_Face& theFace,
0105                                  Standard_Real& UMin,
0106                                  Standard_Real& UMax,
0107                                  Standard_Real& VMin,
0108                                  Standard_Real& VMax);
0109 
0110   //! Computes parameter of the Point theP on
0111   //! the edge aE.
0112   //! Returns zero if the distance between point
0113   //! and edge is less than sum of tolerance value of edge and theTopP,
0114   //! otherwise and for following conditions returns
0115   //! negative value
0116   //! 1. the edge is degenerated (-1)
0117   //! 2. the edge does not contain 3d curve and pcurves (-2)
0118   //! 3. projection algorithm failed (-3)
0119   Standard_EXPORT Standard_Integer ComputePE (const gp_Pnt& theP, const Standard_Real theTolP,
0120                                               const TopoDS_Edge& theE, Standard_Real& theT,
0121                                               Standard_Real& theDist);
0122 
0123 
0124   //! Computes parameter of the vertex aV on
0125   //! the edge aE and correct tolerance value for 
0126   //! the vertex on the edge.
0127   //! Returns zero if the distance between vertex
0128   //! and edge is less than sum of tolerances and the fuzzy value,
0129   //! otherwise and for following conditions returns
0130   //! negative value: <br>
0131   //! 1. the edge is degenerated (-1) <br>
0132   //! 2. the edge does not contain 3d curve and pcurves (-2) <br>
0133   //! 3. projection algorithm failed (-3)
0134   Standard_EXPORT Standard_Integer ComputeVE (const TopoDS_Vertex& theV,
0135                                 const TopoDS_Edge& theE, 
0136                                 Standard_Real& theT,
0137                                 Standard_Real& theTol,
0138                                 const Standard_Real theFuzz = Precision::Confusion());
0139 
0140 
0141   //! Computes UV parameters of the vertex aV on face aF
0142   //! and correct tolerance value for the vertex on the face.
0143   //! Returns zero if the distance between vertex and face is
0144   //! less than or equal the sum of tolerances and the fuzzy value 
0145   //! and the projection point lays inside boundaries of the face.
0146   //! For following conditions returns negative value <br>
0147   //! 1. projection algorithm failed (-1) <br>
0148   //! 2. distance is more than sum of tolerances (-2) <br>
0149   //! 3. projection point out or on the boundaries of face (-3)
0150   Standard_EXPORT Standard_Integer ComputeVF (const TopoDS_Vertex& theVertex, 
0151                                 const TopoDS_Face& theFace, 
0152                                 Standard_Real& theU,
0153                                 Standard_Real& theV,
0154                                 Standard_Real& theTol,
0155                                 const Standard_Real theFuzz = Precision::Confusion());
0156 
0157 
0158   //! Returns the state of the point aP2D
0159   //! relative to face aF
0160   Standard_EXPORT TopAbs_State StatePointFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D);
0161   
0162 
0163   //! Returns true if the point aP2D is
0164   //! inside the boundaries of the face aF,
0165   //! otherwise returns false
0166   Standard_EXPORT Standard_Boolean IsPointInFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D);
0167   
0168 
0169   //! Returns true if the point aP2D is
0170   //! inside the boundaries of the face aF,
0171   //! otherwise returns false
0172   Standard_EXPORT Standard_Boolean IsPointInFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol);
0173   
0174 
0175   //! Returns true if the point aP2D is
0176   //! inside or on the boundaries of aF
0177   Standard_EXPORT Standard_Boolean IsPointInOnFace (const TopoDS_Face& aF, const gp_Pnt2d& aP2D);
0178   
0179 
0180   //! Returns true if the distance between point aP3D
0181   //! and face aF is less or equal to tolerance aTol
0182   //! and projection point is inside or on the boundaries
0183   //! of the face aF
0184   Standard_EXPORT Standard_Boolean IsValidPointForFace (const gp_Pnt& aP3D, const TopoDS_Face& aF, const Standard_Real aTol);
0185   
0186 
0187   //! Returns true if IsValidPointForFace returns true
0188   //! for both face aF1 and aF2
0189   Standard_EXPORT Standard_Boolean IsValidPointForFaces (const gp_Pnt& aP3D, const TopoDS_Face& aF1, const TopoDS_Face& aF2, const Standard_Real aTol);
0190   
0191 
0192   //! Returns true if IsValidPointForFace returns true
0193   //! for some 3d point that lay on the curve aIC bounded by
0194   //! parameters aT1 and aT2
0195   Standard_EXPORT Standard_Boolean IsValidBlockForFace (const Standard_Real aT1, const Standard_Real aT2, const IntTools_Curve& aIC, const TopoDS_Face& aF, const Standard_Real aTol);
0196   
0197 
0198   //! Returns true if IsValidBlockForFace returns true
0199   //! for both faces aF1 and aF2
0200   Standard_EXPORT Standard_Boolean IsValidBlockForFaces (const Standard_Real aT1, const Standard_Real aT2, const IntTools_Curve& aIC, const TopoDS_Face& aF1, const TopoDS_Face& aF2, const Standard_Real aTol);
0201   
0202 
0203   //! Computes parameter of the vertex aV on
0204   //! the curve aIC.
0205   //! Returns true if the distance between vertex and
0206   //! curve is less than sum of tolerance of aV and aTolC,
0207   //! otherwise or if projection algorithm failed
0208   //! returns false (in this case aT isn't significant)
0209   Standard_EXPORT Standard_Boolean IsVertexOnLine (const TopoDS_Vertex& aV, const IntTools_Curve& aIC, const Standard_Real aTolC, Standard_Real& aT);
0210   
0211 
0212   //! Computes parameter of the vertex aV on
0213   //! the curve aIC.
0214   //! Returns true if the distance between vertex and
0215   //! curve is less than sum of tolerance of aV and aTolC,
0216   //! otherwise or if projection algorithm failed
0217   //! returns false (in this case aT isn't significant)
0218   Standard_EXPORT Standard_Boolean IsVertexOnLine (const TopoDS_Vertex& aV, const Standard_Real aTolV, const IntTools_Curve& aIC, const Standard_Real aTolC, Standard_Real& aT);
0219   
0220 
0221   //! Computes parameter of the point aP on
0222   //! the edge aE.
0223   //! Returns false if projection algorithm failed
0224   //! other wiese returns true.
0225   Standard_EXPORT Standard_Boolean ProjectPointOnEdge (const gp_Pnt& aP, const TopoDS_Edge& aE, Standard_Real& aT);
0226   
0227   Standard_EXPORT Bnd_Box& BndBox (const TopoDS_Shape& theS);
0228   
0229   //! Returns true if the solid <theFace> has
0230   //! infinite bounds
0231   Standard_EXPORT Standard_Boolean IsInfiniteFace (const TopoDS_Face& theFace);
0232   
0233   //! Sets tolerance to be used for projection of point on surface.
0234   //! Clears map of already cached projectors in order to maintain
0235   //! correct value for all projectors
0236   Standard_EXPORT void SetPOnSProjectionTolerance (const Standard_Real theValue);
0237 
0238 
0239 
0240   DEFINE_STANDARD_RTTIEXT(IntTools_Context,Standard_Transient)
0241 
0242 protected:
0243 
0244   Handle(NCollection_BaseAllocator) myAllocator;
0245   NCollection_DataMap<TopoDS_Shape, IntTools_FClass2d*, TopTools_ShapeMapHasher>           myFClass2dMap;
0246   NCollection_DataMap<TopoDS_Shape, GeomAPI_ProjectPointOnSurf*, TopTools_ShapeMapHasher>  myProjPSMap;
0247   NCollection_DataMap<TopoDS_Shape, GeomAPI_ProjectPointOnCurve*, TopTools_ShapeMapHasher> myProjPCMap;
0248   NCollection_DataMap<TopoDS_Shape, BRepClass3d_SolidClassifier*, TopTools_ShapeMapHasher> mySClassMap;
0249   NCollection_DataMap<Handle(Geom_Curve), GeomAPI_ProjectPointOnCurve*> myProjPTMap;
0250   NCollection_DataMap<TopoDS_Shape, Geom2dHatch_Hatcher*, TopTools_ShapeMapHasher> myHatcherMap;
0251   NCollection_DataMap<TopoDS_Shape, IntTools_SurfaceRangeLocalizeData*, TopTools_ShapeMapHasher> myProjSDataMap;
0252   NCollection_DataMap<TopoDS_Shape, Bnd_Box*, TopTools_ShapeMapHasher> myBndBoxDataMap;
0253   NCollection_DataMap<TopoDS_Shape, BRepAdaptor_Surface*, TopTools_ShapeMapHasher> mySurfAdaptorMap;
0254   NCollection_DataMap<TopoDS_Shape, Bnd_OBB*, TopTools_ShapeMapHasher> myOBBMap; // Map of oriented bounding boxes
0255   Standard_Integer myCreateFlag;
0256   Standard_Real myPOnSTolerance;
0257 
0258 private:
0259 
0260   
0261   //! Clears map of already cached projectors.
0262   Standard_EXPORT void clearCachedPOnSProjectors();
0263 
0264 };
0265 
0266 DEFINE_STANDARD_HANDLE(IntTools_Context, Standard_Transient)
0267 
0268 #endif // _IntTools_Context_HeaderFile