Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-27 10:37:01

0001 // Created on: 1996-12-16
0002 // Created by: Bruno DUMORTIER
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 _BiTgte_Blend_HeaderFile
0018 #define _BiTgte_Blend_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopoDS_Shape.hxx>
0025 #include <NCollection_List.hxx>
0026 #include <TopTools_ShapeMapHasher.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <NCollection_IndexedMap.hxx>
0029 #include <BRepOffset_Analyse.hxx>
0030 #include <BRepOffset_Offset.hxx>
0031 #include <BRepAlgo_Image.hxx>
0032 #include <Standard_Integer.hxx>
0033 #include <NCollection_Array1.hxx>
0034 #include <NCollection_HArray1.hxx>
0035 #include <BiTgte_ContactType.hxx>
0036 #include <Bnd_Box.hxx>
0037 class BRepAlgo_AsDes;
0038 class TopoDS_Face;
0039 class TopoDS_Edge;
0040 class Geom_Surface;
0041 class Geom_Curve;
0042 class Geom2d_Curve;
0043 class BRepOffset_Offset;
0044 class BRepOffset_Inter3d;
0045 
0046 //! Root class
0047 class BiTgte_Blend
0048 {
0049 public:
0050   DEFINE_STANDARD_ALLOC
0051 
0052   Standard_EXPORT BiTgte_Blend();
0053 
0054   //! <S>: Shape to be rounded
0055   //! <Radius>: radius of the fillet
0056   //! <Tol>: Tol3d used in approximations
0057   //! <NUBS>: if true, generate only NUBS surfaces,
0058   //! if false, generate analytical surfaces if possible
0059   Standard_EXPORT BiTgte_Blend(const TopoDS_Shape& S,
0060                                const double        Radius,
0061                                const double        Tol,
0062                                const bool          NUBS);
0063 
0064   Standard_EXPORT void Init(const TopoDS_Shape& S,
0065                             const double        Radius,
0066                             const double        Tol,
0067                             const bool          NUBS);
0068 
0069   //! Clear all the Fields.
0070   Standard_EXPORT void Clear();
0071 
0072   //! Set two faces of <myShape> on which the Sphere
0073   //! must roll.
0074   Standard_EXPORT void SetFaces(const TopoDS_Face& F1, const TopoDS_Face& F2);
0075 
0076   //! Set an edge of <myShape> to be rounded.
0077   Standard_EXPORT void SetEdge(const TopoDS_Edge& Edge);
0078 
0079   //! Set a face on which the fillet must stop.
0080   Standard_EXPORT void SetStoppingFace(const TopoDS_Face& Face);
0081 
0082   //! Compute the generated surfaces.
0083   //! If <BuildShape> is true, compute the resulting Shape.
0084   //! If false, only the blending surfaces are computed.
0085   Standard_EXPORT void Perform(const bool BuildShape = true);
0086 
0087   Standard_EXPORT bool IsDone() const;
0088 
0089   //! returns the result
0090   Standard_EXPORT const TopoDS_Shape& Shape() const;
0091 
0092   //! returns the Number of generated surfaces.
0093   Standard_EXPORT int NbSurfaces() const;
0094 
0095   //! returns the surface of range Index
0096   Standard_EXPORT occ::handle<Geom_Surface> Surface(const int Index) const;
0097 
0098   //! returns the surface of range Index
0099   Standard_EXPORT const TopoDS_Face& Face(const int Index) const;
0100 
0101   //! set in <LC> all the center lines
0102   Standard_EXPORT void CenterLines(NCollection_List<TopoDS_Shape>& LC) const;
0103 
0104   //! returns the surface generated by the centerline.
0105   //! <CenterLine> may be
0106   //! - an edge  : generate a pipe.
0107   //! - a vertex : generate a sphere.
0108   //! Warning: returns a Null Handle if <CenterLine> generates
0109   //! no surface.
0110   Standard_EXPORT occ::handle<Geom_Surface> Surface(const TopoDS_Shape& CenterLine) const;
0111 
0112   //! returns the face generated by the centerline.
0113   //! <CenterLine> may be
0114   //! - an edge  : generate a pipe.
0115   //! - a vertex : generate a sphere.
0116   //! Warning: returns a Null Shape if <CenterLine> generates
0117   //! no surface.
0118   Standard_EXPORT const TopoDS_Face& Face(const TopoDS_Shape& CenterLine) const;
0119 
0120   //! returns the type of contact
0121   Standard_EXPORT BiTgte_ContactType ContactType(const int Index) const;
0122 
0123   //! gives the first support shape relative to
0124   //! SurfaceFillet(Index);
0125   Standard_EXPORT const TopoDS_Shape& SupportShape1(const int Index) const;
0126 
0127   //! gives the second support shape relative to
0128   //! SurfaceFillet(Index);
0129   Standard_EXPORT const TopoDS_Shape& SupportShape2(const int Index) const;
0130 
0131   //! gives the 3d curve of SurfaceFillet(Index)
0132   //! on SupportShape1(Index)
0133   Standard_EXPORT occ::handle<Geom_Curve> CurveOnShape1(const int Index) const;
0134 
0135   //! gives the 3d curve of SurfaceFillet(Index)
0136   //! on SupportShape2(Index)
0137   Standard_EXPORT occ::handle<Geom_Curve> CurveOnShape2(const int Index) const;
0138 
0139   //! gives the PCurve associated to CurvOnShape1(Index)
0140   //! on the support face
0141   //! Warning: returns a Null Handle if SupportShape1 is not a Face
0142   Standard_EXPORT occ::handle<Geom2d_Curve> PCurveOnFace1(const int Index) const;
0143 
0144   //! gives the PCurve associated to CurveOnShape1(Index)
0145   //! on the Fillet
0146   Standard_EXPORT occ::handle<Geom2d_Curve> PCurve1OnFillet(const int Index) const;
0147 
0148   //! gives the PCurve associated to CurveOnShape2(Index)
0149   //! on the support face
0150   //! Warning: returns a Null Handle if SupportShape2 is not a Face
0151   Standard_EXPORT occ::handle<Geom2d_Curve> PCurveOnFace2(const int Index) const;
0152 
0153   //! gives the PCurve associated to CurveOnShape2(Index)
0154   //! on the fillet
0155   Standard_EXPORT occ::handle<Geom2d_Curve> PCurve2OnFillet(const int Index) const;
0156 
0157   Standard_EXPORT int NbBranches();
0158 
0159   //! Set in <From>,<To> the indices of the faces of
0160   //! the branche <Index>.
0161   //!
0162   //! i.e: Branche<Index> = Face(From) + Face(From+1) + ..+ Face(To)
0163   Standard_EXPORT void IndicesOfBranche(const int Index, int& From, int& To) const;
0164 
0165   //! Computes the center lines
0166   Standard_EXPORT void ComputeCenters();
0167 
0168 private:
0169   //! Perform the generated surfaces.
0170   Standard_EXPORT void ComputeSurfaces();
0171 
0172   //! Build the resulting shape
0173   //! All the faces must be computed
0174   Standard_EXPORT void ComputeShape();
0175 
0176   //! Computes the intersections with <Face> and all the
0177   //! OffsetFaces stored in <myMapSF>. Returns <True>
0178   //! if an intersections ends on a boundary of a Face.
0179   Standard_EXPORT bool Intersect(
0180     const TopoDS_Shape&                                                        Init,
0181     const TopoDS_Face&                                                         Face,
0182     const NCollection_DataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher>& MapSBox,
0183     const BRepOffset_Offset&                                                   OF1,
0184     BRepOffset_Inter3d&                                                        Inter);
0185 
0186   double       myRadius;
0187   double       myTol;
0188   bool         myNubs;
0189   TopoDS_Shape myShape;
0190   TopoDS_Shape myResult;
0191   bool         myBuildShape;
0192   NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0193     myAncestors;
0194   NCollection_DataMap<
0195     TopoDS_Shape,
0196     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>,
0197     TopTools_ShapeMapHasher>
0198     myCreated;
0199   NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0200                                                                                 myCutEdges;
0201   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>                 myFaces;
0202   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>                 myEdges;
0203   NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>                        myStopFaces;
0204   BRepOffset_Analyse                                                            myAnalyse;
0205   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>                 myCenters;
0206   NCollection_DataMap<TopoDS_Shape, BRepOffset_Offset, TopTools_ShapeMapHasher> myMapSF;
0207   BRepAlgo_Image                                                                myInitOffsetFace;
0208   BRepAlgo_Image                                                                myImage;
0209   BRepAlgo_Image                                                                myImageOffset;
0210   occ::handle<BRepAlgo_AsDes>                                                   myAsDes;
0211   int                                                                           myNbBranches;
0212   occ::handle<NCollection_HArray1<int>>                                         myIndices;
0213   bool                                                                          myDone;
0214 };
0215 
0216 #endif // _BiTgte_Blend_HeaderFile