Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d019e4efd | |||
| b6d788ea4f | |||
| f94cc0d1db | |||
| f4471e8c30 | |||
| 8f961fcd74 | |||
| 956c7578d1 | |||
| b7daadfe1b | |||
| dcd399c379 | |||
| 47856162bf | |||
| 74aced79bf | |||
| 5c3c9863ae | |||
| 43c98f3387 | |||
| f655b96ad5 | |||
| fcc1b48196 | |||
| ad52d30e5d | |||
| 27ca1129a7 | |||
| 8dc3b53334 | |||
| baccbad41b | |||
| e1dce523da | |||
| fdc007b0e6 | |||
| 386c2e5b46 | |||
| a167995f4a | |||
| 5b7ed17241 | |||
| 206c24c6a4 | |||
| c2728c7cd3 | |||
| dd77203dab | |||
| 38d15bf412 | |||
| 1396b22802 | |||
| d26abd8452 | |||
| becf06ffed | |||
| 81ea592001 | |||
| 8be2ffeb7b | |||
| abfec33be1 | |||
| 34841e4c16 | |||
| 0cd32caf47 | |||
| 348b01b81b | |||
| 21ec3f0790 | |||
| a7b13f78f7 | |||
| 72351793d5 | |||
| 40b343207e | |||
| 3dad5fde1e | |||
| 595dd560e4 | |||
| 9c1fff1d52 | |||
| a523d9ea2b | |||
| 691c3def9e | |||
| ecdae1b3c3 | |||
| 74e3e2e4df | |||
| 2f04868dd5 | |||
| 8d3cf60fec | |||
| 601c61f930 | |||
| 5074b7f119 | |||
| ec085470f8 | |||
| f7a03f6cb4 | |||
| 024caa43d5 | |||
| 109474cb18 | |||
| c5df52a3ca | |||
| df8cd714b5 | |||
| 917832a54a | |||
| 87c082ceab | |||
| df3024f666 | |||
| d0f8e3bfc0 | |||
| 872906778c | |||
| 34dae2d429 | |||
| 361fe95890 | |||
| f22186f0a2 | |||
| 1272a55294 | |||
| b741391ffc | |||
| 0ad38f9e45 |
Binary file not shown.
+7
-7
@@ -23,19 +23,19 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{d1a76918-1e81-4851-9b6f-2b1db0efb2a4}</ProjectGuid>
|
||||
<RootNamespace>EgtExch3dm</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -104,7 +104,7 @@
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -133,7 +133,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
@@ -165,7 +165,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -192,7 +192,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
+214
-35
@@ -15,28 +15,20 @@
|
||||
#include "stdafx.h"
|
||||
#include "Export3dm.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EE3DllMain.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkGeoObjType.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkExtDimension.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/SELkKeyProc.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtKeyCodes.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Extern/opennurbs/Include/opennurbs.h"
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
|
||||
using namespace std ;
|
||||
//N.B.:
|
||||
@@ -210,6 +202,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,14 +282,21 @@ 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 ;
|
||||
pOnAttr->m_name = ConvertString( sName).c_str() ;
|
||||
int nType = iIter.GetGeoType() ;
|
||||
string sCompleteName = sName ;
|
||||
if ( nType == EXT_DIMENSION) {
|
||||
sCompleteName = "dim_" + sCompleteName ;
|
||||
}
|
||||
pOnAttr->m_name = ConvertString( sCompleteName).c_str() ;
|
||||
pOnAttr->SetColorSource( ON::color_from_object) ;
|
||||
//N.B. RHINO ha i valori di Alpha invertiti rispetto ai nostri, oltre che su una scala diversa! per loro 0 = opaco e 255 = trasparente
|
||||
// per noi invece 0 = trasparente, 100 = opaco
|
||||
ON_Color onCol( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), abs( int( cCol.GetIntAlpha() * 2.55) - 255)) ;
|
||||
ON_Color onCol( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), Clamp( 255 - lround( cCol.GetIntAlpha() * 2.55), 0, 255)) ;
|
||||
pOnAttr->m_color = onCol ;
|
||||
// se è una mesh aggiungo il materiale
|
||||
if ( const ON_Mesh* onMesh = ON_Mesh::Cast( onObject)) {
|
||||
@@ -299,6 +310,7 @@ Export3dm::AddObjectToModel( const IGdbIterator& iIter, ON_Object* onObject, con
|
||||
onMat->SetDiffuse( onCol) ;
|
||||
onMat->SetAmbient( onCAmb) ;
|
||||
onMat->SetReflectivity( 0) ;
|
||||
onMat->SetTransparency( Clamp( 255 - lround( cCol.GetIntAlpha() * 2.55), 0, 255)) ;
|
||||
ON_ModelComponentReference mcr = m_model.AddManagedModelComponent( onMat) ;
|
||||
int nIndex = mcr.ModelComponentIndex() ;
|
||||
m_mMaterial.insert( pair< std::string, int>( sCol, nIndex)) ;
|
||||
@@ -495,16 +507,29 @@ Export3dm::ExportSTM( const string& sName, const IGdbIterator& iIter, const Fram
|
||||
// lo porto nel frame globale
|
||||
pSrfTm->ToGlob( frFrame) ;
|
||||
|
||||
int nVertices = pSrfTm->GetVertexCount() ;
|
||||
int nTriangles = pSrfTm->GetTriangleCount() ;
|
||||
int nVertices = pSrfTm->GetVertexSize() ;
|
||||
int nTriangles = pSrfTm->GetTriangleSize() ;
|
||||
ON_Mesh* onMesh = new ON_Mesh ;
|
||||
|
||||
bool bOk = true ;
|
||||
for ( int v = 0 ; v < nVertices ; ++v) {
|
||||
Point3d pt ; pSrfTm->GetVertex( v, pt) ;
|
||||
onMesh->SetVertex( v, ConvertPoint( pt)) ;
|
||||
bOk = onMesh->SetVertex( v, ConvertPoint( pt)) ;
|
||||
if ( ! bOk) {
|
||||
LOG_ERROR( GetEE3Logger(), "Export3dm SurfTm: Error adding vertex")
|
||||
bOk = true ;
|
||||
}
|
||||
}
|
||||
bOk = true ;
|
||||
for ( int t = 0 ; t < nTriangles ; ++t) {
|
||||
int nIdVert[3] ; pSrfTm->GetTriangle( t, nIdVert) ;
|
||||
onMesh->SetTriangle( t, nIdVert[0], nIdVert[1], nIdVert[2]) ;
|
||||
int nIdVert[3] ;
|
||||
if ( ! pSrfTm->GetTriangle( t, nIdVert))
|
||||
continue ;
|
||||
bOk = onMesh->SetTriangle( t, nIdVert[0], nIdVert[1], nIdVert[2]) ;
|
||||
if ( ! bOk) {
|
||||
LOG_ERROR( GetEE3Logger(), "Export3dm SurfTm: Error adding triangle")
|
||||
bOk = true ;
|
||||
}
|
||||
}
|
||||
ON_MeshVertexFaceMap onMeshVertMap ;
|
||||
onMeshVertMap.SetFromMesh( onMesh, false) ;
|
||||
@@ -629,52 +654,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 +717,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 +741,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 +750,151 @@ Export3dm::ExportCrvLine( const string& sName, const IGdbIterator& iIter, const
|
||||
return AddObjectToModel( iIter, onCrvLine, nLayer, sName, cCol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ON_Text*
|
||||
Export3dm::ConvertText( const IExtText* pText, const Frame3d& frDim)
|
||||
{
|
||||
string sText = pText->GetText() ;
|
||||
wstring wText = wstring(sText.begin(), sText.end());
|
||||
const wchar_t* wcText = wText.c_str();
|
||||
ON_Text* ontText = new ON_Text() ;
|
||||
double dHeight = pText->GetHeight() ;
|
||||
// controllo se esiste già un dim style con quell'altezza sennò lo creo
|
||||
ON_DimStyle onDimStyle = ON_DimStyle::SystemDimstyleFromIndex( -1) ; // default
|
||||
const ON_DimStyle* onDimStyleNew = nullptr ;
|
||||
ONX_ModelComponentIterator component_iterator_ds( m_model, ON_ModelComponent::Type::DimStyle) ;
|
||||
bool bFound = false ;
|
||||
for ( const ON_ModelComponent* mc = component_iterator_ds.FirstComponent() ; mc != nullptr ; mc = component_iterator_ds.NextComponent()) {
|
||||
const ON_DimStyle* onDim = ON_DimStyle::Cast( mc) ;
|
||||
double dTextHeight = onDim->TextHeight() ;
|
||||
if ( abs( dHeight - dTextHeight) < 0.1 ) {
|
||||
onDimStyle = *onDim ;
|
||||
bFound = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( ! bFound) {
|
||||
ON_DimStyle onDimStyleOver = onDimStyle.CreateOverrideCandidate() ;
|
||||
onDimStyleOver.SetFieldOverride( ON_DimStyle::field::TextHeight, true) ;
|
||||
onDimStyleOver.SetTextHeight( dHeight) ;
|
||||
ON_ModelComponentReference mcr = m_model.AddModelComponent( onDimStyleOver, true) ;
|
||||
onDimStyleNew = ON_DimStyle::FromModelComponentRef( mcr, nullptr) ;
|
||||
}
|
||||
// il punto di riferimento di rhino è in alto a sinistra, mentre il nostro è in basso a sinistra
|
||||
Point3d pt ; pText->GetOverStartPoint( pt) ;
|
||||
ON_Plane onPlane( ConvertPoint( pt), ConvertVector(frDim.VersX()), ConvertVector(frDim.VersY())) ;
|
||||
BBox3d bbox3d ; pText->GetBBox( GLOB_FRM, bbox3d, 0) ;
|
||||
if ( onDimStyleNew != nullptr)
|
||||
ontText->Create( wcText, onDimStyleNew, onPlane, true, bbox3d.GetDimX() * 10, 0.) ;
|
||||
else
|
||||
ontText->Create( wcText, &onDimStyle, onPlane, true, bbox3d.GetDimX() * 10, 0.) ;
|
||||
return ontText ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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) ;
|
||||
|
||||
ON_Text* onText = ConvertText( pText, frFrame) ;
|
||||
|
||||
return AddObjectToModel( iIter, onText, nLayer, sName, cCol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ON_Dimension*
|
||||
Export3dm::ConvertExtDimension( const IExtDimension* pExtDim, const Frame3d& frDim)
|
||||
{
|
||||
const ON_DimStyle onDimStyle = ON_DimStyle::DimStyleOrDefault( nullptr) ;
|
||||
ON_UUID onIdDim = onDimStyle.Id() ;
|
||||
// versione con le classi di Rhino
|
||||
string sSubType = pExtDim->GetSubType() ;
|
||||
if ( sSubType == "Linear") {
|
||||
ON_Plane onPlane(ConvertPoint( frDim.Orig()), ConvertVector( frDim.VersX()), ConvertVector( frDim.VersY())) ;
|
||||
ON_DimLinear* onDimLinear( new ON_DimLinear()) ;
|
||||
ON_3dPoint onPt1 = ConvertPoint( pExtDim->GetStart()) ;
|
||||
ON_3dPoint onPt2 = ConvertPoint( pExtDim->GetEnd()) ;
|
||||
ON_3dPoint onPtDim = ConvertPoint( pExtDim->GetPosition()) ;
|
||||
Vector3d vtDir = pExtDim->GetDirVersor() ;
|
||||
|
||||
// aligned
|
||||
if ( ! AreSameVectorApprox( vtDir, X_AX) && ! AreSameVectorApprox( vtDir, Y_AX))
|
||||
ON_DimLinear::CreateAligned( onPt1, onPt2, onPtDim, ConvertVector( frDim.VersZ()), onIdDim, onDimLinear) ;
|
||||
//horizontal o vertical
|
||||
else {
|
||||
ON_3dPoint onPtDim2 = onPtDim + ConvertVector( vtDir) ;
|
||||
ON_DimLinear::CreateRotated( onPt1, onPt2, ON_Line( onPtDim, onPtDim2), ConvertVector( frDim.VersZ()), onIdDim, onDimLinear) ;
|
||||
}
|
||||
|
||||
return onDimLinear ;
|
||||
}
|
||||
else if ( sSubType == "Radial" || sSubType == "Diametral") {
|
||||
ON_Plane onPlane(ConvertPoint( frDim.Orig()), ConvertVector( frDim.VersX()), ConvertVector( frDim.VersY())) ;
|
||||
ON_DimRadial* onDimRadial( new ON_DimRadial()) ;
|
||||
ON_3dPoint onPtV = ConvertPoint( pExtDim->GetStart()) ;
|
||||
ON_3dPoint onPtPos = ConvertPoint( pExtDim->GetEnd()) ;
|
||||
//ON_3dPoint onPtDim = ConvertPoint( pExtDim->GetPosition()) ;
|
||||
Vector3d vtDir = pExtDim->GetDirVersor() ;
|
||||
ON_3dPoint onPtDim = onPtPos + ConvertVector( vtDir) * ( onPtPos - onPtV).Length() / 10. ; // allontano la misura dall'arco di un decimo del raggio
|
||||
double dRot = 0 ;
|
||||
if ( ! AreSameVectorApprox( vtDir, X_AX))
|
||||
X_AX.GetAngleXY(vtDir, dRot) ;
|
||||
if ( sSubType == "Radial")
|
||||
onDimRadial->Create( ON::AnnotationType::Radius, onIdDim, onPlane, onPtV, onPtPos, onPtDim) ;
|
||||
else if ( sSubType == "Diametral")
|
||||
onDimRadial->Create( ON::AnnotationType::Diameter, onIdDim, onPlane, onPtV, onPtPos, onPtDim) ;
|
||||
return onDimRadial ;
|
||||
}
|
||||
else if ( sSubType == "Angular") {
|
||||
ON_Plane onPlane(ConvertPoint( frDim.Orig()), ConvertVector( frDim.VersX()), ConvertVector( frDim.VersY())) ;
|
||||
ON_DimAngular* onDimAngular( new ON_DimAngular()) ;
|
||||
ON_3dPoint onPtV = ConvertPoint( pExtDim->GetStart()) ;
|
||||
ON_3dPoint onPt1 = ConvertPoint( pExtDim->GetOverStart()) ;
|
||||
ON_3dPoint onPt2 = ConvertPoint( pExtDim->GetOverEnd()) ;
|
||||
ON_3dPoint onPtDim = ConvertPoint( pExtDim->GetPosition()) ;
|
||||
Vector3d vtDir = pExtDim->GetDirVersor() ;
|
||||
double dRot = 0 ;
|
||||
if ( ! AreSameVectorApprox( vtDir, X_AX))
|
||||
X_AX.GetAngleXY(vtDir, dRot) ;
|
||||
// per arco
|
||||
//onDimAngular->Create( onIdDim, onPlane, ConvertVector( frDim.VersX()), onPtV, onPt1, onPt2, onPtDim) ;
|
||||
|
||||
// con linee prolungate fino al vertice
|
||||
onDimAngular->Create( onIdDim, onPlane, ConvertVector( frDim.VersX()), onPtV, onPtV, onPt1, onPt2, onPtDim) ;
|
||||
return onDimAngular ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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) ;
|
||||
|
||||
return AddObjectToModel( iIter, ConvertExtDimension( pExtDim, frFrame), nLayer, sName, cCol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Export3dm::ScanGroup( const IGdbIterator& iIter, const int& nLayer, bool& bEmpty)
|
||||
|
||||
+9
-2
@@ -16,7 +16,6 @@
|
||||
#define NOMINMAX
|
||||
|
||||
#include "/EgtDev/Include/EE3Export3dm.h"
|
||||
#include "/EgtDev/Include/EGnWriter.h"
|
||||
#include "/EgtDev/Include/EGkGeoObj.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
@@ -25,9 +24,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 +56,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) ;
|
||||
ON_Text* ConvertText( const IExtText* pText, const Frame3d& frDim) ;
|
||||
ON_Dimension* ConvertExtDimension( const IExtDimension* pExtDim, const Frame3d& frDim) ;
|
||||
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,12 +66,13 @@ 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 :
|
||||
int m_nFilter ; // filtro su livello, modo e stato, se l'oggeto da valutare è un oggetto geometrico
|
||||
int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un gruppo
|
||||
Writer m_Writer ; // scrittore di file di testo
|
||||
ONX_Model m_model ; // modello opennurbs
|
||||
std::map<int,int> m_mLayer ; // mappa dei layer <indice layer nge, indice del componente layer nel modello 3dm>
|
||||
std::map<std::string,int> m_mMaterial ; // mappa dei materiali <stringa del colore ( R,G,B), indice del componente material nel modello 3dm>
|
||||
|
||||
+494
-366
File diff suppressed because it is too large
Load Diff
+6
-4
@@ -13,6 +13,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define NOMINMAX
|
||||
|
||||
#include "/EgtDev/Include/EE3Import3dm.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
@@ -45,20 +47,20 @@ class Import3dm : public IImport3dm
|
||||
Vector3d ConvertVector( const ON_2dVector& onVector)
|
||||
{ return Vector3d( onVector.x, onVector.y, 0) ; } ;
|
||||
ICurve* ConvertCurve( const ON_Curve* onCurve) ;
|
||||
ISurf* ConvertSurface( const ON_Surface* onSurf) ;
|
||||
ISurfTriMesh* ConvertExtrusion( const ON_Extrusion* onExtrusion) ;
|
||||
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) ;
|
||||
ISURFPOVECTOR ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh) ;
|
||||
ICurve* ConvertBrepLoop( const ON_BrepLoop* onBrepLoop) ;
|
||||
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) ;
|
||||
std::string ConvertONwStringToString( ON_wString ON_wString) ;
|
||||
|
||||
private :
|
||||
IGeomDB* m_pGDB ;
|
||||
int m_nIdGroup ;
|
||||
std::map< int, std::tuple<const ON_Layer*, ON_UUID, int, bool>> m_mLayer ; // mappa dei layer con id nel GDB e l'uuid nel modello 3dm, un int per l'indice del layer nel model e un bool che indica la presenza di sottolayer
|
||||
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 ;
|
||||
} ;
|
||||
Reference in New Issue
Block a user