1 // Created on: 1997-10-13 2 // Created by: Roman BORISOV 3 // Copyright (c) 1997-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 8 // This library is free software; you can redistribute it and/or modify it under 9 // the terms of the GNU Lesser General Public License version 2.1 as published 10 // by the Free Software Foundation, with special exception defined in the file 11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 12 // distribution for complete text of the license and disclaimer of any warranty. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _BRepOffsetAPI_NormalProjection_HeaderFile 18 #define _BRepOffsetAPI_NormalProjection_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_DefineAlloc.hxx> 22 #include <Standard_Handle.hxx> 23 24 #include <BRepAlgo_NormalProjection.hxx> 25 #include <BRepBuilderAPI_MakeShape.hxx> 26 #include <Standard_Real.hxx> 27 #include <GeomAbs_Shape.hxx> 28 #include <Standard_Integer.hxx> 29 #include <Standard_Boolean.hxx> 30 #include <TopTools_ListOfShape.hxx> 31 class TopoDS_Shape; 32 class TopoDS_Edge; 33 34 35 //! A framework to define projection onto a shape 36 //! according to the normal from each point to be projected. 37 //! The target shape is a face, and the source shape is an edge or a wire. 38 class BRepOffsetAPI_NormalProjection : public BRepBuilderAPI_MakeShape 39 { 40 public: 41 42 DEFINE_STANDARD_ALLOC 43 44 45 //! Constructs an empty framework to define projection on 46 //! a shape according to the normal from each point to be 47 //! projected to the shape. 48 Standard_EXPORT BRepOffsetAPI_NormalProjection(); 49 50 //! Constructs a framework to define projection onto the 51 //! basis shape S according to the normal from each point 52 //! to be projected from the shape added to this framework by Add. 53 //! Default parameters of the algorithm: Tol3D = 1.e-04, Tol2D =sqr(tol3d) 54 //! , InternalContinuity = GeomAbs_C2, MaxDegree = 14, MaxSeg = 16. 55 Standard_EXPORT BRepOffsetAPI_NormalProjection(const TopoDS_Shape& S); 56 57 //! Initializes the empty constructor framework with the shape S. 58 Standard_EXPORT void Init (const TopoDS_Shape& S); 59 60 //! Adds the shape ToProj to the framework for calculation 61 //! of the projection by Compute3d. 62 //! ToProj is an edge or a wire and will be projected onto the basis shape. 63 //! Exceptions 64 //! Standard_ConstructionError if ToProj is not added. 65 Standard_EXPORT void Add (const TopoDS_Shape& ToProj); 66 67 //! Sets the parameters used for computation 68 //! Tol3 is the required tolerance between the 3d projected 69 //! curve and its 2d representation 70 //! InternalContinuity is the order of constraints 71 //! used for approximation 72 //! MaxDeg and MaxSeg are the maximum degree and the maximum 73 //! number of segment for BSpline resulting of an approximation. 74 Standard_EXPORT void SetParams (const Standard_Real Tol3D, const Standard_Real Tol2D, const GeomAbs_Shape InternalContinuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSeg); 75 76 //! Sets the maximum distance between target shape and 77 //! shape to project. If this condition is not satisfied then corresponding 78 //! part of solution is discarded. 79 //! if MaxDist < 0 then this method does not affect the algorithm 80 Standard_EXPORT void SetMaxDistance (const Standard_Real MaxDist); 81 82 //! Manage limitation of projected edges. 83 Standard_EXPORT void SetLimit (const Standard_Boolean FaceBoundaries = Standard_True); 84 85 //! Returns true if a 3D curve is computed. If not, false is 86 //! returned and an initial 3D curve is kept to build the resulting edges. 87 Standard_EXPORT void Compute3d (const Standard_Boolean With3d = Standard_True); 88 89 //! Builds the result of the projection as a compound of 90 //! wires. Tries to build oriented wires. 91 Standard_EXPORT virtual void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; 92 93 //! Returns true if the object was correctly built by the shape 94 //! construction algorithm. 95 //! If at the construction time of the shape, the algorithm 96 //! cannot be completed, or the original data is corrupted, 97 //! IsDone returns false and therefore protects the use of 98 //! functions to access the result of the construction 99 //! (typically the Shape function). 100 Standard_EXPORT Standard_Boolean IsDone() const Standard_OVERRIDE; 101 102 //! Performs the projection. 103 //! The construction of the result is performed by Build. 104 //! Exceptions 105 //! StdFail_NotDone if the projection was not performed. 106 Standard_EXPORT const TopoDS_Shape& Projection() const; 107 108 //! Returns the initial face corresponding to the projected edge E. 109 //! Exceptions 110 //! StdFail_NotDone if no face was found. 111 //! Standard_NoSuchObject if a face corresponding to 112 //! E has already been found. 113 Standard_EXPORT const TopoDS_Shape& Couple (const TopoDS_Edge& E) const; 114 115 //! Returns the list of shapes generated from the 116 //! shape <S>. 117 Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE; 118 119 //! Returns the initial edge corresponding to the edge E 120 //! resulting from the computation of the projection. 121 //! Exceptions 122 //! StdFail_NotDone if no edge was found. 123 //! Standard_NoSuchObject if an edge corresponding to 124 //! E has already been found. 125 Standard_EXPORT const TopoDS_Shape& Ancestor (const TopoDS_Edge& E) const; 126 127 //! build the result as a list of wire if possible in -- 128 //! a first returns a wire only if there is only a wire. 129 Standard_EXPORT Standard_Boolean BuildWire (TopTools_ListOfShape& Liste) const; 130 131 132 133 134 protected: 135 136 137 138 139 140 private: 141 142 143 144 BRepAlgo_NormalProjection myNormalProjector; 145 146 147 }; 148 149 150 151 152 153 154 155 #endif // _BRepOffsetAPI_NormalProjection_HeaderFile 156