EgtGeomKernel 1.8g1 :
- modifiche a Zmap - aggiunto clamp a ratio di font - migliorata ricerca nomi con *.
This commit is contained in:
+1
-1
@@ -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 PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN) 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* GetFirstCurve( void) const override ;
|
||||
const ICurve* GetNextCurve( void) const override ;
|
||||
|
||||
Binary file not shown.
+2
-1
@@ -18,6 +18,7 @@
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "FontManager.h"
|
||||
#include "FontAux.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include <new>
|
||||
@@ -120,7 +121,7 @@ ExtText::Set( const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
|
||||
m_nWeight = nW ;
|
||||
m_bItalic = bItl ;
|
||||
m_dHeight = dH ;
|
||||
m_dRatio = dRat ;
|
||||
m_dRatio = AdjustFontRatio( dRat) ;
|
||||
m_dAddAdvance = dAddAdv ;
|
||||
m_nInsPos = (( nInsPos >= ETXT_IPTL && nInsPos <= ETXT_IPBR) ? nInsPos : ETXT_IPBL) ;
|
||||
|
||||
|
||||
+14
@@ -15,6 +15,20 @@
|
||||
#include "stdafx.h"
|
||||
#include "FontAux.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
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
#include "/EgtDev/Include/EGtNumCollection.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double AdjustFontRatio( double dRatio) ;
|
||||
bool IsLineBreak( const UINTVECTOR& vCode, int nInd, int& nLen) ;
|
||||
Vector3d GetTextInsertPointMove( double dMaxW, double dAscent, double dMinH, int nInsPos) ;
|
||||
|
||||
+17
-12
@@ -659,6 +659,19 @@ GeomDB::GetPrev( int nId) const
|
||||
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
|
||||
GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const
|
||||
@@ -668,9 +681,7 @@ GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const
|
||||
return GDB_ID_NULL ;
|
||||
// determinazione tipo di ricerca
|
||||
string sToFind = sName ;
|
||||
bool bWild = ( sToFind.back() == '*') ;
|
||||
if ( bWild)
|
||||
sToFind.pop_back() ;
|
||||
bool bWild = AnalyzeName( sToFind) ;
|
||||
// recupero il gruppo
|
||||
const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ;
|
||||
if ( pGdbGroup == nullptr)
|
||||
@@ -698,9 +709,7 @@ GeomDB::GetNextName( int nId, const string& sName) const
|
||||
return GDB_ID_NULL ;
|
||||
// determinazione tipo di ricerca
|
||||
string sToFind = sName ;
|
||||
bool bWild = ( sToFind.back() == '*') ;
|
||||
if ( bWild)
|
||||
sToFind.pop_back() ;
|
||||
bool bWild = AnalyzeName( sToFind) ;
|
||||
// recupero l'oggetto
|
||||
const GdbObj* pGdbObj = GetGdbObj( nId) ;
|
||||
if ( pGdbObj == nullptr)
|
||||
@@ -728,9 +737,7 @@ GeomDB::GetLastNameInGroup( int nGroupId, const string& sName) const
|
||||
return GDB_ID_NULL ;
|
||||
// determinazione tipo di ricerca
|
||||
string sToFind = sName ;
|
||||
bool bWild = ( sToFind.back() == '*') ;
|
||||
if ( bWild)
|
||||
sToFind.pop_back() ;
|
||||
bool bWild = AnalyzeName( sToFind) ;
|
||||
// recupero il gruppo
|
||||
const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ;
|
||||
if ( pGdbGroup == nullptr)
|
||||
@@ -758,9 +765,7 @@ GeomDB::GetPrevName( int nId, const string& sName) const
|
||||
return GDB_ID_NULL ;
|
||||
// determinazione tipo di ricerca
|
||||
string sToFind = sName ;
|
||||
bool bWild = ( sToFind.back() == '*') ;
|
||||
if ( bWild)
|
||||
sToFind.pop_back() ;
|
||||
bool bWild = AnalyzeName( sToFind) ;
|
||||
// recupero l'oggetto
|
||||
const GdbObj* pGdbObj = GetGdbObj( nId) ;
|
||||
if ( pGdbObj == nullptr)
|
||||
|
||||
+1058
-390
File diff suppressed because it is too large
Load Diff
+558
-375
File diff suppressed because it is too large
Load Diff
+36
-8
@@ -179,6 +179,15 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
|
||||
|
||||
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 nYStop = 1 ;
|
||||
|
||||
@@ -216,6 +225,15 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
|
||||
|
||||
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 nZStop = 1 ;
|
||||
|
||||
@@ -253,6 +271,15 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
|
||||
|
||||
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 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 j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
|
||||
|
||||
Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ;
|
||||
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
@@ -4316,9 +4343,9 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
|
||||
|
||||
double dSqIndet = EPS_SMALL * EPS_SMALL ;
|
||||
|
||||
// Variabili booleane per i tappi
|
||||
Vector3d vtUmv = vtMove ; vtUmv.Normalize() ;
|
||||
|
||||
// Variabili booleane per i tappi
|
||||
bool bConeT = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapT) ;
|
||||
bool bConeB = ( 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 ;
|
||||
|
||||
if ( dRatio * dTan <= 1) {
|
||||
|
||||
|
||||
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
|
||||
|
||||
double dX = ( i + 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
|
||||
if ( abs( vtPoly * vtNs) > COS_ORTO_ANG_ZERO) {
|
||||
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 - dLenY) <= dDeltaY * ( ptPoly1.x - dLenX)) {
|
||||
|
||||
@@ -4415,11 +4443,11 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
|
||||
vtN1 = - vtNs ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Intersezione con la seconda faccia
|
||||
if ( abs( vtPoly * vtNd) > COS_ORTO_ANG_ZERO) {
|
||||
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 - dLenY) <= dDeltaY * ( ptPoly2.x - dLenX)) {
|
||||
|
||||
@@ -4549,7 +4577,7 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
|
||||
vtNmin = vtN2 ;
|
||||
vtNmax = vtN1 ;
|
||||
}
|
||||
|
||||
|
||||
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 j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
|
||||
|
||||
double dX = ( i + 0.5) * m_dStep ;
|
||||
double dY = ( j + 0.5) * m_dStep ;
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool AddDexelSideFace( int nPos, int nPosAdj, const Point3d& ptP, const Point3d& ptQ,
|
||||
const Vector3d& vtZ, const Vector3d& vtNorm, 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 FlipEdgesBB( TriaMatrix& InterTria) 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[], bool bFirstCorner, Point3d& ptInt, Vector3d& vtNormal) 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 GetPointVoxel( Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) const ;
|
||||
bool IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP, double dPrec = EPS_SMALL) const ;
|
||||
bool GetPointVoxel( const Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) const ;
|
||||
|
||||
// OPERAZIONI SU INTERVALLI
|
||||
bool SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ,
|
||||
|
||||
+150
-211
@@ -19,6 +19,7 @@
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGKLinePntTgCurve.h"
|
||||
#include "/EgtDev/Include/EGKFilletChamfer.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -98,257 +99,195 @@ bool
|
||||
VolZmap::SetAdvTool( const string& sToolName, double dH, double dR,
|
||||
double dTipH, double dTipR, double dCornR)
|
||||
{
|
||||
// reset nome
|
||||
// Reset nome
|
||||
m_sToolName.clear() ;
|
||||
// verifica dimensioni globali
|
||||
|
||||
// Verifica dimensioni globali
|
||||
if ( dH < EPS_SMALL || dR < EPS_SMALL)
|
||||
return false ;
|
||||
// se altezza punta nulla, ricado nel caso standard
|
||||
if ( dTipH < EPS_SMALL || abs( dTipR - dR) < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// Se altezza punta nulla, ricado nel caso standard
|
||||
if ( dTipH < EPS_SMALL || abs( dTipR - dR) < EPS_SMALL)
|
||||
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 ;
|
||||
m_dRCorner = 0 ;
|
||||
}
|
||||
// Se il raggio corner è non nullo
|
||||
// l'utensile viene descritto da
|
||||
// come utensile generico.
|
||||
else {
|
||||
|
||||
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) ;
|
||||
}
|
||||
// Se raggio corner nullo, allora utensile conico
|
||||
if ( dCornR < EPS_SMALL) {
|
||||
m_nToolType = ConusMill ;
|
||||
m_dRCorner = 0 ;
|
||||
// assegno nome e identificativo
|
||||
m_sToolName = sToolName ;
|
||||
m_nCurrentToolNum = 0 ;
|
||||
return true ;
|
||||
}
|
||||
// assegno il nome
|
||||
m_sToolName = sToolName ;
|
||||
// Aggiorno il numero dell'utensile corrente
|
||||
m_nCurrentToolNum = 0 ;
|
||||
return true ;
|
||||
|
||||
// Altrimenti utensile generico.
|
||||
m_nToolType = GenericTool ;
|
||||
m_dRCorner = dCornR ;
|
||||
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
|
||||
VolZmap::SetGenTool( const string& sToolName, const ICurveComposite* pToolOutline)
|
||||
{
|
||||
// Aggiorno il nome dell'utensile
|
||||
// Assegno nome, tipo e id dell'utensile
|
||||
m_sToolName = sToolName ;
|
||||
|
||||
// Aggiorno il tipo di utensile
|
||||
m_nToolType = GenericTool ;
|
||||
|
||||
// Aggiorno il numero dell'utensile corrente
|
||||
m_nCurrentToolNum = 0 ;
|
||||
|
||||
// Copio il profilo
|
||||
m_ToolOutline.CopyFrom( pToolOutline) ;
|
||||
// Copio il profilo e garantisco sia di soli archi e rette (converto eventuali curve di Bezier)
|
||||
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
|
||||
m_ToolOutline.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, m_dAngTolDeg) ;
|
||||
|
||||
// Puntatore a curva costante
|
||||
const ICurve* pCurve = m_ToolOutline.GetFirstCurve() ;
|
||||
// Flag di avvenuta approssimazione
|
||||
bool bApprox = false ;
|
||||
|
||||
// Ciclo sulle curve componenti
|
||||
const ICurve* pCurve = m_ToolOutline.GetFirstCurve() ;
|
||||
while ( pCurve != nullptr) {
|
||||
|
||||
// Se la curva è un arco valuto se approssimarlo
|
||||
// Se la curva è un arco verifico se approssimarlo
|
||||
if ( pCurve->GetType() == CRV_ARC) {
|
||||
|
||||
// Centro e punti iniziale e finale dell'arco
|
||||
Point3d ptStart, ptEnd, ptO ;
|
||||
|
||||
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
|
||||
// Centro e raggio dell'arco
|
||||
Point3d ptO = GetBasicCurveArc( pCurve)->GetCenter() ;
|
||||
double dRadius = GetBasicCurveArc( pCurve)->GetRadius() ;
|
||||
|
||||
// Recupero la curva precedente e quella successiva
|
||||
const ICurve* pPrev = m_ToolOutline.GetPrevCurve() ;
|
||||
const ICurve* pNext = m_ToolOutline.GetNextCurve() ;
|
||||
pNext = m_ToolOutline.GetNextCurve() ;
|
||||
// Se il centro è fuori dall'asse devo approssimare
|
||||
bool bCurrApprox = ( abs( ptO.x) > EPS_SMALL) ;
|
||||
|
||||
// Valuto la necessità di approssimare l'arco o meno
|
||||
|
||||
// Punto Iniziale della curva precedente e finale della successiva
|
||||
Point3d ptStartPrev, ptEndNext ;
|
||||
|
||||
// Vettori tangenti alle curve precedente corrente e successiva
|
||||
// rispettivamente nei punti finale, iniziale e finale e iniziale
|
||||
// e prodotti vettore fra i suddetti
|
||||
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 una delle altre curve dista dal centro meno del raggio, devo approssimare
|
||||
for ( int nI = 0 ; ! bCurrApprox && nI < m_ToolOutline.GetCurveCount() ; ++ nI) {
|
||||
const ICurve* pOtherCrv = m_ToolOutline.GetCurve( nI) ;
|
||||
if ( pOtherCrv != pCurve) {
|
||||
DistPointCurve CalcDist( ptO, *pOtherCrv) ;
|
||||
double dCurrDist ;
|
||||
if ( CalcDist.GetDist( dCurrDist) && dCurrDist < dRadius - EPS_SMALL)
|
||||
bCurrApprox = true ;
|
||||
}
|
||||
}
|
||||
|
||||
// Se devo approssimare
|
||||
if ( ! ( ( abs( ptO.x) < EPS_SMALL && vtIProd.z > 0 && ptStartPrev.y > ptTopCurrent.y) &&
|
||||
( ( 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() ;
|
||||
}
|
||||
|
||||
if ( bCurrApprox) {
|
||||
// Creo la polyline approssimante
|
||||
PolyLine Polygonal ;
|
||||
|
||||
pCurve->ApproxWithLines( m_dLinTol, m_dAngTolDeg, 10, Polygonal) ;
|
||||
|
||||
// Definisco una curva composita a partire dalla polyline
|
||||
CurveComposite cvTemp ; cvTemp.FromPolyLine( Polygonal) ;
|
||||
|
||||
// Aggiungo la parte approssimata
|
||||
pAux = cvTemp.GetFirstCurve() ;
|
||||
|
||||
while ( pAux != nullptr) {
|
||||
|
||||
m_ToolArcLineApprox.AddCurve( * pAux, true) ;
|
||||
|
||||
pAux = cvTemp.GetNextCurve() ;
|
||||
PolyLine plyApprox ;
|
||||
pCurve->ApproxWithLines( m_dLinTol, m_dAngTolDeg, ICurve::APL_SPECIAL, plyApprox) ;
|
||||
// Aggiungo i segmenti di retta alla approssimazione
|
||||
Point3d ptEnd ;
|
||||
plyApprox.GetFirstPoint( ptEnd) ;
|
||||
while ( plyApprox.GetNextPoint( ptEnd)) {
|
||||
m_ToolArcLineApprox.AddLine( ptEnd) ;
|
||||
}
|
||||
bApprox = true ;
|
||||
}
|
||||
// Se non deve essere approssimato
|
||||
else {
|
||||
// Se è già stato definito m_ToolArcLineApprox deve
|
||||
// essere completo, aggiungo quindi l'arco corrente
|
||||
if ( m_ToolArcLineApprox.GetCurveCount() != 0)
|
||||
m_ToolArcLineApprox.AddCurve( * pCurve, true) ;
|
||||
}
|
||||
// altrimenti lo aggiungo semplicemente
|
||||
else
|
||||
m_ToolArcLineApprox.AddCurve( *pCurve, true) ;
|
||||
}
|
||||
// Se è segmento
|
||||
else {
|
||||
// Se è già stato definito m_ToolArcLineApprox deve
|
||||
// essere completo, aggiungo quindi il segmento corrente
|
||||
if ( m_ToolArcLineApprox.GetCurveCount() != 0)
|
||||
m_ToolArcLineApprox.AddCurve( * pCurve, true) ;
|
||||
}
|
||||
// altrimenti è segmento e lo aggiungo semplicemente
|
||||
else
|
||||
m_ToolArcLineApprox.AddCurve( *pCurve, true) ;
|
||||
|
||||
pCurve = m_ToolOutline.GetNextCurve() ;
|
||||
}
|
||||
|
||||
// Se non ci sono state approssimazioni, cancello la curva approssimante
|
||||
if ( ! bApprox)
|
||||
m_ToolArcLineApprox.Clear() ;
|
||||
|
||||
// Dimensioni dell'utensile
|
||||
BBox3d Bounding ;
|
||||
m_ToolOutline.GetLocalBBox( Bounding) ;
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user