gCAD3D 2.40
ut_bspl.c File Reference

B-Spline-Curve-Utilityfunctions. More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../ut/ut_geo.h"
#include "../ut/ut_bspl.h"
#include "../ut/ut_plg.h"
#include "../ut/ut_ox_base.h"
#include "../ut/func_types.h"
#include "../db/ut_DB.h"

Macros

#define AUXTABSIZ   200
 

Functions

int UT3D_4cvbsp_3cvbsp (CurvBSpl **cv1tab, CurvBSpl **cv2tab, Memspc *objSeg)
 
int UT3D_2ncvbsp_orient (int cv1Nr, CurvBSpl **cv1tab, int cv2Nr, CurvBSpl **cv2tab, Memspc *objSeg)
 
int UT3D_ncvbsp_orient (int cv1Nr, CurvBSpl **cv1tab, Memspc *objSeg)
 
int UT3D_cbsp_dbo (CurvBSpl **cbsp, Memspc *objSeg, int typ, long dbi, Memspc *tmpSeg)
 
int UT3D_cbsp_trim (CurvBSpl *cvo, CurvBSpl *cvi, Memspc *memDat, Memspc *memTmp)
 
int UT3D_cbsp_2cbsp (CurvBSpl *cvo, Memspc *objSeg, double smf, CurvBSpl *cv1, CurvBSpl *cv2, Memspc *tmpSeg)
 
int UT3D_cbsp_ox (CurvBSpl *cbsp, ObjGX *ox1, double smf, Memspc *objSeg, Memspc *tmpSeg)
 
int UT3D_cbsp_1pt (CurvBSpl *bsp, Memspc *memSeg, Point *p1)
 
int UT3D_cbsp_2pt (CurvBSpl *bsp, Memspc *memSeg, Point *p1, Point *p2)
 
int UT3D_cbsp_ci (CurvBSpl *bsp, Memspc *memSeg, Circ *ci1, Memspc *tmpSeg)
 
int UT3D_cbsp_clt (CurvBSpl *bsp, Memspc *memSeg, CurvClot *cv1, Memspc *tmpSeg)
 
int UT3D_cbsp_ell (CurvBSpl *bsp, Memspc *memSeg, CurvElli *el1, Memspc *tmpSeg)
 
int UT3D_bsp_infTg (int *dNr, double *dTab, CurvBSpl *bsp1)
 
int UT3D_bsp_degrad (ObjGX *ox1, CurvBSpl *cv1, Memspc *memSeg1)
 
int UT3D_bsp_ck_pt (CurvBSpl *cv1)
 
int UT3D_bsp_ck_closed__ (CurvBSpl *cv1)
 
int UT3D_bsp_ck_closed_tr (CurvBSpl *cv1)
 
int UT3D_bsp_ck_planar (CurvBSpl *cv1, Vector *vz)
 
int UT3D_cbsp_ck_trim (CurvBSpl *cv1)
 
int UT3D_bsp_ck_minSiz (CurvBSpl *cv1)
 
int UT3D_bsp_cpsbsp (CurvBSpl *cvo, SurBSpl *su1, char cDir, int cvNr, Memspc *memSeg1)
 
int UT3D_pt_intlnbspl (int *nxp, Point *xptab, Memspc *memSeg1, Line *ln, CurvBSpl *bspl)
 
int UT3D_pt_intplbspl (int *pNr, Point *pa, Plane *pln, CurvBSpl *bspl, Memspc *memSeg1, double tol)
 
int UT3D_pt_int2bspl (int *nxp, Point *xptab, Memspc *memSeg1, CurvBSpl *bspl1, CurvBSpl *bspl2)
 
int UT3D_pt_nearptbspl (Point *ptx, double *px, CurvBSpl *cv1, Point *pt)
 
int UT3D_pt_cbsp_lim (Point *p1, Point *p2, double *v1, double *v2, CurvBSpl *cv1)
 
int UT3D_pt_projptbspl (int *nxp, Point *ptab, double *ttab, CurvBSpl *bspl, Point *pt)
 
int UT3D_pt_evparCrvBSpl (Point *pt, CurvBSpl *bspl, double u)
 
double UT3D_par1_parbsp (double *kv, CurvBSpl *cv1)
 
double UT3D_parbsp_par1 (double pv, CurvBSpl *cv1)
 
