1 // File: TopOpeBRepDS_EdgeInterferenceTool.cxx
2 // Created: Tue Nov 8 14:52:21 1994
3 // Author: Jean Yves LEBEY
6 #include <TopOpeBRepDS_EdgeInterferenceTool.ixx>
8 #include <TopOpeBRepDS_CurvePointInterference.hxx>
9 #include <TopOpeBRepDS_EdgeVertexInterference.hxx>
10 #include <BRepLProp_CLProps.hxx>
11 #include <BRep_Tool.hxx>
12 #include <TopoDS_Iterator.hxx>
13 #include <Precision.hxx>
15 #include <TopOpeBRepTool_ShapeTool.hxx>
16 #include <Standard_ProgramError.hxx>
19 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettracePEI();
22 //=======================================================================
23 //function : TopOpeBRepDS_EdgeInterferenceTool
25 //=======================================================================
27 TopOpeBRepDS_EdgeInterferenceTool::TopOpeBRepDS_EdgeInterferenceTool()
31 static Standard_Real Parameter(const Handle(TopOpeBRepDS_Interference)& I)
34 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
35 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
36 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
37 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
40 cout<<"EdgeInterference : mauvais type d'interference"<<endl;
42 Standard_ProgramError::Raise("TopOpeBRepDS_EdgeInterferenceTool1");
48 //=======================================================================
51 //=======================================================================
53 void TopOpeBRepDS_EdgeInterferenceTool::Init
54 (const TopoDS_Shape& E, const Handle(TopOpeBRepDS_Interference)& I)
56 myEdgeOrientation = E.Orientation();
57 myEdgeOriented = I->Support();
59 // NYI 971219 : on ne tient pas compte de l'orientation de E = arete-mere de l'interference I
60 if (myEdgeOrientation == TopAbs_INTERNAL ||
61 myEdgeOrientation == TopAbs_EXTERNAL) {
65 // la premiere arete orientee est gardee dans myEdgeOriented pour MAJ de
66 // l'arete croisee dans l'interference resultat.
68 // par = parametre sur l'arete croisee
69 Standard_Real par = ::Parameter(I);
70 gp_Dir T,N; Standard_Real C;
71 TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
75 //=======================================================================
78 //=======================================================================
80 void TopOpeBRepDS_EdgeInterferenceTool::Add
81 (const TopoDS_Shape& E,
82 const TopoDS_Shape& V,
83 const Handle(TopOpeBRepDS_Interference)& I)
85 TopAbs_Orientation Eori = E.Orientation();
86 if (Eori == TopAbs_INTERNAL ||
87 Eori == TopAbs_EXTERNAL) {
91 // premiere interference sur arete orientee : Init
92 if (myEdgeOrientation == TopAbs_INTERNAL ||
93 myEdgeOrientation == TopAbs_EXTERNAL) {
98 // V est un sommet de E ?
99 Standard_Boolean VofE = Standard_False;
100 TopoDS_Iterator it(E,Standard_False);
101 for ( ; it.More(); it.Next() ) {
102 const TopoDS_Shape& S = it.Value();
104 VofE = Standard_True;
110 if (TopOpeBRepDS_GettracePEI() && !VofE) {
111 cout<<"===================== VofE = False"<<endl;
115 // V est un sommet de E
116 const TopoDS_Vertex& VV = TopoDS::Vertex(V);
117 const TopoDS_Edge& EE = TopoDS::Edge(E);
118 Standard_Real par = BRep_Tool::Parameter(VV,EE);
120 gp_Dir T,N; Standard_Real C;
121 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
122 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
123 TopAbs_Orientation oritan = it.Value().Orientation();
124 myTool.Compare(tol,T,N,C,oriloc,oritan);
127 //=======================================================================
130 //=======================================================================
132 void TopOpeBRepDS_EdgeInterferenceTool::Add
133 (const TopoDS_Shape& E,
134 // const TopOpeBRepDS_Point& P,
135 const TopOpeBRepDS_Point& ,
136 const Handle(TopOpeBRepDS_Interference)& I)
138 TopAbs_Orientation Eori = E.Orientation();
139 if (Eori == TopAbs_INTERNAL ||
140 Eori == TopAbs_EXTERNAL) {
144 // premiere interference sur arete orientee : Init
145 if (myEdgeOrientation == TopAbs_INTERNAL ||
146 myEdgeOrientation == TopAbs_EXTERNAL) {
151 Standard_Real par = ::Parameter(I);
153 gp_Dir T,N; Standard_Real C;
154 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
155 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
156 TopAbs_Orientation oritan = TopAbs_INTERNAL;
157 myTool.Compare(tol,T,N,C,oriloc,oritan);
160 //=======================================================================
161 //function : Transition
163 //=======================================================================
165 void TopOpeBRepDS_EdgeInterferenceTool::Transition
166 (const Handle(TopOpeBRepDS_Interference)& I) const
168 TopOpeBRepDS_Transition& T = I->ChangeTransition();
170 if (myEdgeOrientation == TopAbs_INTERNAL) {
171 T.Set(TopAbs_IN,TopAbs_IN);
173 else if (myEdgeOrientation == TopAbs_EXTERNAL) {
174 T.Set(TopAbs_OUT,TopAbs_OUT);
177 I->Support(myEdgeOriented);
178 T.Set(myTool.StateBefore(),myTool.StateAfter());