Files
EgtInterface/API_GeoSnap.cpp
T
Dario Sassi db790fc5b5 EgtInterface 1.9i4 :
- aggiunti parametri di ritorno a EgtSurfTmFacetOppositeSide.
2018-10-01 07:29:13 +00:00

710 lines
21 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : API_GeoSnap.cpp Data : 02.10.14 Versione : 1.5i5
// Contenuto : Funzioni di snap ad oggetti del DB geometrico per API.
//
//
//
// Modifiche : 02.10.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EgtStringConverter.h"
#include <string>
using namespace std ;
//----------------------------------------------------------------------------
BOOL
__stdcall EgtStartPoint( int nId, int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptStart ;
if ( ! ExeStartPoint( nId, nRefId, ptStart))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptStart)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtEndPoint( int nId, int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptEnd ;
if ( ! ExeEndPoint( nId, nRefId, ptEnd))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptEnd)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtMidPoint( int nId, int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptMid ;
if ( ! ExeMidPoint( nId, nRefId, ptMid))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptMid)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCenterPoint( int nId, int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptCent ;
if ( ! ExeCenterPoint( nId, nRefId, ptCent))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptCent)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCentroid( int nId, int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptCent ;
if ( ! ExeCentroid( nId, nRefId, ptCent))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptCent)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtAtParamPoint( int nId, double dU, int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptAtPar ;
if ( ! ExeAtParamPoint( nId, dU, nRefId, ptAtPar))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptAtPar)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtNearPoint( int nId, const double ptNear[3], int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptInt ;
if ( ! ExeNearPoint( nId, ptNear, nRefId, ptInt))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptInt)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtIntersectionPoint( int nId1, int nId2, const double ptNear[3], int nRefId, double ptP[3])
{
// recupero il punto
Point3d ptInt ;
if ( ! ExeIntersectionPoint( nId1, nId2, ptNear, nRefId, ptInt))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptInt)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtStartVector( int nId, int nRefId, double vtV[3])
{
// recupero il vettore
Vector3d vtStart ;
if ( ! ExeStartVector( nId, nRefId, vtStart))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtStart)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtEndVector( int nId, int nRefId, double vtV[3])
{
// recupero il vettore
Vector3d vtEnd ;
if ( ! ExeEndVector( nId, nRefId, vtEnd))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtEnd)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtMidVector( int nId, int nRefId, double vtV[3])
{
// recupero il vettore
Vector3d vtMid ;
if ( ! ExeMidVector( nId, nRefId, vtMid))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtMid)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtAtParamVector( int nId, double dU, int nSide, int nRefId, double vtV[3])
{
// recupero il vettore
Vector3d vtAtPar ;
if ( ! ExeAtParamVector( nId, dU, nSide, nRefId, vtAtPar))
return FALSE ;
// ritorno il vettore
VEC_FROM_3D( vtV, vtAtPar)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtFrame( int nId, int nRefId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3])
{
// recupero il frame
Frame3d frFrame ;
if ( ! ExeFrame( nId, nRefId, frFrame))
return FALSE ;
// assegno l'origine
VEC_FROM_3D( ptOrig, frFrame.Orig())
// assegno il versore X
VEC_FROM_3D( vtX, frFrame.VersX())
// assegno il versore Y
VEC_FROM_3D( vtY, frFrame.VersY())
// assegno il versore Z
VEC_FROM_3D( vtZ, frFrame.VersZ())
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveDomain( int nId, double* pdStart, double* pdEnd)
{
return ( ExeCurveDomain( nId, pdStart, pdEnd) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveLength( int nId, double* pdLen)
{
return ( ExeCurveLength( nId, pdLen) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveLengthAtPoint( int nId, const double ptOn[3], double dExtend, double* pdLen)
{
return ( ExeCurveLengthAtPoint( nId, ptOn, dExtend, pdLen) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveIsClosed( int nId)
{
return ( ExeCurveIsClosed( nId) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveIsFlat( int nId, double vtN[3], double* pdDist)
{
if ( vtN == nullptr || pdDist == nullptr)
return FALSE ;
Plane3d Plane ;
if ( ! ExeCurveIsFlat( nId, Plane))
return FALSE ;
VEC_FROM_3D( vtN, Plane.GetVersN())
*pdDist = Plane.GetDist() ;
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveAreaXY( int nId, double* pdArea)
{
return ( ExeCurveAreaXY( nId, *pdArea) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveArea( int nId, double vtN[3], double* pdDist, double* pdArea)
{
if ( vtN == nullptr || pdDist == nullptr || pdArea == nullptr)
return FALSE ;
Plane3d Plane ;
if ( ! ExeCurveArea( nId, Plane, *pdArea))
return FALSE ;
VEC_FROM_3D( vtN, Plane.GetVersN())
*pdDist = Plane.GetDist() ;
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveNearestExtremityToPoint( int nId, const double ptP[3], BOOL* pbStart)
{
if ( pbStart == nullptr)
return FALSE ;
bool bStart ;
if ( ! ExeCurveNearestExtremityToPoint( nId, ptP, bStart))
return FALSE ;
*pbStart = ( bStart ? TRUE : FALSE) ;
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveExtrusion( int nId, int nRefId, double vtExtr[3])
{
// recupero il vettore estrusione
Vector3d vtTmp ;
if ( ! ExeCurveExtrusion( nId, nRefId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtExtr, vtTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveThickness( int nId, double* pdThick)
{
return ( ExeCurveThickness( nId, pdThick) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveSelfIntersCount( int nId, int* pnCount)
{
return ( ExeCurveSelfIntersCount( nId, pnCount) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveMinAreaRectangleXY( int nId, int nRefId,
double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3], double* pdDimX, double* pdDimY)
{
// eseguo calcoli
Frame3d frRect ;
double dDimX, dDimY ;
if ( ! ExeCurveMinAreaRectangleXY( nId, nRefId, frRect, dDimX, dDimY))
return FALSE ;
// assegno l'origine
if ( ptOrig != nullptr)
VEC_FROM_3D( ptOrig, frRect.Orig())
// assegno il versore X
if ( vtX != nullptr)
VEC_FROM_3D( vtX, frRect.VersX())
// assegno il versore Y
if ( vtY != nullptr)
VEC_FROM_3D( vtY, frRect.VersY())
// assegno il versore Z
if ( vtZ != nullptr)
VEC_FROM_3D( vtZ, frRect.VersZ())
if ( pdDimX != nullptr)
*pdDimX = dDimX ;
if ( pdDimY != nullptr)
*pdDimY = dDimY ;
return TRUE ;
}
//----------------------------------------------------------------------------
int
__stdcall EgtClosedCurveClassify( int nId1, int nId2)
{
return ExeClosedCurveClassify( nId1, nId2) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtGetMinDistPointCurve( const double ptP[3], int nId, double* pdDist, double* pdU)
{
return ( ExeGetMinDistPointCurve( ptP, nId, pdDist, pdU) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtGetMinDistPntSidePointCurve( const double ptP[3], int nId, const double vtN[3],
double* pdDist, double ptMin[3], int* pnSide)
{
if ( pdDist == nullptr || ptMin == nullptr || pnSide == nullptr)
return FALSE ;
Point3d ptTmp ;
if ( ! ExeGetMinDistPntSidePointCurve( ptP, nId, vtN, pdDist, ptTmp, pnSide))
return FALSE ;
VEC_FROM_3D( ptMin, ptTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtArcRadius( int nId, double* pdRad)
{
return ( ExeArcRadius( nId, pdRad) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtArcAngCenter( int nId, double* pdAngDeg)
{
return ( ExeArcAngCenter( nId, pdAngDeg) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtArcDeltaN( int nId, double* pdDeltaN)
{
return ( ExeArcDeltaN( nId, pdDeltaN) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtArcNormVersor( int nId, int nRefId, double vtNorm[3])
{
// recupero il vettore normale
Vector3d vtTmp ;
if ( ! ExeArcNormVersor( nId, nRefId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtNorm, vtTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, double ptCen[3])
{
// recupero il centro
Point3d ptTmp ;
if ( ! ExeCurveCompoCenter( nId, nSimpCrv, nRefId, ptTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( ptCen, ptTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfFrNormVersor( int nId, int nRefId, double vtNorm[3])
{
// recupero il vettore normale
Vector3d vtTmp ;
if ( ! ExeSurfFrNormVersor( nId, nRefId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtNorm, vtTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
int
__stdcall EgtSurfFrChunkCount( int nId)
{
return ExeSurfFrChunkCount( nId) ;
}
//----------------------------------------------------------------------------
int
__stdcall EgtSurfFrChunkSimpleClassify( int nId1, int nChunk1, int nId2, int nChunk2)
{
return ExeSurfFrChunkSimpleClassify( nId1, nChunk1, nId2, nChunk2) ;
}
//----------------------------------------------------------------------------
int
__stdcall EgtSurfTmFacetCount( int nId)
{
return ExeSurfTmFacetCount( nId) ;
}
//----------------------------------------------------------------------------
int
__stdcall EgtSurfTmFacetFromTria( int nId, int nT)
{
return ExeSurfTmFacetFromTria( nId, nT) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const double ptNear[3], int nRefId,
double ptEnd[3], double vtNorm[3])
{
// recupero il punto e la normale
Point3d ptTmp ;
Vector3d vtN ;
if ( ! ExeSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN))
return FALSE ;
// li assegno
VEC_FROM_3D( ptEnd, ptTmp)
VEC_FROM_3D( vtNorm, vtN)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const double ptNear[3], int nRefId,
double ptMid[3], double vtNorm[3])
{
// recupero il punto e la normale
Point3d ptTmp ;
Vector3d vtN ;
if ( ! ExeSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN))
return FALSE ;
// li assegno
VEC_FROM_3D( ptMid, ptTmp)
VEC_FROM_3D( vtNorm, vtN)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, double ptCen[3], double vtNorm[3])
{
// recupero il centro e la normale
Point3d ptTmp ;
Vector3d vtN ;
if ( ! ExeSurfTmFacetCenter( nId, nFacet, nRefId, ptTmp, vtN))
return FALSE ;
// li assegno
VEC_FROM_3D( ptCen, ptTmp)
VEC_FROM_3D( vtNorm, vtN)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, double vtNorm[3])
{
// recupero il vettore normale
Vector3d vtTmp ;
if ( ! ExeSurfTmFacetNormVersor( nId, nFacet, nRefId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtNorm, vtTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetOppositeSide( int nId, int nFacet, const double vtDir[3], int nRefId,
double ptP1[3], double ptP2[3], double vtIn1[3], double vtOut2[3])
{
// verifica parametri
if ( vtDir == nullptr || ptP1 == nullptr || ptP2 == nullptr || vtIn1 == nullptr || vtOut2 == nullptr)
return FALSE ;
// recupero gli estremi del lato opposto
Point3d ptMyP1, ptMyP2 ;
Vector3d vtMyIn1, vtMyOut2 ;
if ( ! ExeSurfTmFacetOppositeSide( nId, nFacet, vtDir, nRefId, ptMyP1, ptMyP2, vtMyIn1, vtMyOut2))
return FALSE ;
// assegno risultati
VEC_FROM_3D( ptP1, ptMyP1)
VEC_FROM_3D( ptP2, ptMyP2)
VEC_FROM_3D( vtIn1, vtMyIn1)
VEC_FROM_3D( vtOut2, vtMyOut2)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetAdjacencies( int nId, int nFacet, int*& vAdj, int* pnCount)
{
// verifica parametri di ritorno
if ( &vAdj == nullptr || pnCount == nullptr)
return FALSE ;
// eseguo
INTMATRIX vTmp ;
if ( ! ExeSurfTmFacetAdjacencies( nId, nFacet, vTmp))
return FALSE ;
// recupero il risultato
int nDim = 0 ;
for ( int i = 0 ; i < int( vTmp.size()) ; ++ i)
nDim += int( vTmp[i].size()) + 1 ;
int nCount = 0 ;
if ( nDim == 0) {
vAdj = nullptr ;
}
else {
vAdj = (int*) malloc( nDim * sizeof( int)) ;
if ( vAdj == nullptr)
return FALSE ;
for ( int i = 0 ; i < int( vTmp.size()) ; ++ i) {
for ( int j = 0 ; j < int( vTmp[i].size()) ; ++ j) {
vAdj[nCount] = vTmp[i][j] ;
nCount ++ ;
}
vAdj[nCount] = - 2 ;
nCount ++ ;
}
}
*pnCount = nCount ;
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmFacetsContact( int nId, int nF1, int nF2, int nRefId, bool* pbAdjac, double ptP1[3], double ptP2[3], double* pdAng)
{
// verifica parametri di ritorno
if ( pbAdjac == nullptr || ptP1 == nullptr || ptP2 == nullptr || pdAng == nullptr)
return FALSE ;
// eseguo
Point3d ptMyP1, ptMyP2 ;
if ( ! ExeSurfTmFacetsContact( nId, nF1, nF2, nRefId, *pbAdjac, ptMyP1, ptMyP2, *pdAng))
return FALSE ;
// assegno risultati
VEC_FROM_3D( ptP1, ptMyP1)
VEC_FROM_3D( ptP2, ptMyP2)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSurfTmLineInters( int nId, const double ptP[3], const double vtDir[3], int nRefType, int*& vFlagInters, double*& vParInters, int* pnCount)
{
// verifica parametri
if ( ptP == nullptr || vtDir == nullptr || &vFlagInters == nullptr || &vParInters == nullptr || pnCount == nullptr)
return FALSE ;
// eseguo intersezione
INTDBLVECTOR vInters ;
if ( ! ExeSurfTmLineInters( nId, ptP, vtDir, nRefType, vInters))
return FALSE ;
// assegno risultati
int nDim = int( vInters.size()) ;
if ( nDim == 0) {
vFlagInters = nullptr ;
vParInters = nullptr ;
}
else {
vFlagInters = (int*) malloc( nDim * sizeof( int)) ;
if ( vFlagInters == nullptr)
return FALSE ;
vParInters = (double*) malloc( nDim * sizeof( double)) ;
if ( vParInters == nullptr) {
free( vFlagInters) ;
return FALSE ;
}
for ( int i = 0 ; i < nDim ; ++ i) {
vFlagInters[i] = vInters[i].first ;
vParInters[i] = vInters[i].second ;
}
}
*pnCount = nDim ;
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtTextNormVersor( int nId, int nRefId, double vtNorm[3])
{
// verifica parametro di ritorno
if ( vtNorm == nullptr)
return FALSE ;
// recupero il vettore normale
Vector3d vtTmp ;
if ( ! ExeTextNormVersor( nId, nRefId, vtTmp))
return FALSE ;
// lo assegno
VEC_FROM_3D( vtNorm, vtTmp)
return TRUE ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtTextGetContent( int nId, wchar_t*& wsText)
{
if ( &wsText == nullptr)
return FALSE ;
string sText ;
if ( ! ExeTextGetContent( nId, sText))
return FALSE ;
wsText = _wcsdup( stringtoW( sText)) ;
return (( wsText == nullptr) ? FALSE : TRUE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtTextGetFont( int nId, wchar_t*& wsFont)
{
if ( &wsFont == nullptr)
return FALSE ;
string sFont ;
if ( ! ExeTextGetFont( nId, sFont))
return FALSE ;
wsFont = _wcsdup( stringtoW( sFont)) ;
return (( wsFont == nullptr) ? FALSE : TRUE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtPointToIdGlob( double ptP[3], int nId)
{
// trasformo il punto
Point3d ptTmp( ptP) ;
if ( ! ExePointToIdGlob( ptTmp, nId))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptTmp)
return TRUE ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtPointToIdLoc( double ptP[3], int nId)
{
// trasformo il punto
Point3d ptTmp( ptP) ;
if ( ! ExePointToIdLoc( ptTmp, nId))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( ptP, ptTmp)
return TRUE ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtVectorToIdGlob( double vtV[3], int nId)
{
// trasformo il vettore
Vector3d vtTmp( vtV) ;
if ( ! ExeVectorToIdGlob( vtTmp, nId))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( vtV, vtTmp)
return TRUE ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtVectorToIdLoc( double vtV[3], int nId)
{
// trasformo il vettore
Vector3d vtTmp( vtV) ;
if ( ! ExeVectorToIdLoc( vtTmp, nId))
return FALSE ;
// ritorno il punto
VEC_FROM_3D( vtV, vtTmp)
return TRUE ;
}