Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a4ee5cc19 | |||
| 32883dab86 | |||
| 8ac3fdab47 |
+2
-2
@@ -13,8 +13,8 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EGkBBox3d.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "\EgtDev\Include\EGkBBox3d.h"
|
||||
#include "\EgtDev\Include\EGkFrame3d.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+2
-5
@@ -59,10 +59,8 @@ class ArcApproxer
|
||||
//----------------------------------------------------------------------------
|
||||
CurveArc::CurveArc( void)
|
||||
: m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(),
|
||||
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick()
|
||||
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -580,8 +578,7 @@ CurveArc::CopyFrom( const CurveArc& caSrc)
|
||||
return true ;
|
||||
m_VtExtr = caSrc.m_VtExtr ;
|
||||
m_dThick = caSrc.m_dThick ;
|
||||
m_nTempProp[0] = caSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = caSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = caSrc.m_nTempProp ;
|
||||
return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad,
|
||||
caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ;
|
||||
}
|
||||
|
||||
+5
-6
@@ -49,11 +49,10 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -212,7 +211,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
double m_dDeltaN ; // variazione di quota lungo VtN della fine rispetto all'inizio
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+2
-5
@@ -45,10 +45,8 @@ GEOOBJ_REGISTER( CRV_BEZIER, NGE_C_BEZ, CurveBezier) ;
|
||||
//----------------------------------------------------------------------------
|
||||
CurveBezier::CurveBezier( void)
|
||||
: m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2),
|
||||
m_VtExtr(), m_dThick()
|
||||
m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -285,8 +283,7 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
|
||||
m_vWeCtrl = cbSrc.m_vWeCtrl ;
|
||||
m_VtExtr = cbSrc.m_VtExtr ;
|
||||
m_dThick = cbSrc.m_dThick ;
|
||||
m_nTempProp[0] = cbSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = cbSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = cbSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -51,11 +51,10 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override { return true ; }
|
||||
@@ -190,7 +189,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+9
-14
@@ -40,10 +40,8 @@ GEOOBJ_REGISTER( CRV_COMPO, NGE_C_CMP, CurveComposite) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveComposite::CurveComposite( void)
|
||||
: m_nStatus( TO_VERIFY), m_VtExtr(), m_dThick(), m_ptStart(), m_Iter( m_CrvSmplS.end())
|
||||
: m_nStatus( TO_VERIFY), m_VtExtr(), m_dThick(), m_ptStart(), m_nTempProp(), m_Iter( m_CrvSmplS.end())
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -65,8 +63,7 @@ CurveComposite::Clear( void)
|
||||
m_VtExtr = V_NULL ;
|
||||
m_dThick = 0 ;
|
||||
m_ptStart = ORIG ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_nTempProp = 0 ;
|
||||
m_Iter = m_CrvSmplS.end() ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
@@ -544,8 +541,7 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc)
|
||||
Clear() ;
|
||||
m_VtExtr = ccSrc.m_VtExtr ;
|
||||
m_dThick = ccSrc.m_dThick ;
|
||||
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = ccSrc.m_nTempProp ;
|
||||
for ( auto& pCrv : ccSrc.m_CrvSmplS) {
|
||||
if ( ! AddCurve( *pCrv))
|
||||
return false ;
|
||||
@@ -562,8 +558,7 @@ CurveComposite::RelocateFrom( CurveComposite& ccSrc)
|
||||
Clear() ;
|
||||
m_VtExtr = ccSrc.m_VtExtr ;
|
||||
m_dThick = ccSrc.m_dThick ;
|
||||
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = ccSrc.m_nTempProp ;
|
||||
for ( ICurve* pCrv = ccSrc.RemoveFirstOrLastCurve( false) ;
|
||||
pCrv != nullptr ;
|
||||
pCrv = ccSrc.RemoveFirstOrLastCurve( false)) {
|
||||
@@ -3134,7 +3129,7 @@ CurveComposite::RemoveUndercutOnY( double dLinTol, double dAngTolDeg)
|
||||
pSfrCut->Translate( b3Box.GetMin() - Point3d( 10 * EPS_SMALL, dLen, 0)) ;
|
||||
// calcolo la classificazione della curva rispetto alla regione
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! pSfrCut->GetCurveClassification( *pOutLoop, EPS_SMALL, ccClass))
|
||||
if ( ! pSfrCut->GetCurveClassification( *pOutLoop, ccClass))
|
||||
return false ;
|
||||
// determino gli intervalli di curva da conservare
|
||||
Intervals inOk ;
|
||||
@@ -3248,7 +3243,7 @@ CurveComposite::IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
|
||||
CurveComposite::SetCurveTempProp( int nCrv, int nProp)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -3257,13 +3252,13 @@ CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
|
||||
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
|
||||
return false ;
|
||||
// eseguo assegnazione
|
||||
m_CrvSmplS[nCrv]->SetTempProp( nProp, nPropNum) ;
|
||||
m_CrvSmplS[nCrv]->SetTempProp( nProp) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
|
||||
CurveComposite::GetCurveTempProp( int nCrv, int& nProp) const
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -3272,6 +3267,6 @@ CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
|
||||
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
|
||||
return false ;
|
||||
// eseguo recupero
|
||||
nProp = m_CrvSmplS[nCrv]->GetTempProp( nPropNum) ;
|
||||
nProp = m_CrvSmplS[nCrv]->GetTempProp() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+7
-8
@@ -50,11 +50,10 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -159,8 +158,8 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool IsAPoint( void) const override ;
|
||||
bool IsALine( double dLinTol, Point3d& ptStart, Point3d& ptEnd) const override ;
|
||||
bool IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ;
|
||||
bool SetCurveTempProp( int nCrv, int nProp, int nPropNum = 0) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp, int nPropNum = 0) const override ;
|
||||
bool SetCurveTempProp( int nCrv, int nProp) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -203,7 +202,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
||||
} ;
|
||||
|
||||
|
||||
+2
-5
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( CRV_LINE, NGE_C_LIN, CurveLine) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveLine::CurveLine( void)
|
||||
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick()
|
||||
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -125,8 +123,7 @@ CurveLine::CopyFrom( const CurveLine& clSrc)
|
||||
return true ;
|
||||
m_VtExtr = clSrc.m_VtExtr ;
|
||||
m_dThick = clSrc.m_dThick ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -49,11 +49,10 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -165,7 +164,7 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
Point3d m_PtEnd ; // punto finale
|
||||
Vector3d m_VtExtr ; // vettore estrusione
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+11
-10
@@ -23,30 +23,33 @@
|
||||
bool
|
||||
CalcMinDistPointPolyLine( const Point3d& ptP, PolyLine& PL, double dLinTol, MDCVECTOR& vApproxMin)
|
||||
{
|
||||
double dSqDist ;
|
||||
double dPar ;
|
||||
double dUIni ;
|
||||
double dUFin ;
|
||||
Point3d ptIni ;
|
||||
Point3d ptFin ;
|
||||
double dMinDist ;
|
||||
double dSqMinDist ;
|
||||
MinDistCalc approxMin ;
|
||||
|
||||
vApproxMin.reserve( 4) ;
|
||||
vApproxMin.clear() ;
|
||||
|
||||
bool bFound = false ;
|
||||
bool bOnEnd = false ;
|
||||
double dUIni, dUFin ;
|
||||
Point3d ptIni, ptFin ;
|
||||
double dMinDist, dSqMinDist ;
|
||||
vApproxMin.reserve( 4) ;
|
||||
vApproxMin.clear() ;
|
||||
for ( bool bLine = PL.GetFirstULine( &dUIni, &ptIni, &dUFin, &ptFin) ;
|
||||
bLine ;
|
||||
bLine = PL.GetNextULine( &dUIni, &ptIni, &dUFin, &ptFin)) {
|
||||
// calcolo la distanza del punto dal segmento
|
||||
DistPointLine dstPtLn( ptP, ptIni, ptFin) ;
|
||||
double dSqDist ;
|
||||
if ( ! dstPtLn.GetSqDist( dSqDist))
|
||||
continue ;
|
||||
// altro punto con la stessa minima distanza già trovata
|
||||
if ( bFound && abs( dSqDist - dSqMinDist) < 2 * dMinDist * dLinTol) {
|
||||
// salvo i dati nella struttura
|
||||
MinDistCalc approxMin ;
|
||||
approxMin.dDist = dMinDist ;
|
||||
dstPtLn.GetMinDistPoint( approxMin.ptQ) ;
|
||||
double dPar ;
|
||||
dstPtLn.GetParamAtMinDistPoint( dPar) ;
|
||||
approxMin.dPar = ( 1 - dPar) * dUIni + dPar * dUFin ;
|
||||
approxMin.dParMin = dUIni ;
|
||||
@@ -63,10 +66,8 @@ CalcMinDistPointPolyLine( const Point3d& ptP, PolyLine& PL, double dLinTol, MDCV
|
||||
dSqMinDist = dSqDist ;
|
||||
dMinDist = sqrt( dSqMinDist) ;
|
||||
// salvo i dati nella struttura
|
||||
MinDistCalc approxMin ;
|
||||
approxMin.dDist = dMinDist ;
|
||||
dstPtLn.GetMinDistPoint( approxMin.ptQ) ;
|
||||
double dPar ;
|
||||
dstPtLn.GetParamAtMinDistPoint( dPar) ;
|
||||
approxMin.dPar = ( 1 - dPar) * dUIni + dPar * dUFin ;
|
||||
approxMin.dParMin = dUIni ;
|
||||
|
||||
Binary file not shown.
+19
-8
@@ -51,7 +51,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
@@ -86,7 +86,6 @@
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
<IncludePath>C:\;$(IncludePath)</IncludePath>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
|
||||
@@ -102,7 +101,6 @@
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
<IncludePath>C:\;$(IncludePath)</IncludePath>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -116,6 +114,7 @@
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -150,7 +149,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -197,6 +196,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -239,10 +239,10 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -366,7 +366,12 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersCurveCurve.cpp" />
|
||||
<ClCompile Include="IntersLineArc.cpp" />
|
||||
<ClCompile Include="IntersLineLine.cpp" />
|
||||
<ClCompile Include="IntersLinePlane.cpp" />
|
||||
<ClCompile Include="IntersLinePlane.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineSurfTm.cpp" />
|
||||
<ClCompile Include="IntersLineTria.cpp" />
|
||||
<ClCompile Include="Intervals.cpp" />
|
||||
@@ -392,9 +397,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="SurfFlatRegionBooleans.cpp" />
|
||||
<ClCompile Include="SurfFlatRegionOffset.cpp" />
|
||||
<ClCompile Include="SurfTriMeshBooleans.cpp" />
|
||||
<ClCompile Include="SurfTriMeshUtilities.cpp" />
|
||||
<ClCompile Include="TextureData.cpp" />
|
||||
<ClCompile Include="Tool.cpp" />
|
||||
<ClCompile Include="tpp_assert.cpp" />
|
||||
<ClCompile Include="tpp_impl.cpp" />
|
||||
<ClCompile Include="UserObjDefault.cpp" />
|
||||
<ClCompile Include="UserObjFactory.cpp" />
|
||||
<ClCompile Include="OutTsc.cpp" />
|
||||
@@ -558,6 +564,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="DistPointCrvComposite.h" />
|
||||
<ClInclude Include="DistPointLine.h" />
|
||||
<ClInclude Include="DllMain.h" />
|
||||
<ClInclude Include="dpoint.hpp" />
|
||||
<ClInclude Include="ExtDimension.h" />
|
||||
<ClInclude Include="ExtText.h" />
|
||||
<ClInclude Include="FontAux.h" />
|
||||
@@ -605,6 +612,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="TextureData.h" />
|
||||
<ClInclude Include="Tool.h" />
|
||||
<ClInclude Include="CAvToolTriangle.h" />
|
||||
<ClInclude Include="tpp_assert.hpp" />
|
||||
<ClInclude Include="tpp_interface.hpp" />
|
||||
<ClInclude Include="triangle.h" />
|
||||
<ClInclude Include="triangle_impl.hpp" />
|
||||
<ClInclude Include="UserObjDefault.h" />
|
||||
<ClInclude Include="OutTsc.h" />
|
||||
<ClInclude Include="PointsPCA.h" />
|
||||
|
||||
@@ -46,6 +46,12 @@
|
||||
<Filter Include="File di origine\GeoCollision">
|
||||
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di intestazione\tpp">
|
||||
<UniqueIdentifier>{9596e38a-8880-4ab5-bd65-e1db39c92ac5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\tpp">
|
||||
<UniqueIdentifier>{636e60fa-4b24-4a7b-b2e9-74e1c1e8fb31}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Vector3d.cpp">
|
||||
@@ -453,8 +459,11 @@
|
||||
<ClCompile Include="CDeRectPrismoidTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfTriMeshUtilities.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
<ClCompile Include="tpp_assert.cpp">
|
||||
<Filter>File di origine\tpp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tpp_impl.cpp">
|
||||
<Filter>File di origine\tpp</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -1079,6 +1088,21 @@
|
||||
<ClInclude Include="CDeRectPrismoidTria.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="dpoint.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tpp_assert.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tpp_interface.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="triangle.h">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="triangle_impl.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+1
-4
@@ -49,8 +49,6 @@ ExtDimension::ExtDimension( void)
|
||||
: m_dExtLineLen( STD_EXTLINELEN), m_dArrowLen( STD_ARROWLEN), m_dTextDist( STD_TEXTDIST),
|
||||
m_bLenIsMM( true), m_nDecDigit( STD_DECDIGIT), m_sFont( STD_FONT), m_dTextHeight( STD_TEXTHEIGHT)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -188,8 +186,7 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
|
||||
m_nDecDigit = clSrc.m_nDecDigit ;
|
||||
m_sFont = clSrc.m_sFont ;
|
||||
m_dTextHeight = clSrc.m_dTextHeight ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -50,11 +50,10 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IExtDimension
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -149,5 +148,5 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
int m_nDecDigit ; // numero di cifre decimali
|
||||
std::string m_sFont ; // font del testo
|
||||
double m_dTextHeight ; // altezza del testo
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+2
-5
@@ -35,10 +35,8 @@ GEOOBJ_REGISTER( EXT_TEXT, NGE_E_TXT, ExtText) ;
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText::ExtText( void)
|
||||
: m_pSTM( nullptr), m_bNoSTM( false), m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(),
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0)
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -186,8 +184,7 @@ ExtText::CopyFrom( const ExtText& clSrc)
|
||||
m_dRatio = clSrc.m_dRatio ;
|
||||
m_dAddAdvance = clSrc.m_dAddAdvance ;
|
||||
m_nInsPos = clSrc.m_nInsPos ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,10 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IExtText
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -144,5 +143,5 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
double m_dRatio ; // rapporto tra larghezza e altezza
|
||||
double m_dAddAdvance ; // avanzamento addizionale tra caratteri
|
||||
int m_nInsPos ; // posizione del punto di inserimento rispetto al testo
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+118
-118
@@ -57,7 +57,7 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Per Id di entità
|
||||
// Per Id di entità
|
||||
static const int ID_NO = -99 ;
|
||||
// Per tipo di costruzione di poligono
|
||||
static const int POLYG_INSCR = 1 ;
|
||||
@@ -189,7 +189,7 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
LOG_ERROR( GetEGkLogger(), "Error : null GeomDb in GdbExecutor.")
|
||||
return ER_ERR ;
|
||||
}
|
||||
// verifico validità CmdParser
|
||||
// verifico validità CmdParser
|
||||
if ( m_pParser == nullptr) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error : null CmdParser in GdbExecutor.")
|
||||
return ER_ERR ;
|
||||
@@ -218,7 +218,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 2 o 3 parametri : Id, Id del padre[, Frame]
|
||||
if ( vsParams.size() != 2 && vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -236,7 +236,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 3 parametri : Id, Id del padre, Orig
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -253,7 +253,7 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// creo il gruppo
|
||||
int nIdDest = GetIdParam( vsParams[0], true) ;
|
||||
int nIdNew = m_pGDB->AddGroup( nIdDest, GetIdParam( vsParams[1]), frFrame) ;
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[0], nIdNew) ;
|
||||
|
||||
@@ -270,7 +270,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 3 parametri : Id, IdParent e punto
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frPnt ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frPnt))
|
||||
return false ;
|
||||
@@ -289,7 +289,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 4 : Id, IdParent, ptP, vtV
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frPnt ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frPnt))
|
||||
return false ;
|
||||
@@ -351,7 +351,7 @@ GdbExecutor::VectorMake( const STRVECTOR& vsParams)
|
||||
// 3 o 4 parametri : Id, IdParent, Vettore [, ScaleFactor]
|
||||
if ( vsParams.size() != 3 && vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -378,7 +378,7 @@ GdbExecutor::VectorFromSpherical( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, IdParent, dLen, dAngVertDeg, dAngOrizzDeg
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -386,7 +386,7 @@ GdbExecutor::VectorFromSpherical( const STRVECTOR& vsParams)
|
||||
double dLen ;
|
||||
if ( ! GetLengthParam( vsParams[2], dLen))
|
||||
return false ;
|
||||
// recupero l'angolo in verticale (non c'è metodo generale)
|
||||
// recupero l'angolo in verticale (non c'è metodo generale)
|
||||
double dAngVertDeg ;
|
||||
if ( ! FromString( vsParams[3], dAngVertDeg))
|
||||
return false ;
|
||||
@@ -410,7 +410,7 @@ GdbExecutor::VectorCrossProduct( const STRVECTOR& vsParams)
|
||||
// 4 o 5 parametri : Id, IdParent, vtV1, vtV2 [, bNorm]
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -444,7 +444,7 @@ GdbExecutor::VectorDifference( const STRVECTOR& vsParams)
|
||||
// 4 o 5 parametri : Id, IdParent, ptP1, ptP2 [, bNorm]
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -478,7 +478,7 @@ GdbExecutor::VectorBaseVector( const STRVECTOR& vsParams)
|
||||
// 4 o 5 parametri : Id, IdParent, PtBase, Vettore [, ScaleFactor]
|
||||
if ( vsParams.size() != 4 && vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frVect))
|
||||
return false ;
|
||||
@@ -512,7 +512,7 @@ GdbExecutor::VectorModifyBase( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// indice dell'oggetto
|
||||
int nId = GetIdParam( vsParams[0]) ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frVect ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nId, frVect))
|
||||
return false ;
|
||||
@@ -537,7 +537,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 3 parametri : Id, ParentId, Frame
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -557,7 +557,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptOrig, ptOnX, ptNearY
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -579,7 +579,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -634,7 +634,7 @@ GdbExecutor::CurveLineMake( const STRVECTOR& vsParams)
|
||||
// 4 parametri : Id, IdParent, ptStart, ptEnd
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -664,7 +664,7 @@ GdbExecutor::CurveLineVersorLength( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, IdParent, ptStart, vtDir, dLen
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -698,7 +698,7 @@ GdbExecutor::CurveLineDirLength( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, IdParent, ptStart, dAngDeg, dLen
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -863,7 +863,7 @@ GdbExecutor::CurveLineMinPointCurve( const STRVECTOR& vsParams)
|
||||
// porto il punto nel riferimento della curva
|
||||
Point3d ptSloc = ptStart ;
|
||||
ptSloc.LocToLoc( frPoint, frCurve) ;
|
||||
// recupero eventuale parametro per discriminare tra più soluzioni
|
||||
// recupero eventuale parametro per discriminare tra più soluzioni
|
||||
double dNearParam ;
|
||||
if ( vsParams.size() < 5 || ! FromString( vsParams[4], dNearParam))
|
||||
dNearParam = 0 ;
|
||||
@@ -962,7 +962,7 @@ GdbExecutor::CurveCircleMake( const STRVECTOR& vsParams)
|
||||
// 5 parametri
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -996,7 +996,7 @@ GdbExecutor::CurveCirclePlaneXY( const STRVECTOR& vsParams)
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1026,7 +1026,7 @@ GdbExecutor::CurveArcMake( const STRVECTOR& vsParams)
|
||||
// 8 parametri
|
||||
if ( vsParams.size() != 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1072,7 +1072,7 @@ GdbExecutor::CurveArcPlaneXY( const STRVECTOR& vsParams)
|
||||
// 7 parametri
|
||||
if ( vsParams.size() != 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1114,7 +1114,7 @@ GdbExecutor::CurveArcCircle3P( const STRVECTOR& vsParams, bool bCirc)
|
||||
// 5 parametri : Id, ParentId, ptP0, ptP1, ptP2
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1148,7 +1148,7 @@ GdbExecutor::CurveArc2PDi( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptPi, ptPf, dDiri
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1164,7 +1164,7 @@ GdbExecutor::CurveArc2PDi( const STRVECTOR& vsParams)
|
||||
double dDirI ;
|
||||
if ( ! GetDirParam( vsParams[4], frRef, dDirI))
|
||||
return false ;
|
||||
// calcolo l'arco (in casi particolari può essere una retta)
|
||||
// calcolo l'arco (in casi particolari può essere una retta)
|
||||
ICurve* pCurve = GetArc2PD( ptPi, ptPf, dDirI) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
@@ -1179,7 +1179,7 @@ GdbExecutor::CurveArc2PRS( const STRVECTOR& vsParams)
|
||||
// 5 o 6 parametri : Id, ParentId, ptPi, ptPf, dRad[, CCW/CW]
|
||||
if ( vsParams.size() != 5 && vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1217,7 +1217,7 @@ GdbExecutor::CurveArcC2P( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptCen, ptPi, ptNearPf
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1251,7 +1251,7 @@ GdbExecutor::CurveCircleCenterTgArc( const STRVECTOR& vsParams)
|
||||
// 5 parametri : Id, ParentId, ptCen, IdArc, ptNear
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
@@ -1297,7 +1297,7 @@ GdbExecutor::CurveArcCenterTgArcP( const STRVECTOR& vsParams)
|
||||
// 6 parametri : Id, ParentId, ptCen, IdArc, ptNearTg, ptNearEnd
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
@@ -1349,7 +1349,7 @@ GdbExecutor::CurveArcPDiTgArc( const STRVECTOR& vsParams)
|
||||
// 6 parametri : Id, ParentId, ptStart, dirStart, IdArc, ptNear
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
|
||||
return false ;
|
||||
@@ -1382,7 +1382,7 @@ GdbExecutor::CurveArcPDiTgArc( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
Point3d ptNtloc = ptNear ;
|
||||
ptNtloc.LocToLoc( frDest, frTgArc) ;
|
||||
// calcolo l'arco (in casi particolari può essere una linea)
|
||||
// calcolo l'arco (in casi particolari può essere una linea)
|
||||
ICurve* pCurve = GetArcPntDirTgCurve( ptSloc, FromPolar( 1, dDirI), *pTgArc, ptNtloc, Z_AX) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
@@ -1521,7 +1521,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDeg, false))
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1547,7 +1547,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDeg, true))
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1949,7 +1949,7 @@ GdbExecutor::CurveCompoFromPolygon( const STRVECTOR& vsParams, int nType)
|
||||
int nNumLati ;
|
||||
if ( ! FromString( vsParams[2], nNumLati))
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -1994,7 +1994,7 @@ GdbExecutor::CurveCompoFromBiarc( const STRVECTOR& vsParams)
|
||||
// 6 o 7 parametri : Id, IdParent, ptP1, Dir1, ptP2, Dir2 [, Par]
|
||||
if ( vsParams.size() != 6 && vsParams.size() != 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2074,7 +2074,7 @@ GdbExecutor::CurveCompoExtractCurve( const STRVECTOR& vsParams, bool bEndOrStart
|
||||
Frame3d frSou ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdCCompo, frSou))
|
||||
return false ;
|
||||
// estraggo la opportuna entità
|
||||
// estraggo la opportuna entità
|
||||
PtrOwner<ICurve> pCrv( pCrvCompo->RemoveFirstOrLastCurve( bEndOrStart)) ;
|
||||
// se 1 solo parametro -> cancellazione
|
||||
if ( vsParams.size() == 1)
|
||||
@@ -2161,7 +2161,7 @@ GdbExecutor::ExecuteSurfTriMesh( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
else if ( sCmd2 == "COMP" || sCmd2 == "DOCOMPACTING") {
|
||||
return SurfTriMeshDoCompacting( vsParams) ;
|
||||
}
|
||||
// se unione di due o più superfici per cucitura
|
||||
// se unione di due o più superfici per cucitura
|
||||
else if ( sCmd2 == "SEW" || sCmd2 == "DOSEWING") {
|
||||
return SurfTriMeshDoSewing( vsParams) ;
|
||||
}
|
||||
@@ -2395,7 +2395,7 @@ GdbExecutor::SurfTriMeshByExtrusion( const STRVECTOR& vsParams)
|
||||
CurveLocal CrvLoc( m_pGDB, nCrvId, frDest) ;
|
||||
if ( CrvLoc.Get() == nullptr)
|
||||
return false ;
|
||||
// recupero il vettore di estrusione (già in locale)
|
||||
// recupero il vettore di estrusione (già in locale)
|
||||
Vector3d vtExtr ;
|
||||
if ( ! GetVectorParam( vsParams[3], frDest, vtExtr))
|
||||
return false ;
|
||||
@@ -2471,7 +2471,7 @@ GdbExecutor::SurfTriMeshByScrewing( bool bMove, const STRVECTOR& vsParams)
|
||||
// recupero la tolleranza lineare
|
||||
if ( vsParams.size() == 7)
|
||||
FromString( vsParams[6], dLinTol) ;
|
||||
// non c'é movimento lungo l'asse
|
||||
// non c'é movimento lungo l'asse
|
||||
}
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
@@ -2642,7 +2642,7 @@ GdbExecutor::SurfTrimeshClonePart( const STRVECTOR& vsParams)
|
||||
// Parametri : IdNew, IdOld, IdParent, nPart
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// Recupero il riferimento in cui è immerso
|
||||
// Recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[2]), frRef))
|
||||
return false ;
|
||||
@@ -2785,7 +2785,7 @@ GdbExecutor::VolZmapCreate( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptO, dLengthX, dLengthY, dLengthZ, dPrec [, bTriDexel]
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2829,7 +2829,7 @@ GdbExecutor::VolZmapCreateFromFlatRegion( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, idCurv, dPrec, dLengthZ [, bTriDexel]
|
||||
if ( vsParams.size() < 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2867,7 +2867,7 @@ GdbExecutor::VolZmapCreateFromTriMesh( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, idSurf, dPrec, bFlag
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -2900,7 +2900,7 @@ GdbExecutor::VolZmapMilling( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptPs, ptPe, vtVs, vtVe, dLinTol, dAngTolDeg (dLinTol e dAngTol sono per lavo con gen tool), bType
|
||||
if ( vsParams.size() != 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3019,7 +3019,7 @@ bool GdbExecutor::VolZmapDeepnessMeasure( const STRVECTOR& vsParams) {
|
||||
VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
if ( pZmap == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3051,7 +3051,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
|
||||
VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
if ( pZmap == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
// recupero il riferimento in cui è immerso lo Zmap
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3096,7 +3096,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
|
||||
// VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
// if ( pZmap == nullptr)
|
||||
// return false ;
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// Frame3d frRef ;
|
||||
// if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
// return false ;
|
||||
@@ -3143,7 +3143,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
|
||||
// VolZmap* pZmap = GetBasicVolZmap( m_pGDB->GetGeoObj( nZmapId)) ;
|
||||
// if ( pZmap == nullptr)
|
||||
// return false;
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// // recupero il riferimento in cui è immerso lo Zmap
|
||||
// Frame3d frRef ;
|
||||
// if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
// return false ;
|
||||
@@ -3213,7 +3213,7 @@ GdbExecutor::LineDiscInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptDisc, ptLine, vtDisc, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3281,7 +3281,7 @@ GdbExecutor::RayDiscInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptDisc, ptLine, vtDisc, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3349,7 +3349,7 @@ GdbExecutor::SegmentDiscInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptDisc, ptLine, vtDisc, vtLine, dRad, dLen
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3421,7 +3421,7 @@ GdbExecutor::LineSphereInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptC, ptP, vtV, dRad
|
||||
if ( vsParams.size() < 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3472,7 +3472,7 @@ GdbExecutor::RaySphereInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptC, ptP, vtV, dRad
|
||||
if ( vsParams.size() < 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3530,7 +3530,7 @@ GdbExecutor::SegmentSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtV, dRad, dLen
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3594,7 +3594,7 @@ GdbExecutor::LineSemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3651,7 +3651,7 @@ GdbExecutor::RaySemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3714,7 +3714,7 @@ GdbExecutor::SegmentSemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad, dLen
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3783,7 +3783,7 @@ GdbExecutor::LinCompSemiSphereInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptC, ptP, vtSphOr, vtV, dRad, dLen, nLinType
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3854,7 +3854,7 @@ GdbExecutor::LineInfiniteCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3923,7 +3923,7 @@ GdbExecutor::RayInfiniteCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad
|
||||
if ( vsParams.size() < 7)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -3992,7 +3992,7 @@ GdbExecutor::SegmentInfiniteCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad, dLen
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4064,7 +4064,7 @@ GdbExecutor::SegmentCylinderInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptCyl, ptLine, vtCyl, vtLine, dRad, dCylHeigth, dLen
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4140,7 +4140,7 @@ GdbExecutor::SegmentConeInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptVCone, ptLine, vtCone, vtLine, dRad, dCylHeigth, dLen
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4221,7 +4221,7 @@ GdbExecutor::LineTruncateConeInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptMinBase, ptLine, vtCone, vtLine, dMinRad, dMaxRad, dConeHeigth
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4303,7 +4303,7 @@ GdbExecutor::RayTruncateConeInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptMinBase, ptLine, vtCone, vtLine, dMinRad, dMaxRad, dConeHeigth
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4384,7 +4384,7 @@ GdbExecutor::SegmentTruncateConeInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptMinBase, ptLine, vtCone, vtLine, dMinRad, dMaxRad, dConeHeigth
|
||||
if ( vsParams.size() < 10)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4469,7 +4469,7 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams)
|
||||
{ // parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad,
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4584,7 +4584,7 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad,
|
||||
if ( vsParams.size() < 8)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4734,7 +4734,7 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad, dSgLen
|
||||
if ( vsParams.size() < 9)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -4903,7 +4903,7 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams)
|
||||
// parametri : Id, IdParent, ptTorus, ptLine, vtTorus, vtLine, dMinRad, dMaxRad, dSgLen, nLinType
|
||||
if ( vsParams.size() < 10)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5124,7 +5124,7 @@ GdbExecutor::ExecuteDistPointTrimesh( const std::string& sCmd2, const STRVECTOR&
|
||||
// parametri : Id, IdMovedTria, IdParent, ptP, idSurf
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5228,7 +5228,7 @@ GdbExecutor::TextSimple( const STRVECTOR& vsParams)
|
||||
// parametri : Id, ParentId, Text, Point, AngDeg, H
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5266,7 +5266,7 @@ GdbExecutor::TextComplete( const STRVECTOR& vsParams)
|
||||
// parametri : Id, ParentId, Text, Point, AngDeg, Font, W, Italic, H, Rat, AddAdv, PosIns
|
||||
if ( vsParams.size() != 12)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
@@ -5486,7 +5486,7 @@ GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGe
|
||||
// creo il gruppo
|
||||
int nId = GetIdParam( sId, true) ;
|
||||
int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ;
|
||||
// se nId da calcolare, può essere una variabile a cui cambiare il valore
|
||||
// se nId da calcolare, può essere una variabile a cui cambiare il valore
|
||||
if ( nId == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( sId, nIdNew) ;
|
||||
|
||||
@@ -5600,9 +5600,9 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
int nIdEnt = GetIdParam( vsParams[0]) ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -5623,7 +5623,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se entità geometrica
|
||||
// se entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( nIdEnt)) != nullptr) {
|
||||
// se curva
|
||||
@@ -5659,7 +5659,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
return false ;
|
||||
return vtV.LocToLoc( frEnt, frVect) ;
|
||||
}
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
{
|
||||
// secondo parametro : punto di riferimento
|
||||
Point3d ptRef ;
|
||||
@@ -5669,7 +5669,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
ICurve::Side nSide = ICurve::FROM_MINUS ;
|
||||
if ( vsParams.size() >= 3 && vsParams[2] == "+")
|
||||
nSide = ICurve::FROM_PLUS ;
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptRef, *pCrv) ;
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
@@ -5723,7 +5723,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// altrimenti nome di vettore già nel DB
|
||||
// altrimenti nome di vettore già nel DB
|
||||
else {
|
||||
int nIdEnt = GetIdParam( sParam) ;
|
||||
const IGeoVector3d* pV ;
|
||||
@@ -5742,7 +5742,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
|
||||
bool
|
||||
GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& ptP)
|
||||
{
|
||||
// se insieme di 2 o 3 coordinate (considerate già nel riferimento frPnt)
|
||||
// se insieme di 2 o 3 coordinate (considerate già nel riferimento frPnt)
|
||||
if ( sParam[0] == '(') {
|
||||
// divido in parti
|
||||
STRVECTOR vsParams ;
|
||||
@@ -5766,7 +5766,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
// se altrimenti punto predefinito ORIG (considerato già nel riferimento frPnt)
|
||||
// se altrimenti punto predefinito ORIG (considerato già nel riferimento frPnt)
|
||||
else if ( sParam == "ORIG") {
|
||||
ptP = ORIG ;
|
||||
return true ;
|
||||
@@ -5784,9 +5784,9 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
// recupero l'indice dell'entità indicata dal primo parametro
|
||||
int nIdEnt = GetIdParam( vsParams[0]) ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -5801,7 +5801,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se entità geometrica
|
||||
// se entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( nIdEnt)) != nullptr) {
|
||||
// se curva
|
||||
@@ -5835,13 +5835,13 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
return false ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
}
|
||||
case 'N' : // punto più vicino a punto dato
|
||||
case 'N' : // punto più vicino a punto dato
|
||||
{
|
||||
// secondo parametro : punto di riferimento
|
||||
Point3d ptRef ;
|
||||
if ( vsParams.size() < 2 || ! GetPointParam( vsParams[1], frEnt, ptRef))
|
||||
return false ;
|
||||
// calcolo il punto della curva più vicino al punto di riferimento
|
||||
// calcolo il punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptRef, *pCrv) ;
|
||||
int nFlag ;
|
||||
if ( ! dstPC.GetMinDistPoint( 0, ptP, nFlag))
|
||||
@@ -5859,11 +5859,11 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
const ICurve* pCrv2 = GetCurve( pGObj2) ;
|
||||
if ( pCrv2 == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt2 ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt2, frEnt2))
|
||||
return false ;
|
||||
// se il riferimento è diverso da quello della prima entità, devo trasformarla
|
||||
// se il riferimento è diverso da quello della prima entità, devo trasformarla
|
||||
PtrOwner<ICurve> pcrvTrans( nullptr) ;
|
||||
if ( ! AreSameFrame( frEnt, frEnt2)) {
|
||||
pcrvTrans.Set( pCrv2->Clone()) ;
|
||||
@@ -5876,7 +5876,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
Point3d ptRef ;
|
||||
if ( vsParams.size() >= 3 && ! GetPointParam( vsParams[2], frEnt, ptRef))
|
||||
return false ;
|
||||
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
||||
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
||||
IntersCurveCurve intCC( *pCrv, *pCrv2, true) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptRef, ptP))
|
||||
return false ;
|
||||
@@ -5938,7 +5938,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// altrimenti nome di punto già nel DB
|
||||
// altrimenti nome di punto già nel DB
|
||||
else {
|
||||
int nIdEnt = GetIdParam( sParam) ;
|
||||
const IGeoPoint3d* pPt ;
|
||||
@@ -6015,7 +6015,7 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d
|
||||
FromString( vsParams[1], ptP.y) &&
|
||||
FromString( vsParams[2], dW)) ;
|
||||
}
|
||||
// se 2 parti, nome di punto predefinito, punto notevole o già nel DB e un peso
|
||||
// se 2 parti, nome di punto predefinito, punto notevole o già nel DB e un peso
|
||||
else if ( vsParams.size() == 2) {
|
||||
// recupero il punto
|
||||
if ( ! GetPointParam( vsParams[0], frPnt, ptP))
|
||||
@@ -6065,7 +6065,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) == nullptr)
|
||||
return false ;
|
||||
@@ -6088,7 +6088,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) == nullptr)
|
||||
return false ;
|
||||
@@ -6124,12 +6124,12 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
// ci deve essere almeno un parametro
|
||||
if ( vsParams.size() < 1)
|
||||
return false ;
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
// recupero l'entità indicata dal primo parametro
|
||||
int nIdEnt = GetIdParam( vsParams[0]) ;
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGDB->GetGeoObj( nIdEnt)) == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immersa
|
||||
// recupero il riferimento in cui è immersa
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -6143,7 +6143,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
if ( ! pCrv->GetStartDir( vtDir) || ! vtDir.LocToLoc( frEnt, frDir))
|
||||
return false ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6154,7 +6154,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
if ( ! pCrv->GetEndDir( vtDir) || ! vtDir.LocToLoc( frEnt, frDir))
|
||||
return false ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6165,7 +6165,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
if ( ! pCrv->GetMidDir( vtDir) || ! vtDir.LocToLoc( frEnt, frDir))
|
||||
return false ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6196,7 +6196,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
case 'N' : // versore direzione nel punto più vicino a punto dato
|
||||
{
|
||||
// secondo parametro : punto di riferimento
|
||||
Point3d ptRef ;
|
||||
@@ -6206,7 +6206,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
ICurve::Side nSide = ICurve::FROM_MINUS ;
|
||||
if ( vsParams.size() >= 3 && vsParams[2] == "+")
|
||||
nSide = ICurve::FROM_PLUS ;
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
// calcolo il parametro del punto della curva più vicino al punto di riferimento
|
||||
DistPointCurve dstPC( ptRef, *pCrv) ;
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
@@ -6236,7 +6236,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
|
||||
Vector3d vtDir = pGVect->GetVector() ;
|
||||
vtDir.LocToLoc( frEnt, frDir) ;
|
||||
vtDir.ToSpherical( nullptr, nullptr, &dDir) ;
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
// se esiste un secondo parametro è un offset di rotazione
|
||||
if ( vsParams.size() >= 2) {
|
||||
double dOffsetDeg = 0 ;
|
||||
FromString( vsParams[1], dOffsetDeg) ;
|
||||
@@ -6294,7 +6294,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
STRVECTOR::iterator Iter ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n") ;
|
||||
// se c'è un parametro è l'origine
|
||||
// se c'è un parametro è l'origine
|
||||
Point3d ptOrig ;
|
||||
if ( vsParams.size() >= 1) {
|
||||
if ( ! GetPointParam( vsParams[0], frRef, ptOrig))
|
||||
@@ -6325,11 +6325,11 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
// altrimenti nome di gruppo o di frame già nel DB
|
||||
// altrimenti nome di gruppo o di frame già nel DB
|
||||
else {
|
||||
// identificativo
|
||||
int nIdEnt = GetIdParam( sParam) ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frEnt ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt, frEnt))
|
||||
return false ;
|
||||
@@ -6337,7 +6337,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
|
||||
if ( m_pGDB->GetGroupFrame( nIdEnt, frF)) {
|
||||
return frF.LocToLoc( frEnt, frRef) ;
|
||||
}
|
||||
// altrimenti entità geometrica
|
||||
// altrimenti entità geometrica
|
||||
else {
|
||||
// verifico se riferimento
|
||||
const IGeoFrame3d* pFr ;
|
||||
@@ -6393,7 +6393,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
|
||||
// ci deve essere un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero il colore dell'entità indicata dal parametro
|
||||
// recupero il colore dell'entità indicata dal parametro
|
||||
bByParent = false ;
|
||||
return m_pGDB->GetCalcMaterial( GetIdParam( vsParams[0]), cCol) ;
|
||||
}
|
||||
@@ -6427,7 +6427,7 @@ GdbExecutor::GetMaterialParam( const string& sParam, bool& bByParent, int& nMat)
|
||||
// ci deve essere un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero il materiale dell'entità indicata dal parametro
|
||||
// recupero il materiale dell'entità indicata dal parametro
|
||||
bByParent = false ;
|
||||
return ( m_pGDB->GetCalcMaterial( GetIdParam( vsParams[0]), nMat) && nMat != GDB_MT_COLOR) ;
|
||||
}
|
||||
@@ -6975,7 +6975,7 @@ GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
nIdNew = m_pGDB->CopyGlob( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
|
||||
else
|
||||
nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
|
||||
// se IdDest da calcolare, può essere una variabile a cui cambiare il valore
|
||||
// se IdDest da calcolare, può essere una variabile a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[1], nIdNew) ;
|
||||
|
||||
@@ -7647,7 +7647,7 @@ GdbExecutor::CurveCopyBySplitClass( const STRVECTOR& vsParams)
|
||||
IntersCurveCurve intCC( *pCrv, *pCloCrv, true) ;
|
||||
// recupero la classificazione della prima curva
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! intCC.GetCurveClassification( 0, EPS_SMALL, ccClass))
|
||||
if ( ! intCC.GetCurveClassification( 0, ccClass))
|
||||
return false ;
|
||||
// recupero gli indici dei gruppi destinazione e i loro riferimenti
|
||||
const int N_GRP = 4 ;
|
||||
@@ -7877,7 +7877,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// devono essere 6 parametri : IdText, IdGroup, IdEnt1, IdEnt2, ptText, hText
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero l'indice delle entità
|
||||
// recupero l'indice delle entità
|
||||
int nIdEnt1 = GetIdParam( vsParams[2]) ;
|
||||
int nIdEnt2 = GetIdParam( vsParams[3]) ;
|
||||
// verifico siano due curve
|
||||
@@ -7894,7 +7894,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
Frame3d frEnt2 ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdEnt2, frEnt2))
|
||||
return false ;
|
||||
// se i riferimenti sono diversi, porto la seconda entità nel riferimento della prima
|
||||
// se i riferimenti sono diversi, porto la seconda entità nel riferimento della prima
|
||||
PtrOwner<ICurve> pcrvTrans ;
|
||||
if ( ! AreSameFrame( frEnt1, frEnt2)) {
|
||||
pcrvTrans.Set( pCrv2->Clone()) ;
|
||||
@@ -7953,7 +7953,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
// recupero il riferimento in cui è immerso il testo
|
||||
// recupero il riferimento in cui è immerso il testo
|
||||
Frame3d frText ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frText))
|
||||
return false ;
|
||||
@@ -8090,7 +8090,7 @@ bool
|
||||
GdbExecutor::OutGroupTsc( int nId, int nFlag, int nLev)
|
||||
{
|
||||
m_OutTsc.Remark( "Start Group ---") ;
|
||||
// emetto dati gruppo ( se non è radice)
|
||||
// emetto dati gruppo ( se non è radice)
|
||||
if ( nId > GDB_ID_ROOT) {
|
||||
Frame3d frFrame ;
|
||||
if ( ( nLev == 0 && m_pGDB->GetGroupGlobFrame( nId, frFrame)) ||
|
||||
@@ -8113,7 +8113,7 @@ GdbExecutor::OutGroupTsc( int nId, int nFlag, int nLev)
|
||||
}
|
||||
}
|
||||
}
|
||||
// emetto entità gruppo
|
||||
// emetto entità gruppo
|
||||
m_OutTsc.Remark( "Entities :") ;
|
||||
GdbIterator Iter( m_pGDB) ;
|
||||
bool bNext = Iter.GoToFirstInGroup( nId) ;
|
||||
|
||||
+2
-3
@@ -32,9 +32,8 @@ using namespace std ;
|
||||
//----------------------------------------------------------------------------
|
||||
GdbObj::GdbObj( void)
|
||||
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_pTxrData( nullptr), m_pUserObj( nullptr),
|
||||
m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr),
|
||||
m_pSelNext( nullptr), m_pSelPrev( nullptr)
|
||||
|
||||
m_pSelPrev( nullptr), m_pSelNext( nullptr),
|
||||
m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_FRAME3D, NGE_G_FRM, GeoFrame3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoFrame3d::GeoFrame3d( void)
|
||||
: m_frF()
|
||||
: m_frF(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -116,8 +114,7 @@ GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
|
||||
{
|
||||
if ( &gfSrc == this)
|
||||
return true ;
|
||||
m_nTempProp[0] = gfSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = gfSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = gfSrc.m_nTempProp ;
|
||||
return Set( gfSrc.m_frF) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -57,11 +57,10 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IGeoFrame3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -96,5 +95,5 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Frame3d m_frF ; // oggetto
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+2
-5
@@ -28,10 +28,8 @@ GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoPoint3d::GeoPoint3d( void)
|
||||
: m_ptP()
|
||||
: m_ptP(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -84,8 +82,7 @@ GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return Set( clSrc.m_ptP) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -57,11 +57,10 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IGeoPoint3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -90,5 +89,5 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Point3d m_ptP ; // oggetto
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+2
-5
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_VECT3D, NGE_G_VEC, GeoVector3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoVector3d::GeoVector3d( void)
|
||||
: m_vtV()
|
||||
: m_vtV(), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -100,8 +98,7 @@ GeoVector3d::CopyFrom( const GeoVector3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
return Set( clSrc.m_vtV, clSrc.m_ptBase) ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -65,11 +65,10 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IGeoVector3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -105,5 +104,5 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Vector3d m_vtV ; // oggetto
|
||||
Point3d m_ptBase ; // punto base da cui tracciare il vettore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
+8
-10
@@ -391,7 +391,7 @@ IntersCurveCurve::GetIntersPointNearTo( int nCrv, const Point3d& ptNear, Point3d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::GetCurveClassification( int nCrv, double dLenMin, CRVCVECTOR& ccClass)
|
||||
IntersCurveCurve::GetCurveClassification( int nCrv, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// pulisco vettore classificazioni
|
||||
ccClass.clear() ;
|
||||
@@ -407,7 +407,7 @@ IntersCurveCurve::GetCurveClassification( int nCrv, double dLenMin, CRVCVECTOR&
|
||||
return false ;
|
||||
// se esiste almeno una intersezione
|
||||
if ( m_nIntersCount >= 1)
|
||||
return CalcCurveClassification( m_pCurve[0], m_Info, dLenMin, ccClass) ;
|
||||
return CalcCurveClassification( m_pCurve[0], m_Info, ccClass) ;
|
||||
// altrimenti la curva è completamente interna oppure completamente esterna
|
||||
else
|
||||
return CalcCurveInOrOut( m_pCurve[0], m_pCurve[1], ccClass) ;
|
||||
@@ -424,7 +424,7 @@ IntersCurveCurve::GetCurveClassification( int nCrv, double dLenMin, CRVCVECTOR&
|
||||
SwapInfoAB( InfoTmp, 1) ;
|
||||
// se esiste almeno una intersezione
|
||||
if ( m_nIntersCount >= 1)
|
||||
return CalcCurveClassification( m_pCurve[1], InfoTmp, dLenMin, ccClass) ;
|
||||
return CalcCurveClassification( m_pCurve[1], InfoTmp, ccClass) ;
|
||||
// altrimenti la curva è completamente interna oppure completamente esterna
|
||||
else
|
||||
return CalcCurveInOrOut( m_pCurve[1], m_pCurve[0], ccClass) ;
|
||||
@@ -461,7 +461,7 @@ IntersCurveCurve::SwapInfoAB( ICCIVECTOR& Info, int IndCrvOrd)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTOR& Info, double dLenMin, CRVCVECTOR& ccClass)
|
||||
IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTOR& Info, CRVCVECTOR& ccClass)
|
||||
{
|
||||
// numero intersezioni
|
||||
int nNumInters = int( Info.size()) ;
|
||||
@@ -471,8 +471,6 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
double dStartPar, dEndPar ;
|
||||
if ( pCurve == nullptr || ! pCurve->GetDomain( dStartPar, dEndPar))
|
||||
return false ;
|
||||
// limito lunghezza minima
|
||||
dLenMin = max( dLenMin, EPS_ZERO) ;
|
||||
// elimino intersezioni senza attraversamento che giacciono in intervalli di sovrapposizione
|
||||
ICCIVECTOR InfoCorr ;
|
||||
InfoCorr.reserve( Info.size()) ;
|
||||
@@ -529,7 +527,7 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
for ( int i = 0 ; i < nNumInters ; ++ i) {
|
||||
// se è definito un tratto precedente
|
||||
double dLenU ; pCurve->GetLengthAtParam( InfoCorr[i].IciA[0].dU, dLenU) ;
|
||||
if ( InfoCorr[i].IciA[0].dU > dCurrPar + EPS_PARAM && dLenU - dCurrLen > dLenMin) {
|
||||
if ( InfoCorr[i].IciA[0].dU > dCurrPar + EPS_PARAM && dLenU - dCurrLen > EPS_SMALL) {
|
||||
// verifico che la definizione sul tratto sia omogenea e valida
|
||||
int nPrevTy = InfoCorr[i].IciA[0].nPrevTy ;
|
||||
if ( ( nLastTy != ICCT_NULL && nPrevTy != nLastTy) ||
|
||||
@@ -564,7 +562,7 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
}
|
||||
}
|
||||
// eventuale tratto finale rimasto
|
||||
if ( dCurrPar < dEndPar - EPS_PARAM && dEndLen - dCurrLen > dLenMin) {
|
||||
if ( dCurrPar < dEndPar - EPS_PARAM && dEndLen - dCurrLen > EPS_SMALL) {
|
||||
// verifico che la definizione sul tratto sia valida
|
||||
if ( nLastTy == ICCT_NULL || nLastTy == ICCT_ON)
|
||||
return false ;
|
||||
@@ -675,7 +673,7 @@ IntersCurveCurve::GetRegionCurveClassification( void)
|
||||
{
|
||||
// classifico la prima curva rispetto alla seconda
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! GetCurveClassification( 0, EPS_SMALL, ccClass))
|
||||
if ( ! GetCurveClassification( 0, ccClass))
|
||||
return CCREGC_NULL ;
|
||||
// derivo la classificazione delle curve come regioni
|
||||
bool bIn = false ;
|
||||
@@ -712,7 +710,7 @@ IntersCurveCurve::GetRegionCurveClassification( void)
|
||||
if ( bOnP)
|
||||
return CCREGC_IN2 ;
|
||||
CRVCVECTOR ccClass2 ;
|
||||
if ( ! GetCurveClassification( 1, EPS_SMALL, ccClass2) || ccClass2.empty())
|
||||
if ( ! GetCurveClassification( 1, ccClass2) || ccClass2.empty())
|
||||
return CCREGC_NULL ;
|
||||
if ( ccClass2[0].nClass == CRVC_OUT)
|
||||
return CCREGC_OUT ;
|
||||
|
||||
+15
-52
@@ -68,36 +68,18 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
{
|
||||
// pulisco tutto
|
||||
Reset() ;
|
||||
// verifico se la curva è un segmento di retta
|
||||
bool bIsLine = false ;
|
||||
const CurveLine* pLine = GetBasicCurveLine( pCrv) ;
|
||||
if ( pLine != nullptr)
|
||||
bIsLine = true ;
|
||||
else {
|
||||
const CurveComposite* pCompo = GetBasicCurveComposite( pCrv) ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd))
|
||||
bIsLine = true ;
|
||||
}
|
||||
// verifico che la curva esista e sia piana
|
||||
Plane3d plPlane ;
|
||||
if ( pCrv == nullptr || ! pCrv->IsFlat( plPlane, bIsLine, 10 * EPS_SMALL))
|
||||
if ( pCrv == nullptr || ! pCrv->IsFlat( plPlane))
|
||||
return false ;
|
||||
// recupero o assegno estrusione
|
||||
// se esiste estrusione, verifico sia perpendicolare al piano della curva
|
||||
Vector3d vtExtr ;
|
||||
if ( ! pCrv->GetExtrusion( vtExtr) || vtExtr.IsSmall()) {
|
||||
vtExtr = plPlane.GetVersN() ;
|
||||
if ( vtExtr.IsZminus())
|
||||
vtExtr.Invert() ;
|
||||
if ( pCrv->GetExtrusion( vtExtr) && ! vtExtr.IsSmall()) {
|
||||
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtExtr))
|
||||
return false ;
|
||||
}
|
||||
// recupero normale al piano della curva
|
||||
Vector3d vtNorm = plPlane.GetVersN() ;
|
||||
if ( vtNorm * vtExtr < 0)
|
||||
vtNorm.Invert() ;
|
||||
// verifico che estrusione non sia troppo vicina al piano della curva (almeno 30 gradi di angolazione)
|
||||
double dExtrOnN = vtExtr * vtNorm ;
|
||||
if ( dExtrOnN < 0.5)
|
||||
return false ;
|
||||
else
|
||||
vtExtr = plPlane.GetVersN() ;
|
||||
// recupero spessore
|
||||
double dThick ;
|
||||
pCrv->GetThickness( dThick) ;
|
||||
@@ -120,9 +102,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
// determino se necessario cambiare riferimento ( dal vettore estrusione)
|
||||
bool bNeedRef = ( ! vtExtr.IsZplus()) ;
|
||||
|
||||
// determino se necessario effettuare scalatura
|
||||
bool bNeedScale = ( abs( dExtrOnN) < cos( 0.1 * DEGTORAD)) ;
|
||||
|
||||
// creo una copia della curva
|
||||
CurveComposite ccCopy ;
|
||||
if ( ! ccCopy.CopyFrom( pCrv))
|
||||
@@ -130,23 +109,13 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
ccCopy.SetExtrusion( vtExtr) ;
|
||||
|
||||
// se necessario cambio il riferimento
|
||||
Frame3d frCopy ;
|
||||
if ( bNeedScale) {
|
||||
// calcolo il riferimento con vtNorm come asse Z e componente di vtExtr perpendicolare a vtNorm come asse X
|
||||
if ( ! frCopy.Set( ORIG, vtNorm, vtExtr - dExtrOnN * vtNorm))
|
||||
return false ;
|
||||
ccCopy.SetExtrusion( vtNorm) ;
|
||||
// esprimo la curva in questo riferimento
|
||||
ccCopy.ToLoc( frCopy) ;
|
||||
// scalo lungo l'asse X locale
|
||||
ccCopy.Scale( GLOB_FRM, dExtrOnN, 1, 1) ;
|
||||
}
|
||||
else if ( bNeedRef) {
|
||||
Frame3d frExtr ;
|
||||
if ( bNeedRef) {
|
||||
// calcolo il riferimento OCS con VtExtr come asse Z
|
||||
if ( ! frCopy.Set( ORIG, vtExtr))
|
||||
if ( ! frExtr.Set( ORIG, vtExtr))
|
||||
return false ;
|
||||
// esprimo la curva in questo riferimento
|
||||
ccCopy.ToLoc( frCopy) ;
|
||||
ccCopy.ToLoc( frExtr) ;
|
||||
}
|
||||
|
||||
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+)
|
||||
@@ -460,7 +429,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
inOk.Set( dStart, dEnd) ;
|
||||
IntersCurveCurve ccInt( *pCrv, *pCircS) ;
|
||||
CRVCVECTOR ccPart ;
|
||||
if ( ! ccInt.GetCurveClassification( 0, EPS_SMALL, ccPart))
|
||||
if ( ! ccInt.GetCurveClassification( 0, ccPart))
|
||||
return false ;
|
||||
for ( auto& ccOne : ccPart) {
|
||||
switch ( ccOne.nClass) {
|
||||
@@ -509,7 +478,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
inOk.Set( dStart, dEnd) ;
|
||||
IntersCurveCurve ccInt( *pCrv, *pCircE) ;
|
||||
CRVCVECTOR ccPart ;
|
||||
if ( ! ccInt.GetCurveClassification( 0, EPS_SMALL, ccPart))
|
||||
if ( ! ccInt.GetCurveClassification( 0, ccPart))
|
||||
return false ;
|
||||
for ( auto& ccOne : ccPart) {
|
||||
switch ( ccOne.nClass) {
|
||||
@@ -632,15 +601,9 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
||||
}
|
||||
|
||||
// riporto il risultato nel riferimento originale
|
||||
if ( bNeedScale) {
|
||||
for ( auto pCrv : m_CrvLst) {
|
||||
pCrv->Scale( GLOB_FRM, 1 / dExtrOnN, 1, 1) ;
|
||||
pCrv->ToGlob( frCopy) ;
|
||||
}
|
||||
}
|
||||
else if ( bNeedRef) {
|
||||
if ( bNeedRef) {
|
||||
for ( auto pCrv : m_CrvLst)
|
||||
pCrv->ToGlob( frCopy) ;
|
||||
pCrv->ToGlob( frExtr) ;
|
||||
}
|
||||
|
||||
// assegno estrusione e spessore come curva originale
|
||||
|
||||
+297
-190
@@ -23,6 +23,7 @@
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -830,11 +831,12 @@ PolyLine::MyChangeStart( int nPos)
|
||||
// solo per polilinee chiuse
|
||||
if ( ! IsClosed())
|
||||
return false ;
|
||||
// cancello l'ultimo punto ( coincide con il primo)
|
||||
// cancello ultimo punto ( coincide con primo)
|
||||
m_lUPoints.pop_back() ;
|
||||
// sposto la parte iniziale dei punti alla fine
|
||||
m_lUPoints.splice( m_lUPoints.end(), m_lUPoints, m_lUPoints.begin(), next( m_lUPoints.begin(), nPos)) ;
|
||||
// aggiungo il punto finale come copia dell'iniziale
|
||||
// sposto la metà iniziale dei punti alla fine
|
||||
for ( int i = 0 ; i < nPos ; ++ i)
|
||||
m_lUPoints.splice( m_lUPoints.end(), m_lUPoints, m_lUPoints.begin()) ;
|
||||
// aggiungo punto finale come copia dell'iniziale
|
||||
m_lUPoints.push_back( m_lUPoints.front()) ;
|
||||
|
||||
return true ;
|
||||
@@ -1297,220 +1299,325 @@ PolyLine::Trim( const Plane3d& plPlane, bool bInVsOut)
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dDist)
|
||||
/*static*/ bool
|
||||
ChangePolyLineStart( const Point3d& ptNewStart, PolyLine& Loop, double dTol)
|
||||
{
|
||||
// La polilinea deve contenere almeno due punti
|
||||
if ( plPoly.GetPointNbr() < 2)
|
||||
return false ;
|
||||
// Ciclo sui punti della polilinea
|
||||
dDist = INFINITO ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
plPoly.GetFirstPoint( ptStart) ;
|
||||
while ( plPoly.GetNextPoint( ptEnd)) {
|
||||
// distanza del punto dal segmento della polilinea
|
||||
DistPointLine PointLineDistCalc( ptP, ptStart, ptEnd) ;
|
||||
double dPlDist ;
|
||||
PointLineDistCalc.GetDist( dPlDist) ;
|
||||
if ( dPlDist < dDist)
|
||||
dDist = dPlDist ;
|
||||
// assegno nuovo inizio
|
||||
ptStart = ptEnd ;
|
||||
// Rinomino la lista di punti della PolyLine.
|
||||
PNTULIST& LoopList = Loop.GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
auto itMinDist = LoopList.end() ;
|
||||
auto itSt = LoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptNewStart, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDist = itSt ;
|
||||
}
|
||||
}
|
||||
// Se il punto non sta sul loop, errore
|
||||
if ( dMinSqDist > dTol * dTol)
|
||||
return false ;
|
||||
// Se il punto non sta su un vertice del segmento, lo aggiungo. Altrimenti non devo fare nulla.
|
||||
auto itNewPointSt = LoopList.begin() ;
|
||||
auto itNext = itMinDist ;
|
||||
++ itNext ;
|
||||
bool bOnStart = AreSamePointApprox( ptNewStart, itMinDist->first) ;
|
||||
bool bOnEnd = AreSamePointApprox( ptNewStart, itNext->first) ;
|
||||
itNewPointSt = LoopList.emplace( itNext, ptNewStart, 0) ;
|
||||
// Sposto i punti precedenti in coda.
|
||||
bool bStartRemoved = false ;
|
||||
auto it = LoopList.begin() ;
|
||||
while ( it != itNewPointSt) {
|
||||
if ( bStartRemoved) {
|
||||
LoopList.emplace_back( it->first, it->second) ;
|
||||
}
|
||||
bStartRemoved = true ;
|
||||
it = LoopList.erase( it) ;
|
||||
}
|
||||
// Se il punto inserito non coincide con l'inizio del segmento chiudo il loop.
|
||||
if ( ! bOnStart) {
|
||||
LoopList.emplace_back( ptNewStart, 0) ;
|
||||
// Se coincide con la fine tolgo il punto di fine che diviene inutile.
|
||||
if ( bOnEnd) {
|
||||
//LoopList.erase( itNext) ;
|
||||
auto itNewStart = LoopList.begin() ;
|
||||
++ itNewStart ;
|
||||
LoopList.erase( itNewStart) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler)
|
||||
// nSegNum 0-based
|
||||
/*static*/ bool
|
||||
PointPositionOnPolyLine( const Point3d& ptPoint, /*const*/ PolyLine& Loop, int& nSegNum, double& dParOnSeg, double dTol)
|
||||
{
|
||||
// La polilinea deve essere chiusa e piatta, altrimenti non ha senso parlare di interno
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
if ( ! plPoly.IsClosedAndFlat( plPlane, dArea, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
// Impongo l'orientamento CCW
|
||||
if ( dArea < 0)
|
||||
plPlane.Invert() ;
|
||||
// Il punto deve giacere nel piano della polilinea
|
||||
if ( ! PointInPlaneEpsilon( ptP, plPlane, 10 * EPS_SMALL))
|
||||
return false ;
|
||||
// Riferimento alla lista dei punti
|
||||
PNTULIST& List = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
Point3d ptMinDist ;
|
||||
auto itMinDistEnd = List.end() ;
|
||||
auto itStart = List.begin() ;
|
||||
auto itEnd = next( itStart) ;
|
||||
for ( ; itEnd != List.end() ; ++ itStart, ++ itEnd) {
|
||||
// Distanza del punto dal segmento corrente
|
||||
DistPointLine dDistCalc( ptP, itStart->first, itEnd->first) ;
|
||||
// Rinomino la lista di punti della PolyLine.
|
||||
/*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
|
||||
nSegNum = - 1 ;
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
int nS = 0 ;
|
||||
auto itMinDistSt = LoopList.end() ;
|
||||
auto itMinDistEn = itMinDistSt ;
|
||||
auto itSt = LoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn, ++ nS) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
nSegNum = nS ;
|
||||
dMinSqDist = dSqDist ;
|
||||
dDistCalc.GetMinDistPoint( ptMinDist) ;
|
||||
itMinDistEnd = itEnd ;
|
||||
itMinDistSt = itSt ;
|
||||
itMinDistEn = itEn ;
|
||||
}
|
||||
}
|
||||
// Determino tangente di riferimento
|
||||
Vector3d vtTang ;
|
||||
// se minima distanza nell'estremo iniziale del segmento
|
||||
if ( AreSamePointApprox( ptMinDist, prev( itMinDistEnd)->first)) {
|
||||
// direzione del segmento
|
||||
Vector3d vtCurrTg = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
vtCurrTg.Normalize() ;
|
||||
// direzione del segmento precedente
|
||||
Vector3d vtPrevTg ;
|
||||
if ( prev( itMinDistEnd) != List.begin())
|
||||
vtPrevTg = prev( itMinDistEnd)->first - prev( itMinDistEnd, 2)->first ;
|
||||
else
|
||||
vtPrevTg = prev( itMinDistEnd)->first - prev( List.rbegin())->first ;
|
||||
vtPrevTg.Normalize() ;
|
||||
// tangente media
|
||||
vtTang = vtPrevTg + vtCurrTg ;
|
||||
vtTang.Normalize() ;
|
||||
}
|
||||
// se altrimenti minima distanza nell'estremo finale del segmento
|
||||
else if ( AreSamePointApprox( ptMinDist, itMinDistEnd->first)) {
|
||||
// direzione del segmento
|
||||
Vector3d vtCurrTg = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
vtCurrTg.Normalize() ;
|
||||
// direzione del segmento successivo
|
||||
Vector3d vtNextTg ;
|
||||
if ( next( itMinDistEnd) != List.end())
|
||||
vtNextTg = next( itMinDistEnd)->first - itMinDistEnd->first ;
|
||||
else
|
||||
vtNextTg = next( List.begin())->first - itMinDistEnd->first ;
|
||||
vtNextTg.Normalize() ;
|
||||
// tangente media
|
||||
vtTang = vtCurrTg + vtNextTg ;
|
||||
vtTang.Normalize() ;
|
||||
}
|
||||
// altrimenti minima distanza con l'interno
|
||||
else {
|
||||
vtTang = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
}
|
||||
// Determino la posizione del punto
|
||||
Vector3d vtDiff = ptP - ptMinDist ;
|
||||
Vector3d vtOut = vtTang ^ plPlane.GetVersN() ;
|
||||
vtOut.Normalize() ;
|
||||
return ( vtDiff * vtOut < -dToler) ;
|
||||
// Se il punto non sta sul loop, lo segnalo.
|
||||
if ( dMinSqDist > dTol * dTol)
|
||||
return false ;
|
||||
// Calcolo il parametro lungo il segmento.
|
||||
Vector3d vtSeg = itMinDistEn->first - itMinDistSt->first ;
|
||||
double dSegLen = vtSeg.Len() ;
|
||||
if ( dSegLen < EPS_SMALL)
|
||||
return false ;
|
||||
vtSeg /= dSegLen ;
|
||||
dParOnSeg = Clamp( ( ptPoint - itMinDistSt->first) * vtSeg, 0., dSegLen) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GetPointParamOnPolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler, double& dPar)
|
||||
/*static*/ bool
|
||||
IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly)
|
||||
{
|
||||
// La polilinea deve contenere almeno due punti
|
||||
if ( plPoly.GetPointNbr() < 2)
|
||||
return false ;
|
||||
// Ciclo sui punti della polilinea
|
||||
int nSeg = -1 ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
double dMinPar = -1 ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
plPoly.GetFirstPoint( ptStart) ;
|
||||
while ( plPoly.GetNextPoint( ptEnd)) {
|
||||
// aggiorno l'indice
|
||||
++ nSeg ;
|
||||
// distanza del punto dal segmento della polilinea
|
||||
DistPointLine dDistCalc( ptP, ptStart, ptEnd) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
double dSegPar ;
|
||||
dDistCalc.GetParamAtMinDistPoint( dSegPar) ;
|
||||
dMinPar = nSeg + dSegPar ;
|
||||
}
|
||||
// assegno nuovo inizio
|
||||
ptStart = ptEnd ;
|
||||
}
|
||||
// Il punto è sulla linea se la sua distanza rispetta la tolleranza
|
||||
return ( dMinSqDist < dToler * dToler) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ChangePolyLineStart( PolyLine& plPoly, const Point3d& ptNewStart, double dToler)
|
||||
{
|
||||
// La polilinea deve essere chiusa
|
||||
// Se la PolyLine non è chiusa, il punto non può essere interno.
|
||||
if ( ! plPoly.IsClosed())
|
||||
return false ;
|
||||
// Riferimento alla lista dei punti
|
||||
PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
auto itMinDistEnd = LoopList.end() ;
|
||||
auto itStart = LoopList.begin() ;
|
||||
auto itEnd = next( itStart) ;
|
||||
for ( ; itEnd != LoopList.end() ; ++ itStart, ++ itEnd) {
|
||||
// Distanza del punto dal segmento corrente
|
||||
DistPointLine dDistCalc( ptNewStart, itStart->first, itEnd->first) ;
|
||||
// Lista dei punti
|
||||
PolyLine& MyPlPoly = const_cast< PolyLine&>( plPoly) ;
|
||||
const PNTULIST& List = MyPlPoly.GetUPointList() ;
|
||||
// Ciclo sui segmenti della PolyLine per cercarne il tratto più vicino al punto.
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
Point3d ptMinDist ;
|
||||
auto itMinDistSt = List.end() ;
|
||||
auto itSt = List.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != List.end() && itEn != List.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptP, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDistEnd = itEnd ;
|
||||
dDistCalc.GetMinDistPoint( ptMinDist) ;
|
||||
itMinDistSt = itSt ;
|
||||
}
|
||||
}
|
||||
// Se il punto non sta sulla polilinea, non ha senso cambiare l'inizio
|
||||
if ( dMinSqDist > dToler * dToler)
|
||||
return false ;
|
||||
// Se il punto non coincide con un vertice, lo aggiungo
|
||||
auto itNewStart = LoopList.end() ;
|
||||
if ( AreSamePointApprox( ptNewStart, prev( itMinDistEnd)->first))
|
||||
itNewStart = prev( itMinDistEnd) ;
|
||||
else if ( AreSamePointApprox( ptNewStart, itMinDistEnd->first))
|
||||
itNewStart = itMinDistEnd ;
|
||||
else
|
||||
itNewStart = LoopList.emplace( itMinDistEnd, ptNewStart, 0) ;
|
||||
// Cancello l'ultimo punto ( coincide con il primo)
|
||||
LoopList.pop_back() ;
|
||||
// Sposto la parte iniziale dei punti alla fine
|
||||
LoopList.splice( LoopList.end(), LoopList, LoopList.begin(), itNewStart) ;
|
||||
// Aggiungo il punto finale come copia dell'iniziale
|
||||
LoopList.push_back( LoopList.front()) ;
|
||||
|
||||
return true ;
|
||||
// Termine del segmento di minima distanza.
|
||||
auto itMinDistEn = itMinDistSt ;
|
||||
++ itMinDistEn ;
|
||||
// Punto di minima distanza nell'estremo iniziale del segento
|
||||
if ( AreSamePointApprox( ptMinDist, itMinDistSt->first)) {
|
||||
auto itPrevSt = List.begin() ;
|
||||
if ( itMinDistSt == List.begin()) {
|
||||
auto itAuxNext = itPrevSt ;
|
||||
++ ( ++ itAuxNext) ;
|
||||
for ( ; itAuxNext != List.end() ; ++ itPrevSt, ++ itAuxNext)
|
||||
;
|
||||
}
|
||||
else {
|
||||
auto itAuxNext = itPrevSt ;
|
||||
++ itAuxNext ;
|
||||
for (; itAuxNext != itMinDistSt; ++itPrevSt, ++itAuxNext)
|
||||
;
|
||||
}
|
||||
Vector3d vtPrevTan = itMinDistSt->first - itPrevSt->first ;
|
||||
vtPrevTan.Normalize() ;
|
||||
Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
|
||||
vtTan.Normalize() ;
|
||||
Polygon3d AuxPolygon ;
|
||||
AuxPolygon.FromPolyLine( plPoly) ;
|
||||
Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
|
||||
Vector3d vtPrevOut = vtPrevTan ^ vtPolyNorm ;
|
||||
Vector3d vtOut = vtTan ^ vtPolyNorm ;
|
||||
// Caso concavo
|
||||
if ( vtTan * vtPrevOut > 0) {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtPrevOut < 0 || vtTest * vtOut < 0)
|
||||
return true ;
|
||||
}
|
||||
// Caso convesso
|
||||
else {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtPrevOut < 0 && vtTest * vtOut < 0)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Punto di minima distanza nell'estremo finale del segento
|
||||
else if ( AreSamePointApprox( ptMinDist, itMinDistEn->first)) {
|
||||
auto itNextEn = itMinDistEn ;
|
||||
++ itNextEn ;
|
||||
if ( itNextEn == List.end()) {
|
||||
itNextEn = List.begin() ;
|
||||
++ itNextEn ;
|
||||
}
|
||||
Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
|
||||
vtTan.Normalize() ;
|
||||
Vector3d vtNextTan = itNextEn->first - itMinDistEn->first ;
|
||||
vtNextTan.Normalize() ;
|
||||
Polygon3d AuxPolygon ;
|
||||
AuxPolygon.FromPolyLine( plPoly) ;
|
||||
Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
|
||||
Vector3d vtOut = vtTan ^ vtPolyNorm ;
|
||||
Vector3d vtNextOut = vtNextTan ^ vtPolyNorm ;
|
||||
// Caso concavo
|
||||
if ( vtNextTan * vtOut > 0) {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtOut < 0 || vtTest * vtNextOut < 0)
|
||||
return true ;
|
||||
}
|
||||
// Caso convesso
|
||||
else {
|
||||
Vector3d vtTest = ptP - ptMinDist ;
|
||||
if ( vtTest * vtOut < 0 && vtTest * vtNextOut < 0)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Punto di minima distanza interno al segmeno
|
||||
else {
|
||||
Vector3d vtP = ptP - itMinDistSt->first ;
|
||||
Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ;
|
||||
vtTan.Normalize() ;
|
||||
Polygon3d AuxPolygon ;
|
||||
AuxPolygon.FromPolyLine( plPoly) ;
|
||||
Vector3d vtPolyNorm = AuxPolygon.GetVersN() ;
|
||||
Vector3d vtOut = vtTan ^ vtPolyNorm ;
|
||||
vtP -= ( vtP * vtTan) * vtTan ;
|
||||
if ( vtP * vtOut < - EPS_SMALL)
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SplitPolyLineAtPoint( const PolyLine& plPoly, const Point3d& ptP, double dToler, PolyLine& plPoly1, PolyLine& plPoly2)
|
||||
DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dPointPolyLineDist)
|
||||
{
|
||||
// La polilinea deve contenere almeno due punti
|
||||
if ( plPoly.GetPointNbr() < 2)
|
||||
if ( plPoly.GetPointNbr() == 0)
|
||||
return false ;
|
||||
// Riferimento alla lista dei punti
|
||||
const PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
auto itMinDistEnd = LoopList.end() ;
|
||||
auto itStart = LoopList.begin() ;
|
||||
auto itEnd = next( itStart) ;
|
||||
for ( ; itEnd != LoopList.end() ; ++ itStart, ++ itEnd) {
|
||||
// Distanza del punto dal segmento corrente
|
||||
DistPointLine dDistCalc( ptP, itStart->first, itEnd->first) ;
|
||||
double dSqDist ;
|
||||
if ( dDistCalc.GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDistEnd = itEnd ;
|
||||
}
|
||||
dPointPolyLineDist = DBL_MAX ;
|
||||
Point3d ptSt, ptEn ;
|
||||
bool bContinue = plPoly.GetFirstPoint( ptSt) && plPoly.GetNextPoint( ptEn) ;
|
||||
while ( bContinue) {
|
||||
double dPoinLineDist ;
|
||||
DistPointLine PointLineDistCalc( ptP, ptSt, ptEn) ;
|
||||
PointLineDistCalc.GetDist( dPoinLineDist) ;
|
||||
if ( dPoinLineDist < dPointPolyLineDist)
|
||||
dPointPolyLineDist = dPoinLineDist ;
|
||||
ptSt = ptEn ;
|
||||
bContinue = plPoly.GetNextPoint( ptEn) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/*static*/ bool
|
||||
SplitPolyLineAtPoint( const Point3d& ptPoint, /*const*/ PolyLine& Loop, PolyLine& Loop1, PolyLine& Loop2, double dTol)
|
||||
{
|
||||
// Rinomino la lista di punti della PolyLine.
|
||||
/*const*/ PNTULIST& LoopList = Loop.GetUPointList() ;
|
||||
// Ciclo sui segmenti del loop per cercare il tratto del loop chiuso più vicino al punto.
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
auto itMinDistSt = LoopList.end() ;
|
||||
auto itSt = LoopList.begin() ;
|
||||
auto itEn = itSt ;
|
||||
++ itEn ;
|
||||
for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) {
|
||||
// Estremi del segmento corrente del loop
|
||||
Point3d ptSegSt = itSt->first ;
|
||||
Point3d ptSegEn = itEn->first ;
|
||||
// Distanza del punto dal segmento del loop
|
||||
DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ;
|
||||
double dSqDist ;
|
||||
dDistCalc.GetSqDist( dSqDist) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
itMinDistSt = itSt ;
|
||||
}
|
||||
}
|
||||
// Se il punto non sta sul loop, lo segnalo.
|
||||
if ( dMinSqDist > dTol * dTol)
|
||||
return false ;
|
||||
// Se il punto di stop sta su un vertice non devo aggiungerlo e il
|
||||
// punto di stop sarà uno degli estremi del segmento su cui giace.
|
||||
auto itStop = itMinDistSt ;
|
||||
auto itNext = itMinDistSt ;
|
||||
++ itNext ;
|
||||
if ( AreSamePointApprox( ptPoint, itStop->first))
|
||||
;
|
||||
else if ( AreSamePointApprox( ptPoint, itNext->first))
|
||||
itStop = itNext ;
|
||||
else {
|
||||
itStop = LoopList.emplace( itNext, ptPoint, 0.) ;
|
||||
}
|
||||
// Creo i due loop
|
||||
PNTULIST& LoopList1 = Loop1.GetUPointList() ;
|
||||
PNTULIST& LoopList2 = Loop2.GetUPointList() ;
|
||||
for ( auto it = LoopList.begin() ; it != itStop ; ++ it) {
|
||||
LoopList1.emplace_back( it->first, it->second) ;
|
||||
}
|
||||
LoopList1.emplace_back( itStop->first, itStop->second) ;
|
||||
for ( auto it = itStop ; it != LoopList.end() ; ++ it) {
|
||||
LoopList2.emplace_back( it->first, it->second) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/*static*/ bool
|
||||
AddPolyLineToPolyLine( PolyLine& Poly, PolyLine& PolyToAdd, double dTol)
|
||||
{
|
||||
// Se la PolyLine a cui devo aggiungere l'altra è chiusa, non posso aggiungere nulla.
|
||||
if ( Poly.IsClosed())
|
||||
return false ;
|
||||
// Se la PolyLina che devo aggiungere è vuota, ho finito.
|
||||
PNTULIST& PolyToAddList = PolyToAdd.GetUPointList() ;
|
||||
if ( int( PolyToAddList.size()) == 0)
|
||||
return true ;
|
||||
// Se Poly non è vuota e la sua fine non coincide con l'inizio di PolyToAdd, non è possibile aggiungere nulla.
|
||||
Point3d ptLast ;
|
||||
Poly.GetLastPoint( ptLast) ;
|
||||
auto it = PolyToAddList.begin() ;
|
||||
if ( Poly.GetPointNbr() != 0 && ! AreSamePointEpsilon( it->first, ptLast, dTol))
|
||||
return false ;
|
||||
/*if ( Poly.GetPointNbr() == 0)
|
||||
Poly.AddUPoint( 0., it->first) ;
|
||||
++ it ;*/
|
||||
// Aggiungo i punti.
|
||||
for ( ; it != PolyToAddList.end() ; ++ it) {
|
||||
Poly.AddUPoint( 0., it->first) ;
|
||||
}
|
||||
// Se il punto non sta sulla polilinea, non ha senso spezzare
|
||||
if ( dMinSqDist > dToler * dToler)
|
||||
return false ;
|
||||
// Copio i punti opportuni nella prima parte
|
||||
PNTULIST& LoopList1 = plPoly1.GetUPointList() ;
|
||||
for ( auto it = LoopList.begin() ; it != itMinDistEnd ; ++ it)
|
||||
LoopList1.emplace_back( it->first, it->second) ;
|
||||
plPoly1.AddUPoint( 0, ptP) ;
|
||||
// Copio i punti opportuni nella seconda parte
|
||||
PNTULIST& LoopList2 = plPoly2.GetUPointList() ;
|
||||
for ( auto it = itMinDistEnd ; it != LoopList.end() ; ++ it)
|
||||
LoopList2.emplace_back( it->first, it->second) ;
|
||||
plPoly2.AddUPoint( 0, ptP, false) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+10
-46
@@ -17,7 +17,6 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "AdjustLoops.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgkPolyLine.h"
|
||||
#include "/EgtDev/Include/EgkBiArcs.h"
|
||||
@@ -279,34 +278,13 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromTriangle( const Triangle3d& Tria)
|
||||
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||
{
|
||||
// Creo la regione.
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// Creo curva composita.
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pLoop))
|
||||
return nullptr ;
|
||||
if ( ! pLoop->AddPoint( Tria.GetP( 0)) ||
|
||||
! pLoop->AddLine( Tria.GetP( 1)) ||
|
||||
! pLoop->AddLine( Tria.GetP( 2)) ||
|
||||
! pLoop->Close())
|
||||
return nullptr ;
|
||||
pSfr->AddExtLoop( Release( pLoop)) ;
|
||||
return Release( pSfr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||
{
|
||||
// Creo la regione.
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// Creo curva composita.
|
||||
// Creo curva composita.
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pLoop))
|
||||
return nullptr ;
|
||||
@@ -328,13 +306,13 @@ GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||
ISurfFlatRegion*
|
||||
GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
|
||||
{
|
||||
// Creo la regione.
|
||||
// Creo la regione.
|
||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// Ciclo sulle PolyLine.
|
||||
// Ciclo sulle PolyLine.
|
||||
for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) {
|
||||
// Creo curva composita.
|
||||
// Creo curva composita.
|
||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pLoop))
|
||||
return nullptr ;
|
||||
@@ -348,11 +326,11 @@ GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
|
||||
ptSt = ptEn ;
|
||||
bContinue = vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
|
||||
}
|
||||
// Loop esterno
|
||||
// Loop esterno
|
||||
if ( nL == 0) {
|
||||
pSfr->AddExtLoop( Release( pLoop)) ;
|
||||
}
|
||||
// Loop interno
|
||||
// Loop interno
|
||||
else {
|
||||
pSfr->AddIntLoop( Release( pLoop)) ;
|
||||
}
|
||||
@@ -385,20 +363,8 @@ SurfFlatRegionByContours::AddCurve( ICurve* pCrv)
|
||||
// verifico sia chiusa
|
||||
if ( ! pMyCrv->IsClosed())
|
||||
return false ;
|
||||
// verifico sia piana e imposto estrusione come normale al piano
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
if ( ! pMyCrv->GetArea( plPlane, dArea))
|
||||
return false ;
|
||||
pMyCrv->SetExtrusion( plPlane.GetVersN()) ;
|
||||
pMyCrv->SetThickness( 0) ;
|
||||
// rimuovo eventuali sovrapposizioni (calcolate nel suo piano)
|
||||
ICURVEPLIST CrvLst ;
|
||||
if ( ! AdjustLoops( Release( pMyCrv), CrvLst))
|
||||
return false ;
|
||||
// la/le inserisco nel vettore delle curve
|
||||
for ( auto& pSingCrv : CrvLst)
|
||||
m_vpCrv.push_back( pSingCrv) ;
|
||||
// la inserisco nel vettore delle curve
|
||||
m_vpCrv.push_back( Release( pMyCrv)) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -452,7 +418,6 @@ SurfFlatRegionByContours::GetSurf( void)
|
||||
if ( IsNull( pSfr))
|
||||
return nullptr ;
|
||||
// aggiungo le diverse curve
|
||||
bool bExtLoop = false ;
|
||||
bool bFirstCrv ;
|
||||
do {
|
||||
bFirstCrv = true ;
|
||||
@@ -471,7 +436,6 @@ SurfFlatRegionByContours::GetSurf( void)
|
||||
}
|
||||
// provo a inserirla
|
||||
if ( pSfr->AddExtLoop( Release( pCrv))) {
|
||||
bExtLoop = true ;
|
||||
bFirstCrv = false ;
|
||||
delete m_vpCrv[j] ;
|
||||
m_vpCrv[j] = nullptr ;
|
||||
@@ -496,7 +460,7 @@ SurfFlatRegionByContours::GetSurf( void)
|
||||
}
|
||||
} while ( m_bAllowedMultiChunk && ! bFirstCrv) ;
|
||||
// se non valida, errore
|
||||
if ( ! bExtLoop || ! pSfr->IsValid())
|
||||
if ( ! pSfr->IsValid())
|
||||
return nullptr ;
|
||||
// restituisco la superficie
|
||||
return Release( pSfr) ;
|
||||
|
||||
+2
-5
@@ -35,10 +35,8 @@ GEOOBJ_REGISTER( SRF_BEZIER, NGE_S_BEZ, SurfBezier) ;
|
||||
//----------------------------------------------------------------------------
|
||||
SurfBezier::SurfBezier(void)
|
||||
: m_pSTM( nullptr), m_nStatus( TO_VERIFY), m_nDegU(), m_nDegV(), m_nSpanU(), m_nSpanV(), m_bRat( false),
|
||||
m_bTrimmed( false), m_pTrimReg( nullptr)
|
||||
m_bTrimmed( false), m_pTrimReg( nullptr), m_nTempProp( 0)
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -568,8 +566,7 @@ SurfBezier::CopyFrom( const SurfBezier& sbSrc)
|
||||
m_vPtCtrl = sbSrc.m_vPtCtrl ;
|
||||
if ( sbSrc.m_bRat)
|
||||
m_vWeCtrl = sbSrc.m_vWeCtrl ;
|
||||
m_nTempProp[0] = sbSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = sbSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = sbSrc.m_nTempProp ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -53,11 +53,10 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
@@ -166,7 +165,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+11
-15
@@ -33,10 +33,8 @@ GEOOBJ_REGISTER( SRF_FLATRGN, NGE_S_FRG, SurfFlatRegion) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SurfFlatRegion::SurfFlatRegion( void)
|
||||
: m_pSTM( nullptr), m_nStatus( TO_VERIFY)
|
||||
: m_pSTM( nullptr), m_nStatus( TO_VERIFY), m_nTempProp()
|
||||
{
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -57,8 +55,7 @@ SurfFlatRegion::Clear( void)
|
||||
delete pLoop ;
|
||||
m_vpLoop.clear() ;
|
||||
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_nTempProp = 0 ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
@@ -165,7 +162,7 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
|
||||
for ( auto i : m_vExtInd) {
|
||||
IntersCurveCurve ccInt( *pMyCrv, *m_vpLoop[i]) ;
|
||||
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
||||
! ccInt.GetCurveClassification( 0, EPS_SMALL, ccClass) ||
|
||||
! ccInt.GetCurveClassification( 0, ccClass) ||
|
||||
ccClass.empty() || ccClass[0].nClass != CRVC_OUT) {
|
||||
bOk = false ;
|
||||
break ;
|
||||
@@ -178,7 +175,7 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
|
||||
continue ;
|
||||
IntersCurveCurve ccInt( *pMyCrv, *m_vpLoop[i]) ;
|
||||
if ( ccInt.GetCrossOrOverlapIntersCount() == 0 &&
|
||||
ccInt.GetCurveClassification( 0, EPS_SMALL, ccClass) &&
|
||||
ccInt.GetCurveClassification( 0, ccClass) &&
|
||||
! ccClass.empty() && ccClass[0].nClass == CRVC_OUT) {
|
||||
bOk = true ;
|
||||
break ;
|
||||
@@ -298,7 +295,7 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
|
||||
IntersCurveCurve ccInt( *pMyCrv, *m_vpLoop[m_vExtInd[i]]) ;
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
||||
! ccInt.GetCurveClassification( 0, EPS_SMALL, ccClass) ||
|
||||
! ccInt.GetCurveClassification( 0, ccClass) ||
|
||||
ccClass.empty() || ccClass[0].nClass != CRVC_IN)
|
||||
continue ;
|
||||
// verifica rispetto ai loop interni
|
||||
@@ -309,7 +306,7 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
|
||||
IntersCurveCurve ccInt2( *pMyCrv, *m_vpLoop[k]) ;
|
||||
CRVCVECTOR ccClass2 ;
|
||||
if ( ccInt2.GetCrossOrOverlapIntersCount() > 0 ||
|
||||
! ccInt2.GetCurveClassification( 0, EPS_SMALL, ccClass2) ||
|
||||
! ccInt2.GetCurveClassification( 0, ccClass2) ||
|
||||
ccClass2.empty() || ccClass2[0].nClass != CRVC_IN) {
|
||||
bOk = false ;
|
||||
break ;
|
||||
@@ -400,8 +397,7 @@ SurfFlatRegion::CopyFrom( const SurfFlatRegion& sfrSrc)
|
||||
m_vpLoop.push_back( pCrv) ;
|
||||
}
|
||||
m_vExtInd = sfrSrc.m_vExtInd ;
|
||||
m_nTempProp[0] = sfrSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = sfrSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = sfrSrc.m_nTempProp ;
|
||||
m_nStatus = sfrSrc.m_nStatus ;
|
||||
return ( m_nStatus == OK && ! m_vpLoop.empty()) ;
|
||||
}
|
||||
@@ -1150,7 +1146,7 @@ SurfFlatRegion::CloneChunk( int nChunk) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const
|
||||
SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, CRVCVECTOR& ccClass) const
|
||||
{
|
||||
// la curva deve già essere nel riferimento intrinseco della regione
|
||||
// verifico lo stato
|
||||
@@ -1179,7 +1175,7 @@ SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRV
|
||||
IntersCurveCurve ccInt( Crv, *pLoop) ;
|
||||
// classificazione
|
||||
CRVCVECTOR ccPart ;
|
||||
if ( ! ccInt.GetCurveClassification( 0, dLenMin, ccPart))
|
||||
if ( ! ccInt.GetCurveClassification( 0, ccPart))
|
||||
return false ;
|
||||
for ( auto& ccOne : ccPart) {
|
||||
switch ( ccOne.nClass) {
|
||||
@@ -1272,7 +1268,7 @@ SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRV
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const
|
||||
SurfFlatRegion::GetCurveClassification( const ICurve& Crv, CRVCVECTOR& ccClass) const
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK || m_vpLoop.empty())
|
||||
@@ -1293,7 +1289,7 @@ SurfFlatRegion::GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCV
|
||||
pCrvLoc = pCopyCrv ;
|
||||
}
|
||||
// esecuzione classificazione nel riferimento intrinseco
|
||||
return MyGetCurveClassification( *pCrvLoc, dLenMin, ccClass) ;
|
||||
return MyGetCurveClassification( *pCrvLoc, ccClass) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+7
-8
@@ -51,11 +51,10 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
@@ -92,7 +91,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
const SurfTriMesh* GetAuxSurf( void) const override ;
|
||||
SurfFlatRegion* CloneChunk( int nChunk) const override ;
|
||||
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
|
||||
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
|
||||
bool GetCurveClassification( const ICurve& Crv, CRVCVECTOR& ccClass) const override ;
|
||||
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
|
||||
|
||||
public : // IGeoObjRW
|
||||
@@ -131,7 +130,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
ICurve* GetMyLoop( int nChunk, int nLoop) const ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni)
|
||||
void ResetAuxSurf( void) const ;
|
||||
bool ConvertArcsToBezierCurves( void) ;
|
||||
bool MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const ;
|
||||
bool MyGetCurveClassification( const ICurve& Crv, CRVCVECTOR& ccClass) const ;
|
||||
static bool MySelectCurves( const PCRV_DEQUE& vpLoop, const SurfFlatRegion& Other,
|
||||
int nType1, bool bInvert1, int nType2, bool bInvert2, PCRV_DEQUE& vpCurve) ;
|
||||
static bool MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop) ;
|
||||
@@ -145,7 +144,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
Frame3d m_frF ; // riferimento intrinseco
|
||||
PCRV_DEQUE m_vpLoop ; // deque delle curve che formano i loop
|
||||
INTVECTOR m_vExtInd ; // indice dei loop esterni nel precedente vettore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -289,7 +289,7 @@ SurfFlatRegion::MySelectCurves( const PCRV_DEQUE& vpLoop, const SurfFlatRegion&
|
||||
for ( auto& pLoop : vpLoop) {
|
||||
// eseguo classificazione
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! Other.MyGetCurveClassification( *pLoop, EPS_SMALL, ccClass))
|
||||
if ( ! Other.MyGetCurveClassification( *pLoop, ccClass))
|
||||
return false ;
|
||||
// creo intervalli validi, tenendo classificazioni ricevute
|
||||
Intervals inOk1( EPS_PARAM), inOk2( EPS_PARAM) ;
|
||||
@@ -441,7 +441,7 @@ SurfFlatRegion::MyNewSurfFromLoops( PCRV_DEQUE& vpLoop)
|
||||
CRVCVECTOR ccClass ;
|
||||
IntersCurveCurve ccInt( *vpLoop[l], *pExtLoop) ;
|
||||
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
||||
! ccInt.GetCurveClassification( 0, EPS_SMALL, ccClass) ||
|
||||
! ccInt.GetCurveClassification( 0, ccClass) ||
|
||||
ccClass.empty() || ccClass[0].nClass != CRVC_IN)
|
||||
continue ;
|
||||
// lo inserisco
|
||||
|
||||
@@ -27,9 +27,6 @@ SurfFlatRegion::Offset( double dDist, int nType)
|
||||
int nChunk = GetChunkCount() ;
|
||||
if ( nChunk == 0)
|
||||
return false ;
|
||||
// se offset nullo, non devo fare alcunché
|
||||
if ( abs( dDist) < 10 * EPS_SMALL)
|
||||
return true ;
|
||||
// creo una nuova regione
|
||||
PtrOwner<SurfFlatRegion> pSfr( new( nothrow) SurfFlatRegion) ;
|
||||
if ( IsNull( pSfr))
|
||||
|
||||
+47
-186
@@ -41,12 +41,10 @@ GEOOBJ_REGISTER( SRF_TRIMESH, NGE_S_TRM, SurfTriMesh) ;
|
||||
SurfTriMesh::SurfTriMesh( void)
|
||||
: m_nStatus( TO_VERIFY), m_dLinTol( STM_STD_LIN_TOL), m_dBoundaryAng( STM_STD_BOUNDARY_ANG),
|
||||
m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bOriented( false), m_bClosed( false), m_bFaceted( false),
|
||||
m_nTimeStamp( 0), m_nMaxTFlag( 0), m_nParts( -1), m_pHGrd3d( nullptr)
|
||||
m_nTimeStamp( 0), m_nTempProp( 0), m_nMaxTFlag( 0), m_nParts( -1), m_pHGrd3d( nullptr)
|
||||
{
|
||||
m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ;
|
||||
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -991,7 +989,7 @@ SurfTriMesh::MarchOneTria( int& nT, int& nV, int nTimeStamp,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL) const
|
||||
SurfTriMesh::GetSilhouette( const Vector3d& vtDir, POLYLINEVECTOR& vPL) const
|
||||
{
|
||||
// Verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
@@ -1002,19 +1000,6 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
||||
if ( ! vtVers.Normalize())
|
||||
return false ;
|
||||
|
||||
// Controlli su tolleranza
|
||||
dTol = max( dTol, 100 * EPS_SMALL) ;
|
||||
|
||||
// Determino il riferimento di proiezione
|
||||
Frame3d frOCS ; frOCS.Set( ORIG, vtVers) ;
|
||||
Frame3d frBox = frOCS ; frBox.Invert() ;
|
||||
BBox3d b3Box ;
|
||||
GetBBox( frBox, b3Box) ;
|
||||
frOCS.Translate( b3Box.GetMin().z * frOCS.VersZ()) ;
|
||||
|
||||
#if 0
|
||||
// *** 1° Sfruttando le adiacenze ***
|
||||
// Non funziona perchè genera loop con anelli
|
||||
// Copio la superficie
|
||||
PtrOwner<SurfTriMesh> pStm( Clone()) ;
|
||||
if ( IsNull( pStm))
|
||||
@@ -1026,100 +1011,14 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
||||
if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL)
|
||||
continue ;
|
||||
// verifico la normale
|
||||
if ( pStm->m_vTria[i].vtN * vtVers < EPS_ZERO)
|
||||
if ( pStm->m_vTria[i].vtN * vtVers < - EPS_ZERO)
|
||||
pStm->RemoveTriangle( i) ;
|
||||
}
|
||||
// dichiaro facce non calcolate
|
||||
pStm->m_bFaceted = false ;
|
||||
|
||||
// Proietto la superficie
|
||||
pStm->Scale( frOCS, 1, 1, 0) ;
|
||||
|
||||
// Recupero i loop della nuova superficie
|
||||
POLYLINEVECTOR vMyPL ;
|
||||
if ( pStm->GetLoops( vMyPL)) {
|
||||
// calcolo la regione della superficie proiettata
|
||||
bool bOk = true ;
|
||||
PtrOwner<ISurfFlatRegion> pSfr ;
|
||||
for ( int i = 0 ; i < int( vMyPL.size()) && bOk ; ++ i) {
|
||||
// Regione di un loop
|
||||
PtrOwner<ISurfFlatRegion> pSfrPart( GetSurfFlatRegionFromPolyLine( vMyPL[i])) ;
|
||||
if ( ! IsNull( pSfrPart)) {
|
||||
pSfrPart->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
if ( pSfrPart->GetNormVersor() * vtVers > 0)
|
||||
bOk = pSfr.Set( Release( pSfrPart)) ;
|
||||
else
|
||||
bOk = false ;
|
||||
else {
|
||||
if ( pSfrPart->GetNormVersor() * vtVers > 0)
|
||||
bOk = pSfr->Add( *pSfrPart) ;
|
||||
else {
|
||||
pSfrPart->Invert() ;
|
||||
bOk = pSfr->Subtract( *pSfrPart) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
bOk = false ;
|
||||
}
|
||||
// Verifico esistenza della regione
|
||||
if ( bOk && ! IsNull( pSfr)) {
|
||||
// Effettuo contro-offset
|
||||
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
|
||||
// Recupero i contorni della regione
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PolyLine PL ;
|
||||
if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
vPL.emplace_back( PL) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
vPL.clear() ;
|
||||
#endif
|
||||
|
||||
// *** 2° Mediante unione delle regioni dei triangoli proiettati ***
|
||||
// calcolo la regione dei triangoli proiettati
|
||||
PtrOwner<ISurfFlatRegion> pSfr ;
|
||||
Triangle3d Tria ;
|
||||
int nT = GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
// verifico la normale e il triangolo proiettato
|
||||
if ( Tria.GetN() * vtVers > EPS_ZERO &&
|
||||
Tria.Scale( frOCS, 1, 1, 0) && Tria.GetSqMinHeight() > SQ_EPS_SMALL) {
|
||||
PtrOwner<ISurfFlatRegion> pSfrTria( GetSurfFlatRegionFromTriangle( Tria)) ;
|
||||
if ( ! IsNull( pSfrTria)) {
|
||||
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||
if ( IsNull( pSfr))
|
||||
pSfr.Set( Release( pSfrTria)) ;
|
||||
else
|
||||
pSfr->Add( *pSfrTria) ;
|
||||
}
|
||||
}
|
||||
// passo al successivo
|
||||
nT = GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
|
||||
// Se non esiste la regione
|
||||
if ( IsNull( pSfr))
|
||||
return false ;
|
||||
|
||||
// Effettuo contro-offset
|
||||
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
|
||||
|
||||
// Recupero i contorni della regione
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PolyLine PL ;
|
||||
if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
vPL.emplace_back( PL) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
return pStm->GetLoops( vPL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1169,8 +1068,7 @@ SurfTriMesh::CopyFrom( const SurfTriMesh& stmSrc)
|
||||
m_vTria = stmSrc.m_vTria ;
|
||||
m_vFacet = stmSrc.m_vFacet ;
|
||||
m_nTimeStamp = stmSrc.m_nTimeStamp ;
|
||||
m_nTempProp[0] = stmSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = stmSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = stmSrc.m_nTempProp ;
|
||||
m_nMaxTFlag = stmSrc.m_nMaxTFlag ;
|
||||
m_nParts = stmSrc.m_nParts ;
|
||||
return true ;
|
||||
@@ -2930,7 +2828,7 @@ SurfTriMesh::DoCompacting( double dTol)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther, double dTol)
|
||||
SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther)
|
||||
{
|
||||
// recupero l'altra superficie
|
||||
const SurfTriMesh* pOther = dynamic_cast<const SurfTriMesh*>( &stmOther) ;
|
||||
@@ -2972,7 +2870,7 @@ SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther, dou
|
||||
ptOP.ToGlob( frOther) ;
|
||||
// se non c'è già un vertice con la stessa posizione lo inserisco
|
||||
int nNewId ;
|
||||
if ( ! VertGrid.Find( ptOP, dTol, nNewId)) {
|
||||
if ( ! VertGrid.Find( ptOP, 2 * EPS_SMALL, nNewId)) {
|
||||
if ( ( nNewId = AddVertex( ptOP)) == SVT_NULL)
|
||||
return false ;
|
||||
VertGrid.InsertPoint( ptOP, nNewId) ;
|
||||
@@ -3401,9 +3299,11 @@ SurfTriMesh::Invert( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif)
|
||||
SurfTriMesh::Cut( const Plane3d& plPlane, bool bSaveOnEq)
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
#define UseTria 1
|
||||
#if UseTria
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
@@ -3428,6 +3328,7 @@ SurfTriMesh::CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModi
|
||||
++ m_nTimeStamp ;
|
||||
|
||||
// sistemo i triangoli (eventualmente li elimino)
|
||||
bool bModif = false ;
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
||||
// salto i triangoli cancellati e quelli aggiunti
|
||||
if ( m_vTria[i].nIdVert[0] == SVT_DEL || m_vTria[i].nTemp == m_nTimeStamp)
|
||||
@@ -3606,40 +3507,43 @@ SurfTriMesh::CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModi
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
// se effettuate modifiche
|
||||
if ( bModif) {
|
||||
// aggiorno tutto
|
||||
if ( ! AdjustVertices() || ! DoCompacting())
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::CutByFacets( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif)
|
||||
{
|
||||
// Setto posizione triangoli non definita
|
||||
for ( int nT = 0 ; nT < GetTriangleSize() ; ++ nT)
|
||||
return true ;
|
||||
|
||||
#else
|
||||
|
||||
bool bModif = false ;
|
||||
|
||||
// Setto i triangoli come né fuori né dentro.
|
||||
int nTriaNum = GetTriangleSize() ;
|
||||
for ( int nT = 0 ; nT < nTriaNum ; ++ nT) {
|
||||
m_vTria[nT].nTempPart = 0 ;
|
||||
}
|
||||
|
||||
INTERSCHAINMAP IntersLineMap ;
|
||||
|
||||
// Ciclo su tutte le facce.
|
||||
for ( int nF = 0 ; nF < GetFacetCount() ; ++ nF) {
|
||||
int nFacetNum = GetFacetCount() ;
|
||||
for ( int nF = 0 ; nF < nFacetNum ; ++ nF) {
|
||||
// Dati della faccia
|
||||
POLYLINEVECTOR vLoopVec ;
|
||||
GetFacetLoops( nF, vLoopVec) ;
|
||||
if ( vLoopVec.empty())
|
||||
continue ;
|
||||
// Verifico la posizione del loop esterno
|
||||
int nIntType = VerifyLoopPlane( vLoopVec[0], plPlane) ;
|
||||
// Se interseca il piano di taglio, calcolo la divisione della faccia
|
||||
PtrOwner<SurfFlatRegion> pReg( GetBasicSurfFlatRegion( GetSurfFlatRegionFromPolyLineVector( vLoopVec))) ;
|
||||
if ( IsNull( pReg))
|
||||
return false ;
|
||||
LineFacetClassVector IntersLinePart ;
|
||||
if ( nIntType == FPI_CUT) {
|
||||
PtrOwner<SurfFlatRegion> pReg( GetBasicSurfFlatRegion( GetSurfFlatRegionFromPolyLineVector( vLoopVec))) ;
|
||||
if ( IsNull( pReg) || ! pReg->IsValid())
|
||||
return false ;
|
||||
nIntType = IntersFacetPlane( *pReg, plPlane, IntersLinePart) ;
|
||||
}
|
||||
// Gestione dei risultati
|
||||
if ( nIntType == FPI_CUT) {
|
||||
int nIntType = IntersFacetPlane( *pReg, vLoopVec[0], plPlane, IntersLinePart) ;
|
||||
if ( nIntType == FacetPlaneIntersType::FPI_CUT) {
|
||||
for ( int nPart = 0 ; nPart < int( IntersLinePart.size()) ; ++ nPart) {
|
||||
// Salvo intersezione per la faccia.
|
||||
// Salvo intersezione per la faccia.
|
||||
auto it = IntersLineMap.find( nF) ;
|
||||
if ( it != IntersLineMap.end()) {
|
||||
it->second.emplace_back( IntersInnSeg( IntersLinePart[nPart].ptSt, IntersLinePart[nPart].ptEn)) ;
|
||||
@@ -3649,28 +3553,26 @@ SurfTriMesh::CutByFacets( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( nIntType == FPI_ON) {
|
||||
else if ( nIntType == FacetPlaneIntersType::FPI_ON) {
|
||||
INTVECTOR vT ;
|
||||
GetAllTriaInFacet( nF, vT) ;
|
||||
Vector3d vtNf ;
|
||||
GetFacetNormal( nF, vtNf) ;
|
||||
for ( auto& nT : vT)
|
||||
m_vTria[nT].nTempPart = ( vtNf * plPlane.GetVersN() > 0 ? 2 : -2) ;
|
||||
m_vTria[nT].nTempPart = pReg->GetNormVersor() * plPlane.GetVersN() > 0. ? 2 : - 2 ;
|
||||
}
|
||||
else if ( nIntType == FPI_IN) {
|
||||
else if ( nIntType == FacetPlaneIntersType::FPI_INN) {
|
||||
INTVECTOR vT ;
|
||||
GetAllTriaInFacet( nF, vT) ;
|
||||
for ( auto& nT : vT)
|
||||
m_vTria[nT].nTempPart = 1 ;
|
||||
}
|
||||
else if ( nIntType == FPI_OUT) {
|
||||
else if ( nIntType == FacetPlaneIntersType::FPI_OUT) {
|
||||
INTVECTOR vT ;
|
||||
GetAllTriaInFacet( nF, vT) ;
|
||||
for ( auto& nT : vT)
|
||||
m_vTria[nT].nTempPart = -1 ;
|
||||
m_vTria[nT].nTempPart = - 1 ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
;
|
||||
}
|
||||
|
||||
// Divido le facce.
|
||||
@@ -3679,54 +3581,13 @@ SurfTriMesh::CutByFacets( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif)
|
||||
INTERSEDGEMAP EdgeInterLineMap, EdgeEdgeLineMap ;
|
||||
RetriangulateFacetPieces( NewFacet, EdgeInterLineMap, EdgeEdgeLineMap) ;
|
||||
|
||||
// Elimino i triangoli superflui
|
||||
for ( int nT = 0 ; nT < GetTriangleSize() ; ++ nT) {
|
||||
if ( m_vTria[nT].nTempPart == 0 ||
|
||||
m_vTria[nT].nTempPart == -1 ||
|
||||
m_vTria[nT].nTempPart == -2 ||
|
||||
( ! bSaveOnEq && m_vTria[nT].nTempPart == 2)) {
|
||||
int nNumTria = GetTriangleSize() ;
|
||||
for ( int nT = 0 ; nT < nNumTria ; ++ nT)
|
||||
if ( m_vTria[nT].nTempPart == - 1 || m_vTria[nT].nTempPart == - 2 || ( ! bSaveOnEq && m_vTria[nT].nTempPart == 2))
|
||||
RemoveTriangle( nT) ;
|
||||
bModif = true ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::Cut( const Plane3d& plPlane, bool bSaveOnEq)
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// recupero il numero originale di triangoli e di facce
|
||||
int nTriaOriCnt = GetTriangleCount() ;
|
||||
int nFacetOriCnt = GetFacetCount() ;
|
||||
|
||||
// eseguo il taglio con il metodo delle faccette o dei triangoli (per ora solo coi triangoli)
|
||||
bool bModif = false ;
|
||||
if ( true || ! CutByFacets( plPlane, bSaveOnEq, bModif)) {
|
||||
bModif = false ;
|
||||
if ( ! CutByTriangles( plPlane, bSaveOnEq, bModif))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se effettuate modifiche
|
||||
if ( bModif) {
|
||||
// aggiorno tutto
|
||||
if ( ! AdjustVertices() || ! DoCompacting())
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se superficie originale a facce, cerco di semplificarle in ogni caso
|
||||
if ( nFacetOriCnt < 200 || double( nTriaOriCnt) / nFacetOriCnt > 4) {
|
||||
if ( ! SimplifyFacets( 500.0))
|
||||
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Cut")
|
||||
}
|
||||
|
||||
return true ;
|
||||
return AdjustVertices() && DoCompacting() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+14
-19
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2021
|
||||
// EgalTech 2014-2019
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SurfTriMesh.h Data : 26.09.21 Versione : 2.3i2
|
||||
// File : SurfTriMesh.h Data : 12.02.19 Versione : 2.1b2
|
||||
// Contenuto : Dichiarazione della classe Superficie TriMesh.
|
||||
//
|
||||
//
|
||||
@@ -121,7 +121,7 @@ struct LineFacetClass {
|
||||
nTypeA = 0 ;
|
||||
nTypeB = 0 ;
|
||||
}
|
||||
LineFacetClass( const Point3d& ptS, const Point3d& ptE, int nTpA, int nTpB) {
|
||||
LineFacetClass( const Point3d& ptS, const Point3d ptE, int nTpA, int nTpB) {
|
||||
ptSt = ptS ;
|
||||
ptEn = ptE ;
|
||||
nTypeA = nTpA ;
|
||||
@@ -131,7 +131,7 @@ struct LineFacetClass {
|
||||
typedef std::vector<LineFacetClass> LineFacetClassVector ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
enum FacetPlaneIntersType { FPI_ERROR = 0, FPI_CUT = 1, FPI_IN = 2, FPI_OUT = 3, FPI_ON = 4 } ;
|
||||
enum FacetPlaneIntersType { FPI_ERROR = 0, FPI_CUT = 1, FPI_INN = 2, FPI_OUT = 3, FPI_ON = 4 } ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Definizione strutture e contenitori
|
||||
@@ -206,11 +206,10 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
@@ -249,7 +248,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Vector3d& vtAx,
|
||||
double dAngRot, double dStepRot, double dMove) override ;
|
||||
bool DoCompacting( double dTol = EPS_SMALL) override ;
|
||||
bool DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther = GLOB_FRM, double dTol = 2 * EPS_SMALL) override ;
|
||||
bool DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther = GLOB_FRM) override ;
|
||||
int GetVertexCount( void) const override ;
|
||||
int GetTriangleCount( void) const override ;
|
||||
int GetTriangleCount( int nTFlag) const override ;
|
||||
@@ -278,7 +277,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool GetTriangleBoundaryEdges( int nId, TriFlags3d& TFlags) const override ;
|
||||
bool GetTriangleSmoothNormals( int nId, TriNormals3d& TNrms) const override ;
|
||||
bool GetLoops( POLYLINEVECTOR& vPL) const override ;
|
||||
bool GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL) const override ;
|
||||
bool GetSilhouette( const Vector3d& vtDir, POLYLINEVECTOR& vPL) const override ;
|
||||
int GetFacetCount( void) const override ;
|
||||
int GetFacetSize( void) const override
|
||||
{ return int( m_vFacet.size()) ; }
|
||||
@@ -381,23 +380,19 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
void ResetHashGrids3d( void) const ;
|
||||
bool VerifyHashGrids3d( void) const ;
|
||||
bool VerifyConnection( void) const ;
|
||||
bool CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
|
||||
bool CutByFacets( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
|
||||
bool DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMATRIX& cvBoundClosedLoopVec, BOOLVECTOR& vbInOut) ;
|
||||
bool RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf, bool& bModif) ;
|
||||
bool AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf) ;
|
||||
bool IntersectTriMeshTriangle( SurfTriMesh& Other) ;
|
||||
int VerifyLoopPlane( const PolyLine& ExtLoop, const Plane3d& plCutPlane) ;
|
||||
int IntersFacetPlane( const SurfFlatRegion& Region, const Plane3d& plCutPlane,
|
||||
LineFacetClassVector& IntersLinePart) ;
|
||||
int IntersFacetPlane( const SurfFlatRegion& Region, const PolyLine& ExtLoop, const Plane3d& plCutPlane,
|
||||
LineFacetClassVector& IntersLinePart) ;
|
||||
bool IntersFacetFacet( const SurfFlatRegion& RegionA, const PolyLine& ExtLoopA,
|
||||
const SurfFlatRegion& RegionB, const PolyLine& ExtLoopB,
|
||||
LineFacetClassVector& IntersLinePart) ;
|
||||
bool IntersectTriMeshFacets( SurfTriMesh& Other) ;
|
||||
bool ItersectTriMeshFacets( SurfTriMesh& Other) ;
|
||||
bool RetriangulateFacetPieces( const PieceMap& NewFacet,
|
||||
const INTERSEDGEMAP& EdgeInterLineMap,
|
||||
const INTERSEDGEMAP& EdgeEdgeLineMap) ;
|
||||
bool SimplifyFacets( double dMaxEdgeLen) ;
|
||||
bool EdgeInteriorContactManager( const SurfTriMesh& OthSurf,
|
||||
const INTERSCHAINMAP& InterInterLineMap,
|
||||
const INTERSEDGEMAP& EdgeInterLineMap) ;
|
||||
@@ -427,7 +422,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
TRIAVECTOR m_vTria ; // vettore dei triangoli
|
||||
INTVECTOR m_vFacet ; // vettore delle sfaccettature
|
||||
mutable int m_nTimeStamp ; // orologio locale
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
int m_nMaxTFlag ; // massimo valore dei TFlag dei triangoli
|
||||
mutable int m_nParts ; // numero di parti connesse (-1 se da calcolare)
|
||||
mutable HashGrids3d* m_pHGrd3d ; // Hash Grid 3d nel suo riferimento
|
||||
|
||||
+734
-504
File diff suppressed because it is too large
Load Diff
@@ -1,250 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2021-2021
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SurfTriMeshUtilities.cpp Data : 01.11.21 Versione : 2.3k1
|
||||
// Contenuto : Implementazione funzioni di utilità di Superfici TriMesh.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 25.10.21 LM Creazione modulo.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Triangulate.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "DistPointLine.h"
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
IsVertex( PNTULIST& PointList, PNTULIST::const_iterator itCurr)
|
||||
{
|
||||
// recupero il punto precedente
|
||||
PNTULIST::const_iterator itPrev ;
|
||||
if ( itCurr == PointList.begin())
|
||||
itPrev = prev( PointList.end(), 2) ;
|
||||
else
|
||||
itPrev = prev( itCurr) ;
|
||||
// recupero il punto successivo
|
||||
auto itNext = next( itCurr) ;
|
||||
if ( itNext == PointList.end())
|
||||
itNext = next( PointList.begin()) ;
|
||||
// se cambia faccia adiacente tra prima e dopo, va bene
|
||||
if ( itPrev->second != itCurr->second)
|
||||
return true ;
|
||||
// se lati aperti e cambia direzione tra prima e dopo, va bene
|
||||
if ( itPrev->second == -1) {
|
||||
DistPointLine PointLineDistCalc( itCurr->first, itPrev->first, itNext->first) ;
|
||||
double dDist ;
|
||||
if ( PointLineDistCalc.GetDist( dDist) && dDist > EPS_SMALL)
|
||||
return true ;
|
||||
}
|
||||
// altrimenti non va bene
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ChooseGoodStartPoint( PNTULIST& PointList)
|
||||
{
|
||||
// se il punto iniziale è un vertice, non devo fare alcunché
|
||||
if ( IsVertex( PointList, PointList.begin()))
|
||||
return true ;
|
||||
// altrimenti cerco il vertice più vicino
|
||||
for ( auto it = next( PointList.begin()) ; it != PointList.end() ; ++it) {
|
||||
if ( IsVertex( PointList, it)) {
|
||||
// cancello ultimo punto ( coincide con primo)
|
||||
PointList.pop_back() ;
|
||||
// sposto la parte iniziale dei punti alla fine
|
||||
PointList.splice( PointList.end(), PointList, PointList.begin(), it) ;
|
||||
// aggiungo punto finale come copia dell'iniziale
|
||||
PointList.push_back( PointList.front()) ;
|
||||
// ho finito
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, bool& bModif)
|
||||
{
|
||||
// Ciclo sui punti del loop
|
||||
auto itLast = PointList.begin() ;
|
||||
for ( auto it = next( itLast) ; it != PointList.end() ; ++ it) {
|
||||
|
||||
// Se dal punto corrente inizia un segmento adiacente a un'altra faccia
|
||||
if ( itLast->second != it->second) {
|
||||
// Elimino i punti interni
|
||||
auto itNextToLast = next( itLast) ;
|
||||
for ( auto itInn = itNextToLast ; itInn != it ; ) {
|
||||
itInn = PointList.erase( itInn) ;
|
||||
bModif = true ;
|
||||
}
|
||||
// Se la lunghezza del segmento supera il limite imposto
|
||||
double dSegLen = Dist( it->first, itLast->first) ;
|
||||
if ( dSegLen > dMaxEdgeLen) {
|
||||
// determino il numero di step
|
||||
double dRatio = dSegLen / dMaxEdgeLen ;
|
||||
int nStepCount = int( dRatio) + 1 ;
|
||||
// inserisco i punti
|
||||
auto itAdd = it ;
|
||||
for ( int nP = 1 ; nP < nStepCount ; ++ nP) {
|
||||
double dCoeff = double( nP) / nStepCount ;
|
||||
itAdd = PointList.insert( itAdd, POINTU( Media( itLast->first, it->first, 1 - dCoeff), itLast->second)) ;
|
||||
bModif = true ;
|
||||
}
|
||||
}
|
||||
// Nuovo punto di riferimento
|
||||
itLast = it ;
|
||||
}
|
||||
|
||||
// Se sono due segmenti liberi non allineati
|
||||
else if ( itLast->second == - 1) {
|
||||
// Calcolo se i punti compresi fra gli estremi sono allineati
|
||||
bool bAreAligned = true ;
|
||||
auto itNextToLast = next( itLast) ;
|
||||
for ( auto itInn = itNextToLast ; itInn != it && bAreAligned ; ++ itInn) {
|
||||
DistPointLine PointLineDistCalc( itInn->first, itLast->first, it->first) ;
|
||||
double dDist ;
|
||||
if ( PointLineDistCalc.GetDist( dDist))
|
||||
bAreAligned = ( dDist < EPS_SMALL) ;
|
||||
}
|
||||
// Se i punti sono allineati
|
||||
if ( bAreAligned) {
|
||||
// Verifico se il successivo punto non è più allineato
|
||||
auto itNextToCurr = next( it) ;
|
||||
if ( itNextToCurr != PointList.end()) {
|
||||
for ( auto itInn = itNextToLast ; itInn != itNextToCurr && bAreAligned ; ++ itInn) {
|
||||
DistPointLine PointLineDistCalc( itInn->first, itLast->first, itNextToCurr->first) ;
|
||||
double dDist ;
|
||||
if ( PointLineDistCalc.GetDist( dDist))
|
||||
bAreAligned = ( dDist < EPS_SMALL) ;
|
||||
}
|
||||
}
|
||||
// Se ho trovato un insieme massimale di punti allineati li processo
|
||||
if ( ! bAreAligned || itNextToCurr == PointList.end()) {
|
||||
// Elimino i punti interni
|
||||
for ( auto itInn = itNextToLast ; itInn != it ; ) {
|
||||
itInn = PointList.erase( itInn) ;
|
||||
bModif = true ;
|
||||
}
|
||||
// Se la lunghezza del segmento supera il limite imposto
|
||||
double dSegLen = Dist( it->first, itLast->first) ;
|
||||
if ( dSegLen > dMaxEdgeLen) {
|
||||
// determino il numero di step
|
||||
double dRatio = dSegLen / dMaxEdgeLen ;
|
||||
int nStepCount = int( dRatio) + 1 ;
|
||||
// inserisco i punti
|
||||
auto itAdd = it ;
|
||||
for ( int nP = 1 ; nP < nStepCount ; ++ nP) {
|
||||
double dCoeff = double( nP) / nStepCount ;
|
||||
itAdd = PointList.insert( itAdd, POINTU( Media( itLast->first, it->first, 1 - dCoeff), itLast->second)) ;
|
||||
bModif = true ;
|
||||
}
|
||||
}
|
||||
// Nuovo punto di riferimento
|
||||
itLast = it ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::SimplifyFacets( double dMaxEdgeLen)
|
||||
{
|
||||
// La trimesh deve essere valida
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
// Se la lunghezza massima del lato del triangolo sul bordo della faccia è nulla, non devo fare alcunché
|
||||
if ( dMaxEdgeLen < EPS_SMALL)
|
||||
return true ;
|
||||
|
||||
// Recupero il numero delle facce (esegue anche una verifica delle stesse)
|
||||
int nFacetCnt = GetFacetCount() ;
|
||||
|
||||
// Ciclo sulle facce della mesh per trovare quelle da ritriangolare
|
||||
unordered_map< int, pair< PNTVECTOR, INTVECTOR>> FacetMap ;
|
||||
for ( int nF = 0 ; nF < nFacetCnt ; ++ nF) {
|
||||
|
||||
// Recupero i loop della faccia (il parametro indica la faccia adiacente)
|
||||
POLYLINEVECTOR LoopVec ;
|
||||
GetFacetLoops( nF, LoopVec) ;
|
||||
|
||||
// Ciclo sui loop della faccia
|
||||
bool bToRetriangulate = false ;
|
||||
for ( int nL = 0 ; nL < int( LoopVec.size()) ; ++ nL) {
|
||||
|
||||
// Lista dei punti del loop
|
||||
PNTULIST& PointList = LoopVec[nL].GetUPointList() ;
|
||||
|
||||
// Mi assicuro che il punto iniziale/finale non sia all'interno di un possibile segmento
|
||||
if ( ! ChooseGoodStartPoint( PointList))
|
||||
return false ;
|
||||
|
||||
// Sistemo il loop
|
||||
bool bModif = false ;
|
||||
if ( ! AdjustLoop( PointList, dMaxEdgeLen, bModif))
|
||||
return false ;
|
||||
if ( bModif)
|
||||
bToRetriangulate = true ;
|
||||
}
|
||||
|
||||
// Se da ritriangolare,
|
||||
if ( bToRetriangulate) {
|
||||
// Eseguo la ritriangolazione della faccia
|
||||
PNTVECTOR vPt ;
|
||||
INTVECTOR vTr ;
|
||||
if ( Triangulate().Make( LoopVec, vPt, vTr)) {
|
||||
FacetMap.emplace( nF, make_pair( vPt, vTr)) ;
|
||||
}
|
||||
// Se non riesco a triangolare anche solo questa faccia, interrompo tutto
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// Ciclo sulle facce da ritriangolare per eliminare i triangoli (nel contempo salvo flag colore)
|
||||
unordered_map< int, int> ColorMap ;
|
||||
for ( auto itF = FacetMap.begin() ; itF != FacetMap.end() ; ++ itF) {
|
||||
// Recupero i triangoli della faccia
|
||||
INTVECTOR vFacetTria ;
|
||||
GetAllTriaInFacet( itF->first, vFacetTria) ;
|
||||
// Salvo il colore della faccia da flag di un suo triangolo
|
||||
ColorMap.emplace( itF->first, m_vTria[m_vFacet[itF->first]].nTFlag) ;
|
||||
// Cancello i triangoli della faccia.
|
||||
for ( int nT : vFacetTria)
|
||||
RemoveTriangle( nT) ;
|
||||
}
|
||||
|
||||
// Applico le nuove triangolazioni delle facce
|
||||
for ( auto itFac = FacetMap.begin() ; itFac != FacetMap.end() ; ++ itFac) {
|
||||
const PNTVECTOR& vPt = itFac->second.first ;
|
||||
const INTVECTOR& vTr = itFac->second.second ;
|
||||
// Inserisco i nuovi triangoli
|
||||
for ( int n = 0 ; n < int( vTr.size()) - 2 ; n += 3) {
|
||||
int nNewId[3] = { AddVertex( vPt[vTr[n]]),
|
||||
AddVertex( vPt[vTr[n + 1]]),
|
||||
AddVertex( vPt[vTr[n + 2]])} ;
|
||||
auto itCol = ColorMap.find( itFac->first) ;
|
||||
int nTFlag = ( itCol != ColorMap.end() ? itCol->second : 0) ;
|
||||
int nNewTriaId = AddTriangle( nNewId, nTFlag) ;
|
||||
}
|
||||
}
|
||||
|
||||
// dichiaro necessità ricalcolo della grafica e di hashgrids3d
|
||||
m_OGrMgr.Reset() ;
|
||||
ResetHashGrids3d() ;
|
||||
|
||||
// Eseguo aggiustamenti
|
||||
return ( AdjustVertices() && DoCompacting()) ;
|
||||
}
|
||||
@@ -27,9 +27,9 @@ using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Tool::Tool( bool bApproxWithLines)
|
||||
: m_bApproxWithLines( bApproxWithLines), m_dLinTol( LIN_TOL_STD), m_dAngTolDeg( ANG_TOL_APPROX_DEG),
|
||||
m_nType( UNDEF), m_nCurrentNum( 0), m_dHeight( 0), m_dTipHeight( 0), m_dRadius( 0), m_dRCorner( 0),
|
||||
m_dTipRadius( 0), m_dRefRadius( 0), m_dCutterHeight( 0), m_dMrtChsWidth( 0), m_dMrtChsThickness( 0)
|
||||
: m_dLinTol( LIN_TOL_STD), m_dAngTolDeg( ANG_TOL_APPROX_DEG), m_nType( UNDEF), m_nCurrentNum( 0), m_dHeight( 0), m_dTipHeight( 0),
|
||||
m_dRadius( 0), m_dRCorner( 0), m_dTipRadius( 0), m_dRefRadius( 0), m_dCutterHeight( 0), m_dMrtChsWidth( 0), m_dMrtChsThickness( 0),
|
||||
m_bApproxWithLines( bApproxWithLines)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+423
-22
@@ -16,12 +16,21 @@
|
||||
#include "DllMain.h"
|
||||
#include "Triangulate.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "Mathematics/TriangulateCDT.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "tpp_interface.hpp"
|
||||
|
||||
using namespace std ;
|
||||
using namespace tpp ;
|
||||
using namespace gte ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
enum EarStatus{ EAS_NULL = -1, EAS_NO = 0, EAS_OK = 1} ;
|
||||
@@ -35,18 +44,22 @@ static bool ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi) ;
|
||||
// INTVECTOR (int Vector) : 3*T indices of above points for T triangles
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType)
|
||||
{
|
||||
// verifico che la polilinea sia chiusa e piana e calcolo il piano medio del poligono
|
||||
// verifico che la polilinea sia chiusa e piana e calcolo il piano medio del poligono
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
if ( ! PL.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
|
||||
return false ;
|
||||
// determino il piano ottimale di proiezione e il relativo senso di rotazione
|
||||
|
||||
if ( trgType != TRG_STANDARD)
|
||||
return Make( POLYLINEVECTOR{ PL}, vPt, vTr, trgType) ;
|
||||
|
||||
// determino il piano ottimale di proiezione e il relativo senso di rotazione
|
||||
bool bCCW ;
|
||||
if ( ! CalcProjPlane( plPlane.GetVersN(), m_nPlane, bCCW))
|
||||
return false ;
|
||||
// riempio il vettore con i vertici del poligono da triangolare
|
||||
// riempio il vettore con i vertici del poligono da triangolare
|
||||
vPt.clear() ;
|
||||
vPt.reserve( PL.GetPointNbr() - 1) ;
|
||||
// salto il primo punto (coincide con l'ultimo)
|
||||
@@ -56,24 +69,24 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
// inserisco i punti
|
||||
while ( PL.GetNextPoint( ptP))
|
||||
vPt.push_back( ptP) ;
|
||||
// se non CCW inverto il vettore dei punti
|
||||
// se non CCW inverto il vettore dei punti
|
||||
if ( ! bCCW)
|
||||
reverse( vPt.begin(), vPt.end()) ;
|
||||
// creo il vettore degli indici del Poligono
|
||||
// creo il vettore degli indici del Poligono
|
||||
INTVECTOR vPol ;
|
||||
int n = int( vPt.size()) ;
|
||||
vPol.reserve( n) ;
|
||||
for ( int i = 0 ; i < n ; ++ i)
|
||||
vPol.push_back( i) ;
|
||||
|
||||
// eseguo la triangolazione
|
||||
// eseguo la triangolazione
|
||||
if ( ! MakeByEC2( vPt, vPol, vTr) &&
|
||||
! MakeByEC3( vPt, vPol, vTr)) {
|
||||
! MakeByEC3( vPt, vPol, vTr)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByEC23(1)")
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se era CW, devo invertire il senso dei triangoli
|
||||
// se era CW, devo invertire il senso dei triangoli
|
||||
if ( ! bCCW)
|
||||
reverse( vTr.begin(), vTr.end()) ;
|
||||
|
||||
@@ -86,7 +99,7 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
// INTVECTOR (int Vector) : 3*T indices of above points for T triangles
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType)
|
||||
{
|
||||
// pulisco i vettori di ritorno
|
||||
vPt.clear() ;
|
||||
@@ -115,6 +128,38 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
! AreOppositeVectorApprox( plExtPlane.GetVersN(), plPlane.GetVersN()))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// triangolazione Delaunay
|
||||
if ( trgType == TRG_DEL_CONFORMING) {
|
||||
if ( ! MakeByDelaunay( vPL, vPt, vTr, true, true)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( conforming)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else if ( trgType == TRG_DEL_QUALITY) {
|
||||
if ( ! MakeByDelaunay( vPL, vPt, vTr, false, true)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( quality)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else if ( trgType == TRG_DEL_NOQUALITY) {
|
||||
if ( ! MakeByDelaunay( vPL, vPt, vTr, false, false)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( no quality)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else if ( trgType == TRG_DEL_GTE) {
|
||||
if ( ! MakeByDelaunayGTE( vPL, vPt, vTr)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( Geometric Tools Engine)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// ear clipping
|
||||
// se non CCW inverto tutte le polilinee
|
||||
if ( ! bCCW) {
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++i)
|
||||
@@ -172,7 +217,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
INTVECTOR vPol ;
|
||||
int n = int( vPt.size()) ;
|
||||
vPol.reserve( n) ;
|
||||
// non devo gestire separatamente CCW perchè ho già invertito i punti
|
||||
// non devo gestire separatamente CCW perch� ho gi� invertito i punti
|
||||
for ( int i = 0 ; i < n ; ++ i)
|
||||
vPol.push_back( i) ;
|
||||
|
||||
@@ -190,6 +235,362 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Delaunay Triangulation ( Triangle library)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::MakeByDelaunay( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, bool bConforming, bool bQuality)
|
||||
{
|
||||
// sistema di riferimento locale sul piano della polyline
|
||||
Plane3d plPlane ;
|
||||
double dArea;
|
||||
if ( ! vPL[0].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
|
||||
return false ;
|
||||
Frame3d frLoc ;
|
||||
frLoc.Set( plPlane.GetPoint(), plPlane.GetVersN()) ;
|
||||
|
||||
POLYLINEVECTOR vMyPL = vPL ;
|
||||
for ( size_t t = 0 ; t < vPL.size() ; ++ t) {
|
||||
vMyPL[t].ToLoc( frLoc) ;
|
||||
if ( vMyPL[t].GetPointNbr() < 4) // per poter triangolare devo avere almeno tre punti distinti
|
||||
return false ;
|
||||
}
|
||||
|
||||
// vertici e constraint per la triangolazione
|
||||
vector<Delaunay::Point> vDelaunayVert ;
|
||||
INTVECTOR vDelaunayConstr ;
|
||||
|
||||
for ( size_t i = 0 ; i < vMyPL.size() ; i++) {
|
||||
Point3d ptFirst, pt ;
|
||||
vMyPL[i].GetFirstPoint( ptFirst) ;
|
||||
vDelaunayVert.push_back( Delaunay::Point( ptFirst.x, ptFirst.y)) ;
|
||||
int nFirst = ( int)vDelaunayVert.size() - 1 ; // indice del primo punto della polyline fra i vertici della triangolazione
|
||||
vDelaunayConstr.push_back( nFirst) ;
|
||||
|
||||
while ( vMyPL[i].GetNextPoint( pt)) {
|
||||
vDelaunayVert.push_back( Delaunay::Point( pt.x, pt.y)) ;
|
||||
// nei constraint gli indici vanno inseriti due volte perchè vengono letti a due a due per definire un segmento
|
||||
vDelaunayConstr.push_back( ( int)vDelaunayVert.size() - 1) ;
|
||||
vDelaunayConstr.push_back( ( int)vDelaunayVert.size() - 1) ;
|
||||
}
|
||||
|
||||
// impongo che l'ultimo vertice coincida con il primo ( curva chiusa)
|
||||
vDelaunayVert.pop_back() ;
|
||||
vDelaunayConstr.erase(vDelaunayConstr.end() - 2, vDelaunayConstr.end()) ;
|
||||
vDelaunayConstr.push_back( nFirst) ;
|
||||
}
|
||||
|
||||
// holes : sono definiti da un punto interno al buco
|
||||
std::vector<Delaunay::Point> vDelaunayHoles ;
|
||||
for ( size_t i = 1 ; i < vMyPL.size() ; i++) {
|
||||
Point3d pt ;
|
||||
CurveComposite * pCrvHole = CreateBasicCurveComposite() ;
|
||||
pCrvHole->FromPolyLine( vMyPL[i]) ;
|
||||
pCrvHole->GetCentroid( pt) ;
|
||||
// se il centroide fosse esterno, cerco per tentativi un punto qualsiasi all'interno della curva
|
||||
double dPar = 0.5 ;
|
||||
while ( ! IsPointInsidePolyLine( pt, vMyPL[i])) {
|
||||
double dParS, dParE ;
|
||||
pCrvHole->GetDomain( dParS, dParE) ;
|
||||
if ( dPar > dParE)
|
||||
return false ;
|
||||
Vector3d vtDir ;
|
||||
pCrvHole->GetPointTang( dPar, ICurve::FROM_MINUS, pt, vtDir) ;
|
||||
vtDir.Rotate( Z_AX, 0, -1) ;
|
||||
pt += 2 * EPS_SMALL * vtDir ;
|
||||
// tento con un nuovo punto
|
||||
dPar += 10 * EPS_SMALL ;
|
||||
}
|
||||
|
||||
vDelaunayHoles.push_back( Delaunay::Point( pt.x, pt.y)) ;
|
||||
}
|
||||
|
||||
// parti concave
|
||||
PNTVECTOR vPtConvexHull ;
|
||||
vMyPL[0].GetConvexHullXY( vPtConvexHull) ;
|
||||
CurveComposite* pCrv = CreateBasicCurveComposite() ;
|
||||
pCrv->FromPolyLine( vMyPL[0]) ;
|
||||
|
||||
for ( size_t i = 0 ; i < vPtConvexHull.size() ; i ++) {
|
||||
size_t NextIdx = ( i == vPtConvexHull.size() - 1) ? 0 : i + 1 ;
|
||||
CurveLine * pLine = CreateBasicCurveLine() ;
|
||||
pLine->Set( vPtConvexHull[i], vPtConvexHull[NextIdx]) ;
|
||||
|
||||
// verifico se ho regioni da eliminare
|
||||
IntersCurveCurve intCC( *pLine, *pCrv) ;
|
||||
CRVCVECTOR ccClass ;
|
||||
intCC.GetCurveClassification( 0, ccClass) ;
|
||||
for ( size_t j = 0 ; j < ccClass.size() ; j ++) {
|
||||
if ( ccClass[j].nClass == CRVC_OUT) {
|
||||
// cerco per tentativi un punto a caso all'interno della regione da eliminare
|
||||
double dPar = ( ccClass[j].dParS + ccClass[j].dParE) / 2 ;
|
||||
double dDist = 0 ;
|
||||
Point3d pt ;
|
||||
Vector3d vtDir ;
|
||||
while ( dDist < EPS_SMALL) {
|
||||
if ( dPar > ccClass[j].dParE)
|
||||
return false ;
|
||||
pLine->GetPointTang( dPar, ICurve::FROM_MINUS, pt, vtDir) ;
|
||||
vtDir.Rotate( Z_AX, 0, 1) ;
|
||||
DistPointCurve distPtCrv( pt, *pCrv) ;
|
||||
dDist = 0.0 ;
|
||||
distPtCrv.GetDist( dDist) ;
|
||||
if ( dDist > EPS_SMALL) {
|
||||
pt += EPS_SMALL * ( vtDir) ;
|
||||
vDelaunayHoles.push_back( Delaunay::Point( pt.x , pt.y)) ;
|
||||
}
|
||||
// tento con nuovo punto
|
||||
dPar += 10 * EPS_SMALL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// triangolazione
|
||||
Delaunay trGenerator( vDelaunayVert) ;
|
||||
trGenerator.setSegmentConstraint( vDelaunayConstr) ;
|
||||
trGenerator.setHolesConstraint( vDelaunayHoles) ;
|
||||
if ( bConforming)
|
||||
trGenerator.TriangulateConf( true) ;
|
||||
else
|
||||
trGenerator.Triangulate( bQuality) ;
|
||||
|
||||
// se non ho generato triangoli, errore
|
||||
if ( trGenerator.ntriangles() == 0)
|
||||
return false ;
|
||||
|
||||
// vertici
|
||||
std::vector< Delaunay::Point> vVertex = trGenerator.MyVertexTraverse() ;
|
||||
for (size_t i = 0; i < vVertex.size(); i++) {
|
||||
Point3d pt( vVertex[i][0], vVertex[i][1]) ;
|
||||
pt.ToGlob( frLoc) ;
|
||||
vPt.push_back( pt) ;
|
||||
}
|
||||
|
||||
// triangoli
|
||||
vTr = trGenerator.MyTriangleTraverse() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Delaunay Triangulation ( Geometric Tools Engine library)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::MakeByDelaunayGTE( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
{
|
||||
// sistema di riferimento locale sul piano della polyline
|
||||
Plane3d plPlane ;
|
||||
double dArea;
|
||||
if ( ! vPL[0].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
|
||||
return false ;
|
||||
Frame3d frLoc ;
|
||||
frLoc.Set( plPlane.GetPoint(), plPlane.GetVersN()) ;
|
||||
|
||||
POLYLINEVECTOR vMyPL = vPL ;
|
||||
for ( size_t t = 0 ; t < vPL.size() ; ++ t) {
|
||||
vMyPL[t].ToLoc( frLoc) ;
|
||||
if ( vMyPL[t].GetPointNbr() < 4)
|
||||
return false ;
|
||||
}
|
||||
|
||||
CurveComposite * pCrvPL = CreateBasicCurveComposite() ;
|
||||
pCrvPL->FromPolyLine( vMyPL[0]) ;
|
||||
|
||||
// controllo che holes siano contenuti nel loop esterno
|
||||
for ( size_t i = 1 ; i < vMyPL.size() ; i ++) {
|
||||
CurveComposite * pCrvHole = CreateBasicCurveComposite() ;
|
||||
pCrvHole->FromPolyLine( vMyPL[i]) ;
|
||||
|
||||
IntersCurveCurve intCC( *pCrvPL, *pCrvHole) ;
|
||||
CRVCVECTOR ccClass ;
|
||||
intCC.GetCurveClassification( 1, ccClass) ;
|
||||
|
||||
if ( ccClass.size() > 1 || ccClass[0].nClass != CRVC_IN)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Verifico non ci siano autointersezioni
|
||||
SelfIntersCurve Inters( *pCrvPL) ;
|
||||
if ( Inters.GetIntersCount() > 0 && Inters.GetOverlaps() == 0)
|
||||
return false ;
|
||||
|
||||
// Gestione autointersezione
|
||||
// if ( Inters.GetIntersCount() > 0 && Inters.GetOverlaps() == 0) {
|
||||
//
|
||||
// // vertici della triangolazione
|
||||
// vector<Vector2<double>> vPoints ;
|
||||
// Point3d pt ;
|
||||
// vMyPL[0].GetFirstPoint( pt) ;
|
||||
// vPoints.push_back( {pt.x, pt.y}) ;
|
||||
// pt.ToGlob( frLoc) ;
|
||||
// vPt.push_back( pt) ;
|
||||
// while ( vMyPL[0].GetNextPoint( pt) ) {
|
||||
// vPoints.push_back( {pt.x, pt.y}) ;
|
||||
// pt.ToGlob( frLoc) ;
|
||||
// vPt.push_back( pt) ;
|
||||
// }
|
||||
// vPt.pop_back() ;
|
||||
// vPoints.pop_back() ;
|
||||
//
|
||||
// // i punti di autointersezione P sono salvati come pair: parametro di P, indice posizione di P in vPoints
|
||||
// vector<pair<double,int>> dParams ;
|
||||
// for ( int i = 0 ; i < Inters.GetIntersCount() ; i++) {
|
||||
//
|
||||
// IntCrvCrvInfo aInfo ;
|
||||
// Inters.GetIntCrvCrvInfo( i, aInfo) ;
|
||||
//
|
||||
// Point3d pt ;
|
||||
// pt = aInfo.IciA[0].ptI ;
|
||||
// pt.ToGlob( frLoc) ;
|
||||
//
|
||||
// auto it = find_if( vPt.begin(), vPt.end(), [pt]( const Point3d& ptCrv){ return AreSamePointApprox( ptCrv, pt) ;} ) ;
|
||||
// // se il punto di interezione è uno dei vertici
|
||||
// if ( it != vPt.end()) {
|
||||
// dParams.push_back( pair<double, int> (aInfo.IciA[0].dU, it - vPt.begin())) ;
|
||||
// dParams.push_back( pair<double, int> (aInfo.IciB[0].dU, it - vPt.begin())) ;
|
||||
// }
|
||||
// // se non è uno dei vertici, lo aggiungo in vPt e in vPoints
|
||||
// else {
|
||||
// vPt.push_back( pt) ;
|
||||
// pt.ToLoc( frLoc) ;
|
||||
// vPoints.push_back( { pt.x, pt.y}) ;
|
||||
// dParams.push_back( pair<double, int> (aInfo.IciA[0].dU, vPoints.size() - 1)) ;
|
||||
// dParams.push_back( pair<double, int> (aInfo.IciB[0].dU, vPoints.size() - 1)) ;
|
||||
// }
|
||||
// }
|
||||
// sort( dParams.begin(), dParams.end(), []( const pair<double, int>& a, const pair<double, int>& b){ return a.first < b.first ; }) ;
|
||||
//
|
||||
// // lati del poligono :
|
||||
// INTVECTOR vPolygonIdx ;
|
||||
// for ( int i = 0 ; i < vMyPL[0].GetPointNbr() ; i++)
|
||||
// vPolygonIdx.push_back( i) ;
|
||||
//
|
||||
// // inserisco i nuovi lati determinati dai punti di intersezione
|
||||
// for ( int i = 0 ; i < dParams.size() ; i++) {
|
||||
// // se il parametro c'è già, non lo inserisco
|
||||
// if ( find_if( vPolygonIdx.begin(), vPolygonIdx.end(),
|
||||
// [dParams, i]( const int& val) { return abs( val - dParams[i].first) < 0 ; }) != vPolygonIdx.end())
|
||||
// break ;
|
||||
// // altrimenti lo inserisco in modo ordinato nel vettore
|
||||
// auto it = lower_bound( vPolygonIdx.begin(), vPolygonIdx.end(), dParams[i].first,
|
||||
// []( const int& a , const int& b) { return a < b ; }) ;
|
||||
// vPolygonIdx.insert( it, dParams[i].second) ;
|
||||
// }
|
||||
//
|
||||
// auto pPolygon = std::make_shared<PolygonTree>() ;
|
||||
// pPolygon->polygon = vPolygonIdx ;
|
||||
//
|
||||
// // holes
|
||||
// int k = vPoints.size() ;
|
||||
// for ( size_t i = 1 ; i < vMyPL.size() ; i++) {
|
||||
//
|
||||
// auto pHole = std::make_shared<PolygonTree>() ;
|
||||
// Point3d pt ;
|
||||
// vMyPL[i].GetFirstPoint( pt) ;
|
||||
// vPoints.push_back( { pt.x, pt.y}) ;
|
||||
// pHole->polygon.push_back( k) ;
|
||||
// k ++ ;
|
||||
// while ( vMyPL[i].GetNextPoint( pt)) {
|
||||
// vPoints.push_back( { pt.x, pt.y}) ;
|
||||
// pHole->polygon.push_back( k) ;
|
||||
// k ++ ;
|
||||
// }
|
||||
//
|
||||
// vPoints.pop_back() ;
|
||||
// pHole->polygon.pop_back() ;
|
||||
// k -- ;
|
||||
//
|
||||
// pPolygon->child.push_back( pHole) ;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // Triangolazione
|
||||
// PolygonTreeEx PTOutput ;
|
||||
// TriangulateCDT<double> triangulator ;
|
||||
// triangulator( vPoints, pPolygon, PTOutput) ;
|
||||
//
|
||||
// for ( auto const& tri : PTOutput.interiorTriangles) {
|
||||
// vTr.push_back( tri[0]) ;
|
||||
// vTr.push_back( tri[1]) ;
|
||||
// vTr.push_back( tri[2]) ;
|
||||
// }
|
||||
//
|
||||
// return true ;
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// i vertici della triangolazione vPt sono i punti delle polyline nel sistema globale
|
||||
for ( size_t i = 0 ; i < vPL.size() ; i++) {
|
||||
Point3d pt ;
|
||||
vPL[i].GetFirstPoint( pt) ;
|
||||
vPt.push_back( Point3d( pt.x, pt.y, pt.z)) ;
|
||||
while ( vPL[i].GetNextPoint( pt ) )
|
||||
vPt.push_back( Point3d( pt.x, pt.y, pt.z)) ;
|
||||
// ultimo punto della polyline coincide con il primo, quindi non serve
|
||||
vPt.pop_back() ;
|
||||
}
|
||||
|
||||
vector<Vector2<double>> vPoints ; // vertici per la triangolazione
|
||||
auto pPolygon = std::make_shared<PolygonTree>() ; // poligono da triangolare
|
||||
|
||||
Point3d pt ;
|
||||
int k = 0 ;
|
||||
vMyPL[0].GetFirstPoint( pt) ;
|
||||
vPoints.push_back( { pt.x, pt.y}) ;
|
||||
pPolygon->polygon.push_back( k) ;
|
||||
k ++ ;
|
||||
|
||||
while ( vMyPL[0].GetNextPoint( pt) ) {
|
||||
vPoints.push_back( { pt.x, pt.y}) ;
|
||||
pPolygon->polygon.push_back( k) ;
|
||||
k ++ ;
|
||||
}
|
||||
|
||||
// ultimo punto della polyline coincide con il primo, quindi non serve
|
||||
vPoints.pop_back() ;
|
||||
pPolygon->polygon.pop_back() ;
|
||||
k -- ;
|
||||
|
||||
// holes
|
||||
for ( size_t i = 1 ; i < vMyPL.size() ; i++) {
|
||||
|
||||
auto pHole = std::make_shared<PolygonTree>() ;
|
||||
vMyPL[i].GetFirstPoint( pt) ;
|
||||
vPoints.push_back( { pt.x, pt.y}) ;
|
||||
pHole->polygon.push_back( k) ;
|
||||
k ++ ;
|
||||
while ( vMyPL[i].GetNextPoint( pt)) {
|
||||
vPoints.push_back( { pt.x, pt.y}) ;
|
||||
pHole->polygon.push_back( k) ;
|
||||
k ++ ;
|
||||
}
|
||||
|
||||
vPoints.pop_back() ;
|
||||
pHole->polygon.pop_back() ;
|
||||
k -- ;
|
||||
|
||||
pPolygon->child.push_back( pHole) ;
|
||||
|
||||
}
|
||||
|
||||
// Triangolazione
|
||||
PolygonTreeEx PTOutput ;
|
||||
TriangulateCDT<double> triangulator ;
|
||||
triangulator( vPoints, pPolygon, PTOutput) ;
|
||||
|
||||
for ( auto const & tri : PTOutput.interiorTriangles) {
|
||||
vTr.push_back( tri[0]) ;
|
||||
vTr.push_back( tri[1]) ;
|
||||
vTr.push_back( tri[2]) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::PrepareGrid( const PNTVECTOR& vPt, const INTVECTOR& vPol,
|
||||
@@ -273,7 +674,7 @@ Triangulate::MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& v
|
||||
vTr.push_back( vPol[i]) ;
|
||||
vTr.push_back( vPol[vNext[i]]) ;
|
||||
}
|
||||
// ‘Delete’ vertex v[i] by redirecting next and previous links
|
||||
// �Delete� vertex v[i] by redirecting next and previous links
|
||||
// of neighboring verts past it. Decrement vertex count
|
||||
vNext[vPrev[i]] = vNext[i] ;
|
||||
vPrev[vNext[i]] = vPrev[i] ;
|
||||
@@ -393,7 +794,7 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR&
|
||||
// Reset earity of diagonal endpoints
|
||||
vEar[vPrev[i]] = EAS_NULL ;
|
||||
vEar[vNext[i]] = EAS_NULL ;
|
||||
// ‘Delete’ vertex v[i] by redirecting next and previous links
|
||||
// �Delete� vertex v[i] by redirecting next and previous links
|
||||
// of neighboring verts past it. Decrement vertex count
|
||||
vNext[vPrev[i]] = vNext[i] ;
|
||||
vPrev[vNext[i]] = vPrev[i] ;
|
||||
@@ -506,7 +907,7 @@ Triangulate::MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR&
|
||||
// Reset earity of diagonal endpoints
|
||||
vEar[vPrev[i]] = EAS_NULL ;
|
||||
vEar[vNext[i]] = EAS_NULL ;
|
||||
// ‘Delete’ vertex v[i] by redirecting next and previous links
|
||||
// �Delete� vertex v[i] by redirecting next and previous links
|
||||
// of neighboring verts past it. Decrement vertex count
|
||||
vNext[vPrev[i]] = vNext[i] ;
|
||||
vPrev[vNext[i]] = vPrev[i] ;
|
||||
@@ -570,7 +971,7 @@ Triangulate::TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol,
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The ‘ear’ triangle is clockwise so v[i] is not an ear
|
||||
// The �ear� triangle is clockwise so v[i] is not an ear
|
||||
bIsEar = false ;
|
||||
}
|
||||
|
||||
@@ -896,14 +1297,14 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// non ho trovato alcunché, errore
|
||||
// non ho trovato alcunch�, errore
|
||||
if ( nI == - 1)
|
||||
return false ;
|
||||
// se ho trovato un punto esatto del contorno, non devo fare altri controlli
|
||||
if ( AreSamePointApprox( ptInt, vPt[nI]))
|
||||
return true ;
|
||||
// devo ora verificare che il segmento che unisce i punti non intersechi altri lati del contorno esterno
|
||||
// altrimenti tengo il punto con raggio più vicino a X_AX o Y_AX o Z_AX secondo m_nPlane
|
||||
// altrimenti tengo il punto con raggio pi� vicino a X_AX o Y_AX o Z_AX secondo m_nPlane
|
||||
int nJ = nI ;
|
||||
Point3d ptPa = ptP ;
|
||||
Point3d ptPb = vPt[nI] ;
|
||||
@@ -919,7 +1320,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
||||
double dMinTan = INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < nNumPt ; ++ i) {
|
||||
// salto il punto già trovato
|
||||
// salto il punto gi� trovato
|
||||
if ( i == nJ)
|
||||
continue ;
|
||||
// verifico se sta nel triangolo
|
||||
@@ -955,7 +1356,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
||||
bool
|
||||
Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const Point3d& ptCorn, const Point3d& ptNext)
|
||||
{
|
||||
// la parte valida del settore è a sinistra dei segmenti ptPrev --> ptCorn --> ptNext
|
||||
// la parte valida del settore � a sinistra dei segmenti ptPrev --> ptCorn --> ptNext
|
||||
// se corner convesso
|
||||
if ( TriangleIsCCW( ptPrev, ptCorn, ptNext, 0))
|
||||
return ( TriangleIsCCW( ptPrev, ptCorn, ptTest) &&
|
||||
@@ -970,10 +1371,10 @@ Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const
|
||||
bool
|
||||
ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi)
|
||||
{
|
||||
// se il nuovo inizio coincide col vecchio, non devo fare alcunché
|
||||
// se il nuovo inizio coincide col vecchio, non devo fare alcunch�
|
||||
if ( nNewStart == 0)
|
||||
return true ;
|
||||
// se il nuovo indice è oltre la dimensione del vettore, errore
|
||||
// se il nuovo indice � oltre la dimensione del vettore, errore
|
||||
if ( nNewStart >= int( vPi.size()))
|
||||
return false ;
|
||||
// ciclo di aggiustamento
|
||||
|
||||
+12
-2
@@ -16,12 +16,20 @@
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
||||
|
||||
//
|
||||
enum TrgType { TRG_STANDARD, // ear clipping
|
||||
TRG_DEL_CONFORMING, // conforming constrained Delaunay ( with quality constraint)
|
||||
TRG_DEL_QUALITY, // constrained Delaunay with quality constraints ( no angle smaller than 20 degrees)
|
||||
TRG_DEL_NOQUALITY, // constrained Delaunay without quality constraints
|
||||
TRG_DEL_GTE // constrained Delaunay with Geomtric Tools Engine library
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Triangulate
|
||||
{
|
||||
public :
|
||||
bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||
bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||
bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType = TRG_STANDARD) ;
|
||||
bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType = TRG_STANDARD) ;
|
||||
|
||||
private :
|
||||
bool PrepareGrid( const PNTVECTOR& vPt, const INTVECTOR& vPol,
|
||||
@@ -29,6 +37,8 @@ class Triangulate
|
||||
bool MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ;
|
||||
bool MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ;
|
||||
bool MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ;
|
||||
bool MakeByDelaunay( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, bool bConforming, bool bQuality) ;
|
||||
bool MakeByDelaunayGTE( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||
bool TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol,
|
||||
const INTVECTOR& vPrev, INTVECTOR& vNext, int i) ;
|
||||
double CalcTriangleAspectRatio( const Point3d& ptPa, const Point3d& ptPb, const Point3d& ptPc) ;
|
||||
|
||||
+5
-8
@@ -34,8 +34,8 @@ GEOOBJ_REGISTER( VOL_ZMAP, NGE_V_ZMP, VolZmap) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
VolZmap::VolZmap(void)
|
||||
: m_nStatus( TO_VERIFY), m_dStep( 10.0), m_nMapNum( 0), m_nShape( GENERIC), m_nVoxNumPerBlock( N_VOXBLOCK),
|
||||
m_nDexVoxRatio( 1), m_nNumBlock( 0), m_nConnectedCompoCount( 0), m_Tool( true)
|
||||
: m_nStatus( TO_VERIFY), m_nMapNum( 0), m_nNumBlock( 0), m_nConnectedCompoCount( 0), m_dStep( 10.0),
|
||||
m_nVoxNumPerBlock( N_VOXBLOCK), m_nDexVoxRatio( 1), m_nShape( GENERIC), m_nTempProp( 0), m_Tool( true)
|
||||
{
|
||||
for ( int i = 0 ; i < N_MAPS ; ++ i) {
|
||||
m_nNx[i] = 0 ;
|
||||
@@ -45,8 +45,6 @@ VolZmap::VolZmap(void)
|
||||
m_dMaxZ[i] = 0 ;
|
||||
m_nFracLin[i] = 0 ;
|
||||
}
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_Tool.SetTolerances( LIN_TOL_STD, ANG_TOL_APPROX_DEG) ;
|
||||
}
|
||||
|
||||
@@ -74,8 +72,7 @@ VolZmap::Clear( void)
|
||||
m_Values[i].clear() ;
|
||||
}
|
||||
m_dStep = EPS_SMALL ;
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
m_nTempProp = 0 ;
|
||||
m_Tool.Clear() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
@@ -141,8 +138,7 @@ VolZmap::CopyFrom( const VolZmap& vzmSrc)
|
||||
|
||||
m_dStep = vzmSrc.m_dStep ;
|
||||
m_nStatus = vzmSrc.m_nStatus ;
|
||||
m_nTempProp[0] = vzmSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = vzmSrc.m_nTempProp[1] ;
|
||||
m_nTempProp = vzmSrc.m_nTempProp ;
|
||||
|
||||
// dimensiono membri legati ai blocchi
|
||||
m_BlockToUpdate = vzmSrc.m_BlockToUpdate ;
|
||||
@@ -762,6 +758,7 @@ VolZmap::CheckMapConnection( void)
|
||||
int tStopIntZ = int( m_Values[0][tDexZ].size()) ;
|
||||
// Ciclo sugli intervalli del dexel
|
||||
for ( int tIntZ = 0 ; tIntZ < tStopIntZ ; ++ tIntZ) {
|
||||
|
||||
if ( m_Values[0][tDexZ][tIntZ].nCompo == 0) {
|
||||
++ m_nConnectedCompoCount ;
|
||||
m_Values[0][tDexZ][tIntZ].nCompo = m_nConnectedCompoCount ;
|
||||
|
||||
@@ -60,11 +60,10 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
|
||||
public : // IVolZmap
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -402,7 +401,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
double m_dStep ; // passo delle griglie
|
||||
int m_nMapNum ; // numero di griglie ( 1 o 3)
|
||||
Frame3d m_MapFrame ; // riferimento intrinseco dello Zmap
|
||||
|
||||
+5
-5
@@ -249,7 +249,7 @@ VolZmap::IntersRayDexel( const Point3d& ptP, const Vector3d& vtV, int nGrid, int
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Calcola la profondità del materiale lungo un raggio, identificato da un punto e un versore.
|
||||
// Calcola la profondità del materiale lungo un raggio, identificato da un punto e un versoreore.
|
||||
// Punto e versore devono essere espressi nel sistema di riferimento locale, in cui è immerso quello dello Zmap.
|
||||
// InLength = distanza di ingresso (se -1 il punto è interno, se -2 il punto è esterno e il raggio non interseca lo Zmap)
|
||||
// OutLength = distanza di uscita
|
||||
@@ -293,7 +293,7 @@ VolZmap::GetDepthWithDexel( const Point3d& ptPLoc, const Vector3d& vtDLoc, doubl
|
||||
double dOutLen[N_MAPS] ;
|
||||
|
||||
// Ciclo sulle griglie
|
||||
for ( int nGrid = 0 ; nGrid < m_nMapNum ; ++ nGrid) {
|
||||
for ( int nGrid = 0 ; nGrid < m_nMapNum ; ++ nGrid) {
|
||||
|
||||
Point3d ptP0 = ptP ;
|
||||
Vector3d vtV0 = vtD ;
|
||||
@@ -417,7 +417,7 @@ VolZmap::GetDepthWithDexel( const Point3d& ptPLoc, const Vector3d& vtDLoc, doubl
|
||||
else {
|
||||
dInLength = INFINITO ;
|
||||
dOutLength = - INFINITO ;
|
||||
for ( int nGr = 0 ; nGr < m_nMapNum ; ++ nGr) {
|
||||
for ( int nGr = 0 ; nGr < 3 ; ++ nGr) {
|
||||
if ( dInLen[nGr] > -2 && dInLen[nGr] < dInLength)
|
||||
dInLength = dInLen[nGr] ;
|
||||
if ( dOutLen[nGr] > -2 && dOutLen[nGr] > dOutLength)
|
||||
@@ -3130,8 +3130,8 @@ VolZmap::GetPartVolume( int nPart, double& dVol) const
|
||||
|
||||
// Eseguo il calcolo della lunghezza totale degli spilloni
|
||||
double dLen = 0 ;
|
||||
for ( int nMap = 0 ; nMap < m_nMapNum ; ++ nMap) {
|
||||
for ( int nDex = 0 ; nDex < m_nDim[nMap] ; ++ nDex) {
|
||||
for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) {
|
||||
for ( int nDex = 0 ; nDex < int( m_Values[nMap].size()) ; ++ nDex) {
|
||||
for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) {
|
||||
// se il pezzo di spillone appartiene alla parte, ne aggiungo la lunghezza
|
||||
if ( m_Values[nMap][nDex][nInt].nCompo == nPart + 1) {
|
||||
|
||||
+2
-2
@@ -220,7 +220,7 @@ VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double
|
||||
|
||||
// Determino le intersezioni della retta con la regione
|
||||
CRVCVECTOR IntersectionResults ;
|
||||
Surf.GetCurveClassification( GridLine, EPS_SMALL, IntersectionResults) ;
|
||||
Surf.GetCurveClassification( GridLine, IntersectionResults) ;
|
||||
|
||||
// Analizzo le parti in cui la retta è stata divisa
|
||||
int nPart = int( IntersectionResults.size()) ;
|
||||
@@ -327,7 +327,7 @@ VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double
|
||||
|
||||
// Determino le intersezioni della retta con la regione
|
||||
CRVCVECTOR IntersectionResults ;
|
||||
Surf.GetCurveClassification( GridLine, EPS_SMALL, IntersectionResults) ;
|
||||
Surf.GetCurveClassification( GridLine, IntersectionResults) ;
|
||||
|
||||
// Analizzo le parti
|
||||
int nPart = int( IntersectionResults.size()) ;
|
||||
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2021
|
||||
// EgalTech 2015-2019
|
||||
//----------------------------------------------------------------------------
|
||||
// File : VolZmap.cpp Data : 13.09.21 Versione : 2.3i1
|
||||
// File : VolZmap.cpp Data : 07.03.19 Versione : 2.1c2
|
||||
// Contenuto : Implementazione della classe Volume Zmap (tre griglie)
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 22.01.15 DS Creazione modulo.
|
||||
// 13.09.21 LM Correzione funzione che determina se voxel su frontiera di un blocco.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -3984,13 +3984,13 @@ VolZmap::IsAVoxelOnBoundary( const int nLimits[], const int nIJK[], int nDeltaIn
|
||||
-- nDeltaIndex[0] ;
|
||||
else if ( nIJK[0] == nLimits[1] - 1)
|
||||
++ nDeltaIndex[0] ;
|
||||
if ( nIJK[1] == nLimits[2])
|
||||
if ( nIJK[0] == nLimits[0])
|
||||
-- nDeltaIndex[1];
|
||||
else if ( nIJK[1] == nLimits[3] - 1)
|
||||
else if ( nIJK[0] == nLimits[1] - 1)
|
||||
++ nDeltaIndex[1];
|
||||
if ( nIJK[2] == nLimits[4])
|
||||
if ( nIJK[0] == nLimits[0])
|
||||
-- nDeltaIndex[2];
|
||||
else if ( nIJK[2] == nLimits[5] - 1)
|
||||
else if ( nIJK[0] == nLimits[1] - 1)
|
||||
++ nDeltaIndex[2];
|
||||
return ( nDeltaIndex[0] != 0 || nDeltaIndex[1] != 0 || nDeltaIndex[2] != 0) ;
|
||||
}
|
||||
|
||||
+635
@@ -0,0 +1,635 @@
|
||||
/*! \file dpoint.hpp
|
||||
\brief d-dimensional point class
|
||||
|
||||
A d-dimensional point class which is written carefully using templates. It allows for basic
|
||||
operations on points in any dimension. Orientation tests for 2 and 3 dimensional points are
|
||||
supported using <a href="http://www.cs.berkeley.edu/~jrs/">Jonathan's</a> code. This class
|
||||
forms the building block of other classes like dplane, dsphere etc.
|
||||
|
||||
\author <a href="www.compgeom.com/~piyush">Piyush Kumar</a>
|
||||
\bug No known bugs.
|
||||
*/
|
||||
|
||||
#ifndef REVIVER_POINT_HPP
|
||||
#define REVIVER_POINT_HPP
|
||||
|
||||
// changed mrkkrj --
|
||||
//#include "assert.hpp"
|
||||
#include "tpp_assert.hpp"
|
||||
// END changed --
|
||||
#include <iostream>
|
||||
#include <valarray>
|
||||
#include <stdio.h>
|
||||
#include <limits>
|
||||
|
||||
|
||||
//! The reviver namespace signifies the part of the code borrowed from reviver (dpoint.hpp).
|
||||
namespace reviver {
|
||||
|
||||
|
||||
// Forward Declaration of the main Point Class
|
||||
// Eucledian d-dimensional point. The distance is L_2
|
||||
|
||||
template<typename NumType, unsigned D>
|
||||
class dpoint;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Internal number type traits for dpoint
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
class InternalNumberType;
|
||||
|
||||
template<>
|
||||
class InternalNumberType<float>{
|
||||
public:
|
||||
typedef double __INT;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
class InternalNumberType<int>{
|
||||
public:
|
||||
typedef long long __INT;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
class InternalNumberType<double>{
|
||||
public:
|
||||
typedef double __INT;
|
||||
};
|
||||
|
||||
template<>
|
||||
class InternalNumberType<long>{
|
||||
public:
|
||||
typedef long long __INT;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Origin of d-dimensional point
|
||||
///////////////////////////////////////////////////////
|
||||
template< typename NumType, unsigned D, unsigned I > struct origin
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& p )
|
||||
{
|
||||
p[I] = 0.0;
|
||||
origin< NumType, D, I-1 >::eval( p );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Partial Template Specialization
|
||||
template <typename NumType, unsigned D> struct origin<NumType, D, 0>
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& p )
|
||||
{
|
||||
p[0] = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! A structure to compute squared distances between points
|
||||
/*!
|
||||
Uses unrolling of loops using templates.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// Squared Distance of d-dimensional point
|
||||
///////////////////////////////////////////////////////
|
||||
template< typename NumType, unsigned D, unsigned I > struct Distance
|
||||
{
|
||||
static inline double eval( const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
double sum = ((double)p[I] - (double)q[I] ) *( (double)p[I] - (double)q[I] );
|
||||
return sum + Distance< NumType, D, I-1 >::eval( p,q );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Partial Template Specialization for distance calculations
|
||||
template <typename NumType, unsigned D> struct Distance<NumType, D, 0>
|
||||
{
|
||||
static inline double eval( const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
return ((double) p[0] - (double)q[0] )*( (double)p[0] - (double)q[0] );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! A structure to compute dot product between two points or associated vectors
|
||||
/*!
|
||||
Uses unrolling of loops using templates.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// Dot Product of two d-dimensional points
|
||||
///////////////////////////////////////////////////////
|
||||
template< typename __INT, typename NumType, unsigned D, unsigned I > struct DotProd
|
||||
{
|
||||
static inline __INT eval( const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
__INT sum = ( ((__INT)p[I]) * ((__INT)q[I]) );
|
||||
return sum + DotProd< __INT, NumType, D, I-1 >::eval( p,q );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Partial Template Specialization for dot product calculations
|
||||
template < typename __INT, typename NumType, unsigned D> struct DotProd<__INT,NumType, D, 0>
|
||||
{
|
||||
static inline __INT eval( const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
return ( ((__INT)p[0]) * ((__INT)q[0]) );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Equality of two d-dimensional points
|
||||
///////////////////////////////////////////////////////
|
||||
template< typename NumType, unsigned D, unsigned I > struct IsEqual
|
||||
{
|
||||
static inline bool eval( const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
if( p[I] != q[I] ) return false;
|
||||
else return IsEqual< NumType, D, I-1 >::eval( p,q );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Partial Template Specialization
|
||||
template <typename NumType, unsigned D> struct IsEqual<NumType, D, 0>
|
||||
{
|
||||
static inline NumType eval( const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
return (p[0] == q[0])?1:0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! Equate two d-dimensional points.
|
||||
/*!
|
||||
Uses unrolling of loops using templates.
|
||||
A class used to implement operator= for points. This class also helps in automatic type
|
||||
conversions of points (with explicit calls for conversion).
|
||||
*/
|
||||
template<
|
||||
typename NumType1,
|
||||
typename NumType2,
|
||||
unsigned D,
|
||||
unsigned I
|
||||
> struct Equate
|
||||
{
|
||||
static inline void eval( dpoint<NumType1,D>& p,const dpoint<NumType2,D>& q )
|
||||
{
|
||||
p[I] = q[I];
|
||||
Equate< NumType1, NumType2, D, I-1 >::eval( p,q );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Partial Template Specialization for Equate
|
||||
template <
|
||||
typename NumType1,
|
||||
typename NumType2,
|
||||
unsigned D
|
||||
> struct Equate<NumType1,NumType2, D, 0>
|
||||
{
|
||||
static inline void eval( dpoint<NumType1,D>& p,const dpoint<NumType2,D>& q )
|
||||
{
|
||||
p[0] = q[0];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! A structure to add two points
|
||||
/*!
|
||||
Uses unrolling of loops using templates.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// Add two d-dimensional points
|
||||
///////////////////////////////////////////////////////
|
||||
template< typename NumType, unsigned D, unsigned I > struct Add
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& result, const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
result[I] = p[I] + q[I];
|
||||
Add< NumType, D, I-1 >::eval( result,p,q );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Partial Template Specialization for Add structure
|
||||
template <typename NumType, unsigned D> struct Add<NumType, D, 0>
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& result, const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
result[0] = p[0] + q[0];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Subtract two d-dimensional points
|
||||
///////////////////////////////////////////////////////
|
||||
// Could actually be done using scalar multiplication and addition
|
||||
|
||||
|
||||
// What about unsigned types?
|
||||
template< typename NumType >
|
||||
inline NumType Subtract_nums(const NumType& x, const NumType& y) {
|
||||
if(!std::numeric_limits<NumType>::is_signed) {
|
||||
std::cerr << "Exception: Can't subtract unsigned types."; exit(1);
|
||||
}
|
||||
return x - y;
|
||||
}
|
||||
|
||||
|
||||
//! Subtract two d-dimensional vectors
|
||||
/*!
|
||||
Caution: Do not use on unsigned types.
|
||||
*/
|
||||
template< typename NumType, unsigned D, unsigned I > struct Subtract
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& result, const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
|
||||
result[I] = Subtract_nums(p[I] , q[I]);
|
||||
Subtract< NumType, D, I-1 >::eval( result,p,q );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Partial Template Specialization for subtraction of points (associated vectors)
|
||||
template <typename NumType, unsigned D> struct Subtract<NumType, D, 0>
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& result, const dpoint<NumType,D>& p, const dpoint<NumType,D>& q )
|
||||
{
|
||||
result[0] = Subtract_nums(p[0] , q[0]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//! Mutiply scalar with d-dimensional point
|
||||
/*!
|
||||
Scalar mulipltication of d-dimensional point with a number using template unrolling.
|
||||
*/
|
||||
template< typename NumType, unsigned D, unsigned I > struct Multiply
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& result, const dpoint<NumType,D>& p, NumType k)
|
||||
{
|
||||
result[I] = p[I] * k;
|
||||
Multiply< NumType, D, I-1 >::eval( result,p,k );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Partial Template Specialization for scalar multiplication
|
||||
template <typename NumType, unsigned D> struct Multiply<NumType, D, 0>
|
||||
{
|
||||
static inline void eval( dpoint<NumType,D>& result, const dpoint<NumType,D>& p, NumType k )
|
||||
{
|
||||
result[0] = p[0] * k;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! Main d dimensional Point Class
|
||||
/*!
|
||||
- NumType = Floating Point Type
|
||||
- D = Dimension of Point
|
||||
*/
|
||||
template<typename NumType = double, unsigned D = 3>
|
||||
class dpoint {
|
||||
|
||||
// Makes Swap operation fast
|
||||
NumType x[D];
|
||||
|
||||
public:
|
||||
typedef NumType NT;
|
||||
typedef typename InternalNumberType<NumType>::__INT __INT;
|
||||
|
||||
// To be defined in a cpp file
|
||||
// const MgcVector2 MgcVector2::ZERO(0,0);
|
||||
// static const dpoint<NumType,D> Zero;
|
||||
|
||||
inline void move2origin(){ origin<NumType, D, D-1>::eval(*this); };
|
||||
|
||||
dpoint(){
|
||||
Assert( (D >= 1), "Dimension < 1 not allowed" );
|
||||
// move2origin();
|
||||
};
|
||||
|
||||
//! 1 D Point
|
||||
dpoint(NumType x0){ x[0] = x0; };
|
||||
//! 2 D Point
|
||||
dpoint(NumType x0,NumType x1){ x[0] = x0; x[1] = x1; };
|
||||
//! 3 D Point
|
||||
dpoint(NumType x0,NumType x1,NumType x2){ x[0] = x0; x[1] = x1; x[2] = x2; };
|
||||
//! Array Initialization
|
||||
dpoint(NumType ax[]){ for(int i =0; i < D; ++i) x[i] = ax[i]; };
|
||||
//! Initialization from another point : Copy Constructor
|
||||
dpoint(const dpoint<NumType,D>& p){ Equate<NumType,NumType,D,D-1>::eval((*this),p); };
|
||||
|
||||
|
||||
//! Automatic type conversions of points.
|
||||
//! Only allowed if the conversion is specified explicitly by the programmer.
|
||||
template<class OtherNumType>
|
||||
explicit dpoint(const dpoint<OtherNumType,D>& p){ Equate<NumType,OtherNumType,D,D-1>::eval((*this),p); };
|
||||
|
||||
// Destructor
|
||||
~dpoint(){};
|
||||
|
||||
inline int dim() const { return D; };
|
||||
inline double sqr_dist(const dpoint<NumType,D> q) const ;
|
||||
inline double distance(const dpoint<NumType,D> q) const ;
|
||||
inline __INT dotprod (const dpoint<NumType,D> q) const ;
|
||||
inline __INT sqr_length(void) const;
|
||||
inline void normalize (void);
|
||||
inline NumType& operator[](int i);
|
||||
inline NumType operator[](int i) const;
|
||||
|
||||
inline dpoint& operator= (const dpoint<NumType,D>& q);
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
friend dpoint<NT,__DIM> operator- (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q);
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
friend dpoint<NT,__DIM> operator+ (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q);
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
friend bool operator== (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q);
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
friend bool operator!= (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q);
|
||||
|
||||
|
||||
// inline dpoint& operator= (const valarray<NumType>& v);
|
||||
// inline operator valarray<NumType>() const;
|
||||
|
||||
template<typename __NT,unsigned __DIM>
|
||||
friend void iswap(dpoint<__NT,__DIM>& p,dpoint<__NT,__DIM>& q);
|
||||
};
|
||||
|
||||
template<typename NumType, unsigned D>
|
||||
void dpoint<NumType,D>::normalize (void){
|
||||
double len = sqrt(sqr_length());
|
||||
if (len > 0.00001)
|
||||
for(int i = 0; i < D; ++i){
|
||||
x[i] /= len;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
template<typename NumType, unsigned D>
|
||||
dpoint<NumType,D>::operator valarray<NumType>() const{
|
||||
valarray<NumType> result((*this).x , D);
|
||||
return result;
|
||||
}
|
||||
|
||||
//Warning : Valarray should be of size D
|
||||
//TODO: Unwind this for loop into a template system
|
||||
template<typename NumType, unsigned D>
|
||||
dpoint<NumType,D>&
|
||||
dpoint<NumType,D>::operator= (const valarray<NumType>& v){
|
||||
dpoint<NumType,D> result;
|
||||
for(int i = 0; i < D; i++) (*this).x[i] = v[i];
|
||||
return (*this);
|
||||
}
|
||||
*/
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
dpoint<NT,__DIM>
|
||||
operator+ (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q){
|
||||
dpoint<NT,__DIM> result;
|
||||
Add<NT,__DIM,__DIM-1>::eval(result,p,q);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
dpoint<NT,__DIM>
|
||||
operator- (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q){
|
||||
dpoint<NT,__DIM> result;
|
||||
// cout << "Subtracting..." << p << " from " << q << " = ";
|
||||
Subtract<NT,__DIM,__DIM-1>::eval(result,p,q);
|
||||
// cout << result << endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
bool
|
||||
operator== (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q){
|
||||
return IsEqual<NT,__DIM,__DIM-1>::eval(p,q);
|
||||
}
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
bool
|
||||
operator!= (const dpoint<NT,__DIM>& p, const dpoint<NT,__DIM>& q){
|
||||
return !(IsEqual<NT,__DIM,__DIM-1>::eval(p,q));
|
||||
}
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
dpoint<NT,__DIM>
|
||||
operator* (const dpoint<NT,__DIM>& p, const NT k){
|
||||
dpoint<NT,__DIM> result;
|
||||
Multiply<NT,__DIM,__DIM-1>::eval(result,p,k);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename NT, unsigned __DIM>
|
||||
dpoint<NT,__DIM>
|
||||
operator/ (const dpoint<NT,__DIM>& p, const NT k){
|
||||
Assert( (k != 0), "Hell division by zero man...\n");
|
||||
dpoint<NT,__DIM> result;
|
||||
Multiply<NT,__DIM,__DIM-1>::eval(result,p,((double)1.0)/k);
|
||||
return result;
|
||||
}
|
||||
|
||||
template < typename NumType, unsigned D >
|
||||
dpoint<NumType,D>&
|
||||
dpoint<NumType,D>::operator=(const dpoint<NumType,D> &q)
|
||||
{
|
||||
Assert((this != &q), "Error p = p");
|
||||
Equate<NumType,NumType,D,D-1>::eval(*this,q);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template < typename NumType, unsigned D >
|
||||
NumType
|
||||
dpoint<NumType,D>::operator[](int i) const
|
||||
{ return x[i]; }
|
||||
|
||||
template < typename NumType, unsigned D >
|
||||
NumType&
|
||||
dpoint<NumType,D>::operator[](int i)
|
||||
{
|
||||
return x[i];
|
||||
}
|
||||
|
||||
|
||||
template<typename NumType, unsigned D>
|
||||
double
|
||||
dpoint<NumType,D>::sqr_dist (const dpoint<NumType,D> q) const {
|
||||
return Distance<NumType,D,D-1>::eval(*this,q);
|
||||
}
|
||||
|
||||
template<typename NumType, unsigned D>
|
||||
double
|
||||
dpoint<NumType,D>::distance (const dpoint<NumType,D> q) const {
|
||||
return sqrt(static_cast<double>(Distance<NumType,D,D-1>::eval(*this,q)));
|
||||
}
|
||||
|
||||
|
||||
template<typename NumType, unsigned D>
|
||||
typename dpoint<NumType,D>::__INT
|
||||
dpoint<NumType,D>::dotprod (const dpoint<NumType,D> q) const {
|
||||
return DotProd<__INT,NumType,D,D-1>::eval(*this,q);
|
||||
}
|
||||
|
||||
template<typename NumType, unsigned D>
|
||||
typename dpoint<NumType,D>::__INT
|
||||
dpoint<NumType,D>::sqr_length (void) const {
|
||||
#ifdef _DEBUG
|
||||
if( DotProd<__INT,NumType,D,D-1>::eval(*this,*this) < 0) {
|
||||
std::cerr << "Point that caused error: ";
|
||||
std::cerr << *this << std::endl;
|
||||
std::cerr << DotProd<__INT,NumType,D,D-1>::eval(*this,*this) << std::endl;
|
||||
std::cerr << "Fatal: Hell!\n"; exit(1);
|
||||
}
|
||||
#endif
|
||||
return DotProd<__INT,NumType,D,D-1>::eval(*this,*this);
|
||||
|
||||
}
|
||||
|
||||
template < class NumType, unsigned D >
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os,const dpoint<NumType,D> &p)
|
||||
{
|
||||
os << "Point (d=";
|
||||
os << D << ", (";
|
||||
for (unsigned int i=0; i<D-1; ++i)
|
||||
os << p[i] << ", ";
|
||||
return os << p[D-1] << "))";
|
||||
|
||||
};
|
||||
|
||||
template < class NumType, unsigned D >
|
||||
std::istream&
|
||||
operator>>(std::istream& is,dpoint<NumType,D> &p)
|
||||
{
|
||||
for (int i=0; i<D; ++i)
|
||||
if(!(is >> p[i])){
|
||||
if(!is.eof()){
|
||||
std::cerr << "Error Reading Point:"
|
||||
<< is << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return is;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
template<typename __NT,unsigned __DIM>
|
||||
static inline void iswap(dpoint<__NT,__DIM>& p,dpoint<__NT,__DIM>& q){
|
||||
__NT *y;
|
||||
y = p.x;
|
||||
p.x = q.x;
|
||||
q.x = y;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
template < typename NumType, unsigned D >
|
||||
dpoint<NumType, D> CrossProd(const dpoint<NumType, D>& vector1,
|
||||
const dpoint<NumType, D>& vector2) {
|
||||
Assert(D == 3, "Cross product only defined for 3d vectors");
|
||||
dpoint<NumType, D> vector;
|
||||
vector[0] = (vector1[1] * vector2[2]) - (vector2[1] * vector1[2]);
|
||||
vector[1] = (vector2[0] * vector1[2]) - (vector1[0] * vector2[2]);
|
||||
vector[2] = (vector1[0] * vector2[1]) - (vector2[0] * vector1[1]);
|
||||
return vector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template < typename __NT, unsigned __DIM >
|
||||
int
|
||||
orientation(const dpoint<__NT,__DIM> p[__DIM+1])
|
||||
{
|
||||
int _sign = + 1;
|
||||
// To be implemented
|
||||
std::cerr << "Not yet implemented\n";
|
||||
exit(1);
|
||||
return _sign;
|
||||
|
||||
}
|
||||
|
||||
|
||||
template < typename __NT >
|
||||
inline __NT
|
||||
orientation(
|
||||
const dpoint<__NT,2>& p,
|
||||
const dpoint<__NT,2>& q,
|
||||
const dpoint<__NT,2>& r
|
||||
)
|
||||
{
|
||||
// 2D speaciliazation for orientation
|
||||
std::cout << "FATAL";
|
||||
exit(1);
|
||||
return ((p[0]-r[0])*(q[1]-r[1]))-((q[0]-r[0])*(p[1]-r[1]));
|
||||
}
|
||||
|
||||
|
||||
extern "C" double orient2d(double *p, double *q, double *r);
|
||||
|
||||
template < >
|
||||
inline double
|
||||
orientation<double>(
|
||||
const dpoint<double,2>& p,
|
||||
const dpoint<double,2>& q,
|
||||
const dpoint<double,2>& r
|
||||
)
|
||||
{
|
||||
// 2D speaciliazation for orientation
|
||||
double pp[2] = { p[0], p[1] };
|
||||
double qq[2] = { q[0], q[1] };
|
||||
double rr[2] = { r[0], r[1] };
|
||||
return orient2d(pp,qq,rr);
|
||||
}
|
||||
|
||||
|
||||
template < >
|
||||
inline float
|
||||
orientation<float>(
|
||||
const dpoint<float,2>& p,
|
||||
const dpoint<float,2>& q,
|
||||
const dpoint<float,2>& r
|
||||
)
|
||||
{
|
||||
// 2D speaciliazation for orientation
|
||||
double pp[2] = { p[0], p[1] };
|
||||
double qq[2] = { q[0], q[1] };
|
||||
double rr[2] = { r[0], r[1] };
|
||||
return (float)orient2d(pp,qq,rr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; // Namespace Ends here
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*! \file assert.cpp
|
||||
\brief Implements a better 'Assert'
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if _WINDOWS
|
||||
#include <cassert>
|
||||
#endif
|
||||
|
||||
namespace tpp {
|
||||
|
||||
/*! \def MyAssertFunction
|
||||
\brief Function used by 'Assert' function in _DEBUG mode.
|
||||
|
||||
Details.
|
||||
*/
|
||||
bool MyAssertFunction( bool b, const char* desc, int line, const char* file){
|
||||
// changed mrkkrj --
|
||||
#if _WINDOWS
|
||||
(void)desc;
|
||||
(void)line;
|
||||
(void)file;
|
||||
assert(b); // use integration with Visual Studio!
|
||||
(void)b;
|
||||
return true;
|
||||
#else
|
||||
// Original:
|
||||
if (b) return true;
|
||||
std::cerr << "\n\nAssertion Failure\n";
|
||||
std::cerr << "Description : " << desc << std::endl;
|
||||
std::cerr << "Filename : " << file << std::endl;
|
||||
std::cerr << "Line No : " << line << std::endl;
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace
|
||||
@@ -0,0 +1,29 @@
|
||||
/*! \file assert.hpp
|
||||
\brief Implements a better 'Assert'.
|
||||
Used in the reviver::dpoint inplementation.
|
||||
*/
|
||||
|
||||
namespace tpp {
|
||||
|
||||
#ifndef REVIVER_ASSERT_HPP
|
||||
#define REVIVER_ASSERT_HPP
|
||||
|
||||
/*! \def MyAssertFunction
|
||||
\brief Function used by 'Assert' function in _DEBUG mode.
|
||||
*/
|
||||
extern bool MyAssertFunction( bool b, const char* desc, int line, const char* file);
|
||||
|
||||
|
||||
#if defined( _DEBUG )
|
||||
// changed mrkkrj --
|
||||
//#define Assert( exp, description ) MyAssertFunction( (int)(exp), description, __LINE__, __FILE__ )
|
||||
#define Assert( exp, description ) tpp::MyAssertFunction( (int)(exp), description, __LINE__, __FILE__ )
|
||||
// END changed --
|
||||
#else
|
||||
#define Assert( exp, description )
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
+1454
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,719 @@
|
||||
|
||||
/*! \file tpp_interface.hpp
|
||||
\brief The main Delaunay C++ class of the Triangle++ wrapper.
|
||||
|
||||
Use this class to produce Delaunay triangulations.
|
||||
|
||||
The following description pertains to the original version, the current version
|
||||
was ported to VisualStudio. Thus it doesn't need Python scripts, and is supposed
|
||||
to be used *as it is* in your program!
|
||||
*/
|
||||
|
||||
|
||||
/*! \mainpage Triangle++
|
||||
\section intro Introduction
|
||||
<table border="0">
|
||||
<tr><td>
|
||||
If you do not know, what a Delaunay triangulation is, you can read more about it
|
||||
<a href="http://www.compgeom.com/~piyush/teach/5930/slides/lecture8.ppt">here</a> and
|
||||
<a href="http://en.wikipedia.org/wiki/Delaunay_triangulation">here</a>.
|
||||
This C++ library module is just a wrapper class on the
|
||||
<a href="http://www.cs.berkeley.edu/~jrs/">Triangle</a>
|
||||
package of <a href="http://www.cs.berkeley.edu/~jrs/">Jonathan</a>.
|
||||
|
||||
Many times I have had to use triangle in C++ code bases of mine and have been forced to use C.
|
||||
At last I thought I would put a wrapper on his cool C code and it seems that this is what I got.
|
||||
|
||||
The design is not perfect and the code was written in a day, but it does compile and run on the
|
||||
machines I tried (cygwin/redhat). The C++ wrapper will certainly slow access down if you want to
|
||||
mess with the triangulation but the basic delaunay triangulation should be as fast as triangle.
|
||||
|
||||
Look at the tpp_interface.hpp file for getting started on what this wrapper can do for you. Also
|
||||
have a look at main.cpp which shows an example of using this class. The class is thread-safe.
|
||||
<p>
|
||||
<b>Requirements</b> : Python, make and C++ compilers.
|
||||
Supported C/C++ Compilers: g++ / icpc (Intel C++).
|
||||
Also needed is doxygen for generating documentation.
|
||||
</p>
|
||||
<p>
|
||||
<b>Compilation</b> : Just type 'make'</p>
|
||||
<p>
|
||||
<b>Testing</b> : Goto the bin directory, and type './test ../data/input.dat' (after compilation of course).
|
||||
</p>
|
||||
</td>
|
||||
<td><img src="http://upload.wikimedia.org/wikipedia/en/9/92/Delaunay_triangulation.png" alt="Delaunay Triangulation Example"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
\section Downloads
|
||||
You can download the latest version of the source code from <a href="triangle++.tar.gz">here</a>.
|
||||
|
||||
\section authors Authors
|
||||
<ul>
|
||||
<li><a href="http://compgeom.com/~piyush">Piyush Kumar</a></li>
|
||||
<li><a href="http://www.ib-krajewski.de">Marek Krajewski</a></li>
|
||||
<li>Hopefully more to come... (please feel free to extend this wrapper)</li>
|
||||
</ul>
|
||||
|
||||
\section changelog Change Log
|
||||
|
||||
17/04/20: mrkkrj – added support Voronoi tesselation <br>
|
||||
22/01/20: mrkkrj – added support for custom constraints (angle and area) <br>
|
||||
17/09/18: mrkkrj – ported to 64-bit (preliminary, not thorougly tested!) <br>
|
||||
11/07/11: mrkkrj - bugfix in Triangle's divandconqdelauney() <br>
|
||||
10/15/11: mrkkrj - added support for the "quality triangulation" option, added some debug support<br>
|
||||
08/24/11: mrkkrj - Ported to VisualStudio, added comp. operators, reformatted and added some comments<br>
|
||||
10/21/06: Replaced vertexsort with C++ sort.<br>
|
||||
10/25/06: Wrapped in tpp namespace for usage with other libraries with similar names.
|
||||
Added some more documentation/small changes. Used doxygen 1.5.0 and dot. Tested compilation with
|
||||
icc 9.0/9.1, gcc-4.1/3.4.6. <br>
|
||||
11/03/06: Fixed the compilation system. <br>
|
||||
|
||||
\todo
|
||||
<ol>
|
||||
<li> Intel Compiler Warnings with -Wall </li>
|
||||
<ul>
|
||||
<li> remove the compiler warnings for icpc 9.0/9.1</li>
|
||||
</ul>
|
||||
|
||||
<li> Implement vertexmedian() in C++. </li>
|
||||
<li> Implement the flip operator as a member function of Delaunay. </li>
|
||||
</ol>
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
#ifndef TRPP_INTERFACE
|
||||
#define TRPP_INTERFACE
|
||||
|
||||
// changed mrkkrj --
|
||||
//#include <dpoint.hpp>
|
||||
#include "dpoint.hpp"
|
||||
// END changed --
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
//! The main namespace in which the Triangle++ project lives
|
||||
namespace tpp {
|
||||
|
||||
// (mrkkrj)
|
||||
enum DebugOutputLevel {
|
||||
None,
|
||||
Info, // most useful; it gives information on algorithmic progress and much more detailed statistics
|
||||
Vertex, // gives vertex-by-vertex details, and prints so much that Triangle runs much more slowly
|
||||
Debug // gives information only a debugger could love
|
||||
};
|
||||
|
||||
//! The main Delaunay Class that wraps around Triangle.
|
||||
/*!
|
||||
This is a C++ wrapper of the Triangle package by JRS.
|
||||
|
||||
This class currently uses the dpoint class written by me (the point class is a d-dimensional point
|
||||
class reviver::dpoint (but for this application it only uses the d=2 case).
|
||||
Additionally, the inner helper C++ class Triwrap groups the original Triangle's C functions.
|
||||
|
||||
\author Piyush Kumar, mrkkrj
|
||||
|
||||
\note (mrkkrj) For for backgroud info on the Triangle's implementation see "Triangle:
|
||||
Engineering a 2D Quality Mesh Generator and Delaunay Triangulator" by JP Shewchuk:
|
||||
www.cs.cmu.edu/~quake-papers/triangle.ps
|
||||
*/
|
||||
class Delaunay {
|
||||
public:
|
||||
//! Point Typedef
|
||||
/*! Warning: If you want to use your own point class, you might have to
|
||||
work hard...
|
||||
- mrkkrj: true!!! - spare your time, use an adapter class.
|
||||
*/
|
||||
typedef reviver::dpoint <double, 2> Point;
|
||||
|
||||
//! The main constructor.
|
||||
/*!
|
||||
Takes a vector of 2 dimensional points where each of the coordinates is
|
||||
expressed as double.
|
||||
*/
|
||||
Delaunay(const std::vector<Point>& points);
|
||||
|
||||
//! The main destructor.
|
||||
/*!
|
||||
Does memory cleanup mostly.
|
||||
*/
|
||||
~Delaunay();
|
||||
|
||||
//! Delaunay Triangulate the input points (Quality)
|
||||
/*!
|
||||
This function calls Triangle.h to Delaunay-triangulate points given as input to the
|
||||
constructor of this class. Here a Quality triangualtion will be created.
|
||||
|
||||
\param quality enforce minimal angle (default: 20°) and, minimal area (only if explicitely set)
|
||||
*/
|
||||
void Triangulate(bool quality = false, DebugOutputLevel = None);
|
||||
|
||||
//! Delaunay Triangulate the input points (Conforming)
|
||||
/*!
|
||||
This function calls Triangle.h to Delaunay-triangulate points given as input to the
|
||||
constructor of this class. Here a Conforming triangualtion will be created.
|
||||
*/
|
||||
void TriangulateConf(bool quality = false, DebugOutputLevel = None);
|
||||
|
||||
//! Voronoi-tesselate the input points (added mrkkrj)
|
||||
/*!
|
||||
This function calls triangle to create a Voronoi diagram with points given as input
|
||||
to the constructor of this class.
|
||||
|
||||
Note that a Voronoi diagram can be only created if the underlying triangulation is convex
|
||||
and doesn't have holes!
|
||||
|
||||
\param useConformingDelaunay use conforming Delaunay triangulation as base for the Voronoi diagram
|
||||
*/
|
||||
void Tesselate(bool useConformingDelaunay = false, DebugOutputLevel traceLvl = None);
|
||||
|
||||
//! Set a quality constraint for the triangulation
|
||||
/*!
|
||||
\param angle min. resulting angle, if angle <= 0, the constraint will be removed.
|
||||
*/
|
||||
void setMinAngle(float angle) {
|
||||
m_minAngle = angle;
|
||||
}
|
||||
|
||||
//! Set a quality constraint for the triangulation
|
||||
/*!
|
||||
\param area max. triangle area, if area <= 0, the constraint will be removed.
|
||||
*/
|
||||
void setMaxArea(float area) {
|
||||
m_maxArea = area;
|
||||
}
|
||||
|
||||
//! Set the segments to constrain the triangulation
|
||||
/*!
|
||||
Takes a vector of 2 dimensional points where each consecutive pair of points describes a single segment.
|
||||
Both endpoints of every segment are vertices of the input vector, and a segment may intersect other segments
|
||||
and vertices only at its endpoints.
|
||||
|
||||
\return true if the input is valid, false otherwise
|
||||
*/
|
||||
bool setSegmentConstraint(const std::vector<Point>& segments);
|
||||
|
||||
//! Set the segments to constrain the triangulation
|
||||
/*!
|
||||
Same as above, but usign indexes of the input points!
|
||||
|
||||
\return true if the input is valid, false otherwise
|
||||
*/
|
||||
bool setSegmentConstraint(const std::vector<int>& segmentPointIndexes);
|
||||
|
||||
//! Set the holes to constrain the triangulation
|
||||
/*!
|
||||
Takes a vector of 2 dimensional points where each consecutive pair of points describes a single edge of a hole.
|
||||
|
||||
\return true if the input is valid, false otherwise
|
||||
*/
|
||||
bool setHolesConstraint(const std::vector<Point>& holes);
|
||||
|
||||
//! Are the quality constrainst sane?
|
||||
/*!
|
||||
\possible true if is highly probable for triangualtion to succeed
|
||||
\return true if triangualtion is guaranteed to succeed
|
||||
*/
|
||||
bool checkConstraints(bool& possible) const;
|
||||
|
||||
//! Are the quality constrainst sane, take two
|
||||
/*!
|
||||
\relaxed report highly probable as correct too, as error otherwise
|
||||
\return true if triangualtion is guaranteed to succeed, or at least higly probable to
|
||||
*/
|
||||
bool checkConstraintsOpt(bool relaxed) const;
|
||||
|
||||
//! Get minAngle intervals
|
||||
/*!
|
||||
\guaranteed up to this value triangualtion is guaranteed to succeed
|
||||
\possible up to this value it is highly probable for triangualtion to succeed
|
||||
*/
|
||||
static void getMinAngleBoundaries(float& guaranteed, float& possible);
|
||||
|
||||
//! Set a user test function for the triangulation
|
||||
/*!
|
||||
OPEN TODO::: (use the -u switch!!!!)
|
||||
*/
|
||||
void setUserConstraint(bool (*f)()) {};
|
||||
|
||||
//! Output a geomview .off file containing the delaunay triangulation
|
||||
/*!
|
||||
\param fname output file name.
|
||||
*/
|
||||
void writeoff(std::string& fname);
|
||||
|
||||
//! Number of edges in the triangulation
|
||||
/*!
|
||||
\return Number of Edges
|
||||
Remember to call Triangulate before using this function.
|
||||
*/
|
||||
int nedges() const;
|
||||
|
||||
//! Number of triangles in the triangulation
|
||||
/*!
|
||||
\return Number of Triangles
|
||||
Remember to call Triangulate before using this function.
|
||||
*/
|
||||
int ntriangles() const;
|
||||
|
||||
//! Number of vertices in the triangulation
|
||||
/*!
|
||||
\return Number of Vertices
|
||||
Remember to call Triangulate before using this function.
|
||||
*/
|
||||
int nvertices() const;
|
||||
|
||||
//! Number of vertices on the convex hull.
|
||||
/*!
|
||||
\return Number of vertices on the convex hull.
|
||||
Remember to call Triangulate before using this function.
|
||||
*/
|
||||
int hull_size() const;
|
||||
|
||||
//! Number of Voronoi points in the tesselation
|
||||
/*!
|
||||
\return Number of Points
|
||||
Remember to call Tesselate before using this function.
|
||||
*/
|
||||
int nvpoints() const;
|
||||
|
||||
//! Number of Voronoi edges in the tesselation
|
||||
/*!
|
||||
\return Number of Edges
|
||||
Remember to call Tesselate before using this function.
|
||||
*/
|
||||
int nvedges() const;
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
// Vertex Iterator
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
//! The vertex iterator for the Delaunay class
|
||||
class vIterator {
|
||||
private:
|
||||
vIterator(Delaunay* tiangulator); //! To set container
|
||||
|
||||
Delaunay* MyDelaunay; //! Which container do I point
|
||||
void* vloop; //! Triangles Internal data.
|
||||
|
||||
public:
|
||||
vIterator operator++();
|
||||
vIterator() :vloop(nullptr) {};
|
||||
Point& operator*() const;
|
||||
~vIterator();
|
||||
|
||||
friend class Delaunay;
|
||||
friend bool operator==(vIterator const&, vIterator const&);
|
||||
friend bool operator!=(vIterator const&, vIterator const&);
|
||||
};
|
||||
|
||||
//! Vertex iterator begin function
|
||||
vIterator vbegin() { return vIterator(this); };
|
||||
//! Vertex iterator end function
|
||||
vIterator vend();
|
||||
|
||||
//! Given an iterator, find its index in the input vector of points.
|
||||
int vertexId(vIterator const& vit) const;
|
||||
|
||||
//! Given an index, return the actual double Point
|
||||
const Point& point_at_vertex_id(int i) { return m_PList[i]; };
|
||||
|
||||
//! Return the Point additionally created in quality mesh generation ("q" option)
|
||||
Point added_point_at_vertex_id(int i);
|
||||
|
||||
friend class vIterator;
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
// Face Iterator
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
//! The face iterator for the Delaunay class
|
||||
class fIterator {
|
||||
private:
|
||||
|
||||
struct tdata {
|
||||
double*** tri;
|
||||
int orient;
|
||||
};
|
||||
|
||||
typedef struct tdata poface;
|
||||
|
||||
fIterator(Delaunay* tiangulator); //! To set container
|
||||
|
||||
Delaunay* MyDelaunay; //! Which container do I point
|
||||
//void *floop; //! Triangles Internal data.
|
||||
poface floop;
|
||||
|
||||
public:
|
||||
void operator++();
|
||||
fIterator() { floop.tri = nullptr; };
|
||||
~fIterator();
|
||||
|
||||
friend class Delaunay;
|
||||
friend bool operator==(fIterator const&, fIterator const&);
|
||||
friend bool operator!=(fIterator const&, fIterator const&);
|
||||
friend bool operator<(fIterator const&, fIterator const&); // added mrkkrj
|
||||
};
|
||||
|
||||
//! Face iterator begin function
|
||||
fIterator fbegin() { return fIterator(this); };
|
||||
//! Face iterator end function
|
||||
fIterator fend();
|
||||
int faceId(fIterator const&);
|
||||
|
||||
|
||||
//! Access the origin (Org) vertex of a face.
|
||||
/*!
|
||||
\param fit Face interator.
|
||||
\param point if specified: the cordinates of the vertex
|
||||
\return Index of the vertex in m_pList,
|
||||
or -1 if quality option was used and a new vertex was created!
|
||||
|
||||
A triangle abc has origin (org) a,destination (dest) b, and apex (apex)
|
||||
c. These vertices occur in counterclockwise order about the triangle.
|
||||
Remember to call Triangulate before using this function. Do not use it on a null iterator.
|
||||
*/
|
||||
int Org(fIterator const& fit, Point* point = 0);
|
||||
|
||||
|
||||
//! Access the destination (Dest) vertex of a face.
|
||||
/*!
|
||||
\param fit Face interator.
|
||||
\param point if specified: the cordinates of the vertex
|
||||
\return Index of the vertex in m_pList,
|
||||
or -1 if quality option was used and a new vertex was created!
|
||||
|
||||
A triangle abc has origin (org) a,destination (dest) b, and apex (apex)
|
||||
c. These vertices occur in counterclockwise order about the triangle.
|
||||
Remember to call Triangulate before using this function. Do not use it on a null iterator.
|
||||
*/
|
||||
int Dest(fIterator const& fit, Point* point = 0);
|
||||
|
||||
|
||||
//! Access the apex (Apex) vertex of a face.
|
||||
/*!
|
||||
\param fit Face interator.
|
||||
\param point if specified: the cordinates of the vertex
|
||||
\return Index of the vertex in m_pList,
|
||||
or -1 if quality option was used and a new vertex was created!
|
||||
|
||||
A triangle abc has origin (org) a,destination (dest) b, and apex (apex)
|
||||
c. These vertices occur in counterclockwise order about the triangle.
|
||||
Remember to call Triangulate before using this function. Do not use it on a null iterator.
|
||||
*/
|
||||
int Apex(fIterator const& fit, Point* point = 0);
|
||||
|
||||
|
||||
//! Access the triangle adjoining edge i
|
||||
/*!
|
||||
\param fit Face Iterator
|
||||
\param i edge number
|
||||
\return The vertex on the opposite face, or -1 (see Org() above)
|
||||
|
||||
A triangle abc has origin (org) a,destination (dest) b, and apex (apex)
|
||||
c. These vertices occur in counterclockwise order about the triangle.
|
||||
<ul>
|
||||
<li>sym(abc, 0) -> ba*</li>
|
||||
<li>sym(abc, 1) -> cb*</li>
|
||||
<li>sym(abc, 2) -> ac*</li>
|
||||
</ul>
|
||||
* is the farthest vertex on the adjoining triangle whose index
|
||||
is returned. A -1 is returned if the edge is part of the convex hull.
|
||||
Remember to call Triangulate before using this function.
|
||||
Do not use it on a null iterator.
|
||||
*/
|
||||
int Sym(fIterator const& fit, char i);
|
||||
|
||||
|
||||
//! Access the triangle opposite to current edge of the face
|
||||
/*!
|
||||
\param fit Face iterator
|
||||
\return The iterator of the opposite face
|
||||
|
||||
A triangle abc has origin (org) a,destination (dest) b, and apex (apex)
|
||||
c. These vertices occur in counterclockwise order about the triangle.
|
||||
The iterator
|
||||
to the triangle is returned. The iterator is empty if the edge
|
||||
is on the convex hull.
|
||||
Remember to call Triangulate before using this function.
|
||||
Do not use it on a null iterator.
|
||||
*/
|
||||
fIterator Sym(fIterator const& fit);
|
||||
|
||||
|
||||
//! Is the iterator empty?
|
||||
/*!
|
||||
\param fit Face interator.
|
||||
\return true if the iterator is empty
|
||||
*/
|
||||
inline bool empty(fIterator const& fit)
|
||||
{
|
||||
return fit.floop.tri == nullptr;
|
||||
};
|
||||
|
||||
|
||||
//! Is the iterator pointing to the dummy triangle?
|
||||
/*!
|
||||
\param fit Face interator.
|
||||
\return true if the iterator is of the dummy triangle.
|
||||
*/
|
||||
bool isdummy(fIterator const& fit);
|
||||
|
||||
|
||||
//! Find the next edge (counterclockwise) of a triangle.
|
||||
/*!
|
||||
\param fit face iterator
|
||||
\return The face iterator corresponding to the next counterclockwise edge of a triangle
|
||||
|
||||
Lnext(abc) -> bca.
|
||||
Remember to call Triangulate before using this function.
|
||||
Do not use it on a null iterator.
|
||||
*/
|
||||
fIterator Lnext(fIterator const& fit);
|
||||
|
||||
|
||||
//! Find the previous edge (clockwise) of a triangle.
|
||||
/*!
|
||||
\param fit face iterator
|
||||
\return The face iterator corresponding to the previous clockwise edge of a triangle
|
||||
|
||||
Lprev(abc) -> cab.
|
||||
Remember to call Triangulate before using this function.
|
||||
Do not use it on a null iterator.
|
||||
*/
|
||||
fIterator Lprev(fIterator const& fit);
|
||||
|
||||
|
||||
//! Find the next edge (counterclockwise) of a triangle with the same origin
|
||||
/*!
|
||||
\param fit face iterator
|
||||
\return The face iterator corresponding to the next edge counterclockwise with the same origin.
|
||||
|
||||
Onext(abc) -> ac*.
|
||||
Remember to call Triangulate before using this function.
|
||||
Do not use it on a null iterator.
|
||||
*/
|
||||
fIterator Onext(fIterator const& fit);
|
||||
|
||||
|
||||
//! Find the next edge clockwise with the same origin.
|
||||
/*!
|
||||
\param fit face iterator
|
||||
\return The face iterator corresponding to the next edge clockwise with the same origin.
|
||||
|
||||
Onext(abc) -> a*b.
|
||||
Remember to call Triangulate before using this function.
|
||||
Do not use it on a null iterator.
|
||||
*/
|
||||
fIterator Oprev(fIterator const& fit);
|
||||
|
||||
|
||||
// TODO List: (for face iterators)
|
||||
/* dnext: Find the next edge counterclockwise with the same destination. */
|
||||
/* dnext(abc) -> *ba */
|
||||
/* */
|
||||
/* dprev: Find the next edge clockwise with the same destination. */
|
||||
/* dprev(abc) -> cb* */
|
||||
/* */
|
||||
/* rnext: Find the next edge (counterclockwise) of the adjacent triangle. */
|
||||
/* rnext(abc) -> *a* */
|
||||
/* */
|
||||
/* rprev: Find the previous edge (clockwise) of the adjacent triangle. */
|
||||
/* rprev(abc) -> b** */
|
||||
|
||||
|
||||
//! Calculate incident triangles around a vertex.
|
||||
/*!
|
||||
\param vertexid The vertex for which you want incident triangles.
|
||||
\param ivv Returns triangles around a vertex in counterclockwise order.
|
||||
|
||||
Note that behaviour is undefined if vertexid is greater than
|
||||
number of vertices - 1. Remember to call Triangulate before using this function.
|
||||
All triangles returned have Org(triangle) = vertexid.
|
||||
All triangles returned are in counterclockwise order.
|
||||
*/
|
||||
void trianglesAroundVertex(int vertexid, std::vector<int>& ivv);
|
||||
|
||||
|
||||
//! Calculate the area of a face.
|
||||
/*!
|
||||
\param fit Face interator.
|
||||
\return area of the face associated with the iterator.
|
||||
|
||||
*/
|
||||
double area(fIterator const& fit);
|
||||
|
||||
|
||||
//! Point locate a vertex v
|
||||
/*!
|
||||
\param vertexid vertex id
|
||||
\return a face iterator whose origin is v.
|
||||
*/
|
||||
fIterator locate(int vertexid); // OPEN:: doesn't seem to be working!
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
// Voronoi Points Iterator
|
||||
// (added mrkkrj)
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
//! The Voronoi points iterator for the Delaunay class
|
||||
class vvIterator {
|
||||
public:
|
||||
vvIterator();
|
||||
vvIterator operator++();
|
||||
Point& operator*() const;
|
||||
void advance(int steps);
|
||||
|
||||
private:
|
||||
vvIterator(Delaunay* tiangulator); //! To set container
|
||||
|
||||
Delaunay* m_delaunay; //! Which container do I point to
|
||||
void* vvloop; //! Triangle's Internal data.
|
||||
int vvindex;
|
||||
int vvcount;
|
||||
|
||||
friend class Delaunay;
|
||||
friend bool operator==(vvIterator const&, vvIterator const&);
|
||||
friend bool operator!=(vvIterator const&, vvIterator const&);
|
||||
};
|
||||
|
||||
//! Voronoi Points iterator begin function
|
||||
vvIterator vvbegin() { return vvIterator(this); };
|
||||
//! Voronoi Points iterator end function
|
||||
vvIterator vvend();
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
// Voronoi Edges Iterator
|
||||
// (added mrkkrj)
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
//! The Voronoi edges iterator for the Delaunay class
|
||||
class veIterator {
|
||||
public:
|
||||
veIterator();
|
||||
veIterator operator++();
|
||||
int startPointId() const;
|
||||
int endPointId(Point& normvec) const;
|
||||
|
||||
private:
|
||||
veIterator(Delaunay* tiangulator); //! To set container
|
||||
|
||||
Delaunay* m_delaunay; //! Which container do I point to
|
||||
void* veloop; //! Triangle's Internal data.
|
||||
int veindex;
|
||||
int vecount;
|
||||
|
||||
friend class Delaunay;
|
||||
friend bool operator==(veIterator const&, veIterator const&);
|
||||
friend bool operator!=(veIterator const&, veIterator const&);
|
||||
};
|
||||
|
||||
//! Voronoi Points iterator begin function
|
||||
veIterator vebegin() { return veIterator(this); };
|
||||
//! Voronoi Points iterator end function
|
||||
veIterator veend();
|
||||
|
||||
|
||||
//! Access the origin (Org) vertex of an edge. (added mrkkrj)
|
||||
/*!
|
||||
\param eit Voronoi Edge iterator.
|
||||
\return The start point of the Voronoi edge,
|
||||
|
||||
Remember to call Tesselate before using this function. Do not use it on a null iterator.
|
||||
*/
|
||||
const Point& Org(veIterator const& eit);
|
||||
|
||||
|
||||
//! Access the destination (Dest) vertex of an edge. (added mrkkrj)
|
||||
/*!
|
||||
\param eit Voronoi Edge iterator.
|
||||
\param finiteEdge true for finite edges, false for inifinte rays.
|
||||
\return The end point of the Voronoi edge, for infinite rays the normal vector of the ray
|
||||
|
||||
Remember to call Tesselate before using this function. Do not use it on a null iterator.
|
||||
*/
|
||||
Point Dest(veIterator const& eit, bool& finiteEdge);
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// added mrkkrj - helper for Points
|
||||
// OPEN:: compiler cannot instantiate less<> with operator<() for Point, why?!
|
||||
//--------------------------------------
|
||||
struct OrderPoints
|
||||
{
|
||||
bool operator() (const Point& lhs, const Point& rhs) const {
|
||||
// first sort on x, then on y coordinates
|
||||
if (lhs[0] < rhs[0]) {
|
||||
return true;
|
||||
}
|
||||
if (lhs[0] == rhs[0] && lhs[1] < rhs[1]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector< Delaunay::Point> MyVertexTraverse( ) ;
|
||||
std::vector< int> Delaunay::MyTriangleTraverse( ) ;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
private:
|
||||
void Triangulate(std::string& triswitches);
|
||||
|
||||
// added mrkkrj - helper functions for face iterator access methods
|
||||
// HACK:: double* as not to export internal impl.
|
||||
void SetPoint(Point& point, double* vertexptr);
|
||||
int GetVertexIndex(fIterator const& fit, double* vertexptr);
|
||||
int GetFirstIndexNumber() const;
|
||||
|
||||
// added mrkkrj
|
||||
std::string formatFloatConstraint(float f) const;
|
||||
void setDebugLevelOption(std::string& options, DebugOutputLevel traceLvl);
|
||||
void freeTriangleDataStructs();
|
||||
|
||||
friend class fIterator;
|
||||
|
||||
private:
|
||||
std::vector<Point> m_PList; /*! Stores the input point list. */
|
||||
void* m_in; /*! Used for intput to triangle */
|
||||
void* m_triangleWrap; /*! Triangle impl. is wrapped in this pointer. */
|
||||
void* m_pmesh; /*! pointer to triangle mesh */
|
||||
void* m_pbehavior;
|
||||
bool m_Triangulated;
|
||||
|
||||
// added mrkkrj:
|
||||
void* m_vorout; /*! pointer to Voronoi output */
|
||||
|
||||
// added mrkkrj: quality constraints
|
||||
float m_minAngle;
|
||||
float m_maxArea;
|
||||
|
||||
// added mrkkrj: segment constraints
|
||||
std::vector<int> m_SList;
|
||||
// added mrkkrj: holes
|
||||
std::vector<Point> m_HList;
|
||||
|
||||
}; // Class Delaunay
|
||||
|
||||
} // namespace tpp ends.
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
|
||||
/*! \file triangle.h
|
||||
\brief Original Triangle package's include file.
|
||||
|
||||
Exports triangulateio structure for use in tpp_impl.hpp. You should not
|
||||
use struct triangulateio in your application if you are using Triangle++
|
||||
wrapper!
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* (triangle.h) */
|
||||
/* */
|
||||
/* Include file for programs that call Triangle. */
|
||||
/* */
|
||||
/* Accompanies Triangle Version 1.6 */
|
||||
/* July 28, 2005 */
|
||||
/* */
|
||||
/* Copyright 1996, 2005 */
|
||||
/* Jonathan Richard Shewchuk */
|
||||
/* 2360 Woolsey #H */
|
||||
/* Berkeley, California 94705-1927 */
|
||||
/* jrs@cs.berkeley.edu */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* How to call Triangle from another program */
|
||||
/* */
|
||||
/* */
|
||||
/* If you haven't read Triangle's instructions (run "triangle -h" to read */
|
||||
/* them), you won't understand what follows. */
|
||||
/* */
|
||||
/* Triangle must be compiled into an object file (triangle.o) with the */
|
||||
/* TRILIBRARY symbol defined (generally by using the -DTRILIBRARY compiler */
|
||||
/* switch). The makefile included with Triangle will do this for you if */
|
||||
/* you run "make trilibrary". The resulting object file can be called via */
|
||||
/* the procedure triangulate(). */
|
||||
/* */
|
||||
/* If the size of the object file is important to you, you may wish to */
|
||||
/* generate a reduced version of triangle.o. The REDUCED symbol gets rid */
|
||||
/* of all features that are primarily of research interest. Specifically, */
|
||||
/* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */
|
||||
/* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */
|
||||
/* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */
|
||||
/* eliminates Triangle's -r, -q, -a, -u, -D, -Y, -S, and -s switches. */
|
||||
/* */
|
||||
/* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */
|
||||
/* made in the makefile or in triangle.c itself. Putting these definitions */
|
||||
/* in this file (triangle.h) will not create the desired effect. */
|
||||
/* */
|
||||
/* */
|
||||
/* The calling convention for triangulate() follows. */
|
||||
/* */
|
||||
/* void triangulate(triswitches, in, out, vorout) */
|
||||
/* char *triswitches; */
|
||||
/* struct triangulateio *in; */
|
||||
/* struct triangulateio *out; */
|
||||
/* struct triangulateio *vorout; */
|
||||
/* */
|
||||
/* `triswitches' is a string containing the command line switches you wish */
|
||||
/* to invoke. No initial dash is required. Some suggestions: */
|
||||
/* */
|
||||
/* - You'll probably find it convenient to use the `z' switch so that */
|
||||
/* points (and other items) are numbered from zero. This simplifies */
|
||||
/* indexing, because the first item of any type always starts at index */
|
||||
/* [0] of the corresponding array, whether that item's number is zero or */
|
||||
/* one. */
|
||||
/* - You'll probably want to use the `Q' (quiet) switch in your final code, */
|
||||
/* but you can take advantage of Triangle's printed output (including the */
|
||||
/* `V' switch) while debugging. */
|
||||
/* - If you are not using the `q', `a', `u', `D', `j', or `s' switches, */
|
||||
/* then the output points will be identical to the input points, except */
|
||||
/* possibly for the boundary markers. If you don't need the boundary */
|
||||
/* markers, you should use the `N' (no nodes output) switch to save */
|
||||
/* memory. (If you do need boundary markers, but need to save memory, a */
|
||||
/* good nasty trick is to set out->pointlist equal to in->pointlist */
|
||||
/* before calling triangulate(), so that Triangle overwrites the input */
|
||||
/* points with identical copies.) */
|
||||
/* - The `I' (no iteration numbers) and `g' (.off file output) switches */
|
||||
/* have no effect when Triangle is compiled with TRILIBRARY defined. */
|
||||
/* */
|
||||
/* `in', `out', and `vorout' are descriptions of the input, the output, */
|
||||
/* and the Voronoi output. If the `v' (Voronoi output) switch is not used, */
|
||||
/* `vorout' may be NULL. `in' and `out' may never be NULL. */
|
||||
/* */
|
||||
/* Certain fields of the input and output structures must be initialized, */
|
||||
/* as described below. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* The `triangulateio' structure. */
|
||||
/* */
|
||||
/* Used to pass data into and out of the triangulate() procedure. */
|
||||
/* */
|
||||
/* */
|
||||
/* Arrays are used to store points, triangles, markers, and so forth. In */
|
||||
/* all cases, the first item in any array is stored starting at index [0]. */
|
||||
/* However, that item is item number `1' unless the `z' switch is used, in */
|
||||
/* which case it is item number `0'. Hence, you may find it easier to */
|
||||
/* index points (and triangles in the neighbor list) if you use the `z' */
|
||||
/* switch. Unless, of course, you're calling Triangle from a Fortran */
|
||||
/* program. */
|
||||
/* */
|
||||
/* Description of fields (except the `numberof' fields, which are obvious): */
|
||||
/* */
|
||||
/* `pointlist': An array of point coordinates. The first point's x */
|
||||
/* coordinate is at index [0] and its y coordinate at index [1], followed */
|
||||
/* by the coordinates of the remaining points. Each point occupies two */
|
||||
/* REALs. */
|
||||
/* `pointattributelist': An array of point attributes. Each point's */
|
||||
/* attributes occupy `numberofpointattributes' REALs. */
|
||||
/* `pointmarkerlist': An array of point markers; one int per point. */
|
||||
/* */
|
||||
/* `trianglelist': An array of triangle corners. The first triangle's */
|
||||
/* first corner is at index [0], followed by its other two corners in */
|
||||
/* counterclockwise order, followed by any other nodes if the triangle */
|
||||
/* represents a nonlinear element. Each triangle occupies */
|
||||
/* `numberofcorners' ints. */
|
||||
/* `triangleattributelist': An array of triangle attributes. Each */
|
||||
/* triangle's attributes occupy `numberoftriangleattributes' REALs. */
|
||||
/* `trianglearealist': An array of triangle area constraints; one REAL per */
|
||||
/* triangle. Input only. */
|
||||
/* `neighborlist': An array of triangle neighbors; three ints per */
|
||||
/* triangle. Output only. */
|
||||
/* */
|
||||
/* `segmentlist': An array of segment endpoints. The first segment's */
|
||||
/* endpoints are at indices [0] and [1], followed by the remaining */
|
||||
/* segments. Two ints per segment. */
|
||||
/* `segmentmarkerlist': An array of segment markers; one int per segment. */
|
||||
/* */
|
||||
/* `holelist': An array of holes. The first hole's x and y coordinates */
|
||||
/* are at indices [0] and [1], followed by the remaining holes. Two */
|
||||
/* REALs per hole. Input only, although the pointer is copied to the */
|
||||
/* output structure for your convenience. */
|
||||
/* */
|
||||
/* `regionlist': An array of regional attributes and area constraints. */
|
||||
/* The first constraint's x and y coordinates are at indices [0] and [1], */
|
||||
/* followed by the regional attribute at index [2], followed by the */
|
||||
/* maximum area at index [3], followed by the remaining area constraints. */
|
||||
/* Four REALs per area constraint. Note that each regional attribute is */
|
||||
/* used only if you select the `A' switch, and each area constraint is */
|
||||
/* used only if you select the `a' switch (with no number following), but */
|
||||
/* omitting one of these switches does not change the memory layout. */
|
||||
/* Input only, although the pointer is copied to the output structure for */
|
||||
/* your convenience. */
|
||||
/* */
|
||||
/* `edgelist': An array of edge endpoints. The first edge's endpoints are */
|
||||
/* at indices [0] and [1], followed by the remaining edges. Two ints per */
|
||||
/* edge. Output only. */
|
||||
/* `edgemarkerlist': An array of edge markers; one int per edge. Output */
|
||||
/* only. */
|
||||
/* `normlist': An array of normal vectors, used for infinite rays in */
|
||||
/* Voronoi diagrams. The first normal vector's x and y magnitudes are */
|
||||
/* at indices [0] and [1], followed by the remaining vectors. For each */
|
||||
/* finite edge in a Voronoi diagram, the normal vector written is the */
|
||||
/* zero vector. Two REALs per edge. Output only. */
|
||||
/* */
|
||||
/* */
|
||||
/* Any input fields that Triangle will examine must be initialized. */
|
||||
/* Furthermore, for each output array that Triangle will write to, you */
|
||||
/* must either provide space by setting the appropriate pointer to point */
|
||||
/* to the space you want the data written to, or you must initialize the */
|
||||
/* pointer to NULL, which tells Triangle to allocate space for the results. */
|
||||
/* The latter option is preferable, because Triangle always knows exactly */
|
||||
/* how much space to allocate. The former option is provided mainly for */
|
||||
/* people who need to call Triangle from Fortran code, though it also makes */
|
||||
/* possible some nasty space-saving tricks, like writing the output to the */
|
||||
/* same arrays as the input. */
|
||||
/* */
|
||||
/* Triangle will not free() any input or output arrays, including those it */
|
||||
/* allocates itself; that's up to you. You should free arrays allocated by */
|
||||
/* Triangle by calling the trifree() procedure defined below. (By default, */
|
||||
/* trifree() just calls the standard free() library procedure, but */
|
||||
/* applications that call triangulate() may replace trimalloc() and */
|
||||
/* trifree() in triangle.c to use specialized memory allocators.) */
|
||||
/* */
|
||||
/* Here's a guide to help you decide which fields you must initialize */
|
||||
/* before you call triangulate(). */
|
||||
/* */
|
||||
/* `in': */
|
||||
/* */
|
||||
/* - `pointlist' must always point to a list of points; `numberofpoints' */
|
||||
/* and `numberofpointattributes' must be properly set. */
|
||||
/* `pointmarkerlist' must either be set to NULL (in which case all */
|
||||
/* markers default to zero), or must point to a list of markers. If */
|
||||
/* `numberofpointattributes' is not zero, `pointattributelist' must */
|
||||
/* point to a list of point attributes. */
|
||||
/* - If the `r' switch is used, `trianglelist' must point to a list of */
|
||||
/* triangles, and `numberoftriangles', `numberofcorners', and */
|
||||
/* `numberoftriangleattributes' must be properly set. If */
|
||||
/* `numberoftriangleattributes' is not zero, `triangleattributelist' */
|
||||
/* must point to a list of triangle attributes. If the `a' switch is */
|
||||
/* used (with no number following), `trianglearealist' must point to a */
|
||||
/* list of triangle area constraints. `neighborlist' may be ignored. */
|
||||
/* - If the `p' switch is used, `segmentlist' must point to a list of */
|
||||
/* segments, `numberofsegments' must be properly set, and */
|
||||
/* `segmentmarkerlist' must either be set to NULL (in which case all */
|
||||
/* markers default to zero), or must point to a list of markers. */
|
||||
/* - If the `p' switch is used without the `r' switch, then */
|
||||
/* `numberofholes' and `numberofregions' must be properly set. If */
|
||||
/* `numberofholes' is not zero, `holelist' must point to a list of */
|
||||
/* holes. If `numberofregions' is not zero, `regionlist' must point to */
|
||||
/* a list of region constraints. */
|
||||
/* - If the `p' switch is used, `holelist', `numberofholes', */
|
||||
/* `regionlist', and `numberofregions' is copied to `out'. (You can */
|
||||
/* nonetheless get away with not initializing them if the `r' switch is */
|
||||
/* used.) */
|
||||
/* - `edgelist', `edgemarkerlist', `normlist', and `numberofedges' may be */
|
||||
/* ignored. */
|
||||
/* */
|
||||
/* `out': */
|
||||
/* */
|
||||
/* - `pointlist' must be initialized (NULL or pointing to memory) unless */
|
||||
/* the `N' switch is used. `pointmarkerlist' must be initialized */
|
||||
/* unless the `N' or `B' switch is used. If `N' is not used and */
|
||||
/* `in->numberofpointattributes' is not zero, `pointattributelist' must */
|
||||
/* be initialized. */
|
||||
/* - `trianglelist' must be initialized unless the `E' switch is used. */
|
||||
/* `neighborlist' must be initialized if the `n' switch is used. If */
|
||||
/* the `E' switch is not used and (`in->numberofelementattributes' is */
|
||||
/* not zero or the `A' switch is used), `elementattributelist' must be */
|
||||
/* initialized. `trianglearealist' may be ignored. */
|
||||
/* - `segmentlist' must be initialized if the `p' or `c' switch is used, */
|
||||
/* and the `P' switch is not used. `segmentmarkerlist' must also be */
|
||||
/* initialized under these circumstances unless the `B' switch is used. */
|
||||
/* - `edgelist' must be initialized if the `e' switch is used. */
|
||||
/* `edgemarkerlist' must be initialized if the `e' switch is used and */
|
||||
/* the `B' switch is not. */
|
||||
/* - `holelist', `regionlist', `normlist', and all scalars may be ignored.*/
|
||||
/* */
|
||||
/* `vorout' (only needed if `v' switch is used): */
|
||||
/* */
|
||||
/* - `pointlist' must be initialized. If `in->numberofpointattributes' */
|
||||
/* is not zero, `pointattributelist' must be initialized. */
|
||||
/* `pointmarkerlist' may be ignored. */
|
||||
/* - `edgelist' and `normlist' must both be initialized. */
|
||||
/* `edgemarkerlist' may be ignored. */
|
||||
/* - Everything else may be ignored. */
|
||||
/* */
|
||||
/* After a call to triangulate(), the valid fields of `out' and `vorout' */
|
||||
/* will depend, in an obvious way, on the choice of switches used. Note */
|
||||
/* that when the `p' switch is used, the pointers `holelist' and */
|
||||
/* `regionlist' are copied from `in' to `out', but no new space is */
|
||||
/* allocated; be careful that you don't free() the same array twice. On */
|
||||
/* the other hand, Triangle will never copy the `pointlist' pointer (or any */
|
||||
/* others); new space is allocated for `out->pointlist', or if the `N' */
|
||||
/* switch is used, `out->pointlist' remains uninitialized. */
|
||||
/* */
|
||||
/* All of the meaningful `numberof' fields will be properly set; for */
|
||||
/* instance, `numberofedges' will represent the number of edges in the */
|
||||
/* triangulation whether or not the edges were written. If segments are */
|
||||
/* not used, `numberofsegments' will indicate the number of boundary edges. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
struct triangulateio {
|
||||
REAL *pointlist; /* In / out */
|
||||
REAL *pointattributelist; /* In / out */
|
||||
int *pointmarkerlist; /* In / out */
|
||||
int numberofpoints; /* In / out */
|
||||
int numberofpointattributes; /* In / out */
|
||||
|
||||
int *trianglelist; /* In / out */
|
||||
REAL *triangleattributelist; /* In / out */
|
||||
REAL *trianglearealist; /* In only */
|
||||
int *neighborlist; /* Out only */
|
||||
int numberoftriangles; /* In / out */
|
||||
int numberofcorners; /* In / out */
|
||||
int numberoftriangleattributes; /* In / out */
|
||||
|
||||
int *segmentlist; /* In / out */
|
||||
int *segmentmarkerlist; /* In / out */
|
||||
int numberofsegments; /* In / out */
|
||||
|
||||
REAL *holelist; /* In / pointer to array copied out */
|
||||
int numberofholes; /* In / copied out */
|
||||
|
||||
REAL *regionlist; /* In / pointer to array copied out */
|
||||
int numberofregions; /* In / copied out */
|
||||
|
||||
int *edgelist; /* Out only */
|
||||
int *edgemarkerlist; /* Not used with Voronoi diagram; out only */
|
||||
REAL *normlist; /* Used only with Voronoi diagram; out only */
|
||||
int numberofedges; /* Out only */
|
||||
};
|
||||
|
||||
#ifdef ANSI_DECLARATORS
|
||||
void triangulate(char *, struct triangulateio *, struct triangulateio *,
|
||||
struct triangulateio *);
|
||||
void trifree(VOID *memptr);
|
||||
#else /* not ANSI_DECLARATORS */
|
||||
void triangulate();
|
||||
void trifree();
|
||||
#endif /* not ANSI_DECLARATORS */
|
||||
|
||||
|
||||
+16198
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user