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 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRep_Tool.hxx>
19 #include <BRepLProp_CLProps.hxx>
20 #include <Precision.hxx>
21 #include <Standard_ProgramError.hxx>
23 #include <TopoDS_Iterator.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopOpeBRepDS_CurvePointInterference.hxx>
26 #include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
27 #include <TopOpeBRepDS_EdgeVertexInterference.hxx>
28 #include <TopOpeBRepDS_Interference.hxx>
29 #include <TopOpeBRepDS_Point.hxx>
30 #include <TopOpeBRepTool_ShapeTool.hxx>
32 //=======================================================================
33 //function : TopOpeBRepDS_EdgeInterferenceTool
35 //=======================================================================
37 TopOpeBRepDS_EdgeInterferenceTool::TopOpeBRepDS_EdgeInterferenceTool()
41 static Standard_Real Parameter(const Handle(TopOpeBRepDS_Interference)& I)
44 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
45 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
46 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
47 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
49 throw Standard_ProgramError("TopOpeBRepDS_EdgeInterferenceTool1");
55 //=======================================================================
58 //=======================================================================
60 void TopOpeBRepDS_EdgeInterferenceTool::Init
61 (const TopoDS_Shape& E, const Handle(TopOpeBRepDS_Interference)& I)
63 myEdgeOrientation = E.Orientation();
64 myEdgeOriented = I->Support();
66 // NYI 971219 : on ne tient pas compte de l'orientation de E = arete-mere de l'interference I
67 if (myEdgeOrientation == TopAbs_INTERNAL ||
68 myEdgeOrientation == TopAbs_EXTERNAL) {
72 // la premiere arete orientee est gardee dans myEdgeOriented pour MAJ de
73 // l'arete croisee dans l'interference resultat.
75 // par = parametre sur l'arete croisee
76 Standard_Real par = ::Parameter(I);
77 gp_Dir T,N; Standard_Real C;
78 TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
82 //=======================================================================
85 //=======================================================================
87 void TopOpeBRepDS_EdgeInterferenceTool::Add
88 (const TopoDS_Shape& E,
89 const TopoDS_Shape& V,
90 const Handle(TopOpeBRepDS_Interference)& I)
92 TopAbs_Orientation Eori = E.Orientation();
93 if (Eori == TopAbs_INTERNAL ||
94 Eori == TopAbs_EXTERNAL) {
98 // premiere interference sur arete orientee : Init
99 if (myEdgeOrientation == TopAbs_INTERNAL ||
100 myEdgeOrientation == TopAbs_EXTERNAL) {
105 // V est un sommet de E ?
106 Standard_Boolean VofE = Standard_False;
107 TopoDS_Iterator it(E,Standard_False);
108 for ( ; it.More(); it.Next() ) {
109 const TopoDS_Shape& S = it.Value();
111 VofE = Standard_True;
120 // V est un sommet de E
121 const TopoDS_Vertex& VV = TopoDS::Vertex(V);
122 const TopoDS_Edge& EE = TopoDS::Edge(E);
123 Standard_Real par = BRep_Tool::Parameter(VV,EE);
125 gp_Dir T,N; Standard_Real C;
126 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
127 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
128 TopAbs_Orientation oritan = it.Value().Orientation();
129 myTool.Compare(tol,T,N,C,oriloc,oritan);
132 //=======================================================================
135 //=======================================================================
137 void TopOpeBRepDS_EdgeInterferenceTool::Add
138 (const TopoDS_Shape& E,
139 // const TopOpeBRepDS_Point& P,
140 const TopOpeBRepDS_Point& ,
141 const Handle(TopOpeBRepDS_Interference)& I)
143 TopAbs_Orientation Eori = E.Orientation();
144 if (Eori == TopAbs_INTERNAL ||
145 Eori == TopAbs_EXTERNAL) {
149 // premiere interference sur arete orientee : Init
150 if (myEdgeOrientation == TopAbs_INTERNAL ||
151 myEdgeOrientation == TopAbs_EXTERNAL) {
156 Standard_Real par = ::Parameter(I);
158 gp_Dir T,N; Standard_Real C;
159 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
160 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
161 TopAbs_Orientation oritan = TopAbs_INTERNAL;
162 myTool.Compare(tol,T,N,C,oriloc,oritan);
165 //=======================================================================
166 //function : Transition
168 //=======================================================================
170 void TopOpeBRepDS_EdgeInterferenceTool::Transition
171 (const Handle(TopOpeBRepDS_Interference)& I) const
173 TopOpeBRepDS_Transition& T = I->ChangeTransition();
175 if (myEdgeOrientation == TopAbs_INTERNAL) {
176 T.Set(TopAbs_IN,TopAbs_IN);
178 else if (myEdgeOrientation == TopAbs_EXTERNAL) {
179 T.Set(TopAbs_OUT,TopAbs_OUT);
182 I->Support(myEdgeOriented);
183 T.Set(myTool.StateBefore(),myTool.StateAfter());