Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b87b53d43 |
+128
-13
@@ -33,6 +33,8 @@
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkExtDimension.h"
|
||||
#include "/EgtDev/Extern/opennurbs/Include/opennurbs.h"
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
@@ -210,6 +212,18 @@ Export3dm::ExportObject( const IGdbIterator& iIter, const int& nLayer, bool& bAd
|
||||
else
|
||||
bAdded = true ;
|
||||
break ;
|
||||
case EXT_TEXT :
|
||||
if ( ! ExportText( sName, iIter, frFrame, cCol, nLayer))
|
||||
return false ;
|
||||
else
|
||||
bAdded = true ;
|
||||
break ;
|
||||
case EXT_DIMENSION :
|
||||
if ( ! ExportDimension( sName, iIter, frFrame, cCol, nLayer))
|
||||
return false ;
|
||||
else
|
||||
bAdded = true ;
|
||||
break ;
|
||||
}
|
||||
default :
|
||||
break ;
|
||||
@@ -278,6 +292,8 @@ bool
|
||||
Export3dm::AddObjectToModel( const IGdbIterator& iIter, ON_Object* onObject, const int& nLayer, const std::string& sName, const Color& cCol,
|
||||
ON_3dmObjectAttributes* pOnAttr)
|
||||
{
|
||||
if ( onObject == nullptr)
|
||||
return false ;
|
||||
if ( pOnAttr == nullptr)
|
||||
pOnAttr = new ON_3dmObjectAttributes() ;
|
||||
pOnAttr->m_layer_index = nLayer ;
|
||||
@@ -629,52 +645,62 @@ Export3dm::ExportCrvCompo( const string& sName, const IGdbIterator& iIter, const
|
||||
return false ;
|
||||
// verifico oggetto
|
||||
PtrOwner<ICurveComposite> pCrvCompo( GetCurveComposite( pGeoObj->Clone())) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
if ( IsNull( pCrvCompo) || ! pCrvCompo->IsValid())
|
||||
return false ;
|
||||
// lo porto nel riferimento globale
|
||||
pCrvCompo->ToGlob( frFrame) ;
|
||||
// converto
|
||||
ON_PolyCurve* onPolyCrv = ConvertCrvCompo( pCrvCompo) ;
|
||||
// aggiungo l'oggetto al modello
|
||||
return AddObjectToModel( iIter, onPolyCrv, nLayer, sName, cCol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ON_PolyCurve*
|
||||
Export3dm::ConvertCrvCompo( const ICurveComposite* pCrvCompo)
|
||||
{
|
||||
ON_PolyCurve* onPolyCrv = new ON_PolyCurve ;
|
||||
for ( const ICurve* pCrv = pCrvCompo->GetFirstCurve() ; pCrv != nullptr ; pCrv = pCrvCompo->GetNextCurve()) {
|
||||
GeoObjType type = pCrv->GetType() ;
|
||||
switch ( type) {
|
||||
case CRV_LINE : {
|
||||
PtrOwner<ICurveLine> pCrvL( GetCurveLine( pCrv->Clone())) ;
|
||||
if ( IsNull( pCrvL)) {
|
||||
if ( IsNull( pCrvL) || ! pCrvL->IsValid()) {
|
||||
delete onPolyCrv ;
|
||||
return false ;
|
||||
return nullptr ;
|
||||
}
|
||||
ON_LineCurve* onLine = ConvertCrvLine( pCrvL) ;
|
||||
if ( onLine == nullptr) {
|
||||
delete onPolyCrv ;
|
||||
return false ;
|
||||
return nullptr ;
|
||||
}
|
||||
onPolyCrv->Append( onLine) ;
|
||||
break ;
|
||||
}
|
||||
case CRV_ARC : {
|
||||
PtrOwner<ICurveArc> pCrvArc( GetCurveArc( pCrv->Clone())) ;
|
||||
if ( IsNull( pCrvArc)) {
|
||||
if ( IsNull( pCrvArc) || ! pCrvArc->IsValid()) {
|
||||
delete onPolyCrv ;
|
||||
return false ;
|
||||
return nullptr ;
|
||||
}
|
||||
ON_ArcCurve* onArcCrv = ConvertCrvArc( pCrvArc) ;
|
||||
if ( onArcCrv == nullptr) {
|
||||
delete onPolyCrv ;
|
||||
return false ;
|
||||
return nullptr ;
|
||||
}
|
||||
onPolyCrv->Append( onArcCrv) ;
|
||||
break ;
|
||||
}
|
||||
case CRV_BEZIER : {
|
||||
PtrOwner<ICurveBezier> pCrvBz( GetCurveBezier( pCrv->Clone())) ;
|
||||
if ( IsNull( pCrvBz)) {
|
||||
if ( IsNull( pCrvBz) || ! pCrvBz->IsValid()) {
|
||||
delete onPolyCrv ;
|
||||
return false ;
|
||||
return nullptr ;
|
||||
}
|
||||
ON_NurbsCurve* onNurbsCrv = ConvertCrvBezier( pCrvBz) ;
|
||||
if ( onNurbsCrv == nullptr) {
|
||||
delete onPolyCrv ;
|
||||
return false ;
|
||||
return nullptr ;
|
||||
}
|
||||
onPolyCrv->Append( onNurbsCrv) ;
|
||||
break ;
|
||||
@@ -682,8 +708,7 @@ Export3dm::ExportCrvCompo( const string& sName, const IGdbIterator& iIter, const
|
||||
default : break ;
|
||||
}
|
||||
}
|
||||
// aggiungo l'oggetto al modello
|
||||
return AddObjectToModel( iIter, onPolyCrv, nLayer, sName, cCol) ;
|
||||
return onPolyCrv ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -707,7 +732,7 @@ Export3dm::ExportCrvLine( const string& sName, const IGdbIterator& iIter, const
|
||||
return false ;
|
||||
// verifico oggetto
|
||||
PtrOwner<ICurveLine> pCrvL( GetCurveLine( pGeoObj->Clone())) ;
|
||||
if ( IsNull( pCrvL))
|
||||
if ( IsNull( pCrvL) || ! pCrvL->IsValid())
|
||||
return false ;
|
||||
// lo porto nel frame globale
|
||||
pCrvL->ToGlob( frFrame) ;
|
||||
@@ -716,6 +741,96 @@ Export3dm::ExportCrvLine( const string& sName, const IGdbIterator& iIter, const
|
||||
return AddObjectToModel( iIter, onCrvLine, nLayer, sName, cCol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::vector<ON_PolyCurve*>
|
||||
Export3dm::ConvertText( const IExtText* pText)
|
||||
{
|
||||
// tolleranza lineare standard
|
||||
const double LIN_TOL_STD = 0.1 ;
|
||||
// deviazione angolare standard (in gradi)
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
POLYLINELIST lPl ;
|
||||
pText->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, lPl) ;
|
||||
vector<ON_PolyCurve*> vOnPolyCrv ;
|
||||
for ( PolyLine pl : lPl) {
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
pCC->FromPolyLine( pl) ;
|
||||
ON_PolyCurve* onPolyCrv = ConvertCrvCompo( pCC) ;
|
||||
vOnPolyCrv.push_back( onPolyCrv) ;
|
||||
}
|
||||
return vOnPolyCrv ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Export3dm::ExportText( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
|
||||
{
|
||||
// recupero l'oggetto geometrico
|
||||
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
|
||||
if ( pGeoObj == nullptr)
|
||||
return false ;
|
||||
// verifico oggetto
|
||||
PtrOwner<IExtText> pText( GetExtText( pGeoObj->Clone())) ;
|
||||
if ( IsNull( pText) || ! pText->IsValid())
|
||||
return false ;
|
||||
// lo porto nel frame globale
|
||||
pText->ToGlob( frFrame) ;
|
||||
vector<ON_PolyCurve*> vOnPolyCrv = ConvertText( pText) ;
|
||||
// aggiungo l'oggetto al modello
|
||||
bool bOk = true ;
|
||||
for ( ON_PolyCurve* onPolyCrv : vOnPolyCrv) {
|
||||
bOk = bOk && AddObjectToModel( iIter, onPolyCrv, nLayer, sName, cCol) ;
|
||||
if ( ! bOk)
|
||||
break ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::vector<ON_PolyCurve*>
|
||||
Export3dm::ConvertExtDimension( const IExtDimension* pExtDim)
|
||||
{
|
||||
// tolleranza lineare standard
|
||||
const double LIN_TOL_STD = 0.1 ;
|
||||
// deviazione angolare standard (in gradi)
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
POLYLINELIST lPl ;
|
||||
pExtDim->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, lPl) ;
|
||||
vector<ON_PolyCurve*> vOnPolyCrv ;
|
||||
for ( PolyLine pl : lPl) {
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
pCC->FromPolyLine( pl) ;
|
||||
ON_PolyCurve* onPolyCrv = ConvertCrvCompo( pCC) ;
|
||||
vOnPolyCrv.push_back( onPolyCrv) ;
|
||||
}
|
||||
return vOnPolyCrv ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Export3dm::ExportDimension( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
|
||||
{
|
||||
// recupero l'oggetto geometrico
|
||||
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
|
||||
if ( pGeoObj == nullptr)
|
||||
return false ;
|
||||
// verifico oggetto
|
||||
PtrOwner<IExtDimension> pExtDim( GetExtDimension( pGeoObj->Clone())) ;
|
||||
if ( IsNull( pExtDim) || ! pExtDim->IsValid())
|
||||
return false ;
|
||||
// lo porto nel frame globale
|
||||
pExtDim->ToGlob( frFrame) ;
|
||||
vector<ON_PolyCurve*> vOnPolyCrv = ConvertExtDimension( pExtDim) ;
|
||||
// aggiungo l'oggetto al modello
|
||||
bool bOk = true ;
|
||||
for ( ON_PolyCurve* onPolyCrv : vOnPolyCrv) {
|
||||
bOk = bOk && AddObjectToModel( iIter, onPolyCrv, nLayer, sName, cCol) ;
|
||||
if ( ! bOk)
|
||||
break ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Export3dm::ScanGroup( const IGdbIterator& iIter, const int& nLayer, bool& bEmpty)
|
||||
|
||||
@@ -25,9 +25,13 @@
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkExtDimension.h"
|
||||
#include "/EgtDev/Extern/opennurbs/Include/opennurbs.h"
|
||||
#include <map>
|
||||
|
||||
typedef std::vector<ON_PolyCurve*> VONPOLYCRV ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Export3dm : public IExport3dm
|
||||
{
|
||||
@@ -53,6 +57,9 @@ class Export3dm : public IExport3dm
|
||||
ON_NurbsCurve* ConvertCrvBezier( const ICurveBezier* pCrvBz) ;
|
||||
ON_ArcCurve* ConvertCrvArc( const ICurveArc* pCrvArc) ;
|
||||
ON_LineCurve* ConvertCrvLine( const ICurveLine* pCrvL) ;
|
||||
ON_PolyCurve* ConvertCrvCompo( const ICurveComposite* pCC) ;
|
||||
VONPOLYCRV ConvertText( const IExtText* pCrvL) ;
|
||||
VONPOLYCRV ConvertExtDimension( const IExtDimension* pExtDim) ;
|
||||
bool ExportPnt( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool ExportSrfBz( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool ExportSTM( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
@@ -60,6 +67,8 @@ class Export3dm : public IExport3dm
|
||||
bool ExportCrvBezier( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool ExportCrvCompo( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool ExportCrvLine( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool ExportText( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool ExportDimension( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
|
||||
bool CalcGroupFilter( void) ;
|
||||
|
||||
private :
|
||||
|
||||
Reference in New Issue
Block a user