int UT3D_pt_evalparCv (Point *pto, CurvBSpl *cv1, double uVal)
 
int UT3D_vc_evalparCv (Vector *vco, CurvBSpl *cv1, double uVal)
 
int UT3D_parCv_bsplpt (double *up, double *dist, CurvBSpl *bspl, Point *pt)
 
int UT3D_du_bsplTol (double *du, CurvBSpl *cvbs, double tol)
 
int UT3D_ptNr_bsp (int *iu, CurvBSpl *bsp, double tol1)
 
int bspl_bsp_ptn (CurvBSpl *cvo, Memspc *memSeg1, Point *pTab, int pNr, int deg)
 
int UT3D_knotvec_m (double **knTab, double *v0, double *v1, int ptNr, int deg, Memspc *workSeg)
 
int bspl_knotvec__ (double *knTab, int ptNr, int deg)
 
int bspl_pol2_bsp2 (Point *pTab1, Point *pTab2, int *ptNr, int ptMax, CurvBSpl *cv1, CurvBSpl *cv2, double tol)
 
int bspl_cv_bsp (int *ptNr, Point *pTab, CurvBSpl *cv1)
 
int bspl_pol_bsp (int *ptNr, Point *pTab, CurvBSpl *cv1, int ptMax, double tol)
 
int bspl_cvpol_cvbsp (int *ptNr, Point ptPol[], int ianz, int ideg, double ps, double pe, Point ptCrv[], double *vTab)
 
int bspl_pt_cbspDeg1 (Point *pto, int ptNr, Point *cpTab, double *kvTab, double uVal)
 
int bspl_eval_Pt (int segNr, int ideg, Point ContPt[], double *vk, double uVal, Point *P)
 
int bspl_eval_Tg (int segNr, int ideg, Point ContPt[], double *vk, double uVal, Vector *tg)
 
int UT3D_pt_projptbsp_ext (double *uo, Point *po, Point *p0, CurvBSpl *bspl)
 
int bspl_eval_expPt (Point *pto, CurvBSpl *cv1, double uv, double dist)
 
int bspl_segNr_par (int *segNr, double up, CurvBSpl *cv1)
 
int UT2D_pt_evpar_cbsp (Point2 *pto, CurvBSpl2 *cv, double u)
 
int UT2D_pt_tng_cbsp_vc (Point2 *ptg, Vector2 *vc1, CurvBSpl2 *cv1, int isol)
 
int UT2D_pt_tng_cbsp_pt (Point2 *ptg, int *isolMax, CurvBSpl2 *cv, Point2 *pt1, int isol)
 

Variables

double UT_TOL_0Cos
 tolerance for zero cosine More...
 
double APT_ModSiz
 

Detailed Description

B-Spline-Curve-Utilityfunctions.

