Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/BRepOffset_SimpleOffset.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 <TopoDS_Shape.hxx>
0030 #include <NCollection_List.hxx>
0031 #include <TopTools_ShapeMapHasher.hxx>
0032 #include <NCollection_IndexedDataMap.hxx>
0033 
0034 //! This class represents mechanism of simple offset algorithm
0035 //! i.e. topology-preserve offset construction without intersection.
0036 //!
0037 //! The list below shows mapping scheme:
0038 //! - Each surface is mapped to its geometric offset surface.
0039 //! - For each edge, pcurves are mapped to the same pcurves on offset surfaces.
0040 //! - For each edge, 3d curve is constructed by re-approximation of pcurve on the first offset face.
0041 //! - Position of each vertex in a result shell is computed as average point of all ends of edges
0042 //! shared by that vertex.
0043 //! - Tolerances are updated according to the resulting geometry.
0044 class BRepOffset_SimpleOffset : public BRepTools_Modification
0045 {
0046 public:
0047   DEFINE_STANDARD_RTTI_INLINE(BRepOffset_SimpleOffset, BRepTools_Modification)
0048 
0049   //! Constructor.
0050   //! @param theInputShape shape to be offset
0051   //! @param theOffsetValue offset distance (signed)
0052   //! @param theTolerance tolerance for handling singular points
0053   Standard_EXPORT BRepOffset_SimpleOffset(const TopoDS_Shape& theInputShape,
0054                                           const double        theOffsetValue,
0055                                           const double        theTolerance);
0056 
0057   //! Returns true if the face <F> has been
0058   //! modified. In this case, <S> is the new geometric
0059   //! support of the face, <L> the new location,
0060   //! <Tol> the new tolerance. <RevWires> has to be set to
0061   //! true when the modification reverses the
0062   //! normal of the surface. (the wires have to be
0063   //! reversed). <RevFace> has to be set to
0064   //! true if the orientation of the modified
0065   //! face changes in the shells which contain it.
0066   //! Here, <RevFace> will return true if the
0067   //! gp_Trsf is negative.
0068   Standard_EXPORT bool NewSurface(const TopoDS_Face&         F,
0069                                   occ::handle<Geom_Surface>& S,
0070                                   TopLoc_Location&           L,
0071                                   double&                    Tol,
0072                                   bool&                      RevWires,
0073                                   bool&                      RevFace) override;
0074 
0075   //! Returns true if the edge <E> has been
0076   //! modified. In this case, <C> is the new geometric
0077   //! support of the edge, <L> the new location,
0078   //! <Tol> the new tolerance. Otherwise, returns
0079   //! false, and <C>, <L>,
0080   //! <Tol> are not significant.
0081   Standard_EXPORT bool NewCurve(const TopoDS_Edge&       E,
0082                                 occ::handle<Geom_Curve>& C,
0083                                 TopLoc_Location&         L,
0084                                 double&                  Tol) override;
0085 
0086   //! Returns true if the vertex <V> has been
0087   //! modified. In this case, <P> is the new geometric
0088   //! support of the vertex, <Tol> the new tolerance.
0089   //! Otherwise, returns false, and <P>,
0090   //! <Tol> are not significant.
0091   Standard_EXPORT bool NewPoint(const TopoDS_Vertex& V, gp_Pnt& P, double& Tol) override;
0092 
0093   //! Returns true if the edge <E> has a new
0094   //! curve on surface on the face <F>. In this case,
0095   //! <C> is the new geometric support of the edge,
0096   //! <L> the new location, <Tol> the new tolerance.
0097   //! Otherwise, returns false, and <C>, <L>,
0098   //! <Tol> are not significant.
0099   Standard_EXPORT bool NewCurve2d(const TopoDS_Edge&         E,
0100                                   const TopoDS_Face&         F,
0101                                   const TopoDS_Edge&         NewE,
0102                                   const TopoDS_Face&         NewF,
0103                                   occ::handle<Geom2d_Curve>& C,
0104                                   double&                    Tol) override;
0105 
0106   //! Returns true if the Vertex <V> has a new
0107   //! parameter on the edge <E>. In this case,
0108   //! <P> is the parameter, <Tol> the new tolerance.
0109   //! Otherwise, returns false, and <P>,
0110   //! <Tol> are not significant.
0111   Standard_EXPORT bool NewParameter(const TopoDS_Vertex& V,
0112                                     const TopoDS_Edge&   E,
0113                                     double&              P,
0114                                     double&              Tol) override;
0115 
0116   //! Returns the continuity of <NewE> between <NewF1>
0117   //! and <NewF2>.
0118   //!
0119   //! <NewE> is the new edge created from <E>. <NewF1>
0120   //! (resp. <NewF2>) is the new face created from <F1>
0121   //! (resp. <F2>).
0122   Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,
0123                                            const TopoDS_Face& F1,
0124                                            const TopoDS_Face& F2,
0125                                            const TopoDS_Edge& NewE,
0126                                            const TopoDS_Face& NewF1,
0127                                            const TopoDS_Face& NewF2) override;
0128 
0129 private:
0130   //! Method to fill new face data for single face.
0131   void FillFaceData(const TopoDS_Face& theFace);
0132 
0133   //! Method to fill new edge data for single edge.
0134   void FillEdgeData(const TopoDS_Edge&                                         theEdge,
0135                     const NCollection_IndexedDataMap<TopoDS_Shape,
0136                                                      NCollection_List<TopoDS_Shape>,
0137                                                      TopTools_ShapeMapHasher>& theEdgeFaceMap,
0138                     const int                                                  theIdx);
0139 
0140   //! Method to fill new vertex data for single vertex.
0141   void FillVertexData(const TopoDS_Vertex&                                       theVertex,
0142                       const NCollection_IndexedDataMap<TopoDS_Shape,
0143                                                        NCollection_List<TopoDS_Shape>,
0144                                                        TopTools_ShapeMapHasher>& theVertexEdgeMap,
0145                       const int                                                  theIdx);
0146 
0147   struct NewFaceData
0148   {
0149     occ::handle<Geom_Surface> myOffsetS;
0150     TopLoc_Location           myL;
0151     double                    myTol;
0152     bool                      myRevWires;
0153     bool                      myRevFace;
0154   };
0155 
0156   struct NewEdgeData
0157   {
0158     occ::handle<Geom_Curve> myOffsetC; // Resulting curve.
0159     TopLoc_Location         myL;
0160     double                  myTol;
0161   };
0162 
0163   struct NewVertexData
0164   {
0165     gp_Pnt myP;
0166     double 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&)          = delete;
0174   BRepOffset_SimpleOffset(const BRepOffset_SimpleOffset&) = delete;
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   double myOffsetValue;
0187 
0188   //! Tolerance.
0189   double myTolerance;
0190 };
0191 
0192 #endif // _BRepOffset_SimpleOffset_HeaderFile