UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.63 kB
import{unwrapOr as t,toNullable as s,isSome as e}from"../../../core/maybe.js";import{h as n,a as r}from"../../../chunks/vec2.js";import{a as i}from"../../../chunks/vec2f64.js";import{k as o}from"../../../chunks/vec3.js";import{f as c}from"../../../chunks/vec3f64.js";import{cloneSnappingPoint as u,asSnappingPoint as a}from"./SnappingPoint.js";import{projectPointToLineLike as h,projectPointToVerticalCylinder as l,projectPointToVerticalPlane as p,VerticalPlaneType as f,epsilon as d,intersectLineAndPoint as L,intersectVerticalCylinderAndPoint as k,intersectVerticalPlaneAndPoint as m,intersectLineLike as y,intersectLineLikeAndVerticalCylinder as q,intersectVerticalPlaneAndLineLike as x,intersectVerticalPlaneAndVerticalCylinder as T,intersectVerticalPlane as g}from"../../support/geometry3dUtils.js";import{LineType as j}from"../../support/geometry2dUtils.js";class P{intersect(t){return H(this,t)}}class Z extends P{constructor(t){super(),this.point=t}equals(t){return _(t)&&o(this.point,t.point)}closestTo(){return u(this.point)}}class A extends P{constructor(t,s,e){super(),this.start=t,this.end=s,this.type=e,this.lineLike={start:this.start,end:this.end,type:this.type}}equals(t){return S(t)&&this.type===t.type&&o(this.start,t.start)&&o(this.end,t.end)}closestTo(t){const s=h(t,this.lineLike);return a(s)}}class E extends A{constructor(t,s){super(t,s,j.LINE)}}class b extends P{constructor(t,s,e){super(),this.intersection=t,this.first=s,this.second=e}equals(t){return t instanceof b&&this.first.equals(t.first)&&this.second.equals(t.second)}closestTo(){return u(this.intersection)}}class v extends P{constructor(t,s,e){super(),this.basePoint=t,this.first=s,this.second=e}equals(t){return t instanceof v&&this.first.equals(t.first)&&this.second.equals(t.second)}closestTo(t){const s=this.basePoint;return a(c(s[0],s[1],t[2]))}}class w extends P{constructor(t,s){super(),this.center=t,this.radius=s}equals(t){return z(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const s=l(t,this.center,this.radius);return a(s)}}class I extends P{constructor(t,s,e){super(),this.start=t,this.end=s,this.type=e,this.planeLike={start:t,end:s,type:e}}equals(t){return B(t)&&this.type===t.type&&o(this.start,t.start)&&o(this.end,t.end)}closestTo(t){return a(p(t,this.planeLike))}closestEndTo(t){const{start:s,end:e}=this;return Math.sign(n(r(D,e,s),r(J,t,s)))>0?e:s}}class N extends I{constructor(t,s){super(t,s,f.HALF_PLANE)}}class G extends I{constructor(t,s){super(t,s,f.PLANE)}}class O extends P{constructor(t,s,e){super(),this.start=t,this.end=s,this.getZ=e,this.planeLike={start:t,end:s,type:f.HALF_PLANE}}equals(t){return C(t)&&o(this.start,t.start)&&o(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return F(this,t)}addIfOnTheGround(s,e){for(const n of e){const e=t(this.getZ(n[0],n[1],n[2]),0);Math.abs(n[2]-e)<d&&(n[2]=e,s.push(n))}}}function F(t,e){const n=p(e,t.planeLike);return n[2]=s(t.getZ(e[0],e[1],e[2]))??K,a(n)}function H(t,s){let e=[];if(_(t)){const{point:n}=t;S(s)?e=L(s.lineLike,n):z(s)?e=k(s.center,s.radius,n):B(s)?e=m(s.planeLike,n):C(s)&&(e=M(s,t))}else if(S(t)){const{lineLike:n}=t;_(s)?e=L(n,s.point):S(s)?e=y(n,s.lineLike):z(s)?e=q(n,s.center,s.radius):B(s)?e=x(s.planeLike,n):C(s)&&(e=M(s,t))}else if(z(t)){const{center:n,radius:r}=t;if(S(s))e=q(s.lineLike,n,r);else if(_(s))e=k(n,r,s.point);else{if(B(s))return T(s.planeLike,n,r).map((e=>new v(e,t,s)));C(s)&&(e=M(s,t))}}else if(B(t)){const{planeLike:n}=t;if(B(s))return g(n,s.planeLike).map((e=>new v(e,t,s)));if(_(s))e=m(n,s.point);else if(S(s))e=x(n,s.lineLike);else{if(z(s))return T(n,s.center,s.radius).map((e=>new v(e,t,s)));C(s)&&(e=M(s,t))}}else C(t)&&(e=M(t,s));return U(e,t,s)}function M(t,n){const{planeLike:r,getZ:i}=t,o=[];if(_(n))t.addIfOnTheGround(o,m(r,n.point));else if(S(n))t.addIfOnTheGround(o,x(r,n.lineLike));else if(z(n))for(const[s,u]of T(r,n.center,n.radius)){const t=i(s,u,0);e(t)&&o.push(c(s,u,t))}else if(B(n)||C(n))for(const[e,u]of g(r,n.planeLike)){const t=s(i(e,u,0))??K;o.push(c(e,u,t))}return o}function U(t,s,e){return t.map((t=>new b(a(t),s,e)))}function _(t){return t instanceof Z}function S(t){return t instanceof A}function z(t){return t instanceof w}function B(t){return t instanceof I}function C(t){return t instanceof O}const D=i(),J=i(),K=0;export{O as DrapedLineConstraint,b as IntersectionConstraint,E as LineConstraint,A as LineLikeConstraint,Z as PointConstraint,P as SnappingConstraint,w as VerticalCylinderConstraint,N as VerticalHalfPlaneConstraint,v as VerticalLineIntersectionConstraint,G as VerticalPlaneConstraint,I as VerticalPlaneLikeConstraint};