Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9f5421566 | |||
| d18c7e6dad | |||
| bf572634ee | |||
| daa31dee8e | |||
| c9d13c7559 | |||
| e87a9b7bcc | |||
| bcbf546662 |
+197
-84
@@ -87,6 +87,13 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
return false ;
|
||||
}
|
||||
m_pGDB = pGDB ;
|
||||
m_dTextHeight = dTextHeight ;
|
||||
m_dExtLine = dExtLine ;
|
||||
m_dArrLen = dArrLen ;
|
||||
m_dTextDist = dTextDist ;
|
||||
m_bLenIsMM = bLenIsMM ;
|
||||
m_nDecDig = nDecDig ;
|
||||
m_sFont = sFont ;
|
||||
|
||||
// verifico l'Id di gruppo
|
||||
if ( ! m_pGDB->ExistsObj( nIdGroup)) {
|
||||
@@ -95,8 +102,6 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
}
|
||||
m_nIdGroup = nIdGroup ;
|
||||
|
||||
ONX_Model model ;
|
||||
|
||||
wstring widestr( sFile.begin(), sFile.end()) ;
|
||||
|
||||
const wchar_t* sFileName = widestr.c_str() ;
|
||||
@@ -111,7 +116,7 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
|
||||
// read the contents of the file into "model"
|
||||
ON_TextLog dump ;
|
||||
bool rc = model.Read( archive, &dump) ;
|
||||
bool rc = m_model.Read( archive, &dump) ;
|
||||
|
||||
if ( ! rc)
|
||||
LOG_ERROR( GetEE3Logger(), "Import3dm : Unable to read file.") ;
|
||||
@@ -121,7 +126,7 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
|
||||
// LAYER
|
||||
// creo i layer e i conto
|
||||
ONX_ModelComponentIterator component_iterator_l( model, ON_ModelComponent::Type::Layer) ;
|
||||
ONX_ModelComponentIterator component_iterator_l( m_model, ON_ModelComponent::Type::Layer) ;
|
||||
int nFirstId = 0 ;
|
||||
|
||||
ON_UUID ON_nil_uuid = { 0,0,0,{ 0,0,0,0,0,0,0,0}} ;
|
||||
@@ -183,7 +188,7 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
}
|
||||
|
||||
// OGGETTI GEOMETRICI
|
||||
ONX_ModelComponentIterator component_iterator( model, ON_ModelComponent::Type::ModelGeometry) ;
|
||||
ONX_ModelComponentIterator component_iterator( m_model, ON_ModelComponent::Type::ModelGeometry) ;
|
||||
|
||||
// se non riesco a convertire un oggetto, lo scarto e incremento il contatore del suo tipo nel dizionario error_count
|
||||
ON_nEntity = 0 ;
|
||||
@@ -194,17 +199,24 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
ON_wString onwStrName ;
|
||||
mgc->GetName( onwStrName) ;
|
||||
string sObjName = ConvertONwStringToString( onwStrName) ;
|
||||
|
||||
//// verifico se ho un oggetto che è un instance reference
|
||||
//const ON_3dmObjectAttributes* model_geometry_attributes = mgc->Attributes( nullptr) ;
|
||||
//bool bIsInstanceDefinitionObject = model_geometry_attributes->IsInstanceDefinitionObject() ;
|
||||
//if( ! bIsInstanceDefinitionObject)
|
||||
// continue ;
|
||||
|
||||
const ON_Object* oGeometry = mgc->Geometry( nullptr) ;
|
||||
// individuo a che layer appartiene l'oggetto
|
||||
const ON_3dmObjectAttributes* attributes = mgc->Attributes( nullptr) ;
|
||||
int nLayer = attributes->m_layer_index ;
|
||||
bool bIsObjectVisibile = attributes->IsVisible() ;
|
||||
ON::object_mode onMode = attributes->Mode() ;
|
||||
if ( onMode == ON::object_mode::idef_object) {
|
||||
++ ON_nEntity ;
|
||||
continue ;
|
||||
}
|
||||
// verifico se un oggetto è una instance definition
|
||||
bool bIsInstanceDefinitionObject = attributes->IsInstanceDefinitionObject() ;
|
||||
if ( bIsInstanceDefinitionObject){
|
||||
++ ON_nEntity ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
if ( nLayer < 0)
|
||||
nLayer = m_pGDB->GetFirstInGroup( 0) ;
|
||||
else {
|
||||
@@ -236,13 +248,86 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
// per noi invece 0 = trasparente, 100 = opaco
|
||||
cCol.Set( onCol.Red(), onCol.Green(), onCol.Blue(), lround( ( 255 - onCol.Alpha()) / 2.55)) ;
|
||||
// converto l'oggetto e lo aggiungo al GeomDB
|
||||
ON::object_type type = oGeometry->ObjectType() ;
|
||||
vector<PtrOwner<IGeoObj>> vpGeoObj ;
|
||||
switch ( type) {
|
||||
ConvertGeometry( oGeometry, vpGeoObj) ;
|
||||
|
||||
int nSubLayer = -1 ;
|
||||
// se il layer in cui dovrei mettere l'oggetto è in realtà un part allora creo un layer ausiliario in cui metter gli oggetti che dovrebbero stare in questo part
|
||||
if ( get<3>(m_mLayer[nLayer]) == 1) {
|
||||
if ( get<4>(m_mLayer[nLayer]) == -1) {
|
||||
int nAuxLayer = m_pGDB->AddGroup( GDB_ID_NULL, nLayer, GLOB_FRM) ;
|
||||
get<4>(m_mLayer[nLayer]) = nAuxLayer ;
|
||||
}
|
||||
// recupero l'id del layer ausiliario
|
||||
nLayer = get<4>(m_mLayer[nLayer]) ;
|
||||
}
|
||||
|
||||
// se ho più oggetti da inserire creo un subLayer
|
||||
if ( ssize( vpGeoObj) > 1) {
|
||||
int nParent = m_pGDB->GetParentId( nLayer) ;
|
||||
nSubLayer = m_pGDB->AddGroup( GDB_ID_NULL, nParent, GLOB_FRM) ;
|
||||
string sSubName ; m_pGDB->GetName( nSubLayer, sSubName) ;
|
||||
if ( sSubName == "")
|
||||
sSubName = "Layer " + ToString(nSubLayer) ;
|
||||
string sName ; m_pGDB->GetName( nLayer, sName) ;
|
||||
if ( sName == "")
|
||||
sName = "Layer " + ToString(nLayer) ;
|
||||
sSubName = sName + "_" + sSubName ;
|
||||
m_pGDB->SetName( nSubLayer, sSubName) ;
|
||||
}
|
||||
else
|
||||
nSubLayer = nLayer ;
|
||||
|
||||
// recupero eventuali informazioni dell'oggetto
|
||||
ON_ClassArray<ON_UserString> onvUserString ;
|
||||
const ON_3dmObjectAttributes* model_geometry_attributes = mgc->Attributes( nullptr) ;
|
||||
int nInfo = model_geometry_attributes->GetUserStrings( onvUserString) ;
|
||||
|
||||
for ( int p = 0 ; p < ssize( vpGeoObj) ; ++p) {
|
||||
if ( ! IsNull( vpGeoObj[p]) && vpGeoObj[p]->IsValid()) {
|
||||
nId = m_pGDB->AddGeoObj( GDB_ID_NULL, nSubLayer, Release( vpGeoObj[p])) ;
|
||||
m_pGDB->SetMaterial( nId, cCol) ;
|
||||
for ( int i = 0 ; i < nInfo ; ++i) {
|
||||
m_pGDB->SetInfo( nId, ConvertONwStringToString( onvUserString[i].m_key), ConvertONwStringToString( onvUserString[i].m_string_value)) ;
|
||||
}
|
||||
m_pGDB->SetName( nId, sObjName) ;
|
||||
GdbStatus status = bIsObjectVisibile ? GDB_ST_ON : GDB_ST_OFF ;
|
||||
m_pGDB->SetStatus( nId, status) ;
|
||||
|
||||
////debug
|
||||
//m_pGDB->SetInfo( nId, "3dmId", ToString(ON_nEntity)) ;
|
||||
}
|
||||
}
|
||||
++ ON_nEntity ;
|
||||
}
|
||||
|
||||
// CANCELLO I LAYER RIMASTI VUOTI ??
|
||||
|
||||
// messaggio di errore da mettere nel log per dire quanti oggetti sono stati ignorati perché la conversione non è riuscita
|
||||
map<string, int>::iterator it = m_mError_count.begin() ;
|
||||
while (it != m_mError_count.end()) {
|
||||
string type = it->first ;
|
||||
int count = it->second ;
|
||||
string sOut = "Import3dm : " + to_string( count) + " " + type + " objects have been ignored, due to conversion errors" ;
|
||||
LOG_ERROR( GetEE3Logger(), sOut.c_str()) ;
|
||||
it++;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Import3dm::ConvertGeometry( const ON_Object* oGeometry, vector<PtrOwner<IGeoObj>>& vpGeoObj)
|
||||
{
|
||||
ON::object_type type = oGeometry->ObjectType() ;
|
||||
|
||||
switch ( type) {
|
||||
case ON::object_type::point_object : {
|
||||
const ON_Point* oPoint = ON_Point::Cast( oGeometry) ;
|
||||
Point3d pt( ConvertPoint( *oPoint)) ;
|
||||
// lo aggiungo al GeomDB nel layer corretto
|
||||
// lo aggiungo al GeomDB nel layer corretto
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
if ( ! IsNull( pGeoPnt) && pGeoPnt->Set( pt) && pGeoPnt->IsValid())
|
||||
vpGeoObj.emplace_back( Release( pGeoPnt)) ;
|
||||
@@ -258,7 +343,7 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
}
|
||||
for ( int i = 0 ; i < pc->PointCount() ; i++) {
|
||||
Point3d pt( ConvertPoint( pc->m_P[i])) ;
|
||||
// lo aggiungo al GeomDB nel layer corretto
|
||||
// lo aggiungo al GeomDB nel layer corretto
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
if ( ! IsNull( pGeoPnt) && pGeoPnt->Set( pt) && pGeoPnt->IsValid())
|
||||
vpGeoObj.emplace_back( Release(pGeoPnt)) ;
|
||||
@@ -319,7 +404,7 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
break ;
|
||||
}
|
||||
case ON::object_type::loop_object : {// some type of ON_BrepLoop
|
||||
// in teoria non dovrei mai trovare questo tipo di oggetti come model geometry indipendenti, ma solo come parte di una brep
|
||||
// in teoria non dovrei mai trovare questo tipo di oggetti come model geometry indipendenti, ma solo come parte di una brep
|
||||
const ON_BrepLoop* onBrepLoop = ON_BrepLoop::Cast( oGeometry) ;
|
||||
PtrOwner<ICurve> pCurve( ConvertBrepLoop( onBrepLoop)) ;
|
||||
if ( ! IsNull( pCurve) && pCurve->IsValid())
|
||||
@@ -329,7 +414,7 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
break ;
|
||||
}
|
||||
case ON::object_type::subd_object: {
|
||||
// non c'è un comando per convertire le subd in altre superfici...
|
||||
// non c'è un comando per convertire le subd in altre superfici...
|
||||
m_mError_count["subd"] += 1 ;
|
||||
break ;
|
||||
}
|
||||
@@ -338,11 +423,11 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
// recupero il DimStyle
|
||||
onAnnot->DimensionStyleId() ;
|
||||
ON_UUID onStyleId = onAnnot->DimensionStyleId() ;
|
||||
ON_ModelComponentReference mcr = model.ComponentFromId( ON_ModelComponent::Type::DimStyle, onStyleId) ;
|
||||
ON_ModelComponentReference mcr = m_model.ComponentFromId( ON_ModelComponent::Type::DimStyle, onStyleId) ;
|
||||
const ON_ModelComponent* mc = mcr.ModelComponent() ;
|
||||
const ON_DimStyle* onDimStyle = ON_DimStyle::Cast( mc) ;
|
||||
// converto l'oggetto
|
||||
vpGeoObj = ConvertAnnotation( onAnnot, onDimStyle, dTextHeight, dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont) ;
|
||||
// converto l'oggetto
|
||||
vpGeoObj = ConvertAnnotation( onAnnot, onDimStyle) ;
|
||||
break ;
|
||||
}
|
||||
// TO DO
|
||||
@@ -357,66 +442,88 @@ Import3dm::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup,
|
||||
// ON::view_type onViewType = onView.m_view_type ;
|
||||
// error_count["detail"] += 1 ;
|
||||
//}
|
||||
case ON::object_type::instance_definition: {
|
||||
string sOut = "instance_definition: object " + ToString( ON_nEntity) ;
|
||||
LOG_INFO( GetEE3Logger(), sOut.c_str()) ;
|
||||
break ;
|
||||
}
|
||||
case ON::object_type::instance_reference : {
|
||||
string sOut = "instance_reference: object " + ToString( ON_nEntity) ;
|
||||
LOG_INFO( GetEE3Logger(), sOut.c_str()) ;
|
||||
const ON_InstanceRef* onInstRef = ON_InstanceRef::Cast( oGeometry) ;
|
||||
ON_Xform xform = ON_Xform::DiagonalTransformation( 1) ; // trasformazione identità
|
||||
ConvertInstanceReference( onInstRef, xform, vpGeoObj) ;
|
||||
break ;
|
||||
}
|
||||
default: {
|
||||
m_mError_count["other"] += 1 ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
int nSubLayer = -1 ;
|
||||
// se il layer in cui dovrei mettere l'oggetto è in realtà un part allora creo un layer ausiliario in cui metter gli oggetti che dovrebbero stare in questo part
|
||||
if ( get<3>(m_mLayer[nLayer]) == 1) {
|
||||
if ( get<4>(m_mLayer[nLayer]) == -1) {
|
||||
int nAuxLayer = m_pGDB->AddGroup( GDB_ID_NULL, nLayer, GLOB_FRM) ;
|
||||
get<4>(m_mLayer[nLayer]) = nAuxLayer ;
|
||||
}
|
||||
// recupero l'id del layer ausiliario
|
||||
nLayer = get<4>(m_mLayer[nLayer]) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// se ho più oggetti da inserire creo un subLayer
|
||||
if ((int) vpGeoObj.size() > 1) {
|
||||
int nParent = m_pGDB->GetParentId( nLayer) ;
|
||||
nSubLayer = m_pGDB->AddGroup( GDB_ID_NULL, nParent, GLOB_FRM) ;
|
||||
string sSubName ; m_pGDB->GetName( nSubLayer, sSubName) ;
|
||||
if ( sSubName == "")
|
||||
sSubName = "Layer " + ToString(nSubLayer) ;
|
||||
string sName ; m_pGDB->GetName( nLayer, sName) ;
|
||||
if ( sName == "")
|
||||
sName = "Layer " + ToString(nLayer) ;
|
||||
sSubName = sName + "_" + sSubName ;
|
||||
m_pGDB->SetName( nSubLayer, sSubName) ;
|
||||
}
|
||||
else
|
||||
nSubLayer = nLayer ;
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Import3dm::ConvertInstanceReference( const ON_InstanceRef* onInstRef, const ON_Xform& onXForm, vector<PtrOwner<IGeoObj>>& vpGeoObj)
|
||||
{
|
||||
const ON_ModelComponentReference& idef_component_ref = m_model.ComponentFromId( ON_ModelComponent::Type::InstanceDefinition, onInstRef->m_instance_definition_uuid) ;
|
||||
const ON_InstanceDefinition* onInstDef = ON_InstanceDefinition::Cast( idef_component_ref.ModelComponent()) ;
|
||||
if ( onInstDef)
|
||||
{
|
||||
ON_Xform xform = onXForm * onInstRef->m_xform ;
|
||||
bool bApplyTransform = ( xform.IsValid() && ! xform.IsZero() && ! xform.IsIdentity()) ;
|
||||
|
||||
const ON_SimpleArray<ON_UUID>& geometry_id_list = onInstDef->InstanceGeometryIdList() ;
|
||||
const int geometry_id_count = geometry_id_list.Count() ;
|
||||
if ( geometry_id_count > 0) {
|
||||
for ( int i = 0; i < geometry_id_count; i++) {
|
||||
string sOut = "Importing instRef: GeoC = " + ToString( geometry_id_count) + " i = " + ToString( i) ;
|
||||
LOG_ERROR( GetEE3Logger(), sOut.c_str()) ;
|
||||
|
||||
// recupero eventuali informazioni dell'oggetto
|
||||
ON_ClassArray<ON_UserString> onvUserString ;
|
||||
const ON_3dmObjectAttributes* model_geometry_attributes = mgc->Attributes( nullptr) ;
|
||||
int nInfo = model_geometry_attributes->GetUserStrings( onvUserString) ;
|
||||
const ON_ModelComponentReference& model_component_ref = m_model.ComponentFromId(ON_ModelComponent::Type::ModelGeometry, geometry_id_list[i]) ;
|
||||
const ON_ModelGeometryComponent* model_geometry = ON_ModelGeometryComponent::Cast(model_component_ref.ModelComponent()) ;
|
||||
if ( nullptr != model_geometry) {
|
||||
const ON_Geometry* onGeometry = model_geometry->Geometry(nullptr) ;
|
||||
if ( nullptr != onGeometry) {
|
||||
const ON_InstanceRef* onInstRefNested = ON_InstanceRef::Cast( onGeometry) ;
|
||||
if ( onInstRefNested) {
|
||||
ConvertInstanceReference( onInstRefNested, xform, vpGeoObj) ;
|
||||
}
|
||||
else {
|
||||
// Copy the geometry. Note, we are responsible for the memory allocated here.
|
||||
// So make to dispose of it, otherwise you'll leak memory.
|
||||
ON_Geometry* onGeometryCopy = onGeometry->Duplicate() ;
|
||||
if ( nullptr != onGeometryCopy) {
|
||||
if ( bApplyTransform)
|
||||
onGeometryCopy->Transform( xform) ;
|
||||
if ( ! ConvertGeometry( onGeometryCopy, vpGeoObj))
|
||||
m_mError_count["instance reference"] += 1 ;
|
||||
delete onGeometryCopy ;
|
||||
}
|
||||
else
|
||||
m_mError_count["instance reference"] += 1 ;
|
||||
|
||||
for ( int p = 0 ; p < (int) vpGeoObj.size() ; ++p) {
|
||||
if ( ! IsNull( vpGeoObj[p]) && vpGeoObj[p]->IsValid()) {
|
||||
nId = m_pGDB->AddGeoObj( GDB_ID_NULL, nSubLayer, Release( vpGeoObj[p])) ;
|
||||
m_pGDB->SetMaterial( nId, cCol) ;
|
||||
for ( int i = 0 ; i < nInfo ; ++i) {
|
||||
m_pGDB->SetInfo( nId, ConvertONwStringToString( onvUserString[i].m_key), ConvertONwStringToString( onvUserString[i].m_string_value)) ;
|
||||
//if ( ! ConvertGeometry( onGeometry, vpGeoObj))
|
||||
// m_mError_count["instance reference"] += 1 ;
|
||||
//if ( bApplyTransform) {
|
||||
// ON_Xform xformInv( xform.m_xform) ;
|
||||
// xformInv.Transpose() ;
|
||||
// Frame3d frLoc ;
|
||||
// Point3d ptOrig (xformInv[0][3], xformInv[1][3], xformInv[2][3]) ;
|
||||
// Vector3d vtX( xformInv[0][0], xformInv[1][0], xformInv[2][0]) ;
|
||||
// Vector3d vtY( xformInv[0][1], xformInv[1][1], xformInv[2][1]) ;
|
||||
// Vector3d vtZ( xformInv[0][2], xformInv[1][2], xformInv[2][2]) ;
|
||||
// frLoc.Set( ptOrig, vtX, vtY, vtZ) ;
|
||||
// frLoc.Invert() ;
|
||||
// for ( IGeoObj* pGeo : vpGeoObj)
|
||||
// pGeo->ToLoc( frLoc) ;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pGDB->SetName( nId, sObjName) ;
|
||||
}
|
||||
}
|
||||
++ ON_nEntity ;
|
||||
}
|
||||
|
||||
// CANCELLO I LAYER RIMASTI VUOTI ??
|
||||
|
||||
// messaggio di errore da mettere nel log per dire quanti oggetti sono stati ignorati perché la conversione non è riuscita
|
||||
map<string, int>::iterator it = m_mError_count.begin() ;
|
||||
while (it != m_mError_count.end()) {
|
||||
string type = it->first ;
|
||||
int count = it->second ;
|
||||
string sOut = "Import3dm : " + to_string( count) + " " + type + " objects have been ignored, due to conversion errors" ;
|
||||
LOG_ERROR( GetEE3Logger(), sOut.c_str()) ;
|
||||
it++;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -794,8 +901,6 @@ Import3dm::ConvertSurface( const ON_Surface* onSurf, DBLVECTOR* vU, DBLVECTOR* v
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
int nFailedBFace = 0, nFailedTm = 0, nFailedFr = 0, nFailedBz = 0, nFailedBTrim = 0 ;
|
||||
|
||||
#if SAVETRIMLOOP
|
||||
int nLoop = 0 ;
|
||||
#endif
|
||||
@@ -808,6 +913,8 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
// se le facce sono delle NURBS restituisco un vettore di superfici Bezier
|
||||
// se ForceTriMesh è true allora le Bezier vengono trasformate in trimesh e aggiunte alla zuppa
|
||||
|
||||
int nFailedBFace = 0, nFailedTm = 0, nFailedFr = 0, nFailedBz = 0, nFailedBTrim = 0 ;
|
||||
|
||||
ISURFPOVECTOR vSurf ;
|
||||
StmFromTriangleSoup stmSoup ;
|
||||
if ( ! stmSoup.Start())
|
||||
@@ -833,12 +940,17 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
for ( int k = 0 ; k < nLoopCount ; ++k) {
|
||||
PtrOwner<ICurveComposite> pCrvCompo( GetCurveComposite(ConvertBrepLoop( onFace->Loop( k)))) ;
|
||||
PolyArc paLoopApprox ;
|
||||
pCrvCompo->ApproxWithArcs(LIN_TOL_FINE, ANG_TOL_FINE, paLoopApprox) ;
|
||||
//pCrvCompo->ApproxWithArcs(LIN_TOL_FINE, ANG_TOL_FINE, paLoopApprox) ;
|
||||
// pCrvCompo->Clear() ; // Da provare, senza questa riga non viene modificata la crvCompo
|
||||
pCrvCompo->FromPolyArc( paLoopApprox) ;
|
||||
//pCrvCompo->FromPolyArc( paLoopApprox) ;
|
||||
pCrvCompo->MergeCurves(LIN_TOL_FINE, ANG_TOL_FINE) ;
|
||||
|
||||
#if SAVETRIMLOOP
|
||||
SaveGeoObj( pCrvCompo->Clone(), "D:\\Temp\\bezier\\import3dm\\import_trim\\loop" + ToString(k) + ".nge") ;
|
||||
#endif
|
||||
|
||||
double dArea = 0 ; pCrvCompo->GetArea( plane, dArea) ;
|
||||
if ( nLoopCount == 1 && dArea <= 0)
|
||||
if ( nLoopCount == 1 && dArea <= 10 * EPS_SMALL)
|
||||
bTooSmallOnlyLoop = true ;
|
||||
if ( ! SfrCntr.AddCurve( Release( pCrvCompo)))
|
||||
++ nFailedBTrim ;
|
||||
@@ -857,8 +969,9 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
if ( IsNull( pSurf) || ! pSurf->IsValid()) {
|
||||
// se la superficie aveva un solo loop e questo era troppo piccolo allora NON lo segno come errore
|
||||
// semplicmente la superficie non verrà disegnata perché troppo piccola
|
||||
if ( ! bTooSmallOnlyLoop)
|
||||
if ( ! bTooSmallOnlyLoop) {
|
||||
++ nFailedBFace ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// se ho una trimesh o una flatregion la aggiungo alla zuppa, se è una bezier la aggiungo al vettore delle superfici
|
||||
@@ -1050,6 +1163,7 @@ Import3dm::ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh)
|
||||
pSurfBezNew->Invert() ;
|
||||
|
||||
pSurfBezNew->RemoveCollapsedSpans() ;
|
||||
pSurfBezNew->LimitSurfToTrimmedRegion() ;
|
||||
|
||||
#if SAVEREVOLVESURF
|
||||
SaveGeoObj( pSurfBezNew->Clone(), "D:\\Temp\\bezier\\import3dm\\revolve_surf\\surf_ok.nge") ;
|
||||
@@ -1382,8 +1496,7 @@ Import3dm::ConvertMesh( const ON_Mesh* onMesh)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::vector<PtrOwner<IGeoObj>>
|
||||
Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* onDimStyle, double dTextHeight, double dExtLine, double dArrLen, double dTextDist,
|
||||
bool bLenIsMM, int nDecDig, std::string sFont)
|
||||
Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* onDimStyle)
|
||||
{
|
||||
// TO DO
|
||||
// la posizione è da correggere se le annotazioni sono presenti nell'anteprima di stampa
|
||||
@@ -1400,7 +1513,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
Vector3d vtDir = ConvertVector( onText->HorizontalDirection()) ;
|
||||
PtrOwner<IExtText> tText( CreateExtText()) ;
|
||||
|
||||
tText->Set( ptOrig, vtN, vtDir, str, sFont, false, dTextHeight) ;
|
||||
tText->Set( ptOrig, vtN, vtDir, str, m_sFont, false, m_dTextHeight) ;
|
||||
if ( ! IsNull( tText) && tText->IsValid()) {
|
||||
vpObj.emplace_back( Release( tText)) ;
|
||||
return vpObj ;
|
||||
@@ -1426,7 +1539,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
frPlane.Set( ptOrig, vtX, vtY,vtN) ;
|
||||
ptTextPoint.ToGlob( frPlane) ;
|
||||
PtrOwner<IExtText> tText( CreateExtText()) ;
|
||||
tText->Set( ptTextPoint, vtN, vtDir, str, sFont, false, dTextHeight) ;
|
||||
tText->Set( ptTextPoint, vtN, vtDir, str, m_sFont, false, m_dTextHeight) ;
|
||||
//aggiungo al gruppo: testo, linea e landing
|
||||
if ( ! IsNull( tText) && tText->IsValid())
|
||||
vpObj.emplace_back( Release( tText)) ;
|
||||
@@ -1486,7 +1599,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
if ( onAnnType == ON::AnnotationType::Aligned) {
|
||||
if ( IsNull( pDim ) ||
|
||||
! pDim->SetStyle( dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont, dTextHeight) ||
|
||||
! pDim->SetStyle( m_dExtLine, m_dArrLen, m_dTextDist, m_bLenIsMM, m_nDecDig, m_sFont, m_dTextHeight) ||
|
||||
! pDim->SetLinear( ptP1, ptP2, ptPDimL, vtN, V_NULL, "<>")) {
|
||||
m_mError_count["annotation"] += 1 ;
|
||||
break ;
|
||||
@@ -1494,7 +1607,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
}
|
||||
else if ( onAnnType == ON::AnnotationType::Rotated){
|
||||
if ( IsNull( pDim ) ||
|
||||
! pDim->SetStyle( dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont, dTextHeight) ||
|
||||
! pDim->SetStyle( m_dExtLine, m_dArrLen, m_dTextDist, m_bLenIsMM, m_nDecDig, m_sFont, m_dTextHeight) ||
|
||||
! pDim->SetLinear( ptP1, ptP2, ptPDimL, vtN, vtDir, "<>")) {
|
||||
m_mError_count["annotation"] += 1 ;
|
||||
break ;
|
||||
@@ -1527,7 +1640,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
// creo la quota
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
if ( ! IsNull( pDim) &&
|
||||
pDim->SetStyle( dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont, dTextHeight) &&
|
||||
pDim->SetStyle( m_dExtLine, m_dArrLen, m_dTextDist, m_bLenIsMM, m_nDecDig, m_sFont, m_dTextHeight) &&
|
||||
pDim->SetAngular( ptCen, ptP1, ptP2, ptPDimL, vtN, "<>") &&
|
||||
pDim->IsValid()) {
|
||||
vpObj.emplace_back( Release( pDim)) ;
|
||||
@@ -1550,7 +1663,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
// creo la quota
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
if ( ! IsNull( pDim ) &&
|
||||
pDim->SetStyle( dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont, dTextHeight) &&
|
||||
pDim->SetStyle( m_dExtLine, m_dArrLen, m_dTextDist, m_bLenIsMM, m_nDecDig, m_sFont, m_dTextHeight) &&
|
||||
pDim->SetRadial( ptCen, ptDim, vtN, "<>")) {
|
||||
vpObj.emplace_back( Release( pDim)) ;
|
||||
return vpObj ;
|
||||
@@ -1571,7 +1684,7 @@ Import3dm::ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* o
|
||||
// creo la quota
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
if ( ! IsNull( pDim ) ||
|
||||
pDim->SetStyle( dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont, dTextHeight) ||
|
||||
pDim->SetStyle( m_dExtLine, m_dArrLen, m_dTextDist, m_bLenIsMM, m_nDecDig, m_sFont, m_dTextHeight) ||
|
||||
pDim->SetDiametral( ptCen, ptDim, vtN, "<>")) {
|
||||
vpObj.emplace_back( Release( pDim)) ;
|
||||
return vpObj ;
|
||||
|
||||
+11
-2
@@ -50,17 +50,26 @@ class Import3dm : public IImport3dm
|
||||
ISurf* ConvertSurface( const ON_Surface* onSurf, DBLVECTOR* vU = nullptr, DBLVECTOR* vV = nullptr) ;
|
||||
ISURFPOVECTOR ConvertExtrusion( const ON_Extrusion* onExtrusion) ;
|
||||
ISurfTriMesh* ConvertMesh( const ON_Mesh* onMesh) ;
|
||||
std::vector<PtrOwner<IGeoObj>> ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* onDimStyle, double dTextHeight, double dExtLine, double dArrLen, double dTextDist,
|
||||
bool bLenIsMM, int nDecDig, std::string sFont) ;
|
||||
std::vector<PtrOwner<IGeoObj>> ConvertAnnotation( const ON_Annotation* onAnnot, const ON_DimStyle* onDimStyle) ;
|
||||
ISURFPOVECTOR ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh) ;
|
||||
ICurve* ConvertBrepLoop( const ON_BrepLoop* onBrepLoop) ;
|
||||
ICurveComposite* ApproxTrim( ICurve* pCrv) ;
|
||||
bool ConvertCurveParam( const ON_RevSurface* onRevSurf, ICurve** pCrv) ;
|
||||
std::string ConvertONwStringToString( ON_wString ON_wString) ;
|
||||
bool ConvertGeometry( const ON_Object* oGeometry, std::vector<PtrOwner<IGeoObj>>& vpGeoObj) ;
|
||||
bool ConvertInstanceReference( const ON_InstanceRef* iref, const ON_Xform& xf, std::vector<PtrOwner<IGeoObj>>& vpGeoObj) ;
|
||||
|
||||
private :
|
||||
ONX_Model m_model ;
|
||||
IGeomDB* m_pGDB ;
|
||||
int m_nIdGroup ;
|
||||
std::map< int, std::tuple<const ON_Layer*, ON_UUID, int, int, int>> m_mLayer ; // mappa dei layer con id nel GDB e l'uuid nel modello 3dm, un int per l'indice del layer nel model, un int che indica la profondità del layer ( Root = 0, Part = 1, layer = 2), un int che è l'indice del layer ausiliario se avevo un Part senza layer ( lo aggiungo io e finché non l'ho aggiunto questo int è settato a -1)
|
||||
std::map< std::string, int> m_mError_count ;
|
||||
double m_dTextHeight ;
|
||||
double m_dExtLine ;
|
||||
double m_dArrLen ;
|
||||
double m_dTextDist ;
|
||||
bool m_bLenIsMM ;
|
||||
int m_nDecDig ;
|
||||
std::string m_sFont ;
|
||||
} ;
|
||||
Reference in New Issue
Block a user