EgtGeomKernel 1.5a4 : Implementazione BoundingBox.

This commit is contained in:
Dario Sassi
2014-01-16 22:02:41 +00:00
parent 2e00faa02b
commit 7479cb4162
34 changed files with 982 additions and 233 deletions
+72 -160
View File
@@ -335,159 +335,84 @@ OutScl::NormalOrNone( const CrvPointDiffGeom& oDiffG)
//----------------------------------------------------------------------------
bool
OutScl::PutCurve( const IGeoObj* pCurve, int nFlag)
OutScl::PutCurve( const IGeoObj* pGeoObj, int nFlag)
{
if ( pCurve == nullptr)
bool bFound ;
PolyLine PL ;
const ICurve* pCurve ;
// recupero e controllo la curva
if ( ( pCurve = GetCurve( pGeoObj)) == nullptr)
return false ;
switch ( pCurve->GetType()) {
case CRV_LINE :
return PutCurveLine( *GetCurveLine( pCurve), nFlag) ;
case CRV_ARC :
return PutCurveArc( *GetCurveArc( pCurve), nFlag) ;
case CRV_BEZ :
return PutCurveBez( *GetCurveBezier( pCurve), nFlag) ;
case CRV_COMPO :
return PutCurveCompo( *GetCurveComposite( pCurve), nFlag) ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
OutScl::PutCurveLine( const ICurveLine& CrvLine, int nFlag)
{
bool bFound ;
double dU ;
PolyLine PL ;
CrvPointDiffGeom oDiffG ;
// scrittura della linea
Remark( "CurveLine") ;
Line2P( CrvLine.GetStart(), CrvLine.GetEnd()) ;
// se richieste tangenti e curvature
if ( ( nFlag & 1) != 0) {
// ciclo per disegnare le derivate
Remark( "LineTangents+Der2") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvLine.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
ArcCurvOrTgOrNone( oDiffG) ;
}
}
// se richieste normali
if ( ( nFlag & 2) != 0) {
// ciclo per disegnare le normali
Remark( "LineNormals") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvLine.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
NormalOrNone( oDiffG) ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
OutScl::PutCurveArc( const ICurveArc& CrvArc, int nFlag)
{
bool bFound ;
double dU ;
Point3d ptIni ;
Point3d ptFin ;
PolyLine PL ;
CrvPointDiffGeom oDiffG ;
// ciclo sui segmenti
Remark( "CurveArc") ;
CrvArc.ApproxWithLines( 0.1, 5, PL) ;
for ( bFound = PL.GetFirstLine( ptIni, ptFin) ; bFound ; bFound = PL.GetNextLine( ptIni, ptFin)) {
Line2P( ptIni, ptFin) ;
}
// se richieste tangenti e curvature
if ( ( nFlag & 1) != 0) {
// ciclo per disegnare le derivate
Remark( "ArcTangents+Der2") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvArc.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
ArcCurvOrTgOrNone( oDiffG) ;
}
}
// se richieste normali
if ( ( nFlag & 2) != 0) {
// ciclo per disegnare le normali
Remark( "ArcNormals") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvArc.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
NormalOrNone( oDiffG) ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
OutScl::PutCurveBez( const ICurveBezier& CrvBez, int nFlag)
{
bool bFound ;
double dU ;
Point3d ptIni ;
Point3d ptFin ;
PolyLine PL ;
CrvPointDiffGeom oDiffG ;
// se richiesto anche il poligono di controllo
if ( ( nFlag & 4) != 0)
PutPolygBez( CrvBez) ;
// ciclo per disegnare i segmenti
Remark( "BezierCurve") ;
CrvBez.ApproxWithLines( 0.1, 5, PL) ;
for ( bFound = PL.GetFirstLine( ptIni, ptFin) ; bFound ; bFound = PL.GetNextLine( ptIni, ptFin)) {
Remark( "Curve") ;
Point3d ptIni ;
Point3d ptFin ;
pCurve->ApproxWithLines( 0.1, 5, PL) ;
for ( bFound = PL.GetFirstLine( ptIni, ptFin) ; bFound ; bFound = PL.GetNextLine( ptIni, ptFin))
Line2P( ptIni, ptFin) ;
}
// se richieste tangenti e curvature
if ( ( nFlag & 1) != 0) {
// ciclo per disegnare le derivate e le curvature
Remark( "BezierTangents+Der2") ;
Remark( "Curve:Tangents+Der2") ;
double dU ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvBez.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
CrvPointDiffGeom oDiffG ;
pCurve->GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
ArcCurvOrTgOrNone( oDiffG) ;
// se punto con possibili discontinuità
if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) {
// ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore
CrvPointDiffGeom oDiffGs ;
pCurve->GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ;
// se ci sono delle discontinuità
if ( ThereIsDiscontinuity( oDiffG, oDiffGs))
// emetto curvatura o tangente o niente
ArcCurvOrTgOrNone( oDiffGs) ;
}
}
}
// se richieste normali
if ( ( nFlag & 2) != 0) {
// ciclo per disegnare le derivate e le curvature
Remark( "BezierNormals") ;
Remark( "Curve:Normals") ;
double dU ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvBez.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
CrvPointDiffGeom oDiffG ;
pCurve->GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
NormalOrNone( oDiffG) ;
// se punto con possibili discontinuità
if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) {
// ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore
CrvPointDiffGeom oDiffGs ;
pCurve->GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ;
// se ci sono delle discontinuità
if ( ThereIsDiscontinuity( oDiffG, oDiffGs))
// normale o niente
NormalOrNone( oDiffG) ;
}
}
}
// se curva di Bezier e richiesto anche il poligono di controllo
if ( pCurve->GetType() == CRV_BEZ && ( nFlag & 4) != 0)
PutPolygBez( *(GetCurveBezier( pCurve))) ;
// se richiesto il box
if ( ( nFlag & 8) != 0) {
BBox3d b3B ;
if ( pCurve->GetLocalBBox( b3B))
PutBBox( b3B) ;
}
return true ;
}
@@ -516,42 +441,29 @@ OutScl::PutPolygBez( const ICurveBezier& CrvBez)
//----------------------------------------------------------------------------
bool
OutScl::PutCurveCompo( const ICurveComposite& CrvCompo, int nFlag)
OutScl::PutBBox( const BBox3d& b3B)
{
bool bFound ;
double dU ;
Point3d ptIni ;
Point3d ptFin ;
PolyLine PL ;
CrvPointDiffGeom oDiffG ;
CrvPointDiffGeom oDiffGs ;
Point3d ptMin ;
Point3d ptMax ;
// ciclo per disegnare i segmenti
Remark( "CurveComposite") ;
CrvCompo.ApproxWithLines( 0.1, 5, PL) ;
for ( bFound = PL.GetFirstLine( ptIni, ptFin) ; bFound ; bFound = PL.GetNextLine( ptIni, ptFin)) {
Line2P( ptIni, ptFin) ;
}
// se richieste derivate e curvature
if ( ( nFlag & 1) != 0) {
// ciclo per disegnare le derivate e le curvature
Remark( "CompositeTangents+Der2") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
CrvCompo.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// emetto curvatura o tangente o niente
ArcCurvOrTgOrNone( oDiffG) ;
// se punto con possibili discontinuità
if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) {
// ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore
CrvCompo.GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ;
// se ci sono delle discontinuità
if ( ThereIsDiscontinuity( oDiffG, oDiffGs))
// emetto curvatura o tangente o niente
ArcCurvOrTgOrNone( oDiffGs) ;
}
}
if ( b3B.GetMinMax( ptMin, ptMax)) {
Remark( "BoundingBox") ;
// giro a Zmin
Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMin.z)) ;
Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMin.z)) ;
Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMin.z)) ;
Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMin.z)) ;
// giro a Zmax
Line2P( Point3d( ptMin.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ;
Line2P( Point3d( ptMax.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMax.y, ptMax.z)) ;
Line2P( Point3d( ptMax.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ;
Line2P( Point3d( ptMin.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ;
// giunzione tra i due giri
Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ;
Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ;
Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMax.z)) ;
Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ;
}
return true ;