EgtGeomKernel :
- generalizzazione della skinned con bezier.
This commit is contained in:
+34
-15
@@ -4646,13 +4646,31 @@ SurfBezier::CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez)
|
||||
int nDegV = 3 ;
|
||||
int nSpanV = int( vCrvBez.size()) - 1 ;
|
||||
|
||||
//nSpanU = 1 ;
|
||||
//nSpanV = 2 ;
|
||||
|
||||
PNTMATRIX vPntCrvs ;
|
||||
for ( int j = 0 ; j < nSpanU ; ++j ) {
|
||||
PNTVECTOR vPntCtrl0 ;
|
||||
PNTVECTOR vPntCtrl1 ;
|
||||
for ( int i = 0 ; i < int( vCrvBez.size()) ; ++i) {
|
||||
const ICurveComposite* pCC = GetCurveComposite(vCrvBez[i]) ;
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier(pCC->GetCurve( j)) ;
|
||||
if ( j == 0)
|
||||
vPntCtrl0.push_back( pCrvBez->GetControlPoint(0)) ;
|
||||
vPntCtrl1.push_back( pCrvBez->GetControlPoint(nDegU)) ;
|
||||
}
|
||||
if( j==0 )
|
||||
vPntCrvs.push_back( vPntCtrl0) ;
|
||||
vPntCrvs.push_back( vPntCtrl1) ;
|
||||
}
|
||||
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, false) ;
|
||||
// scorro le span
|
||||
for ( int s = 0 ; s < int( nSpanU) ; ++s) {
|
||||
// trovo la direzione media del parametro V
|
||||
Point3d ptMean = ORIG ;
|
||||
for ( int i = 1 ; i < int( vPntCrvs[0].size()) ; ++i )
|
||||
ptMean += vPntCrvs[s][i] ;
|
||||
ptMean /= int( vPntCrvs[0].size() - 1) ;
|
||||
Vector3d vtDirXGeneral = ptMean - vPntCrvs[s][0] ;
|
||||
// prendo le curve a gruppi di 3 per costruire la parabola per trovare la pendenza "intuitiva" della superficie in V
|
||||
for ( int g = 0 ; g < nSpanV - 1 ; ++g) {
|
||||
const ICurveComposite* pCC0 = GetCurveComposite( vCrvBez[g]) ;
|
||||
@@ -4674,10 +4692,6 @@ SurfBezier::CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez)
|
||||
SetControlPoint( n + (s * nDegU) + (nDegU * nSpanU + 1) * (g * 3 + 6), ptCtrl2) ;
|
||||
//// trovo i punti di controllo intermedi tra le curve usando la parabola che unisce queste tre curve////
|
||||
double dPar = double(n) / nDegU ;
|
||||
//Point3d ptP0 ; pCrv0->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptP0, nullptr, nullptr) ;
|
||||
//Point3d ptP1 ; pCrv1->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptP1, nullptr, nullptr) ;
|
||||
//Point3d ptP2 ; pCrv2->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptP2, nullptr, nullptr) ;
|
||||
|
||||
Point3d ptP0 = pCrv0->GetControlPoint( n) ;
|
||||
Point3d ptP1 = pCrv1->GetControlPoint( n) ;
|
||||
Point3d ptP2 = pCrv2->GetControlPoint( n) ;
|
||||
@@ -4692,19 +4706,24 @@ SurfBezier::CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez)
|
||||
ptP6 = ptP1 * 1/3 + ptP2 * 2/3 ;
|
||||
}
|
||||
else {
|
||||
// calcolo il piano della parabola e porto i
|
||||
// calcolo il piano della parabola e porto i punti in quel riferimento
|
||||
Plane3d plParab ; plParab.Set( ptP0, ptP1, ptP2) ;
|
||||
Point3d ptStartV, ptEndV ;
|
||||
Vector3d vDirX = ptP2 - ptP0 ;
|
||||
//Vector3d vDirX = ptP2 - ptP0 ;
|
||||
DistPointLine dpl( ptP1, ptP0, ptP2, true) ;
|
||||
Point3d ptPerp ; dpl.GetMinDistPoint( ptPerp) ;
|
||||
Vector3d vDirY = ptPerp - ptP1 ;
|
||||
Vector3d vtDirY = ptPerp - ptP1 ;
|
||||
Frame3d frParab ;
|
||||
//Vector3d vDirZ = plParab.GetVersN() ;
|
||||
Vector3d vDirZ = X_AX ;
|
||||
if ( ! frParab.Set( ptP0, vDirX, vDirY, vDirZ)) {
|
||||
vDirY = vDirZ ^ vDirX ;
|
||||
if ( ! frParab.Set( ptP0, vDirX, vDirY, vDirZ))
|
||||
Point3d ptStart, ptEnd ;
|
||||
pCrv1->GetStartPoint( ptStart) ;
|
||||
pCrv1->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtDirCrv1 = ptEnd - ptStart ;
|
||||
Vector3d vtParabNorm = plParab.GetVersN() ;
|
||||
Vector3d vtDirZ = vtDirCrv1 * vtParabNorm > 0 ? vtParabNorm : - vtParabNorm ;
|
||||
Vector3d vtDirX = vtDirXGeneral - (vtDirXGeneral * vtDirZ * vtDirZ) ;
|
||||
if ( ! frParab.Set( ptP0, vtDirX, vtDirY, vtDirZ)) {
|
||||
vtDirY = vtDirZ ^ vtDirX ;
|
||||
if ( ! frParab.Set( ptP0, vtDirX, vtDirY, vtDirZ))
|
||||
return false ;
|
||||
}
|
||||
// porto i punti nel piano di riferimento della parabola
|
||||
|
||||
Reference in New Issue
Block a user