Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b87b53d43 | |||
| 749b2bba41 | |||
| 4df66bc741 | |||
| f2d9057797 | |||
| db13b068d5 | |||
| 0dc23a643c | |||
| d8b035b120 | |||
| f03984a6e8 | |||
| 4d5dbd78c4 | |||
| d24c798bae | |||
| 6f875efc07 | |||
| 9a91df3cad |
Binary file not shown.
+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 :
|
||||
|
||||
+114
-20
@@ -41,6 +41,11 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
// deviazione angolare standard (in gradi)
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
// tolleranza lineare affinata
|
||||
const double LIN_TOL_FINE = 0.01 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IImport3dm*
|
||||
CreateImport3dm( void)
|
||||
@@ -426,6 +431,18 @@ Import3dm::ConvertCurve( const ON_Curve* onCurve)
|
||||
nuCurve.vCP = vPtCtrl ;
|
||||
}
|
||||
|
||||
// qui aggiungo un controllo se la curva è collassata in un punto restituisco nullptr
|
||||
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
|
||||
DBLVECTOR vU ;
|
||||
int nKnot = onNurbsCurve->KnotCount() ;
|
||||
@@ -507,8 +524,8 @@ Import3dm::ConvertSurface( const ON_Surface* onSurf)
|
||||
sNurbsSurf.bClosedV = onNurbsSurface.IsClosed( 1) ;
|
||||
sNurbsSurf.bPeriodicU = onNurbsSurface.IsPeriodic( 0) ;
|
||||
sNurbsSurf.bPeriodicV = onNurbsSurface.IsPeriodic( 1) ;
|
||||
sNurbsSurf.bClampedU = onNurbsSurface.IsClamped( 0, 2) ;
|
||||
sNurbsSurf.bClampedV = onNurbsSurface.IsClamped( 1, 2) ;
|
||||
sNurbsSurf.bClampedU = onNurbsSurface.IsClamped( 0, 2) ; // qui do per scontato che se la curva è clamped alla fine allora lo è anche all'inizio e viceversa
|
||||
sNurbsSurf.bClampedV = onNurbsSurface.IsClamped( 1, 2) ; // qui do per scontato che se la curva è clamped alla fine allora lo è anche all'inizio e viceversa
|
||||
sNurbsSurf.bRat = onNurbsSurface.IsRational() ;
|
||||
sNurbsSurf.nDegU = onNurbsSurface.Degree( 0) ;
|
||||
sNurbsSurf.nDegV = onNurbsSurface.Degree( 1) ;
|
||||
@@ -624,7 +641,7 @@ Import3dm::ConvertSurface( const ON_Surface* onSurf)
|
||||
PtrOwner<ON_Curve> onpCrvEast( onSumSurface->IsoCurve(1, onIntDomain0[1])) ;
|
||||
PtrOwner<ON_Curve> onpCrvNorth( onSumSurface->IsoCurve(0, onIntDomain1[1])) ;
|
||||
// da implementare ////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
else if ( const ON_SurfaceProxy* onSurfaceProxy = ON_SurfaceProxy::Cast( onSurf)) {
|
||||
PtrOwner<ISurf> pSurf ;
|
||||
@@ -679,6 +696,7 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
int nFailedBFace = 0, nFailedTm = 0, nFailedFr = 0, nFailedBz = 0, nFailedBTrim = 0 ;
|
||||
|
||||
for ( int i = 0 ; i < onBrep->m_F.Count() ; ++i) {
|
||||
bool bOk = true ;
|
||||
ON_BrepFace* onFace = onBrep->Face( i) ;
|
||||
bool bRev = onFace->m_bRev ;
|
||||
const ON_Surface* onSurface = onFace->SurfaceOf() ;
|
||||
@@ -686,8 +704,12 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
if ( const ON_PlaneSurface* onPlaneSurface = ON_PlaneSurface::Cast( onSurface)) {
|
||||
SurfFlatRegionByContours SfrCntr ;
|
||||
for ( int k = 0 ; k < onFace->LoopCount() ; ++k) {
|
||||
PtrOwner<ICurve> pCurve( ConvertBrepLoop( onFace->Loop( k))) ;
|
||||
SfrCntr.AddCurve( Release( pCurve)) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo( GetCurveComposite(ConvertBrepLoop( onFace->Loop( k)))) ;
|
||||
PolyArc paLoopApprox ;
|
||||
pCrvCompo->ApproxWithArcs(LIN_TOL_FINE, ANG_TOL_STD_DEG, paLoopApprox) ;
|
||||
pCrvCompo->FromPolyArc( paLoopApprox) ;
|
||||
pCrvCompo->MergeCurves(LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
|
||||
SfrCntr.AddCurve( Release( pCrvCompo)) ;
|
||||
}
|
||||
pSurf.Set( SfrCntr.GetSurf()) ;
|
||||
if ( ! IsNull( pSurf) && pSurf->IsValid()) {
|
||||
@@ -699,7 +721,7 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
Frame3d frPlane ;
|
||||
frPlane.Set( ptOrig, vtX, vtY, vtZ) ;
|
||||
pSurf->ToGlob( frPlane) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
pSurf.Set( ConvertSurface( onFace)) ;
|
||||
@@ -742,20 +764,48 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
// e non riferita allo spazio parametrico della nurbs corrispondente ( che sarebbe una nurbs razionale, dovendo approssimare un arco di circonferenza)
|
||||
// devo quindi prelevare le curve di trim e cambiarne le coordinate per matcharle allo spazio parametrico della nurbs
|
||||
if ( const ON_RevSurface* onRevSurf = ON_RevSurface::Cast( onSurface) ) {
|
||||
for ( int k = 0 ; k < onFace->LoopCount() ; ++k ) {
|
||||
for ( int k = 0 ; k < onFace->LoopCount(); ++k ) {
|
||||
ICurve* pCrv( ConvertBrepLoop( onFace->Loop( k))) ;
|
||||
if ( pCrv == nullptr || ! pCrv->IsValid()) {
|
||||
++ nFailedBTrim ;
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
// qui devo spostare ogni punto della curva dallo spazio parametrico della superificie rev allo spazio della superficie nurbs
|
||||
ConvertCurveParam( onRevSurf, &pCrv) ;
|
||||
pCrv->Scale( GLOB_FRM, SBZ_TREG_COEFF, SBZ_TREG_COEFF, 1) ;
|
||||
SfrCntr.AddCurve( pCrv) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo( ApproxTrim( pCrv)) ;
|
||||
double dArea = 0 ;
|
||||
pCrvCompo->GetAreaXY(dArea) ;
|
||||
if (abs(dArea) > EPS_SMALL) {
|
||||
pCrvCompo->Scale( GLOB_FRM, SBZ_TREG_COEFF, SBZ_TREG_COEFF, 1) ;
|
||||
SfrCntr.AddCurve( Release(pCrvCompo)) ;
|
||||
}
|
||||
else
|
||||
continue ;
|
||||
}
|
||||
if ( ! bOk)
|
||||
continue ;
|
||||
}
|
||||
else {
|
||||
for ( int k = 0 ; k < onFace->LoopCount() ; ++k ) {
|
||||
PtrOwner<ICurve> pCrv( ConvertBrepLoop( onFace->Loop( k))) ;
|
||||
pCrv->Scale( GLOB_FRM, SBZ_TREG_COEFF, SBZ_TREG_COEFF, 1) ;
|
||||
SfrCntr.AddCurve( Release( pCrv)) ;
|
||||
for ( int k = 0 ; k < onFace->LoopCount() && bOk ; ++k ) {
|
||||
PtrOwner<ICurve> pCrv( ConvertBrepLoop( onFace->Loop( k))) ;
|
||||
if ( IsNull(pCrv) || ! pCrv->IsValid()) {
|
||||
++ nFailedBTrim ;
|
||||
bOk = false ;
|
||||
break ;
|
||||
}
|
||||
PtrOwner<ICurveComposite> pCrvCompo( ApproxTrim( Release(pCrv))) ;
|
||||
double dArea = 0 ;
|
||||
pCrvCompo->GetAreaXY(dArea) ;
|
||||
if (abs(dArea) > EPS_SMALL) {
|
||||
pCrvCompo->Scale( GLOB_FRM, SBZ_TREG_COEFF, SBZ_TREG_COEFF, 1) ;
|
||||
SfrCntr.AddCurve( Release( pCrvCompo)) ;
|
||||
}
|
||||
else
|
||||
continue ;
|
||||
}
|
||||
if ( ! bOk)
|
||||
continue ;
|
||||
}
|
||||
ISurfFlatRegion* sfrTrim = SfrCntr.GetSurf() ;
|
||||
|
||||
@@ -773,7 +823,7 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
sfrTrim->Translate( vToOrig) ;
|
||||
else {
|
||||
++ nFailedBTrim ;
|
||||
return vSurf ;
|
||||
continue ;
|
||||
}
|
||||
// se la superficie di partenza aveva vettori dei nodi non uniformi devo riscalare lo spazio parametrico in modo da renderli uniformi
|
||||
// applicando così la trasformazione anche alle curve di trim.
|
||||
@@ -785,10 +835,24 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
pSurfBezNew->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bRat, bTrim) ;
|
||||
// devo rendere lo spazio parametrico uniforme solo se la superficie è trimmata, sennò non serve
|
||||
// per capire se la superficie sia trimmata controllo che lo spazio parametrico trimmato non coincida con tutto lo spazio parametrico
|
||||
PtrOwner<ISurfFlatRegion> pSurfParam(GetSurfFlatRegionRectangle(( dScaleU - EPS_SMALL ) * SBZ_TREG_COEFF, ( dScaleV - EPS_SMALL) * SBZ_TREG_COEFF)) ;
|
||||
double dParamX = dScaleU * SBZ_TREG_COEFF - EPS_SMALL ;
|
||||
double dParamY = dScaleV * SBZ_TREG_COEFF - EPS_SMALL ;
|
||||
PtrOwner<ISurfFlatRegion> pSurfParam(GetSurfFlatRegionRectangle( dParamX > 0 ? dParamX : 2 * EPS_SMALL, dParamY > 0 ? dParamY : 2 * EPS_SMALL)) ;
|
||||
// se la sottrazione tra spazio parametrico e superficie di trim è diversa da zero, allora la superficie era trimmata
|
||||
if ( sfrTrim != nullptr && pSurfParam->Subtract( *sfrTrim) && pSurfParam->IsValid()) {
|
||||
MakeUniform( &sfrTrim, onNurbsSurface, dScaleU, dScaleV) ;
|
||||
bool bRescaled = false ;
|
||||
if ( ! MakeUniform( &sfrTrim, onNurbsSurface, dScaleU, dScaleV, bRescaled, false)) {
|
||||
// se make uniform fallisce potrei provare a farlo rigirare con gli offset ad ogni passaggio, per non avere errori nelle operazioni tra flat region/////////
|
||||
if ( MakeUniform( &sfrTrim, onNurbsSurface, dScaleU, dScaleV, bRescaled, true)) {
|
||||
++ nFailedBTrim ;
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
if ( bRescaled) {
|
||||
// per correggere eventuali crack create dal lavoro di collage sullo spazio parametrico faccio un OFFSET e controOFFSET
|
||||
sfrTrim->Offset( 100*EPS_SMALL, ICurve::OFF_FILLET) ;
|
||||
sfrTrim->Offset( -100*EPS_SMALL, ICurve::OFF_FILLET) ;
|
||||
}
|
||||
pSurfBezNew->SetTrimRegion( *sfrTrim) ;
|
||||
}
|
||||
else
|
||||
@@ -800,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
|
||||
@@ -808,7 +875,7 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
else {
|
||||
++nFailedBz ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,9 +908,24 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
return vSurf ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveComposite*
|
||||
Import3dm::ApproxTrim( ICurve* pCrv)
|
||||
{
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
//PolyArc paLoopApprox ;
|
||||
PolyLine plApprox ;
|
||||
// pCrv->ApproxWithArcs(10*EPS_SMALL, ANG_TOL_STD_DEG, paLoopApprox) ;
|
||||
pCrv->ApproxWithLines(10*EPS_SMALL, ANG_TOL_STD_DEG, 0, plApprox) ;
|
||||
//pCrvCompo->FromPolyArc(paLoopApprox) ;
|
||||
pCC->FromPolyLine(plApprox) ;
|
||||
pCC->MergeCurves(10*EPS_SMALL, ANG_TOL_STD_DEG) ;
|
||||
return Release( pCC) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Import3dm::MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, double dScaleU, double dScaleV)
|
||||
Import3dm::MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, double dScaleU, double dScaleV, bool& bRescaled, bool bRetry)
|
||||
{
|
||||
// riscalo le superfici prima di effettuare una serie di operazioni di collage
|
||||
//(*sfr)->Scale( GLOB_FRM, SBZ_TREG_COEFF, SBZ_TREG_COEFF, 1) ;
|
||||
@@ -929,6 +1011,9 @@ Import3dm::MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, d
|
||||
else
|
||||
vtJoin.Set( 0, p * SBZ_TREG_COEFF - pt.y, 0) ;
|
||||
pSfr_copy->Translate( vtJoin) ;
|
||||
// se sto ritentando MakeUniform, allora faccio anche OFFSET e controOFFSET
|
||||
if ( bRetry)
|
||||
pSfr_copy->Offset( 10*EPS_SMALL,ICurve::OFF_FILLET) ; // OFFSET
|
||||
if ( sfr_rescaled->IsValid()) {
|
||||
if ( ! sfr_rescaled->Add( *pSfr_copy))
|
||||
return false ;
|
||||
@@ -939,16 +1024,22 @@ Import3dm::MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, d
|
||||
}
|
||||
if ( nDir == 0) {
|
||||
dScaleU = (int)vU.size() - 1 ;
|
||||
if ( sfr_rescaled->IsValid())
|
||||
if ( sfr_rescaled->IsValid()) {
|
||||
if ( bRetry)
|
||||
sfr_rescaled->Offset( -10*EPS_SMALL,ICurve::OFF_FILLET) ; //contro OFFSET
|
||||
*sfr = Release( sfr_rescaled) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
dScaleV = (int)vU.size() - 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! IsNull( sfr_rescaled) && sfr_rescaled->IsValid())
|
||||
if ( ! IsNull( sfr_rescaled) && sfr_rescaled->IsValid()) {
|
||||
if ( bRetry)
|
||||
sfr_rescaled->Offset( -10*EPS_SMALL,ICurve::OFF_FILLET) ; // contro OFFSET
|
||||
*sfr = Release( sfr_rescaled) ;
|
||||
}
|
||||
|
||||
if ( ! bRescaledU && ! bRescaledV)
|
||||
( *sfr)->Scale( GLOB_FRM, nSpanU / dScaleU, nSpanV / dScaleV, 1) ;
|
||||
@@ -957,6 +1048,7 @@ Import3dm::MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, d
|
||||
else if ( ! bRescaledU && bRescaledV)
|
||||
( *sfr)->Scale( GLOB_FRM, nSpanU / dScaleU, 1, 1) ;
|
||||
|
||||
bRescaled = bRescaledU || bRescaledV ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -973,6 +1065,8 @@ Import3dm::ConvertBrepLoop( const ON_BrepLoop* onBrepLoop)
|
||||
ON_BrepTrim* onBrepTrim = onBrepLoop->Trim( i) ;
|
||||
ON_CurveProxy* onCurveProxy = ON_CurveProxy::Cast( onBrepTrim);
|
||||
PtrOwner<ICurve> pCrv( ConvertCurve( onCurveProxy)) ;
|
||||
if ( IsNull(pCrv) || ! pCrv->IsValid())
|
||||
continue ;
|
||||
if ( ! pCrvCompo->AddCurve( pCrv->Clone())) {
|
||||
Point3d ptEnd ; pCrvCompo->GetEndPoint( ptEnd) ;
|
||||
pCrv->ModifyStart( ptEnd) ;
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ class Import3dm : public IImport3dm
|
||||
bool bLenIsMM, int nDecDig, std::string sFont) ;
|
||||
ISURFPOVECTOR ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh) ;
|
||||
ICurve* ConvertBrepLoop( const ON_BrepLoop* onBrepLoop) ;
|
||||
bool MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, double dScaleU, double dScaleV) ;
|
||||
ICurveComposite* ApproxTrim( ICurve* pCrv) ;
|
||||
bool MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, double dScaleU, double dScaleV, bool& bRescaled, bool bRetry = false) ;
|
||||
bool ConvertCurveParam( const ON_RevSurface* onRevSurf, ICurve** pCrv) ;
|
||||
|
||||
private :
|
||||
|
||||
Reference in New Issue
Block a user