1 // Created on: 1994-11-08
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TopOpeBRepDS_EdgeInterferenceTool.ixx>
19 #include <TopOpeBRepDS_CurvePointInterference.hxx>
20 #include <TopOpeBRepDS_EdgeVertexInterference.hxx>
21 #include <BRepLProp_CLProps.hxx>
22 #include <BRep_Tool.hxx>
23 #include <TopoDS_Iterator.hxx>
24 #include <Precision.hxx>
26 #include <TopOpeBRepTool_ShapeTool.hxx>
27 #include <Standard_ProgramError.hxx>
30 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettracePEI();
33 //=======================================================================
34 //function : TopOpeBRepDS_EdgeInterferenceTool
36 //=======================================================================
38 TopOpeBRepDS_EdgeInterferenceTool::TopOpeBRepDS_EdgeInterferenceTool()
42 static Standard_Real Parameter(const Handle(TopOpeBRepDS_Interference)& I)
45 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
46 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
47 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
48 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
51 cout<<"EdgeInterference : mauvais type d'interference"<<endl;
53 Standard_ProgramError::Raise("TopOpeBRepDS_EdgeInterferenceTool1");
59 //=======================================================================
62 //=======================================================================
64 void TopOpeBRepDS_EdgeInterferenceTool::Init
65 (const TopoDS_Shape& E, const Handle(TopOpeBRepDS_Interference)& I)
67 myEdgeOrientation = E.Orientation();
68 myEdgeOriented = I->Support();
70 // NYI 971219 : on ne tient pas compte de l'orientation de E = arete-mere de l'interference I
71 if (myEdgeOrientation == TopAbs_INTERNAL ||
72 myEdgeOrientation == TopAbs_EXTERNAL) {
76 // la premiere arete orientee est gardee dans myEdgeOriented pour MAJ de
77 // l'arete croisee dans l'interference resultat.
79 // par = parametre sur l'arete croisee
80 Standard_Real par = ::Parameter(I);
81 gp_Dir T,N; Standard_Real C;
82 TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
86 //=======================================================================
89 //=======================================================================
91 void TopOpeBRepDS_EdgeInterferenceTool::Add
92 (const TopoDS_Shape& E,
93 const TopoDS_Shape& V,
94 const Handle(TopOpeBRepDS_Interference)& I)
96 TopAbs_Orientation Eori = E.Orientation();
97 if (Eori == TopAbs_INTERNAL ||
98 Eori == TopAbs_EXTERNAL) {
102 // premiere interference sur arete orientee : Init
103 if (myEdgeOrientation == TopAbs_INTERNAL ||
104 myEdgeOrientation == TopAbs_EXTERNAL) {
109 // V est un sommet de E ?
111 Standard_Boolean VofE = Standard_False;
113 TopoDS_Iterator it(E,Standard_False);
114 for ( ; it.More(); it.Next() ) {
115 const TopoDS_Shape& S = it.Value();
118 VofE = Standard_True;
125 if (TopOpeBRepDS_GettracePEI() && !VofE) {
126 cout<<"===================== VofE = False"<<endl;
130 // V est un sommet de E
131 const TopoDS_Vertex& VV = TopoDS::Vertex(V);
132 const TopoDS_Edge& EE = TopoDS::Edge(E);
133 Standard_Real par = BRep_Tool::Parameter(VV,EE);
135 gp_Dir T,N; Standard_Real C;
136 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
137 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
138 TopAbs_Orientation oritan = it.Value().Orientation();
139 myTool.Compare(tol,T,N,C,oriloc,oritan);
142 //=======================================================================
145 //=======================================================================
147 void TopOpeBRepDS_EdgeInterferenceTool::Add
148 (const TopoDS_Shape& E,
149 // const TopOpeBRepDS_Point& P,
150 const TopOpeBRepDS_Point& ,
151 const Handle(TopOpeBRepDS_Interference)& I)
153 TopAbs_Orientation Eori = E.Orientation();
154 if (Eori == TopAbs_INTERNAL ||
155 Eori == TopAbs_EXTERNAL) {
159 // premiere interference sur arete orientee : Init
160 if (myEdgeOrientation == TopAbs_INTERNAL ||
161 myEdgeOrientation == TopAbs_EXTERNAL) {
166 Standard_Real par = ::Parameter(I);
168 gp_Dir T,N; Standard_Real C;
169 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
170 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
171 TopAbs_Orientation oritan = TopAbs_INTERNAL;
172 myTool.Compare(tol,T,N,C,oriloc,oritan);
175 //=======================================================================
176 //function : Transition
178 //=======================================================================
180 void TopOpeBRepDS_EdgeInterferenceTool::Transition
181 (const Handle(TopOpeBRepDS_Interference)& I) const
183 TopOpeBRepDS_Transition& T = I->ChangeTransition();
185 if (myEdgeOrientation == TopAbs_INTERNAL) {
186 T.Set(TopAbs_IN,TopAbs_IN);
188 else if (myEdgeOrientation == TopAbs_EXTERNAL) {
189 T.Set(TopAbs_OUT,TopAbs_OUT);
192 I->Support(myEdgeOriented);
193 T.Set(myTool.StateBefore(),myTool.StateAfter());