EgtGeomKernel 1.8g1 :

- modifiche a Zmap
- aggiunto clamp a ratio di font
- migliorata ricerca nomi con *.
This commit is contained in:
Dario Sassi
2017-08-01 07:59:56 +00:00
parent e162483df8
commit 76d94d6194
11 changed files with 1840 additions and 1001 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
bool PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide, const Vector3d& vtN) override ; bool PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide, const Vector3d& vtN) override ;
bool PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN) override ; bool PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN) override ;
int GetCurveCount( void) const override int GetCurveCount( void) const override
{ return int( m_CrvSmplS.size()) ; } { return ( ( m_nStatus != OK) ? 0 : int( m_CrvSmplS.size())) ; }
const ICurve* GetCurve( int nCrv) const override ; const ICurve* GetCurve( int nCrv) const override ;
const ICurve* GetFirstCurve( void) const override ; const ICurve* GetFirstCurve( void) const override ;
const ICurve* GetNextCurve( void) const override ; const ICurve* GetNextCurve( void) const override ;
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -18,6 +18,7 @@
#include "NgeWriter.h" #include "NgeWriter.h"
#include "NgeReader.h" #include "NgeReader.h"
#include "FontManager.h" #include "FontManager.h"
#include "FontAux.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EGkUiUnits.h"
#include <new> #include <new>
@@ -120,7 +121,7 @@ ExtText::Set( const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
m_nWeight = nW ; m_nWeight = nW ;
m_bItalic = bItl ; m_bItalic = bItl ;
m_dHeight = dH ; m_dHeight = dH ;
m_dRatio = dRat ; m_dRatio = AdjustFontRatio( dRat) ;
m_dAddAdvance = dAddAdv ; m_dAddAdvance = dAddAdv ;
m_nInsPos = (( nInsPos >= ETXT_IPTL && nInsPos <= ETXT_IPBR) ? nInsPos : ETXT_IPBL) ; m_nInsPos = (( nInsPos >= ETXT_IPTL && nInsPos <= ETXT_IPBR) ? nInsPos : ETXT_IPBL) ;
+14
View File
@@ -15,6 +15,20 @@
#include "stdafx.h" #include "stdafx.h"
#include "FontAux.h" #include "FontAux.h"
#include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EgtNumUtils.h"
//----------------------------------------------------------------------------
double
AdjustFontRatio( double dRatio)
{
// se nullo viene posto a 1
if ( abs( dRatio) < EPS_SMALL)
return 1.0 ;
// altrimenti deve stare nei limiti
const double MIN_FONT_RATIO = 0.1 ;
const double MAX_FONT_RATIO = 10.0 ;
return Clamp( dRatio, MIN_FONT_RATIO, MAX_FONT_RATIO) ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
+1
View File
@@ -17,5 +17,6 @@
#include "/EgtDev/Include/EGtNumCollection.h" #include "/EgtDev/Include/EGtNumCollection.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
double AdjustFontRatio( double dRatio) ;
bool IsLineBreak( const UINTVECTOR& vCode, int nInd, int& nLen) ; bool IsLineBreak( const UINTVECTOR& vCode, int nInd, int& nLen) ;
Vector3d GetTextInsertPointMove( double dMaxW, double dAscent, double dMinH, int nInsPos) ; Vector3d GetTextInsertPointMove( double dMaxW, double dAscent, double dMinH, int nInsPos) ;
+17 -12
View File
@@ -659,6 +659,19 @@ GeomDB::GetPrev( int nId) const
return ( pGdbPrev->m_nId) ; return ( pGdbPrev->m_nId) ;
} }
//----------------------------------------------------------------------------
static bool
AnalyzeName( string& sToFind)
{
bool bRepl = ( ReplaceString( sToFind, "**", "\n") != 0) ;
bool bWild = ( sToFind.back() == '*') ;
if ( bWild)
sToFind.pop_back() ;
if ( bRepl)
ReplaceString( sToFind, "\n", "*") ;
return bWild ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int int
GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const
@@ -668,9 +681,7 @@ GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const
return GDB_ID_NULL ; return GDB_ID_NULL ;
// determinazione tipo di ricerca // determinazione tipo di ricerca
string sToFind = sName ; string sToFind = sName ;
bool bWild = ( sToFind.back() == '*') ; bool bWild = AnalyzeName( sToFind) ;
if ( bWild)
sToFind.pop_back() ;
// recupero il gruppo // recupero il gruppo
const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ;
if ( pGdbGroup == nullptr) if ( pGdbGroup == nullptr)
@@ -698,9 +709,7 @@ GeomDB::GetNextName( int nId, const string& sName) const
return GDB_ID_NULL ; return GDB_ID_NULL ;
// determinazione tipo di ricerca // determinazione tipo di ricerca
string sToFind = sName ; string sToFind = sName ;
bool bWild = ( sToFind.back() == '*') ; bool bWild = AnalyzeName( sToFind) ;
if ( bWild)
sToFind.pop_back() ;
// recupero l'oggetto // recupero l'oggetto
const GdbObj* pGdbObj = GetGdbObj( nId) ; const GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr) if ( pGdbObj == nullptr)
@@ -728,9 +737,7 @@ GeomDB::GetLastNameInGroup( int nGroupId, const string& sName) const
return GDB_ID_NULL ; return GDB_ID_NULL ;
// determinazione tipo di ricerca // determinazione tipo di ricerca
string sToFind = sName ; string sToFind = sName ;
bool bWild = ( sToFind.back() == '*') ; bool bWild = AnalyzeName( sToFind) ;
if ( bWild)
sToFind.pop_back() ;
// recupero il gruppo // recupero il gruppo
const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ;
if ( pGdbGroup == nullptr) if ( pGdbGroup == nullptr)
@@ -758,9 +765,7 @@ GeomDB::GetPrevName( int nId, const string& sName) const
return GDB_ID_NULL ; return GDB_ID_NULL ;
// determinazione tipo di ricerca // determinazione tipo di ricerca
string sToFind = sName ; string sToFind = sName ;
bool bWild = ( sToFind.back() == '*') ; bool bWild = AnalyzeName( sToFind) ;
if ( bWild)
sToFind.pop_back() ;
// recupero l'oggetto // recupero l'oggetto
const GdbObj* pGdbObj = GetGdbObj( nId) ; const GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr) if ( pGdbObj == nullptr)
+1058 -390
View File
File diff suppressed because it is too large Load Diff
+558 -375
View File
File diff suppressed because it is too large Load Diff
+36 -8
View File
@@ -179,6 +179,15 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
if ( nGrid == 0) { if ( nGrid == 0) {
/*INTVECTOR nXBlock ;
INTVECTOR nYBlock ;
nXBlock.emplace_back( min( nI / m_nDexNumPBlock, m_nFracLin[0] - 1)) ;
nYBlock.emplace_back( min( nJ / m_nDexNumPBlock, m_nFracLin[1] - 1)) ;
if ( nI % N_DEXBLOCK == 0 && nXBlock[0] > 0)
nXBlock.emplace_back( nXBlock[0] - 1) ;
if ( nJ % N_DEXBLOCK == 0 && nYBlock[0] > 0)
nYBlock.emplace_back( nYBlock[0] - 1) ;*/
int nXStop = 1 ; int nXStop = 1 ;
int nYStop = 1 ; int nYStop = 1 ;
@@ -216,6 +225,15 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
else if ( nGrid == 1) { else if ( nGrid == 1) {
/*INTVECTOR nYBlock ;
INTVECTOR nZBlock ;
nYBlock.emplace_back( min( nI / m_nDexNumPBlock, m_nFracLin[1] - 1)) ;
nZBlock.emplace_back( min( nJ / m_nDexNumPBlock, m_nFracLin[2] - 1)) ;
if ( nI % N_DEXBLOCK == 0 && nYBlock[0] > 0)
nYBlock.emplace_back( nYBlock[0] - 1) ;
if ( nJ % N_DEXBLOCK == 0 && nZBlock[0] > 0)
nZBlock.emplace_back( nZBlock[0] - 1) ;*/
int nYStop = 1 ; int nYStop = 1 ;
int nZStop = 1 ; int nZStop = 1 ;
@@ -253,6 +271,15 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
else if ( nGrid == 2) { else if ( nGrid == 2) {
/*INTVECTOR nXBlock ;
INTVECTOR nZBlock ;
nXBlock.emplace_back( min( nJ / m_nDexNumPBlock, m_nFracLin[0] - 1)) ;
nZBlock.emplace_back( min( nI / m_nDexNumPBlock, m_nFracLin[2] - 1)) ;
if ( nJ % N_DEXBLOCK == 0 && nXBlock[0] > 0)
nXBlock.emplace_back( nXBlock[0] - 1) ;
if ( nI % N_DEXBLOCK == 0 && nZBlock[0] > 0)
nZBlock.emplace_back( nZBlock[0] - 1) ;*/
int nXStop = 1 ; int nXStop = 1 ;
int nZStop = 1 ; int nZStop = 1 ;
@@ -4096,7 +4123,7 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) { for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) { for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ; Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ;
Point3d ptInt1, ptInt2 ; Point3d ptInt1, ptInt2 ;
@@ -4316,9 +4343,9 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
double dSqIndet = EPS_SMALL * EPS_SMALL ; double dSqIndet = EPS_SMALL * EPS_SMALL ;
// Variabili booleane per i tappi
Vector3d vtUmv = vtMove ; vtUmv.Normalize() ; Vector3d vtUmv = vtMove ; vtUmv.Normalize() ;
// Variabili booleane per i tappi
bool bConeT = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapT) ; bool bConeT = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapT) ;
bool bConeB = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ; bool bConeB = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ;
bool bElpsB = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ; bool bElpsB = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ;
@@ -4328,10 +4355,11 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
Vector3d vtNmin, vtNmax ; Vector3d vtNmin, vtNmax ;
if ( dRatio * dTan <= 1) { if ( dRatio * dTan <= 1) {
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) { for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) { for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
double dX = ( i + 0.5) * m_dStep ; double dX = ( i + 0.5) * m_dStep ;
double dY = ( j + 0.5) * m_dStep ; double dY = ( j + 0.5) * m_dStep ;
@@ -4407,7 +4435,7 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
// Intersezione con la prima faccia // Intersezione con la prima faccia
if ( abs( vtPoly * vtNs) > COS_ORTO_ANG_ZERO) { if ( abs( vtPoly * vtNs) > COS_ORTO_ANG_ZERO) {
if ( dLenY * ptPoly1.x >= dLenX * ptPoly1.y && if ( dLenY * ptPoly1.x >= dLenX * ptPoly1.y &&
dLenY * ( ptPoly1.x - dDeltaX) <= dLenX * ptPoly1.y && dLenY * ( ptPoly1.x - dDeltaX) <= dLenX * ( ptPoly1.y - dDeltaY) &&
dDeltaX * ptPoly1.y >= dDeltaY * ptPoly1.x && dDeltaX * ptPoly1.y >= dDeltaY * ptPoly1.x &&
dDeltaX * ( ptPoly1.y - dLenY) <= dDeltaY * ( ptPoly1.x - dLenX)) { dDeltaX * ( ptPoly1.y - dLenY) <= dDeltaY * ( ptPoly1.x - dLenX)) {
@@ -4415,11 +4443,11 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtN1 = - vtNs ; vtN1 = - vtNs ;
++ nIntNum ; ++ nIntNum ;
} }
} }
// Intersezione con la seconda faccia // Intersezione con la seconda faccia
if ( abs( vtPoly * vtNd) > COS_ORTO_ANG_ZERO) { if ( abs( vtPoly * vtNd) > COS_ORTO_ANG_ZERO) {
if ( dLenY * ptPoly2.x >= dLenX * ptPoly2.y && if ( dLenY * ptPoly2.x >= dLenX * ptPoly2.y &&
dLenY * ( ptPoly2.x - dDeltaX) <= dLenX * ptPoly2.y && dLenY * ( ptPoly2.x - dDeltaX) <= dLenX * ( ptPoly2.y - dDeltaY) &&
dDeltaX * ptPoly2.y >= dDeltaY * ptPoly2.x && dDeltaX * ptPoly2.y >= dDeltaY * ptPoly2.x &&
dDeltaX * ( ptPoly2.y - dLenY) <= dDeltaY * ( ptPoly2.x - dLenX)) { dDeltaX * ( ptPoly2.y - dLenY) <= dDeltaY * ( ptPoly2.x - dLenX)) {
@@ -4549,7 +4577,7 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ; vtNmin = vtN2 ;
vtNmax = vtN1 ; vtNmax = vtN1 ;
} }
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
} }
@@ -4605,7 +4633,7 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) { for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) { for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
double dX = ( i + 0.5) * m_dStep ; double dX = ( i + 0.5) * m_dStep ;
double dY = ( j + 0.5) * m_dStep ; double dY = ( j + 0.5) * m_dStep ;
+3 -3
View File
@@ -123,7 +123,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool AddDexelSideFace( int nPos, int nPosAdj, const Point3d& ptP, const Point3d& ptQ, bool AddDexelSideFace( int nPos, int nPosAdj, const Point3d& ptP, const Point3d& ptQ,
const Vector3d& vtZ, const Vector3d& vtNorm, TRIA3DLIST& lstTria) const ; const Vector3d& vtZ, const Vector3d& vtNorm, TRIA3DLIST& lstTria) const ;
bool MarchingCubes( int nBlock, TRIA3DLIST& lstTria) const ; bool MarchingCubes( int nBlock, TRIA3DLIST& lstTria) const ;
bool ExtMarchingCubes( int nBlock, TRIA3DLIST& lstTria, TriHolder& triHold) const ; bool ExtMarchingCubes( int nBlock, TRIA3DLIST& lstTria, TriHolder& triHold) const ;
bool FlipEdgesII( TriHolder& TriHold) const ; bool FlipEdgesII( TriHolder& TriHold) const ;
bool FlipEdgesBB( TriaMatrix& InterTria) const ; bool FlipEdgesBB( TriaMatrix& InterTria) const ;
bool IsThereMat( int nI, int nJ, int nK) const ; bool IsThereMat( int nI, int nJ, int nK) const ;
@@ -131,8 +131,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool IntersPos( int nVec1[], int nVec2[], Point3d & ptInt) const ; bool IntersPos( int nVec1[], int nVec2[], Point3d & ptInt) const ;
bool IntersPos( int nVec1[], int nVec2[], bool bFirstCorner, Point3d& ptInt, Vector3d& vtNormal) const ; bool IntersPos( int nVec1[], int nVec2[], bool bFirstCorner, Point3d& ptInt, Vector3d& vtNormal) const ;
bool IsPointInsideVoxel( int nI, int nJ, int nK, const Point3d& ptP) const ; bool IsPointInsideVoxel( int nI, int nJ, int nK, const Point3d& ptP) const ;
bool IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP) const ; bool IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP, double dPrec = EPS_SMALL) const ;
bool GetPointVoxel( Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) const ; bool GetPointVoxel( const Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) const ;
// OPERAZIONI SU INTERVALLI // OPERAZIONI SU INTERVALLI
bool SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ, bool SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ,
+150 -211
View File
@@ -19,6 +19,7 @@
#include "GeoConst.h" #include "GeoConst.h"
#include "/EgtDev/Include/EGKLinePntTgCurve.h" #include "/EgtDev/Include/EGKLinePntTgCurve.h"
#include "/EgtDev/Include/EGKFilletChamfer.h" #include "/EgtDev/Include/EGKFilletChamfer.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
using namespace std ; using namespace std ;
@@ -98,257 +99,195 @@ bool
VolZmap::SetAdvTool( const string& sToolName, double dH, double dR, VolZmap::SetAdvTool( const string& sToolName, double dH, double dR,
double dTipH, double dTipR, double dCornR) double dTipH, double dTipR, double dCornR)
{ {
// reset nome // Reset nome
m_sToolName.clear() ; m_sToolName.clear() ;
// verifica dimensioni globali
// Verifica dimensioni globali
if ( dH < EPS_SMALL || dR < EPS_SMALL) if ( dH < EPS_SMALL || dR < EPS_SMALL)
return false ; return false ;
// se altezza punta nulla, ricado nel caso standard
if ( dTipH < EPS_SMALL || abs( dTipR - dR) < EPS_SMALL) // Se altezza punta nulla, ricado nel caso standard
if ( dTipH < EPS_SMALL || abs( dTipR - dR) < EPS_SMALL)
return SetStdTool( sToolName, dH, dR, dCornR) ; return SetStdTool( sToolName, dH, dR, dCornR) ;
// caso avanzato
else {
m_dHeight = dH ;
m_dRadius = dR ;
m_dTipHeight = dTipH ;
m_dTipRadius = max( dTipR, 0.) ;
if ( dCornR < EPS_SMALL) { // Caso avanzato
m_dHeight = dH ;
m_dRadius = dR ;
m_dTipHeight = dTipH ;
m_dTipRadius = max( dTipR, 0.) ;
m_nToolType = ConusMill ; // Se raggio corner nullo, allora utensile conico
m_dRCorner = 0 ; if ( dCornR < EPS_SMALL) {
} m_nToolType = ConusMill ;
// Se il raggio corner è non nullo m_dRCorner = 0 ;
// l'utensile viene descritto da // assegno nome e identificativo
// come utensile generico. m_sToolName = sToolName ;
else { m_nCurrentToolNum = 0 ;
return true ;
m_dRCorner = dCornR ;
m_nToolType = GenericTool ;
// come profilo
m_nToolType = GenericTool ;
Point3d pt0( 0, 0, 0) ;
Point3d pt1( m_dRadius, 0, 0) ;
Point3d pt2( m_dRadius, - m_dHeight + m_dTipHeight, 0) ;
if ( m_dTipRadius < m_dRadius) {
Point3d ptInt( dTipR, - dH, 0) ;
Point3d ptLast( 0, - dH, 0) ;
CurveLine cLine1 ; cLine1.Set( pt2, ptInt) ;
CurveLine cLine2 ; cLine2.Set( ptInt, ptLast) ;
double dTrim1, dTrim2 ;
Point3d ptIn1 = ptInt + Y_AX * dCornR ;
Point3d ptIn2 = ptInt - X_AX * dCornR ;
ICurveArc* pArc = CreateFillet( cLine1, ptIn1, cLine2, ptIn2, Z_AX, dCornR, dTrim1, dTrim2) ;
cLine1.TrimEndAtParam( abs( dTrim1)) ;
cLine2.TrimStartAtParam( abs( dTrim2)) ;
Point3d pt3, pt4 ;
cLine1.GetEndPoint( pt3) ;
cLine2.GetStartPoint( pt4) ;
Point3d ptC = pArc -> GetCenter() ;
CurveArc cvArc ; cvArc.SetC2P( ptC, pt3, pt4) ;
m_ToolOutline.Clear() ;
CurveLine LineSt ; LineSt.Set( pt0, pt1) ;
m_ToolOutline.AddCurve( LineSt) ;
m_ToolOutline.AddLine( pt2);
m_ToolOutline.AddLine( pt3);
m_ToolOutline.AddCurve( cvArc) ;
m_ToolOutline.AddLine( ptLast) ;
}
else {
if ( dTipR - dCornR < 0)
return false ;
Point3d ptC( dTipR - dCornR, - dH + dCornR, 0) ;
CurveArc cvCirc ; cvCirc.SetXY( ptC, dCornR) ;
Point3d ptNear( ptC.x + dCornR, ptC.y + dCornR, 0) ;
ICurveLine* pLine = GetLinePointTgCurve( pt2, cvCirc, ptNear) ;
Point3d pt3 ;
pLine -> GetEndPoint( pt3) ;
Point3d pt4( ptC.x, - dH, 0) ;
CurveArc cvArc ; cvArc.SetC2P( ptC, pt3, pt4) ;
Point3d pt5( 0, - dH, 0) ;
m_ToolOutline.Clear() ;
CurveLine Line ; Line.Set( pt0, pt1) ;
m_ToolOutline.AddCurve( Line) ;
m_ToolOutline.AddLine( pt2);
m_ToolOutline.AddLine( pt3);
m_ToolOutline.AddCurve( cvArc) ;
m_ToolOutline.AddLine( pt5) ;
}
return SetGenTool( sToolName, &m_ToolOutline) ;
}
} }
// assegno il nome
m_sToolName = sToolName ; // Altrimenti utensile generico.
// Aggiorno il numero dell'utensile corrente m_nToolType = GenericTool ;
m_nCurrentToolNum = 0 ; m_dRCorner = dCornR ;
return true ; m_ToolOutline.Clear() ;
// Definisco il profilo
Point3d pt0( 0, 0, 0) ;
Point3d pt1( m_dRadius, 0, 0) ;
Point3d pt2( m_dRadius, - m_dHeight + m_dTipHeight, 0) ;
if ( m_dTipRadius < m_dRadius) {
CurveLine LineSt ;
LineSt.Set( pt0, pt1) ;
Point3d ptInt( dTipR, - dH, 0) ;
Point3d ptLast( 0, - dH, 0) ;
CurveLine cLine1 ;
cLine1.Set( pt2, ptInt) ;
CurveLine cLine2 ;
cLine2.Set( ptInt, ptLast) ;
Point3d ptIn1 = ptInt + Y_AX * dCornR ;
Point3d ptIn2 = ptInt - X_AX * dCornR ;
double dTrim1, dTrim2 ;
PtrOwner< ICurveArc> pArc( CreateFillet( cLine1, ptIn1, cLine2, ptIn2, Z_AX, dCornR, dTrim1, dTrim2)) ;
if ( IsNull( pArc))
return false ;
cLine1.TrimEndAtParam( abs( dTrim1)) ;
cLine2.TrimStartAtParam( abs( dTrim2)) ;
Point3d pt3, pt4 ;
cLine1.GetEndPoint( pt3) ;
cLine2.GetStartPoint( pt4) ;
Point3d ptC = pArc->GetCenter() ;
CurveArc cvArc ;
cvArc.SetC2P( ptC, pt3, pt4) ;
m_ToolOutline.AddCurve( LineSt) ;
m_ToolOutline.AddLine( pt2);
m_ToolOutline.AddLine( pt3);
m_ToolOutline.AddCurve( cvArc) ;
m_ToolOutline.AddLine( ptLast) ;
}
else {
if ( m_dTipRadius < m_dRCorner)
return false ;
CurveLine LineSt ;
LineSt.Set( pt0, pt1) ;
Point3d ptC( dTipR - dCornR, - dH + dCornR, 0) ;
CurveArc cvCirc ;
cvCirc.SetXY( ptC, dCornR) ;
Point3d ptNear( ptC.x + dCornR, ptC.y + dCornR, 0) ;
PtrOwner<ICurveLine> pLine( GetLinePointTgCurve( pt2, cvCirc, ptNear)) ;
if ( IsNull( pLine))
return false ;
Point3d pt3 ;
pLine->GetEndPoint( pt3) ;
Point3d pt4( ptC.x, - dH, 0) ;
CurveArc cvArc ;
cvArc.SetC2P( ptC, pt3, pt4) ;
Point3d pt5( 0, - dH, 0) ;
m_ToolOutline.AddCurve( LineSt) ;
m_ToolOutline.AddLine( pt2);
m_ToolOutline.AddLine( pt3);
m_ToolOutline.AddCurve( cvArc) ;
m_ToolOutline.AddLine( pt5) ;
}
return SetGenTool( sToolName, &m_ToolOutline) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
VolZmap::SetGenTool( const string& sToolName, const ICurveComposite* pToolOutline) VolZmap::SetGenTool( const string& sToolName, const ICurveComposite* pToolOutline)
{ {
// Aggiorno il nome dell'utensile // Assegno nome, tipo e id dell'utensile
m_sToolName = sToolName ; m_sToolName = sToolName ;
// Aggiorno il tipo di utensile
m_nToolType = GenericTool ; m_nToolType = GenericTool ;
// Aggiorno il numero dell'utensile corrente
m_nCurrentToolNum = 0 ; m_nCurrentToolNum = 0 ;
// Copio il profilo // Copio il profilo e garantisco sia di soli archi e rette (converto eventuali curve di Bezier)
m_ToolOutline.CopyFrom( pToolOutline) ; if ( ! m_ToolOutline.CopyFrom( pToolOutline) ||
! m_ToolOutline.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, m_dAngTolDeg))
return false ;
// Se ci fosse una Bézier la convertiamo in archi e rette // Flag di avvenuta approssimazione
m_ToolOutline.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, m_dAngTolDeg) ; bool bApprox = false ;
// Puntatore a curva costante
const ICurve* pCurve = m_ToolOutline.GetFirstCurve() ;
// Ciclo sulle curve componenti // Ciclo sulle curve componenti
const ICurve* pCurve = m_ToolOutline.GetFirstCurve() ;
while ( pCurve != nullptr) { while ( pCurve != nullptr) {
// Se la curva è un arco valuto se approssimarlo // Se la curva è un arco verifico se approssimarlo
if ( pCurve->GetType() == CRV_ARC) { if ( pCurve->GetType() == CRV_ARC) {
// Centro e punti iniziale e finale dell'arco // Centro e raggio dell'arco
Point3d ptStart, ptEnd, ptO ; Point3d ptO = GetBasicCurveArc( pCurve)->GetCenter() ;
pCurve->GetStartPoint( ptStart) ;
pCurve->GetEndPoint( ptEnd) ;
pCurve->GetCenterPoint( ptO) ;
// Vettore congiungente il centro con i punti iniziale e finale
Vector3d vtStRad = ptStart - ptO ;
Vector3d vtEnRad = ptEnd - ptO ;
// Calcolo del raggio dell'arco
double dRadius = GetBasicCurveArc( pCurve)->GetRadius() ; double dRadius = GetBasicCurveArc( pCurve)->GetRadius() ;
// Recupero la curva precedente e quella successiva // Se il centro è fuori dall'asse devo approssimare
const ICurve* pPrev = m_ToolOutline.GetPrevCurve() ; bool bCurrApprox = ( abs( ptO.x) > EPS_SMALL) ;
const ICurve* pNext = m_ToolOutline.GetNextCurve() ;
pNext = m_ToolOutline.GetNextCurve() ;
// Valuto la necessità di approssimare l'arco o meno // Se una delle altre curve dista dal centro meno del raggio, devo approssimare
for ( int nI = 0 ; ! bCurrApprox && nI < m_ToolOutline.GetCurveCount() ; ++ nI) {
// Punto Iniziale della curva precedente e finale della successiva const ICurve* pOtherCrv = m_ToolOutline.GetCurve( nI) ;
Point3d ptStartPrev, ptEndNext ; if ( pOtherCrv != pCurve) {
DistPointCurve CalcDist( ptO, *pOtherCrv) ;
// Vettori tangenti alle curve precedente corrente e successiva double dCurrDist ;
// rispettivamente nei punti finale, iniziale e finale e iniziale if ( CalcDist.GetDist( dCurrDist) && dCurrDist < dRadius - EPS_SMALL)
// e prodotti vettore fra i suddetti bCurrApprox = true ;
Vector3d vtPrevEndDir, vtCurrentStartDir, vtCurrentEndDir, vtNextStartDir ; }
Vector3d vtIProd, vtFProd ;
Point3d ptTopCurrent = ptO + Y_AX * dRadius ;
Point3d ptBottomCurrent = ptO - Y_AX * dRadius ;
// Valuto le relazioni geometriche fra la
// curva corrente e quella precedente.
pPrev->GetStartPoint( ptStartPrev) ;
pPrev->GetEndDir( vtPrevEndDir) ;
pCurve->GetStartDir( vtCurrentStartDir) ;
vtIProd = vtPrevEndDir ^ vtCurrentStartDir ;
// Se la curva successiva esiste valuto le
// medesime relazioni con la quest'ultima
if ( pNext != nullptr) {
pNext->GetEndPoint( ptEndNext) ;
pCurve->GetEndDir( vtCurrentEndDir) ;
pNext->GetStartDir( vtNextStartDir) ;
vtFProd = vtCurrentEndDir ^ vtNextStartDir ;
} }
// Se devo approssimare // Se devo approssimare
if ( ! ( ( abs( ptO.x) < EPS_SMALL && vtIProd.z > 0 && ptStartPrev.y > ptTopCurrent.y) && if ( bCurrApprox) {
( ( pNext == nullptr && abs( ptEnd.x) < EPS_SMALL) ||
( pNext != nullptr && vtFProd.z > 0 && ptBottomCurrent.y > ptEndNext.y)))) {
// Copio la parte precedente
const ICurve* pAux = m_ToolOutline.GetFirstCurve() ;
while ( pAux != pCurve) {
m_ToolArcLineApprox.AddCurve( * pAux, true) ;
pAux = m_ToolOutline.GetNextCurve() ;
}
// Creo la polyline approssimante // Creo la polyline approssimante
PolyLine Polygonal ; PolyLine plyApprox ;
pCurve->ApproxWithLines( m_dLinTol, m_dAngTolDeg, ICurve::APL_SPECIAL, plyApprox) ;
pCurve->ApproxWithLines( m_dLinTol, m_dAngTolDeg, 10, Polygonal) ; // Aggiungo i segmenti di retta alla approssimazione
Point3d ptEnd ;
// Definisco una curva composita a partire dalla polyline plyApprox.GetFirstPoint( ptEnd) ;
CurveComposite cvTemp ; cvTemp.FromPolyLine( Polygonal) ; while ( plyApprox.GetNextPoint( ptEnd)) {
m_ToolArcLineApprox.AddLine( ptEnd) ;
// Aggiungo la parte approssimata
pAux = cvTemp.GetFirstCurve() ;
while ( pAux != nullptr) {
m_ToolArcLineApprox.AddCurve( * pAux, true) ;
pAux = cvTemp.GetNextCurve() ;
} }
bApprox = true ;
} }
// Se non deve essere approssimato // altrimenti lo aggiungo semplicemente
else { else
// Se è già stato definito m_ToolArcLineApprox deve m_ToolArcLineApprox.AddCurve( *pCurve, true) ;
// essere completo, aggiungo quindi l'arco corrente
if ( m_ToolArcLineApprox.GetCurveCount() != 0)
m_ToolArcLineApprox.AddCurve( * pCurve, true) ;
}
} }
// Se è segmento // altrimenti è segmento e lo aggiungo semplicemente
else { else
// Se è già stato definito m_ToolArcLineApprox deve m_ToolArcLineApprox.AddCurve( *pCurve, true) ;
// essere completo, aggiungo quindi il segmento corrente
if ( m_ToolArcLineApprox.GetCurveCount() != 0)
m_ToolArcLineApprox.AddCurve( * pCurve, true) ;
}
pCurve = m_ToolOutline.GetNextCurve() ; pCurve = m_ToolOutline.GetNextCurve() ;
} }
// Se non ci sono state approssimazioni, cancello la curva approssimante
if ( ! bApprox)
m_ToolArcLineApprox.Clear() ;
// Dimensioni dell'utensile // Dimensioni dell'utensile
BBox3d Bounding ; BBox3d Bounding ;
m_ToolOutline.GetLocalBBox( Bounding) ; m_ToolOutline.GetLocalBBox( Bounding) ;
double m_dHeight = Bounding.GetMax().y - Bounding.GetMin().y ; double m_dHeight = Bounding.GetMax().y - Bounding.GetMin().y ;
double m_dRadius = Bounding.GetMax().x - Bounding.GetMin().x ; double m_dRadius = Bounding.GetMax().x - Bounding.GetMin().x ;
return true ; return true ;
} }