047bff2f11
- aggiunta funzione exe e lua CreateAngularDimensionEx.
939 lines
41 KiB
C++
939 lines
41 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_GdbCreate.cpp Data : 04.05.15 Versione : 1.6e1
|
|
// Contenuto : Funzioni di creazione oggetti del DB geometrico per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 30.09.14 DS Creazione modulo.
|
|
// 07.01.15 DS Agg. scrittura comandi Lua.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "AuxTools.h"
|
|
#include "GeoTools.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
|
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
|
#include "/EgtDev/Include/EGkExtText.h"
|
|
#include "/EgtDev/Include/EGkExtDimension.h"
|
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
|
#include "/EgtDev/Include/EgtStringConverter.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
#include "/EgtDev/Include/EGkIntersCurves.h"
|
|
#include "/EgtDev/Include/EGkCurveLine.h"
|
|
#include "/EgtDev/Include/EGkCurveArc.h"
|
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateGroup( int nParentId, const Frame3d& frFrame, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc ) ;
|
|
// porto in locale l'origine e i versori
|
|
Point3d ptOrigL = GetPointLocal( pGeomDB, frFrame.Orig(), nRefType, frLoc) ;
|
|
Vector3d vtXL = GetVectorLocal( pGeomDB, frFrame.VersX(), nRefType, frLoc) ;
|
|
Vector3d vtYL = GetVectorLocal( pGeomDB, frFrame.VersY(), nRefType, frLoc) ;
|
|
Vector3d vtZL = GetVectorLocal( pGeomDB, frFrame.VersZ(), nRefType, frLoc) ;
|
|
// costruisco il riferimento
|
|
Frame3d frFrameL ;
|
|
bOk = bOk && frFrameL.Set( ptOrigL, vtXL, vtYL, vtZL) ;
|
|
// creo il gruppo
|
|
int nId = ( bOk ? pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrameL) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua ;
|
|
if ( AreSameFrame( frFrame, GLOB_FRM)) {
|
|
if ( nRefType == RTY_LOC)
|
|
sLua = "EgtGroup(" + IdToString( nParentId) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
else
|
|
sLua = "EgtGroup(" + IdToString( nParentId) + "," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
}
|
|
else
|
|
sLua = "EgtGroup(" + IdToString( nParentId) + ",{{" +
|
|
ToString( frFrame.Orig()) + "},{" +
|
|
ToString( frFrame.VersX()) + "},{" +
|
|
ToString( frFrame.VersY()) + "},{" +
|
|
ToString( frFrame.VersZ()) + "}}," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del nuovo gruppo
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateGeoPoint( int nParentId, const Point3d& ptP, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
|
// porto in locale il punto
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
|
|
// creo il punto
|
|
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
|
bOk = bOk && !IsNull( pGeoPnt) ;
|
|
// setto il punto
|
|
bOk = bOk && pGeoPnt->Set( ptPL) ;
|
|
// inserisco il punto nel DB
|
|
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtPoint(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptP) + "}," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo della nuova entit�
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
|
// porto in locale il vettore e il punto
|
|
Vector3d vtVL = GetVectorLocal( pGeomDB, vtV, nRefType, frLoc) ;
|
|
Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ;
|
|
// creo il vettore
|
|
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
|
|
bOk = bOk && ! IsNull( pGeoVct) ;
|
|
// setto il vettore (con il punto base)
|
|
bOk = bOk && pGeoVct->Set( vtVL, ptBL) ;
|
|
// inserisco il vettore nel DB
|
|
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua ;
|
|
if ( ptB.IsSmall())
|
|
sLua = "EgtVector(" + IdToString( nParentId) + ",{" +
|
|
ToString( vtV) + "}," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
else
|
|
sLua = "EgtVector(" + IdToString( nParentId) + ",{" +
|
|
ToString( vtV) + "},{" +
|
|
ToString( ptB) + "}," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo della nuova entit�
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateGeoFrame( int nParentId, const Frame3d& frFrame, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc ) ;
|
|
// porto in locale l'origine e i versori
|
|
Point3d ptOrigL = GetPointLocal( pGeomDB, frFrame.Orig(), nRefType, frLoc) ;
|
|
Vector3d vtXL = GetVectorLocal( pGeomDB, frFrame.VersX(), nRefType, frLoc) ;
|
|
Vector3d vtYL = GetVectorLocal( pGeomDB, frFrame.VersY(), nRefType, frLoc) ;
|
|
Vector3d vtZL = GetVectorLocal( pGeomDB, frFrame.VersZ(), nRefType, frLoc) ;
|
|
// creo e setto il riferimento
|
|
PtrOwner<IGeoFrame3d> pGeoFrm( CreateGeoFrame3d()) ;
|
|
bOk = bOk && !IsNull( pGeoFrm) ;
|
|
bOk = bOk && pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ;
|
|
// inserisco il riferimento nel DB
|
|
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtFrame(" + IdToString( nParentId) + ",{{" +
|
|
ToString( frFrame.Orig()) + "},{" +
|
|
ToString( frFrame.VersX()) + "},{" +
|
|
ToString( frFrame.VersY()) + "},{" +
|
|
ToString( frFrame.VersZ()) + "}}," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del nuovo gruppo
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateText( int nParentId, const Point3d& ptP,
|
|
const string& sText, double dH, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
|
// porto in locale l'origine e i versori
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
|
Vector3d vtDL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ;
|
|
// creo il testo e lo riempio
|
|
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
|
bOk = bOk && !IsNull( pTXT) ;
|
|
bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, "", false, dH) ;
|
|
// inserisco il testo nel DB
|
|
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtText(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptP) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
ToString( dH) + "," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateTextEx( int nParentId, const Point3d& ptP, double dAngRotDeg,
|
|
const string& sText, const string& sFont, bool bItalic, double dH, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
|
// porto in locale l'origine e i versori
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
|
Vector3d vtDL = GetVectorLocal( pGeomDB, FromPolar( 1, dAngRotDeg), nRefType, frLoc) ;
|
|
// creo il testo e lo riempio
|
|
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
|
bOk = bOk && !IsNull( pTXT) ;
|
|
bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, bItalic, dH) ;
|
|
// inserisco il testo nel DB
|
|
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtTextEx(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptP) + "}," +
|
|
ToString( dAngRotDeg) + ",'" +
|
|
StringToLuaString( sText) + "','" +
|
|
StringToLuaString( sFont) + "'," +
|
|
( bItalic ? "'I'" : "'S'") + "," +
|
|
ToString( dH) + "," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg,
|
|
const string& sText, const string& sFont,
|
|
int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
bool bOk = true ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
|
// porto in locale l'origine e i versori
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
|
Vector3d vtDL = GetVectorLocal( pGeomDB, FromPolar( 1, dAngRotDeg), nRefType, frLoc) ;
|
|
// creo il testo e lo imposto
|
|
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
|
bOk = bOk && !IsNull( pTXT) ;
|
|
bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ;
|
|
// inserisco il testo nel DB
|
|
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtTextAdv(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptP) + "}," +
|
|
ToString( dAngRotDeg) + ",'" +
|
|
StringToLuaString( sText) + "','" +
|
|
StringToLuaString( sFont) + "'," +
|
|
ToString( nW) + "," +
|
|
( bItalic ? "'I'" : "'S'") + "," +
|
|
ToString( dH) + "," +
|
|
ToString( dRat) + "," +
|
|
ToString( dAddAdv) + "," +
|
|
ETxtInsPosToString( nInsPos) + "," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
ExeSetCurrDimensionStyle( double dExtLineLen, double dArrowLen, double dTextDist,
|
|
int nLenIsMM, int nDecDigit, const string& sFont, double dTextHeight)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX( pGseCtx, false)
|
|
// aggiorno lo stile di quotatura corrente
|
|
pGseCtx->m_dsCurr.Set( dExtLineLen, dArrowLen, dTextDist, nLenIsMM, nDecDigit, sFont, dTextHeight) ;
|
|
return true ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
ExeResetCurrDimensionStyle( void)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX( pGseCtx, false)
|
|
// aggiorno lo stile di quotatura corrente
|
|
pGseCtx->m_dsCurr.Reset() ;
|
|
return true ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static bool
|
|
MySetDimensionStyle( IExtDimension* pDim)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX( pGseCtx, false)
|
|
// verifico validit� quotatura
|
|
if ( pDim == nullptr)
|
|
return false ;
|
|
// recupero lo stile di quotatura
|
|
const DimensionStyle& DimSt = pGseCtx->m_dsCurr ;
|
|
// recupero l'unit� di misura lineare per la quotatura
|
|
bool bLenIsMM = ( DimSt.nLenIsMM == 2 ? ExeUiUnitsAreMM() : ( DimSt.nLenIsMM != 0 )) ;
|
|
// imposto lo stile
|
|
return pDim->SetStyle( DimSt.dExtLineLen, DimSt.dArrowLen, DimSt.dTextDist,
|
|
bLenIsMM, DimSt.nDecDigit, DimSt.sFont, DimSt.dTextHeight) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateLinearDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
|
const Point3d& ptDim, const Vector3d& vtDir, const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc ))
|
|
return GDB_ID_NULL ;
|
|
// porto in locale i punti e assegno i versori
|
|
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
|
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
|
Vector3d vtDL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ;
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim ) ||
|
|
! MySetDimensionStyle( pDim ) ||
|
|
! pDim->SetLinear( ptP1L, ptP2L, ptDimL, vtNL, vtDL, sText ))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateHorizontalDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
|
const Point3d& ptDim, const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateLinearDimension( nParentId, ptP1, ptP2, ptDim, X_AX, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtHorizontalDimension(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptP1) + "},{" +
|
|
ToString( ptP2) + "},{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateVerticalDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
|
const Point3d& ptDim, const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateLinearDimension( nParentId, ptP1, ptP2, ptDim, Y_AX, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtVerticalDimension(" + IdToString( nParentId ) + ",{" +
|
|
ToString( ptP1) + "},{" +
|
|
ToString( ptP2) + "},{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateAlignedDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
|
const Point3d& ptDim, const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateLinearDimension( nParentId, ptP1, ptP2, ptDim, V_NULL, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAlignedDimension(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptP1) + "},{" +
|
|
ToString( ptP2) + "},{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
|
return GDB_ID_NULL ;
|
|
// recupero l'arco di circonferenza e il suo frame
|
|
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ;
|
|
if ( pArc == nullptr)
|
|
return GDB_ID_NULL ;
|
|
Frame3d frArc ;
|
|
if ( ! pGeomDB->GetGlobFrame( nCrvId, frArc))
|
|
return GDB_ID_NULL ;
|
|
// porto il punto nel riferimento locale
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
// recupero il centro e la normale e li porto nel riferimento locale
|
|
Point3d ptCenL = pArc->GetCenter() ;
|
|
ptCenL.LocToLoc( frArc, frLoc) ;
|
|
Vector3d vtNL = pArc->GetNormVersor() ;
|
|
vtNL.LocToLoc( frArc, frLoc) ;
|
|
// porto ptDimL sulla circonferenza cui appartiene l'arco
|
|
Vector3d vtDir = ptDimL - ptCenL ;
|
|
if ( ! vtDir.Normalize())
|
|
return GDB_ID_NULL ;
|
|
ptDimL = ptCenL + pArc->GetRadius() * vtDir ;
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim) ||
|
|
! MySetDimensionStyle( pDim) ||
|
|
! pDim->SetRadial( ptCenL, ptDimL, vtNL, sText))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtRadialDimension(" + IdToString( nParentId) + "," +
|
|
IdToString( nCrvId) + ",{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
|
return GDB_ID_NULL ;
|
|
// recupero l'arco e il suo frame
|
|
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ;
|
|
if ( pArc == nullptr)
|
|
return GDB_ID_NULL ;
|
|
Frame3d frArc ;
|
|
if ( ! pGeomDB->GetGlobFrame( nCrvId, frArc))
|
|
return GDB_ID_NULL ;
|
|
// porto il punto nel riferimento locale
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
// recupero il centro e la normale e li porto nel riferimento locale
|
|
Point3d ptCenL = pArc->GetCenter() ;
|
|
ptCenL.LocToLoc( frArc, frLoc) ;
|
|
Vector3d vtNL = pArc->GetNormVersor() ;
|
|
vtNL.LocToLoc( frArc, frLoc) ;
|
|
// porto ptDimL sulla circonferenza
|
|
Vector3d vtDir = ptDimL - ptCenL ;
|
|
if ( ! vtDir.Normalize())
|
|
return GDB_ID_NULL ;
|
|
ptDimL = ptCenL + pArc->GetRadius() * vtDir ;
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim) ||
|
|
! MySetDimensionStyle( pDim) ||
|
|
! pDim->SetDiametral( ptCenL, ptDimL, vtNL, sText))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtDiametralDimension(" + IdToString( nParentId) + "," +
|
|
IdToString( nCrvId) + ",{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateAngularDimension( int nParentId, const Point3d& ptV, const Point3d& ptP1, const Point3d& ptP2,
|
|
const Point3d& ptDim, const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
|
return GDB_ID_NULL ;
|
|
// porto in locale i punti e assegno i versori
|
|
Point3d ptVL = GetPointLocal( pGeomDB, ptV, nRefType, frLoc) ;
|
|
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
|
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim) ||
|
|
! MySetDimensionStyle( pDim ) ||
|
|
! pDim->SetAngular( ptVL, ptP1L, ptP2L, ptDimL, vtNL, sText))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateAngularDimension( int nParentId, const Point3d& ptV, const Point3d& ptP1, const Point3d& ptP2,
|
|
const Point3d& ptDim, const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateAngularDimension( nParentId, ptV, ptP1, ptP2, ptDim, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAngularDimension(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptV) + "},{" +
|
|
ToString( ptP1) + "},{" +
|
|
ToString( ptP2) + "},{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateAngularDimensionEx( int nParentId, const Point3d& ptV1, const Point3d& ptP1,
|
|
const Point3d& ptV2,const Point3d& ptP2, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
|
return GDB_ID_NULL ;
|
|
// porto in locale i punti e assegno i versori
|
|
Point3d ptV1L = GetPointLocal( pGeomDB, ptV1, nRefType, frLoc) ;
|
|
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
|
Point3d ptV2L = GetPointLocal( pGeomDB, ptV2, nRefType, frLoc) ;
|
|
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim) ||
|
|
! MySetDimensionStyle( pDim ) ||
|
|
! pDim->SetAngularEx( ptV1L, ptP1L, ptV2L, ptP2L, ptDimL, vtNL, sText))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateAngularDimensionEx( int nParentId, const Point3d& ptV1, const Point3d& ptP1,
|
|
const Point3d& ptV2, const Point3d& ptP2, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateAngularDimensionEx( nParentId, ptV1, ptP1, ptV2, ptP2, ptDim, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAngularDimensionEx(" + IdToString( nParentId) + ",{" +
|
|
ToString( ptV1) + "},{" +
|
|
ToString( ptP1) + "},{" +
|
|
ToString( ptV2) + "},{" +
|
|
ToString( ptP2) + "},{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateAngularDimensionFromLines( int nParentId, INTVECTOR vLineIds, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
|
return GDB_ID_NULL ;
|
|
// recupero le linee
|
|
ICurveLine* pCrv1 = GetCurveLine( pGeomDB->GetGeoObj( vLineIds[0])) ;
|
|
ICurveLine* pCrv2 = GetCurveLine( pGeomDB->GetGeoObj( vLineIds[1])) ;
|
|
if ( pCrv1 == nullptr || pCrv2 == nullptr)
|
|
return GDB_ID_NULL ;
|
|
PtrOwner<ICurveLine> pL1( pCrv1->Clone()) ;
|
|
PtrOwner<ICurveLine> pL2( pCrv2->Clone()) ;
|
|
if ( IsNull( pL1 ) || ! pL1->IsValid() || IsNull( pL2) || ! pL2->IsValid())
|
|
return GDB_ID_NULL ;
|
|
// porto tutto nel frLoc
|
|
Frame3d frL1, frL2 ;
|
|
if ( ! pGeomDB->GetGlobFrame( vLineIds[0], frL1) || ! pGeomDB->GetGlobFrame( vLineIds[1], frL2))
|
|
return GDB_ID_NULL ;
|
|
pL1->LocToLoc( frL1, frLoc) ;
|
|
pL2->LocToLoc( frL2, frLoc) ;
|
|
// recupero il punto lo porto nel riferimento locale
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
// recupero i punti e le direzioni
|
|
Point3d ptP1L, ptP2L, ptP3L, ptP4L ;
|
|
Vector3d vtL1, vtL2 ;
|
|
pL1->GetStartPoint( ptP1L) ;
|
|
pL1->GetEndPoint( ptP2L) ;
|
|
pL2->GetStartPoint( ptP3L) ;
|
|
pL2->GetEndPoint( ptP4L) ;
|
|
pL1->GetStartDir( vtL1) ;
|
|
pL2->GetStartDir( vtL2) ;
|
|
// controllo se le rette sono coincidenti o parallele
|
|
if ( AreSameOrOppositeVectorApprox( vtL1, vtL2))
|
|
return GDB_ID_NULL ;
|
|
// verifico se le rette si intersecano già
|
|
Point3d ptCenL ;
|
|
IntersCurveCurve pInters( *pL1, *pL2) ;
|
|
int nNumeroInters = pInters.GetIntersCount() ;
|
|
// se non ho intersezioni estendo
|
|
if ( nNumeroInters == 0) {
|
|
double dLen = pow( 10, 5) ;
|
|
pL1->ExtendStartByLen( dLen) ;
|
|
pL2->ExtendStartByLen( dLen) ;
|
|
pL1->ExtendEndByLen( dLen) ;
|
|
pL2->ExtendEndByLen( dLen) ;
|
|
// faccio intersezione
|
|
IntersCurveCurve pIntersExt( *pL1, *pL2) ;
|
|
nNumeroInters = pIntersExt.GetIntersCount() ;
|
|
// le linee estese non si intersecano, quindi vuol dire che sono quasi parallele e lontanissime
|
|
if ( nNumeroInters == 0 )
|
|
return GDB_ID_NULL ;
|
|
else {
|
|
IntCrvCrvInfo Info ;
|
|
pIntersExt.GetIntCrvCrvInfo( 0, Info) ;
|
|
// controllo che non siano coincidenti
|
|
if ( Info.bOverlap)
|
|
return false ;
|
|
else
|
|
ptCenL = Info.IciA->ptI ;
|
|
}
|
|
// seleziono i punti necessari
|
|
// se ptDimL è più vicino a ptCenL rispetto agli estremi esterni delle linee, allora tengo gli estremi interni
|
|
double dP1Cen = ( ptP1L - ptCenL).Len() ;
|
|
double dP2Cen = ( ptP2L - ptCenL).Len() ;
|
|
double dDimCen = ( ptDimL - ptCenL).Len() ;
|
|
if ( ( dDimCen < dP1Cen || dDimCen < dP2Cen))
|
|
// se uno dei due punti è più vicino a ptCenL rispetto a ptDimL, allora tengo il punto più vicino a ptDimL
|
|
ptP1L = ( ( ptDimL - ptP1L ).Len() < ( ptDimL - ptP2L ).Len() ? ptP1L : ptP2L) ;
|
|
else
|
|
ptP1L = ( dP1Cen < dP2Cen ? ptP2L : ptP1L ) ;
|
|
// rifaccio anche per l'altro lato
|
|
double dP3Cen = ( ptP3L - ptCenL).Len() ;
|
|
double dP4Cen = ( ptP4L - ptCenL).Len() ;
|
|
if ( dDimCen < dP3Cen || dDimCen < dP4Cen)
|
|
ptP3L = ( ( ptDimL - ptP3L).Len() < ( ptDimL - ptP4L).Len() ? ptP3L : ptP4L) ;
|
|
else
|
|
ptP3L = ( dP3Cen < dP4Cen ? ptP4L : ptP3L) ;
|
|
}
|
|
// se ho già intesezioni devo capire in quale quadrante si trova ptDim
|
|
else {
|
|
// recupero l'intersezione
|
|
IntCrvCrvInfo Info ;
|
|
pInters.GetIntCrvCrvInfo( 0, Info) ;
|
|
// controllo che non siano coincidenti
|
|
if ( Info.bOverlap)
|
|
return false ;
|
|
// se non coincidono restituisco l'intersezione
|
|
else
|
|
ptCenL = Info.IciA->ptI ;
|
|
// se le due linee hanno un estremo in comune, estendo le linee da quel lato
|
|
if ( ( AreSamePointApprox( ptCenL, ptP1L) || AreSamePointApprox( ptCenL, ptP2L)) &&
|
|
( AreSamePointApprox( ptCenL, ptP3L) || AreSamePointApprox( ptCenL, ptP4L))) {
|
|
if ( AreSamePointApprox( ptCenL, ptP1L)) {
|
|
pL1->ExtendStartByLen(Dist( ptP1L, ptP2L) / 2) ;
|
|
pL1->GetStartPoint( ptP1L) ;
|
|
}
|
|
else {
|
|
pL1->ExtendEndByLen(Dist( ptP1L, ptP2L) / 2) ;
|
|
pL1->GetEndPoint( ptP2L) ;
|
|
}
|
|
if ( AreSamePointApprox( ptCenL, ptP3L)) {
|
|
pL2->ExtendStartByLen( Dist( ptP3L, ptP4L) / 2);
|
|
pL2->GetStartPoint( ptP3L) ;
|
|
}
|
|
else {
|
|
pL2->ExtendEndByLen(Dist( ptP3L, ptP4L) / 2);
|
|
pL2->GetEndPoint( ptP4L) ;
|
|
}
|
|
}
|
|
// seleziono i punti necessari
|
|
// proietto pdDim su vtLine1 e su vtLine2
|
|
Point3d ptDim1, ptDim2 ;
|
|
DistPointCurve distPL1( ptDimL, *pL1, true) ;
|
|
DistPointCurve distPL2( ptDimL, *pL2, true) ;
|
|
int nFlag1, nFlag2 ;
|
|
if ( ! distPL1.GetMinDistPoint( 0, ptDim1, nFlag1) || ! distPL2.GetMinDistPoint( 0, ptDim2, nFlag2) )
|
|
return false ;
|
|
if ( abs(( ptDim1 - ptP1L).Len() + ( ptCenL - ptDim1).Len() - ( ptCenL - ptP1L).Len()) < EPS_SMALL ||
|
|
abs(( ptDim1 - ptP1L).Len() + ( ptCenL - ptP1L ).Len() - ( ptDim1 - ptCenL).Len()) < EPS_SMALL)
|
|
// ptDim è dal lato di ptP1L, quindi tengo ptP1L
|
|
;
|
|
else
|
|
// ptDim è dal lato di ptP2L
|
|
ptP1L = ptP2L ;
|
|
if ( abs(( ptDim2 - ptP3L).Len() + ( ptCenL - ptDim2).Len() - ( ptCenL - ptP3L).Len()) < EPS_SMALL ||
|
|
abs(( ptDim2 - ptP3L).Len() + ( ptCenL - ptP3L).Len() - ( ptDim2 - ptCenL).Len()) < EPS_SMALL)
|
|
// ptDim è dal lato di ptP1L
|
|
;
|
|
else
|
|
// ptDim è dal lato di ptP2L
|
|
ptP3L = ptP4L ;
|
|
}
|
|
// recupero la normale al piano dell'angolo da quotare
|
|
Frame3d frArc;
|
|
frArc.Set(ptCenL, ptP1L, ptP3L);
|
|
Vector3d vtNL = frArc.VersZ() ;
|
|
if ( vtNL * Z_AX < - EPS_SMALL) {
|
|
frArc.Set(ptCenL, ptP3L, ptP1L);
|
|
vtNL = frArc.VersZ() ;
|
|
}
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim ) ||
|
|
! MySetDimensionStyle( pDim ) ||
|
|
! pDim->SetAngular( ptP1L, ptCenL, ptP3L, ptDimL, vtNL, sText))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateAngularDimensionFromLines( int nParentId, const INTVECTOR vLineIds, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateAngularDimensionFromLines( nParentId, vLineIds, ptDim, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAngularDimensionFromLines(" + IdToString( nParentId) + "," +
|
|
ToString( vLineIds[0]) + "," +
|
|
ToString( vLineIds[1]) + ",{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
MyCreateAngularDimensionFromArc( int nParentId, int nCrvId, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero il riferimento locale
|
|
Frame3d frLoc ;
|
|
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
|
return GDB_ID_NULL ;
|
|
// recupero l'arco e il suo frame
|
|
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ;
|
|
if ( pArc == nullptr)
|
|
return GDB_ID_NULL ;
|
|
Frame3d frArc ;
|
|
if ( ! pGeomDB->GetGlobFrame( nCrvId, frArc))
|
|
return GDB_ID_NULL ;
|
|
// recupero i punti e la normale e li porto nel frame locale
|
|
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
|
Vector3d vtNL = pArc->GetNormVersor() ;
|
|
vtNL.LocToLoc( frArc, frLoc) ;
|
|
Point3d ptCenL, ptP1L, ptP2L ;
|
|
pArc->GetStartPoint( ptP1L) ;
|
|
ptP1L.LocToLoc( frArc, frLoc) ;
|
|
pArc->GetEndPoint( ptP2L) ;
|
|
ptP2L.LocToLoc( frArc, frLoc) ;
|
|
pArc->GetCenterPoint( ptCenL) ;
|
|
ptCenL.LocToLoc( frArc, frLoc) ;
|
|
// porto ptDimL nell'area di influenza dell'arco
|
|
Point3d ptMid ;
|
|
pArc->GetMidPoint( ptMid) ;
|
|
Vector3d vtDir = ( ptMid - ptCenL) ;
|
|
if ( ! vtDir.Normalize())
|
|
return GDB_ID_NULL ;
|
|
ptDimL = ptCenL + Dist( ptDimL, ptCenL) * vtDir ;
|
|
// creo la quota
|
|
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
|
if ( IsNull( pDim ) ||
|
|
! MySetDimensionStyle( pDim) ||
|
|
! pDim->SetAngular( ptP1L, ptCenL, ptP2L, ptDimL, vtNL, sText))
|
|
return GDB_ID_NULL ;
|
|
// inserisco la quota nel DB
|
|
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateAngularDimensionFromArc( int nParentId, int nCrvId, const Point3d& ptDim,
|
|
const string& sText, int nRefType)
|
|
{
|
|
// eseguo
|
|
int nId = MyCreateAngularDimensionFromArc( nParentId, nCrvId, ptDim, sText, nRefType) ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAngularDimensionFromArc(" + IdToString( nParentId) + "," +
|
|
IdToString( nCrvId) + ",{" +
|
|
ToString( ptDim) + "},'" +
|
|
StringToLuaString( sText) + "'," +
|
|
RefTypeToString( nRefType) + ")" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo del oggetto
|
|
return nId ;
|
|
} |