1 # Checks whether theCurve has a loop/bend
2 # Use: CheckLoops curve CosMaxAngle [theNbPoints]}
3 # theNbPoints sets the interval of discretization;
4 # theCosMaxAngle sets the maximal rotation angle between two adjacent segments. This value must be equal to the cosine of this angle.
6 help CheckLoops {curve CosMaxAngle theNbPoints }
7 proc CheckLoops {theCurve {theCosMaxAngle 0.8} {theNbPoints 1000.0}} {
8 upvar #0 $theCurve aCurve
11 set delta [dval (U2-U1)/$theNbPoints]
12 cvalue aCurve [dval U1] xp yp zp dx1 dy1 dz1
14 for {set p [dval U1]} {$p <= [dval U2]} {set p [expr $p + $delta]} {
15 cvalue aCurve $p xp yp zp dx2 dy2 dz2
17 #Check if the angle between the vectors {dx1 dy1 dz1} and {dx2 dy2 dz2} is less than 30deg.
18 set nv1 [ dval dx1*dx1+dy1*dy1+dz1*dz1 ]
19 set nv2 [ dval dx2*dx2+dy2*dy2+dz2*dz2 ]
20 set dp [ dval dx1*dx2+dy2*dy2+dz1*dz2 ]
22 if {$dp < [ expr $theCosMaxAngle * sqrt($nv1 * $nv2) ] } {
23 puts "Error: The curve $theCurve is possible to have a bend at parameter $p. Please check carefully"
32 # General check of the result of geometrical intersection
33 help CheckIntersectionResult { surf1 surf2 ListOfCurves NbPoints TolerS1 TolerS2 }
34 proc CheckIntersectionResult {theSurf1 theSurf2 theListOfCurves theNbPoints theTolerS1 theTolerS2} {
38 foreach a $theListOfCurves {
39 puts "** Check of $a **"
43 if {[dval U2-U1] < 1.0e-9} {
44 puts "Error: Wrong range of $a"
47 xdistcs aCurve s1 U1 U2 $theNbPoints $theTolerS1
48 xdistcs aCurve s2 U1 U2 $theNbPoints $theTolerS2