Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:15

0001 // Created on: 2016-10-14
0002 // Created by: Alexander MALYSHEV
0003 // Copyright (c) 1999-2016 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BRepOffset_SimpleOffset_HeaderFile
0017 #define _BRepOffset_SimpleOffset_HeaderFile
0018 
0019 #include <BRepTools_Modification.hxx>
0020 #include <Geom2d_Curve.hxx>
0021 #include <GeomAbs_Shape.hxx>
0022 #include <NCollection_DataMap.hxx>
0023 #include <Standard_Macro.hxx>
0024 #include <Standard_Real.hxx>
0025 #include <Standard_Type.hxx>
0026 #include <TopoDS_Edge.hxx>
0027 #include <TopoDS_Face.hxx>
0028 #include <TopoDS_Vertex.hxx>
0029 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
0030 
0031 
0032 class BRepOffset_SimpleOffset;
0033 DEFINE_STANDARD_HANDLE(BRepOffset_SimpleOffset, BRepTools_Modification)
0034 
0035 //! This class represents mechanism of simple offset algorithm i. e.
0036 //! topology-preserve offset construction without intersection.
0037 //!
0038 //! The list below shows mapping scheme:
0039 //! - Each surface is mapped to its geometric offset surface.
0040 //! - For each edge, pcurves are mapped to the same pcurves on offset surfaces.
0041 //! - For each edge, 3d curve is constructed by re-approximation of pcurve on the first offset face.
0042 //! - Position of each vertex in a result shell is computed as average point of all ends of edges shared by that vertex.
0043 //! - Tolerances are updated according to the resulting geometry.
0044 class BRepOffset_SimpleOffset : public BRepTools_Modification
0045 {
0046 public:
0047 
0048   DEFINE_STANDARD_RTTI_INLINE(BRepOffset_SimpleOffset, BRepTools_Modification)
0049 
0050   //! Constructor.
0051   //! @param theInputShape shape to be offset
0052   //! @param theOffsetValue offset distance (signed)
0053   //! @param theTolerance tolerance for handling singular points
0054   Standard_EXPORT BRepOffset_SimpleOffset(const TopoDS_Shape& theInputShape,
0055                                           const Standard_Real theOffsetValue,
0056                                           const Standard_Real theTolerance);
0057 
0058   //! Returns Standard_True  if  the face  <F> has  been
0059   //! modified.  In this  case, <S> is the new geometric
0060   //! support of  the  face, <L> the  new location,<Tol>
0061   //! the new  tolerance.<RevWires> has  to  be set   to
0062   //! Standard_True   when the modification reverses the
0063   //! normal of  the   surface.(the wires   have  to  be
0064   //! reversed).   <RevFace>   has   to   be   set    to
0065   //! Standard_True if  the orientation  of the modified
0066   //! face changes in the  shells which contain  it.  --
0067   //! Here, <RevFace>  will  return Standard_True if the
0068   //! -- gp_Trsf is negative.
0069   Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F,
0070                                                Handle(Geom_Surface)& S,
0071                                                TopLoc_Location& L,
0072                                                Standard_Real& Tol,
0073                                                Standard_Boolean& RevWires,
0074                                                Standard_Boolean& RevFace) Standard_OVERRIDE;
0075 
0076   //! Returns Standard_True  if  the edge  <E> has  been
0077   //! modified.  In this case,  <C> is the new geometric
0078   //! support of the  edge, <L> the  new location, <Tol>
0079   //! the         new    tolerance.   Otherwise, returns
0080   //! Standard_False,    and  <C>,  <L>,   <Tol> are not
0081   //! significant.
0082   Standard_EXPORT Standard_Boolean NewCurve (const TopoDS_Edge& E,
0083                                              Handle(Geom_Curve)& C,
0084                                              TopLoc_Location& L,
0085                                              Standard_Real& Tol) Standard_OVERRIDE;
0086 
0087   //! Returns  Standard_True if the  vertex <V> has been
0088   //! modified.  In this  case, <P> is the new geometric
0089   //! support of the vertex,   <Tol> the new  tolerance.
0090   //! Otherwise, returns Standard_False, and <P>,  <Tol>
0091   //! are not significant.
0092   Standard_EXPORT Standard_Boolean NewPoint (const TopoDS_Vertex& V,
0093                                              gp_Pnt& P,
0094                                              Standard_Real& Tol) Standard_OVERRIDE;
0095 
0096   //! Returns Standard_True if  the edge  <E> has a  new
0097   //! curve on surface on the face <F>.In this case, <C>
0098   //! is the new geometric support of  the edge, <L> the
0099   //! new location, <Tol> the new tolerance.
0100   //! Otherwise, returns  Standard_False, and <C>,  <L>,
0101   //! <Tol> are not significant.
0102   Standard_EXPORT Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
0103                                                const TopoDS_Face& F,
0104                                                const TopoDS_Edge& NewE,
0105                                                const TopoDS_Face& NewF,
0106                                                Handle(Geom2d_Curve)& C,
0107                                                Standard_Real& Tol) Standard_OVERRIDE;
0108 
0109   //! Returns Standard_True if the Vertex  <V> has a new
0110   //! parameter on the  edge <E>. In  this case,  <P> is
0111   //! the parameter,    <Tol>  the     new    tolerance.
0112   //! Otherwise, returns Standard_False, and <P>,  <Tol>
0113   //! are not significant.
0114   Standard_EXPORT Standard_Boolean NewParameter (const TopoDS_Vertex& V,
0115                                                  const TopoDS_Edge& E,
0116                                                  Standard_Real& P,
0117                                                  Standard_Real& Tol) Standard_OVERRIDE;
0118 
0119   //! Returns the  continuity of  <NewE> between <NewF1>
0120   //! and <NewF2>.
0121   //!
0122   //! <NewE> is the new  edge created from <E>.  <NewF1>
0123   //! (resp. <NewF2>) is the new  face created from <F1>
0124   //! (resp. <F2>).
0125   Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E,
0126                                             const TopoDS_Face& F1,
0127                                             const TopoDS_Face& F2,
0128                                             const TopoDS_Edge& NewE,
0129                                             const TopoDS_Face& NewF1,
0130                                             const TopoDS_Face& NewF2) Standard_OVERRIDE;
0131 
0132 private:
0133 
0134   //! Method to fill new face data for single face.
0135   void FillFaceData(const TopoDS_Face& theFace);
0136 
0137   //! Method to fill new edge data for single edge.
0138   void FillEdgeData(const TopoDS_Edge& theEdge,
0139                     const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeFaceMap,
0140                     const Standard_Integer theIdx);
0141 
0142   //! Method to fill new vertex data for single vertex.
0143   void FillVertexData(const TopoDS_Vertex& theVertex,
0144                       const TopTools_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap,
0145                       const Standard_Integer theIdx);
0146 
0147   struct NewFaceData
0148   {
0149     Handle(Geom_Surface) myOffsetS;
0150     TopLoc_Location myL;
0151     Standard_Real myTol;
0152     Standard_Boolean myRevWires;
0153     Standard_Boolean myRevFace;
0154   };
0155 
0156   struct NewEdgeData
0157   {
0158     Handle(Geom_Curve) myOffsetC; // Resulting curve.
0159     TopLoc_Location myL;
0160     Standard_Real myTol;
0161   };
0162 
0163   struct NewVertexData
0164   {
0165     gp_Pnt myP;
0166     Standard_Real myTol;
0167   };
0168 
0169   //! Fills offset data.
0170   void FillOffsetData(const TopoDS_Shape& theInputShape);
0171 
0172   //! Copy-assignment constructor and copy constructor are not allowed.
0173   void operator=(const BRepOffset_SimpleOffset&);
0174   BRepOffset_SimpleOffset(const BRepOffset_SimpleOffset&);
0175 
0176   //! Map of faces to new faces information.
0177   NCollection_DataMap<TopoDS_Face, NewFaceData> myFaceInfo;
0178 
0179   //! Map of edges to new edges information.
0180   NCollection_DataMap<TopoDS_Edge, NewEdgeData> myEdgeInfo;
0181 
0182   //! Map of vertices to new vertices information.
0183   NCollection_DataMap<TopoDS_Vertex, NewVertexData> myVertexInfo;
0184 
0185   //! Offset value.
0186   Standard_Real myOffsetValue;
0187 
0188   //! Tolerance.
0189   Standard_Real myTolerance;
0190 };
0191 
0192 #endif // _BRepOffset_SimpleOffset_HeaderFile