DPoint3dOps.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
11 // To be included from GeomApi.h !!!
15 template <typename T>
19 struct VectorOps
20 {
24 public:
25 static GEOMDLLIMPEXP void Copy (bvector<T> *dest, bvector<T> const *source);
26 
27 static GEOMDLLIMPEXP void Copy (bvector<T> *dest, T const *source, size_t count);
28 
30 
31 static GEOMDLLIMPEXP size_t Append (bvector<T> *dest, T const *source, size_t count);
32 
34 
35 static GEOMDLLIMPEXP size_t Append (bvector<T> *dest, bvector<T> const *source);
36 
38 
39 static GEOMDLLIMPEXP size_t Size (bvector<T> *dest);
40 
42 
43 static GEOMDLLIMPEXP size_t Append (bvector<T> *dest, T const &data);
44 
46 
47 static GEOMDLLIMPEXP void AppendDisconnect (bvector<T> *dest);
48 
50 static GEOMDLLIMPEXP bool Set (bvector<T> *dest, T const &data, size_t index);
51 
53 static GEOMDLLIMPEXP bool Get (bvector<T> *dest, T &data, size_t index);
54 
62 static GEOMDLLIMPEXP void AppendInterpolated (bvector<T> &dest, T const &first, T const &last, size_t count, bool includeFirst = true);
63 
69 static GEOMDLLIMPEXP void InterpolateAll (bvector<T> &dest, bvector <T> const &dataA, double f, bvector <T> const &dataB);
70 
74 static GEOMDLLIMPEXP T * MallocAndCopy (bvector<T> &source);
75 
79 static GEOMDLLIMPEXP void Compress (bvector<T> &data, double tolerance);
80 
84 static GEOMDLLIMPEXP void CompressCyclic (bvector<T> &data, double tolerance);
85 
90 static GEOMDLLIMPEXP void Compress (bvector<T> const &source, bvector<T> &dest, double tolerance);
91 
92 
96 public:
97 static GEOMDLLIMPEXP void Reverse (bvector<T>& xyz);
98 
100 public: static double GEOMDLLIMPEXP LargestCoordinate (bvector<T> const &data);
101 
103 public: static double GEOMDLLIMPEXP LargestCoordinate (T const *data, size_t count);
104 
108 public: static double GEOMDLLIMPEXP Tolerance (bvector<T> const &data, double absTol, double relTol);
109 
113 public: static double GEOMDLLIMPEXP Tolerance (T const *data, size_t count, double absTol, double relTol);
114 
116 public: static bool GEOMDLLIMPEXP Equal (bvector<T> const &dataA, bvector<T> const &dataB);
117 
119 public: static bool GEOMDLLIMPEXP Equal (T const *dataA, size_t countA, T const *dataB, size_t countB);
120 
122 public: static bool GEOMDLLIMPEXP FindNotAlmostEqualAtOrAfter (bvector<T>const &data, T const &baseValue, size_t i0, size_t &i1, T &value);
124 public: static bool GEOMDLLIMPEXP FindNotAlmostEqualBefore (bvector<T>const &data, T const &baseValue, size_t i0, size_t &i1, T &value);
125 
127 public: static bool GEOMDLLIMPEXP AlmostEqual (T const &valueA, T const &valueB);
128 
129 
130 
135 public: static bool GEOMDLLIMPEXP AlmostEqual (T const &valueA, T const &valueB, double tolerance);
136 
143 public: static bool GEOMDLLIMPEXP AlmostEqual
144 (
145 T const *valueA,
146 size_t numA,
147 T const *valueB,
148 size_t numB,
149 double tolerance);
150 
151 
153 public: static size_t GEOMDLLIMPEXP MostDistantIndex (bvector<T>const &data, T const &baseValue);
155 public: static size_t GEOMDLLIMPEXP MostDistantIndex (T const *data, size_t n, T const &baseValue);
156 
157 };
158 
161 struct DPoint2dOps : VectorOps <DPoint2d>
162 {
163 private: DPoint2dOps (){};
164 public:
165 
167 
168 static GEOMDLLIMPEXP void AppendXY (bvector<DPoint2d> *dest, double x, double y);
169 
171 static GEOMDLLIMPEXP void AppendXY (bvector<DPoint2d> &dest, bvector<DPoint3d> const &source);
172 
181 public:
182 static GEOMDLLIMPEXP size_t Cluster
183 (
184 bvector<DPoint2d> const &xyzIn,
185 bvector<DPoint2d> *xyzOut,
186 bvector<size_t>&oldIndexToPackedIndex,
187 double absTol = -1.0,
188 double relTol = -1.0
189 );
190 
196 public:
197 static GEOMDLLIMPEXP void Multiply
198 (
199 bvector<DPoint2d> *xyz,
200 TransformCR transform
201 );
202 
203 public:
205 static bool LexicalXExtrema (int &iMin, int &iMax, DPoint2dCP points, int nPoint);
206 public:
208 static bool LexicalYExtrema (int &iMin, int &iMax, DPoint2dCP points, int nPoint);
209 };
210 
213 struct DVec3dOps : VectorOps <DVec3d>
214 {
215 private: DVec3dOps (){};
216 public:
217 
219 
220 static GEOMDLLIMPEXP void AppendXYZ (bvector<DVec3d> *dest, double x, double y, double z = 0.0);
221 
222 
231 public:
232 static GEOMDLLIMPEXP size_t Cluster
233 (
234 bvector<DVec3d> const &xyzIn,
235 bvector<DVec3d> *xyzOut,
236 bvector<size_t>&oldIndexToPackedIndex,
237 double absTol = -1.0,
238 double relTol = -1.0
239 );
240 
242 public: static bool GEOMDLLIMPEXP MinMaxAngle (bvector<DVec3d> const &dataA, bvector<DVec3d> const &dataB,
243  double &minAngle, size_t &minIndex,
244  double &maxAngle, size_t &maxIndex
245  );
246 };
249 struct DVec2dOps : VectorOps <DVec2d>
250 {
251 private: DVec2dOps (){};
252 public:
253 
255 
256 static GEOMDLLIMPEXP void AppendXY (bvector<DVec2d> *dest, double x, double y);
257 };
261 struct DoubleOps : VectorOps <double>
262 {
263 public:
264 
265 private: DoubleOps ();
266 public:
268 static GEOMDLLIMPEXP double Min (double a1, double a2);
270 static GEOMDLLIMPEXP double Min (double a1, double a2, double a3);
272 static GEOMDLLIMPEXP double Min (double a1, double a2, double a3, double a4);
273 
275 static GEOMDLLIMPEXP double MinAbs (double a1, double a2);
277 static GEOMDLLIMPEXP double MinAbs (double a1, double a2, double a3);
279 static GEOMDLLIMPEXP double MinAbs (double a1, double a2, double a3, double a4);
280 
281 
283 static GEOMDLLIMPEXP double Max (double a1, double a2);
285 static GEOMDLLIMPEXP double Max (double a1, double a2, double a3);
287 static GEOMDLLIMPEXP double Max (double a1, double a2, double a3, double a4);
288 
290 static GEOMDLLIMPEXP double MaxAbs (double a1, double a2);
292 static GEOMDLLIMPEXP double MaxAbs (double a1, double a2, double a3);
294 static GEOMDLLIMPEXP double MaxAbs (double a1, double a2, double a3, double a4);
295 
297 static GEOMDLLIMPEXP double MaxAbs (double a1, double a2, double a3, double a4, double a5, double a6);
298 
300 static GEOMDLLIMPEXP void UpdateMax (double &evolvingMax, double testValue);
301 
303 static GEOMDLLIMPEXP bool WithinTolerance (double a1, double a2, double abstol);
304 
306 static GEOMDLLIMPEXP double SnapZero (double a, double abstol);
307 
309 static GEOMDLLIMPEXP int TolerancedSign (double a, double abstol);
310 
312 static GEOMDLLIMPEXP bool WithinTolerance (double a1, double a2, double abstol, double reltol);
317 static GEOMDLLIMPEXP double ComputeTolerance (double maxSize, double abstol, double reltol);
318 
319 static GEOMDLLIMPEXP double Max (bvector <double> &values);
320 static GEOMDLLIMPEXP double Min (bvector <double> &values);
321 static GEOMDLLIMPEXP double MaxAbs (bvector <double> &values);
322 static GEOMDLLIMPEXP double MinAbs (bvector <double> &values);
323 
324 static GEOMDLLIMPEXP double Max (double const *values, size_t n);
325 static GEOMDLLIMPEXP double Min (double const *values, size_t n);
326 static GEOMDLLIMPEXP double MaxAbs (double const *values, size_t n);
327 static GEOMDLLIMPEXP double MinAbs (double const *values, size_t n);
328 
329 static GEOMDLLIMPEXP void ScaleArray (double *values, size_t n, double a);
330 static GEOMDLLIMPEXP void ScaleArray (bvector <double> &values, double a);
332 static GEOMDLLIMPEXP double ClampFraction (double s);
333 
335 static GEOMDLLIMPEXP void ClampDirectedFractionInterval (double &t0, double &t1);
336 
338 static GEOMDLLIMPEXP double Clamp (double x, double a, double b);
340 static GEOMDLLIMPEXP bool IsExact01 (double a0, double a1);
341 
343 static GEOMDLLIMPEXP bool IsIn01 (double x);
345 static GEOMDLLIMPEXP bool IsAlmostIn01 (double x);
346 
348 static GEOMDLLIMPEXP bool IsIn01OrExtension (double x, bool extend0, bool extend1);
349 
351 static GEOMDLLIMPEXP bool IsIn01 (double x, double y);
352 
354 static GEOMDLLIMPEXP bool IsIn01 (DPoint2dCR xy);
355 
357 static GEOMDLLIMPEXP bool IsIn01 (DPoint3dCR xyz);
358 
360 static GEOMDLLIMPEXP double Hypotenuse (double a, double b);
362 static GEOMDLLIMPEXP double Hypotenuse (double a, double b, double c);
364 static GEOMDLLIMPEXP double Hypotenuse (double a, double b, double c, double d);
365 
367 static GEOMDLLIMPEXP double DeterminantXYXY (double x0, double y0, double x1, double y1);
371 static GEOMDLLIMPEXP bool SafeDivideParameter (double &result, double numerator, double denominator, double defaultResult = 0.0);
372 
376 static GEOMDLLIMPEXP bool ChooseSafeDivideParameter
377 (
378 double &result,
379 double numerator0,
380 double denominator0,
381 double numerator1,
382 double denominator1,
383 double defaultResult = 0.0
384 );
385 
386 
392 static GEOMDLLIMPEXP ValidatedDouble ValidatedDivideDistance(double a, double b, double defaultResult = 0.0);
393 
399 static GEOMDLLIMPEXP ValidatedDouble ValidatedDivideDistanceSquared (double a, double b, double defaultResult = 0.0);
400 
403 
405 (
406 double f,
407 double df,
408 double g,
409 double dg
410 );
411 
412 
418 static GEOMDLLIMPEXP ValidatedDouble ValidatedDivideParameter (double a, double b, double defaultResult = 0.0);
419 
426 static GEOMDLLIMPEXP ValidatedDouble ValidatedDivide (double a, double b, double defaultResult = 0.0, double minRelativeDivisor = 1.0e-15);
427 
428 
429 
433 static GEOMDLLIMPEXP bool SafeDivideDistanceSquared (double &result, double numerator, double denominator, double defaultResult = 0.0);
434 
439 static GEOMDLLIMPEXP bool SafeDivide (double &result, double numerator, double denominator, double defaultResult = 0.0, double smallFraction = 1.0e-15);
440 
443 static GEOMDLLIMPEXP bool LinearTransform (double a0, double a1, double b0, double b1, double &c, double &d);
445 static GEOMDLLIMPEXP bool UpperBound (double const *pData, size_t n, double searchValue, size_t &index);
447 static GEOMDLLIMPEXP bool LowerBound (double const *pData, size_t n, double searchValue, size_t &index);
461 static GEOMDLLIMPEXP bool BoundingValues (double const *pData, size_t n, double searchValue, size_t &lowerIndex, double &lowerBound, double &upperBound);
462 static GEOMDLLIMPEXP bool BoundingValues (bvector<double>const &data, double searchValue, size_t &lowerIndex, double &lowerBound, double &upperBound);
463 static GEOMDLLIMPEXP bool BoundingValues (size_t n, double searchValue, size_t &lowerIndex, double &lowerBound, double &upperBound);
465 static GEOMDLLIMPEXP void Sort (double *data, size_t count, bool ascending = true);
466 static GEOMDLLIMPEXP void Sort (bvector<double> &data, bool ascending = true);
468 static GEOMDLLIMPEXP void SortTail (bvector<double> &data, size_t i0, bool ascending = true);
469 
471 static GEOMDLLIMPEXP double Interpolate (double dataA, double fraction, double dataB);
474 static GEOMDLLIMPEXP ValidatedDouble InverseInterpolate (double dataA, double value, double dataB);
475 static GEOMDLLIMPEXP void Swap (double &dataA, double &dataB);
476 
478 static GEOMDLLIMPEXP void UpdateMinMax (double x, double f, double &xMin, double &fMin, double &xMax, double &fMax);
479 
481 static GEOMDLLIMPEXP double Magnitude (double a, double b, double c);
483 static GEOMDLLIMPEXP double Magnitude (double a, double b);
485 static GEOMDLLIMPEXP bool AlmostEqualFraction (double a, double b);
486 
488 static GEOMDLLIMPEXP int TolerancedComparison (double a, double b);
489 
491 static GEOMDLLIMPEXP bool ClearlyIncreasingFraction (double a, double b);
492 
494 static GEOMDLLIMPEXP bool ClearlyIncreasing (double a, double b, double tol);
495 
496 static GEOMDLLIMPEXP double Sum (double *data, int n);
497 static GEOMDLLIMPEXP double Sum (bvector<double> const &data);
498 static GEOMDLLIMPEXP double SumAbs (double *data, int n);
499 static GEOMDLLIMPEXP double SumAbs (bvector<double> const &data);
500 
503 static GEOMDLLIMPEXP double PreciseSum (double *data, size_t n);
504 static GEOMDLLIMPEXP double PreciseSum (double a, double b, double c);
505 
508 static GEOMDLLIMPEXP bool Normalize (bvector<double> &data, double a0, double a1);
509 
512 static GEOMDLLIMPEXP void CopyToIndex (bvector<double> const &source, bvector<size_t> const &index, bvector<double> &dest);
515 static GEOMDLLIMPEXP void CopyFromIndex (bvector<double> const &source, bvector<size_t> const &index, bvector<double> &dest);
516 static GEOMDLLIMPEXP void SetZeros (bvector<double> &dest);
517 static GEOMDLLIMPEXP void SetSequential (bvector<double> &dest, double a0 = 0.0, double delta = 1.0);
518 static GEOMDLLIMPEXP double MaxAbsDiff (bvector<double> const &x, bvector<double> const &y);
519 static GEOMDLLIMPEXP void ApplyFunction (bvector<double> const &x, double (*f)(double), bvector <double> &fOfx);
520 
526 static GEOMDLLIMPEXP void MovingAverages
527 (
528 bvector<double> &dest,
529 bvector<double> const &source,
530 size_t blockSize,
531 size_t numSkip0 = 0,
532 size_t numSkip1 = 0
533 );
534 
540 static GEOMDLLIMPEXP void MovingAverages
541 (
542 bvector<double> &dest,
543 double value0,
544 double value1,
545 size_t numOut,
546 size_t blockSize,
547 size_t numCopy0 = 1,
548 size_t numCopy1 = 1
549 );
550 
552 static GEOMDLLIMPEXP void ChebyshevPoints
553 (
554  bvector<double> &dest,
555  size_t numChebyshev,
556  bool addLimitPoints,
557  size_t numCopyLeft = 1,
558  size_t numCopyRight = 1
559  );
561 static GEOMDLLIMPEXP void LinearMapInPlace (bvector<double> &data, double a, double b);
563 static GEOMDLLIMPEXP void MinusOnePlus1LinearMapInPlace (bvector<double> &data, double aMinus, double aPlus);
565 static GEOMDLLIMPEXP void LinearMapFrontBackToInterval(bvector<double> &data, double a0, double a1);
566 
568 static GEOMDLLIMPEXP double ChebyshevPoint (size_t i, size_t n);
570 public: static GEOMDLLIMPEXP double SmallCoordinateRelTol ();
571 };
572 
573 
578 struct DPoint3dOps : VectorOps <DPoint3d>
579 {
580 private:
581  DPoint3dOps (); // No instances.
582 public:
583 
585 
586 static GEOMDLLIMPEXP void AppendXYZ (bvector<DPoint3d> *dest, double x, double y, double z = 0.0);
587 
589 static GEOMDLLIMPEXP void AppendXY0 (bvector<DPoint3d> &dest, bvector<DPoint2d> const &source);
590 
599 public:
600 static GEOMDLLIMPEXP size_t Cluster
601 (
602 bvector<DPoint3d> const &xyzIn,
603 bvector<DPoint3d> *xyzOut,
604 bvector<size_t>&oldIndexToPackedIndex,
605 double absTol = -1.0,
606 double relTol = -1.0
607 );
608 
609 
610 
616 public:
617 static GEOMDLLIMPEXP void Multiply
618 (
619 bvector<DPoint3d> *xyz,
620 TransformCR transform
621 );
622 
623 
625 public: static bool GEOMDLLIMPEXP MinMaxDistance (bvector<DPoint3d> const &xyzA, bvector<DPoint3d> const &xyzB,
626  double &minDistance, size_t &minIndex,
627  double &maxDistance, size_t &maxIndex
628  );
629 
630 
635 public: static bool GEOMDLLIMPEXP ClosestPoint (bvector<DPoint3d> const &xyz, DPoint3dCR spacePoint, size_t &closestIndex, double &minDist);
636 
641 public: static bool GEOMDLLIMPEXP MaxDistanceFromUnboundedRay (bvector<DPoint3d> const &xyz, DRay3dCR ray, size_t &index, double &maxDistance);
642 
643 
644 
650 public: static bool GEOMDLLIMPEXP ClosestPointXY (bvector<DPoint3d> const &xyz, DMatrix4dCP worldToLocal, DPoint3dCR spacePoint, size_t &closestIndex, double &minDist);
651 
652 
653 public:
658 static GEOMDLLIMPEXP DRange3d Range (bvector<DPoint3d> const *pXYZIn);
659 
660 public:
666 static GEOMDLLIMPEXP DRange3d Range (bvector<DPoint3d> const *pXYZIn, TransformCR worldToLocal);
667 
669 public: static GEOMDLLIMPEXP DRange1d ProjectedParameterRange (bvector <DPoint3d> const &points, DRay3dCR ray);
670 
671 
673 static GEOMDLLIMPEXP double LargestXYCoordinate (DPoint3dCP points, size_t n);
674 
676 static GEOMDLLIMPEXP size_t CountDisconnects (bvector<DPoint3d> &points);
677 
678 
687 static GEOMDLLIMPEXP bool PrincipalAxes (bvector<DPoint3d> const &points, DVec3dR centroid, RotMatrixR axes, DVec3dR moments);
688 
696 static GEOMDLLIMPEXP bool PrincipalAxes (bvector<DPoint3d> const &points, TransformR localToWorld, TransformR worldToLocal, DVec3dR moments);
697 
706 static GEOMDLLIMPEXP bool PrincipalAxes (
707  bvector<DPoint3d> const &pointsA,
708  bvector<DPoint3d> const &pointsB,
709  TransformR localToWorld, TransformR worldToLocal, DVec3dR moments);
710 
718 static GEOMDLLIMPEXP bool PrincipalAxes (bvector<DPoint4d> const &points, DVec3dR centroid, RotMatrixR axes, DVec3dR moments);
719 
720 
729 static GEOMDLLIMPEXP bool PrincipalAxes (bvector<DPoint3d> const &pointsA, bvector<DPoint3d> const &pointsB, DVec3dR centroid, RotMatrixR axes, DVec3dR moments);
730 
742 static GEOMDLLIMPEXP bool PrincipalExtents (bvector<DPoint3d> const &points, TransformR originWithExtentVectors);
743 
744 
758 static GEOMDLLIMPEXP bool PrincipalExtents (bvector<DPoint3d> const &points, TransformR originWithExtentVectors, TransformR localToWorld, TransformR worldToLocal);
759 
760 
761 
762 
767 static GEOMDLLIMPEXP DMatrix4d MomentSums (DPoint3dCR origin, bvector<DPoint3d> const &points);
768 
769 };
773 {
774 private:
775  PolylineOps (); // No instances.
776 
779 public: static GEOMDLLIMPEXP void SetPolylinePolylineHeapTrigger (size_t mn);
780 
782 public: static GEOMDLLIMPEXP double SegmentFractionToPolylineFraction (size_t segmentIndex, size_t numSegment, double segmentFraction);
783 
793 public: static GEOMDLLIMPEXP bool PolylineFractionToSegmentData
794 (
795 size_t numVertex,
796 double fraction,
797 size_t &segmentIndex,
798 size_t &numSegment,
799 double &segmentFraction,
800 bool &isExtrapolated
801 );
802 
804 public: static GEOMDLLIMPEXP bool PolylineFractionsOnSameSegment
805 (
806 double f0,
807 double f1,
808 size_t numVertex
809 );
810 
812 public: static GEOMDLLIMPEXP double Length (bvector<DPoint3d> const &xyz, bool addClosure = false);
814 public: static GEOMDLLIMPEXP double Length (bvector< bvector<DPoint3d> > const &xyz, bool addClosure = false);
816 public: static GEOMDLLIMPEXP double Length (RotMatrixCP worldToLocal, bvector<DPoint3d> const &xyz, bool addClosure = false);
817 
819 public: static GEOMDLLIMPEXP UsageSums SumSegmentLengths (bvector<DPoint3d> const &xyz);
820 
822 public: static GEOMDLLIMPEXP double Length (DPoint3dCP xyz, double const *weight, ptrdiff_t step, size_t n, bool addClosure = false);
823 
824 
825 
826 // return the total of (absolute) angles at vertices of polyline with step index. Optionally add closure edge. Weights optional.
833 public: static GEOMDLLIMPEXP double SumAbsoluteAngles (DPoint3dCP xyz, double const *weight, ptrdiff_t step, size_t count, bool addClosure, double minEdgeLength = 0.0);
834 
836 public: static GEOMDLLIMPEXP bool ClosestPoint
837  (
838  bvector<DPoint3d> const &xyz,
839  bool addClosurePoint,
840  DPoint3dCR spacePoint,
841  double &fraction,
842  DPoint3dR curvePoint
843  );
844 
846 public: static GEOMDLLIMPEXP bool ClosestPoint
847  (
848  bvector<DPoint3d> const &xyz,
849  bool addClosurePoint,
850  DPoint3dCR spacePoint,
851  double &fraction,
852  DPoint3dR curvePoint,
853  size_t &edgeIndex,
854  size_t &numEdge,
855  double &edgeFraction,
856  bool extend0,
857  bool extend1
858  );
859 
861 public: static GEOMDLLIMPEXP bool ClosestPointXY
862  (
863  bvector<DPoint3d> const &xyz,
864  bool addClosurePoint,
865  DPoint3dCR spacePoint,
866  DMatrix4dCP worldToLocal,
867  double &globalFraction,
868  DPoint3dR curvePoint,
869  size_t &edgeIndex,
870  size_t &numEdge,
871  double &edgeFraction,
872  double &xyDistance
873  );
874 
876 public: static GEOMDLLIMPEXP bool ClosestPointXY
877  (
878  bvector<DPoint3d> const &xyz,
879  bool addClosurePoint,
880  DPoint3dCR spacePoint,
881  DMatrix4dCP worldToLocal,
882  double &globalFraction,
883  DPoint3dR curvePoint,
884  size_t &edgeIndex,
885  size_t &numEdge,
886  double &edgeFraction,
887  double &xyDistance,
888  bool extend0,
889  bool extend1
890  );
891 
892 
896 public: static bool GEOMDLLIMPEXP AddCloseApproaches
897 (
898 bvector<DPoint3d> const &xyzA,
899 bvector<DPoint3d> const &xyzB,
902 double maxDistance = DBL_MAX
903 );
904 
905 public: static bool GEOMDLLIMPEXP AddCloseApproaches
906 (
907 bvector<DPoint3d> const &xyzA,
908 bvector<double> const *paramA,
909 bvector<DPoint3d> const &xyzB,
910 bvector<double> const *paramB,
913 double maxDist
914 );
915 
925 public: static bool GEOMDLLIMPEXP CollectIntersectionsAndCloseApproachesXY
926 (
927 bvector<DPoint3d> const &xyzA,
928 bvector<double> const *paramA,
929 bvector<DPoint3d> const &xyzB,
930 bvector<double> const *paramB,
933 double maxDist
934 );
935 
938 public: static bool GEOMDLLIMPEXP ClosestApproach
939 (
940 bvector<DPoint3d> const &xyzA,
941 bvector<DPoint3d> const &xyzB,
942 CurveLocationDetailR locationA,
943 CurveLocationDetailR locationB
944 );
945 
948 public: static GEOMDLLIMPEXP void CollectZPairsForOrderedXPoints (
949 bvector<DPoint3d>const &pointA,
950 bvector<DPoint3d> const &pointB,
952 );
953 
954 
955 
957 public: static GEOMDLLIMPEXP bool IsSelfIntersectingXY (bvector<DPoint3d> const &xyz, bool addClosure = false);
959 public: static GEOMDLLIMPEXP bool IsSelfIntersectingXY (DPoint3d *points, size_t n, bool addClosure = false);
961 public: static GEOMDLLIMPEXP bool IsRectangle (DPoint3dCP points, size_t n,
962  TransformR localToWorld,
963  TransformR worldToLocal,
964  bool requireClosurePoint = true
965  );
966 
968 public: static GEOMDLLIMPEXP bool Are4EdgesPerpendicular (DPoint3dCP points);
969 
971 public: static GEOMDLLIMPEXP bool IsRectangle (bvector<DPoint3d> const &points,
972  TransformR localToWorld,
973  TransformR worldToLocal,
974  bool requireClosurePoint = true);
975 
978 public: static GEOMDLLIMPEXP double SegmentLength (bvector<DPoint3d> const &points, size_t index);
981 public: static GEOMDLLIMPEXP double SegmentLength (RotMatrixCP worldToLocal, bvector<DPoint3d> const &points, size_t index);
982 
985 public: static GEOMDLLIMPEXP DPoint3d SegmentFractionToPoint (bvector<DPoint3d> const &points, size_t index, double segmentFraction);
986 public: static GEOMDLLIMPEXP ValidatedDRay3d PolylineFractionToRay (bvector<DPoint3d> const &points, double polylineFraction);
987 
989 public: static GEOMDLLIMPEXP bool FractionAtSignedDistanceFromFraction
990 (
991 bvector<DPoint3d> const &xyz,
992 double startFraction,
993 double signedDistance,
994 double &endFraction,
995 size_t &endSegmentIndex,
996 double &segmentFraction,
997 double &actualDistance
998 );
999 
1001 public: static GEOMDLLIMPEXP bool FractionAtSignedDistanceFromFraction
1002 (
1003 RotMatrixCP worldToLocal,
1004 bvector<DPoint3d> const &xyz,
1005 double startFraction,
1006 double signedDistance,
1007 double &endFraction,
1008 size_t &endSegmentIndex,
1009 double &segmentFraction,
1010 double &actualDistance
1011 );
1012 
1015 public: static GEOMDLLIMPEXP double SignedDistanceBetweenFractions
1016 (
1017 bvector <DPoint3d> const & points,
1018 double fraction0,
1019 double fraction1
1020 );
1021 
1024 public: static GEOMDLLIMPEXP double SignedDistanceBetweenFractions
1025 (
1026 RotMatrixCP worldTolocal,
1027 bvector <DPoint3d> const & points,
1028 double fraction0,
1029 double fraction1
1030 );
1031 
1032 public: static GEOMDLLIMPEXP bool FractionToFrenetFrame
1033 (
1034 bvector <DPoint3d> const & points,
1035 double f,
1036 TransformR frame
1037 );
1038 
1040 public: static GEOMDLLIMPEXP void CopyBetweenFractions
1041 (
1042 bvector <DPoint3d> const &points,
1043 bvector<DPoint3d> &dest,
1044 double fractionA,
1045 double fractionB
1046 );
1047 
1048 public: static void CopyBetweenFractions
1049 (
1050 bvector <DPoint3d> const &points,
1052 double fractionA,
1053 double fractionB
1054 );
1063 public: static GEOMDLLIMPEXP bool WireCentroid
1064 (
1065 bvector <DPoint3d> const &points,
1066 double &length,
1067 DPoint3dR centroid,
1068 double fraction0 = 0.0,
1069 double fraction1 = 1.0
1070 );
1071 
1073 public: static GEOMDLLIMPEXP DRange1d ProjectedParameterRange (bvector <DPoint3d> const &points, DRay3dCR ray, double fraction0, double fraction1);
1074 
1079 public: static GEOMDLLIMPEXP void AddContinuationStartPoint (bvector<DPoint3d>&points, DPoint3dCR xyz, bool forceIncludeThisPoint);
1080 
1081 public: static GEOMDLLIMPEXP bool AddStrokes
1082 (
1083 bvector <DPoint3d> const &points,
1084 bvector <DPoint3d> & strokes,
1085 IFacetOptionsCR options,
1086 bool includeStartPoint = true,
1087 double startFraction = 0.0,
1088 double endFraction = 1.0
1089 );
1094 public: static GEOMDLLIMPEXP bool AddStrokes
1095 (
1096 bvector <DPoint3d> const &points,
1097 DPoint3dDoubleUVCurveArrays &strokes,
1098 IFacetOptionsCR options,
1099 double startFraction = 0.0,
1100 double endFraction = 1.0,
1101 ICurvePrimitiveCP curve = nullptr
1102 );
1103 
1104 
1105 public: static GEOMDLLIMPEXP size_t GetStrokeCount
1106 (
1107 bvector <DPoint3d> const &points,
1108 IFacetOptionsCR options,
1109 double startFraction = 0.0,
1110 double endFraction = 1.0
1111 );
1112 
1120 public: static GEOMDLLIMPEXP void CompressColinearPoints (bvector<DPoint3d> &points, double absTol, bool eliminateOverdraw, bool closed);
1121 
1122 
1124 static GEOMDLLIMPEXP bool OffsetLineStringXY
1125 (
1126 bvector<DPoint3d> &out,
1127 bvector<DPoint3d> const &in,
1128 double offsetDistance,
1129 bool periodic = false,
1130 double maxMiterRadians = 1.58
1131 );
1133 
1135 static GEOMDLLIMPEXP bool OffsetLineString
1136 (
1137 bvector<DPoint3d> &out,
1138 bvector<DPoint3d> const &in,
1139 double offsetDistance,
1140 DVec3dCR planeNormal,
1141 bool periodic = false,
1142 double maxMiterRadians = 1.58
1143 );
1146 
1150 static GEOMDLLIMPEXP void GreedyTriangulationBetweenLinestrings
1151 (
1152 bvector<DPoint3d> const & linestringA,
1153 bvector<DPoint3d> const &linestringB,
1154 bvector<DTriangle3d> &triangles,
1155 bvector<int> *oneBasedABIndex = nullptr
1156 );
1157 
1159 static GEOMDLLIMPEXP void AppendToChains (bvector<bvector<DPoint3d>> &chains, DSegment3dCR segment);
1160 
1162 static GEOMDLLIMPEXP void AddPointIfDistinctFromBack (bvector<DPoint3d> &points, DPoint3d xyz);
1164 static GEOMDLLIMPEXP void EnforceClosure(bvector<DPoint3d> &points);
1166 static GEOMDLLIMPEXP void PackAlmostEqualAfter (bvector<DPoint3d> &points, size_t initialCount);
1169 static GEOMDLLIMPEXP void CompressByChordError (bvector<DPoint3d>& result, bvector<DPoint3d> const& source, double chordTolerance);
1170 };
1171 
1172 
1173 
1175 {
1176 Unknown = 0,
1177 Transverse = 1,
1178 Coincident = 2
1179 };
1180 
1184 {
1185 private:
1186  PolygonOps (); // No instances.
1187 
1192 public: static GEOMDLLIMPEXP DVec3d AreaNormal (bvector<DPoint3d> const &xyz);
1193 
1194 
1199 public: static GEOMDLLIMPEXP DVec3d AreaNormal (bvector<DPoint3d> const &xyz, size_t n);
1200 
1201 
1205 public: static GEOMDLLIMPEXP bool IsConvex (bvector<DPoint3d> const &xyz);
1206 
1207 
1228 public:
1229 static GEOMDLLIMPEXP bool FixupAndTriangulateLoopsXY
1230 (
1231 bvector<int> *pIndices,
1232 bvector<int> *pExteriorLoopIndices,
1233 bvector<DPoint3d> *pXYZOut,
1234 bvector<DPoint3d> *pXYZIn,
1235 double xyTolerance,
1236 int maxPerFace,
1237 bool signedOneBasedIndices,
1238 bool addVerticesAtCrossings
1239 );
1240 
1256 public:
1257 static GEOMDLLIMPEXP bool FixupAndTriangulateProjectedLoops
1258 (
1259 bvector<int>* pIndices,
1260 bvector<int>* pExteriorLoopIndices,
1261 bvector<DPoint3d>* pXYZOut,
1262 TransformCR localToWorld,
1263 TransformCR worldToLocal,
1264 bvector<DPoint3d> *pXYZIn,
1265 double xyTolerance,
1266 bool bSignedOneBasedIndices
1267 );
1268 
1283 public:
1284 static GEOMDLLIMPEXP bool FixupAndTriangulateSpaceLoops
1285 (
1286 bvector<int>* pIndices,
1287 bvector<int>* pExteriorLoopIndices,
1288 bvector<DPoint3d>* pXYZOut,
1289 TransformR localToWorld,
1290 TransformR worldToLocal,
1291 bvector<DPoint3d>* pXYZIn,
1292 double xyTolerance,
1293 bool bSignedOneBasedIndices
1294 );
1295 
1296 
1307 public:
1308 static GEOMDLLIMPEXP bool CoordinateFrame
1309 (
1310 bvector<DPoint3d> *pXYZIn,
1311 TransformR localToWorld,
1312 TransformR worldToLocal
1313 );
1314 
1326 public:
1327 static GEOMDLLIMPEXP bool CoordinateFrame
1328 (
1329 DPoint3dCP pXYZIn,
1330 size_t numXYZ,
1331 TransformR localToWorld,
1332 TransformR worldToLocal
1333 );
1334 
1335 public:
1336 static GEOMDLLIMPEXP bool CoordinateFrame
1337 (
1338 DPoint3dCP pXYZIn,
1339 size_t numXYZ,
1340 TransformR localToWorld,
1341 TransformR worldToLocal,
1342 enum LocalCoordinateSelect selector
1343 );
1344 
1345 
1346 
1360 public:
1361 static GEOMDLLIMPEXP bool ReorientTriangulationIndices
1362 (
1363 bvector<int> &indices,
1364 bool *pbReversed,
1365 bool bSignedOneBasedIndices
1366 );
1367 
1371 public: static GEOMDLLIMPEXP double AreaXY (bvector<DPoint3d> const &xyz);
1375 public: static GEOMDLLIMPEXP double AreaXY (DPoint3dCP pXYZ, size_t numXYZ);
1376 
1380 public: static GEOMDLLIMPEXP double Area (bvector<DPoint2d> const &xy);
1384 public: static GEOMDLLIMPEXP double Area (DPoint2dCP pXY, size_t numXY);
1385 
1389 public: static GEOMDLLIMPEXP bool CentroidNormalAndArea (bvector<DPoint3d> const &xyz, DPoint3dR centroid, DVec3dR normal, double &area);
1393 public: static GEOMDLLIMPEXP bool CentroidNormalAndArea (DPoint3dCP pXYZ, size_t numXYZ, DPoint3dR centroid, DVec3dR normal, double &area);
1394 
1397 public: static GEOMDLLIMPEXP bool CentroidAndArea (bvector<DPoint2d> &points, DPoint2dR centroid, double &area);
1398 
1404 public: static GEOMDLLIMPEXP bool SecondAreaMomentProducts (bvector<DPoint3d> const &xyz, DPoint3dCR origin, DMatrix4dR products);
1405 
1417 public: static GEOMDLLIMPEXP bool PickTriangleFromStart
1418  (
1419  DPoint3dCP pXYZ,
1420  size_t numXYZ,
1421  DRay3dCR ray,
1422  DPoint3dR xyz,
1423  DPoint3dR triangleFractions,
1424  double &rayFraction,
1425  size_t &edgeBaseIndex
1426  );
1427 
1428 
1438 public: static GEOMDLLIMPEXP bool PickTriangleFromStart
1439  (
1440  DPoint2dCP xyPoints, size_t n, DPoint2dCR xy,
1441  size_t &edgeBaseIndex,
1442  DPoint3dR uvw, DPoint3dR duvwdX, DPoint3dCR duvwdY
1443  );
1444 
1467 public: static GEOMDLLIMPEXP PlanePolygonSSICode PlaneIntersectionPoints
1468 (
1469 bvector<DPoint3d> const &points,
1470 DPlane3dCR plane,
1471 double touchTolerance,
1472 bvector<CurveLocationDetail> &trueCrossings,
1473 bvector<CurveLocationDetail> *touchData,
1474 DRange1d &altitudeLimits
1475 );
1476 
1477 };
1478 
1479 
1515 
1517 {
1521 static bool GEOMDLLIMPEXP IsValidClusterIndex (bvector <size_t> &clusterData, size_t index);
1522 
1524 static size_t GEOMDLLIMPEXP NewClusterIndex (bvector<size_t> &clusterData);
1525 
1527 static size_t GEOMDLLIMPEXP AddClusters (bvector<size_t> &clusterData, size_t numAdd);
1528 
1530 static size_t GEOMDLLIMPEXP MergeClusters (bvector<size_t> &clusterData, size_t index0, size_t index1);
1531 
1533 static size_t GEOMDLLIMPEXP FindClusterRoot (bvector<size_t> &clusterData, size_t start);
1534 
1535 };
1536 
1537 
1552 
1553 template <typename T>
1555 {
1556 
1557 private:
1558 bvector<T> m_entries;
1559 // The dequeue entries are in indices i0 <= i < i1, considered cyclically.
1560 size_t m_i0; // Always 0 <= m_i0 < m_entries.size ();
1561 size_t m_i1; // Always m_i0 <= m_i1 <= m_i0 + m_entries.size ();
1562 T m_defaultValue;
1563 
1564 size_t CyclicPhysicalIndex (size_t i) const
1565  {
1566  if (i < m_entries.size ())
1567  return i;
1568  else
1569  return i % m_entries.size ();
1570  }
1571 
1572 
1573 public:
1575 void Clear (){m_i0 = m_i1 = 0;}
1577 DoubleEndedQueue (T defaultValue)
1578  :
1579  m_entries(10),
1580  m_defaultValue (defaultValue)
1581  {
1582  Clear ();
1583  }
1585 bool IsEmpty () const {return m_i1 <= m_i0;}
1590  {
1591  size_t n0 = m_i1 - m_i0;
1592  size_t n1 = m_entries.size ();
1593  if (n0 < n1)
1594  return;
1595  // (and strictly, n0==n1 -- the > case cannot happen)
1596  // the array is packed with entries a..b c..d organized physically as [c..d a..b]
1597  // Copy all entries of the physical aray to the back, so its contents are [c..d a..b c..d a..b]
1598  m_entries.reserve (2 * n0);
1599  for (size_t i = 0; i < n0; i++)
1600  m_entries.push_back (m_entries[i]);
1601  // m_i0 already points at the first a
1602  // m_i1 = m_i0 + n0 is already correct, but now with no wraparound happening.
1603  // so there is nothing more to do!!!
1604  }
1606 size_t Size () const { return m_i1 - m_i0;}
1608 void AddRight (T value)
1609  {
1611  m_entries[CyclicPhysicalIndex (m_i1)] = value;
1612  m_i1++;
1613 // if (s_printHullSteps)
1614 // printf (" PushLeft %3d\n", (int)value);
1615  }
1617 void AddLeft (T value)
1618  {
1620 // if (s_printHullSteps)
1621 // printf (" PushLeft %3d\n", (int)value);
1622  if (m_i0 == 0)
1623  {
1624  size_t n = m_entries.size ();
1625  m_i0 += n;
1626  m_i1 += n;
1627  }
1628  m_i0--;
1629  m_entries[m_i0] = value;
1630  }
1632 T GetRight () const
1633  {
1634  if (IsEmpty ())
1635  return m_defaultValue;
1636  return m_entries[CyclicPhysicalIndex(m_i1)];
1637  }
1638 
1640 T GetLeft () const
1641  {
1642  if (IsEmpty ())
1643  return m_defaultValue;
1644  return m_entries[m_i0];
1645  }
1646 
1648 T GetCyclicFromLeft (ptrdiff_t k) const
1649  {
1650  size_t n = m_i1 - m_i0;
1651  if (n == 0)
1652  return m_defaultValue;
1653  if (k < 0)
1654  k = n - ((-k) % n);
1655  if (k >= (ptrdiff_t)n)
1656  k = (k % n);
1657  if ((ptrdiff_t)m_i0 + k >= (ptrdiff_t)m_i1)
1658  return m_defaultValue;
1659  size_t i = m_i0 + k;
1660  return m_entries[CyclicPhysicalIndex(i)];
1661  }
1662 
1664 T GetFromRight (size_t k) const
1665  {
1666  if (IsEmpty ())
1667  return m_defaultValue;
1668  if (m_i0 + k >= m_i1)
1669  return m_defaultValue;
1670  size_t i = m_i1 - 1 - k;
1671  return m_entries[CyclicPhysicalIndex(i)];
1672  }
1673 
1675 T GetFromLeft (size_t k) const
1676  {
1677  if (IsEmpty ())
1678  return m_defaultValue;
1679  size_t i = m_i0 + k;
1680  if (i < m_i1)
1681  return m_entries[CyclicPhysicalIndex(i)];
1682  return m_defaultValue;
1683  }
1684 
1686 void PopRight ()
1687  {
1688  if (!IsEmpty ())
1689  {
1690 // if (s_printHullSteps)
1691 // printf (" PopRight %3d\n", (int)GetRight ());
1692  if (m_i1 > m_i0)
1693  m_i1--;
1694  }
1695  }
1696 
1698 void PopLeft ()
1699  {
1700  if (!IsEmpty ())
1701  {
1702 // if (s_printHullSteps)
1703 // printf (" PopLeft %3d\n", (int)GetLeft ());
1704  m_i0++;
1705  if (m_i0 >= m_entries.size ())
1706  {
1707  m_i0 = 0;
1708  m_i1 -= m_entries.size ();
1709  }
1710  }
1711  }
1714 bool operator == (DoubleEndedQueue<T> const &other) const
1715  {
1716  size_t n = Size ();
1717  if (n != other.Size ())
1718  return false;
1719  for (size_t i = 0; i < n; i++)
1720  if (GetFromLeft (i) != other.GetFromLeft (i))
1721  return false;
1722  return true;
1723  }
1724 };
1725 
1739 template <typename T>
1741  {
1742  struct Entry
1743  {
1744  double m_value;
1746  Entry (T data, double value) : m_data (data), m_value (value) {}
1747  };
1748  private:
1749  bvector<Entry> m_heap;
1750 
1751  size_t Parent (size_t i)
1752  {
1753  if (i > 0)
1754  return (i - 1) / 2;
1755  return 0; // root is its own parent !?!?!
1756  }
1757  size_t LeftChild (size_t i) { return 2 * i + 1; }
1758  size_t RightChild (size_t i) { return 2 * i + 2; }
1759  public: size_t Size () const { return m_heap.size ();}
1760  public:
1761  void Clear (){m_heap.clear ();}
1763  void Insert (T data, double value)
1764  {
1766  m_heap.push_back (Entry (data, value));
1767  size_t child = m_heap.size () - 1;
1769  while (child > 0)
1770  {
1771  size_t parent = Parent (child);
1772  if (m_heap[parent].m_value < m_heap[child].m_value)
1773  break;
1774  std::swap (m_heap[parent], m_heap[child]);
1775  child = parent;
1776  }
1777  }
1778  public:
1779  // ASSUME heap has data .. use IsEmpty () to pretest !!!
1780  double MinValue (){return m_heap.front ().m_value;}
1781  T MinData (){return m_heap.front ().m_data;}
1782  bool IsEmpty (){return m_heap.empty ();}
1783 
1784 
1786  bool RemoveMin (T &data, double &value)
1787  {
1788  size_t n = m_heap.size ();
1789  if (n == 0)
1790  return false;
1791  data = m_heap.front ().m_data;
1792  value = m_heap.front ().m_value;
1793  // fill the hole at the root with the very last array entry.
1794  m_heap.front () = m_heap.back ();
1795  m_heap.pop_back ();
1796  size_t parent = 0;
1797  // push the new value back down until the sort condition is again in effect.
1798  for (;;)
1799  {
1800  // swap with the smaller child and continue down ....
1801  size_t child = LeftChild (parent);
1802  if (child >= n)
1803  break;
1804  size_t rightChild = child + 1;
1805  if (rightChild < n && m_heap[rightChild].m_value < m_heap[child].m_value)
1806  child = rightChild;
1807  if (m_heap[child].m_value < m_heap[parent].m_value)
1808  {
1809  std::swap (m_heap[child], m_heap[parent]);
1810  parent = child;
1811  }
1812  else
1813  break;
1814  }
1815  return true;
1816  }
1817 
1818  bool RemoveMin ()
1819  {
1820  T data;
1821  double value;
1822  return removeMin (data, value);
1823  }
1825  bool Validate ()
1826  {
1827  size_t errors = 0;
1828  size_t n = m_heap.size ();
1829  for (size_t i = 0; i < n; i++)
1830  {
1831  size_t i1 = LeftChild (i);
1832  size_t i2 = RightChild (i);
1833  if (i1 < n && m_heap[i1].m_value < m_heap[i].m_value)
1834  errors++;
1835  if (i2 < n && m_heap[i2].m_value < m_heap[i].m_value)
1836  errors++;
1837  }
1838  return errors == 0;
1839  }
1840  };
1841 
1849 {
1852 
1854 void AppendXF (DPoint3dCR xyz, double f);
1858 void AppendXdeltaF (DPoint3dCR xyz, double deltaF);
1859 
1866 bool SearchBracketPoints (double f, size_t &i0, double &f0, DPoint3dR xyz0, size_t &i1, double &f1, DPoint3dR xyz1) const;
1867 
1869 DRange3d GetRange () const;
1870 
1872 DRange3d GetRange (TransformCR transform) const;
1876 void ReverseXF (bool reverseFAs01Fraction);
1877 };
1878 
1886 {
1890 
1896 void ReverseXFUV (bool reverseFAs01Fraction, bool negateVectorU, bool negateVectorV);
1897 
1898 };
1899 
1905 {
1907 
1913 void ReverseXFUVC (bool reverseFAs01Fraction, bool negateVectorU, bool negateVectorV);
1918 void ReverseXFUVC (size_t index0, size_t index1, bool reverseFAs01Fraction, bool negateVectorU, bool negateVectorV);
1919 
1920 
1922 void Add (DPoint3dCR xyz, double f, DVec3dCR vectorU, ICurvePrimitive* curve)
1923  {
1924  m_xyz.push_back (xyz);
1925  m_f.push_back (f);
1926  m_vectorU.push_back (vectorU);
1927  m_curve.push_back (curve);
1928  }
1929 void Add (ValidatedDRay3d const &ray, double f, ICurvePrimitive* curve)
1930  {
1931  if (ray.IsValid ())
1932  {
1933  m_xyz.push_back (ray.Value ().origin);
1934  m_f.push_back (f);
1935  m_vectorU.push_back (ray.Value ().direction);
1936  m_curve.push_back (curve);
1937  }
1938  }
1939 
1940 };
1941 
struct RotMatrix const * RotMatrixCP
Definition: msgeomstructs_typedefs.h:135
static bool ClearlyIncreasingFraction(double a, double b)
test knowing range 0..1 for values...
static bool IsIn01OrExtension(double x, bool extend0, bool extend1)
Test if x is between 0 and 1 inclusive.
Operations on arrays of DVec3d (bvector and contiguous buffer).
Definition: DPoint3dOps.h:213
static bool IsRectangle(DPoint3dCP points, size_t n, TransformR localToWorld, TransformR worldToLocal, bool requireClosurePoint=true)
test if points are form a rectangle.
Entry(T data, double value)
Definition: DPoint3dOps.h:1746
static void AddContinuationStartPoint(bvector< DPoint3d > &points, DPoint3dCR xyz, bool forceIncludeThisPoint)
push_back xyz to the point array, but possibly ignore if it duplicates points.back () ...
static bool Are4EdgesPerpendicular(DPoint3dCP points)
return true if the 4 edges between points 01,12,23,30 are perpendicular.
struct RotMatrix & RotMatrixR
Definition: msgeomstructs_typedefs.h:135
static bool SafeDivideDistanceSquared(double &result, double numerator, double denominator, double defaultResult=0.0)
Attempt to divide {numerator/denominator} Return false if result is larger than 30 digits...
static void CopyBetweenFractions(bvector< DPoint3d > const &points, bvector< DPoint3d > &dest, double fractionA, double fractionB)
Search (forward or reverse, according to sign of requested distance).
static size_t FindClusterRoot(bvector< size_t > &clusterData, size_t start)
Walk from start to root. All entries along the way are fixed up to point directly to the root...
static double SumAbsoluteAngles(DPoint3dCP xyz, double const *weight, ptrdiff_t step, size_t count, bool addClosure, double minEdgeLength=0.0)
void Clear()
Definition: DPoint3dOps.h:1761
static void EnforceClosure(bvector< DPoint3d > &points)
If final point is "AlmostEqual" to first, make it exact. If not, push first point to close...
static size_t MostDistantIndex(bvector< T >const &data, T const &baseValue)
Find the index of the value most distance from baseValue. Return SIZE_MAX if empty array...
static void ApplyFunction(bvector< double > const &x, double(*f)(double), bvector< double > &fOfx)
static void SetZeros(bvector< double > &dest)
DPoint3dDoubleUVArrays with additional markup: ul> ul>m_curve – array of curve primitive pointer (no...
Definition: DPoint3dOps.h:1904
static bool CoordinateFrame(bvector< DPoint3d > *pXYZIn, TransformR localToWorld, TransformR worldToLocal)
Compute a local to world transformation for a polygon (disconnects allowed) Favor first polygon CCW f...
void push_back(const_reference)
static double Magnitude(double a, double b, double c)
return sqrt (a*a + b*b + c*c)
static bool ClosestApproach(bvector< DPoint3d > const &xyzA, bvector< DPoint3d > const &xyzB, CurveLocationDetailR locationA, CurveLocationDetailR locationB)
Find the closest approach between polylines.
T GetFromRight(size_t k) const
return the i'th entry counting from right to left.
Definition: DPoint3dOps.h:1664
struct DPoint3d const * DPoint3dCP
Definition: msgeomstructs_typedefs.h:79
static ValidatedDouble ValidatedDivideDistanceSquared(double a, double b, double defaultResult=0.0)
Attempt to divide {numerator/denominator}.
bool operator==(DoubleEndedQueue< T > const &other) const
Test if two queues have identical logical entries.
Definition: DPoint3dOps.h:1714
static void SortTail(bvector< double > &data, size_t i0, bool ascending=true)
Sort entries starting at i0.
void PopLeft()
remove the left-most entry.
Definition: DPoint3dOps.h:1698
struct IFacetOptions const & IFacetOptionsCR
Definition: msgeomstructs_typedefs.h:162
static void Swap(double &dataA, double &dataB)
static void Compress(bvector< T > &data, double tolerance)
Inplace removal of near-duplicate points.
static void MinusOnePlus1LinearMapInPlace(bvector< double > &data, double aMinus, double aPlus)
map (-1,1) to (aMinus,aPlus) in place
static double SmallCoordinateRelTol()
Relative tolerance for coordinate tests. This is 1e-10, and is coarser than Angle::SmallAngle.
static void AppendXY(bvector< DPoint2d > *dest, double x, double y)
append a point to the bvector
static double Min(double a1, double a2)
min of 2 candidates
static bool AddCloseApproaches(bvector< DPoint3d > const &xyzA, bvector< DPoint3d > const &xyzB, bvector< CurveLocationDetail > &locationA, bvector< CurveLocationDetail > &locationB, double maxDistance=DBL_MAX)
Find (pairs of) points of closest approach between two linestrings.
static bool IsValidClusterIndex(bvector< size_t > &clusterData, size_t index)
Simple bounds check in an index.
T GetFromLeft(size_t k) const
return the k'th entry counting from left to right
Definition: DPoint3dOps.h:1675
void MakeRoomForInsertion()
Ensure there is capacity for 1 additional insertion to the logical dequeue.
Definition: DPoint3dOps.h:1589
struct DVec3d & DVec3dR
Definition: msgeomstructs_typedefs.h:89
static bool IsAlmostIn01(double x)
Test if x is between 0 and 1 inclusive, with AlmostEqualFraction at each end.
static bool PrincipalExtents(bvector< DPoint3d > const &points, TransformR originWithExtentVectors)
T m_data
Definition: DPoint3dOps.h:1745
static bool FixupAndTriangulateProjectedLoops(bvector< int > *pIndices, bvector< int > *pExteriorLoopIndices, bvector< DPoint3d > *pXYZOut, TransformCR localToWorld, TransformCR worldToLocal, bvector< DPoint3d > *pXYZIn, double xyTolerance, bool bSignedOneBasedIndices)
Triangulate a single space polygon as projected in caller-supplied coordinate frame.
static bool ClosestPoint(bvector< DPoint3d > const &xyz, bool addClosurePoint, DPoint3dCR spacePoint, double &fraction, DPoint3dR curvePoint)
Search for closest point on edge. Optionally add closure edge.
static DRange1d ProjectedParameterRange(bvector< DPoint3d > const &points, DRay3dCR ray)
static bool IsExact01(double a0, double a1)
Bitwise equality test for exact 01 interval references...
static bool OffsetLineStringXY(bvector< DPoint3d > &out, bvector< DPoint3d > const &in, double offsetDistance, bool periodic=false, double maxMiterRadians=1.58)
Simple linestring offset – miter joints, no loop removal.
#define END_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:30
static bool WireCentroid(bvector< DPoint3d > const &points, double &length, DPoint3dR centroid, double fraction0=0.0, double fraction1=1.0)
return polyline length and centroid of the "wire".
static bool AlmostEqual(T const &valueA, T const &valueB)
Near equality test with default Angle::SmallAngle absolute and relative tolerances.
size_t Size() const
Definition: DPoint3dOps.h:1759
static double Hypotenuse(double a, double b)
return sqrt (a^2 + b^2)
static bool LinearTransform(double a0, double a1, double b0, double b1, double &c, double &d)
Compute a linear transformation f(x) = c + d * x so that a0 maps to b0 and a1 maps to b1...
T MinData()
Definition: DPoint3dOps.h:1781
static bool CentroidAndArea(bvector< DPoint2d > &points, DPoint2dR centroid, double &area)
Return the centroid and area of the polygon.
static bool WithinTolerance(double a1, double a2, double abstol)
Test if two doubles are equal within tolerance.
Embed a double ended queue in a bvector ul> li>The dequeue's logical start value a can appear a...
Definition: DPoint3dOps.h:1554
static bool Equal(bvector< T > const &dataA, bvector< T > const &dataB)
Test if all members are exactly equal.
static ValidatedDouble ValidatedDivideParameter(double a, double b, double defaultResult=0.0)
Attempt to divide {numerator/denominator}.
bool RemoveMin(T &data, double &value)
Remove the root (minimum sort value) entry.
Definition: DPoint3dOps.h:1786
static void InterpolateAll(bvector< T > &dest, bvector< T > const &dataA, double f, bvector< T > const &dataB)
Interpolate between T values in dataA and dataB.
bool SearchBracketPoints(double f, size_t &i0, double &f0, DPoint3dR xyz0, size_t &i1, double &f1, DPoint3dR xyz1) const
Search the fraction array for an interval containing f.
Coincident logical constraint.
static void Multiply(bvector< DPoint3d > *xyz, TransformCR transform)
Multiply each (non-disconnect) point in place by a transform.
static bool LexicalYExtrema(int &iMin, int &iMax, DPoint2dCP points, int nPoint)
Return indices where min and max y of lexical sort order occur.
static void CopyToIndex(bvector< double > const &source, bvector< size_t > const &index, bvector< double > &dest)
make dest[i] = source[index[i]];
PlanePolygonSSICode
Definition: DPoint3dOps.h:1174
static bool ClearlyIncreasing(double a, double b, double tol)
test with tolerance for equality
void Insert(T data, double value)
insert an entry
Definition: DPoint3dOps.h:1763
size_type count(const key_type &__x) const
Definition: stdcxx/bstdmap.h:277
void swap(basic_string< _CharT, _Traits, _Allocator > &__a, basic_string< _CharT, _Traits, _Allocator > &__b)
Definition: basic_string.h:1396
static double Length(bvector< DPoint3d > const &xyz, bool addClosure=false)
return the total length of the polyline. Optionally add closure edge. disconnects allowed...
static bool ClosestPointXY(bvector< DPoint3d > const &xyz, DMatrix4dCP worldToLocal, DPoint3dCR spacePoint, size_t &closestIndex, double &minDist)
search for closest point in array (NO implied curve or lines between points).
static bool FractionToFrenetFrame(bvector< DPoint3d > const &points, double f, TransformR frame)
static bool IsConvex(bvector< DPoint3d > const &xyz)
test if the polygon is convex.
static double SumAbs(double *data, int n)
static double MaxAbsDiff(bvector< double > const &x, bvector< double > const &y)
static void LinearMapFrontBackToInterval(bvector< double > &data, double a0, double a1)
map first point to a0, last to a1, others proportionally
struct Transform & TransformR
Definition: msgeomstructs_typedefs.h:134
bool IsEmpty() const
Definition: DPoint3dOps.h:1585
T GetCyclicFromLeft(ptrdiff_t k) const
return the i'th entry counting cyclically from the left
Definition: DPoint3dOps.h:1648
static void CollectZPairsForOrderedXPoints(bvector< DPoint3d >const &pointA, bvector< DPoint3d > const &pointB, bvector< CurveLocationDetailPair > &pairs)
Both inputs must have increasing X.
static bool FixupAndTriangulateSpaceLoops(bvector< int > *pIndices, bvector< int > *pExteriorLoopIndices, bvector< DPoint3d > *pXYZOut, TransformR localToWorld, TransformR worldToLocal, bvector< DPoint3d > *pXYZIn, double xyTolerance, bool bSignedOneBasedIndices)
Triangulate a single space polygon.
ValidatedValue< double > ValidatedDouble
Definition: GeomApi.h:353
bvector< ICurvePrimitive * > m_curve
ul> li>Invoke the base class ReverseXFYV with with passthrough args li>Reverse curves, optionally negating vectors /ul>
Definition: DPoint3dOps.h:1906
static ValidatedDouble ValidatedDivide(double a, double b, double defaultResult=0.0, double minRelativeDivisor=1.0e-15)
Attempt to divide {numerator/denominator}.
static ValidatedDRay3d PolylineFractionToRay(bvector< DPoint3d > const &points, double polylineFraction)
static bool BoundingValues(double const *pData, size_t n, double searchValue, size_t &lowerIndex, double &lowerBound, double &upperBound)
Search a sorted array for a bracketing interval, preferably lowerBound &le searchValue < upperBound...
double m_value
Definition: DPoint3dOps.h:1744
static void AddPointIfDistinctFromBack(bvector< DPoint3d > &points, DPoint3d xyz)
push a point on the back, but skip of "AlmostEqual"
static bool ClosestPointXY(bvector< DPoint3d > const &xyz, bool addClosurePoint, DPoint3dCR spacePoint, DMatrix4dCP worldToLocal, double &globalFraction, DPoint3dR curvePoint, size_t &edgeIndex, size_t &numEdge, double &edgeFraction, double &xyDistance)
Search for closest point on edge, using xy coordinates after optional projection. Optionally add clos...
static bool Get(bvector< T > *dest, T &data, size_t index)
Get with checked array pointer and index.
ValidatedValue< struct DVec2d > ValidatedDVec2d
Definition: GeomApi.h:345
Pair of arrays of corresponding xyz and double values.
Definition: DPoint3dOps.h:1848
Implement the classic "Union Find" algorithm in bvector Begin with n distinct sequential inte...
Definition: DPoint3dOps.h:1516
static T * MallocAndCopy(bvector< T > &source)
Copy data to the heap as allocated by BSIBaseGeom::Malloc.
static void AppendXY(bvector< DVec2d > *dest, double x, double y)
append a vector to the bvector
struct DPoint2d & DPoint2dR
Definition: msgeomstructs_typedefs.h:78
static double Interpolate(double dataA, double fraction, double dataB)
Interpolate between values.
static size_t Cluster(bvector< DVec3d > const &xyzIn, bvector< DVec3d > *xyzOut, bvector< size_t > &oldIndexToPackedIndex, double absTol=-1.0, double relTol=-1.0)
Find nearly-identical points.
bool RemoveMin()
Definition: DPoint3dOps.h:1818
static bool FixupAndTriangulateLoopsXY(bvector< int > *pIndices, bvector< int > *pExteriorLoopIndices, bvector< DPoint3d > *pXYZOut, bvector< DPoint3d > *pXYZIn, double xyTolerance, int maxPerFace, bool signedOneBasedIndices, bool addVerticesAtCrossings)
Triangulate a single xy polygon.
class wrapper for static utiliity functions on data structures built around DPoint2d.
Definition: DPoint3dOps.h:19
Operations on arrays of DVec2d (bvector and contiguous buffer).
Definition: DPoint3dOps.h:249
bvector< double > m_f
Definition: DPoint3dOps.h:1851
static UsageSums SumSegmentLengths(bvector< DPoint3d > const &xyz)
return statistical data (sum, min, max ..) for length of segments
static double Max(double a1, double a2)
min of 2 candidates
static bool FindNotAlmostEqualBefore(bvector< T >const &data, T const &baseValue, size_t i0, size_t &i1, T &value)
Search for [i0-1..(downward)] for index i1 at which the array value is not AlmostEqual to the given v...
LocalCoordinateSelect
Definition: msgeomstructs_typedefs.h:231
static bool SafeDivide(double &result, double numerator, double denominator, double defaultResult=0.0, double smallFraction=1.0e-15)
Attempt to divide {numerator/denominator} Return false if result is larger than than 1/safeDivideFrac...
static size_t GetStrokeCount(bvector< DPoint3d > const &points, IFacetOptionsCR options, double startFraction=0.0, double endFraction=1.0)
static double PreciseSum(double *data, size_t n)
Sum using Kanane's high precision correction sequence.
double MinValue()
Definition: DPoint3dOps.h:1780
Implementation of a priorityQueue (sometimes called a heap).
Definition: DPoint3dOps.h:1740
bvector< DPoint2d > m_uv
Definition: DPoint3dOps.h:1887
static void AppendXY0(bvector< DPoint3d > &dest, bvector< DPoint2d > const &source)
Append xy points with 0 z.
static double AreaXY(bvector< DPoint3d > const &xyz)
Return the of the polygon's projection to the xy plane.
Operations on arrays of DPoint2d (bvector and contiguous buffer).
Definition: DPoint3dOps.h:161
static bool PickTriangleFromStart(DPoint3dCP pXYZ, size_t numXYZ, DRay3dCR ray, DPoint3dR xyz, DPoint3dR triangleFractions, double &rayFraction, size_t &edgeBaseIndex)
Search for a triangle which has an interior point intersection with a ray.
static DRange1d ProjectedParameterRange(bvector< DPoint3d > const &points, DRay3dCR ray, double fraction0, double fraction1)
static void Sort(double *data, size_t count, bool ascending=true)
sort flat array of doubles, optionally descending.
static bool MinMaxDistance(bvector< DPoint3d > const &xyzA, bvector< DPoint3d > const &xyzB, double &minDistance, size_t &minIndex, double &maxDistance, size_t &maxIndex)
Find the min and max distances and their index positions.
static ValidatedDouble InverseInterpolate(double dataA, double value, double dataB)
Return the fraction such that Interplate (dataA, fraction, dataB) equals value.
static bool AddStrokes(bvector< DPoint3d > const &points, bvector< DPoint3d > &strokes, IFacetOptionsCR options, bool includeStartPoint=true, double startFraction=0.0, double endFraction=1.0)
static void UpdateMinMax(double x, double f, double &xMin, double &fMin, double &xMax, double &fMax)
update evolving minmax f values with associated x values.
static void SetPolylinePolylineHeapTrigger(size_t mn)
Set the transition from m*n search to range heap for PolylinePolyline searches.
static size_t NewClusterIndex(bvector< size_t > &clusterData)
Create a new cluster, i.e. new entry at end of array pointing to itself as parent.
void AppendXdeltaF(DPoint3dCR xyz, double deltaF)
Append xyz to its array, If there are prior fractions, add deltaF to the last.
static bool FractionAtSignedDistanceFromFraction(bvector< DPoint3d > const &xyz, double startFraction, double signedDistance, double &endFraction, size_t &endSegmentIndex, double &segmentFraction, double &actualDistance)
Search (forward or reverse, according to sign of requested distance).
Operations in which an array of points is understood to be connected as a polyline (but not closed as...
Definition: DPoint3dOps.h:772
static bool MaxDistanceFromUnboundedRay(bvector< DPoint3d > const &xyz, DRay3dCR ray, size_t &index, double &maxDistance)
search for farthest point from unbounded ray
Operations in which an array of points is understood to be connected as a closed polygon.
Definition: DPoint3dOps.h:1183
void ReverseXF(bool reverseFAs01Fraction)
Reverse the order of the xyz and F arrays.
static void GreedyTriangulationBetweenLinestrings(bvector< DPoint3d > const &linestringA, bvector< DPoint3d > const &linestringB, bvector< DTriangle3d > &triangles, bvector< int > *oneBasedABIndex=nullptr)
Build triangles that advance along two linestrings.
static bool FindNotAlmostEqualAtOrAfter(bvector< T >const &data, T const &baseValue, size_t i0, size_t &i1, T &value)
Search for [i0..] for index i1 at which the array value is not AlmostEqual to the given value...
static size_t AddClusters(bvector< size_t > &clusterData, size_t numAdd)
Create numAdd new clusters. Return the total number of clusters.
static ValidatedDouble ValidatedDivideDistance(double a, double b, double defaultResult=0.0)
Attempt to divide {numerator/denominator}.
static size_t MergeClusters(bvector< size_t > &clusterData, size_t index0, size_t index1)
Announce that the clusters that contains index0 are ultimately the same cluster.
static double LargestXYCoordinate(DPoint3dCP points, size_t n)
Find the largest coordinate in array, ignoreing z.
struct CurveLocationDetail & CurveLocationDetailR
Definition: msgeomstructs_typedefs.h:167
ValidatedValue< DRay3d > ValidatedDRay3d
Definition: GeomApi.h:360
struct DMatrix4d & DMatrix4dR
Definition: msgeomstructs_typedefs.h:97
static bool ClosestPoint(bvector< DPoint3d > const &xyz, DPoint3dCR spacePoint, size_t &closestIndex, double &minDist)
search for closest point in array (NO implied curve or lines between points).
static bool CollectIntersectionsAndCloseApproachesXY(bvector< DPoint3d > const &xyzA, bvector< double > const *paramA, bvector< DPoint3d > const &xyzB, bvector< double > const *paramB, bvector< CurveLocationDetail > &locationA, bvector< CurveLocationDetail > &locationB, double maxDist)
Compute intersections among linestrings.
static double ClampFraction(double s)
Clamp a single fraction.
struct DPoint2d const & DPoint2dCR
Definition: msgeomstructs_typedefs.h:78
static void AppendXYZ(bvector< DPoint3d > *dest, double x, double y, double z=0.0)
append a point to the bvector
static size_t Append(bvector< T > *dest, T const *source, size_t count)
append contiguous points to the bvector. return first index
A Bentley supplied implementation std::vector.
Definition: stdcxx/bvector.h:77
void ReverseXFUV(bool reverseFAs01Fraction, bool negateVectorU, bool negateVectorV)
DRange3d GetRange() const
Return the range of the points.
static bool PrincipalAxes(bvector< DPoint3d > const &points, DVec3dR centroid, RotMatrixR axes, DVec3dR moments)
struct DPlane3d const & DPlane3dCR
Definition: msgeomstructs_typedefs.h:113
static void CompressColinearPoints(bvector< DPoint3d > &points, double absTol, bool eliminateOverdraw, bool closed)
Inplace compression of points to eliminate colinear points.
static void CompressByChordError(bvector< DPoint3d > &result, bvector< DPoint3d > const &source, double chordTolerance)
Simplifies a sequence of segments up to tolerance.
static void CopyFromIndex(bvector< double > const &source, bvector< size_t > const &index, bvector< double > &dest)
make dest[index[i]] = source[i];
struct DPoint3d & DPoint3dR
Definition: msgeomstructs_typedefs.h:79
static double SegmentLength(bvector< DPoint3d > const &points, size_t index)
Return the length of the segment starting at given index.
static void ClampDirectedFractionInterval(double &t0, double &t1)
Clamp two fractions to 0..1 respecting directional relationship.
static size_t CountDisconnects(bvector< DPoint3d > &points)
Return the number of disconnect points in the array.
static double DeterminantXYXY(double x0, double y0, double x1, double y1)
return determinant
static double Clamp(double x, double a, double b)
Clamp x so it is between a and b. a is assumed less than or equal to b.
static bool LexicalXExtrema(int &iMin, int &iMax, DPoint2dCP points, int nPoint)
Return indices where min and max y of lexical sort order occur.
static DMatrix4d MomentSums(DPoint3dCR origin, bvector< DPoint3d > const &points)
Accumulate (points[i]-origin) into moments sums.
static void Copy(bvector< T > *dest, bvector< T > const *source)
Copy from source to destination.
struct DSegment3d const & DSegment3dCR
Definition: msgeomstructs_typedefs.h:115
A 1d interval with low and high values.
Definition: DRange1d.h:41
static void LinearMapInPlace(bvector< double > &data, double a, double b)
replace each data[i] by (a + b * data[i]);
static size_t Cluster(bvector< DPoint2d > const &xyzIn, bvector< DPoint2d > *xyzOut, bvector< size_t > &oldIndexToPackedIndex, double absTol=-1.0, double relTol=-1.0)
Find nearly-identical points.
struct DMatrix4d const * DMatrix4dCP
Definition: msgeomstructs_typedefs.h:97
static double Area(bvector< DPoint2d > const &xy)
Return the of the polygon's area.
static bool ReorientTriangulationIndices(bvector< int > &indices, bool *pbReversed, bool bSignedOneBasedIndices)
Adjust the triangulation indices returned by ~mvu_triangulateSpacePolygon to match the orientation of...
static double MaxAbs(double a1, double a2)
min absolute value of 2 candidates
struct Transform const & TransformCR
Definition: msgeomstructs_typedefs.h:134
static DRange3d Range(bvector< DPoint3d > const *pXYZIn)
static int TolerancedComparison(double a, double b)
Return -1,0,1 for less than, AlmostEqual, greater than.
static bool IsSelfIntersectingXY(bvector< DPoint3d > const &xyz, bool addClosure=false)
return true if there are any intersections within the linestring.
ICurvePrimitive is a (polymorphic) base class for parametric curves – line segemnt, circular/elliptic arc, bspline curve, spiral.
Definition: CurvePrimitive.h:49
static double Tolerance(bvector< T > const &data, double absTol, double relTol)
return a tolerance as an absolute tolerance plus relative tolerance times largest coordinate...
static void UpdateMax(double &evolvingMax, double testValue)
update an evolving max value.
static bool OffsetLineString(bvector< DPoint3d > &out, bvector< DPoint3d > const &in, double offsetDistance, DVec3dCR planeNormal, bool periodic=false, double maxMiterRadians=1.58)
Simple linestring offset – miter joints, no loop removal.
static void ChebyshevPoints(bvector< double > &dest, size_t numChebyshev, bool addLimitPoints, size_t numCopyLeft=1, size_t numCopyRight=1)
Constructs an array of Chebyshev points, optionally adding -1 and +1 end values.
struct ICurvePrimitive const * ICurvePrimitiveCP
Definition: msgeomstructs_typedefs.h:166
void PopRight()
remove the right-most entry
Definition: DPoint3dOps.h:1686
static void Reverse(bvector< T > &xyz)
Reverse all points in the vector.
bool Validate()
verify the heap structure .
Definition: DPoint3dOps.h:1825
void Add(DPoint3dCR xyz, double f, DVec3dCR vectorU, ICurvePrimitive *curve)
Add data to respective arrays.
Definition: DPoint3dOps.h:1922
static bool Set(bvector< T > *dest, T const &data, size_t index)
Set with checked array pointer and index.
static double SignedDistanceBetweenFractions(bvector< DPoint3d > const &points, double fraction0, double fraction1)
Return distance (along polyline) between fractional positions.
static PlanePolygonSSICode PlaneIntersectionPoints(bvector< DPoint3d > const &points, DPlane3dCR plane, double touchTolerance, bvector< CurveLocationDetail > &trueCrossings, bvector< CurveLocationDetail > *touchData, DRange1d &altitudeLimits)
Collect data for a polygon crossing a plane.
static bool UpperBound(double const *pData, size_t n, double searchValue, size_t &index)
Find the Index of value in pData(sorted!!!) which is greater than searchValue.
DoubleEndedQueue(T defaultValue)
Initialize with a specified default value to be returned for invalid accesses.
Definition: DPoint3dOps.h:1577
static void Multiply(bvector< DPoint2d > *xyz, TransformCR transform)
Multiply each (non-disconnect) point in place by a transform.
DPoint3dDoubleArrays with additional markup: ul> ul>m_uv – array of 2d (uv, xy) data ul>m_vectorU –...
Definition: DPoint3dOps.h:1885
static bool SecondAreaMomentProducts(bvector< DPoint3d > const &xyz, DPoint3dCR origin, DMatrix4dR products)
bvector< DVec3d > m_vectorV
ul> li>Invoke the base class ReverseXF with reverseFAs01Fraction.
Definition: DPoint3dOps.h:1889
static double SnapZero(double a, double abstol)
snap to zero if within tolerance.
void AppendXF(DPoint3dCR xyz, double f)
Append to each array.
static void AppendToChains(bvector< bvector< DPoint3d >> &chains, DSegment3dCR segment)
If segment chains to the final chain, add its endpoint to the chain. Otherwise start a new chain...
static bool IsIn01(double x)
Test if x is between 0 and 1 inclusive.
static void PackAlmostEqualAfter(bvector< DPoint3d > &points, size_t initialCount)
Starting at initialIndex, pack out points that are AlmostEqual. (if initialIndex is greater than 0...
#define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:29
struct DPoint3d const & DPoint3dCR
Definition: msgeomstructs_typedefs.h:79
T GetLeft() const
return the left entry in the dequeue
Definition: DPoint3dOps.h:1640
static double MinAbs(double a1, double a2)
min absolute value of 2 candidates
static bool ChooseSafeDivideParameter(double &result, double numerator0, double denominator0, double numerator1, double denominator1, double defaultResult=0.0)
Attempt to divide either of {numerator0/denominator0} or (numerator1/denominator1) Return false if re...
static double LargestCoordinate(bvector< T > const &data)
return the largest absolute coordinate in the array.
bvector< DVec3d > m_vectorU
Definition: DPoint3dOps.h:1888
static void AppendDisconnect(bvector< T > *dest)
append a disconnect.
static bool MinMaxAngle(bvector< DVec3d > const &dataA, bvector< DVec3d > const &dataB, double &minAngle, size_t &minIndex, double &maxAngle, size_t &maxIndex)
Find the min and max distances and their index positions.
struct DRay3d const & DRay3dCR
Definition: msgeomstructs_typedefs.h:120
struct DVec3d const & DVec3dCR
Definition: msgeomstructs_typedefs.h:89
static bool Normalize(bvector< double > &data, double a0, double a1)
replace each value by its fractional position between a0 and a1.
static void CompressCyclic(bvector< T > &data, double tolerance)
Inplace removal of near-duplicate points via Compress, followed by removal of trailing points that ma...
void AddRight(T value)
Add value to the dequeue at the right.
Definition: DPoint3dOps.h:1608
static bool LowerBound(double const *pData, size_t n, double searchValue, size_t &index)
Find the Index of value in pData(sorted!!!) which is greater or than equal to searchValue.
void Add(ValidatedDRay3d const &ray, double f, ICurvePrimitive *curve)
Definition: DPoint3dOps.h:1929
struct DPoint2d const * DPoint2dCP
Definition: msgeomstructs_typedefs.h:78
Operations on arrays of doubles (bvector and contiguous buffer).
Definition: DPoint3dOps.h:261
Definition: DPoint3dOps.h:1742
static void AppendXYZ(bvector< DVec3d > *dest, double x, double y, double z=0.0)
append a point to the bvector
bool IsEmpty()
Definition: DPoint3dOps.h:1782
static bool CentroidNormalAndArea(bvector< DPoint3d > const &xyz, DPoint3dR centroid, DVec3dR normal, double &area)
Return the 3D polygon centroid, normal and area.
static size_t Cluster(bvector< DPoint3d > const &xyzIn, bvector< DPoint3d > *xyzOut, bvector< size_t > &oldIndexToPackedIndex, double absTol=-1.0, double relTol=-1.0)
Find nearly-identical points.
static double ChebyshevPoint(size_t i, size_t n)
Return the ith of n chebyshev points, cos(PI * (2i+1)/(2n)), starting at i=0.
static void AppendInterpolated(bvector< T > &dest, T const &first, T const &last, size_t count, bool includeFirst=true)
Add uniformly spaced interpolated points between limits.
Operations on arrays of DPoint2d (bvector and contiguous buffer).
Definition: DPoint3dOps.h:578
static void ScaleArray(double *values, size_t n, double a)
static DVec3d AreaNormal(bvector< DPoint3d > const &xyz)
Sum 0.5 times the cross product vectors from first point to all edges.
static size_t Size(bvector< T > *dest)
size with pointer check
static double SegmentFractionToPolylineFraction(size_t segmentIndex, size_t numSegment, double segmentFraction)
convert segment index and fraction along segment to overall fraction of polyline. ...
size_t Size() const
Definition: DPoint3dOps.h:1606
static bool AlmostEqualFraction(double a, double b)
Near-equality test knowing range 0..1 for values...
void Clear()
Clear the dequeue.
Definition: DPoint3dOps.h:1575
T GetRight() const
return the right entry in the dequeue
Definition: DPoint3dOps.h:1632
static ValidatedDVec2d ValidatedDivideAndDifferentiate(double f, double df, double g, double dg)
Attempt to divide {f/g}.
static DPoint3d SegmentFractionToPoint(bvector< DPoint3d > const &points, size_t index, double segmentFraction)
Return the point at fractional position along a specified edge.
static void MovingAverages(bvector< double > &dest, bvector< double > const &source, size_t blockSize, size_t numSkip0=0, size_t numSkip1=0)
Compute moving averages of blockSize consecutive values, optionally skipping some leading and trailin...
A 3d low and high corner pair for range boxes.
Definition: drange3d.h:20
Accumulate given values.
Definition: counters.h:42
static int TolerancedSign(double a, double abstol)
Return -1,0,1 according to sign, with 0 case subject to tolerance.
static bool PolylineFractionsOnSameSegment(double f0, double f1, size_t numVertex)
Test if two global fractions map to the same segment within a polyline.
static void SetSequential(bvector< double > &dest, double a0=0.0, double delta=1.0)
static double Sum(double *data, int n)
4x4 matrix used for perspective (homogeneous coordinate) calculations.
Definition: dmatrix4d.h:18
static double ComputeTolerance(double maxSize, double abstol, double reltol)
Return a tolerance appropriate for coordinates up to maxSize.
static bool PolylineFractionToSegmentData(size_t numVertex, double fraction, size_t &segmentIndex, size_t &numSegment, double &segmentFraction, bool &isExtrapolated)
convert fraction along total polyline to segment and local fraction.
bvector< DPoint3d > m_xyz
Definition: DPoint3dOps.h:1850
void AddLeft(T value)
Add value to the dequeue at the left.
Definition: DPoint3dOps.h:1617
void ReverseXFUVC(bool reverseFAs01Fraction, bool negateVectorU, bool negateVectorV)
ul> li> Reverse in range index0<=index=""> Any array for which any part of the index range...
static bool SafeDivideParameter(double &result, double numerator, double denominator, double defaultResult=0.0)
Attempt to divide {numerator/denominator} Return false if result is larger than 10 digits...

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.