1 // Created on: 1994-10-11 2 // Created by: Jean Yves LEBEY 3 // Copyright (c) 1994-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 _TopOpeBRep_FacesIntersector_HeaderFile 18 #define _TopOpeBRep_FacesIntersector_HeaderFile 19 20 #include <BRepAdaptor_Surface.hxx> 21 #include <GeomAbs_SurfaceType.hxx> 22 #include <IntPatch_Intersection.hxx> 23 #include <TopAbs_ShapeEnum.hxx> 24 #include <TopOpeBRep_LineInter.hxx> 25 #include <TopOpeBRep_HArray1OfLineInter.hxx> 26 #include <TopoDS_Face.hxx> 27 #include <TopTools_IndexedMapOfShape.hxx> 28 29 class BRepTopAdaptor_TopolTool; 30 class Bnd_Box; 31 32 //! Describes the intersection of two faces. 33 class TopOpeBRep_FacesIntersector 34 { 35 public: 36 37 DEFINE_STANDARD_ALLOC 38 39 40 Standard_EXPORT TopOpeBRep_FacesIntersector(); 41 42 //! Computes the intersection of faces S1 and S2. 43 Standard_EXPORT void Perform (const TopoDS_Shape& S1, const TopoDS_Shape& S2); 44 45 //! Computes the intersection of faces S1 and S2. 46 Standard_EXPORT void Perform (const TopoDS_Shape& S1, const TopoDS_Shape& S2, const Bnd_Box& B1, const Bnd_Box& B2); 47 48 Standard_EXPORT Standard_Boolean IsEmpty(); 49 50 Standard_EXPORT Standard_Boolean IsDone() const; 51 52 //! Returns True if Perform() arguments are two faces with the 53 //! same surface. 54 Standard_EXPORT Standard_Boolean SameDomain() const; 55 56 //! returns first or second intersected face. 57 Standard_EXPORT const TopoDS_Shape& Face (const Standard_Integer Index) const; 58 59 //! Returns True if Perform() arguments are two faces 60 //! SameDomain() and normals on both side. 61 //! Raise if SameDomain is False 62 Standard_EXPORT Standard_Boolean SurfacesSameOriented() const; 63 64 //! returns true if edge <E> is found as same as the edge 65 //! associated with a RESTRICTION line. 66 Standard_EXPORT Standard_Boolean IsRestriction (const TopoDS_Shape& E) const; 67 68 //! returns the map of edges found as TopeBRepBRep_RESTRICTION 69 Standard_EXPORT const TopTools_IndexedMapOfShape& Restrictions() const; 70 71 Standard_EXPORT void PrepareLines(); 72 73 Standard_EXPORT Handle(TopOpeBRep_HArray1OfLineInter) Lines(); 74 75 Standard_EXPORT Standard_Integer NbLines() const; 76 77 Standard_EXPORT void InitLine(); 78 79 Standard_EXPORT Standard_Boolean MoreLine() const; 80 81 Standard_EXPORT void NextLine(); 82 83 Standard_EXPORT TopOpeBRep_LineInter& CurrentLine(); 84 85 Standard_EXPORT Standard_Integer CurrentLineIndex() const; 86 87 Standard_EXPORT TopOpeBRep_LineInter& ChangeLine (const Standard_Integer IL); 88 89 90 //! Force the tolerance values used by the next Perform(S1,S2) call. 91 Standard_EXPORT void ForceTolerances (const Standard_Real tolarc, const Standard_Real toltang); 92 93 94 //! Return the tolerance values used in the last Perform() call 95 //! If ForceTolerances() has been called, return the given values. 96 //! If not, return values extracted from shapes. 97 Standard_EXPORT void GetTolerances (Standard_Real& tolarc, Standard_Real& toltang) const; 98 99 100 101 102 protected: 103 104 105 106 107 108 private: 109 110 111 Standard_EXPORT void FindLine(); 112 113 Standard_EXPORT void ResetIntersection(); 114 115 //! extract tolerance values from shapes <S1>,<S2>, 116 //! in order to perform intersection between <S1> and <S2> 117 //! with tolerance values "fitting" the shape tolerances. 118 //! (called by Perform() by default, when ForceTolerances() has not 119 //! been called) 120 Standard_EXPORT void ShapeTolerances (const TopoDS_Shape& S1, const TopoDS_Shape& S2); 121 122 //! returns the max tolerance of sub-shapes of type <T> 123 //! found in shape <S>. If no such sub-shape found, return 124 //! Precision::Intersection() 125 //! (called by ShapeTolerances()) 126 Standard_EXPORT Standard_Real ToleranceMax (const TopoDS_Shape& S, const TopAbs_ShapeEnum T) const; 127 128 129 IntPatch_Intersection myIntersector; 130 Standard_Boolean myIntersectionDone; 131 Standard_Real myTol1; 132 Standard_Real myTol2; 133 Standard_Boolean myForceTolerances; 134 Handle(TopOpeBRep_HArray1OfLineInter) myHAL; 135 TopOpeBRep_LineInter myLine; 136 Standard_Integer myLineIndex; 137 Standard_Boolean myLineFound; 138 Standard_Integer myLineNb; 139 TopoDS_Face myFace1; 140 TopoDS_Face myFace2; 141 Handle(BRepAdaptor_Surface) mySurface1; 142 Handle(BRepAdaptor_Surface) mySurface2; 143 GeomAbs_SurfaceType mySurfaceType1; 144 GeomAbs_SurfaceType mySurfaceType2; 145 Standard_Boolean mySurfacesSameOriented; 146 Handle(BRepTopAdaptor_TopolTool) myDomain1; 147 Handle(BRepTopAdaptor_TopolTool) myDomain2; 148 TopTools_IndexedMapOfShape myEdgeRestrictionMap; 149 TopoDS_Shape myNullShape; 150 151 152 }; 153 154 155 156 157 158 159 160 #endif // _TopOpeBRep_FacesIntersector_HeaderFile 161