EgtGeomKernel :
- aggiunta la funzione per creare una sfera come superficie bezier - aggiunta la funzione per tagliare una superificie bezier con un piano.
This commit is contained in:
+7
-39
@@ -17,46 +17,11 @@
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfBez.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Extern/Eigen/Dense"
|
||||
#include "DistPointLine.h"
|
||||
#include "CurveLine.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// raffino i punti di intersezione e recupero le rispettive coordinate nello spazio parametrico
|
||||
bool
|
||||
FindParametricCoord( const ISurfTriMesh* pSurfTm ,int nIL, int nT, const Point3d& ptI, Point3d& ptSP) {
|
||||
// recupero i dati dei vertici del triangolo che fa intersezione
|
||||
int nVert[3] ;
|
||||
pSurfTm->GetTriangle( nT, nVert) ;
|
||||
double dU0, dV0, dU1, dV1,dU2, dV2 ;
|
||||
pSurfTm->GetVertexParam( nVert[0], dU0, dV0) ;
|
||||
pSurfTm->GetVertexParam( nVert[1], dU1, dV1) ;
|
||||
pSurfTm->GetVertexParam( nVert[2], dU2, dV2) ;
|
||||
Point3d pt0, pt1, pt2 ;
|
||||
pSurfTm->GetVertex( nVert[0], pt0) ;
|
||||
pSurfTm->GetVertex( nVert[1], pt1) ;
|
||||
pSurfTm->GetVertex( nVert[2], pt2) ;
|
||||
// calcolo approssimativamente le coordinate nello spazio parametrico del punto di intersezione
|
||||
// quindi prima calcolo la composizione lineare tra i vertici del triangolo per ottenere il punto di intersezione
|
||||
Eigen::Matrix3d mA ;
|
||||
mA.col(0) << pt0.x, pt0.y , pt0.z ;
|
||||
mA.col(1) << pt1.x, pt1.y , pt1.z ;
|
||||
mA.col(2) << pt2.x, pt2.y , pt2.z ;
|
||||
Eigen::Vector3d b ( ptI.x, ptI.y, ptI.z) ;
|
||||
Eigen::Vector3d x = mA.fullPivLu().solve(b) ;
|
||||
// applico questa composizione alle loro coordinate parametriche
|
||||
Eigen::Matrix3d mB ;
|
||||
mB.col(0) << dU0, dV0, 0 ;
|
||||
mB.col(1) << dU1, dV1, 0 ;
|
||||
mB.col(2) << dU2, dV2, 0 ;
|
||||
Eigen::Vector3d ptParam = mB * x ;
|
||||
ptSP.x = ptParam.x() ;
|
||||
ptSP.y = ptParam.y() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------
|
||||
bool
|
||||
RefineIntersNewton( const Point3d& ptL, const Vector3d& vtL, double dLen, bool bFinite,
|
||||
@@ -162,7 +127,10 @@ IntersLineSurfBz( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
|
||||
ILSBIVECTOR& vInfo, bool bFinite)
|
||||
{
|
||||
PtrOwner<ICurveLine> pCL( CreateCurveLine()) ;
|
||||
pCL->SetPVL(ptL, vtL, dLen) ;
|
||||
if ( bFinite)
|
||||
pCL->SetPVL(ptL, vtL, dLen) ;
|
||||
else
|
||||
pCL->SetPVL(ptL, vtL, 1e6) ;
|
||||
// verifico linea
|
||||
Vector3d vtDir = vtL ;
|
||||
if ( ! vtDir.Normalize( EPS_ZERO))
|
||||
@@ -186,7 +154,7 @@ IntersLineSurfBz( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
|
||||
Point3d ptI, ptI2 ;
|
||||
// devo trovare le intersezioni
|
||||
Point3d ptSP, ptSP2 ; // coordinate parametriche delle soluzioni
|
||||
FindParametricCoord( pSurfTm, InfoTm.nILTT, InfoTm.nT, InfoTm.ptI, ptSP) ;
|
||||
pSurfBz->UnprojectPointFromStm( InfoTm.nT, InfoTm.ptI, ptSP, InfoTm.nILTT) ;
|
||||
Point3d ptIBz, ptIBz2 ;
|
||||
if ( ! RefineIntersNewton( ptL, vtL, dLen, bFinite, pSurfBz, ptSP, ptIBz)) {
|
||||
/////// posso provare anche a rilanciare newton con un punto di partenza diverso oppure con una direzione di avvicinamento diversa///////////////////////////////////
|
||||
@@ -205,8 +173,8 @@ IntersLineSurfBz( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
|
||||
double dCos2 = 0 ;
|
||||
// eventualmente ripeto tutto per ptI2 ( se ho un'intersezione con sovrapposizione)
|
||||
if ( InfoTm.nILTT == ILTT_SEGM || InfoTm.nILTT == ILTT_SEGM_ON_EDGE ) {
|
||||
FindParametricCoord( pSurfTm, InfoTm.nILTT, InfoTm.nT, InfoTm.ptI2, ptSP2) ;
|
||||
if ( !RefineIntersNewton(ptL, vtL, dLen, bFinite, pSurfBz, ptSP2, ptIBz2) ) {
|
||||
pSurfBz->UnprojectPointFromStm( InfoTm.nT, InfoTm.ptI2, ptSP2, InfoTm.nILTT) ;
|
||||
if ( ! RefineIntersNewton(ptL, vtL, dLen, bFinite, pSurfBz, ptSP2, ptIBz2) ) {
|
||||
int nVert[3] ;
|
||||
pSurfTm->GetTriangle( InfoTm.nT, nVert) ;
|
||||
double dU0, dV0 ;
|
||||
|
||||
Reference in New Issue
Block a user