=====================================================
List_functions_start:
UT3D_bsp_ck_closed__ check if B-SplCurv is closed (ignores trimmed)
UT3D_bsp_ck_closed_tr check if B-SplCurv is closed and untrimmed
UT3D_bsp_ck_pt check if B-SplineCurve is a point
UT3D_bsp_ck_minSiz check for minSiz / underSize
UT3D_bsp_ck_maxDeg returns max degree
UT3D_bsp_ck_planar check if spline is planar to given vector
UT3D_cbsp_ck_trim test is spline is trimmed
UT3D_ncvbsp_orient orient group of B-SplCurves (same directiorn)
UT3D_2ncvbsp_orient orient 2 groups of BSplCurves for surface
UT3D_4cvbsp_3cvbsp make 4 curves from 3 curves for a CoonsPatchSurf.
UT3D_parCv_bsplpt curve parameter <-- point on b-spline curve
UT3D_ptNr_bsplTol estimate nr of polygonPoints for B-spline
UT3D_du_bsplTol get du for polygonalization of bSpline from tol
UT3D_bsp_degrad degrade bsp to line
UT3D_bsp_infTg Eine Tabelle der Wendepunkte liefern (nur Parameter)
UT3D_cbsp_ox create BSP-Curv from ObjGX-obj
UT3D_cbsp_1pt create BSP-Curv from point
UT3D_cbsp_2pt create BSP-Curv from Line
UT3D_cbsp_ci create BSP-Curv from Circ
UT3D_cbsp_ell create BSP-Curv from Ellipse
UT3D_cbsp_clt create BSP-Curv from Clothoid
bspl_bsp_ptn make B-spline cvo from pointTable pTab
UT3D_cbsp_2cbsp join 2 BSP-Curves
UT3D_cbsp_trim trim a bspline-curve
UT3D_pt_cbsp_lim get limits (startpoint, endpoint, parameters)
UT3D_pt_projptbspl project point onto b-spline curve
UT3D_pt_int2bspl intersect 2 b-spline curves
UT3D_pt_intlnbspl intersect line with b-spline curve
UT3D_pt_intplbspl Intersect Plane / BSplineCurve
UT2D_pt_tng_cbsp_vc tangent vector-bSpline
UT2D_pt_tng_cbsp_pt tangent point-bSpline
UT3D_pt_tng_cbsp_vc__ get tangent vector-bSpline USE UT2D_pt_tng_cbsp_vc
UT3D_vc_tng_cbsp_pt__ get tangent point-bSplineCurve USE UT2D_pt_tng_cbsp_pt
UT2D_pt_evpar_cbsp point from knotValue
UT3D_pt_evparCrvBSpl point <-- evaluate curve parameter
ACHTUNG: kann Extrapolation noch nicht !
UT3D_pt_evalparCv Punkt an B-Spline aus Parameterwert
bspl_pt_cbspDeg1 evaluate Point on B-SplCurve with degree 1.
UT3D_vc_evalparCv Tangente an B-Spline aus Parameterwert
UT3D_par1_parbsp get parameter 0-1 from knotValue
UT3D_parbsp_par1 get knotValue from parameter 0-1
bspl_segNr_par get segmentNr from parameter
bspl_tmpSpc_siz get size of necessary tempSpace for UT3D_pt_projptbspl
UT3D_bsp_cpsbsp copy Bsp-Curve out of Bsp-Surf (nicht interpolierend)
UT3D_knotvec_m create & copy knotvektor
bspl_knotvec__ Erstellen des knotvektor
bspl_pol_bsp make Polygon from B-Spline-Kurve
bspl_cv_bsp make Polygon from B-Spline mit fixer ptNr
bspl_cvpol_cvbsp UNUSED Aus einem B-Spline eine Polygon bilden.
bspl_eval_Pt Zwischenpunkte einer B-Spline-Kurve errechnen
bspl_eval_Tg Evaluate a tangent on a B-spline.
UT3D_pt_projptbsp_ext lineare extrapolation
bspl_eval_expPt lineare extrapolation
List_functions_end:
=====================================================
- test functions:
UT3D_testbsplbez B-spline curve segments <--> Bezier curves
- see also:
../ut/ubscrv.c

Macro Definition Documentation

#define AUXTABSIZ   200

Function Documentation

int UT3D_4cvbsp_3cvbsp ( CurvBSpl **  cv1tab,
CurvBSpl **  cv2tab,
Memspc objSeg 
)
int UT3D_2ncvbsp_orient ( int  cv1Nr,
CurvBSpl **  cv1tab,
int  cv2Nr,
CurvBSpl **  cv2tab,
Memspc objSeg 
)
int UT3D_ncvbsp_orient ( int  cv1Nr,
CurvBSpl **  cv1tab,
Memspc objSeg 
)
int UT3D_cbsp_dbo ( CurvBSpl **  cbsp,
Memspc objSeg,
int  typ,
long  dbi,
Memspc tmpSeg 
)
* UT3D_cbsp_dbo create B_SplineCurve from Point/Line/Circ/Curve
* create B_SplineCurve from a single object.
*
int UT3D_cbsp_trim ( CurvBSpl cvo,
CurvBSpl cvi,
Memspc memDat,
Memspc memTmp 
)
* UT3D_cbsp_trim trim a bspline-curve
* IN: cvi, trimmed by the parameters v0,v1;
* OUT: the resulting knots go from v0 to v1;
* exceeding controlpoints are removed.
* Knotvektor & controlpoints are in memDat.
*
int UT3D_cbsp_2cbsp ( CurvBSpl cvo,
Memspc objSeg,
double  smf,
CurvBSpl cv1,
CurvBSpl cv2,
Memspc tmpSeg 
)
int UT3D_cbsp_ox ( CurvBSpl cbsp,
ObjGX ox1,
double  smf,
Memspc objSeg,
Memspc tmpSeg 
)
int UT3D_cbsp_1pt ( CurvBSpl bsp,
Memspc memSeg,
Point p1 
)
int UT3D_cbsp_2pt ( CurvBSpl bsp,
Memspc memSeg,
Point p1,
Point p2 
)
int UT3D_cbsp_ci ( CurvBSpl bsp,
Memspc memSeg,
Circ ci1,
Memspc tmpSeg 
)
int UT3D_cbsp_clt ( CurvBSpl bsp,
Memspc memSeg,
CurvClot cv1,
Memspc tmpSeg 
)
int UT3D_cbsp_ell ( CurvBSpl bsp,
Memspc memSeg,
CurvElli el1,
Memspc tmpSeg 
)
int UT3D_bsp_infTg ( int *  dNr,
double *  dTab,
CurvBSpl bsp1 
)
int UT3D_bsp_degrad ( ObjGX ox1,
CurvBSpl cv1,
Memspc memSeg1 
)
int UT3D_bsp_ck_pt ( CurvBSpl cv1)

