1 // Created on: 1992-06-10
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <IntImpParGen_Tool.hxx>
26 #define TOLERANCE_ANGULAIRE 0.00000001
28 //----------------------------------------------------------------------
29 Standard_Real NormalizeOnDomain(Standard_Real& Param,const IntRes2d_Domain& TheDomain) {
30 Standard_Real modParam = Param;
31 if(TheDomain.IsClosed()) {
32 Standard_Real Periode,t;
33 TheDomain.EquivalentParameters(t,Periode);
35 if(TheDomain.HasFirstPoint()) {
36 while(modParam<TheDomain.FirstParameter()) {
40 if(TheDomain.HasLastPoint()) {
41 if(modParam>TheDomain.LastParameter()) {
48 //----------------------------------------------------------------------
49 void Determine_Position(IntRes2d_Position& Pos1,
50 const IntRes2d_Domain& TheDomain,
52 const Standard_Real Param1) {
56 if(TheDomain.HasFirstPoint()) {
57 if(Pnt1.Distance(TheDomain.FirstPoint())
58 <= TheDomain.FirstTolerance()) {
63 if(TheDomain.HasLastPoint()) {
64 if(Pnt1.Distance(TheDomain.LastPoint())
65 <= TheDomain.LastTolerance()) {
66 if(Pos1==IntRes2d_Head) {
67 if(Abs(Param1-TheDomain.LastParameter())
68 < Abs(Param1-TheDomain.FirstParameter()))
77 //----------------------------------------------------------------------
78 void Determine_Transition(const IntRes2d_Position Pos1,
80 const gp_Vec2d& Norm1,
81 IntRes2d_Transition& T1,
82 const IntRes2d_Position Pos2,
84 const gp_Vec2d& Norm2,
85 IntRes2d_Transition& T2,
86 // const Standard_Real Tolerance_Angulaire) {
87 const Standard_Real ) {
89 Standard_Boolean courbure1=Standard_True;
90 Standard_Boolean courbure2=Standard_True;
91 Standard_Boolean decide=Standard_True;
92 if (Tan1.Magnitude()<=gp::Resolution()) {
94 courbure1=Standard_False;
95 if (Tan1.Magnitude()<=gp::Resolution()) { // transition undecided
96 decide=Standard_False;
100 if (Tan2.Magnitude()<=gp::Resolution()) {
102 courbure2=Standard_False;
103 if (Tan2.Magnitude()<=gp::Resolution()) { // transition undecided
104 decide=Standard_False;
113 Standard_Real sgn=Tan1.Crossed(Tan2);
114 Standard_Real norm=Tan1.Magnitude()*Tan2.Magnitude();
116 if (Abs(sgn)<=TOLERANCE_ANGULAIRE*norm) { // Transition TOUCH #########
117 Standard_Boolean opos=(Tan1.Dot(Tan2))<0;
118 if (!(courbure1||courbure2)) {
119 T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
120 T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
125 Norm.SetCoord(-Tan1.Y(),Tan1.X());
126 Standard_Real Val1,Val2;
131 Val1=Norm.Dot(Norm1);
137 Val2=Norm.Dot(Norm2);
140 if (Abs(Val1-Val2) <= gp::Resolution()) {
141 T1.SetValue(Standard_True,Pos1,IntRes2d_Unknown,opos);
142 T2.SetValue(Standard_True,Pos2,IntRes2d_Unknown,opos);
144 else if (Val2 > Val1) {
145 T2.SetValue(Standard_True,Pos2,IntRes2d_Inside,opos);
147 T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos);
150 T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos);
153 else { // Val1 > Val2
154 T2.SetValue(Standard_True,Pos2,IntRes2d_Outside,opos);
156 T1.SetValue(Standard_True,Pos1,IntRes2d_Outside,opos);
159 T1.SetValue(Standard_True,Pos1,IntRes2d_Inside,opos);
165 T1.SetValue(Standard_False,Pos1,IntRes2d_In);
166 T2.SetValue(Standard_False,Pos2,IntRes2d_Out);
169 T1.SetValue(Standard_False,Pos1,IntRes2d_Out);
170 T2.SetValue(Standard_False,Pos2,IntRes2d_In);