EgtGraphics 1.5k3 :

- insieme con punto snap si prende la direzione e l'id dell'oggetto generatore
- si marca anche l'inizio delle curve, quando richiesto.
This commit is contained in:
Dario Sassi
2014-11-21 17:45:13 +00:00
parent 829205a886
commit d5fff587aa
6 changed files with 212 additions and 8 deletions
BIN
View File
Binary file not shown.
+1
View File
@@ -154,6 +154,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
+11
View File
@@ -123,6 +123,13 @@ class Scene : public IEGrScene
// Snap
virtual bool GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel) ;
virtual bool GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel) ;
virtual int GetLastSnapId( void)
{ return m_nLastSnapId ; }
virtual bool GetLastSnapDir( Vector3d& vtDir)
{ if ( ! m_bLastSnapDirOk)
return false ;
vtDir = m_vtLastSnapDir ;
return true ; }
public :
// Basic
@@ -199,6 +206,10 @@ class Scene : public IEGrScene
static const int DIM_SEL_BUF = 32768 ;
SelRec m_nSelBuff[DIM_SEL_BUF] ; // buffer per selezione con OpenGL
int m_nLastSnapId ; // Id dell'entità generatrice dell'ultimo punto snap
bool m_bLastSnapDirOk ; // flag validità direzione associata a ultimo punto snap
Vector3d m_vtLastSnapDir ; // direzione associata a ultimo punto snap
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
Color m_colDef ; // colore di default
Color m_colMark ; // colore per marcatura
+3
View File
@@ -60,6 +60,9 @@ Scene::Scene( void)
m_bSelect = false ;
m_Unsel.reserve( 50) ;
m_nSelCurr = - 1 ;
// Snap Punti
m_nLastSnapId = GDB_ID_NULL ;
m_bLastSnapDirOk = false ;
// GeomData
m_pGeomDB = nullptr ;
m_colDef.Set( 0, 0, 0) ;
+60 -5
View File
@@ -34,6 +34,7 @@ using namespace std ;
//------------------------------ Local functions -----------------------------
static ObjEGrGraphics* CreateObjEGrGraphics( bool bNewWay) ;
static bool CalcCurveTailMark( const PolyLine& plCrv, PolyLine& plMark) ;
static bool CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr) ;
static bool CalcConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) ;
@@ -237,10 +238,10 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
pGraphics->Clear() ;
pGraphics->AddColor( cCol) ;
pGraphics->AddPolyLine( PL) ;
// eventuali segni ausiliari (frecce,...)
//Point3d ptStart ;
//if ( PL.GetFirstPoint( ptStart))
// pGraphics->AddPoint( ptStart, true) ;
// eventuali segni ausiliari (mark, frecce, ...)
PolyLine PLM ;
if ( CalcCurveTailMark( PL, PLM))
pGraphics->AddPolyLine( PLM, true) ;
PolyLine PLA ;
if ( CalcCurveTipArrow( PL, PLA))
pGraphics->AddPolyLine( PLA, true) ;
@@ -384,6 +385,60 @@ CreateObjEGrGraphics( bool bNewWay)
return ( new ObjOldGraphics) ;
}
//----------------------------------------------------------------------------
static bool
CalcCurveTailMark( const PolyLine& plCrv, PolyLine& plMark)
{
// pulisco la polilinea per il segno
plMark.Clear() ;
// verifico effettiva esistenza della polilinea approssimante la curva
if ( plCrv.GetLineNbr() < 1)
return false ;
// dimensioni limite traverso
const double MAX_LEN_TR = 6 ;
const double MIN_LEN_TR = 0.1 ;
// recupero dati primo tratto della curva
Point3d ptTail, ptP ;
if ( ! plCrv.GetFirstLine( ptTail, ptP))
return false ;
Vector3d vtDir = ptP - ptTail ;
double dLen = vtDir.Len() ;
if ( dLen < EPS_SMALL)
return false ;
vtDir /= dLen ;
// se molto piccolo, cerco di allungarmi senza deviare troppo
while ( dLen < MAX_LEN_TR) {
Point3d ptP1, ptP2 ;
if ( ! plCrv.GetNextLine( ptP1, ptP2))
break ;
Vector3d vtNxDir = ptP2 - ptP1 ;
vtNxDir.Normalize() ;
if ( ( vtDir * vtNxDir) > cos( 30 * DEGTORAD)) {
vtDir = ptP1 - ptTail ;
dLen = vtDir.Len() ;
vtDir /= dLen ;
}
else
break ;
}
// calcolo dimensioni traverso
double dLenTr = dLen ;
if ( dLenTr > MAX_LEN_TR)
dLenTr = MAX_LEN_TR ;
else if ( dLenTr < MIN_LEN_TR)
dLenTr = MIN_LEN_TR ;
// disegno traverso
Frame3d frF ;
frF.Set( ptTail, vtDir) ;
Point3d ptP1 = ORIG + Vector3d( 0.5 * dLenTr, 0, 0) ;
ptP1.ToGlob( frF) ;
plMark.AddUPoint( 0, ptP1) ;
Point3d ptP2 = ORIG - Vector3d( 0.5 * dLenTr, 0, 0) ;
ptP2.ToGlob( frF) ;
plMark.AddUPoint( 1, ptP2) ;
return true ;
}
//----------------------------------------------------------------------------
static bool
CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr)
@@ -394,7 +449,7 @@ CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr)
if ( plCrv.GetLineNbr() < 1)
return false ;
// dimensioni freccia limite
const double MAX_LEN_ARR = 3 ;
const double MAX_LEN_ARR = 10.0 ;
const double MIN_LEN_ARR = 0.1 ;
// recupero dati ultimo tratto della curva
Point3d ptTip, ptP ;
+137 -3
View File
@@ -31,6 +31,9 @@ using namespace std ;
bool
Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Point3d& ptSel)
{
// reset dati associati a ultimo punto snap
m_nLastSnapId = GDB_ID_NULL ;
m_bLastSnapDirOk = false ;
// se Snap Sketch o Grid, devo trovare il punto sulla griglia
if ( nSnap == SP_SKETCH || nSnap == SP_GRID)
return GetGridSnapPoint( ( nSnap == SP_SKETCH), ptWin, ptSel) ;
@@ -139,6 +142,8 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = false ;
}
}
// se vettore
@@ -151,6 +156,10 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
m_vtLastSnapDir = pGV->GetVector() ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
// se frame
@@ -163,12 +172,24 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = false ;
}
}
// se curva
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
// recupero la curva
const ICurve* pCrv = GetCurve( m_pGeomDB->GetGeoObj( nIds[i])) ;
// recupero eventuale spessore di estrusione
bool bExtr = false ;
double dTh ;
Vector3d vtExtr ;
if ( pCrv->GetExtrusion( vtExtr) && ! vtExtr.IsSmall() &&
pCrv->GetThickness( dTh) && fabs( dTh) > EPS_SMALL) {
vtExtr *= dTh ;
vtExtr.ToGlob( frEnt) ;
bExtr = true ;
}
// recupero il punto
Point3d ptP ;
switch ( nSnap) {
@@ -179,6 +200,24 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
pCrv->GetStartDir( m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
m_vtLastSnapDir.Invert() ;
}
// eventuale verifica dell'estruso
if ( bExtr) {
ptP += vtExtr ;
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
pCrv->GetStartDir( m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
m_vtLastSnapDir.Invert() ;
}
}
}
// punto finale
@@ -187,6 +226,22 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
pCrv->GetEndDir( m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
// eventuale verifica dell'estruso
if ( bExtr) {
ptP += vtExtr ;
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
pCrv->GetEndDir( m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
}
break ;
@@ -196,6 +251,22 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
pCrv->GetMidDir( m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
// eventuale verifica dell'estruso
if ( bExtr) {
ptP += vtExtr ;
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
pCrv->GetMidDir( m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
}
break ;
@@ -205,6 +276,18 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = false ;
}
// eventuale verifica dell'estruso
if ( bExtr) {
ptP += vtExtr ;
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = false ;
}
}
}
break ;
@@ -217,16 +300,45 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
// lo porto nel frame della curva
ptRef.ToLoc( frEnt) ;
// determino il punto più vicino della curva a questo
int nFlag ;
MinDistPCInfo mdInfo ;
DistPointCurve dstPtCurve( ptRef, *pCrv) ;
if ( dstPtCurve.GetMinDistPoint( 0, ptP, nFlag)) {
if ( dstPtCurve.GetMinDistInfo( 0, mdInfo)) {
ptP = mdInfo.ptQ ;
ptP.ToGlob( frEnt) ;
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
Point3d ptTmp ;
pCrv->GetPointTang( mdInfo.dPar, ICurve::FROM_MINUS, ptTmp, m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
} break ;
// eventuale verifica dell'estruso
if ( bExtr) {
Vector3d vtTemp = - vtExtr ;
vtTemp.ToLoc( frEnt) ;
// determino il punto più vicino della curva a questo
MinDistPCInfo mdInfo ;
DistPointCurve dstPtCurve( ptRef, *pCrv) ;
if ( dstPtCurve.GetMinDistInfo( 0, mdInfo)) {
ptP = mdInfo.ptQ ;
ptP.ToGlob( frEnt) ;
ptP += vtExtr ;
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
Point3d ptTmp ;
pCrv->GetPointTang( mdInfo.dPar, ICurve::FROM_MINUS, ptTmp, m_vtLastSnapDir) ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
}
}
break ;
}
}
// se testo
@@ -243,6 +355,10 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
m_vtLastSnapDir = pTxt->GetDirVersor() ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
// punto sopra iniziale
@@ -251,6 +367,10 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
m_vtLastSnapDir = pTxt->GetDirVersor() ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
// punto finale
@@ -259,6 +379,10 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
m_vtLastSnapDir = pTxt->GetDirVersor() ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
// punto sopra finale
@@ -267,6 +391,10 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
m_vtLastSnapDir = pTxt->GetDirVersor() ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
break ;
@@ -277,6 +405,10 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = true ;
m_vtLastSnapDir = pTxt->GetDirVersor() ;
m_vtLastSnapDir.ToGlob( frEnt) ;
}
}
break ;
@@ -287,6 +419,8 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
if ( VerifySnapPoint( ptP, ptWin, dMinSqDist)) {
bFound = true ;
ptSel = ptP ;
m_nLastSnapId = nIds[i] ;
m_bLastSnapDirOk = false ;
}
}
break ;