UT3D_bsp_ck_pt check if B-SplineCurve is a point RetCod: 0=yes, cv1 is a point; -1=no.

int UT3D_bsp_ck_closed__ ( CurvBSpl cv1)
* UT3D_bsp_ck_closed__ check if B-SplCurv is closed (ignores trimmed)
* Retcod:
* rc = 1: NO, not closed
* rc = 0: YES, curve is closed
* rc = -2: degenerated (shorter UT_TOL_cv)
*
*
int UT3D_bsp_ck_closed_tr ( CurvBSpl cv1)
* UT3D_bsp_ck_closed_tr check if B-SplCurv is closed and untrimmed
* Retcod:
* rc = 1: NO, not closed
* rc = 0: YES, curve is closed AND endpoint == end_of_curve (untrimmed)
* rc = -1: NO, curve is closed BUT endpoint is trimmed
* rc = -2: degenerated
*
int UT3D_bsp_ck_planar ( CurvBSpl cv1,
Vector vz 
)

UT3D_bsp_ck_planar check if spline is planar to given vector Input: vc normalvector of plane RetCod = 0 OK, ist planar -1 no, 1-n points of pTab are not in plane pPln-vc

int UT3D_cbsp_ck_trim ( CurvBSpl cv1)
* UT3D_cbsp_ck_trim test is spline is trimmed
* RetCod
* 0 polygon is unlimited
* >0 polygon is limited; nr of points (not exactly)
*
* see also UT3D_cbsp_trim
*
int UT3D_bsp_ck_minSiz ( CurvBSpl cv1)
int UT3D_bsp_cpsbsp ( CurvBSpl cvo,
SurBSpl su1,
char  cDir,
int  cvNr,
Memspc memSeg1 
)
int UT3D_pt_intlnbspl ( int *  nxp,
Point xptab,
Memspc memSeg1,
Line ln,
CurvBSpl bspl 
)
int UT3D_pt_intplbspl ( int *  pNr,
Point pa,
Plane pln,
CurvBSpl bspl,
Memspc memSeg1,
double  tol 
)
int UT3D_pt_int2bspl ( int *  nxp,
Point xptab,
Memspc memSeg1,
CurvBSpl bspl1,
CurvBSpl bspl2 
)
int UT3D_pt_nearptbspl ( Point ptx,
double *  px,
CurvBSpl cv1,
Point pt 
)
int UT3D_pt_cbsp_lim ( Point p1,
Point p2,
double *  v1,
double *  v2,
CurvBSpl cv1 
)
* UT3D_pt_cbsp_lim get limits (startpoint, endpoint, parameters)
*
* Output:
* p1 startpoint (none if p1 == NULL)
* p2 endpoint (none if p2 == NULL)
* v1 parameter (0-1) for startpoint (v1=NULL: none)
* v2 parameter (0-1) for endpoint (v2=NULL: none)
*
*
* see also UTO_2pt_lim_ox UTO_2pt_lim_dbo UTO_pt_ox
*
int UT3D_pt_projptbspl ( int *  nxp,
Point ptab,
double *  ttab,
CurvBSpl bspl,
Point pt 
)
int UT3D_pt_evparCrvBSpl ( Point pt,
CurvBSpl bspl,
double  u 
)
double UT3D_par1_parbsp ( double *  kv,
CurvBSpl cv1 
)

