b5b48bf4c2
- dove possibile e sicuro sostituiti dynamic_cast con static_cast.
166 lines
4.3 KiB
C++
166 lines
4.3 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2013
|
|
//----------------------------------------------------------------------------
|
|
// File : GeoPoint3d.cpp Data : 10.10.13 Versione : 1.2a3
|
|
// Contenuto : Implementazione della classe Punto geometrico.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 10.10.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "GeoPoint3d.h"
|
|
#include "GeoObjFactory.h"
|
|
#include "NgeWriter.h"
|
|
#include "NgeReader.h"
|
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
|
#include "/EgtDev/Include/EGkUiUnits.h"
|
|
#include <new>
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
GeoPoint3d::GeoPoint3d( void)
|
|
: m_ptP()
|
|
{
|
|
m_nTempProp[0] = 0 ;
|
|
m_nTempProp[1] = 0 ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
GeoPoint3d::~GeoPoint3d( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::Set( const Point3d& ptP)
|
|
{
|
|
// assegno i dati
|
|
m_ptP = ptP ;
|
|
|
|
// imposto ricalcolo della grafica
|
|
m_OGrMgr.Reset() ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
GeoPoint3d*
|
|
GeoPoint3d::Clone( void) const
|
|
{
|
|
// alloco oggetto
|
|
GeoPoint3d* pGPt = new( nothrow) GeoPoint3d ;
|
|
if ( pGPt != nullptr) {
|
|
if ( ! pGPt->CopyFrom( *this)) {
|
|
delete pGPt ;
|
|
return nullptr ;
|
|
}
|
|
}
|
|
|
|
return pGPt ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::CopyFrom( const IGeoObj* pGObjSrc)
|
|
{
|
|
const GeoPoint3d* pGP = GetBasicGeoPoint3d( pGObjSrc) ;
|
|
if ( pGP == nullptr)
|
|
return false ;
|
|
return CopyFrom( *pGP) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
|
|
{
|
|
if ( &clSrc == this)
|
|
return true ;
|
|
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
|
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
|
return Set( clSrc.m_ptP) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
GeoObjType
|
|
GeoPoint3d::GetType( void) const
|
|
{
|
|
return static_cast<GeoObjType>( GEOOBJ_GETTYPE( GeoPoint3d)) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
const string&
|
|
GeoPoint3d::GetTitle( void) const
|
|
{
|
|
static const string sTitle = "Point" ;
|
|
return sTitle ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
|
{
|
|
// parametri : punto
|
|
sOut += "P(" + ToString( GetInUiUnits( m_ptP, bMM)) + ")" + szNewLine ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
GeoPoint3d::GetNgeId( void) const
|
|
{
|
|
return GEOOBJ_GETNGEID( GeoPoint3d) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::Save( NgeWriter& ngeOut) const
|
|
{
|
|
// parametri : punto
|
|
return ngeOut.WritePoint( m_ptP, ";", true) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::Load( NgeReader& ngeIn)
|
|
{
|
|
// imposto ricalcolo della grafica
|
|
m_OGrMgr.Reset() ;
|
|
// leggo la prossima linea
|
|
return ngeIn.ReadPoint( m_ptP, ";", true) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
|
{
|
|
// assegno il box in locale
|
|
b3Loc.Set( m_ptP) ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
GeoPoint3d::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
|
{
|
|
// verifico validità del frame
|
|
if ( frRef.GetType() == Frame3d::ERR)
|
|
return false ;
|
|
// porto il punto nel riferimento passato
|
|
Point3d ptP = m_ptP ;
|
|
ptP.ToGlob( frRef) ;
|
|
// assegno il box nel riferimento
|
|
b3Ref.Set( ptP) ;
|
|
|
|
return true ;
|
|
}
|