5 Commits

Author SHA1 Message Date
Daniele Bariletti 4b87b53d43 EgtExch3dm :
- aggiunte all'export le classi Text e ExtDim.
2024-03-22 12:32:01 +01:00
Daniele Bariletti 749b2bba41 EgtExch3dm :
- corretto controllo per le curve nurbs collassate in punti.
2024-03-11 10:32:17 +01:00
Daniele Bariletti 4df66bc741 Merge remote-tracking branch 'origin/HEAD' into develop 2024-03-08 17:09:03 +01:00
Daniele Bariletti f2d9057797 EgtExch3dm :
- aggiunto calcolo dei poli alla creazione di una superficie di Bezier, durante l'import.
2024-03-08 17:08:40 +01:00
Dario Sassi db13b068d5 EgtExch3dm 2.6b3 :
- ricompilazione con cambio versione.
2024-02-16 08:45:08 +01:00
4 changed files with 149 additions and 14 deletions
BIN
View File
Binary file not shown.
+128 -13
View File
@@ -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)
+9
View File
@@ -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 :
+12 -1
View File
@@ -432,7 +432,15 @@ Import3dm::ConvertCurve( const ON_Curve* onCurve)
}
// qui aggiungo un controllo se la curva è collassata in un punto restituisco nullptr
if ( AreSamePointApprox( nuCurve.vCP.front(), nuCurve.vCP.back()))
bool bCollapsed = true ;
Point3d ptFirst = nuCurve.vCP.front() ;
for( int i = 1 ; i < int( nuCurve.vCP.size()) ; ++i) {
if ( ! AreSamePointApprox( ptFirst, nuCurve.vCP[i])) {
bCollapsed = false ;
break ;
}
}
if ( bCollapsed)
return nullptr ;
// vettore dei nodi
@@ -856,6 +864,9 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
if ( bRev)
pSurfBezNew->Invert() ;
// calcolo i poli
pSurfBezNew->CalcPoles() ;
if ( ! bForceTriMesh)
vSurf.emplace_back( Release( pSurfBezNew)) ;
else