Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:16:57

0001 // Created on: 1998-06-17
0002 // Created by: data exchange team
0003 // Copyright (c) 1998-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 _ShapeFix_Edge_HeaderFile
0018 #define _ShapeFix_Edge_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <ShapeExtend_Status.hxx>
0026 class ShapeConstruct_ProjectCurveOnSurface;
0027 class TopoDS_Edge;
0028 class TopoDS_Face;
0029 class Geom_Surface;
0030 class TopLoc_Location;
0031 class ShapeAnalysis_Surface;
0032 class ShapeBuild_ReShape;
0033 
0034 // resolve name collisions with X11 headers
0035 #ifdef Status
0036   #undef Status
0037 #endif
0038 
0039 //! Fixing invalid edge.
0040 //! Geometrical and/or topological inconsistency:
0041 //! - no 3d curve or pcurve,
0042 //! - mismatching orientation of 3d curve and pcurve,
0043 //! - incorrect SameParameter flag (curve deviation is greater than
0044 //! edge tolerance),
0045 //! - not adjacent curves (3d or pcurve) to the vertices.
0046 class ShapeFix_Edge : public Standard_Transient
0047 {
0048 
0049 public:
0050   //! Empty constructor
0051   Standard_EXPORT ShapeFix_Edge();
0052 
0053   //! Returns the projector used for recomputing missing pcurves
0054   //! Can be used for adjusting parameters of projector
0055   Standard_EXPORT occ::handle<ShapeConstruct_ProjectCurveOnSurface> Projector();
0056 
0057   Standard_EXPORT bool FixRemovePCurve(const TopoDS_Edge& edge, const TopoDS_Face& face);
0058 
0059   //! Removes the pcurve(s) of the edge if it does not match the
0060   //! vertices
0061   //! Check is done
0062   //! Use    : It is to be called when pcurve of an edge can be wrong
0063   //! (e.g., after import from IGES)
0064   //! Returns: True, if does not match, removed (status DONE)
0065   //! False, (status OK) if matches or (status FAIL) if no pcurve,
0066   //! nothing done
0067   Standard_EXPORT bool FixRemovePCurve(const TopoDS_Edge&               edge,
0068                                        const occ::handle<Geom_Surface>& surface,
0069                                        const TopLoc_Location&           location);
0070 
0071   //! Removes 3d curve of the edge if it does not match the vertices
0072   //! Returns: True, if does not match, removed (status DONE)
0073   //! False, (status OK) if matches or (status FAIL) if no 3d curve,
0074   //! nothing done
0075   Standard_EXPORT bool FixRemoveCurve3d(const TopoDS_Edge& edge);
0076 
0077   //! See method below for information
0078   Standard_EXPORT bool FixAddPCurve(const TopoDS_Edge& edge,
0079                                     const TopoDS_Face& face,
0080                                     const bool         isSeam,
0081                                     const double       prec = 0.0);
0082 
0083   //! See method below for information
0084   Standard_EXPORT bool FixAddPCurve(const TopoDS_Edge&               edge,
0085                                     const occ::handle<Geom_Surface>& surface,
0086                                     const TopLoc_Location&           location,
0087                                     const bool                       isSeam,
0088                                     const double                     prec = 0.0);
0089 
0090   //! See method below for information
0091   Standard_EXPORT bool FixAddPCurve(const TopoDS_Edge&                        edge,
0092                                     const TopoDS_Face&                        face,
0093                                     const bool                                isSeam,
0094                                     const occ::handle<ShapeAnalysis_Surface>& surfana,
0095                                     const double                              prec = 0.0);
0096 
0097   //! Adds pcurve(s) of the edge if missing (by projecting 3d curve)
0098   //! Parameter isSeam indicates if the edge is a seam.
0099   //! The parameter <prec> defines the precision for calculations.
0100   //! If it is 0 (default), the tolerance of the edge is taken.
0101   //! Remark : This method is rather for internal use since it accepts parameter
0102   //! <surfana> for optimization of computations
0103   //! Use    : It is to be called after FixRemovePCurve (if removed) or in any
0104   //! case when edge can have no pcurve
0105   //! Returns: True if pcurve was added, else False
0106   //! Status :
0107   //! OK   : Pcurve exists
0108   //! FAIL1: No 3d curve
0109   //! FAIL2: fail during projecting
0110   //! DONE1: Pcurve was added
0111   //! DONE2: specific case of pcurve going through degenerated point on
0112   //! sphere encountered during projection (see class
0113   //! ShapeConstruct_ProjectCurveOnSurface for more info)
0114   Standard_EXPORT bool FixAddPCurve(const TopoDS_Edge&                        edge,
0115                                     const occ::handle<Geom_Surface>&          surface,
0116                                     const TopLoc_Location&                    location,
0117                                     const bool                                isSeam,
0118                                     const occ::handle<ShapeAnalysis_Surface>& surfana,
0119                                     const double                              prec = 0.0);
0120 
0121   //! Tries to build 3d curve of the edge if missing
0122   //! Use    : It is to be called after FixRemoveCurve3d (if removed) or in any
0123   //! case when edge can have no 3d curve
0124   //! Returns: True if 3d curve was added, else False
0125   //! Status :
0126   //! OK   : 3d curve exists
0127   //! FAIL1: BRepLib::BuildCurve3d() has failed
0128   //! DONE1: 3d curve was added
0129   Standard_EXPORT bool FixAddCurve3d(const TopoDS_Edge& edge);
0130 
0131   Standard_EXPORT bool FixVertexTolerance(const TopoDS_Edge& edge, const TopoDS_Face& face);
0132 
0133   //! Increases the tolerances of the edge vertices to comprise
0134   //! the ends of 3d curve and pcurve on the given face
0135   //! (first method) or all pcurves stored in an edge (second one)
0136   //! Returns: True, if tolerances have been increased, otherwise False
0137   //! Status:
0138   //! OK   : the original tolerances have not been changed
0139   //! DONE1: the tolerance of first vertex has been increased
0140   //! DONE2: the tolerance of last vertex has been increased
0141   Standard_EXPORT bool FixVertexTolerance(const TopoDS_Edge& edge);
0142 
0143   Standard_EXPORT bool FixReversed2d(const TopoDS_Edge& edge, const TopoDS_Face& face);
0144 
0145   //! Fixes edge if pcurve is directed opposite to 3d curve
0146   //! Check is done by call to the function
0147   //! ShapeAnalysis_Edge::CheckCurve3dWithPCurve()
0148   //! Warning: For seam edge this method will check and fix the pcurve in only
0149   //! one direction. Hence, it should be called twice for seam edge:
0150   //! once with edge orientation FORWARD and once with REVERSED.
0151   //! Returns: False if nothing done, True if reversed (status DONE)
0152   //! Status:  OK    - pcurve OK, nothing done
0153   //! FAIL1 - no pcurve
0154   //! FAIL2 - no 3d curve
0155   //! DONE1 - pcurve was reversed
0156   Standard_EXPORT bool FixReversed2d(const TopoDS_Edge&               edge,
0157                                      const occ::handle<Geom_Surface>& surface,
0158                                      const TopLoc_Location&           location);
0159 
0160   //! Tries to make edge SameParameter and sets corresponding
0161   //! tolerance and SameParameter flag.
0162   //! First, it makes edge same range if SameRange flag is not set.
0163   //!
0164   //! If flag SameParameter is set, this method calls the
0165   //! function ShapeAnalysis_Edge::CheckSameParameter() that
0166   //! calculates the maximal deviation of pcurves of the edge from
0167   //! its 3d curve. If deviation > tolerance, the tolerance of edge
0168   //! is increased to a value of deviation. If deviation < tolerance
0169   //! nothing happens.
0170   //!
0171   //! If flag SameParameter is not set, this method chooses the best
0172   //! variant (one that has minimal tolerance), either
0173   //! a. only after computing deviation (as above) or
0174   //! b. after calling standard procedure BRepLib::SameParameter
0175   //! and computing deviation (as above). If <tolerance> > 0, it is
0176   //! used as parameter for BRepLib::SameParameter, otherwise,
0177   //! tolerance of the edge is used.
0178   //!
0179   //! Use    : Is to be called after all pcurves and 3d curve of the edge are
0180   //! correctly computed
0181   //! Remark : SameParameter flag is always set to True after this method
0182   //! Returns: True, if something done, else False
0183   //! Status : OK    - edge was initially SameParameter, nothing is done
0184   //! FAIL1 - computation of deviation of pcurves from 3d curve has failed
0185   //! FAIL2 - BRepLib::SameParameter() has failed
0186   //! DONE1 - tolerance of the edge was increased
0187   //! DONE2 - flag SameParameter was set to True (only if
0188   //! BRepLib::SameParameter() did not set it)
0189   //! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
0190   //! DONE4 - not used anymore
0191   //! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
0192   //! (only for edges with not set SameParameter)
0193   Standard_EXPORT bool FixSameParameter(const TopoDS_Edge& edge, const double tolerance = 0.0);
0194 
0195   //! Tries to make edge SameParameter and sets corresponding
0196   //! tolerance and SameParameter flag.
0197   //! First, it makes edge same range if SameRange flag is not set.
0198   //!
0199   //! If flag SameParameter is set, this method calls the
0200   //! function ShapeAnalysis_Edge::CheckSameParameter() that
0201   //! calculates the maximal deviation of pcurves of the edge from
0202   //! its 3d curve. If deviation > tolerance, the tolerance of edge
0203   //! is increased to a value of deviation. If deviation < tolerance
0204   //! nothing happens.
0205   //!
0206   //! If flag SameParameter is not set, this method chooses the best
0207   //! variant (one that has minimal tolerance), either
0208   //! a. only after computing deviation (as above) or
0209   //! b. after calling standard procedure BRepLib::SameParameter
0210   //! and computing deviation (as above). If <tolerance> > 0, it is
0211   //! used as parameter for BRepLib::SameParameter, otherwise,
0212   //! tolerance of the edge is used.
0213   //!
0214   //! Use    : Is to be called after all pcurves and 3d curve of the edge are
0215   //! correctly computed
0216   //! Remark : SameParameter flag is always set to True after this method
0217   //! Returns: True, if something done, else False
0218   //! Status : OK    - edge was initially SameParameter, nothing is done
0219   //! FAIL1 - computation of deviation of pcurves from 3d curve has failed
0220   //! FAIL2 - BRepLib::SameParameter() has failed
0221   //! DONE1 - tolerance of the edge was increased
0222   //! DONE2 - flag SameParameter was set to True (only if
0223   //! BRepLib::SameParameter() did not set it)
0224   //! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
0225   //! DONE4 - not used anymore
0226   //! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
0227   //! (only for edges with not set SameParameter)
0228   Standard_EXPORT bool FixSameParameter(const TopoDS_Edge& edge,
0229                                         const TopoDS_Face& face,
0230                                         const double       tolerance = 0.0);
0231 
0232   //! Returns the status (in the form of True/False) of last Fix
0233   Standard_EXPORT bool Status(const ShapeExtend_Status status) const;
0234 
0235   //! Sets context
0236   Standard_EXPORT void SetContext(const occ::handle<ShapeBuild_ReShape>& context);
0237 
0238   //! Returns context
0239   Standard_EXPORT occ::handle<ShapeBuild_ReShape> Context() const;
0240 
0241   DEFINE_STANDARD_RTTIEXT(ShapeFix_Edge, Standard_Transient)
0242 
0243 protected:
0244   occ::handle<ShapeBuild_ReShape>                   myContext;
0245   int                                               myStatus;
0246   occ::handle<ShapeConstruct_ProjectCurveOnSurface> myProjector;
0247 };
0248 
0249 #endif // _ShapeFix_Edge_HeaderFile