UT3D_par1_parbsp get parameter 0-1 from knotValue

double UT3D_parbsp_par1 ( double  pv,
CurvBSpl cv1 
)

UT3D_parbsp_par1 get knotValue from parameter 0-1

int UT3D_pt_evalparCv ( Point pto,
CurvBSpl cv1,
double  uVal 
)
int UT3D_vc_evalparCv ( Vector vco,
CurvBSpl cv1,
double  uVal 
)
int UT3D_parCv_bsplpt ( double *  up,
double *  dist,
CurvBSpl bspl,
Point pt 
)
int UT3D_du_bsplTol ( double *  du,
CurvBSpl cvbs,
double  tol 
)
int UT3D_ptNr_bsp ( int *  iu,
CurvBSpl bsp,
double  tol1 
)
* UT3D_ptNr_rbsp estimate nr of polygonPoints for B-spline
* see also UT3D_ptNr_rbsp SUSbsp_ck_tol
*
int bspl_bsp_ptn ( CurvBSpl cvo,
Memspc memSeg1,
Point pTab,
int  pNr,
int  deg 
)
int UT3D_knotvec_m ( double **  knTab,
double *  v0,
double *  v1,
int  ptNr,
int  deg,
Memspc workSeg 
)
int bspl_knotvec__ ( double *  knTab,
int  ptNr,
int  deg 
)
int bspl_pol2_bsp2 ( Point pTab1,
Point pTab2,
int *  ptNr,
int  ptMax,
CurvBSpl cv1,
CurvBSpl cv2,
double  tol 
)
int bspl_cv_bsp ( int *  ptNr,
Point pTab,
CurvBSpl cv1 
)
int bspl_pol_bsp ( int *  ptNr,
Point pTab,
CurvBSpl cv1,
int  ptMax,
double  tol 
)
* bspl_pol_bsp make Polygon from B-Spline-Kurve
* Method: make point in half; test deviation; redo until deviation < tol.
* RetCode: 0 = OK
* -1 = overflow pTab (E001)
* does not respect dir; use UT3D_pta_bsp
* see also bspl_cv_bsp (fixed pointNr)
*
int bspl_cvpol_cvbsp ( int *  ptNr,
Point  ptPol[],
int  ianz,
int  ideg,
double  ps,
double  pe,
Point  ptCrv[],
double *  vTab 
)
int bspl_pt_cbspDeg1 ( Point pto,
int  ptNr,
Point cpTab,
double *  kvTab,
double  uVal 
)
int bspl_eval_Pt ( int  segNr,
int  ideg,
Point  ContPt[],
double *  vk,
double  uVal,
Point P 
)
int bspl_eval_Tg ( int  segNr,
int  ideg,
Point  ContPt[],
double *  vk,
double  uVal,
Vector tg 
)
int UT3D_pt_projptbsp_ext ( double *  uo,
Point po,
Point p0,
CurvBSpl bspl 
)
int bspl_eval_expPt ( Point pto,
CurvBSpl cv1,
double  uv,
double  dist 
)
int bspl_segNr_par ( int *  segNr,
double  up,
CurvBSpl cv1 
)
int UT2D_pt_evpar_cbsp ( Point2 pto,
CurvBSpl2 cv,
double  u 
)
int UT2D_pt_tng_cbsp_vc ( Point2 ptg,
Vector2 vc1,
CurvBSpl2 cv1,
int  isol 
)

get tangent vector-bSpline. Bspline must be planar to constr.Plane. isol 0=solution-1; 1=solution-2; 2013-04-20 Reiter RetCod: >0 OK, max nr of solutions -1 Error isol -2 internal error -3 EOM

int UT2D_pt_tng_cbsp_pt ( Point2 ptg,
int *  isolMax,
CurvBSpl2 cv,
Point2 pt1,
int  isol 
)
* get tangent point-bSpline.
* Bspline must be planar to constr.Plane.
* isol 0-n; 0=solution-1; 1=solution-2;
* 2013-04-20 Reiter
* 1 OK, point is on bSpline
* 0 OK, point is not on bSpline
* -1 Error isol; isolMax gives max nr of solutions
* -2 internal error
* -3 EOM
*

Variable Documentation

double UT_TOL_0Cos

tolerance for zero cosine

double APT_ModSiz