Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:56

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