1 // Created on: 1999-11-02
2 // Created by: Peter KURNEV
3 // Copyright (c) 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 _TopOpeBRepBuild_Tools_HeaderFile
18 #define _TopOpeBRepBuild_Tools_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <Standard_Integer.hxx>
25 #include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx>
26 #include <TopAbs_State.hxx>
27 #include <TopAbs_ShapeEnum.hxx>
28 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
29 #include <TopTools_MapOfShape.hxx>
30 #include <TopOpeBRepDS_DataMapOfShapeState.hxx>
31 #include <TopTools_IndexedMapOfShape.hxx>
32 #include <Standard_Boolean.hxx>
33 #include <TopTools_IndexedMapOfOrientedShape.hxx>
34 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
35 #include <Standard_Real.hxx>
36 class TopoDS_Shape;
37 class TopOpeBRepTool_ShapeClassifier;
38 class TopoDS_Face;
39 class TopoDS_Edge;
40 class gp_Vec;
41 class TopoDS_Wire;
42 
43 
44 //! Auxiliary  methods  used  in  TopOpeBRepBuild_Builder1  class
45 class TopOpeBRepBuild_Tools
46 {
47 public:
48 
49   DEFINE_STANDARD_ALLOC
50 
51 
52   Standard_EXPORT static void FindState (const TopoDS_Shape& aVertex, const TopAbs_State aState, const TopAbs_ShapeEnum aShapeEnum, const TopTools_IndexedDataMapOfShapeListOfShape& aMapVertexEdges, TopTools_MapOfShape& aMapProcessedVertices, TopOpeBRepDS_DataMapOfShapeState& aMapVs);
53 
54   Standard_EXPORT static void PropagateState (const TopOpeBRepDS_DataMapOfShapeState& aSplEdgesState, const TopTools_IndexedMapOfShape& anEdgesToRestMap, const TopAbs_ShapeEnum aShapeEnum1, const TopAbs_ShapeEnum aShapeEnum2, TopOpeBRepTool_ShapeClassifier& aShapeClassifier, TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState, const TopTools_MapOfShape& anUnkStateShapes);
55 
56   Standard_EXPORT static TopAbs_State FindStateThroughVertex (const TopoDS_Shape& aShape, TopOpeBRepTool_ShapeClassifier& aShapeClassifier, TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState, const TopTools_MapOfShape& anAvoidSubshMap);
57 
58   Standard_EXPORT static void PropagateStateForWires (const TopTools_IndexedMapOfShape& aFacesToRestMap, TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState);
59 
60   Standard_EXPORT static void SpreadStateToChild (const TopoDS_Shape& aShape, const TopAbs_State aState, TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState);
61 
62   Standard_EXPORT static void FindState1 (const TopoDS_Shape& anEdge, const TopAbs_State aState, const TopTools_IndexedDataMapOfShapeListOfShape& aMapEdgesFaces, TopTools_MapOfShape& aMapProcessedVertices, TopOpeBRepDS_DataMapOfShapeState& aMapVs);
63 
64   Standard_EXPORT static void FindState2 (const TopoDS_Shape& anEdge, const TopAbs_State aState, const TopTools_IndexedDataMapOfShapeListOfShape& aMapEdgesFaces, TopTools_MapOfShape& aMapProcessedEdges, TopOpeBRepDS_DataMapOfShapeState& aMapVs);
65 
66   Standard_EXPORT static Standard_Boolean GetAdjacentFace (const TopoDS_Shape& aFaceObj, const TopoDS_Shape& anEObj, const TopTools_IndexedDataMapOfShapeListOfShape& anEdgeFaceMap, TopoDS_Shape& anAdjFaceObj);
67 
68   Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Face& aFObj, const TopoDS_Edge& anEdgeObj, gp_Vec& aDirNormal);
69 
70   //! This  function  used  to  compute  normal  in  point  which  is  located
71   //! near  the  point  with  param  UV    (used  for  computation  of  normals  where  the  normal  in  the  point UV  equal  to  zero).
72   Standard_EXPORT static void GetNormalInNearestPoint (const TopoDS_Face& aFace, const TopoDS_Edge& anEdge, gp_Vec& aNormal);
73 
74   Standard_EXPORT static Standard_Boolean GetTangentToEdgeEdge (const TopoDS_Face& aFObj, const TopoDS_Edge& anEdgeObj, const TopoDS_Edge& aOriEObj, gp_Vec& aTangent);
75 
76   Standard_EXPORT static Standard_Boolean GetTangentToEdge (const TopoDS_Edge& anEdgeObj, gp_Vec& aTangent);
77 
78   //! Recompute  PCurves  of  the  all  edges  from  the  wire  on  the  <toFace>
79   Standard_EXPORT static void UpdatePCurves (const TopoDS_Wire& aWire, const TopoDS_Face& fromFace, const TopoDS_Face& toFace);
80 
81   //! recompute  PCurves  of  the  closing  (SIM  ,  with 2  PCurves)  edge on  the  NewFace
82   Standard_EXPORT static void UpdateEdgeOnPeriodicalFace (const TopoDS_Edge& aEdgeToUpdate, const TopoDS_Face& OldFace, const TopoDS_Face& NewFace);
83 
84   //! recompute  PCurve  of  the    edge on  the  NewFace
85   Standard_EXPORT static void UpdateEdgeOnFace (const TopoDS_Edge& aEdgeToUpdate, const TopoDS_Face& OldFace, const TopoDS_Face& NewFace);
86 
87   Standard_EXPORT static Standard_Boolean IsDegEdgesTheSame (const TopoDS_Shape& anE1, const TopoDS_Shape& anE2);
88 
89   //! test  if  <oldFace>  does  not  contain  INTERNAL  or  EXTERNAL  edges
90   //! and  remove  such  edges  in  case  of  its  presence.  The  result  is  stored  in  <corrFace>
91   Standard_EXPORT static void NormalizeFace (const TopoDS_Shape& oldFace, TopoDS_Shape& corrFace);
92 
93   //! test  if  UV  representation  of  <oldFace>  is  good  (i.e.  face  is  closed  in  2d).
94   //! if  face  is  not  closed  ,  this  method  will  try  to  close  such  face  and  will
95   //! return  corrected  edges  in  the  <aMapOfCorrect2dEdges>.  Parameter  <aSourceShapes>
96   //! used  to  fix  the  edge  (or  wires)  which  should  be  correct  (Corrector  used  it  as  a  start  shapes).
97   //! NOTE  :  Parameter  corrFace  doesn't  mean  anything.  If  you  want  to use  this  method  ,  rebuild  resulting  face
98   //! after  by  yourself  using  corrected  edges.
99   Standard_EXPORT static void CorrectFace2d (const TopoDS_Shape& oldFace, TopoDS_Shape& corrFace, const TopTools_IndexedMapOfOrientedShape& aSourceShapes, TopTools_IndexedDataMapOfShapeShape& aMapOfCorrect2dEdges);
100 
101   Standard_EXPORT static void CorrectTolerances (const TopoDS_Shape& aS, const Standard_Real aTolMax = 0.0001);
102 
103   Standard_EXPORT static void CorrectCurveOnSurface (const TopoDS_Shape& aS, const Standard_Real aTolMax = 0.0001);
104 
105   Standard_EXPORT static void CorrectPointOnCurve (const TopoDS_Shape& aS, const Standard_Real aTolMax = 0.0001);
106 
107   //! Checks if <theFace> has the properly closed in 2D boundary(ies)
108   Standard_EXPORT static Standard_Boolean CheckFaceClosed2d (const TopoDS_Face& theFace);
109 
110 
111 
112 
113 protected:
114 
115 
116 
117 
118 
119 private:
120 
121 
122 
123 
124 
125 };
126 
127 
128 
129 
130 
131 
132 
133 #endif // _TopOpeBRepBuild_Tools_HeaderFile
134