Skip to content

Commit b3262d5

Browse files
chaterpaulADO Syncaruniverse
authored
Sync changes from github-sync (#7)
* Sync changes from github-sync * Update ThirdPartyNotices.md * Update ThirdPartyNotices.md --------- Co-authored-by: ADO Sync <ado-sync@bentley.com> Co-authored-by: Arun George <11051042+aruniverse@users.noreply.github.com>
1 parent 9be8728 commit b3262d5

74 files changed

Lines changed: 30078 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ You may be asked to clarify things or try different approaches, so please follow
6565
We'd love to accept your contributions to MicroStation Python.
6666
There are just a few guidelines you need to follow.
6767

68-
### Contributor License Agreement (CLA)
69-
70-
A [Contribution License Agreement with Bentley](https://gist.github.com/imodeljs-admin/9a071844d3a8d420092b5cf360e978ca) must be signed before your contributions will be accepted. Upon opening a pull request, you will be prompted to use [cla-assistant](https://cla-assistant.io/) for a one-time acceptance applicable for all Bentley projects.
71-
You can read more about [Contributor License Agreements](https://en.wikipedia.org/wiki/Contributor_License_Agreement) on Wikipedia.
72-
7368
### Pull Requests
7469

7570
All submissions go through a review process.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright © 2017-2024 Bentley Systems, Incorporated. All rights reserved.
3+
Copyright © Bentley Systems, Incorporated. All rights reserved.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#---------------------------------------------------------------------------------------------
2+
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3+
# See LICENSE.md in the repository root for full copyright notice.
4+
#---------------------------------------------------------------------------------------------
5+
import os
6+
import pytest
7+
8+
from MSPyBentley import *
9+
from MSPyBentleyGeom import *
10+
11+
def test_DetailConstructors():
12+
data = []
13+
for i in range(0,3):
14+
curveRef = CurveLocationDetail()
15+
data.append(PathLocationDetail(curveRef, i, i + 0.0))
16+
data.append(PathLocationDetail(curveRef, i, i + 0.2))
17+
data.append(PathLocationDetail(curveRef, i, i + 0.5))
18+
for i in range(0, len(data)):
19+
for j in range(i + 1, len(data)):
20+
assert PathLocationDetail.IsLessThan_ByPathDistance (data[i], data[j])
21+
22+
def Interpolate(dataA, fraction, dataB):
23+
return dataA + fraction * (dataB - dataA)
24+
25+
def ExerciseSearcher(searcher, numTest = 5, isInViewPlane = True):
26+
location0 = searcher.AtStart()
27+
location1 = searcher.AtEnd()
28+
if numTest < 2:
29+
numTest = 2
30+
s_circleFraction = 0.25
31+
pathDistance = location1.DistanceFromPathStart()
32+
circleRadius = s_circleFraction * pathDistance / numTest
33+
for i in range (0, numTest+1):
34+
f = i / numTest
35+
f = f + 0.0
36+
targetDistance = Interpolate(location0.DistanceFromPathStart(), f, location1.DistanceFromPathStart())
37+
locationA = PathLocationDetail()
38+
print(locationA)
39+
assert searcher.SearchByDistanceFromPathStart(targetDistance, locationA)
40+
locationB = searcher.SearchClosestPointBounded(locationA.Point(), True)
41+
#Check::Near (targetDistance, locationB.DistanceFromPathStart ());
42+
if locationA.DistanceToPoint(location0) > circleRadius:
43+
circleIntersection = PathLocationDetail()
44+
if searcher.SearchFirstIntersectionWithCircleXY(locationA, circleRadius, circleIntersection):
45+
assert PathLocationDetail.IsLessThan_ByPathDistance(circleIntersection, locationA)
46+
#Check::Near (circleRadius, searcher.DistanceBetweenPointsXY (circleIntersection.Point (), locationA.Point ()))
47+
if locationA.DistanceToPoint(location1) > circleRadius:
48+
circleIntersection = PathLocationDetail()
49+
if searcher.SearchFirstIntersectionWithCircleXY(locationA, circleRadius, circleIntersection):
50+
assert PathLocationDetail.IsLessThan_ByPathDistance (locationA, circleIntersection)
51+
#Check::Near (circleRadius, searcher.DistanceBetweenPointsXY (circleIntersection.Point (), locationA.Point ()))
52+
53+
54+
def PathTestLines(upVector):
55+
worldToView = RotMatrix()
56+
viewToWorld = RotMatrix()
57+
xVec = yVec = zVec = DVec3d()
58+
upVector.GetNormalizedTriad(xVec, yVec, zVec)
59+
viewToWorld = RotMatrix.FromColumnVectors(xVec, yVec, zVec)
60+
worldToView.TransposeOf(viewToWorld)
61+
62+
xyzA = DPoint3d.From(10, 0, 0)
63+
line = ICurvePrimitive.CreateLine(DSegment3d(DPoint3d.From(0,0,0), xyzA))
64+
path = CurveVector(CurveVector.eBOUNDARY_TYPE_Open)
65+
path.Add(line)
66+
searcher = CurveVectorWithDistanceIndex(worldToView)
67+
searcher.SetPath(path)
68+
ExerciseSearcher(searcher, 4)
69+
lsAxyz = DPoint3dArray()
70+
lsAxyz.append(xyzA)
71+
lsAxyz.append(DPoint3d.FromSumOf(xyzA, DVec3d.From(3,5,0)))
72+
lsAxyz.append(DPoint3d.FromSumOf(xyzA, DVec3d.From(7,2,0)))
73+
lsA = ICurvePrimitive.CreateLineString(lsAxyz)
74+
path.Add(lsA)
75+
searcher.SetPath(path)
76+
ExerciseSearcher(searcher, 4)
77+
78+
def test_OneLine():
79+
PathTestLines(DVec3d(DVec3d.From(0, 0, 1)))
80+
PathTestLines(DVec3d(DVec3d.From(0, 1, 3)))
81+
PathTestLines(DVec3d(DVec3d.From(1, 0, 3)))
82+
83+
@pytest.mark.skip(reason="NEEDS WORK: Fix me")
84+
def test_ExtendedPath():
85+
xyzA = DPoint3d.From(10, 0, 0)
86+
line = ICurvePrimitive.CreateLine(DSegment3d(DPoint3d.From(0,0,0,), xyzA))
87+
path = CurveVector(CurveVector.eBOUNDARY_TYPE_Open)
88+
path.Add(line)
89+
worldToView = RotMatrix()
90+
viewToWorld = RotMatrix()
91+
upVector = DVec3d(DVec3d.From(1,1,4))
92+
xVec = yVec = zVec = DVec3d()
93+
upVector.GetNormalizedTriad(xVec, yVec, zVec)
94+
viewToWorld = RotMatrix.FromColumnVectors (xVec, yVec, zVec)
95+
worldToView.TransposeOf (viewToWorld)
96+
97+
searcher = CurveVectorWithDistanceIndex(worldToView)
98+
99+
boundedStart = PathLocationDetail()
100+
boundedEnd = PathLocationDetail()
101+
searcher.SetExtendedPath(arr,
102+
2.0,
103+
boundedStart, boundedEnd,
104+
True,
105+
5.0
106+
)
107+
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#---------------------------------------------------------------------------------------------
2+
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3+
# See LICENSE.md in the repository root for full copyright notice.
4+
#---------------------------------------------------------------------------------------------
5+
import os
6+
import pytest
7+
8+
from MSPyBentley import *
9+
from MSPyBentleyGeom import *
10+
11+
def EvaluateClothoidTerms(s, L, R, terms, minTerm, maxTerm, relTolR):
12+
if maxTerm > 32:
13+
maxTerm = 32
14+
tol = relTolR * R
15+
terms.clear()
16+
terms.append(s)
17+
W = s
18+
B = s * s / ( 2.0 * L * R)
19+
Q = 0.0
20+
numAccept = 0
21+
for k in range(1, maxTerm):
22+
W = B * W / ( k + 0.0 )
23+
Q = W / (2.0 * k + 1.0)
24+
terms.append(Q)
25+
if Q < tol:
26+
numAccept = numAccept + 1
27+
if numAccept > 1 and k >= minTerm:
28+
return
29+
30+
def SumClothoidTerms(terms, x, y, lastXTerm, lastYTerm):
31+
x = 0.0
32+
y = 0.0
33+
ix = 0
34+
iy = 0
35+
n = 0
36+
n = len(terms)
37+
if n & 0x01:
38+
ix = n - 1
39+
iy = n - 2
40+
else:
41+
iy = n - 1
42+
ix = n - 2
43+
sx = 0.0
44+
sy = 0.0
45+
if ix & 0x02:
46+
sx = -1.0
47+
else:
48+
sx = 1.0
49+
50+
if iy & 0x02:
51+
sy = -1.0
52+
else:
53+
sy = 1.0
54+
55+
lastXTerm = terms[ix]
56+
lastYTerm = terms[iy]
57+
i = ix
58+
while i >= 0:
59+
x += sx * terms[i]
60+
i -=2
61+
sx *= -1.0
62+
63+
i = iy
64+
while i >= 0:
65+
y += sy * terms[i]
66+
i -= 2
67+
sy *= -1.0
68+
69+
def SafeDivide(numerator, denominator, defaultResult, fraction):
70+
if denominator > fraction * numerator:
71+
result = numerator / denominator
72+
return True
73+
result = defaultResult
74+
return False
75+
76+
77+
def test_BareTerms():
78+
L = 100.0
79+
terms = []
80+
x = y = dx = dy = 0.0
81+
for relTol in [1.0e-9, 1.0e-12, 1.0e-13, 1.0e-14, 1.0e-15]:
82+
rxMax = 0.0
83+
ryMax = 0.0
84+
print(" series relTol ", relTol)
85+
print()
86+
print(" (f) (terms) (x lastTerm errorX) (y lastTerm errorY\n")
87+
for rFactor in [4.0, 10.0, 20.0]:
88+
R = rFactor * L
89+
T = Transform()
90+
T.InitIdentity()
91+
spiral = ICurvePrimitive.CreateSpiralBearingRadiusLengthRadius(
92+
DSpiral2dBase.TransitionType_Clothoid,
93+
0.0, 0.0,
94+
L, R,
95+
T,
96+
0.0, 1.0
97+
)
98+
placement = spiral.GetSpiralPlacement ()
99+
print("\n Series Clothoid R = ", R ," L = ", L ," relTol = ", relTol)
100+
for f in [0.0, 0.1, 0.2, 0.7, 0.8, 0.9, 1.0 ]:
101+
EvaluateClothoidTerms (f * L, L, R, terms, 2, 20, relTol)
102+
SumClothoidTerms (terms, x, y, dx, dy)
103+
xyz = DPoint3d()
104+
spiral.FractionToPoint(f,xyz)
105+
delta = DVec2d()
106+
errorBound = 0.0
107+
DSpiral2dBase.Stroke(placement.spiral, 0.0, f, 0.01, delta, errorBound)
108+
ex = 0.0
109+
ey = 0.0
110+
SafeDivide(ex, delta.x - x, x, 0.0)
111+
SafeDivide(ey, delta.y - y, y, 0.0)
112+
print('%.14f' %f , " " , len(terms) , "x " , '%.14f' %x , " " , '%8.1f' %dx , " " , '%8.1f' %ex , "y " , '%.14f' %y , " " , '%8.1f' %dy , " " , '%8.1f' %ey)
113+
assert ex <= relTol
114+
assert ey <= relTol
115+
rxMax = max(ex, rxMax)
116+
ryMax = max(ey, ryMax)
117+
print("relTol ", relTol , " rxMax ", rxMax , " ryMax " , ryMax)
118+
119+

0 commit comments

Comments
 (0)