Compare commits
463 Commits
SaraP
..
Shell&Parts
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e924113d3 | |||
| dcc3fc772a | |||
| a48f373e4d | |||
| 2ed2a34d55 | |||
| fcbdee1dba | |||
| 33d1ef4123 | |||
| fe2aba43e5 | |||
| c0b5f38301 | |||
| 1c157f323e | |||
| 3e6aa0d81b | |||
| 34089648b0 | |||
| 0bef1638d0 | |||
| 17759877d4 | |||
| d00064a671 | |||
| dc91f932f7 | |||
| d911862c84 | |||
| 1b025ec60e | |||
| 9d18e1a9ba | |||
| 3a8900983a | |||
| 971a76e473 | |||
| 35c019a03e | |||
| de97f249a2 | |||
| 81f0cc23bf | |||
| 8a0234093e | |||
| 88d355f2f7 | |||
| 20fd06d67c | |||
| 52f2785e67 | |||
| 2e2bd0ceec | |||
| e4c3c9a2a4 | |||
| e490c173e8 | |||
| 7e165a6dea | |||
| 49ff6e79a8 | |||
| 1160e3d067 | |||
| 91d667bcfc | |||
| b23df89cd3 | |||
| cf9737a48e | |||
| ae52115bda | |||
| 3dd9466938 | |||
| c0f7eb6727 | |||
| 76e2843ed3 | |||
| faa2004c29 | |||
| c9a59dc5ea | |||
| aaaf951990 | |||
| cc263089ca | |||
| d99b8f4c86 | |||
| f5e5441469 | |||
| 4206a4822f | |||
| 788a5bc4eb | |||
| a5a96c2bb5 | |||
| 881691e678 | |||
| 80f4d64ad4 | |||
| 7d9a641e39 | |||
| d82ccd8947 | |||
| 318b1e4b2f | |||
| 583e30170a | |||
| fe46b8ebd2 | |||
| 6a845e4f81 | |||
| 46e18b3977 | |||
| 20d146268b | |||
| 5013fc2b6c | |||
| 32a0e1d2b5 | |||
| 7ce9e7e26c | |||
| 9a6e972521 | |||
| 8c008f36c2 | |||
| eae29d4854 | |||
| 2bd53476ca | |||
| 015065f3c8 | |||
| 12862a6c76 | |||
| 9d869411e8 | |||
| 0c3c17e0f4 | |||
| 47f6eedd9c | |||
| b36adefd10 | |||
| 8cf8c0def5 | |||
| 1e6a70c60d | |||
| 9712e8c526 | |||
| 6b1f932dfc | |||
| 7882964b26 | |||
| 9653ba8d53 | |||
| ba66891539 | |||
| 4ab4a2fc81 | |||
| a6d9811595 | |||
| c94a62f5b2 | |||
| 535011072d | |||
| 718f5ce716 | |||
| 3f02119ef7 | |||
| 632b711b2a | |||
| 07faeaaa11 | |||
| 104726c5ee | |||
| e2445c0a15 | |||
| d253312139 | |||
| 9880fa0173 | |||
| 5952eee22c | |||
| 4483434711 | |||
| d276809906 | |||
| 93678ce56c | |||
| 8c4b0bde37 | |||
| 67c03daa42 | |||
| 469d1c3445 | |||
| 4268da4a1f | |||
| 7d3284fef3 | |||
| 3857cd4b5a | |||
| a04a748552 | |||
| 13ecae3829 | |||
| 1acd97d42a | |||
| 4f485d0e87 | |||
| d48348fa1c | |||
| 003dd0bdef | |||
| 6a92f6b80f | |||
| bf3760808e | |||
| ec109908fa | |||
| 3630b85632 | |||
| 45226d0b6f | |||
| fdce6e1853 | |||
| 8ffa9d7fb7 | |||
| 96ea6bc73e | |||
| 360484c9af | |||
| 47606bffcd | |||
| 7a2af0b5f2 | |||
| 8d2ae598e5 | |||
| aea99a635f | |||
| ce139c6925 | |||
| 4b19936136 | |||
| 6efb3a6e7f | |||
| 5dcf5f5616 | |||
| 451ef8356b | |||
| 3a623996d2 | |||
| 4bada73c83 | |||
| 156d0eea4b | |||
| 6e810f050e | |||
| 6bfb5c619f | |||
| bd90fc2b59 | |||
| 5800093e53 | |||
| fae6a7cd78 | |||
| 65daddfced | |||
| c303b1273d | |||
| 95915b16e5 | |||
| ddade325c4 | |||
| 8d0c04e092 | |||
| 5d62db3e73 | |||
| 46b91bb49d | |||
| c8ce0a242e | |||
| 8be2246249 | |||
| 1005aae0e9 | |||
| 47e79756d1 | |||
| 0f8012ce61 | |||
| 595421bcdd | |||
| 2c159d7ce6 | |||
| b4058ad363 | |||
| 6b5de066b7 | |||
| 517a66b0fe | |||
| 56cff98cf3 | |||
| 3168bee865 | |||
| 3d2f8c1495 | |||
| 7cd83efd97 | |||
| 10f9aeb870 | |||
| c088ac9a08 | |||
| 932f590b61 | |||
| df4188002a | |||
| 005f75a4ba | |||
| b5a74807ef | |||
| 56d7726a58 | |||
| 9db53c7ee3 | |||
| 43c511b86f | |||
| 7043b2b318 | |||
| 3c458e9187 | |||
| 3fc056af67 | |||
| 46dbd17d7b | |||
| 86395eb2d1 | |||
| 5fbc75e4bd | |||
| 3d326c9ca2 | |||
| 2a43eca91c | |||
| debf3d65ba | |||
| cfe3672f8b | |||
| 9dfe558a83 | |||
| cc312f1529 | |||
| d88de3576d | |||
| 9e1d183343 | |||
| 09665eda9f | |||
| 44d080eae9 | |||
| d5e1be8be2 | |||
| d96660e6d1 | |||
| d72f7b6299 | |||
| 1f77e00f34 | |||
| 5c222cc59f | |||
| 7ee7fea375 | |||
| 1c2b127a91 | |||
| 0e927d7294 | |||
| 0dc918880e | |||
| ac5fe3ac65 | |||
| a9d6a87317 | |||
| 650540e573 | |||
| 0ae7e1876b | |||
| 4e7501ed7f | |||
| 751ea085a6 | |||
| 59f5c16c3b | |||
| 1280037d1d | |||
| c91c2a9720 | |||
| 7c44a6ec82 | |||
| 6277b2eaa8 | |||
| 92da41d421 | |||
| f7f30854a1 | |||
| 5eea981790 | |||
| f52608e15a | |||
| fbbb0739ee | |||
| 903f0c69bc | |||
| 15ed754512 | |||
| 2ca801e2ec | |||
| fc9312f0f2 | |||
| c2b36208e7 | |||
| b1e30147ea | |||
| 4903fcd9d2 | |||
| c3de378c7d | |||
| b818f5dcb2 | |||
| 6d2cc32568 | |||
| 9bee3fbb8f | |||
| cd303ff099 | |||
| c192d9a539 | |||
| fce40ffc38 | |||
| 5bd5efafb1 | |||
| d6fffd228e | |||
| b96daf4925 | |||
| c755406963 | |||
| 296b274190 | |||
| f378661948 | |||
| 37fc7b2164 | |||
| 91dca91153 | |||
| e30a2481a2 | |||
| 70f2f1cb01 | |||
| c158f8ac3e | |||
| a46fbb3f05 | |||
| b53a5adca4 | |||
| 7d6e3dc386 | |||
| f352ca0ae0 | |||
| 68d0198f3f | |||
| 0007121340 | |||
| a6e3c42340 | |||
| c0c01573ca | |||
| badbef94e6 | |||
| 610bd48747 | |||
| 2d5657a05a | |||
| 04b47e40b4 | |||
| 5bb1fdaed3 | |||
| a5714cc85d | |||
| 83a4c03979 | |||
| e2eb219c5a | |||
| e44b08d669 | |||
| 058814a64b | |||
| 3c52ca3fef | |||
| 9ec04bff06 | |||
| fd2ba16258 | |||
| 9b34154a16 | |||
| 10dd5828ce | |||
| bf2a3f0e22 | |||
| 38146c6294 | |||
| 18d7e471ae | |||
| eccf683ef4 | |||
| d96ea77db7 | |||
| 041cbe4a8f | |||
| 381a137604 | |||
| e5ed9efdd1 | |||
| 1ec38952ed | |||
| a3531c4841 | |||
| bfc6439dc0 | |||
| 4f16e8263a | |||
| d7ec1fd304 | |||
| b2bd8f7afe | |||
| cb0452a248 | |||
| b7a5123ba9 | |||
| 29c00caf4a | |||
| 73a65d8cf9 | |||
| 419d325409 | |||
| 349c515e3e | |||
| 69166fe585 | |||
| 0eb19f1735 | |||
| 737f4f4ffa | |||
| 8a81c3543e | |||
| c0fe5f14a8 | |||
| 9fce0bd4f4 | |||
| 663784a841 | |||
| 238c0ae490 | |||
| c4a4da6945 | |||
| fb62c6d68e | |||
| 2ba32eb93c | |||
| 6e34ab6169 | |||
| 538126cfe5 | |||
| a0a6bf8377 | |||
| ba05c5307a | |||
| 234878388d | |||
| baac48f7b9 | |||
| e4815830cd | |||
| b5b48bf4c2 | |||
| 8279e66cae | |||
| 8f84f78b16 | |||
| 1c34e40289 | |||
| e9c22b895b | |||
| 8a3d46416d | |||
| ebda605497 | |||
| c4f1a7f97b | |||
| 06a69fa66b | |||
| 4daa62db97 | |||
| 0c1ad4dd86 | |||
| cb1edcf20a | |||
| 36547c24c2 | |||
| 3d4042e274 | |||
| d3d7f94c3a | |||
| b9a8777b96 | |||
| 6cf009fae3 | |||
| 735c12bca7 | |||
| 393cac35c5 | |||
| 1aeb2809fa | |||
| 7cf933ec48 | |||
| f3346fd1f1 | |||
| 579bc5492c | |||
| 71ac2fde82 | |||
| 804a434e75 | |||
| 56d80f5bdd | |||
| 71ba650cc5 | |||
| 4704554728 | |||
| e4243a2df3 | |||
| 0a63a4c9a2 | |||
| 967f5aa795 | |||
| f0429aefa4 | |||
| c3b8677910 | |||
| 268983804e | |||
| b78212c3a1 | |||
| 8420edecb5 | |||
| 7c6ddf2a6f | |||
| 2d8c815032 | |||
| 8c79bbb2b6 | |||
| 2d83c860f2 | |||
| 7023d721f4 | |||
| 0f530271f0 | |||
| ec3389633c | |||
| 5c0848797c | |||
| 6a3fc0fd97 | |||
| 545e37b7cd | |||
| 469e660da0 | |||
| 97fd05640b | |||
| 5d4b220dc7 | |||
| 13b02f51a3 | |||
| d1790d8f07 | |||
| bca419ad63 | |||
| c925c6a17a | |||
| 00ccfe967e | |||
| 3b5d145f85 | |||
| ee4592a113 | |||
| 35618b1882 | |||
| bde7ff1e5c | |||
| 10f73435bf | |||
| 21b4af444b | |||
| 4410a83631 | |||
| ca19f9e735 | |||
| aa8ae0146d | |||
| 29138a63c8 | |||
| 64a904b628 | |||
| c939a50a39 | |||
| 27f28b9f28 | |||
| 053410f43b | |||
| a74949c832 | |||
| f84aefc82d | |||
| 133b590e1c | |||
| 65909b3366 | |||
| 68800a1dfa | |||
| 4f60bd24b6 | |||
| 2f3a6189a7 | |||
| 078f730512 | |||
| 368bd80c69 | |||
| e01941644b | |||
| 0f3bd716a3 | |||
| 0030b684f3 | |||
| 6e6be4e579 | |||
| 3add582efb | |||
| bd80f16812 | |||
| ffc78b03a7 | |||
| 2f6a1f7579 | |||
| e890d5f376 | |||
| 56b49d4c9f | |||
| 7ee0e38cec | |||
| 817bfa788e | |||
| a4bd5a25c2 | |||
| 7c3b3e516a | |||
| 9e3c8b697a | |||
| 775fec489b | |||
| 790a75054c | |||
| b57421e2c9 | |||
| a7dea8b1db | |||
| 2808a95e4a | |||
| e0a350b148 | |||
| 560a447349 | |||
| 700b2ad5ca | |||
| 85d677a41a | |||
| cc200501e9 | |||
| d59cb55139 | |||
| 46052e9d1f | |||
| b36baf0fab | |||
| f2499d08ba | |||
| 651b34781b | |||
| c57a6db4ae | |||
| 78b9234865 | |||
| 6238ea1095 | |||
| de99955e93 | |||
| c45912a2e4 | |||
| 025b4a8b48 | |||
| a5802f0731 | |||
| 4f0a1460fd | |||
| 498e5b37f4 | |||
| fe0a6ad15d | |||
| 13774ba26a | |||
| d1b22114d0 | |||
| 3f2b6b2115 | |||
| bb8c0f766e | |||
| 76e490a583 | |||
| ae91e1c51f | |||
| 4aff949349 | |||
| 3dcceecab7 | |||
| 7b6f1c3e92 | |||
| b107596f84 | |||
| b11de227f3 | |||
| f353e65e61 | |||
| de34cfb7e8 | |||
| cb882b9379 | |||
| f43951a9e2 | |||
| 899e371c52 | |||
| 555e0e4375 | |||
| 8710115634 | |||
| 4056be90d9 | |||
| 77640f3a6f | |||
| 9b11212d07 | |||
| 41d76f0c3f | |||
| d2b77833fd | |||
| 9ac1a56535 | |||
| 9aca1f1e25 | |||
| e3c10e9bd3 | |||
| e84a34917a | |||
| 009328b31b | |||
| ca83aaa249 | |||
| 6cdfdf6db8 | |||
| 6628b1ee24 | |||
| 2d70d27d85 | |||
| 63d62fcc92 | |||
| b4303d0e0d | |||
| 9369447886 | |||
| dca713b240 | |||
| aa82c82ddc | |||
| 8a6dbf044e | |||
| 76d009ddbe | |||
| 6deff01b6e | |||
| e79bb117d2 | |||
| 2ea4b59b9b | |||
| 6e9465247f | |||
| 1d1fb41212 | |||
| add949b6a6 | |||
| 4731df3702 | |||
| e7d0b00e0f | |||
| 641708a5fa | |||
| f5b11a61a0 | |||
| a4cc43dadb | |||
| 334ce10018 | |||
| 3d233597f3 | |||
| a5fad89380 | |||
| d0f9c2fff5 | |||
| 038142a6d7 | |||
| 26424252f9 |
+115
-27
@@ -15,15 +15,30 @@
|
||||
#include "stdafx.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "RemoveCurveSpikes.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "AdjustLoops.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------
|
||||
static bool
|
||||
SortCrvCrvInfo( const IntCrvCrvInfo& aInfo1, const IntCrvCrvInfo& aInfo2)
|
||||
{
|
||||
// confronto i valori del primo punto della curva A
|
||||
double dU1 = aInfo1.IciA[0].dU ;
|
||||
double dU2 = aInfo2.IciA[0].dU ;
|
||||
if ( abs( dU1 - dU2) < EPS_SMALL)
|
||||
// se sono uguali confronto i valori del primo punto della curva B
|
||||
return aInfo1.IciB[0].dU > aInfo2.IciB[0].dU ;
|
||||
else
|
||||
return dU1 < dU2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
@@ -73,43 +88,100 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
return false ;
|
||||
Intervals inOk( EPS_PARAM) ;
|
||||
inOk.Set( dStart, dEnd) ;
|
||||
|
||||
// Tolgo le parti da eliminare
|
||||
|
||||
// recupero tutte le info delle autointersezioni
|
||||
IntCrvCrvInfo iccInfo ;
|
||||
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) {
|
||||
ICCIVECTOR vIccInfo( sintC.GetIntersCount()) ;
|
||||
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i)
|
||||
vIccInfo[i]= iccInfo ;
|
||||
// ordino il vettore
|
||||
sort( vIccInfo.begin(), vIccInfo.end(), SortCrvCrvInfo) ;
|
||||
|
||||
// Tolgo le parti da eliminare
|
||||
int nCross = 0 ;
|
||||
for ( int i = 0 ; i < int( vIccInfo.size()) ; ++ i) {
|
||||
|
||||
if ( i < int( vIccInfo.size()) - 1) {
|
||||
// se anche l'intersezione successiva è overlap che parte dallo stesso punto
|
||||
if ( vIccInfo[i].bOverlap && vIccInfo[i+1].bOverlap &&
|
||||
abs( vIccInfo[i].IciA[0].dU - vIccInfo[i+1].IciA[0].dU) < EPS_SMALL &&
|
||||
abs( vIccInfo[i].IciB[0].dU - vIccInfo[i+1].IciB[0].dU) < EPS_SMALL) {
|
||||
// elimino il tratto
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
// salto le intersezioni successive già considerate rimuovendo questo intervallo
|
||||
int j = i + 2 ;
|
||||
while ( j < ( int)vIccInfo.size() && vIccInfo[j].IciA[0].dU > vIccInfo[i].IciA[0].dU - EPS_SMALL &&
|
||||
vIccInfo[j].IciA[1].dU < vIccInfo[i].IciB[0].dU + EPS_SMALL) {
|
||||
j ++ ;
|
||||
}
|
||||
// aggiorno il contatore
|
||||
i = j - 1 ;
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
|
||||
// se con sovrapposizione
|
||||
if ( iccInfo.bOverlap) {
|
||||
if ( vIccInfo[i].bOverlap) {
|
||||
// se solo touch
|
||||
if ( ( iccInfo.IciA[0].nPrevTy == iccInfo.IciA[1].nNextTy ||
|
||||
iccInfo.IciA[0].nPrevTy == ICCT_SPK || iccInfo.IciA[1].nNextTy == ICCT_SPK) &&
|
||||
iccInfo.IciA[0].nPrevTy != ICCT_NULL && iccInfo.IciA[1].nNextTy != ICCT_NULL) {
|
||||
if ( ( vIccInfo[i].IciA[0].nPrevTy == vIccInfo[i].IciA[1].nNextTy ||
|
||||
vIccInfo[i].IciA[0].nPrevTy == ICCT_SPK || vIccInfo[i].IciA[1].nNextTy == ICCT_SPK) &&
|
||||
vIccInfo[i].IciA[0].nPrevTy != ICCT_NULL && vIccInfo[i].IciA[1].nNextTy != ICCT_NULL) {
|
||||
// obbligatoriamente controversi, elimino entrambi i tratti
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciA[1].dU) ;
|
||||
inOk.Subtract( iccInfo.IciB[0].dU, iccInfo.IciB[1].dU) ;
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciA[1].dU) ;
|
||||
inOk.Subtract( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciB[1].dU) ;
|
||||
}
|
||||
// altrimenti attraversamento
|
||||
else {
|
||||
// elimino la parte interna
|
||||
if ( iccInfo.bCBOverEq)
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciB[0].dU) ;
|
||||
if ( vIccInfo[i].bCBOverEq)
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
else
|
||||
inOk.Subtract( min( iccInfo.IciA[0].dU, iccInfo.IciB[1].dU), max( iccInfo.IciB[0].dU, iccInfo.IciA[1].dU)) ;
|
||||
inOk.Subtract( min( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[1].dU), max( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciA[1].dU)) ;
|
||||
}
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// se solo touch
|
||||
if ( iccInfo.IciA[0].nPrevTy == iccInfo.IciA[0].nNextTy &&
|
||||
iccInfo.IciA[0].nPrevTy != ICCT_NULL && iccInfo.IciA[0].nNextTy != ICCT_NULL) {
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciA[0].dU) ;
|
||||
inOk.Subtract( iccInfo.IciB[0].dU, iccInfo.IciB[0].dU) ;
|
||||
if ( vIccInfo[i].IciA[0].nPrevTy == vIccInfo[i].IciA[0].nNextTy &&
|
||||
vIccInfo[i].IciA[0].nPrevTy != ICCT_NULL && vIccInfo[i].IciA[0].nNextTy != ICCT_NULL) {
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciA[0].dU) ;
|
||||
inOk.Subtract( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
}
|
||||
// altrimenti attraversamento
|
||||
else {
|
||||
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciB[0].dU) ;
|
||||
double dParA = vIccInfo[i].IciA[0].dU ;
|
||||
double dParB = vIccInfo[i].IciB[0].dU ;
|
||||
if ( abs( dParA - dEnd) < EPS_SMALL)
|
||||
swap( dParA, dParB) ;
|
||||
// verifico se uno dei due intervalli dà origine ad un tratto trascurabile
|
||||
PtrOwner<ICurve> pCrv1( pMyCrv->CopyParamRange( dParA, dParB)) ;
|
||||
PtrOwner<ICurve> pCrv2( pMyCrv->CopyParamRange( dParB, dParA)) ;
|
||||
double dArea1 = 0, dArea2 = 0 ;
|
||||
if ( ! IsNull( pCrv1))
|
||||
pCrv1->GetAreaXY( dArea1) ;
|
||||
if ( ! IsNull( pCrv2))
|
||||
pCrv2->GetAreaXY( dArea2) ;
|
||||
|
||||
if ( abs( dArea1) > 1e6 * abs( dArea2)) {
|
||||
// se il tratto dParB->dParA non è significativo
|
||||
inOk.Subtract( dStart, dParA) ;
|
||||
inOk.Subtract( dParB, dEnd) ;
|
||||
}
|
||||
else if ( abs( dArea2) > 1e6 * abs( dArea1)) {
|
||||
// se il tratto dParA->dParB non è siginificativo
|
||||
inOk.Subtract( dParA, dParB) ;
|
||||
}
|
||||
else {
|
||||
// se entrambe le regioni sono significative
|
||||
if ( IsEven( nCross))
|
||||
inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
else
|
||||
inOk.Add( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
|
||||
++ nCross ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copio le parti da conservare
|
||||
double dParS, dParE ;
|
||||
@@ -179,14 +251,14 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
Point3d ptEnd2 ; pCrvCo2->GetEndPoint( ptEnd2) ;
|
||||
// se aperta, verifico se concatenabile alla principale
|
||||
if ( ! AreSamePointEpsilon( ptStart2, ptEnd2, 10 * EPS_SMALL)) {
|
||||
if ( AreSamePointEpsilon( ptEnd, ptStart2, 10 * EPS_SMALL)) {
|
||||
pCrvCo->AddCurve( pCrvCo2, true, 10 * EPS_SMALL) ;
|
||||
if ( AreSamePointEpsilon( ptEnd, ptStart2, 100 * EPS_SMALL)) {
|
||||
pCrvCo->AddCurve( pCrvCo2, true, 100 * EPS_SMALL) ;
|
||||
CrvLst.erase( iIter2) ;
|
||||
ptEnd = ptEnd2 ;
|
||||
iIter2 = next( iIter) ;
|
||||
}
|
||||
else if ( AreSamePointEpsilon( ptEnd2, ptStart, 10 * EPS_SMALL)) {
|
||||
pCrvCo->AddCurve( pCrvCo2, false, 10 * EPS_SMALL) ;
|
||||
else if ( AreSamePointEpsilon( ptEnd2, ptStart, 100 * EPS_SMALL)) {
|
||||
pCrvCo->AddCurve( pCrvCo2, false, 100 * EPS_SMALL) ;
|
||||
CrvLst.erase( iIter2) ;
|
||||
ptStart = ptStart2 ;
|
||||
iIter2 = next( iIter) ;
|
||||
@@ -201,6 +273,22 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
++ iIter ;
|
||||
}
|
||||
|
||||
// elimino le curve troppo piccole
|
||||
for ( auto iIter = CrvLst.begin() ; iIter != CrvLst.end() ;) {
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( *iIter) ;
|
||||
BBox3d b3CrvCo ;
|
||||
double dDiam ;
|
||||
if ( ! pCrvCo->GetLocalBBox( b3CrvCo) || b3CrvCo.IsEmpty() ||
|
||||
! b3CrvCo.GetDiameter( dDiam) || dDiam < 20 * EPS_SMALL) {
|
||||
delete pCrvCo ;
|
||||
pCrvCo = nullptr ;
|
||||
iIter = CrvLst.erase( iIter) ;
|
||||
}
|
||||
else {
|
||||
++ iIter ;
|
||||
}
|
||||
}
|
||||
|
||||
// riporto le curve nel riferimento originale
|
||||
if ( bNeedRef) {
|
||||
for ( auto pCrv : CrvLst)
|
||||
@@ -215,7 +303,7 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst, bool bNeedSameProp)
|
||||
{
|
||||
// elimino eventuali sovrapposizioni e accostamenti
|
||||
if ( ! MyAdjustLoops( pCurve, CrvLst))
|
||||
@@ -225,10 +313,10 @@ AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
// se curva composita
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ;
|
||||
if ( pCrvCo != nullptr) {
|
||||
// elimino eventuali Spikes e Small Z
|
||||
pCrvCo->RemoveSmallDefects( 2 * LIN_TOL_MIN, ANG_TOL_STD_DEG, true) ;
|
||||
// unisco eventuali tratti allineati
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
// elimino eventuali spikes
|
||||
RemoveCurveSpikes( pCrvCo) ;
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, bNeedSameProp) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -17,4 +17,4 @@
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst) ;
|
||||
bool AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst, bool bNeedSameProp) ;
|
||||
|
||||
@@ -63,3 +63,57 @@ AngleInSpan( double dAngDeg, double dAngRefDeg, double dAngSpanDeg)
|
||||
dAngDiffDeg < dHalfAngSpanDeg + EPS_ANG_SMALL) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AngleInRange( double dAngDeg, double dAngMinDeg, double dAngMaxDeg)
|
||||
{
|
||||
return AngleInSpan( dAngDeg, ( dAngMinDeg + dAngMaxDeg) / 2, dAngMaxDeg - dAngMinDeg) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustAngleInSpan( double& dAngDeg, double dAngRefDeg, double dAngSpanDeg)
|
||||
{
|
||||
// Verifico consistenza intervallo
|
||||
if ( dAngSpanDeg < -EPS_ANG_ZERO)
|
||||
return false ;
|
||||
// Se intervallo vero
|
||||
if ( dAngSpanDeg > EPS_ANG_SMALL) {
|
||||
double dTryDeg = dAngDeg ;
|
||||
// eseguo gli aggiustamenti
|
||||
while ( dTryDeg < dAngRefDeg - dAngSpanDeg)
|
||||
dTryDeg += ANG_FULL ;
|
||||
while ( dTryDeg > dAngRefDeg + dAngSpanDeg)
|
||||
dTryDeg -= ANG_FULL ;
|
||||
// verifico
|
||||
if ( dTryDeg >= dAngRefDeg - dAngSpanDeg && dTryDeg <= dAngRefDeg + dAngSpanDeg) {
|
||||
dAngDeg = dTryDeg ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// altrimenti un valore
|
||||
else {
|
||||
double dTryDeg = dAngDeg ;
|
||||
// eseguo gli aggiustamenti
|
||||
while ( dTryDeg < dAngRefDeg - EPS_ANG_SMALL)
|
||||
dTryDeg += ANG_FULL ;
|
||||
while ( dTryDeg > dAngRefDeg + EPS_ANG_SMALL)
|
||||
dTryDeg -= ANG_FULL ;
|
||||
// verifico
|
||||
if ( abs( dTryDeg - dAngRefDeg) < EPS_ANG_SMALL) {
|
||||
dAngDeg = dAngRefDeg ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
AdjustAngleInRange( double& dAngDeg, double dAngMinDeg, double dAngMaxDeg)
|
||||
{
|
||||
return AdjustAngleInSpan( dAngDeg, ( dAngMinDeg + dAngMaxDeg) / 2, dAngMaxDeg - dAngMinDeg) ;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgkArcCenTgCurvePnt.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkArcCenTgCurvePnt.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ CurveArc* GetArcCenTgCompoPnt( const Point3d& ptCen, const CurveComposite& crvCo
|
||||
double dSqDist = SqDist( ptNearStart, ptTg) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
pCrvArc.Set( Release( pCrvAtmp)) ;
|
||||
pCrvArc.Set( pCrvAtmp) ;
|
||||
if ( pPtTg != nullptr)
|
||||
*pPtTg = ptTg ;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgkArcPntDirTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkArcPntDirTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ GetArcPntDirTgArc( const Point3d& ptP, const Vector3d& vtDir, const CurveArc& cr
|
||||
if ( bOk1) {
|
||||
double dOffset = ( bOutSide ? crvArcL.GetRadius() : - crvArcL.GetRadius()) ;
|
||||
if ( pCrv1->GetType() == CRV_ARC)
|
||||
bOk1 = (dynamic_cast<CurveArc*>(Get(pCrv1)))->ExtendedOffset( dOffset) ;
|
||||
bOk1 = (static_cast<CurveArc*>( Get( pCrv1)))->ExtendedOffset( dOffset) ;
|
||||
else
|
||||
bOk1 = pCrv1->SimpleOffset( dOffset) ;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ GetArcPntDirTgArc( const Point3d& ptP, const Vector3d& vtDir, const CurveArc& cr
|
||||
if ( bOk2) {
|
||||
double dOffset = ( bOutSide ? - crvArcL.GetRadius() : crvArcL.GetRadius()) ;
|
||||
if ( pCrv2->GetType() == CRV_ARC)
|
||||
bOk2 = (dynamic_cast<CurveArc*>(Get(pCrv2)))->ExtendedOffset( dOffset) ;
|
||||
bOk2 = (static_cast<CurveArc*>( Get( pCrv2)))->ExtendedOffset( dOffset) ;
|
||||
else
|
||||
bOk2 = pCrv2->SimpleOffset( dOffset) ;
|
||||
}
|
||||
@@ -297,7 +297,7 @@ GetArcPntDirTgBezier( const Point3d& ptP, const Vector3d& vtDir, const CurveBezi
|
||||
return nullptr ;
|
||||
// calcolo la circonferenza tangente a questa approssimazione
|
||||
Point3d ptTg ;
|
||||
PtrOwner<ICurve> pCrv( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg))) ;
|
||||
PtrOwner<ICurve> pCrv( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return nullptr ;
|
||||
// porto il punto di tangenza della circonferenza esattamente sulla curva di Bezier
|
||||
@@ -330,14 +330,14 @@ GetArcPntDirTgCompo( const Point3d& ptP, const Vector3d& vtDir, const CurveCompo
|
||||
pCrv = crvCompo.GetNextCurve()) {
|
||||
// recupero la circonferenza tangente alla curva elementare
|
||||
Point3d ptTg ;
|
||||
PtrOwner<ICurve> pCrvTmp( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg))) ;
|
||||
PtrOwner<ICurve> pCrvTmp( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg)) ;
|
||||
if ( IsNull( pCrvTmp))
|
||||
continue ;
|
||||
// verifico se è la più vicina al punto desiderato
|
||||
double dSqDist = SqDist( ptNear, ptTg) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
pCrvNew.Set( Release( pCrvTmp)) ;
|
||||
pCrvNew.Set( pCrvTmp) ;
|
||||
if ( pPtTg != nullptr)
|
||||
*pPtTg = ptTg ;
|
||||
}
|
||||
|
||||
+86
-36
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2015
|
||||
// EgalTech 2014-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ArcSpecial.cpp Data : 15.03.15 Versione : 1.6c2
|
||||
// File : ArcSpecial.cpp Data : 04.08.23 Versione : 2.5h1
|
||||
// Contenuto : Implementazione funzioni per calcoli speciali archi.
|
||||
//
|
||||
//
|
||||
@@ -14,13 +14,12 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Come la CurveArc::Set2PD, ma se raggio infinito restituisce una retta
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -28,15 +27,13 @@ ICurve*
|
||||
GetArc2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStartDeg)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
ICurveArc* pArc = CreateCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con l'arco
|
||||
PtrOwner<ICurve> pCrv( pArc) ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set2PD( ptStart, ptEnd, dDirStartDeg))
|
||||
return Release( pCrv) ;
|
||||
return Release( pArc) ;
|
||||
|
||||
// calcolo arco non riuscito, verifico se retta va bene
|
||||
Vector3d vtDiff = ptEnd - ptStart ;
|
||||
@@ -45,14 +42,12 @@ GetArc2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStartDeg)
|
||||
// verifico se i punti sono allineati con la direzione e nel giusto verso
|
||||
if ( abs( CrossXY( vtDiff, vtDir)) < EPS_SMALL && ScalarXY( vtDiff, vtDir) > EPS_SMALL) {
|
||||
// creo l'oggetto retta
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con la retta
|
||||
pCrv.Set( pLine) ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pCrv) ;
|
||||
return Release( pLine) ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
@@ -65,34 +60,59 @@ ICurve*
|
||||
GetArc2PVN( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDirS, const Vector3d& vtN)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
ICurveArc* pArc = CreateCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con l'arco
|
||||
PtrOwner<ICurve> pCrv( pArc) ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set2PVN( ptStart, ptEnd, vtDirS, vtN))
|
||||
return Release( pCrv) ;
|
||||
return Release( pArc) ;
|
||||
|
||||
// calcolo arco non riuscito, verifico se retta va bene
|
||||
Vector3d vtDiff = ptEnd - ptStart ;
|
||||
// verifico se i punti sono allineati con la direzione e nel giusto verso nel piano perpendicolare a vtN
|
||||
if ( abs( ( vtDiff ^ vtDirS) * vtN) < EPS_SMALL && vtDiff * vtDirS > EPS_SMALL) {
|
||||
// creo l'oggetto retta
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con la retta
|
||||
pCrv.Set( pLine) ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pCrv) ;
|
||||
return Release( pLine) ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Come la CurveArc::Set2PNB, ma se bulge nullo restituisce una retta
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
GetArc2PNB( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN, double dBulge)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
return nullptr ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set2PNB( ptStart, ptEnd, vtN, dBulge))
|
||||
return Release( pArc) ;
|
||||
|
||||
// calcolo arco non riuscito, verifico se retta va bene
|
||||
if ( abs( dBulge) > EPS_SMALL)
|
||||
return nullptr ;
|
||||
// creo l'oggetto retta
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
return nullptr ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pLine) ;
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Come la CurveArc::Set3P, ma se raggio infinito restituisce una retta
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -100,17 +120,15 @@ ICurve*
|
||||
GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd, bool bCirc)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
ICurveArc* pArc = CreateCurveArc() ;
|
||||
if ( pArc == nullptr)
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con l'arco
|
||||
PtrOwner<ICurve> pCrv( pArc) ;
|
||||
|
||||
// calcolo l'arco, se ok lo restituisco ed esco
|
||||
if ( pArc->Set3P( ptStart, ptOther, ptEnd, bCirc))
|
||||
return Release( pCrv) ;
|
||||
return Release( pArc) ;
|
||||
|
||||
// se era richiesta una circonferenza, errore
|
||||
// se era richiesta una circonferenza, errore perchè punti allineati
|
||||
if ( bCirc)
|
||||
return nullptr ;
|
||||
|
||||
@@ -118,15 +136,47 @@ GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd,
|
||||
// verifico se i punti sono allineati nel giusto verso
|
||||
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO) {
|
||||
// creo l'oggetto retta
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
if ( pLine == nullptr)
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
return nullptr ;
|
||||
// inizializzo il puntatore a curva con la retta
|
||||
pCrv.Set( pLine) ;
|
||||
// calcolo retta, se ok la restituisco ed esco
|
||||
if ( pLine->Set( ptStart, ptEnd))
|
||||
return Release( pCrv) ;
|
||||
return Release( pLine) ;
|
||||
}
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Come la CurveArc::SetC2PN, ma garantisce il passaggio per gli estremi e minimizza errore sul centro
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveArc*
|
||||
GetArc2PCN( const Point3d& ptStart, const Point3d& ptEnd, const Point3d& ptNearCen, const Vector3d& vtN)
|
||||
{
|
||||
// creo l'oggetto arco
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc))
|
||||
return nullptr ;
|
||||
|
||||
// vettori dal centro a inizio e fine
|
||||
Vector3d vtStart = ptStart - ptNearCen ;
|
||||
Vector3d vtEnd = ptEnd - ptNearCen ;
|
||||
|
||||
// determino il raggio medio
|
||||
double dStartRad = OrthoCompo( vtStart, vtN).Len() ;
|
||||
double dEndRad = OrthoCompo( vtEnd, vtN).Len() ;
|
||||
double dRad = ( dStartRad + dEndRad) / 2 ;
|
||||
if ( dRad < EPS_SMALL)
|
||||
return nullptr ;
|
||||
|
||||
// determino un valore approssimato dell'angolo al centro
|
||||
double dAngDeg ; bool bDet ;
|
||||
if ( ! vtStart.GetRotation( vtEnd, vtN, dAngDeg, bDet) || ! bDet || abs( dAngDeg) < EPS_ANG_ZERO)
|
||||
return nullptr ;
|
||||
|
||||
// calcolo l'arco antiorario per i due punti con il raggio medio
|
||||
if ( pArc->Set2PNRS( ptStart, ptEnd, vtN, dRad, ( dAngDeg > 0)))
|
||||
return Release( pArc) ;
|
||||
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
+43
-31
@@ -18,7 +18,7 @@
|
||||
#include "NgeReader.h"
|
||||
#include "GeomDB.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -81,8 +81,7 @@ Attribs::Dump( const GeomDB& GDB, string& sOut, bool bMM, const char* szNewLine)
|
||||
}
|
||||
sOut += szNewLine ;
|
||||
// eventuali nome e stringhe informative
|
||||
STRLIST::const_iterator iIter ;
|
||||
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter)
|
||||
for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter)
|
||||
sOut += *iIter + szNewLine ;
|
||||
|
||||
return true ;
|
||||
@@ -101,7 +100,7 @@ Attribs::Save( NgeWriter& ngeOut) const
|
||||
// modo
|
||||
if ( ! ngeOut.WriteUchar( m_Data[MODE], ","))
|
||||
return false ;
|
||||
// stato (se SEL è convertito in ON)
|
||||
// stato (se SEL è convertito in ON)
|
||||
int nStat = (( m_Data[STATUS] > GDB_ST_ON) ? GDB_ST_ON : m_Data[STATUS]) ;
|
||||
if ( ! ngeOut.WriteUchar( nStat, ","))
|
||||
return false ;
|
||||
@@ -118,8 +117,7 @@ Attribs::Save( NgeWriter& ngeOut) const
|
||||
if ( ! ngeOut.WriteInt( int( m_slInfo.size()), ";", true))
|
||||
return false ;
|
||||
// stringhe di info
|
||||
STRLIST::const_iterator iIter ;
|
||||
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
|
||||
for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter) {
|
||||
if ( ! ngeOut.WriteString( *iIter, nullptr, true))
|
||||
return false ;
|
||||
}
|
||||
@@ -141,7 +139,7 @@ Attribs::Load( NgeReader& ngeIn)
|
||||
if ( ! ngeIn.ReadUchar( ucMode, ","))
|
||||
return false ;
|
||||
m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
|
||||
// stato (se SEL è convertito in ON)
|
||||
// stato (se SEL è convertito in ON)
|
||||
unsigned char ucStat ;
|
||||
if ( ! ngeIn.ReadUchar( ucStat, ","))
|
||||
return false ;
|
||||
@@ -177,7 +175,7 @@ Attribs::Load( NgeReader& ngeIn)
|
||||
bool
|
||||
Attribs::DataFromString( const string& sParam)
|
||||
{
|
||||
// il primo parametro è diviso in 4 parti
|
||||
// il primo parametro è diviso in 4 parti
|
||||
STRVECTOR vsParams ;
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
// 4 parti
|
||||
@@ -212,13 +210,12 @@ bool
|
||||
Attribs::SetName( const string& sName)
|
||||
{
|
||||
// se nome non valido, esco con errore
|
||||
if ( ! IsValidVal( sName))
|
||||
if ( sName.empty() || ! IsValidVal( sName))
|
||||
return false ;
|
||||
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME)) {
|
||||
// può essere solo la prima stringa
|
||||
auto iIter = m_slInfo.begin() ;
|
||||
if ( iIter != m_slInfo.end() && FindKey( *iIter, NAME)) {
|
||||
*iIter = NAME + EQUAL + sName ;
|
||||
return true ;
|
||||
}
|
||||
@@ -237,10 +234,9 @@ Attribs::SetName( const string& sName)
|
||||
bool
|
||||
Attribs::GetName( string& sName) const
|
||||
{
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::const_iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME)) {
|
||||
// può essere solo la prima stringa
|
||||
const auto iIter = m_slInfo.cbegin() ;
|
||||
if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
|
||||
sName = iIter->substr( NAME.length() + 1) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -252,23 +248,18 @@ Attribs::GetName( string& sName) const
|
||||
bool
|
||||
Attribs::ExistsName( void) const
|
||||
{
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::const_iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME))
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
// può essere solo la prima stringa
|
||||
const auto iIter = m_slInfo.cbegin() ;
|
||||
return ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::RemoveName( void)
|
||||
{
|
||||
// può essere solo la prima stringa
|
||||
STRLIST::const_iterator iIter ;
|
||||
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
|
||||
FindKey( *iIter, NAME)) {
|
||||
// può essere solo la prima stringa
|
||||
const auto iIter = m_slInfo.cbegin() ;
|
||||
if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
|
||||
m_slInfo.pop_front() ;
|
||||
return true ;
|
||||
}
|
||||
@@ -282,14 +273,14 @@ bool
|
||||
Attribs::SetInfo( const string& sKey, const string& sVal)
|
||||
{
|
||||
// se chiave o valore non validi, esco con errore
|
||||
if ( ! IsValidKey( sKey) || ! IsValidVal( sVal))
|
||||
if ( ! IsValidKey( sKey) || sVal.empty() || ! IsValidVal( sVal))
|
||||
return false ;
|
||||
|
||||
// se è il nome
|
||||
// se è il nome
|
||||
if ( sKey == NAME)
|
||||
return SetName( sVal) ;
|
||||
|
||||
// se esiste già una stringa con quella chiave la sostituisco
|
||||
// se esiste già una stringa con quella chiave la sostituisco
|
||||
for ( auto iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
|
||||
if ( FindKey( *iIter, sKey)) {
|
||||
*iIter = sKey + EQUAL + sVal ;
|
||||
@@ -356,6 +347,27 @@ Attribs::RemoveInfo( const string& sKey)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
// riservo spazio opportuno per il vettore delle stringhe
|
||||
vsInfo.clear() ;
|
||||
|
||||
// se non ci sono info esco
|
||||
if ( m_slInfo.empty())
|
||||
return true ;
|
||||
|
||||
vsInfo.reserve( m_slInfo.size()) ;
|
||||
// recupero tutte le info tranne il nome (se presente sempre al primo posto)
|
||||
auto iIter = m_slInfo.cbegin() ;
|
||||
if ( FindKey( *iIter, NAME))
|
||||
++ iIter ;
|
||||
for ( ; iIter != m_slInfo.cend() ; ++ iIter)
|
||||
vsInfo.emplace_back( *iIter) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Attribs::CopyAllInfoFrom( const Attribs& attrSou)
|
||||
|
||||
@@ -89,6 +89,7 @@ class Attribs
|
||||
bool GetInfo( const std::string& sKey, std::string& sVal) const ;
|
||||
bool ExistsInfo( const std::string& sKey) const ;
|
||||
bool RemoveInfo( const std::string& sKey) ;
|
||||
bool GetAllInfo( STRVECTOR& vsInfo) const ;
|
||||
bool CopyAllInfoFrom( const Attribs& attrSou) ;
|
||||
|
||||
private :
|
||||
@@ -100,7 +101,7 @@ class Attribs
|
||||
private :
|
||||
unsigned char m_Data[DIM] ;
|
||||
unsigned char m_OldData[DIM] ;
|
||||
int m_Material ;
|
||||
Color m_Color ;
|
||||
STRLIST m_slInfo ;
|
||||
int m_Material ;
|
||||
Color m_Color ;
|
||||
STRLIST m_slInfo ;
|
||||
} ;
|
||||
+134
-34
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
// EgalTech 2014-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : BBox3d.cpp Data : 14.01.14 Versione : 1.5a3
|
||||
// File : BBox3d.cpp Data : 17.08.22 Versione : 2.4h1
|
||||
// Contenuto : Implementazione della classe axis aligned bounding box BBox3d.
|
||||
//
|
||||
//
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "\EgtDev\Include\EGkBBox3d.h"
|
||||
#include "\EgtDev\Include\EGkFrame3d.h"
|
||||
#include "/EgtDev/Include/EGkBBox3d.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
@@ -53,7 +53,8 @@ BBox3d::Set( double dX1, double dY1, double dZ1, double dX2, double dY2, double
|
||||
bool
|
||||
BBox3d::IsValid( void) const
|
||||
{
|
||||
return ( m_ptMin.x < ( m_ptMax.x + EPS_SMALL) &&
|
||||
return ( m_ptMin.IsValid() && m_ptMax.IsValid() &&
|
||||
m_ptMin.x < ( m_ptMax.x + EPS_SMALL) &&
|
||||
m_ptMin.y < ( m_ptMax.y + EPS_SMALL) &&
|
||||
m_ptMin.z < ( m_ptMax.z + EPS_SMALL)) ;
|
||||
}
|
||||
@@ -210,6 +211,33 @@ BBox3d::GetMinDim( Point3d& ptMin, double& dDimX, double& dDimY, double& dDimZ)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
BBox3d::GetDimX( void) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return 0 ;
|
||||
return ( m_ptMax.x - m_ptMin.x) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
BBox3d::GetDimY( void) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return 0 ;
|
||||
return ( m_ptMax.y - m_ptMin.y) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
BBox3d::GetDimZ( void) const
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return 0 ;
|
||||
return ( m_ptMax.z - m_ptMin.z) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const
|
||||
@@ -420,69 +448,141 @@ BBox3d::EnclosesXY( const BBox3d& b3Box) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::Overlaps( const BBox3d& b3B) const
|
||||
BBox3d::Overlaps( const BBox3d& b3Box) const
|
||||
{
|
||||
if ( m_ptMax.x < b3B.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3B.m_ptMax.x + EPS_SMALL)
|
||||
if ( m_ptMax.x < b3Box.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3Box.m_ptMax.x + EPS_SMALL)
|
||||
return false ;
|
||||
if ( m_ptMax.y < b3B.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3B.m_ptMax.y + EPS_SMALL)
|
||||
if ( m_ptMax.y < b3Box.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3Box.m_ptMax.y + EPS_SMALL)
|
||||
return false ;
|
||||
if ( m_ptMax.z < b3B.m_ptMin.z - EPS_SMALL || m_ptMin.z > b3B.m_ptMax.z + EPS_SMALL)
|
||||
if ( m_ptMax.z < b3Box.m_ptMin.z - EPS_SMALL || m_ptMin.z > b3Box.m_ptMax.z + EPS_SMALL)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::OverlapsXY( const BBox3d& b3B) const
|
||||
BBox3d::OverlapsXY( const BBox3d& b3Box) const
|
||||
{
|
||||
if ( m_ptMax.x < b3B.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3B.m_ptMax.x + EPS_SMALL)
|
||||
if ( m_ptMax.x < b3Box.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3Box.m_ptMax.x + EPS_SMALL)
|
||||
return false ;
|
||||
if ( m_ptMax.y < b3B.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3B.m_ptMax.y + EPS_SMALL)
|
||||
if ( m_ptMax.y < b3Box.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3Box.m_ptMax.y + EPS_SMALL)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::FindIntersection( const BBox3d& b3B, BBox3d& b3Int) const
|
||||
inline bool
|
||||
TestSeparatingAxis( const Vector3d& vtAx, const Vector3d& vtDiff, const Vector3d& vtHe,
|
||||
const Vector3d& vtHe2X, const Vector3d& vtHe2Y, const Vector3d& vtHe2Z)
|
||||
{
|
||||
if ( ! IsValid() || ! b3B.IsValid())
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
double dLen = ( vtAx.IsNormalized() ? 1 : vtAx.Len()) ;
|
||||
return ( abs( vtDiff * vtAx) >
|
||||
abs( vtHe.x * vtAx.x) + abs( vtHe.y * vtAx.y) + abs( vtHe.z * vtAx.z) +
|
||||
abs( vtHe2X * vtAx) + abs( vtHe2Y * vtAx) + abs( vtHe2Z * vtAx) + EPS_SMALL * dLen) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::Overlaps( const Frame3d& frBox, const BBox3d& b3Box) const
|
||||
{
|
||||
// Verifico validità di entrambi i box
|
||||
if ( ! IsValid() || ! b3Box.IsValid())
|
||||
return false ;
|
||||
|
||||
// Centro e semiampiezza del box
|
||||
Point3d ptCen = ( m_ptMin + m_ptMax) / 2 ;
|
||||
Vector3d vtHe = ( m_ptMax - m_ptMin) / 2 ;
|
||||
// Centro e semiampiezza dell'altro box
|
||||
Point3d ptCen2 = GetToGlob( ( b3Box.m_ptMin + b3Box.m_ptMax) / 2, frBox) ;
|
||||
Vector3d vtHe2X = GetToGlob( Vector3d( ( b3Box.GetDimX()) / 2, 0, 0), frBox) ;
|
||||
Vector3d vtHe2Y = GetToGlob( Vector3d( 0, ( b3Box.GetDimY()) / 2, 0), frBox) ;
|
||||
Vector3d vtHe2Z = GetToGlob( Vector3d( 0, 0, ( b3Box.GetDimZ()) / 2), frBox) ;
|
||||
// Vettore tra i due centri
|
||||
Vector3d vtDiff = ptCen2 - ptCen ;
|
||||
|
||||
// Verifico separazione sulle normali ai piani principali del riferimento globale
|
||||
if ( TestSeparatingAxis( X_AX, vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Y_AX, vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Z_AX, vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
|
||||
// Verifico separazione sulle normali ai piani principali del secondo riferimento
|
||||
if ( TestSeparatingAxis( frBox.VersX(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( frBox.VersY(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( frBox.VersZ(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
|
||||
// Verifico separazione sulle altre normali ottenute come prodotto vettoriali di quelle precedenti
|
||||
if ( TestSeparatingAxis( X_AX ^ frBox.VersX(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( X_AX ^ frBox.VersY(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( X_AX ^ frBox.VersZ(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Y_AX ^ frBox.VersX(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Y_AX ^ frBox.VersY(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Y_AX ^ frBox.VersZ(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Z_AX ^ frBox.VersX(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Z_AX ^ frBox.VersY(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
if ( TestSeparatingAxis( Z_AX ^ frBox.VersZ(), vtDiff, vtHe, vtHe2X, vtHe2Y, vtHe2Z))
|
||||
return false ;
|
||||
|
||||
// Si sovrappongono
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::FindIntersection( const BBox3d& b3Box, BBox3d& b3Int) const
|
||||
{
|
||||
if ( ! IsValid() || ! b3Box.IsValid())
|
||||
return false ;
|
||||
// verifico direttamente la sovrapposizione
|
||||
if ( m_ptMax.x < b3B.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3B.m_ptMax.x + EPS_SMALL)
|
||||
if ( m_ptMax.x < b3Box.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3Box.m_ptMax.x + EPS_SMALL)
|
||||
return false ;
|
||||
if ( m_ptMax.y < b3B.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3B.m_ptMax.y + EPS_SMALL)
|
||||
if ( m_ptMax.y < b3Box.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3Box.m_ptMax.y + EPS_SMALL)
|
||||
return false ;
|
||||
if ( m_ptMax.z < b3B.m_ptMin.z - EPS_SMALL || m_ptMin.z > b3B.m_ptMax.z + EPS_SMALL)
|
||||
if ( m_ptMax.z < b3Box.m_ptMin.z - EPS_SMALL || m_ptMin.z > b3Box.m_ptMax.z + EPS_SMALL)
|
||||
return false ;
|
||||
// calcolo il box intersezione
|
||||
b3Int.m_ptMin.x = (( m_ptMin.x >= b3B.m_ptMin.x) ? m_ptMin.x : b3B.m_ptMin.x) ;
|
||||
b3Int.m_ptMin.y = (( m_ptMin.y >= b3B.m_ptMin.y) ? m_ptMin.y : b3B.m_ptMin.y) ;
|
||||
b3Int.m_ptMin.z = (( m_ptMin.z >= b3B.m_ptMin.z) ? m_ptMin.z : b3B.m_ptMin.z) ;
|
||||
b3Int.m_ptMax.x = (( m_ptMax.x <= b3B.m_ptMax.x) ? m_ptMax.x : b3B.m_ptMax.x) ;
|
||||
b3Int.m_ptMax.y = (( m_ptMax.y <= b3B.m_ptMax.y) ? m_ptMax.y : b3B.m_ptMax.y) ;
|
||||
b3Int.m_ptMax.z = (( m_ptMax.z <= b3B.m_ptMax.z) ? m_ptMax.z : b3B.m_ptMax.z) ;
|
||||
b3Int.m_ptMin.x = (( m_ptMin.x >= b3Box.m_ptMin.x) ? m_ptMin.x : b3Box.m_ptMin.x) ;
|
||||
b3Int.m_ptMin.y = (( m_ptMin.y >= b3Box.m_ptMin.y) ? m_ptMin.y : b3Box.m_ptMin.y) ;
|
||||
b3Int.m_ptMin.z = (( m_ptMin.z >= b3Box.m_ptMin.z) ? m_ptMin.z : b3Box.m_ptMin.z) ;
|
||||
b3Int.m_ptMax.x = (( m_ptMax.x <= b3Box.m_ptMax.x) ? m_ptMax.x : b3Box.m_ptMax.x) ;
|
||||
b3Int.m_ptMax.y = (( m_ptMax.y <= b3Box.m_ptMax.y) ? m_ptMax.y : b3Box.m_ptMax.y) ;
|
||||
b3Int.m_ptMax.z = (( m_ptMax.z <= b3Box.m_ptMax.z) ? m_ptMax.z : b3Box.m_ptMax.z) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
BBox3d::FindIntersectionXY( const BBox3d& b3B, BBox3d& b3Int) const
|
||||
BBox3d::FindIntersectionXY( const BBox3d& b3Box, BBox3d& b3Int) const
|
||||
{
|
||||
if ( ! IsValid() || ! b3B.IsValid())
|
||||
if ( ! IsValid() || ! b3Box.IsValid())
|
||||
return false ;
|
||||
// verifico direttamente la sovrapposizione
|
||||
if ( m_ptMax.x < b3B.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3B.m_ptMax.x + EPS_SMALL)
|
||||
if ( m_ptMax.x < b3Box.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3Box.m_ptMax.x + EPS_SMALL)
|
||||
return false ;
|
||||
if ( m_ptMax.y < b3B.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3B.m_ptMax.y + EPS_SMALL)
|
||||
if ( m_ptMax.y < b3Box.m_ptMin.y - EPS_SMALL || m_ptMin.y > b3Box.m_ptMax.y + EPS_SMALL)
|
||||
return false ;
|
||||
// calcolo il box intersezione
|
||||
b3Int.m_ptMin.x = (( m_ptMin.x >= b3B.m_ptMin.x) ? m_ptMin.x : b3B.m_ptMin.x) ;
|
||||
b3Int.m_ptMin.y = (( m_ptMin.y >= b3B.m_ptMin.y) ? m_ptMin.y : b3B.m_ptMin.y) ;
|
||||
b3Int.m_ptMin.z = 0.5 * ( m_ptMin.z + b3B.m_ptMin.z) ;
|
||||
b3Int.m_ptMax.x = (( m_ptMax.x <= b3B.m_ptMax.x) ? m_ptMax.x : b3B.m_ptMax.x) ;
|
||||
b3Int.m_ptMax.y = (( m_ptMax.y <= b3B.m_ptMax.y) ? m_ptMax.y : b3B.m_ptMax.y) ;
|
||||
b3Int.m_ptMax.z = 0.5 * ( m_ptMax.z + b3B.m_ptMax.z) ;
|
||||
b3Int.m_ptMin.x = (( m_ptMin.x >= b3Box.m_ptMin.x) ? m_ptMin.x : b3Box.m_ptMin.x) ;
|
||||
b3Int.m_ptMin.y = (( m_ptMin.y >= b3Box.m_ptMin.y) ? m_ptMin.y : b3Box.m_ptMin.y) ;
|
||||
b3Int.m_ptMin.z = 0.5 * ( m_ptMin.z + b3Box.m_ptMin.z) ;
|
||||
b3Int.m_ptMax.x = (( m_ptMax.x <= b3Box.m_ptMax.x) ? m_ptMax.x : b3Box.m_ptMax.x) ;
|
||||
b3Int.m_ptMax.y = (( m_ptMax.y <= b3Box.m_ptMax.y) ? m_ptMax.y : b3Box.m_ptMax.y) ;
|
||||
b3Int.m_ptMax.z = 0.5 * ( m_ptMax.z + b3Box.m_ptMax.z) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+30
-18
@@ -14,12 +14,13 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "BiArcs.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -49,7 +50,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
||||
return nullptr ;
|
||||
|
||||
// preparo la curva composita per i biarchi
|
||||
PtrOwner<ICurveComposite> pBiArc( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pBiArc( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pBiArc))
|
||||
return nullptr ;
|
||||
|
||||
@@ -94,10 +95,10 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
||||
pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, 0.5)) ;
|
||||
}
|
||||
else {
|
||||
CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
|
||||
const CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
double dU = - 1 ;
|
||||
double dU = -1 ;
|
||||
double dRad = pArc->GetRadius() ;
|
||||
double dSqRad = dRad * dRad ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
@@ -121,9 +122,11 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
||||
}
|
||||
}
|
||||
}
|
||||
// elimino casi vicino agli estremi, danno solo problemi
|
||||
if ( dU < 0.1 || dU > 0.9)
|
||||
// non c'è intersezione, assegno valore medio
|
||||
if ( dU < -0.5)
|
||||
dU = 0.5 ;
|
||||
// elimino casi vicino agli estremi, danno solo problemi
|
||||
dU = Clamp( dU, 0.1, 0.9) ;
|
||||
pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, dU)) ;
|
||||
}
|
||||
|
||||
@@ -132,15 +135,24 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
||||
return nullptr ;
|
||||
|
||||
// determino la massima distanza tra la curva e il biarco
|
||||
Point3d ptP ;
|
||||
double dSqDist = 0 ;
|
||||
for ( bool bPnt = PL.GetFirstPoint( ptP) ;
|
||||
bPnt ;
|
||||
bPnt = PL.GetNextPoint( ptP)) {
|
||||
DistPointCurve dstPC( ptP, *pBiArc) ;
|
||||
double dSqDistPC ;
|
||||
if ( dstPC.GetSqDist( dSqDistPC) && dSqDistPC > dSqDist)
|
||||
dSqDist = dSqDistPC ;
|
||||
const double STEP = 10 ;
|
||||
Point3d ptCurr ;
|
||||
bool bPnt = PL.GetFirstPoint( ptCurr) ;
|
||||
Point3d ptPrev = ptCurr ;
|
||||
while ( bPnt) {
|
||||
double dLen = Dist( ptCurr, ptPrev) ;
|
||||
int nStep = ( dLen < STEP ? 2 : 1) * int( dLen / STEP) + 1 ;
|
||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||
double dCoeff = double( i) / nStep ;
|
||||
Point3d ptP = Media( ptPrev, ptCurr, dCoeff) ;
|
||||
DistPointCurve dstPC( ptP, *pBiArc) ;
|
||||
double dSqDistPC ;
|
||||
if ( dstPC.GetSqDist( dSqDistPC) && dSqDistPC > dSqDist)
|
||||
dSqDist = dSqDistPC ;
|
||||
}
|
||||
ptPrev = ptCurr ;
|
||||
bPnt = PL.GetNextPoint( ptCurr) ;
|
||||
}
|
||||
dDist = sqrt( dSqDist) ;
|
||||
|
||||
@@ -160,7 +172,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
|
||||
|
||||
// se rotazione nulla, allora segmento di retta tra i due punti
|
||||
if ( abs( dAngDeg) < EPS_ANG_SMALL) {
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pLine) || ! pLine->Set( ptP0, ptP1))
|
||||
return nullptr ;
|
||||
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1
|
||||
@@ -182,7 +194,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
|
||||
Vector3d vtStart = ptP0 - ptCen ;
|
||||
double dRad, dAngStart ;
|
||||
vtStart.ToSpherical( &dRad, nullptr, &dAngStart) ;
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pArc) || ! pArc->SetXY( ptCen, dRad, dAngStart, dAngDeg, ( ptP1.z - ptP0.z)))
|
||||
return nullptr ;
|
||||
double dDirStartDeg = dAngStart + ( dAngDeg > 0 ? ANG_RIGHT : - ANG_RIGHT) ;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EgkBiArcs.h"
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
|
||||
|
||||
+15
-8
@@ -1,8 +1,8 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2018-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CAToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
|
||||
// Contenuto : Implementazione della classe CAToolSurfTm.
|
||||
// File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
|
||||
// Contenuto : Implementazione della classe CAvToolSurfTm.
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -14,8 +14,8 @@
|
||||
#include "stdafx.h"
|
||||
#include "CAvToolTriangle.h"
|
||||
#include "CAvToolSurfTm.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include <thread>
|
||||
#include <future>
|
||||
@@ -104,6 +104,9 @@ CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Ve
|
||||
// Se utensile non definito, errore
|
||||
if ( m_Tool.GetType() == Tool::UNDEF)
|
||||
return false ;
|
||||
// Se direzioni non definite, errore
|
||||
if ( vtDir.IsSmall() || vtMove.IsSmall())
|
||||
return false ;
|
||||
// Imposto il riferimento di movimento
|
||||
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
||||
m_frMove.Set( ORIG, vtMove, vtDir) ;
|
||||
@@ -122,6 +125,9 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
||||
// Se utensile non definito, errore
|
||||
if ( m_Tool.GetType() == Tool::UNDEF)
|
||||
return false ;
|
||||
// Se direzioni non definite, errore
|
||||
if ( vtDir.IsSmall() || vtMove.IsSmall())
|
||||
return false ;
|
||||
// Se lista vuota, non devo fare alcunché
|
||||
if ( lPntM.empty())
|
||||
return true ;
|
||||
@@ -206,8 +212,9 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
|
||||
while ( itPntMCurr != lPntM.end()) {
|
||||
// verifico il punto
|
||||
ptCurr = itPntMCurr->first ;
|
||||
itPntMCurr->second = MyTestPositionHG( itPntMCurr->first, vtDir) ;
|
||||
if ( itPntMCurr->second < - EPS_SMALL)
|
||||
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir) ;
|
||||
itPntMCurr->second = - dMove ;
|
||||
if ( dMove < - EPS_SMALL)
|
||||
return false ;
|
||||
// se esiste il punto precedente devo verificare il medio
|
||||
if ( itPntMPrev != lPntM.end()) {
|
||||
@@ -301,11 +308,11 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir)
|
||||
Vector3d vtDirL = vtDir ; vtDirL.ToLoc( m_frMove) ;
|
||||
b3Tool.Add( ptTL) ;
|
||||
b3Tool.Add( ptTL - vtDirL * m_Tool.GetHeigth()) ;
|
||||
if ( vtDirL.IsXplus() || vtDirL.IsXminus())
|
||||
if ( vtDirL.IsX())
|
||||
b3Tool.Expand( 0, m_Tool.GetRadius(), m_Tool.GetRadius()) ;
|
||||
else if ( vtDirL.IsYplus() || vtDirL.IsYminus())
|
||||
else if ( vtDirL.IsY())
|
||||
b3Tool.Expand( m_Tool.GetRadius(), 0, m_Tool.GetRadius()) ;
|
||||
else if ( vtDirL.IsZplus() || vtDirL.IsZminus())
|
||||
else if ( vtDirL.IsZ())
|
||||
b3Tool.Expand( m_Tool.GetRadius(), m_Tool.GetRadius(), 0) ;
|
||||
else {
|
||||
double dExpandX = m_Tool.GetRadius() * sqrt( 1 - vtDirL.x * vtDirL.x) ;
|
||||
|
||||
+14
-12
@@ -17,8 +17,8 @@
|
||||
#include "CAvToolTriangle.h"
|
||||
#include "IntersLineSurfStd.h"
|
||||
#include "IntersLineTria.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "CDeUtility.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
@@ -146,18 +146,20 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
const Triangle3d& trTria, const Vector3d& vtMove)
|
||||
{
|
||||
// Non ha senso che il movimento sia in direzione "opposta" a quella dell'asse utensile
|
||||
if ( vtMove * vtToolAx < - EPS_ZERO)
|
||||
if ( vtMove * vtToolAx < - 10 * EPS_ZERO)
|
||||
return -1. ;
|
||||
// Se avvicinamento non devo fare nulla
|
||||
if ( vtMove * trTria.GetN() < - EPS_ZERO)
|
||||
return 0. ;
|
||||
return 0. ;
|
||||
// Tolleranza su dischi (parti piatte perpendicolari all'asse utensile)
|
||||
double dEpsilon = ( vtMove * vtToolAx > 0.5 ? 0 : EPS_SMALL) ;
|
||||
// se utensile cilindrico
|
||||
if ( tlTool.GetType() == Tool::CYLMILL) {
|
||||
// parametri geometrici
|
||||
double dHeigth = tlTool.GetHeigth() ;
|
||||
double dRadius = tlTool.GetRadius() ;
|
||||
// prima determino l'allontanamento del disco inferiore
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( dHeigth - EPS_SMALL) * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( dHeigth - dEpsilon) * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return dDist ;
|
||||
// poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il disco)
|
||||
@@ -165,7 +167,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
if ( dDist2 < - EPS_SMALL)
|
||||
return dDist2 ;
|
||||
// verifico quello del disco sopra
|
||||
double dDist3 = CAvDiskTriangle( ptToolOrig - EPS_SMALL * vtToolAx + ( dDist + dDist2) * vtMove, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
double dDist3 = CAvDiskTriangle( ptToolOrig - dEpsilon * vtToolAx + ( dDist + dDist2) * vtMove, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
if ( dDist3 < - EPS_SMALL)
|
||||
return dDist3 ;
|
||||
return ( dDist + dDist2 + dDist3) ;
|
||||
@@ -189,7 +191,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
return dDist2 ;
|
||||
// verifico quello del disco sopra
|
||||
Point3d ptDiskUpOrig = ptCylOrig + dDist2 * vtMove ;
|
||||
double dDist3 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
double dDist3 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
if ( dDist3 < - EPS_SMALL)
|
||||
return dDist3 ;
|
||||
return ( dDist + dDist2 + dDist3) ;
|
||||
@@ -199,7 +201,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
// parametri geometrici
|
||||
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
|
||||
// prima determino l'allontanamento del disco inferiore
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - EPS_SMALL) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - dEpsilon) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
trTria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return dDist ;
|
||||
@@ -220,7 +222,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
return dDist3 ;
|
||||
// verifico quello del disco sopra
|
||||
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
if ( dDist4 < - EPS_SMALL)
|
||||
return dDist4 ;
|
||||
return ( dDist + dDist2 + dDist3 + dDist4) ;
|
||||
@@ -247,7 +249,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
double dMaxR = max( tlTool.GetRadius(), tlTool.GetTipRadius()) ;
|
||||
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
|
||||
// prima determino l'allontanamento del disco inferiore
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - EPS_SMALL) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - dEpsilon) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
|
||||
trTria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return dDist ;
|
||||
@@ -266,7 +268,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
return dDist3 ;
|
||||
// verifico quello del disco sopra
|
||||
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
|
||||
if ( dDist4 < - EPS_SMALL)
|
||||
return dDist4 ;
|
||||
return ( dDist + dDist2 + dDist3 + dDist4) ;
|
||||
@@ -299,10 +301,10 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
|
||||
double dRadius = max( ptStart.x, ptEnd.x) ;
|
||||
// Se disco verso il basso dell'utensile
|
||||
if ( ptStart.x > ptEnd.x)
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig + EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig + dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
// Se disco verso l'alto
|
||||
else
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
dDist2 = CAvDiskTriangle( ptCompOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
|
||||
}
|
||||
else {
|
||||
// Verifiche curva precedente per eventuale tappo sopra
|
||||
|
||||
+70
-19
@@ -1,13 +1,14 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2016-2020
|
||||
// EgalTech 2016-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDBoxSurfTm.cpp Data : 09.01.20 Versione : 2.2a2
|
||||
// File : CDeBoxClosedSurfTm.cpp Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione della verifica di collisione tra
|
||||
// BoundingBox e Closed SurftriMesh.
|
||||
//
|
||||
//
|
||||
// Modifiche : 05.10.16 DS Creazione modulo.
|
||||
// 09.01.20 DS Cambio nome alla funzione.
|
||||
// 24.03.24 DS Aggiunta TestCylSurfTm.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -19,36 +20,86 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Il sistema di riferimento è allineato con il box e ha origine in un suo vertice.
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL.
|
||||
// Il sistema di riferimento del box è riferito a quello della superficie.
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const ISurfTriMesh& Stm)
|
||||
CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// recupero BBox del poliedro
|
||||
// Se il box non è ben definito non ha senso proseguire
|
||||
if ( vtDiag.IsSmall())
|
||||
return true ;
|
||||
// Se superficie non valida o aperta, non ha senso proseguire
|
||||
if ( ! Stm.IsValid() || ! Stm.IsClosed())
|
||||
return true ;
|
||||
// Recupero BBox del poliedro
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// calcolo il BBox del parallelepipedo
|
||||
BBox3d b3Box( ORIG, ORIG + vtDiag) ;
|
||||
b3Box.Expand( dSafeDist) ;
|
||||
b3Box.ToGlob( frBox) ;
|
||||
// confronto i due Box
|
||||
if ( ! b3Box.Overlaps( b3Poly))
|
||||
// Calcolo il BBox del parallelepipedo
|
||||
BBox3d b3BoxL( ORIG, ORIG + vtDiag) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3BoxL.Expand( dSafeDist) ;
|
||||
BBox3d b3Box = GetToGlob( b3BoxL, frBox) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Poly.Overlaps( b3Box) || ! b3Poly.Overlaps( frBox, b3BoxL))
|
||||
return false ;
|
||||
// recupero i triangoli che interferiscono con il box
|
||||
// Verifico se il parallelepipedo interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Box, vT) ;
|
||||
for ( int nT : vT) {
|
||||
Triangle3d Tria ;
|
||||
if ( Stm.GetTriangle( nT, Tria)) {
|
||||
if ( CDeBoxTria( frBox, vtDiag, dSafeDist, Tria))
|
||||
if ( CDeBoxTria( frBox, vtDiag, Tria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Se superficie aperta, non c'è collisione
|
||||
if ( ! Stm.IsClosed())
|
||||
// Se il BBox del parallelepipedo non è interno a quello del poliedro e viceversa, non c'è collisione
|
||||
if ( ! b3Poly.Encloses( b3Box) && ! b3Box.Encloses( b3Poly))
|
||||
return false ;
|
||||
// Verifico se il box è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptBoxOrig, ptBoxMax ;
|
||||
b3Box.GetMinMax( ptBoxOrig, ptBoxMax) ;
|
||||
DistPointSurfTm DistBoxOrigSurfCalc( ptBoxOrig, Stm) ;
|
||||
// Verifico se il box è dentro la superficie tramite calcolo distanza minima del suo centro
|
||||
Point3d ptBoxCen = ORIG + vtDiag / 2 ;
|
||||
ptBoxCen.ToGlob( frBox) ;
|
||||
DistPointSurfTm DistBoxCenSurfCalc( ptBoxCen, Stm) ;
|
||||
// Se il box è interno c'è collisione
|
||||
return DistBoxOrigSurfCalc.IsPointInside() ;
|
||||
return DistBoxCenSurfCalc.IsPointInside() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra il box e la superficie : restituisce true in caso di interferenza.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestBoxSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Se il box non è ben definito non ha senso proseguire
|
||||
if ( vtDiag.IsSmall())
|
||||
return true ;
|
||||
// Se superficie non valida, non ha senso proseguire
|
||||
if ( ! Stm.IsValid())
|
||||
return true ;
|
||||
// Recupero BBox del poliedro
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// Calcolo il BBox del parallelepipedo
|
||||
BBox3d b3BoxL( ORIG, ORIG + vtDiag) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3BoxL.Expand( dSafeDist) ;
|
||||
BBox3d b3Box = GetToGlob( b3BoxL, frBox) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Poly.Overlaps( b3Box) || ! b3Poly.Overlaps( frBox, b3BoxL))
|
||||
return false ;
|
||||
// Verifico se il parallelepipedo interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Box, vT) ;
|
||||
for ( int nT : vT) {
|
||||
Triangle3d Tria ;
|
||||
if ( Stm.GetTriangle( nT, Tria)) {
|
||||
if ( CDeBoxTria( frBox, vtDiag, Tria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
+28
-49
@@ -16,6 +16,7 @@
|
||||
#include "CDeBoxTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
#include "CDeCylTria.h"
|
||||
#include "CDeCapsTria.h"
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -99,9 +100,17 @@ CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d
|
||||
Triangle3d trTriaL = trTria ;
|
||||
trTriaL.ToLoc( frBox) ;
|
||||
|
||||
// Calcolo il box locale del triangolo
|
||||
BBox3d b3TriaL ;
|
||||
trTriaL.GetLocalBBox( b3TriaL) ;
|
||||
|
||||
// Calcolo il box come tale
|
||||
BBox3d b3Box( ORIG, ORIG + vtDiag) ;
|
||||
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Box.Overlaps( b3TriaL))
|
||||
return false ;
|
||||
|
||||
// Compute box center and extents
|
||||
Point3d ptCen ;
|
||||
Vector3d vtExt ;
|
||||
@@ -162,7 +171,7 @@ CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const Triangle3d& trTria)
|
||||
CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
// Porto il triangolo nel riferimento del box
|
||||
Triangle3d trTriaL = trTria ;
|
||||
@@ -173,75 +182,45 @@ CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, cons
|
||||
return CDeSimpleBoxTria( Frame3d(), vtDiag, trTriaL) ;
|
||||
|
||||
// Verifica preliminare con box esteso
|
||||
Frame3d frEst( Point3d( -dSafeDist, -dSafeDist, -dSafeDist)) ;
|
||||
if ( ! CDeSimpleBoxTria( frEst, vtDiag + 2 * Vector3d( dSafeDist, dSafeDist, dSafeDist), trTriaL))
|
||||
Frame3d frTmp( Point3d( -dSafeDist, -dSafeDist, -dSafeDist)) ;
|
||||
if ( ! CDeSimpleBoxTria( frTmp, vtDiag + 2 * Vector3d( dSafeDist, dSafeDist, dSafeDist), trTriaL))
|
||||
return false ;
|
||||
|
||||
// Tre box aumentati con distanza di sicurezza in un sola dimensione
|
||||
Frame3d frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersX()) ;
|
||||
frTmp.ChangeOrig( Point3d( -dSafeDist, 0, 0)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * X_AX, trTriaL))
|
||||
return true ;
|
||||
frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersY()) ;
|
||||
frTmp.ChangeOrig( Point3d( 0, -dSafeDist, 0)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Y_AX, trTriaL))
|
||||
return true ;
|
||||
frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersZ()) ;
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, -dSafeDist)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Z_AX, trTriaL))
|
||||
return true ;
|
||||
|
||||
// Sfere centrate negli otto vertici
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, 0, 0), dSafeDist, trTriaL))
|
||||
// Capsule centrati sui dodici spigoli
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( vtDiag.x, 0, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, 0, 0), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, 0), Point3d( vtDiag.x, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( 0, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, 0), Point3d( vtDiag.x, vtDiag.y, 0), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, vtDiag.z), Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, vtDiag.z), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, vtDiag.z), Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
if ( CDeSimpleSpheTria( Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, vtDiag.z), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
|
||||
// Cilindri centrati sui dodici spigoli
|
||||
frTmp.Set( Point3d( 0, 0, 0), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( 0, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, vtDiag.y, 0), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, 0), Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, 0, 0), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( vtDiag.x, vtDiag.y, 0), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, 0, 0), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, 0, vtDiag.z), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, vtDiag.y, vtDiag.z), X_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0, 0, vtDiag.z), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, 0, vtDiag.z), Y_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0., 0., 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, 0., 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( vtDiag.x, vtDiag.y, 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
return true ;
|
||||
frTmp.Set( Point3d( 0., vtDiag.y, 0.), Z_AX) ;
|
||||
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.z, trTriaL))
|
||||
if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, 0), Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
|
||||
+1
-1
@@ -17,4 +17,4 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d& trTria) ;
|
||||
bool CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const Triangle3d& trTria) ;
|
||||
bool CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d& trTria, double dSafeDist) ;
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDeCapsTria.cpp Data : 14.05.22 Versione : 2.4e2
|
||||
// Contenuto : Implementazione della verifica di collisione tra
|
||||
// Capsule (cilindro con estremità semisferiche) e Triangle3d.
|
||||
//
|
||||
//
|
||||
// Modifiche :14.05.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CDeCapsTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "IntersLineCaps.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSphere.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria)
|
||||
{
|
||||
// vedi Ericson, Real-Time Collision Detection, pag. 226 (Nettle method)
|
||||
|
||||
// Dati della capsule come sfera che si muove
|
||||
Point3d ptC = ptP1 ;
|
||||
Point3d ptE = ptP2 ;
|
||||
Vector3d vtDir = ptP2 - ptP1 ;
|
||||
double dLen = vtDir.Len() ;
|
||||
if ( dLen < EPS_SMALL)
|
||||
return CDeSimpleSpheTria( Media( ptP1, ptP2), dR, trTria) ;
|
||||
vtDir /= dLen ;
|
||||
if ( vtDir * trTria.GetN() > 0) {
|
||||
vtDir.Invert() ;
|
||||
ptC = ptP2 ;
|
||||
ptE = ptP1 ;
|
||||
}
|
||||
// Se sfera finale dista dal piano come o meno del raggio, devo verificarla direttamente (il retro è escluso dal calcolo standard)
|
||||
double dDistE = DistPointPlane( ptE, trTria.GetPlane()) ;
|
||||
if ( abs( dDistE) <= dR) {
|
||||
if ( CDeSimpleSpheTria( ptE, dR, trTria))
|
||||
return true ;
|
||||
}
|
||||
// Determinazione primo possibile punto di contatto della sfera con il piano
|
||||
Point3d ptD = ptC - trTria.GetN() * dR ;
|
||||
// Intersezione della linea di movimento di questo punto con il piano del triangolo
|
||||
Point3d ptP ;
|
||||
int nLpRes = IntersLinePlane( ptD, vtDir, 1, trTria.GetPlane(), ptP, false) ;
|
||||
// Se non c'è intersezione passante
|
||||
if ( nLpRes != ILPT_YES) {
|
||||
// se il centro dista dal piano non meno del raggio, allora non c'è sicuramente collisione
|
||||
double dDistM = DistPointPlane( Media( ptP1, ptP2), trTria.GetPlane()) ;
|
||||
if ( abs( dDistM) >= dR)
|
||||
return false ;
|
||||
// interseco l'asse del capsule con capsule di pari raggio con asse i lati del triangolo
|
||||
double dU1 = INFINITO, dU2 = -INFINITO ;
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
double dInt1, dInt2 ;
|
||||
if ( IntersLineCaps( ptC, vtDir, trTria.GetP( i), trTria.GetP( ( i + 1) % 3), dR, dInt1, dInt2)) {
|
||||
dU1 = min( dU1, dInt1) ;
|
||||
dU2 = max( dU2, dInt2) ;
|
||||
if ( ! ( dU1 >= dLen || dU2 <= 0))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
// Determino la posizione dell'intersezione rispetto al triangolo
|
||||
DistPointTriangle dptDist( ptP, trTria) ;
|
||||
// Se l'intersezione sta nel triangolo
|
||||
double dSqDist ;
|
||||
if ( dptDist.GetSqDist( dSqDist) && dSqDist < 4 * SQ_EPS_SMALL) {
|
||||
double dPos = ( ptP - ptD) * vtDir ;
|
||||
return ( dPos > 0 && dPos < dLen) ;
|
||||
}
|
||||
// Altrimenti, recupero il punto del triangolo più vicino all'intersezione
|
||||
Point3d ptQ ;
|
||||
if ( dptDist.GetMinDistPoint( ptQ)) {
|
||||
Point3d ptI1, ptI2 ;
|
||||
int nLsRes = IntersLineSphere( ptQ, -vtDir, ptC, dR, ptI1, ptI2) ;
|
||||
if ( nLsRes != ILST_SEC)
|
||||
return false ;
|
||||
double dPos = ( ptQ - ptI1) * vtDir ;
|
||||
return ( dPos > 0 && dPos < dLen) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
return CDeSimpleCapsTria( ptP1, ptP2, dR + max( 0., dSafeDist), trTria) ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGkCDeCapsTria.h Data : 14.05.22 Versione : 2.4e2
|
||||
// Contenuto : Dichiarazione funzione verifica collisione tra
|
||||
// Capsule (cilindro con estremità semisferiche) e Triangle3d.
|
||||
//
|
||||
// Modifiche : 14.05.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkTriangle3d.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria) ;
|
||||
bool CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria, double dSafeDist) ;
|
||||
+147
-55
@@ -1,12 +1,12 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDeSurfTmSurfTm.h Data : 13.11.20 Versione :
|
||||
// File : CDeClosedSurfTmClosedSurfTm.h Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione funzione verifica collisione tra
|
||||
// SurfTm e SurfTm.
|
||||
//
|
||||
// Modifiche : 13.11.20 LM Creazione modulo.
|
||||
//
|
||||
// 24.03.24 DS Aggiunta TestSurfTmSurfTm.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -18,78 +18,81 @@
|
||||
#include "/EgtDev/Include/EGkBBox3d.h"
|
||||
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// La funzione restituisce true in caso di collisone, false in caso di assenza
|
||||
// di collisione o inconsistenza dei parametri di input.
|
||||
// Le due superfici devono essere espresse nel medesimo sistema di riferimento.
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL.
|
||||
// Se necessario cerco la collisione con un offset della superficie B costituito
|
||||
// da sfere centrate nei vertici, cilindri con i segmenti per asse e il triangolo
|
||||
// originale traslato di una costante pari alla distanza di sicurezza lungo la
|
||||
// sua normale.
|
||||
// da sfere centrate nei vertici, cilindri con gli spigoli per asse e il triangolo
|
||||
// originale traslato della distanza di sicurezza lungo la sua normale.
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeClosedSurfTmClosedSurfTm( const SurfTriMesh& SurfA, const SurfTriMesh& SurfB, double dSafeDist)
|
||||
CDeClosedSurfTmClosedSurfTm( const ISurfTriMesh& SurfA, const ISurfTriMesh& SurfB, double dSafeDist)
|
||||
{
|
||||
// Se le superfici non sono valide o non sono chiuse, non ha senso proseguire.
|
||||
if ( ! ( SurfA.IsValid() && SurfB.IsValid()) || ! ( SurfA.IsClosed() && SurfB.IsClosed()))
|
||||
return false ;
|
||||
// Se i box delle superfici non si intersecano, ho finito.
|
||||
// Recupero le superfici base
|
||||
const SurfTriMesh* pSrfA = GetBasicSurfTriMesh( &SurfA) ;
|
||||
const SurfTriMesh* pSrfB = GetBasicSurfTriMesh( &SurfB) ;
|
||||
// Se le superfici non sono valide o non sono chiuse, non ha senso proseguire
|
||||
if ( pSrfA == nullptr || ! pSrfA->IsValid() || ! pSrfA->IsClosed() ||
|
||||
pSrfB == nullptr || ! pSrfB->IsValid() || ! pSrfB->IsClosed())
|
||||
return true ;
|
||||
// Se i box delle superfici non si intersecano, ho finito.
|
||||
BBox3d b3BoxA, b3BoxB ;
|
||||
SurfA.GetLocalBBox( b3BoxA) ;
|
||||
SurfB.GetLocalBBox( b3BoxB) ;
|
||||
// Se è necessario, espando il box di una costante additiva pari alla distanza di sicurezza.
|
||||
pSrfA->GetLocalBBox( b3BoxA) ;
|
||||
pSrfB->GetLocalBBox( b3BoxB) ;
|
||||
// Se è necessario, espando il box di B di una costante additiva pari alla distanza di sicurezza.
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3BoxA.Expand( dSafeDist) ;
|
||||
// Se i box non si sovrappongono, non c'è collisione. Ho finito.
|
||||
b3BoxB.Expand( dSafeDist) ;
|
||||
// Se i box non si sovrappongono, non c'è collisione. Ho finito.
|
||||
if ( ! b3BoxA.Overlaps( b3BoxB))
|
||||
return false ;
|
||||
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||
// Recupero i triangoli di A che interferiscono col box di B
|
||||
INTVECTOR vTriaIndex ;
|
||||
SurfA.GetAllTriaOverlapBox( b3BoxB, vTriaIndex) ;
|
||||
// Ciclo sui triangoli della superficie A che cadono nel box della superficie B.
|
||||
pSrfA->GetAllTriaOverlapBox( b3BoxB, vTriaIndex) ;
|
||||
// Ciclo sui triangoli della superficie A che interferiscono col box della superficie B.
|
||||
for ( int nTA : vTriaIndex) {
|
||||
Triangle3d trTriaA ;
|
||||
if ( ! ( SurfA.GetTriangle( nTA, trTriaA) && trTriaA.Validate()))
|
||||
if ( ! ( pSrfA->GetTriangle( nTA, trTriaA) && trTriaA.Validate()))
|
||||
continue ;
|
||||
BBox3d b3BoxTriaA ;
|
||||
trTriaA.GetLocalBBox( b3BoxTriaA) ;
|
||||
// Se è necessario, espando il box di una costante additiva pari alla distanza di sicurezza.
|
||||
// Se è necessario, espando il box di una costante additiva pari alla distanza di sicurezza.
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3BoxTriaA.Expand( dSafeDist) ;
|
||||
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||
INTVECTOR vNearTria ;
|
||||
SurfB.GetAllTriaOverlapBox( b3BoxTriaA, vNearTria) ;
|
||||
// Settare tutti i triangoli come già processati.
|
||||
// Al termine della chiamata i TFlags dei triangoli valgono 0.
|
||||
SurfB.ResetTempInt() ;
|
||||
// Ciclo sui triangoli della superficie B che cadono nel box del triangolo corrente della Superficie A.
|
||||
pSrfB->GetAllTriaOverlapBox( b3BoxTriaA, vNearTria) ;
|
||||
// Settare tutti i triangoli come già processati.
|
||||
// Al termine della chiamata i TempInt dei triangoli valgono 0.
|
||||
pSrfB->ResetTempInts() ;
|
||||
// Ciclo sui triangoli della superficie B che cadono nel box del triangolo corrente della Superficie A.
|
||||
for ( int nTB : vNearTria) {
|
||||
// Recupero il triangolo corrente della superficie B.
|
||||
// Se triangolo non valido salto al successivo.
|
||||
// Recupero il triangolo corrente della superficie B.
|
||||
// Se triangolo non valido salto al successivo.
|
||||
Triangle3d trTriaB ;
|
||||
if ( ! ( SurfB.GetTriangle( nTB, trTriaB) && trTriaB.Validate()))
|
||||
if ( ! ( pSrfB->GetTriangle( nTB, trTriaB) && trTriaB.Validate()))
|
||||
continue ;
|
||||
// Se necessario considero l'offset
|
||||
// Se necessario considero l'offset
|
||||
if ( dSafeDist > EPS_SMALL) {
|
||||
int nAdjTriaId[3] ;
|
||||
SurfB.GetTriangleAdjacencies( nTB, nAdjTriaId) ;
|
||||
// Ciclo sui vertici del triangolo.
|
||||
pSrfB->GetTriangleAdjacencies( nTB, nAdjTriaId) ;
|
||||
// Ciclo sui vertici del triangolo.
|
||||
for ( int nVB = 0 ; nVB < 3 ; ++ nVB) {
|
||||
// Se il triangolo adiacente al triangolo corrente su questo edge
|
||||
// non è stato processato, processo il vertice e l'edge.
|
||||
// Se il triangolo adiacente al triangolo corrente su questo edge
|
||||
// non è stato processato, processo il vertice e l'edge.
|
||||
int nAdjTriaTempFlag ;
|
||||
if ( ! ( SurfB.GetTriangleTempInt( nAdjTriaId[nVB], nAdjTriaTempFlag) || nAdjTriaTempFlag == 0))
|
||||
if ( ! ( pSrfB->GetTempInt( nAdjTriaId[nVB], nAdjTriaTempFlag) || nAdjTriaTempFlag == 0))
|
||||
continue ;
|
||||
// Processo il vertice: se c'è collisione fra triangolo A e sfera ho finito.
|
||||
// Processo il vertice: se c'è collisione fra triangolo A e sfera ho finito.
|
||||
if ( CDeSimpleSpheTria( trTriaB.GetP( nVB), dSafeDist, trTriaA))
|
||||
return true ;
|
||||
// Processo l'edge: se c'è collisione fra triangolo A e cilindro ho finito.
|
||||
Vector3d vtEdgeV = trTriaB.GetP( nVB) - trTriaB.GetP( ( nVB + 1) % 3) ;
|
||||
// Processo l'edge: se c'è collisione fra triangolo A e cilindro ho finito.
|
||||
Vector3d vtEdgeV = trTriaB.GetP( ( nVB + 1) % 3) - trTriaB.GetP( nVB) ;
|
||||
double dEdgeLen = vtEdgeV.Len() ;
|
||||
vtEdgeV /= dEdgeLen ;
|
||||
Frame3d frCyl ;
|
||||
@@ -97,22 +100,111 @@ CDeClosedSurfTmClosedSurfTm( const SurfTriMesh& SurfA, const SurfTriMesh& SurfB,
|
||||
if ( CDeSimpleCylTria( frCyl, dSafeDist, dEdgeLen, trTriaA))
|
||||
return true ;
|
||||
}
|
||||
// Traslo il triangolo
|
||||
// Traslo il triangolo
|
||||
trTriaB.Translate( dSafeDist * trTriaB.GetN()) ;
|
||||
}
|
||||
// Processo il triangolo: se i due triangoli collidono ho finito.
|
||||
// Processo il triangolo: se i due triangoli collidono ho finito.
|
||||
if ( CDeTriaTria( trTriaA, trTriaB))
|
||||
return true ;
|
||||
// Segno il triangolo come processato: nTFlag = 1
|
||||
SurfB.SetTempInt( nTB, 1) ;
|
||||
// Segno il triangolo come processato: nTemp = 1
|
||||
pSrfB->SetTempInt( nTB, 1) ;
|
||||
}
|
||||
}
|
||||
// Non ho trovato collisioni fra triangoli delle superfici.
|
||||
// La collisione c'è se una superficie è dentro l'altra.
|
||||
// Non ho trovato collisioni fra triangoli delle superfici.
|
||||
// Se il BBox della prima superficie non è interno a quello della seconda e viceversa, non c'è collisione
|
||||
if ( ! b3BoxA.Encloses( b3BoxB) && ! b3BoxB.Encloses( b3BoxA))
|
||||
return false ;
|
||||
// La collisione c'è se una superficie è dentro l'altra.
|
||||
Point3d ptPointA, ptPointB ;
|
||||
SurfA.GetFirstVertex( ptPointA) ;
|
||||
SurfB.GetFirstVertex( ptPointB) ;
|
||||
DistPointSurfTm DistPoinASurfB( ptPointA, SurfB) ;
|
||||
DistPointSurfTm DistPoinBSurfA( ptPointB, SurfA) ;
|
||||
return ( DistPoinASurfB.IsPointInside() || DistPoinBSurfA.IsPointInside()) ;
|
||||
}
|
||||
pSrfA->GetFirstVertex( ptPointA) ;
|
||||
pSrfB->GetFirstVertex( ptPointB) ;
|
||||
DistPointSurfTm DistPoinASrfB( ptPointA, *pSrfB) ;
|
||||
DistPointSurfTm DistPoinBSrfA( ptPointB, *pSrfA) ;
|
||||
return ( DistPoinASrfB.IsPointInside() || DistPoinBSrfA.IsPointInside()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra le due superfici : restituisce true in caso di interferenza.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestSurfTmSurfTm( const ISurfTriMesh& SurfA, const ISurfTriMesh& SurfB, double dSafeDist)
|
||||
{
|
||||
// Recupero le superfici base
|
||||
const SurfTriMesh* pSrfA = GetBasicSurfTriMesh( &SurfA) ;
|
||||
const SurfTriMesh* pSrfB = GetBasicSurfTriMesh( &SurfB) ;
|
||||
// Se le superfici non sono valide, non ha senso proseguire
|
||||
if ( pSrfA == nullptr || ! pSrfA->IsValid() ||
|
||||
pSrfB == nullptr || ! pSrfB->IsValid())
|
||||
return true ;
|
||||
// Se i box delle superfici non si intersecano, ho finito.
|
||||
BBox3d b3BoxA, b3BoxB ;
|
||||
pSrfA->GetLocalBBox( b3BoxA) ;
|
||||
pSrfB->GetLocalBBox( b3BoxB) ;
|
||||
// Se è necessario, espando il box di B di una costante additiva pari alla distanza di sicurezza.
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3BoxB.Expand( dSafeDist) ;
|
||||
// Se i box non si sovrappongono, non c'è collisione. Ho finito.
|
||||
if ( ! b3BoxA.Overlaps( b3BoxB))
|
||||
return false ;
|
||||
// Recupero i triangoli di A che interferiscono col box di B
|
||||
INTVECTOR vTriaIndex ;
|
||||
pSrfA->GetAllTriaOverlapBox( b3BoxB, vTriaIndex) ;
|
||||
// Ciclo sui triangoli della superficie A che interferiscono col box della superficie B.
|
||||
for ( int nTA : vTriaIndex) {
|
||||
Triangle3d trTriaA ;
|
||||
if ( ! ( pSrfA->GetTriangle( nTA, trTriaA) && trTriaA.Validate()))
|
||||
continue ;
|
||||
BBox3d b3BoxTriaA ;
|
||||
trTriaA.GetLocalBBox( b3BoxTriaA) ;
|
||||
// Se è necessario, espando il box di una costante additiva pari alla distanza di sicurezza.
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3BoxTriaA.Expand( dSafeDist) ;
|
||||
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||
INTVECTOR vNearTria ;
|
||||
pSrfB->GetAllTriaOverlapBox( b3BoxTriaA, vNearTria) ;
|
||||
// Settare tutti i triangoli come già processati.
|
||||
// Al termine della chiamata i TempInt dei triangoli valgono 0.
|
||||
pSrfB->ResetTempInts() ;
|
||||
// Ciclo sui triangoli della superficie B che cadono nel box del triangolo corrente della Superficie A.
|
||||
for ( int nTB : vNearTria) {
|
||||
// Recupero il triangolo corrente della superficie B.
|
||||
// Se triangolo non valido salto al successivo.
|
||||
Triangle3d trTriaB ;
|
||||
if ( ! ( pSrfB->GetTriangle( nTB, trTriaB) && trTriaB.Validate()))
|
||||
continue ;
|
||||
// Se necessario considero l'offset
|
||||
if ( dSafeDist > EPS_SMALL) {
|
||||
int nAdjTriaId[3] ;
|
||||
pSrfB->GetTriangleAdjacencies( nTB, nAdjTriaId) ;
|
||||
// Ciclo sui vertici del triangolo.
|
||||
for ( int nVB = 0 ; nVB < 3 ; ++ nVB) {
|
||||
// Se il triangolo adiacente al triangolo corrente su questo edge
|
||||
// non è stato processato, processo il vertice e l'edge.
|
||||
int nAdjTriaTempFlag ;
|
||||
if ( ! ( pSrfB->GetTempInt( nAdjTriaId[nVB], nAdjTriaTempFlag) || nAdjTriaTempFlag == 0))
|
||||
continue ;
|
||||
// Processo il vertice: se c'è collisione fra triangolo A e sfera ho finito.
|
||||
if ( CDeSimpleSpheTria( trTriaB.GetP( nVB), dSafeDist, trTriaA))
|
||||
return true ;
|
||||
// Processo l'edge: se c'è collisione fra triangolo A e cilindro ho finito.
|
||||
Vector3d vtEdgeV = trTriaB.GetP( ( nVB + 1) % 3) - trTriaB.GetP( nVB) ;
|
||||
double dEdgeLen = vtEdgeV.Len() ;
|
||||
vtEdgeV /= dEdgeLen ;
|
||||
Frame3d frCyl ;
|
||||
frCyl.Set( trTriaB.GetP( nVB), vtEdgeV) ;
|
||||
if ( CDeSimpleCylTria( frCyl, dSafeDist, dEdgeLen, trTriaA))
|
||||
return true ;
|
||||
}
|
||||
// Traslo il triangolo
|
||||
trTriaB.Translate( dSafeDist * trTriaB.GetN()) ;
|
||||
}
|
||||
// Processo il triangolo: se i due triangoli collidono ho finito.
|
||||
if ( CDeTriaTria( trTriaA, trTriaB))
|
||||
return true ;
|
||||
// Segno il triangolo come processato: nTemp = 1
|
||||
pSrfB->SetTempInt( nTB, 1) ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDCylSurfTm.cpp Data : 09.11.20 Versione :
|
||||
// File : CDeConeFrustumClosedSurfTm.cpp Data : 24.031.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione della verifica di collisione tra
|
||||
// Cone e Closed SurftriMesh.
|
||||
//
|
||||
//
|
||||
// Modifiche : 09.11.20 LM Creazione modulo.
|
||||
// 24.03.24 DS Aggiunta TestConeFrustumSurfTm.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -20,45 +21,93 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Il sisitema di riferimento deve avere l'asse di simmetria del cono come asse Z e origine nel centro della base.
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di epsilon, altrimenti è ignorata ed è ininfluente.
|
||||
// Il sistema di riferimento del cono deve essere immerso in quello della superficie.
|
||||
// Il sistema di riferimento deve avere l'asse di simmetria del cono come asse Z e origine nel centro della base.
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL, altrimenti è ignorata ed è ininfluente.
|
||||
// Il sistema di riferimento del cono è riferito a quello della superficie.
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
|
||||
double dSafeDist, const ISurfTriMesh& Stm)
|
||||
const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Se il tronco di cono non è ben definito non ha senso proseguire.
|
||||
// Se il tronco di cono non è ben definito non ha senso proseguire
|
||||
if ( max( dBaseRad, dTopRad) < EPS_SMALL || dHeight < EPS_SMALL)
|
||||
return false ;
|
||||
return true ;
|
||||
// Se superficie non valida o aperta, non ha senso proseguire
|
||||
if ( ! Stm.IsValid() || ! Stm.IsClosed())
|
||||
return true ;
|
||||
// Recupero BBox della trimesh
|
||||
BBox3d b3Surf = Stm.GetAllTriaBox() ;
|
||||
// Calcolo il BBox del tronco di cono
|
||||
double dMaxRad = max( dBaseRad, dTopRad) ;
|
||||
BBox3d b3Cone( - dMaxRad, - dMaxRad, 0, dMaxRad, dMaxRad, dHeight) ;
|
||||
b3Cone.Expand( dSafeDist) ;
|
||||
// Porto BBox del cono nel sistema della superficie.
|
||||
b3Cone.ToGlob( frCone) ;
|
||||
// Se i BBox non interferiscono, ho finito.
|
||||
if ( ! b3Cone.Overlaps( b3Surf))
|
||||
BBox3d b3ConeL( Point3d( -dMaxRad, -dMaxRad, 0),
|
||||
Point3d( dMaxRad, dMaxRad, dHeight)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3ConeL.Expand( dSafeDist) ;
|
||||
BBox3d b3Cone = GetToGlob( b3ConeL, frCone) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Surf.Overlaps( b3Cone) || ! b3Surf.Overlaps( frCone, b3ConeL))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del cono
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Cone, vT) ;
|
||||
// Ciclo sui triangoli che interferiscono col box del cono
|
||||
// Verifico se il tronco di cono interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
for ( int nT : vT) {
|
||||
Triangle3d trTria ;
|
||||
if ( Stm.GetTriangle( nT, trTria)) {
|
||||
if ( CDeConeFrustumTria( frCone, dBaseRad, dTopRad, dHeight, dSafeDist, trTria))
|
||||
if ( CDeConeFrustumTria( frCone, dBaseRad, dTopRad, dHeight, trTria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Se superficie aperta, non c'è collisione
|
||||
if ( ! Stm.IsClosed())
|
||||
// Se il BBox del tronco di cono non è interno a quello del poliedro e viceversa, non c'è collisione
|
||||
if ( ! b3Surf.Encloses( b3Cone) && ! b3Cone.Encloses( b3Surf))
|
||||
return false ;
|
||||
// Verifico se il tronco di cono è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptConeOrig ;
|
||||
ptConeOrig.ToGlob( frCone) ;
|
||||
DistPointSurfTm DistConeOrigSurfCalc( ptConeOrig, Stm) ;
|
||||
Point3d ptConeCen( 0, 0, dHeight / 2) ;
|
||||
ptConeCen.ToGlob( frCone) ;
|
||||
DistPointSurfTm DistConeCenSurfCalc( ptConeCen, Stm) ;
|
||||
// Se il tronco di cono è interno c'è collisione
|
||||
return DistConeOrigSurfCalc.IsPointInside() ;
|
||||
}
|
||||
return DistConeCenSurfCalc.IsPointInside() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra il tronco di cono e la superficie : restituisce true in caso di interferenza.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestConeFrustumSurfTm( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
|
||||
const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Se il tronco di cono non è ben definito non ha senso proseguire
|
||||
if ( max( dBaseRad, dTopRad) < EPS_SMALL || dHeight < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida, non ha senso proseguire
|
||||
if ( ! Stm.IsValid())
|
||||
return true ;
|
||||
// Recupero BBox della trimesh
|
||||
BBox3d b3Surf = Stm.GetAllTriaBox() ;
|
||||
// Calcolo il BBox del tronco di cono
|
||||
double dMaxRad = max( dBaseRad, dTopRad) ;
|
||||
BBox3d b3ConeL( Point3d( -dMaxRad, -dMaxRad, 0),
|
||||
Point3d( dMaxRad, dMaxRad, dHeight)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3ConeL.Expand( dSafeDist) ;
|
||||
BBox3d b3Cone = GetToGlob( b3ConeL, frCone) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Surf.Overlaps( b3Cone) || ! b3Surf.Overlaps( frCone, b3ConeL))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del cono
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Cone, vT) ;
|
||||
// Verifico se il tronco di cono interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
for ( int nT : vT) {
|
||||
Triangle3d trTria ;
|
||||
if ( Stm.GetTriangle( nT, trTria)) {
|
||||
if ( CDeConeFrustumTria( frCone, dBaseRad, dTopRad, dHeight, trTria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad,
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di epsilon, altrimenti è ignorata ed è ininfluente.
|
||||
bool
|
||||
CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
|
||||
double dSafeDist, const Triangle3d& trTria)
|
||||
const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
// Se il tronco di cono o il triangolo non sono ben definiti non procedo
|
||||
if ( max( dBaseRad, dTopRad) < EPS_SMALL || dHeight < EPS_SMALL || ! trTria.IsValid())
|
||||
@@ -142,7 +142,7 @@ CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, doub
|
||||
|
||||
// Se è un cilindro chiamo la routine apposita.
|
||||
if ( abs( dBaseRad - dTopRad) < EPS_SMALL)
|
||||
return CDeCylTria( frCone, max( dBaseRad, dTopRad), dHeight, dSafeDist, trTria) ;
|
||||
return CDeCylTria( frCone, max( dBaseRad, dTopRad), dHeight, trTria, dSafeDist) ;
|
||||
|
||||
// Se il raggio di base è maggiore del raggio top cambio il sistema di riferimento.
|
||||
double dMinRad = dBaseRad ;
|
||||
@@ -156,11 +156,11 @@ CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, doub
|
||||
|
||||
// Se è un cono, chiamo la routine apposita
|
||||
if ( dMinRad < EPS_SMALL)
|
||||
return CDeConeTria( frMyCone, dMaxRad, dHeight, dSafeDist, trTria) ;
|
||||
return CDeConeTria( frMyCone, dMaxRad, dHeight, trTria, dSafeDist) ;
|
||||
|
||||
// Se distanza di sicurezza nulla
|
||||
if ( dSafeDist < EPS_SMALL)
|
||||
return CDeSimpleConeFrustumTria( frMyCone, dBaseRad, dTopRad, dHeight, trTria ) ;
|
||||
return CDeSimpleConeFrustumTria( frMyCone, dBaseRad, dTopRad, dHeight, trTria) ;
|
||||
|
||||
// Verifica preliminare con tronco di cono esteso
|
||||
double dDiffRad = dMaxRad - dMinRad ;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDeConTria.cpp Data : 28.10.20 Versione : 2.2k1
|
||||
// File : CDeConeFrustumTria.h Data : 28.10.20 Versione : 2.2k1
|
||||
// Contenuto : Dichiarazione della verifica di collisione tra
|
||||
// Cone e Triangle3d.
|
||||
//
|
||||
@@ -20,6 +20,5 @@
|
||||
// Il sistema di riferimento deve avere l'origine nel centro della base minore e l'asse
|
||||
// di simmetria del cono, rivolto verso la direzione di apertura, come asse Z.
|
||||
bool CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad, double dHeight, const Triangle3d& trTria) ;
|
||||
// Il sistema di riferimento ha l'asse Z coincidente con l'asse di simmetria del cono e l'origine nel centro della base.
|
||||
bool CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
|
||||
double dSafeDist, const Triangle3d& trTria) ;
|
||||
const Triangle3d& trTria, double dSafeDist) ;
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ CDeSimpleConeTria( const Frame3d& frCone, double dRad, double dHeight, const Tri
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, double dSafeDist, const Triangle3d& trTria)
|
||||
CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
// Verifico validità del cono
|
||||
if ( dRad < EPS_SMALL || dHeight < EPS_SMALL)
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// Il sistema di riferimento ha asse Z coincidente con l'asse del cono e origine nel vertice del cono (punto più basso).
|
||||
bool CDeSimpleConeTria( const Frame3d& frCone, double dRad, double dHeight, const Triangle3d& trTria) ;
|
||||
bool CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, double dSafeDist, const Triangle3d& trTria) ;
|
||||
bool CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, const Triangle3d& trTria, double dSafeDist) ;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDeConvexTorusTria.cpp Data : 18.11.20 Versione :
|
||||
// File : CDeConvexTorusTria.cpp Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione funzione verifica collisione tra
|
||||
// toro convesso e SurfTriMesh.
|
||||
//
|
||||
// Modifiche : 18.11.20 LM Creazione modulo.
|
||||
//
|
||||
// 24.03.24 DS Aggiunta TestConvexTorusSurfTm.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -18,48 +18,90 @@
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Il toro convesso è il disco limitato dalla sola parte esterna del toro.
|
||||
// Il toro convesso è il solido a disco limitato dalla sola parte esterna del toro.
|
||||
// Raggio principale R1, raggio secondario R2.
|
||||
// Il toro è posto nel piano XY del suo riferimento, centrato sull'origine.
|
||||
// La funzione restituisce true in caso di collisione.
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeConvexTorusClosedSurfTm( const Frame3d& frTorusFrame, double dRad1, double dRad2,
|
||||
double dSafeDist, const ISurfTriMesh& Stm)
|
||||
CDeConvexTorusClosedSurfTm( const Frame3d& frTorus, double dRad1, double dRad2,
|
||||
const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// I raggi devono essere non nulli e la superficie ben definita.
|
||||
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL || ! Stm.IsValid())
|
||||
return false ;
|
||||
// Box del toro (sempre completo)
|
||||
BBox3d b3ConvTorusBox ;
|
||||
b3ConvTorusBox.Set( Point3d( - dRad1 - dRad2, - dRad1 - dRad2, - dRad2),
|
||||
Point3d( dRad1 + dRad2, dRad1 + dRad2, dRad2)) ;
|
||||
// Aggiungo eventuale distanza di sicurezza
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3ConvTorusBox.Expand( dSafeDist) ;
|
||||
// Porto il box del toro nel riferimento della superficie (inteso some globale)
|
||||
b3ConvTorusBox.ToGlob( frTorusFrame) ;
|
||||
// I raggi devono essere non nulli
|
||||
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida o aperta, non ha senso proseguire
|
||||
if ( ! Stm.IsValid() || ! Stm.IsClosed())
|
||||
return true ;
|
||||
// Box della superficie
|
||||
BBox3d b3SurfBox = Stm.GetAllTriaBox() ;
|
||||
BBox3d b3Surf = Stm.GetAllTriaBox() ;
|
||||
// Box del toro (sempre completo)
|
||||
BBox3d b3TorusL( Point3d( -dRad1 - dRad2, -dRad1 - dRad2, -dRad2),
|
||||
Point3d( dRad1 + dRad2, dRad1 + dRad2, dRad2)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3TorusL.Expand( dSafeDist) ;
|
||||
BBox3d b3Torus = GetToGlob( b3TorusL, frTorus) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3ConvTorusBox.Overlaps( b3SurfBox))
|
||||
if ( ! b3Surf.Overlaps( b3Torus) || ! b3Surf.Overlaps( frTorus, b3TorusL))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del toro
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3ConvTorusBox, vT) ;
|
||||
// Ciclo sui triangoli recuperati
|
||||
Stm.GetAllTriaOverlapBox( b3Torus, vT) ;
|
||||
// Verifico se il toro interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
for ( int nT : vT) {
|
||||
Triangle3d trTria ;
|
||||
if ( Stm.GetTriangle( nT, trTria)) {
|
||||
if ( CDeConvexTorusTria( frTorusFrame, dRad1, dRad2, CT_TOT, dSafeDist, trTria))
|
||||
if ( CDeConvexTorusTria( frTorus, dRad1, dRad2, CT_TOT, trTria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Se superficie aperta, non c'è collisione
|
||||
if ( ! Stm.IsClosed())
|
||||
// Se il BBox del toro non è interno a quello del poliedro e viceversa, non c'è collisione
|
||||
if ( ! b3Surf.Encloses( b3Torus) && ! b3Torus.Encloses( b3Surf))
|
||||
return false ;
|
||||
// Verifico se il toro è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptTorusOrig = frTorusFrame.Orig() ;
|
||||
// Verifico se il toro è dentro la superficie tramite calcolo distanza minima del suo centro
|
||||
Point3d ptTorusOrig = frTorus.Orig() ;
|
||||
DistPointSurfTm DistConeOrigSurfCalc( ptTorusOrig, Stm) ;
|
||||
// Se il toro è interno c'è collisione
|
||||
return ( DistConeOrigSurfCalc.IsPointInside()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra il toro convesso e la superficie : restituisce true in caso di interferenza
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestConvexTorusSurfTm( const Frame3d& frTorus, double dRad1, double dRad2,
|
||||
const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// I raggi devono essere non nulli
|
||||
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida, non ha senso proseguire
|
||||
if ( ! Stm.IsValid())
|
||||
return true ;
|
||||
// Box della superficie
|
||||
BBox3d b3Surf = Stm.GetAllTriaBox() ;
|
||||
// Box del toro (sempre completo)
|
||||
BBox3d b3TorusL( Point3d( -dRad1 - dRad2, -dRad1 - dRad2, -dRad2),
|
||||
Point3d( dRad1 + dRad2, dRad1 + dRad2, dRad2)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3TorusL.Expand( dSafeDist) ;
|
||||
BBox3d b3Torus = GetToGlob( b3TorusL, frTorus) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Surf.Overlaps( b3Torus) || ! b3Surf.Overlaps( frTorus, b3TorusL))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del toro
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Torus, vT) ;
|
||||
// Verifico se il toro interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
for ( int nT : vT) {
|
||||
Triangle3d trTria ;
|
||||
if ( Stm.GetTriangle( nT, trTria)) {
|
||||
if ( CDeConvexTorusTria( frTorus, dRad1, dRad2, CT_TOT, trTria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ CDeSimpleConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, in
|
||||
bool bContinue = plyApprox.GetFirstPoint( ptSt) && plyApprox.GetNextPoint( ptEn) ;
|
||||
while ( bContinue && ! bCollision) {
|
||||
frConus.Set( Point3d( 0., 0., ptSt.z), Frame3d::TOP) ;
|
||||
bCollision = CDeConeFrustumTria( frConus, ptSt.x, ptEn.x, ptEn.z - ptSt.z, 0., trMyTria) ;
|
||||
bCollision = CDeSimpleConeFrustumTria( frConus, ptSt.x, ptEn.x, ptEn.z - ptSt.z, trMyTria) ;
|
||||
ptSt = ptEn ;
|
||||
bContinue = plyApprox.GetNextPoint( ptEn) ;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ CDeSimpleConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, in
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, int nCtType,
|
||||
double dSafeDist, const Triangle3d& trTria)
|
||||
const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
// I raggi devono essere non nulli e il triangolo ben definito.
|
||||
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL || ! trTria.IsValid())
|
||||
|
||||
@@ -28,4 +28,4 @@ enum ConvexTorusType { CT_INF = -1, CT_SUP = 1, CT_TOT = 0} ;
|
||||
bool CDeSimpleConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, int nCtType,
|
||||
const Triangle3d& trTria) ;
|
||||
bool CDeConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, int nCtType,
|
||||
double dSafeDist, const Triangle3d& trTria) ;
|
||||
const Triangle3d& trTria, double dSafeDist) ;
|
||||
+82
-24
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDCylSurfTm.cpp Data : 09.01.20 Versione : 2.2a2
|
||||
// File : CDeCylClosedSurfTm.cpp Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione della verifica di collisione tra
|
||||
// Cylinder e Closed SurftriMesh.
|
||||
//
|
||||
//
|
||||
// Modifiche : 09.01.20 DS Creazione modulo.
|
||||
//
|
||||
// 24.03.24 DS Aggiunta TestCylSurfTm.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -19,42 +19,100 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Il sistema di riferimento deve avere l'asse di simmetria del cilindro come asse Z e origine nel centro della base o del top.
|
||||
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL, altrimenti è ignorata ed è ininfluente.
|
||||
// Il sistema di riferimento del cilindro è riferito a quello della superficie.
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const ISurfTriMesh& Stm)
|
||||
CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// recupero BBox del poliedro
|
||||
// Il cilindro deve essere ben definito
|
||||
if ( dR < EPS_SMALL || dH < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida o aperta, non ha senso proseguire
|
||||
if ( ! Stm.IsValid() || ! Stm.IsClosed())
|
||||
return true ;
|
||||
// Recupero BBox del poliedro
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// sistemazioni cilindro
|
||||
Frame3d frC = frCyl ;
|
||||
// Sistemazioni cilindro
|
||||
Frame3d frMyCyl = frCyl ;
|
||||
if ( dH < 0) {
|
||||
frC.Translate( dH * frC.VersZ()) ;
|
||||
dH = - dH ;
|
||||
frMyCyl.Translate( dH * frMyCyl.VersZ()) ;
|
||||
dH = -dH ;
|
||||
}
|
||||
// calcolo il BBox del cilindro
|
||||
BBox3d b3Cyl( -dR, -dR, 0, dR, dR, dH) ;
|
||||
b3Cyl.Expand( dSafeDist) ;
|
||||
b3Cyl.ToGlob( frC) ;
|
||||
// confronto i due Box
|
||||
if ( ! b3Cyl.Overlaps( b3Poly))
|
||||
// Calcolo il BBox del cilindro
|
||||
BBox3d b3CylL( Point3d( -dR, -dR, 0),
|
||||
Point3d( dR, dR, dH)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3CylL.Expand( dSafeDist) ;
|
||||
BBox3d b3Cyl = GetToGlob( b3CylL, frMyCyl) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Poly.Overlaps( b3Cyl) || ! b3Poly.Overlaps( frMyCyl, b3CylL))
|
||||
return false ;
|
||||
// recupero i triangoli che interferiscono con il box del Cilindro
|
||||
// Verifico se il cilindro interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Cyl, vT) ;
|
||||
for ( int nT : vT) {
|
||||
Triangle3d Tria ;
|
||||
if ( Stm.GetTriangle( nT, Tria)) {
|
||||
if ( CDeCylTria( frC, dR, dH, dSafeDist, Tria))
|
||||
if ( CDeCylTria( frMyCyl, dR, dH, Tria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Se superficie aperta, non c'è collisione
|
||||
if ( ! Stm.IsClosed())
|
||||
// Se il BBox del cilindro non è interno a quello del poliedro e viceversa, non c'è collisione
|
||||
if ( ! b3Poly.Encloses( b3Cyl) && ! b3Cyl.Encloses( b3Poly))
|
||||
return false ;
|
||||
// Verifico se il cilindro è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptCylOrig( 0., 0., - dSafeDist) ;
|
||||
ptCylOrig.ToGlob( frC) ;
|
||||
DistPointSurfTm DistCylOrigSurfCalc( ptCylOrig, Stm) ;
|
||||
// Verifico se il cilindro è dentro la superficie tramite calcolo distanza minima del suo centro
|
||||
Point3d ptCylCen( 0, 0, dH / 2) ;
|
||||
ptCylCen.ToGlob( frMyCyl) ;
|
||||
DistPointSurfTm DistCylCenSurfCalc( ptCylCen, Stm) ;
|
||||
// Se il cilindro è interno c'è collisione
|
||||
return ( DistCylOrigSurfCalc.IsPointInside()) ;
|
||||
return ( DistCylCenSurfCalc.IsPointInside()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra il cilindro e la superficie : restituisce true in caso di interferenza
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestCylSurfTm( const Frame3d& frCyl, double dR, double dH, const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Il cilindro deve essere ben definito
|
||||
if ( dR < EPS_SMALL || dH < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida, non ha senso proseguire
|
||||
if ( ! Stm.IsValid())
|
||||
return true ;
|
||||
// Recupero BBox della superficie poligonale
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// Sistemazioni cilindro
|
||||
Frame3d frMyCyl = frCyl ;
|
||||
if ( dH < 0) {
|
||||
frMyCyl.Translate( dH * frMyCyl.VersZ()) ;
|
||||
dH = -dH ;
|
||||
}
|
||||
// Calcolo il BBox del cilindro
|
||||
BBox3d b3CylL( Point3d( -dR, -dR, 0),
|
||||
Point3d( dR, dR, dH)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3CylL.Expand( dSafeDist) ;
|
||||
BBox3d b3Cyl = GetToGlob( b3CylL, frMyCyl) ;
|
||||
// Se i BBox non interferiscono, non c'è interferenza
|
||||
if ( ! b3Poly.Overlaps( b3Cyl) || ! b3Poly.Overlaps( frMyCyl, b3CylL))
|
||||
return false ;
|
||||
// Verifico se il cilindro interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Cyl, vT) ;
|
||||
for ( int nT : vT) {
|
||||
Triangle3d Tria ;
|
||||
if ( Stm.GetTriangle( nT, Tria)) {
|
||||
if ( CDeCylTria( frMyCyl, dR, dH, Tria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,9 +13,9 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "CDeCylTria.h"
|
||||
#include "CDeConvexTorusTria.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -84,7 +84,7 @@ CDeSimpleCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeCylTria( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const Triangle3d& trTria)
|
||||
CDeCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
// Se distanza di sicurezza nulla
|
||||
if ( dSafeDist < EPS_SMALL)
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CDeSimpleCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d& trTria) ;
|
||||
bool CDeCylTria( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const Triangle3d& trTria) ;
|
||||
bool CDeCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d& trTria, double dSafeDist) ;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDePyramidClosedSurfTm.h Data : 09.11.20 Versione :
|
||||
// File : CDeRectPrismoidClosedSurfTm.h Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione funzione verifica collisione tra
|
||||
// Prismoide a basi rettangolari e Closed SurfTriMesh.
|
||||
//
|
||||
// Modifiche : 09.11.20 LM Creazione modulo.
|
||||
//
|
||||
// 24.03.24 DS Aggiunta TestRectPrismoidSurfTm.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -22,49 +22,100 @@ using namespace std ;
|
||||
// Il sistema di riferimento deve avere l'origine nel centro della Base, asse X lungo
|
||||
// un segmento della stessa e asse Z ortogonale alle basi e diretta verso la base Top.
|
||||
// Il sistema di riferimento della piramide deve essere immerso in quello della superficie.
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
|
||||
double dLenghtTopX, double dLenghtTopY, double dHeight,
|
||||
double dSafeDist, const ISurfTriMesh& Stm)
|
||||
const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Se il tronco di piramide non è definito o la superficie non ben definita non ha senso proseguire.
|
||||
// Se il tronco di piramide non è definito non ha senso proseguire.
|
||||
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
|
||||
max( dLenghtBaseY, dLenghtTopY) < EPS_SMALL ||
|
||||
dHeight < EPS_SMALL || ! Stm.IsValid())
|
||||
return false ;
|
||||
dHeight < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida o aperta, non ha senso proseguire
|
||||
if ( ! Stm.IsValid() || ! Stm.IsClosed())
|
||||
return true ;
|
||||
// Recupero BBox della trimesh
|
||||
BBox3d b3Surf = Stm.GetAllTriaBox() ;
|
||||
// Calcolo il BBox del tronco di piramide
|
||||
double dMaxLenX = max( dLenghtBaseX, dLenghtTopX) ;
|
||||
double dMaxLenY = max( dLenghtBaseY, dLenghtTopY) ;
|
||||
BBox3d b3Pyr( -dMaxLenX / 2, -dMaxLenY / 2, 0., dMaxLenX / 2, dMaxLenY / 2, dHeight) ;
|
||||
// Se la distanza di sicurezza è maggiore di epsilon aumento le dimensioni del tronco di piramide.
|
||||
if ( dSafeDist > EPS_SMALL) {
|
||||
b3Pyr.Expand( dSafeDist) ;
|
||||
}
|
||||
// Porto BBox del tronco di piramide nel sistema della superficie.
|
||||
b3Pyr.ToGlob( frPrismoid) ;
|
||||
BBox3d b3PyrL( Point3d( -dMaxLenX / 2, -dMaxLenY / 2, 0.),
|
||||
Point3d( dMaxLenX / 2, dMaxLenY / 2, dHeight)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3PyrL.Expand( dSafeDist) ;
|
||||
BBox3d b3Pyr = GetToGlob( b3PyrL, frPrismoid) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Pyr.Overlaps( b3Surf))
|
||||
if ( ! b3Surf.Overlaps( b3Pyr) || ! b3Surf.Overlaps( frPrismoid, b3PyrL))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del tronco di piramide.
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Pyr, vT) ;
|
||||
// Ciclo sui triangoli che interferiscono col box del tronco di piramide.
|
||||
// Verifico se il tronco di piramide interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
for ( int nT : vT) {
|
||||
Triangle3d trTria ;
|
||||
if ( Stm.GetTriangle( nT, trTria)) {
|
||||
if ( CDeRectPrismoidTria( frPrismoid, dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight,
|
||||
dSafeDist, trTria))
|
||||
trTria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Se superficie aperta, non c'è collisione
|
||||
if ( ! Stm.IsClosed())
|
||||
// Se il BBox del tronco di piramide non è interno a quello del poliedro e viceversa, non c'è collisione
|
||||
if ( ! b3Surf.Encloses( b3Pyr) && ! b3Pyr.Encloses( b3Surf))
|
||||
return false ;
|
||||
// Verifico se il tronco di piramide è dentro la superficie tramite calcolo distanza minima.
|
||||
Point3d ptPyrOrig = frPrismoid.Orig() ;
|
||||
DistPointSurfTm DistBoxOrigSurfCalc( ptPyrOrig, Stm) ;
|
||||
// C'è collisione se il tronco di piramide è interno.
|
||||
return ( DistBoxOrigSurfCalc.IsPointInside()) ;
|
||||
// Verifico se il tronco di piramide è dentro la superficie tramite calcolo distanza minima del suo centro
|
||||
Point3d ptPyrCen( 0, 0, dHeight / 2) ;
|
||||
ptPyrCen.ToGlob( frPrismoid) ;
|
||||
DistPointSurfTm DistPyrCenSurfCalc( ptPyrCen, Stm) ;
|
||||
// C'è collisione se il tronco di piramide è interno
|
||||
return ( DistPyrCenSurfCalc.IsPointInside()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra il Prismoide a basi rettangolari e la superficie : restituisce true in caso di interferenza.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestRectPrismoidSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
|
||||
double dLenghtTopX, double dLenghtTopY, double dHeight,
|
||||
const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Se il tronco di piramide non è definito non ha senso proseguire.
|
||||
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
|
||||
max( dLenghtBaseY, dLenghtTopY) < EPS_SMALL ||
|
||||
dHeight < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida, non ha senso proseguire
|
||||
if ( ! Stm.IsValid())
|
||||
return true ;
|
||||
// Recupero BBox della trimesh
|
||||
BBox3d b3Surf = Stm.GetAllTriaBox() ;
|
||||
// Calcolo il BBox del tronco di piramide
|
||||
double dMaxLenX = max( dLenghtBaseX, dLenghtTopX) ;
|
||||
double dMaxLenY = max( dLenghtBaseY, dLenghtTopY) ;
|
||||
BBox3d b3PyrL( Point3d( -dMaxLenX / 2, -dMaxLenY / 2, 0.),
|
||||
Point3d( dMaxLenX / 2, dMaxLenY / 2, dHeight)) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3PyrL.Expand( dSafeDist) ;
|
||||
BBox3d b3Pyr = GetToGlob( b3PyrL, frPrismoid) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Surf.Overlaps( b3Pyr) || ! b3Surf.Overlaps( frPrismoid, b3PyrL))
|
||||
return false ;
|
||||
// Recupero i triangoli che interferiscono con il box del tronco di piramide.
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Pyr, vT) ;
|
||||
// Verifico se il tronco di piramide interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
for ( int nT : vT) {
|
||||
Triangle3d trTria ;
|
||||
if ( Stm.GetTriangle( nT, trTria)) {
|
||||
if ( CDeRectPrismoidTria( frPrismoid, dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight,
|
||||
trTria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
+34
-54
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CDeRectPrismoidTria.h"
|
||||
#include "CDeCapsTria.h"
|
||||
#include "CDeBoxTria.h"
|
||||
#include "CDeCylTria.h"
|
||||
#include "CDeSpheTria.h"
|
||||
@@ -133,7 +134,7 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl
|
||||
bool
|
||||
CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
|
||||
double dLenghtTopX, double dLenghtTopY, double dHeight,
|
||||
double dSafeDist, const Triangle3d& trTria)
|
||||
const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
// Se il tronco di piramide o il triangolo non sono ben definiti non procedo
|
||||
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
|
||||
@@ -141,9 +142,13 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
|
||||
dHeight < EPS_SMALL || ! trTria.IsValid())
|
||||
return false ;
|
||||
|
||||
// Porto il triangolo nel riferimento del prismoide
|
||||
Triangle3d trTriaL = trTria ;
|
||||
trTriaL.ToLoc( frPrismoid) ;
|
||||
|
||||
// Se distanza di sicurezza nulla
|
||||
if ( dSafeDist < EPS_SMALL)
|
||||
return CDeSimpleRectPrismoidTria( frPrismoid, dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight, trTria) ;
|
||||
return CDeSimpleRectPrismoidTria( Frame3d(), dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight, trTriaL) ;
|
||||
|
||||
// Verifiche con offset esteso
|
||||
double dHDiffX = ( dLenghtBaseX - dLenghtTopX) / 2 ;
|
||||
@@ -156,37 +161,37 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
|
||||
double dSecAy = sqrt( 1 + dTgAy * dTgAy) ;
|
||||
double dOffsBaseY = dSafeDist * ( dSecAy + dTgAy) ;
|
||||
double dOffsTopY = dSafeDist * ( dSecAy - dTgAy) ;
|
||||
Frame3d frFrame = frPrismoid ; frFrame.Translate( - dSafeDist * frFrame.VersZ()) ;
|
||||
if ( ! CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX + 2 * dOffsBaseX, dLenghtBaseY + 2 * dOffsBaseY,
|
||||
dLenghtTopX + 2 * dOffsTopX, dLenghtTopY + 2 * dOffsTopY, dHeight + 2 * dSafeDist, trTria))
|
||||
Frame3d frTmp( Point3d( 0, 0, -dSafeDist)) ;
|
||||
if ( ! CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX + 2 * dOffsBaseX, dLenghtBaseY + 2 * dOffsBaseY,
|
||||
dLenghtTopX + 2 * dOffsTopX, dLenghtTopY + 2 * dOffsTopY, dHeight + 2 * dSafeDist, trTriaL))
|
||||
return false ;
|
||||
|
||||
// Offset fine
|
||||
// Box sotto
|
||||
frFrame = frPrismoid ; frFrame.Translate( - dSafeDist * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleBoxTria( frFrame, Vector3d( dLenghtBaseX, dLenghtBaseY, dSafeDist), trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, -dSafeDist)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, Vector3d( dLenghtBaseX, dLenghtBaseY, dSafeDist), trTriaL))
|
||||
return true ;
|
||||
// Box sopra
|
||||
frFrame = frPrismoid ; frFrame.Translate( dHeight * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleBoxTria( frFrame, Vector3d( dLenghtTopX, dLenghtTopY, dSafeDist), trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, dHeight)) ;
|
||||
if ( CDeSimpleBoxTria( frTmp, Vector3d( dLenghtTopX, dLenghtTopY, dSafeDist), trTriaL))
|
||||
return true ;
|
||||
// Prismoide allungato in X
|
||||
double dHypoX = sqrt( dHDiffX * dHDiffX + dHeight * dHeight) ;
|
||||
double dOffsX = dSafeDist * dHeight / dHypoX ;
|
||||
double dMoveXZ = dSafeDist * dHDiffX / dHypoX ;
|
||||
frFrame = frPrismoid ; frFrame.Translate( dMoveXZ * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX + 2 * dOffsX, dLenghtBaseY,
|
||||
dLenghtTopX + 2 * dOffsX, dLenghtTopY, dHeight, trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, dMoveXZ)) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX + 2 * dOffsX, dLenghtBaseY,
|
||||
dLenghtTopX + 2 * dOffsX, dLenghtTopY, dHeight, trTriaL))
|
||||
return true ;
|
||||
// Prismoide allungato in Y
|
||||
double dHypoY = sqrt( dHDiffY * dHDiffY + dHeight * dHeight) ;
|
||||
double dOffsY = dSafeDist * dHeight / dHypoY ;
|
||||
double dMoveYZ = dSafeDist * dHDiffY / dHypoY ;
|
||||
frFrame = frPrismoid ; frFrame.Translate( dMoveYZ * frFrame.VersZ()) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX, dLenghtBaseY + 2 * dOffsY,
|
||||
dLenghtTopX, dLenghtTopY + 2 * dOffsY, dHeight, trTria))
|
||||
frTmp.ChangeOrig( Point3d( 0, 0, dMoveYZ)) ;
|
||||
if ( CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX, dLenghtBaseY + 2 * dOffsY,
|
||||
dLenghtTopX, dLenghtTopY + 2 * dOffsY, dHeight, trTriaL))
|
||||
return true ;
|
||||
// Sfere centrate nei vertici
|
||||
// Vertici
|
||||
double dHalfBaseX = dLenghtBaseX / 2 ;
|
||||
double dHalfBaseY = dLenghtBaseY / 2 ;
|
||||
double dHalfTopX = dLenghtTopX / 2 ;
|
||||
@@ -199,55 +204,30 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
|
||||
Point3d( dHalfTopX, -dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, dHalfTopY, dHeight),
|
||||
Point3d( -dHalfTopX, dHalfTopY, dHeight)} ;
|
||||
for ( auto& ptV : vVert) {
|
||||
ptV.ToGlob( frPrismoid) ;
|
||||
if ( CDeSimpleSpheTria( ptV, dSafeDist, trTria))
|
||||
return true ;
|
||||
}
|
||||
// Cilindri con i segmenti come asse
|
||||
frFrame.Set( vVert[0], frPrismoid.VersX()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseX, trTria))
|
||||
// Capsule centrati sui dodici spigoli
|
||||
if ( CDeSimpleCapsTria( vVert[0], vVert[1], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[1], frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[1], vVert[2], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[2], -frPrismoid.VersX()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseX, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[2], vVert[3], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[3], -frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[3], vVert[0], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[4], frPrismoid.VersX()) ;
|
||||
if (CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopX, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[4], vVert[5], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[5], frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[5], vVert[6], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[6], -frPrismoid.VersX()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopX, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[6], vVert[7], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
frFrame.Set( vVert[7], -frPrismoid.VersY()) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopY, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[7], vVert[4], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg04 = vVert[4] - vVert[0] ;
|
||||
double dLenSeg04 = vtSeg04.Len() ;
|
||||
frFrame.Set( vVert[0], vtSeg04) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg04, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[0], vVert[4], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg15 = vVert[5] - vVert[1] ;
|
||||
double dLenSeg15 = vtSeg15.Len() ;
|
||||
frFrame.Set( vVert[1], vtSeg15) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg15, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[1], vVert[5], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg26 = vVert[6] - vVert[2] ;
|
||||
double dLenSeg26 = vtSeg26.Len() ;
|
||||
frFrame.Set( vVert[2], vtSeg26) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg26, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[2], vVert[6], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
Vector3d vtSeg37 = vVert[7] - vVert[3] ;
|
||||
double dLenSeg37 = vtSeg37.Len();
|
||||
frFrame.Set( vVert[3], vtSeg37) ;
|
||||
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg37, trTria))
|
||||
if ( CDeSimpleCapsTria( vVert[3], vVert[7], dSafeDist, trTriaL))
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
|
||||
@@ -26,4 +26,4 @@ bool CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX,
|
||||
// asse X lungo un lato della stessa e asse Z ortogonale alle basi e diretta verso la base Top.
|
||||
bool CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
|
||||
double dLenghtTopX, double dLenghtTopY, double dHeight,
|
||||
double dSafeDist, const Triangle3d& trTria) ;
|
||||
const Triangle3d& trTria, double dSafeDist) ;
|
||||
|
||||
+60
-14
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CDCylSurfTm.cpp Data : 09.01.20 Versione : 2.2a2
|
||||
// File : CDCylSurfTm.cpp Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Implementazione della verifica di collisione tra
|
||||
// Sphere e Closed SurftriMesh.
|
||||
//
|
||||
//
|
||||
// Modifiche : 09.01.20 DS Creazione modulo.
|
||||
//
|
||||
// 24.03.24 DS Aggiunta TestSpheSurfTm.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -19,33 +19,79 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// La funzione restituisce :
|
||||
// - true in caso di collisione o inconsistenza dei parametri di input
|
||||
// - false in caso di assenza di collisione.
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const ISurfTriMesh& Stm)
|
||||
CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// recupero BBox del poliedro
|
||||
// Il raggio deve essere non nullo
|
||||
if ( dR < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida o aperta, non ha senso proseguire
|
||||
if ( ! Stm.IsValid() || ! Stm.IsClosed())
|
||||
return true ;
|
||||
// Recupero BBox del poliedro
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// calcolo il BBox della sfera
|
||||
// Calcolo il BBox della sfera
|
||||
BBox3d b3Sphe( ptCen, dR) ;
|
||||
b3Sphe.Expand( dSafeDist) ;
|
||||
// confronto i due Box
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3Sphe.Expand( dSafeDist) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Sphe.Overlaps( b3Poly))
|
||||
return false ;
|
||||
// recupero i triangoli che interferiscono con il box della Sfera
|
||||
// Verifico se la sfera interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Sphe, vT) ;
|
||||
for ( int nT : vT) {
|
||||
Triangle3d Tria ;
|
||||
if ( Stm.GetTriangle( nT, Tria)) {
|
||||
if ( CDeSpheTria( ptCen, dR, dSafeDist, Tria))
|
||||
if ( CDeSpheTria( ptCen, dR, Tria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Se superficie aperta, non c'è collisione
|
||||
if ( ! Stm.IsClosed())
|
||||
// Se il BBox della sfera non è interno a quello del poliedro e viceversa, non c'è collisione
|
||||
if ( ! b3Sphe.Encloses( b3Poly) && ! b3Poly.Encloses( b3Sphe))
|
||||
return false ;
|
||||
// Verifico se la sfera è dentro la superficie tramite calcolo distanza minima.
|
||||
// Verifico se la sfera è dentro la superficie tramite calcolo distanza minima del suo centro
|
||||
DistPointSurfTm DistCenSurfCalc( ptCen, Stm) ;
|
||||
// C'è collisione se la sfera è interna.
|
||||
// C'è collisione se la sfera è interna.
|
||||
return ( DistCenSurfCalc.IsPointInside()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Verifica l'interferenza tra la sfera e la superficie : restituisce true in caso di interferenza
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TestSpheSurfTm( const Point3d& ptCen, double dR, const ISurfTriMesh& Stm, double dSafeDist)
|
||||
{
|
||||
// Il raggio deve essere non nullo
|
||||
if ( dR < EPS_SMALL)
|
||||
return true ;
|
||||
// Se superficie non valida, non ha senso proseguire
|
||||
if ( ! Stm.IsValid())
|
||||
return true ;
|
||||
// Recupero BBox del poliedro
|
||||
BBox3d b3Poly = Stm.GetAllTriaBox() ;
|
||||
// Calcolo il BBox della sfera
|
||||
BBox3d b3Sphe( ptCen, dR) ;
|
||||
if ( dSafeDist > EPS_SMALL)
|
||||
b3Sphe.Expand( dSafeDist) ;
|
||||
// Se i BBox non interferiscono, non c'è collisione
|
||||
if ( ! b3Sphe.Overlaps( b3Poly))
|
||||
return false ;
|
||||
// Verifico se la sfera interferisce con i triangoli del poliedro presenti nel suo BBox
|
||||
INTVECTOR vT ;
|
||||
Stm.GetAllTriaOverlapBox( b3Sphe, vT) ;
|
||||
for ( int nT : vT) {
|
||||
Triangle3d Tria ;
|
||||
if ( Stm.GetTriangle( nT, Tria)) {
|
||||
if ( CDeSpheTria( ptCen, dR, Tria, dSafeDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
// Non c'è interferenza
|
||||
return false ;
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ CDeSimpleSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CDeSpheTria( const Point3d& ptCen, double dR, double dSafeDist, const Triangle3d& trTria)
|
||||
CDeSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria, double dSafeDist)
|
||||
{
|
||||
return CDeSimpleSpheTria( ptCen, dR + max( 0., dSafeDist), trTria) ;
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool CDeSimpleSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria) ;
|
||||
bool CDeSpheTria( const Point3d& ptCen, double dR, double dSafeDist, const Triangle3d& trTria) ;
|
||||
bool CDeSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria, double dSafeDist) ;
|
||||
|
||||
+8
-9
@@ -12,11 +12,10 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "DistLineLine.h"
|
||||
#include "CDeTriaTria.h"
|
||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
||||
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -34,7 +33,7 @@ GetTwoGreater( int nVal0, int nVal1, int nVal2, int& nFirstMaxPos, int& nSecondM
|
||||
}
|
||||
else {
|
||||
nFirstMaxPos = 2 ;
|
||||
nSecondMaxPos = 1 ;
|
||||
nSecondMaxPos = 0 ;
|
||||
}
|
||||
}
|
||||
else if ( nVal0 > nVal2) {
|
||||
@@ -109,7 +108,7 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
DistLineLine LineLineDistCalc( ptStA, PtEnA, ptStB, PtEnB) ;
|
||||
double dSqSegSegDist ;
|
||||
LineLineDistCalc.GetSqDist( dSqSegSegDist) ;
|
||||
if ( dSqSegSegDist < EPS_SMALL * EPS_SMALL)
|
||||
if ( dSqSegSegDist < SQ_EPS_SMALL)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
@@ -136,14 +135,14 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
vtSegFirstA /= dSegLenFirstA ;
|
||||
DistLineLine LineLineDistCalcFirstA( ptLineP, vtLineV, 100., trTriaA.GetP( nFirstMaxPosA), vtSegFirstA, dSegLenFirstA, false) ;
|
||||
double dIntParStA, dOtherParFirstA ;
|
||||
LineLineDistCalcFirstA.GetParamsAtMinDistPoints( dIntParStA, dOtherParFirstA) ;
|
||||
LineLineDistCalcFirstA.GetPositionsAtMinDistPoints( dIntParStA, dOtherParFirstA) ;
|
||||
// Limito la retta col secondo segmento trovato di A
|
||||
Vector3d vtSegSecondA = trTriaA.GetP( ( nSecondMaxPosA + 1) % 3) - trTriaA.GetP( nSecondMaxPosA) ;
|
||||
double dSegLenSecondA = vtSegSecondA.Len() ;
|
||||
vtSegSecondA /= dSegLenSecondA ;
|
||||
DistLineLine LineLineDistCalcSecondA( ptLineP, vtLineV, 100., trTriaA.GetP( nSecondMaxPosA), vtSegSecondA, dSegLenSecondA, false) ;
|
||||
double dIntParEnA, dOtherParSecondA ;
|
||||
LineLineDistCalcSecondA.GetParamsAtMinDistPoints( dIntParEnA, dOtherParSecondA) ;
|
||||
LineLineDistCalcSecondA.GetPositionsAtMinDistPoints( dIntParEnA, dOtherParSecondA) ;
|
||||
// Ordino i parametri lungo la retta di intersezione fra i piani
|
||||
if ( dIntParStA > dIntParEnA) {
|
||||
swap( dIntParStA, dIntParEnA) ;
|
||||
@@ -163,14 +162,14 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
|
||||
vtSegFirstB /= dSegLenFirstB ;
|
||||
DistLineLine LineLineDistCalcFirstB( ptLineP, vtLineV, 100., trTriaB.GetP( nFirstMaxPosB), vtSegFirstB, dSegLenFirstB, false) ;
|
||||
double dIntParStB, dOtherParFirstB ;
|
||||
LineLineDistCalcFirstB.GetParamsAtMinDistPoints( dIntParStB, dOtherParFirstB) ;
|
||||
LineLineDistCalcFirstB.GetPositionsAtMinDistPoints( dIntParStB, dOtherParFirstB) ;
|
||||
// Limito la retta col secondo segmento trovato di B
|
||||
Vector3d vtSegSecondB = trTriaB.GetP( ( nSecondMaxPosB + 1) % 3) - trTriaB.GetP( nSecondMaxPosB) ;
|
||||
double dSegLenSecondB = vtSegSecondB.Len() ;
|
||||
vtSegSecondB /= dSegLenSecondB ;
|
||||
DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosA), vtSegSecondB, dSegLenSecondB, false) ;
|
||||
DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosB), vtSegSecondB, dSegLenSecondB, false) ;
|
||||
double dIntParEnB, dOtherParSecondB ;
|
||||
LineLineDistCalcSecondB.GetParamsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
|
||||
LineLineDistCalcSecondB.GetPositionsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
|
||||
// Ordino i parametri lungo la retta di intersezione fra i piani
|
||||
if ( dIntParStB > dIntParEnB) {
|
||||
swap( dIntParStB, dIntParEnB) ;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "CDeUtility.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -368,4 +368,4 @@ ClampSegmentOutPlane( const Plane3d& plPlane, Point3d& ptSegP, const Vector3d& v
|
||||
dSegLen -= dIntersLen ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
+3315
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -13,9 +13,9 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EgkChainCurves.h"
|
||||
#include "/EgtDev/Include/EgkGeomDB.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2022-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Circle2P.cpp Data : 18.08.22 Versione : 2.4h2
|
||||
// Contenuto : Implementazione funzioni per calcolo circonferenze per 2 punti
|
||||
// diametrali.
|
||||
//
|
||||
//
|
||||
// Modifiche : 18.08.22 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCircle2P.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveArc*
|
||||
GetCircle2P( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtN)
|
||||
{
|
||||
// Verifico che i due punti siano distinti
|
||||
if ( AreSamePointEpsilon( ptP1, ptP2, EPS_SMALL))
|
||||
return nullptr ;
|
||||
// verifico che la normale non sia allineata con i punti
|
||||
Vector3d vtO = OrthoCompo( vtN, ptP2 - ptP1) ;
|
||||
if ( ! vtO.Normalize())
|
||||
return nullptr ;
|
||||
|
||||
// Creo l'oggetto arco
|
||||
PtrOwner<CurveArc> pCrvArc( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return nullptr ;
|
||||
|
||||
// Eseguo calcoli
|
||||
if ( ! pCrvArc->SetCPAN( Media( ptP1, ptP2), ptP1, ANG_FULL, 0, vtO))
|
||||
return nullptr ;
|
||||
|
||||
return Release( pCrvArc) ;
|
||||
}
|
||||
@@ -16,10 +16,10 @@
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "CreateCurveAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -239,7 +239,7 @@ GetCircleCenTgCompo( const Point3d& ptCen, const Vector3d& vtN, const CurveCompo
|
||||
double dSqDist = SqDist( ptNear, ptTg) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
dMinSqDist = dSqDist ;
|
||||
pCrvArc.Set( Release( pCrvAtmp)) ;
|
||||
pCrvArc.Set( pCrvAtmp) ;
|
||||
if ( pPtTg != nullptr)
|
||||
*pPtTg = ptTg ;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "/EgtDev/Include/EGkColor.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+289
-114
@@ -22,9 +22,12 @@
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <new>
|
||||
|
||||
@@ -59,13 +62,14 @@ class ArcApproxer
|
||||
//----------------------------------------------------------------------------
|
||||
CurveArc::CurveArc( void)
|
||||
: m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(),
|
||||
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick(), m_nTempProp{0,0}, m_dTempParam{0.0, 0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveArc::~CurveArc( void)
|
||||
{
|
||||
ResetVoronoiObject() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -87,7 +91,9 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad,
|
||||
// sistemo i versori
|
||||
m_VtN.Normalize() ;
|
||||
m_VtS.Normalize() ;
|
||||
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -113,6 +119,8 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad)
|
||||
m_dDeltaN = 0 ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -134,6 +142,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad, double dAngIniDeg, double dA
|
||||
m_dDeltaN = dDeltaZ ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -155,6 +165,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad)
|
||||
m_dDeltaN = 0 ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -177,7 +189,7 @@ CurveArc::Set3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d&
|
||||
// calcolo del versore normale
|
||||
m_VtN = vtA ^ vtB ;
|
||||
double dNSqLen = m_VtN.SqLen() ;
|
||||
// se i punti sono praticamente allineati non si può calcolare la circonferenza
|
||||
// se i punti sono praticamente allineati non si può calcolare la circonferenza
|
||||
if ( ! m_VtN.Normalize( EPS_ZERO))
|
||||
return false ;
|
||||
// calcolo del centro
|
||||
@@ -204,19 +216,21 @@ CurveArc::Set3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d&
|
||||
if ( ! m_VtS.GetRotation( ( ptEnd - m_PtCen), m_VtN, dAng2Deg, bDet2) || ! bDet2)
|
||||
return false ;
|
||||
// deduzione dell'angolo al centro
|
||||
// se uno dei due angoli è nullo, errore
|
||||
// se uno dei due angoli è nullo, errore
|
||||
if ( abs( dAng1Deg) < EPS_ANG_SMALL || abs( dAng2Deg) < EPS_ANG_SMALL)
|
||||
return false ;
|
||||
// se i due angoli hanno lo stesso segno e Ang1 è minore di Ang2 in modulo
|
||||
// se i due angoli hanno lo stesso segno e Ang1 è minore di Ang2 in modulo
|
||||
else if ( dAng1Deg * dAng2Deg > 0 && abs( dAng1Deg) < abs( dAng2Deg))
|
||||
m_dAngCenDeg = dAng2Deg ;
|
||||
// altrimenti hanno segno opposto oppure Ang1 è maggiore di Ang2 in modulo
|
||||
// altrimenti hanno segno opposto oppure Ang1 è maggiore di Ang2 in modulo
|
||||
else
|
||||
m_dAngCenDeg = - _copysign( ANG_FULL, dAng2Deg) + dAng2Deg ;
|
||||
}
|
||||
// non c'è DeltaN
|
||||
// non c'è DeltaN
|
||||
m_dDeltaN = 0 ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -241,7 +255,7 @@ CurveArc::Set2PNB( const Point3d& ptIni, const Point3d& ptFin, const Vector3d& v
|
||||
Vector3d vtDiff = ptFin - ptIni ;
|
||||
if ( vtDiff.IsSmall())
|
||||
return false ;
|
||||
// deltaN eventuale ( è componente parallela a VtN)
|
||||
// deltaN eventuale ( è componente parallela a VtN)
|
||||
m_dDeltaN = vtDiff * m_VtN ;
|
||||
vtDiff -= m_dDeltaN * m_VtN ;
|
||||
if ( abs( m_dDeltaN) < EPS_SMALL)
|
||||
@@ -264,6 +278,8 @@ CurveArc::Set2PNB( const Point3d& ptIni, const Point3d& ptFin, const Vector3d& v
|
||||
// calcolo l'angolo al centro
|
||||
m_dAngCenDeg = 4 * atan( dBulge) * RADTODEG ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -288,7 +304,7 @@ CurveArc::Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStart
|
||||
// calcolo del versore normale
|
||||
m_VtN = vtA ^ vtB ;
|
||||
double dNSqLen = m_VtN.SqLen() ;
|
||||
// se tangente e punti sono praticamente allineati non si può calcolare la circonferenza
|
||||
// se tangente e punti sono praticamente allineati non si può calcolare la circonferenza
|
||||
if ( ! m_VtN.Normalize( EPS_ZERO))
|
||||
return false ;
|
||||
// calcolo del centro
|
||||
@@ -305,7 +321,7 @@ CurveArc::Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStart
|
||||
double dAng1Deg ;
|
||||
if ( ! m_VtS.GetRotation( ( ptEnd - m_PtCen), m_VtN, dAng1Deg, bDet1) || ! bDet1)
|
||||
return false ;
|
||||
// poichè il senso di rotazione è sempre CCW, se l'angolo è negativo prendo il suo complemento al giro
|
||||
// poichè il senso di rotazione è sempre CCW, se l'angolo è negativo prendo il suo complemento al giro
|
||||
if ( dAng1Deg < 0)
|
||||
m_dAngCenDeg = ANG_FULL + dAng1Deg ;
|
||||
else
|
||||
@@ -320,6 +336,8 @@ CurveArc::Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStart
|
||||
m_dDeltaN = - m_dDeltaN ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -396,12 +414,14 @@ CurveArc::Set2PRS( const Point3d& ptStart, const Point3d& ptEnd, double dRad, bo
|
||||
bool bDet ;
|
||||
if ( ! m_VtS.GetRotation( ( ptEnd - m_PtCen), m_VtN, m_dAngCenDeg, bDet) || ! bDet)
|
||||
return false ;
|
||||
// quando è 180deg il segno è determinato solo dal senso
|
||||
// quando è 180deg il segno è determinato solo dal senso
|
||||
if ( abs( m_dAngCenDeg - ANG_STRAIGHT) < 10 * EPS_ANG_SMALL &&
|
||||
( ( bCCW && m_dAngCenDeg < 0) ||
|
||||
( ! bCCW && m_dAngCenDeg > 0)))
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -456,6 +476,8 @@ CurveArc::SetCPA( const Point3d& ptCen, const Point3d& ptStart, double dAngCenDe
|
||||
// assegno l'angolo al centro
|
||||
m_dAngCenDeg = dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -507,11 +529,12 @@ CurveArc::SetC2P( const Point3d& ptCen, const Point3d& ptStart, const Point3d& p
|
||||
if ( m_dRad < EPS_ZERO)
|
||||
return false ;
|
||||
m_VtS /= m_dRad ;
|
||||
// calcolo l'angolo al centro (la funzione trova sempre il più piccolo)
|
||||
// calcolo l'angolo al centro (la funzione trova sempre il più piccolo)
|
||||
bool bDet ;
|
||||
if ( ! m_VtS.GetRotation( ( ptNearEnd - m_PtCen), m_VtN, m_dAngCenDeg, bDet) || ! bDet)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -564,7 +587,7 @@ CurveArc::Clone( void) const
|
||||
bool
|
||||
CurveArc::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const CurveArc* pCA = dynamic_cast<const CurveArc*>( pGObjSrc) ;
|
||||
const CurveArc* pCA = GetBasicCurveArc( pGObjSrc) ;
|
||||
if ( pCA == nullptr)
|
||||
return false ;
|
||||
return CopyFrom( *pCA) ;
|
||||
@@ -578,7 +601,10 @@ CurveArc::CopyFrom( const CurveArc& caSrc)
|
||||
return true ;
|
||||
m_VtExtr = caSrc.m_VtExtr ;
|
||||
m_dThick = caSrc.m_dThick ;
|
||||
m_nTempProp = caSrc.m_nTempProp ;
|
||||
m_nTempProp[0] = caSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = caSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = caSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = caSrc.m_dTempParam[1] ;
|
||||
return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad,
|
||||
caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ;
|
||||
}
|
||||
@@ -696,29 +722,8 @@ CurveArc::Load( NgeReader& ngeIn)
|
||||
bool
|
||||
CurveArc::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
{
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// assegno il box in locale
|
||||
b3Loc.Reset() ;
|
||||
double dLinTol = LIN_TOL_APPROX ;
|
||||
double dAngTolDeg = ANG_TOL_APPROX_DEG ;
|
||||
if ( ( nFlag & BBF_EXACT) != 0)
|
||||
dLinTol = LIN_TOL_MIN ;
|
||||
ArcApproxer aAppr( dLinTol, dAngTolDeg, false, *this) ;
|
||||
double dU ;
|
||||
Point3d ptPos ;
|
||||
while ( aAppr.GetPoint( dU, ptPos))
|
||||
b3Loc.Add( ptPos) ;
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
|
||||
Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ;
|
||||
Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ;
|
||||
b3Loc.Add( ptMinExtr) ;
|
||||
b3Loc.Add( ptMaxExtr) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
// richiamo della funzione generale
|
||||
return GetBBox( GLOB_FRM, b3Loc, nFlag) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -728,23 +733,94 @@ CurveArc::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// assegno il box nel riferimento
|
||||
b3Ref.Reset() ;
|
||||
double dLinTol = LIN_TOL_APPROX ;
|
||||
double dAngTolDeg = ANG_TOL_APPROX_DEG ;
|
||||
if ( ( nFlag & BBF_EXACT) != 0)
|
||||
dLinTol = LIN_TOL_MIN ;
|
||||
ArcApproxer aAppr( dLinTol, dAngTolDeg, false, *this) ;
|
||||
double dU ;
|
||||
Point3d ptPos ;
|
||||
while ( aAppr.GetPoint( dU, ptPos)) {
|
||||
ptPos.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptPos) ;
|
||||
|
||||
// ricavo il riferimento intrinseco dell'arco
|
||||
Frame3d frArc;
|
||||
frArc.Set( m_PtCen, ( m_dAngCenDeg > 0 ? m_VtN : -m_VtN), m_VtS) ;
|
||||
|
||||
// pendenza intrinseca
|
||||
double dPitch = m_dDeltaN * ( m_dAngCenDeg > 0 ? 1 : -1) / abs( m_dAngCenDeg * DEGTORAD) ;
|
||||
|
||||
// cordinate nel frRef dei versori del sistema di riferimento dell'arco
|
||||
Vector3d vtXRef = frArc.VersX() ;
|
||||
vtXRef.ToGlob( frRef) ;
|
||||
Vector3d vtYRef = frArc.VersY() ;
|
||||
vtYRef.ToGlob( frRef) ;
|
||||
Vector3d vtZRef = frArc.VersZ() ;
|
||||
vtZRef.ToGlob( frRef) ;
|
||||
|
||||
// il punto iniziale e finale sono punti candidati per estremanti
|
||||
Point3d ptS, ptE ;
|
||||
GetStartPoint( ptS) ;
|
||||
ptS.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptS) ;
|
||||
GetEndPoint( ptE) ;
|
||||
ptE.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptE) ;
|
||||
|
||||
// vettore degli angoli dei punti candidati estremi
|
||||
DBLVECTOR vdTheta ;
|
||||
|
||||
// arco piatto
|
||||
if ( abs( dPitch) < EPS_SMALL) {
|
||||
double dAngXDeg = atan2( vtYRef.x, vtXRef.x) * RADTODEG ;
|
||||
bool bAngXSmall = (abs( dAngXDeg) <= EPS_ANG_ZERO) ;
|
||||
if ( ! bAngXSmall) {
|
||||
vdTheta.push_back( dAngXDeg) ;
|
||||
vdTheta.push_back( dAngXDeg + ANG_STRAIGHT) ;
|
||||
}
|
||||
double dAngYDeg = atan2( vtYRef.y, vtXRef.y) * RADTODEG ;
|
||||
bool bAngYSmall = (abs( dAngYDeg) <= EPS_ANG_ZERO) ;
|
||||
if ( ! bAngYSmall) {
|
||||
vdTheta.push_back( dAngYDeg) ;
|
||||
vdTheta.push_back( dAngYDeg + ANG_STRAIGHT) ;
|
||||
}
|
||||
double dAngZDeg = atan2( vtYRef.z, vtXRef.z) * RADTODEG ;
|
||||
bool bAngZSmall = (abs( dAngZDeg) <= EPS_ANG_ZERO) ;
|
||||
if ( ! bAngZSmall) {
|
||||
vdTheta.push_back( dAngZDeg) ;
|
||||
vdTheta.push_back( dAngZDeg + ANG_STRAIGHT) ;
|
||||
}
|
||||
if ( bAngXSmall || bAngYSmall || bAngZSmall)
|
||||
vdTheta.push_back( ANG_STRAIGHT) ;
|
||||
}
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
// altrimenti arco di elica
|
||||
else {
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
DBLVECTOR vdPoly{ m_dRad * vtYRef.v[i] + dPitch * vtZRef.v[i],
|
||||
- 2 * m_dRad * vtXRef.v[i],
|
||||
- m_dRad * vtYRef.v[i] + dPitch * vtZRef.v[i]} ;
|
||||
DBLVECTOR vdRoot ;
|
||||
int nRoot = PolynomialRoots( 2, vdPoly, vdRoot) ;
|
||||
for ( int i = 0 ; i < nRoot ; ++ i) {
|
||||
double dAngDeg = atan2( 2 * vdRoot[i], (1 - vdRoot[i] * vdRoot[i])) * RADTODEG ;
|
||||
if ( abs( dAngDeg) > EPS_ANG_ZERO) {
|
||||
vdTheta.push_back( dAngDeg) ;
|
||||
vdTheta.push_back( dAngDeg + ANG_STRAIGHT) ;
|
||||
}
|
||||
else
|
||||
vdTheta.push_back( ANG_STRAIGHT) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verifica degli angoli sull'arco ed eventuale considerazione dei punti
|
||||
for ( int i = 0 ; i < int( vdTheta.size()) ; ++ i) {
|
||||
double dTheta = ( vdTheta[i] > 0 ? vdTheta[i] : vdTheta[i] + ANG_FULL) ;
|
||||
if ( dTheta < abs( m_dAngCenDeg)) {
|
||||
Point3d ptP ;
|
||||
GetPointD1D2( dTheta / ( abs( m_dAngCenDeg)), FROM_MINUS, ptP) ;
|
||||
ptP.ToGlob( frRef) ;
|
||||
b3Ref.Add( ptP) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
|
||||
Vector3d vtFrExtr = m_VtExtr ;
|
||||
vtFrExtr.ToGlob( frRef) ;
|
||||
@@ -762,7 +838,7 @@ bool
|
||||
CurveArc::Validate( void)
|
||||
{
|
||||
if ( m_nStatus == TO_VERIFY) {
|
||||
// limito l'angolo al centro a un giro se è piatto ( non è elica)
|
||||
// limito l'angolo al centro a un giro se è piatto ( non è elica)
|
||||
if ( abs( m_dDeltaN) < EPS_SMALL) {
|
||||
if ( m_dAngCenDeg > ANG_FULL)
|
||||
m_dAngCenDeg = ANG_FULL ;
|
||||
@@ -770,10 +846,10 @@ CurveArc::Validate( void)
|
||||
m_dAngCenDeg = - ANG_FULL ;
|
||||
}
|
||||
// eseguo il controllo
|
||||
m_nStatus = ( ( m_VtN.IsNormalized() && m_VtS.IsNormalized() &&
|
||||
AreOrthoApprox( m_VtN, m_VtS) &&
|
||||
m_dRad > EPS_SMALL && m_dRad < MAX_ARC_RAD &&
|
||||
abs( m_dAngCenDeg) > EPS_ANG_ZERO) ? OK : ERR) ;
|
||||
m_nStatus = ( ( m_PtCen.IsValid() &&
|
||||
m_VtN.IsNormalized() && m_VtS.IsNormalized() && AreOrthoApprox( m_VtN, m_VtS) &&
|
||||
m_dRad > EPS_SMALL && m_dRad < MAX_ARC_RAD &&
|
||||
abs( m_dAngCenDeg) > EPS_ANG_ZERO) ? OK : ERR) ;
|
||||
}
|
||||
|
||||
return ( m_nStatus == OK) ;
|
||||
@@ -828,7 +904,7 @@ CurveArc::GetEndPoint( Point3d& ptEnd) const
|
||||
double dAng = m_dAngCenDeg * DEGTORAD ;
|
||||
Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
|
||||
ptEnd = m_PtCen + m_dRad * vtDir ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
ptEnd += m_dDeltaN * m_VtN ;
|
||||
|
||||
return true ;
|
||||
@@ -846,7 +922,7 @@ CurveArc::GetMidPoint( Point3d& ptMid) const
|
||||
double dAng = 0.5 * m_dAngCenDeg * DEGTORAD ;
|
||||
Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
|
||||
ptMid = m_PtCen + m_dRad * vtDir ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
ptMid += ( 0.5 * m_dDeltaN) * m_VtN ;
|
||||
|
||||
return true ;
|
||||
@@ -874,7 +950,7 @@ CurveArc::GetCentroid( Point3d& ptCen) const
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, APL_STD, PL))
|
||||
return false ;
|
||||
// calcolo il centro mediante PolygonPlane
|
||||
Point3d ptP ;
|
||||
@@ -896,17 +972,14 @@ CurveArc::GetDir( double dU, Vector3d& vtDir) const
|
||||
return false ;
|
||||
|
||||
// il parametro U deve essere compreso tra 0 e 1
|
||||
if ( dU < 0)
|
||||
dU = 0 ;
|
||||
else if ( dU > 1)
|
||||
dU = 1 ;
|
||||
dU = Clamp( dU, 0., 1.) ;
|
||||
|
||||
// versore al punto nel piano della circonferenza (ruoto m_VtS di dU * m_dAngCenDeg attorno a m_VtN)
|
||||
double dAng = dU * m_dAngCenDeg * DEGTORAD ;
|
||||
Vector3d vtRad = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
|
||||
// calcolo della tangente nel punto finale
|
||||
vtDir = ( m_dRad * m_dAngCenDeg * DEGTORAD) * ( m_VtN ^ vtRad) ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
vtDir += m_dDeltaN * m_VtN ;
|
||||
// normalizzo
|
||||
return vtDir.Normalize( EPS_ZERO) ;
|
||||
@@ -921,10 +994,7 @@ CurveArc::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1, V
|
||||
return false ;
|
||||
|
||||
// il parametro U deve essere compreso tra 0 e 1
|
||||
if ( dU < 0)
|
||||
dU = 0 ;
|
||||
else if ( dU > 1)
|
||||
dU = 1 ;
|
||||
dU = Clamp( dU, 0., 1.) ;
|
||||
|
||||
// versore al punto nel piano della circonferenza (ruoto m_VtS di dU di m_dAngCenDeg attorno a m_VtN)
|
||||
double dAng = dU * m_dAngCenDeg * DEGTORAD ;
|
||||
@@ -932,13 +1002,13 @@ CurveArc::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1, V
|
||||
|
||||
// calcolo del punto
|
||||
ptPos = m_PtCen + m_dRad * vtDir ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
ptPos += ( dU * m_dDeltaN) * m_VtN ;
|
||||
|
||||
// calcolo della derivata prima
|
||||
if ( pvtDer1 != nullptr) {
|
||||
*pvtDer1 = ( m_dRad * m_dAngCenDeg * DEGTORAD) * ( m_VtN ^ vtDir) ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
*pvtDer1 += m_dDeltaN * m_VtN ;
|
||||
}
|
||||
|
||||
@@ -960,7 +1030,7 @@ CurveArc::GetLength( double& dLen) const
|
||||
// lunghezza dell'arco piano
|
||||
dLen = m_dRad * abs( m_dAngCenDeg) * DEGTORAD ;
|
||||
// aggiunta eventuale parte ortogonale
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
dLen = sqrt( dLen * dLen + m_dDeltaN * m_dDeltaN) ;
|
||||
|
||||
return ( dLen > EPS_SMALL) ;
|
||||
@@ -1097,7 +1167,7 @@ CurveArc::ApproxWithLines( double dLinTol, double dAngTolDeg, int nType, PolyLin
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se necessario, sistemo per convessità dalla parte ammessa
|
||||
// se necessario, sistemo per convessità dalla parte ammessa
|
||||
if ( nType == APL_RIGHT_CONVEX || nType == APL_LEFT_CONVEX) {
|
||||
if ( ! PL.MakeConvex( vtExtr, ( nType == APL_LEFT_CONVEX)))
|
||||
return false ;
|
||||
@@ -1171,7 +1241,7 @@ CurveArc::CopyParamRange( double dUStart, double dUEnd) const
|
||||
return nullptr ;
|
||||
// se il parametro start supera quello di end
|
||||
if ( dUStart > dUEnd - EPS_PARAM) {
|
||||
// se curva aperta, il trim la cancella completamente quindi non resta alcunchè
|
||||
// se curva aperta, il trim la cancella completamente quindi non resta alcunchè
|
||||
if ( ! IsClosed())
|
||||
return nullptr ;
|
||||
// se curva chiusa, il trim si avvolge attorno al punto di giunzione
|
||||
@@ -1201,7 +1271,7 @@ CurveArc::Invert( void)
|
||||
return false ;
|
||||
|
||||
// il centro va spostato di DeltaN
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
m_PtCen += m_dDeltaN * m_VtN ;
|
||||
// il versore normale rimane inalterato
|
||||
// il versore iniziale diventa quello finale
|
||||
@@ -1212,7 +1282,9 @@ CurveArc::Invert( void)
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
// l'incremento sulla normale inverte il segno
|
||||
m_dDeltaN = - m_dDeltaN ;
|
||||
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1246,6 +1318,8 @@ CurveArc::SimpleOffset( double dDist, int nType)
|
||||
// aggiorno il raggio
|
||||
m_dRad = dNewRad ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1257,7 +1331,7 @@ bool
|
||||
CurveArc::MyExtendedOffset( double dDist, bool bAll, int nType)
|
||||
{
|
||||
// bAll == true fa accettare raggi nulli ==> da usare solo internamente
|
||||
// quando si è sicuri di aumentare subito il raggio o di cancellare
|
||||
// quando si è sicuri di aumentare subito il raggio o di cancellare
|
||||
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
@@ -1290,6 +1364,8 @@ CurveArc::MyExtendedOffset( double dDist, bool bAll, int nType)
|
||||
// aggiorno il raggio
|
||||
m_dRad = dNewRad ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1333,7 +1409,7 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
|
||||
ptOldEndIntr.ToLoc( frIntr) ;
|
||||
Point3d ptEndIntr = ptNewEnd ;
|
||||
ptEndIntr.ToLoc( frIntr) ;
|
||||
// se coincidono nel piano XY, è cambiato solo il deltaN
|
||||
// se coincidono nel piano XY, è cambiato solo il deltaN
|
||||
if ( AreSamePointXYExact( ptOldEndIntr, ptEndIntr)) {
|
||||
m_dDeltaN += ptEndIntr.z - ptOldEndIntr.z ;
|
||||
}
|
||||
@@ -1362,6 +1438,8 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
|
||||
m_dDeltaN = arcAux.m_dDeltaN ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1372,13 +1450,11 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
|
||||
bool
|
||||
CurveArc::TrimStartAtParam( double dUTrim)
|
||||
{
|
||||
double dLen ;
|
||||
|
||||
|
||||
// riporto i parametri nel loro range
|
||||
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
|
||||
dUTrim = Clamp( dUTrim, 0., 1.) ;
|
||||
|
||||
// recupero lunghezza
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
return false ;
|
||||
|
||||
@@ -1390,13 +1466,11 @@ CurveArc::TrimStartAtParam( double dUTrim)
|
||||
bool
|
||||
CurveArc::TrimEndAtParam( double dUTrim)
|
||||
{
|
||||
double dLen ;
|
||||
|
||||
|
||||
// riporto i parametri nel loro range
|
||||
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
|
||||
dUTrim = Clamp( dUTrim, 0., 1.) ;
|
||||
|
||||
// recupero lunghezza
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
return false ;
|
||||
|
||||
@@ -1444,13 +1518,15 @@ CurveArc::TrimStartAtLen( double dLenTrim)
|
||||
dAngRot = m_dAngCenDeg * dLenTrim / dLen ;
|
||||
m_VtS.Rotate( m_VtN, dAngRot) ;
|
||||
m_dAngCenDeg -= dAngRot ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL) {
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL) {
|
||||
dMoveN = m_dDeltaN * dLenTrim / dLen ;
|
||||
m_PtCen.Translate( m_VtN * dMoveN) ;
|
||||
m_dDeltaN -= dMoveN ;
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1474,10 +1550,12 @@ CurveArc::TrimEndAtLen( double dLenTrim)
|
||||
// eseguo il trim
|
||||
if ( ( dLen - dLenTrim) > EPS_ZERO) {
|
||||
m_dAngCenDeg *= dLenTrim / dLen ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
m_dDeltaN *= dLenTrim / dLen ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1521,6 +1599,8 @@ CurveArc::ExtendEndByLen( double dLenExt)
|
||||
else if ( abs( m_dAngCenDeg) > ANG_FULL)
|
||||
m_dAngCenDeg = _copysign( ANG_FULL, m_dAngCenDeg) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1535,6 +1615,10 @@ CurveArc::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// traslo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1552,10 +1636,14 @@ CurveArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dell'asse di rotazione
|
||||
// verifico validità dell'asse di rotazione
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// ruoto Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1585,6 +1673,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1612,6 +1702,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffY) < EPS_ZERO || m_dRad * abs( dCoeffY) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1639,6 +1731,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffZ) < EPS_ZERO || m_dRad * abs( dCoeffZ) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1666,6 +1760,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
// verifico non sia nulla
|
||||
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
|
||||
return false ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// scalo il centro e le dimensioni lineari
|
||||
@@ -1695,10 +1791,12 @@ CurveArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del piano di specchiatura
|
||||
// verifico validità del piano di specchiatura
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1721,15 +1819,17 @@ CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei parametri
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// possibile solo se l'arco è piatto e il piano di scorrimento coincide con quello dell'arco
|
||||
// possibile solo se l'arco è piatto e il piano di scorrimento coincide con quello dell'arco
|
||||
if ( ! ( abs( m_dDeltaN) < EPS_SMALL) ||
|
||||
! AreSameOrOppositeVectorExact( m_VtN, vtNorm))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1753,11 +1853,18 @@ CurveArc::ToGlob( const Frame3d& frRef)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1775,11 +1882,18 @@ CurveArc::ToLoc( const Frame3d& frRef)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->ToLoc( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1797,14 +1911,21 @@ CurveArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei frame
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->LocToLoc( frOri, frDest) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo il centro e i versori
|
||||
return ( m_PtCen.LocToLoc( frOri, frDest) &&
|
||||
m_VtN.LocToLoc( frOri, frDest) &&
|
||||
@@ -1825,6 +1946,8 @@ CurveArc::InvertN( void)
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
m_dDeltaN = - m_dDeltaN ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1876,12 +1999,12 @@ CurveArc::MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, doub
|
||||
// verifica posizione punto su arco
|
||||
nPos = PP_NULL ; // fuori
|
||||
if ( abs( DiffAngle( dAngDeg, 0) * DEGTORAD * m_dRad) < dLinTol) {
|
||||
nPos = ( IsACircle() ? PP_MID : PP_START) ; // se cerchio è interno, altrimenti vicino a inizio
|
||||
nPos = ( IsACircle() ? PP_MID : PP_START) ; // se cerchio è interno, altrimenti vicino a inizio
|
||||
dU = AngleNearAngle( dAngDeg, 0) / m_dAngCenDeg ;
|
||||
dU = max( dU, 0.) ;
|
||||
}
|
||||
else if ( abs( DiffAngle( dAngDeg, m_dAngCenDeg) * DEGTORAD * m_dRad) < dLinTol) {
|
||||
nPos = ( IsACircle() ? PP_MID : PP_END) ; // se cerchio è interno, altrimenti vicino a fine
|
||||
nPos = ( IsACircle() ? PP_MID : PP_END) ; // se cerchio è interno, altrimenti vicino a fine
|
||||
dU = AngleNearAngle( dAngDeg, m_dAngCenDeg) / m_dAngCenDeg ;
|
||||
dU = min( dU, 1.) ;
|
||||
}
|
||||
@@ -1898,9 +2021,15 @@ CurveArc::ChangeRadius( double dNewRadius)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del raggio
|
||||
if ( ! ( dNewRadius > EPS_SMALL && dNewRadius < MAX_ARC_RAD))
|
||||
return false ;
|
||||
|
||||
// cambio il raggio
|
||||
m_dRad = dNewRadius ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1920,6 +2049,8 @@ CurveArc::ChangeDeltaN( double dNewDeltaN)
|
||||
// cambio il parametro
|
||||
m_dDeltaN = dNewDeltaN ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1936,9 +2067,15 @@ CurveArc::ChangeAngCenter( double dNewAngCenDeg)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico accettabilità angolo
|
||||
if ( ! ( abs( m_dAngCenDeg) > EPS_ANG_ZERO))
|
||||
return false ;
|
||||
|
||||
// cambio il parametro
|
||||
m_dAngCenDeg = dNewAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1963,6 +2100,8 @@ CurveArc::ChangeStartPoint( double dU)
|
||||
if ( ! vtDir.Normalize())
|
||||
return false ;
|
||||
m_VtS = vtDir ;
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -1982,6 +2121,8 @@ CurveArc::ToExplementary( void)
|
||||
// basta prendere l'angolo al centro che completa il giro
|
||||
m_dAngCenDeg = - _copysign( ANG_FULL, m_dAngCenDeg) + m_dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2011,6 +2152,8 @@ CurveArc::Flip( void)
|
||||
m_VtS.Normalize() ;
|
||||
m_dAngCenDeg = - m_dAngCenDeg ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2020,18 +2163,14 @@ CurveArc::Flip( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Oggetto locale per approssimazione di archi
|
||||
// Approx interna è quella cordale standard.
|
||||
// Approx esterna è quella tangente a inizio e fine con metà tratto e un punto in più.
|
||||
// Approx interna è quella cordale standard.
|
||||
// Approx esterna è quella tangente a inizio e fine con metà tratto e un punto in più.
|
||||
// I punti si calcolano a partire dal triangolo tra due punti consecutivi interni e il centro,
|
||||
// usando il versore medio dal centro e moltiplicandolo per il coefficiente ( 2 / ( 1 + cosA)).
|
||||
// Il versore dell'ultimo punto è già stato calcolato per il penultimo.
|
||||
// Il versore dell'ultimo punto è già stato calcolato per il penultimo.
|
||||
//----------------------------------------------------------------------------
|
||||
ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc)
|
||||
{
|
||||
int nStep ;
|
||||
double dAngStepDeg ;
|
||||
|
||||
|
||||
// inizializzazioni
|
||||
m_nTotPnt = 0 ;
|
||||
m_nCurrPnt = - 1 ;
|
||||
@@ -2049,6 +2188,7 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
dAngTolDeg = min( dAngTolDeg, ANG_TOL_EXT_MAX_DEG) ;
|
||||
|
||||
// determinazione dello step angolare
|
||||
double dAngStepDeg ;
|
||||
double dLinTolRel = dLinTol / arArc.GetRadius() ;
|
||||
if ( bInside)
|
||||
dAngStepDeg = sqrt( 8 * dLinTolRel) * RADTODEG ;
|
||||
@@ -2057,7 +2197,7 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
dAngStepDeg = min( dAngStepDeg, dAngTolDeg) ;
|
||||
|
||||
// dall'angolo al centro ricavo il numero di passi
|
||||
nStep = (int) ( abs( arArc.GetAngCenter()) / dAngStepDeg + 0.999) ;
|
||||
int nStep = int( abs( arArc.GetAngCenter()) / dAngStepDeg + 0.999) ;
|
||||
nStep = max( nStep, 1) ;
|
||||
|
||||
// sistemo lo step (per il numero intero di passi)
|
||||
@@ -2084,10 +2224,6 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
bool
|
||||
ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
{
|
||||
Vector3d vtA1p ;
|
||||
Vector3d vtA2p ;
|
||||
|
||||
|
||||
// incremento indice punto corrente
|
||||
++ m_nCurrPnt ;
|
||||
|
||||
@@ -2106,7 +2242,7 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
if ( ! m_bInside && m_nCurrPnt == m_nTotPnt - 1) {
|
||||
dU = 1 ;
|
||||
ptP = m_PtCen + m_vtA1 * m_dRad ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
ptP += ( dU * m_dDeltaN) * m_VtN ;
|
||||
return true ;
|
||||
}
|
||||
@@ -2118,8 +2254,8 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
else
|
||||
dU = ( m_nCurrPnt - 0.5) / (double) ( m_nTotPnt - 2) ;
|
||||
// nuovo valore versori
|
||||
vtA1p = m_vtA1 ;
|
||||
vtA2p = m_vtA2 ;
|
||||
Vector3d vtA1p = m_vtA1 ;
|
||||
Vector3d vtA2p = m_vtA2 ;
|
||||
m_vtA1 = m_dCosA * vtA1p + m_dSinA * vtA2p ;
|
||||
m_vtA2 = - m_dSinA * vtA1p + m_dCosA * vtA2p ;
|
||||
// calcolo del punto
|
||||
@@ -2127,8 +2263,47 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
|
||||
ptP = m_PtCen + m_vtA1 * m_dRad ;
|
||||
else
|
||||
ptP = m_PtCen + ( vtA1p + m_vtA1) * ( m_dRad / ( 1 + m_dCosA)) ;
|
||||
if ( abs( m_dDeltaN) > EPS_SMALL)
|
||||
if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
|
||||
ptP += ( dU * m_dDeltaN) * m_VtN ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveArc::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveArc::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+31
-11
@@ -19,6 +19,8 @@
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
{
|
||||
@@ -49,10 +51,16 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -178,11 +186,14 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
CurveArc( void) ;
|
||||
CurveArc( const CurveArc& caSrc)
|
||||
CurveArc( const CurveArc& caSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( caSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveArc : copy constructor error")}
|
||||
CurveArc& operator =( const CurveArc& caSrc)
|
||||
@@ -191,11 +202,14 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ;
|
||||
bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ;
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveArc& caSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool GetDir( double dU, Vector3d& vtDir) const ;
|
||||
bool GetDir( double dU, Vector3d& vtDir) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
@@ -211,17 +225,23 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
double m_dDeltaN ; // variazione di quota lungo VtN della fine rispetto all'inizio
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CurveArc* CreateBasicCurveArc( void)
|
||||
{ return (static_cast<CurveArc*>( CreateGeoObj( CRV_ARC))) ; }
|
||||
{ return ( static_cast<CurveArc*>( CreateGeoObj( CRV_ARC))) ; }
|
||||
inline CurveArc* CloneBasicCurveArc( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_ARC)
|
||||
return nullptr ;
|
||||
return (static_cast<CurveArc*>(pGObj->Clone())) ; }
|
||||
return ( static_cast<CurveArc*>( pGObj->Clone())) ; }
|
||||
inline const CurveArc* GetBasicCurveArc( const IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<const CurveArc*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_ARC)
|
||||
return nullptr ;
|
||||
return ( static_cast<const CurveArc*>( pGObj)) ; }
|
||||
inline CurveArc* GetBasicCurveArc( IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<CurveArc*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_ARC)
|
||||
return nullptr ;
|
||||
return ( static_cast<CurveArc*>( pGObj)) ; }
|
||||
|
||||
+640
-47
@@ -2,7 +2,7 @@
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CurveAux.cpp Data : 22.11.13 Versione : 1.3a1
|
||||
// Contenuto : Implementazione di alcune funzioni di utilità per le curve.
|
||||
// Contenuto : Implementazione di alcune funzioni di utilità per le curve.
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "CurveArc.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
@@ -30,16 +31,15 @@ using namespace std ;
|
||||
bool
|
||||
IsClosed( const ICurve& crvC)
|
||||
{
|
||||
Point3d ptStart ;
|
||||
Point3d ptEnd ;
|
||||
return ( crvC.GetStartPoint( ptStart) && crvC.GetEndPoint( ptEnd) && AreSamePointApprox( ptStart, ptEnd)) ;
|
||||
Point3d ptStart, ptEnd ;
|
||||
return ( crvC.GetStartPoint( ptStart) && crvC.GetEndPoint( ptEnd) && AreSamePointApprox( ptStart, ptEnd)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide)
|
||||
{
|
||||
// recupero l'intervallo di validità del parametro
|
||||
// recupero l'intervallo di validità del parametro
|
||||
double dStart, dEnd ;
|
||||
if ( ! crvC.GetDomain( dStart, dEnd))
|
||||
return false ;
|
||||
@@ -60,11 +60,11 @@ IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide)
|
||||
bool
|
||||
IsStartParam( const ICurve& crvC, double dPar)
|
||||
{
|
||||
// recupero l'intervallo di validità del parametro
|
||||
// recupero l'intervallo di validità del parametro
|
||||
double dStart, dEnd ;
|
||||
if ( ! crvC.GetDomain( dStart, dEnd))
|
||||
return false ;
|
||||
// se il parametro non è nell'intorno dell'inizio
|
||||
// se il parametro non è nell'intorno dell'inizio
|
||||
if ( abs( dPar - dStart) > EPS_PARAM)
|
||||
return false ;
|
||||
return true ;
|
||||
@@ -74,11 +74,11 @@ IsStartParam( const ICurve& crvC, double dPar)
|
||||
bool
|
||||
IsEndParam( const ICurve& crvC, double dPar)
|
||||
{
|
||||
// recupero l'intervallo di validità del parametro
|
||||
// recupero l'intervallo di validità del parametro
|
||||
double dStart, dEnd ;
|
||||
if ( ! crvC.GetDomain( dStart, dEnd))
|
||||
return false ;
|
||||
// se il parametro non è nell'intorno della fine
|
||||
// se il parametro non è nell'intorno della fine
|
||||
if ( abs( dPar - dEnd) > EPS_PARAM)
|
||||
return false ;
|
||||
return true ;
|
||||
@@ -98,7 +98,7 @@ GetNearestExtremityToPoint( const Point3d& ptP, const ICurve& Curve, bool& bStar
|
||||
return false ;
|
||||
// se curva aperta
|
||||
if ( ! AreSamePointApprox( ptStart, ptEnd)) {
|
||||
// è il più vicino tra inizio e fine
|
||||
// è il più vicino tra inizio e fine
|
||||
bStart = ( SqDist( ptP, ptStart) <= SqDist( ptP, ptEnd)) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ GetPointTang( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos, Ve
|
||||
return false ;
|
||||
double dUmod = dU + ( nS == ICurve::FROM_MINUS ? -1 : +1) * 100 * EPS_PARAM ;
|
||||
Point3d ptDummy ;
|
||||
// se anche la derivata seconda è nulla, provo a spostarmi di poco
|
||||
// se anche la derivata seconda è nulla, provo a spostarmi di poco
|
||||
if ( ! vtTang.Normalize( EPS_ZERO)) {
|
||||
if ( ! crvC.GetPointD1D2( dUmod, nS, ptDummy, &vtDummy, &vtTang))
|
||||
return false ;
|
||||
@@ -263,14 +263,14 @@ GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGe
|
||||
bool
|
||||
ImproveCurveParamAtPoint( double& dU, const Point3d& ptP, const ICurve* pCrv)
|
||||
{
|
||||
// Da usare quando il parametro è già molto vicino a quello esatto
|
||||
// Da usare quando il parametro è già molto vicino a quello esatto
|
||||
|
||||
// calcolo il punto della curva in corrispondenza al parametro
|
||||
Point3d ptQ ;
|
||||
Vector3d vtD ;
|
||||
if ( ! pCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptQ, &vtD))
|
||||
return false ;
|
||||
// se sono uguali, è già tutto ok
|
||||
// se sono uguali, è già tutto ok
|
||||
if ( AreSamePointExact( ptP, ptQ))
|
||||
return true ;
|
||||
// se derivata nulla, non posso migliorare
|
||||
@@ -295,7 +295,7 @@ CurveGetAreaXY( const ICurve& crvC, double& dArea)
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
crvC.ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL) ;
|
||||
crvC.ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL_INT, PL) ;
|
||||
// calcolo l'area
|
||||
double dAreaXY = 0 ;
|
||||
PL.GetAreaXY( dAreaXY) ;
|
||||
@@ -314,7 +314,7 @@ CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea)
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
crvC.ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL) ;
|
||||
crvC.ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL_INT, PL) ;
|
||||
// calcolo l'area
|
||||
Plane3d plMyPlane ;
|
||||
double dMyArea = 0 ;
|
||||
@@ -332,7 +332,7 @@ CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea)
|
||||
bool
|
||||
CurveDump( const ICurve& crvC, string& sOut, bool bMM, const char* szNewLine)
|
||||
{
|
||||
// verifico validità curva
|
||||
// verifico validità curva
|
||||
if ( ! crvC.IsValid())
|
||||
return false ;
|
||||
|
||||
@@ -365,9 +365,11 @@ CurveDump( const ICurve& crvC, string& sOut, bool bMM, const char* szNewLine)
|
||||
// altri dati per curva chiusa
|
||||
double dAreaXY ;
|
||||
if ( CurveGetAreaXY( crvC, dAreaXY)) {
|
||||
bool bCCW = ( dAreaXY > 0) ;
|
||||
bool bCCW = ( dAreaXY > 0) ;
|
||||
double dAreaUi = GetAreaInUiUnits( abs( dAreaXY), bMM) ;
|
||||
int nDec = ( dAreaUi > 100 ? 1 : ( dAreaUi > 0.1 ? 3 : 6)) ;
|
||||
sOut += string( "Closed") + ( bCCW ? " CCW" : " CW") + " AreaXY=" +
|
||||
ToString( GetAreaInUiUnits( abs( dAreaXY), bMM),1) + szNewLine ;
|
||||
ToString( dAreaUi, nDec) + szNewLine ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -401,9 +403,20 @@ CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
LineToBezierCurve( const ICurveLine* pCrvLine)
|
||||
{
|
||||
PtrOwner<ICurveBezier> pCrvBezier( CreateCurveBezier()) ;
|
||||
// rendo tutte le curve di grado 2 e razionali così posso convertire anche archi e avere tutte curve dello stesso grado e razionali
|
||||
pCrvBezier->Init( 2, true) ;
|
||||
pCrvBezier->FromLine( *pCrvLine) ;
|
||||
return Release( pCrvBezier) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ArcToBezierCurve( const ICurve* pCrv)
|
||||
ArcToBezierCurve( const ICurve* pCrv, bool bDeg3OrDeg2)
|
||||
{
|
||||
// verifico sia un arco
|
||||
const CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
||||
@@ -411,7 +424,8 @@ ArcToBezierCurve( const ICurve* pCrv)
|
||||
return nullptr ;
|
||||
|
||||
// se angolo al centro sotto il limite, basta una curva
|
||||
if ( abs( pArc->GetAngCenter()) < BEZARC_ANG_CEN_MAX + EPS_ANG_SMALL) {
|
||||
if ( ( abs( pArc->GetAngCenter()) < BEZARC_ANG_CEN_MAX + EPS_ANG_SMALL && abs( pArc->GetDeltaN()) < EPS_ZERO && ! bDeg3OrDeg2) ||
|
||||
( abs( pArc->GetAngCenter()) < BEZARC_ANG_CEN_MAX + EPS_ANG_SMALL && bDeg3OrDeg2)) {
|
||||
// creo la curva di Bezier equivalente all'arco
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez) || ! pCrvBez->FromArc( *pArc))
|
||||
@@ -427,6 +441,8 @@ ArcToBezierCurve( const ICurve* pCrv)
|
||||
return nullptr ;
|
||||
// inserisco nella CC le curve di Bezier equivalenti alle parti dell'arco
|
||||
int nParts = (int) ceil( abs( pArc->GetAngCenter()) / ( BEZARC_ANG_CEN_MAX + EPS_ANG_SMALL)) ;
|
||||
if ( ! bDeg3OrDeg2 && abs( pArc->GetDeltaN()) > EPS_ZERO)
|
||||
nParts *= 2 ;
|
||||
nParts = max( nParts, 2) ;
|
||||
for ( int i = 0 ; i < nParts ; ++ i) {
|
||||
// copio l'arco originale
|
||||
@@ -449,11 +465,265 @@ ArcToBezierCurve( const ICurve* pCrv)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CompositeToBezierCurve( const ICurveComposite* pCC)
|
||||
{
|
||||
// converto tutte le curve in bezier razionali di grado 2
|
||||
PtrOwner<ICurveComposite> pCCBezier( CreateCurveComposite()) ;
|
||||
for ( int i = 0 ; i < int( pCC->GetCurveCount()) ; ++i) {
|
||||
PtrOwner<ICurve> pCrvNew ;
|
||||
if ( pCC->GetCurve(i)->GetType() == CRV_ARC) {
|
||||
const CurveArc* crArc = GetBasicCurveArc( pCC->GetCurve(i)) ;
|
||||
ICurve* pCrvBezier = ArcToBezierCurve( crArc) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
// se la curva è di grado superiore al secondo allora devo ricondurla al secondo grado
|
||||
pCrvNew.Set( pCrvBezier) ;
|
||||
}
|
||||
else if ( pCC->GetCurve(i)->GetType() == CRV_LINE) {
|
||||
const CurveLine* crLine = GetBasicCurveLine( pCC->GetCurve(i)) ;
|
||||
ICurve* pCrvBezier = LineToBezierCurve( crLine) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
pCrvNew.Set( pCrvBezier) ;
|
||||
}
|
||||
else if ( pCC->GetCurve(i)->GetType() == CRV_BEZIER ) {
|
||||
const CurveBezier* crvBezier = GetBasicCurveBezier( pCC->GetCurve(i)) ;
|
||||
ICurve* pCrvBezier = BezierToBasicBezierCurve( crvBezier) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
pCrvNew.Set( pCrvBezier) ;
|
||||
}
|
||||
|
||||
pCCBezier->AddCurve( Release( pCrvNew)) ;
|
||||
}
|
||||
return Release( pCCBezier) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
BezierToBasicBezierCurve( const ICurveBezier* pCrvBezier)
|
||||
{
|
||||
// resta da calcolare un errore sull'approssimazione oppure usare la tecnica di spezzare la curva originale in sottocurve e approssimarle con bezier cubiche
|
||||
// per ridurre molto l'errore
|
||||
|
||||
// dovrei restituire una bezier di grado 2, razionale per poter essere uniforme con le altre curve trasmorate in bezier
|
||||
PtrOwner<ICurveBezier> pCrvNew( pCrvBezier->Clone()) ;
|
||||
int nDeg = pCrvBezier->GetDegree() ;
|
||||
bool bRat = pCrvBezier->IsRational() ;
|
||||
// se la curva è già nella forma giusta la restituisco
|
||||
if ( nDeg == 2 && bRat)
|
||||
return Release( pCrvNew) ;
|
||||
// sennò la riduco di grado fino al 2
|
||||
PtrOwner<ICurveBezier> pBasicBezier ( CreateCurveBezier()) ;
|
||||
pBasicBezier->Init( 2, true) ;
|
||||
double dW = 1 ;
|
||||
if ( nDeg == 1) {
|
||||
Point3d ptStart = pCrvBezier->GetControlPoint( 0) ;
|
||||
Point3d ptEnd = pCrvBezier->GetControlPoint( 1) ;
|
||||
pBasicBezier->SetControlPoint( 0, ptStart, dW) ;
|
||||
pBasicBezier->SetControlPoint( 1, 0.5 * (ptStart + ptEnd), dW) ;
|
||||
pBasicBezier->SetControlPoint( 2, ptEnd, dW) ;
|
||||
return Release( pBasicBezier) ;
|
||||
}
|
||||
while ( nDeg > 2 ) {
|
||||
pCrvNew.Set( BezierDecreaseDegree( pCrvNew, 1)) ;
|
||||
if ( IsNull( pCrvNew) || ! pCrvNew->IsValid())
|
||||
return nullptr ;
|
||||
-- nDeg ;
|
||||
}
|
||||
for ( int i = 0 ; i < 3 ; ++i) {
|
||||
Point3d ptCopy = pCrvNew->GetControlPoint( i) ;
|
||||
if ( bRat)
|
||||
dW = pCrvNew->GetControlWeight( i) ;
|
||||
pBasicBezier->SetControlPoint( i, ptCopy, dW) ;
|
||||
}
|
||||
|
||||
return Release( pBasicBezier) ;
|
||||
}
|
||||
|
||||
ICurveBezier*
|
||||
BezierIncreaseDegree(const ICurveBezier* pCrvBezier)
|
||||
{
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
// creo la versione con grado aumentato
|
||||
PtrOwner<ICurveBezier> pNewBezier( CreateCurveBezier()) ;
|
||||
int nDeg = pCrvBezier->GetDegree() + 1;
|
||||
bool bRat = pCrvBezier->IsRational();
|
||||
pNewBezier->Init( nDeg , bRat) ;
|
||||
// prev e curr sono riferiti alla curva di partenza
|
||||
// salvo il primo punto
|
||||
Point3d ptCtrlPrev = pCrvBezier->GetControlPoint( 0) ;
|
||||
double dWprev = 1 ;
|
||||
if ( bRat ) {
|
||||
dWprev = pCrvBezier->GetControlWeight( 0) ;
|
||||
pNewBezier->SetControlPoint( 0, ptCtrlPrev, dWprev) ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( 0, ptCtrlPrev) ;
|
||||
// ciclo sui punti di controllo intermedi per calcolare quelli nuovi
|
||||
Point3d ptCtrlCurr ;
|
||||
double dWcurr ;
|
||||
for ( double i = 1 ; i < nDeg ; ++i) {
|
||||
ptCtrlCurr = pCrvBezier->GetControlPoint( int( i)) ;
|
||||
Point3d ptNew = ( i / nDeg) * ptCtrlPrev + ( 1 - i / ( nDeg)) * ptCtrlCurr ;
|
||||
if ( bRat) {
|
||||
dWcurr = pCrvBezier->GetControlWeight( int( i)) ;
|
||||
double dWnew = ( i / nDeg) * dWprev + ( 1 - i / ( nDeg)) * dWcurr ;
|
||||
pNewBezier->SetControlPoint( int( i), ptNew, dWnew) ;
|
||||
dWprev = dWnew ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( int( i), ptNew) ;
|
||||
ptCtrlPrev = ptCtrlCurr ;
|
||||
}
|
||||
// salvo l'ultimo punto
|
||||
ptCtrlCurr = pCrvBezier->GetControlPoint( nDeg - 1) ;
|
||||
if ( bRat ) {
|
||||
dWcurr = pCrvBezier->GetControlWeight( nDeg - 1) ;
|
||||
pNewBezier->SetControlPoint( nDeg, ptCtrlCurr, dWcurr) ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( nDeg, ptCtrlCurr) ;
|
||||
return Release( pNewBezier) ;
|
||||
}
|
||||
|
||||
ICurveBezier*
|
||||
BezierDecreaseDegree(const ICurveBezier* pCrvBezier, double dTol)
|
||||
{
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
PtrOwner<ICurveBezier> pNewBezier( CreateCurveBezier()) ;
|
||||
int nDeg = pCrvBezier->GetDegree() - 1 ;
|
||||
if ( nDeg == 0)
|
||||
return nullptr ;
|
||||
bool bRat = pCrvBezier->IsRational() ;
|
||||
pNewBezier->Init( nDeg, bRat) ;
|
||||
// prev e curr sono riferiti alla nuova curva
|
||||
//salvo il primo punto
|
||||
Point3d ptCtrlPrev = pCrvBezier->GetControlPoint( 0) ;
|
||||
double dWprev = 1 ;
|
||||
if ( bRat ) {
|
||||
dWprev = pCrvBezier->GetControlWeight( 0) ;
|
||||
pNewBezier->SetControlPoint( 0, ptCtrlPrev, dWprev) ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( 0, ptCtrlPrev) ;
|
||||
// ciclo sui punti intermedi per trovare i nuovi punti di controllo // equazioni da NURBS book
|
||||
Point3d ptCtrlCurr ;
|
||||
double dWcurr ;
|
||||
int r = int (nDeg / 2) ;
|
||||
// prima metà
|
||||
for ( double i = 1 ; i < r ; ++i) {
|
||||
double dAlpha = i / ( nDeg + 1) ;
|
||||
// old è riferito alla curva originale
|
||||
Point3d ptOld = pCrvBezier->GetControlPoint( int( i)) ;
|
||||
ptCtrlCurr = ( ptOld + (- dAlpha * ptCtrlPrev)) / ( 1 - dAlpha) ;
|
||||
if ( bRat) {
|
||||
double dWold = pCrvBezier->GetControlWeight( int( i)) ;
|
||||
dWcurr = ( dWold + (- dAlpha * dWprev)) / ( 1 - dAlpha) ;
|
||||
pNewBezier->SetControlPoint( int( i), ptCtrlCurr, dWcurr) ;
|
||||
dWprev = dWcurr ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( int( i), ptCtrlCurr) ;
|
||||
ptCtrlPrev = ptCtrlCurr ;
|
||||
}
|
||||
// risolvo il punto di mezzo per il caso nDeg pari
|
||||
if ( ( nDeg + 1) % 2 == 0) { // pari
|
||||
double dAlpha = r / ( nDeg + 1.) ;
|
||||
Point3d ptOld = pCrvBezier->GetControlPoint( r) ;
|
||||
ptCtrlCurr = ( ptOld + (- dAlpha * ptCtrlPrev)) / ( 1 - dAlpha) ;
|
||||
if ( bRat) {
|
||||
double dWold = pCrvBezier->GetControlWeight( r) ;
|
||||
dWcurr = ( dWold + (- dAlpha * dWprev)) / ( 1 - dAlpha) ;
|
||||
pNewBezier->SetControlPoint( r, ptCtrlCurr, dWcurr) ;
|
||||
dWprev = dWcurr ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( r, ptCtrlCurr) ;
|
||||
}
|
||||
// salvo l'ultimo punto
|
||||
ptCtrlCurr = pCrvBezier->GetControlPoint( nDeg + 1) ;
|
||||
if ( bRat ) {
|
||||
dWcurr = pCrvBezier->GetControlWeight( nDeg + 1) ;
|
||||
pNewBezier->SetControlPoint( nDeg, ptCtrlCurr, dWcurr) ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( nDeg, ptCtrlCurr) ;
|
||||
ptCtrlPrev = ptCtrlCurr ;
|
||||
if ( bRat)
|
||||
dWprev = dWcurr ;
|
||||
// seconda metà
|
||||
for ( double i = nDeg - 1 ; i > r ; --i) {
|
||||
double dAlpha = ( i + 1) / ( nDeg + 1) ;
|
||||
Point3d ptOld = pCrvBezier->GetControlPoint( int( i) + 1) ;
|
||||
ptCtrlCurr = ( ptOld + ( - ( 1 - dAlpha) * ptCtrlPrev)) / dAlpha ;
|
||||
if ( bRat) {
|
||||
double dWold = pCrvBezier->GetControlWeight( int( i) + 1) ;
|
||||
dWcurr = ( dWold - ( ( 1 - dAlpha) * dWprev)) / dAlpha ;
|
||||
pNewBezier->SetControlPoint( int( i), ptCtrlCurr, dWcurr) ;
|
||||
dWprev = dWcurr ;
|
||||
}
|
||||
else
|
||||
pNewBezier->SetControlPoint( int( i), ptCtrlCurr) ;
|
||||
ptCtrlPrev = ptCtrlCurr ;
|
||||
}
|
||||
// risolvo il punto di mezzo per il caso nDeg dispari
|
||||
// calcolo anche l'errore di approssimazione
|
||||
double dErr = 0 ;
|
||||
if ( (nDeg + 1) % 2 != 0) { // dispari
|
||||
// puntdo di sinistra
|
||||
double dAlpha = r / ( nDeg + 1.) ;
|
||||
ptCtrlPrev = pNewBezier->GetControlPoint( r - 1) ;
|
||||
Point3d ptOld = pCrvBezier->GetControlPoint( r) ;
|
||||
Point3d ptL = ( ptOld + ( - dAlpha * ptCtrlPrev)) / ( 1 - dAlpha) ;
|
||||
double dWL = 1 ;
|
||||
if ( bRat) {
|
||||
dWprev = pNewBezier->GetControlWeight( r - 1) ;
|
||||
double dWold =pCrvBezier->GetControlWeight( r) ;
|
||||
dWL = ( dWold - ( dAlpha * dWprev)) / ( 1 - dAlpha) ;
|
||||
}
|
||||
// punto di destra
|
||||
dAlpha = ( r + 1.) / ( nDeg + 1.) ;
|
||||
ptCtrlPrev = pNewBezier->GetControlPoint( r + 1) ;
|
||||
ptOld = pCrvBezier->GetControlPoint( r + 1) ;
|
||||
double dWR = 1 ;
|
||||
if ( bRat) {
|
||||
dWprev = pNewBezier->GetControlWeight( r + 1) ;
|
||||
double dWold =pCrvBezier->GetControlWeight( r + 1) ;
|
||||
dWR = ( dWold - ( ( 1 - dAlpha) * dWprev)) / dAlpha ;
|
||||
}
|
||||
Point3d ptR = ( ptOld + ( - ( 1 - dAlpha) * ptCtrlPrev)) / dAlpha ;
|
||||
// calcolo il punto di mezzo e lo aggiungo
|
||||
Point3d ptNew = ( ptL + ptR) / 2 ;
|
||||
double dWnew = ( dWL + dWR) / 2 ;
|
||||
if ( bRat)
|
||||
pNewBezier->SetControlPoint( r, ptNew, dWnew) ;
|
||||
else
|
||||
pNewBezier->SetControlPoint( r, ptNew) ;
|
||||
dErr = Dist( ptL, ptR) ;
|
||||
}
|
||||
else {
|
||||
ptCtrlCurr = pNewBezier->GetControlPoint( r + 1) ;
|
||||
ptCtrlPrev = pNewBezier->GetControlPoint( r) ;
|
||||
Point3d ptOld = pCrvBezier->GetControlPoint( r + 1) ;
|
||||
dErr = Dist( ptOld, 0.5 * ( ptCtrlPrev + ptCtrlCurr)) ;
|
||||
}
|
||||
//// se l'approssimazione dà un errore troppo alto allora annullo tutto // da controllare
|
||||
//if ( dErr > dTol)
|
||||
// return nullptr ;
|
||||
|
||||
return Release( pNewBezier) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
CurveToNoArcsCurve( const ICurve* pCrv)
|
||||
{
|
||||
// verifico validità curva
|
||||
// verifico validità curva
|
||||
if ( pCrv == nullptr)
|
||||
return nullptr ;
|
||||
// se arco, devo trasformarlo in curva di Bezier (semplice o composta)
|
||||
@@ -477,7 +747,7 @@ CurveToNoArcsCurve( const ICurve* pCrv)
|
||||
ICurve*
|
||||
CurveToArcsPerpExtrCurve( const ICurve* pCrv, double dLinTol, double dAngTolDeg)
|
||||
{
|
||||
// verifico validità curva
|
||||
// verifico validità curva
|
||||
if ( pCrv == nullptr)
|
||||
return nullptr ;
|
||||
// se arco in piano non perpendicolare ad estrusione, curva composita o curva di Bezier trasformo
|
||||
@@ -509,14 +779,7 @@ CurveToArcsPerpExtrCurve( const ICurve* pCrv, double dLinTol, double dAngTolDeg)
|
||||
bool
|
||||
NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
{
|
||||
// se periodica
|
||||
if ( cnData.bPeriodic) {
|
||||
// va trasformata in non-periodica (clamped)
|
||||
// vedere The NurbsBook di Les Piegl e Tiller
|
||||
// mancano esempi per testare
|
||||
return false ;
|
||||
}
|
||||
// se con nodi extra
|
||||
// se con nodi extra
|
||||
if ( cnData.bExtraKnotes) {
|
||||
int nKnotesNbr = int( cnData.vU.size()) ;
|
||||
if ( nKnotesNbr < 4)
|
||||
@@ -525,7 +788,248 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
for ( int i = 0 ; i < nKnotesNbr - 2 ; ++ i)
|
||||
cnData.vU[i] = cnData.vU[i+1] ;
|
||||
cnData.vU.resize( nKnotesNbr - 2) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// se periodica
|
||||
if ( cnData.bPeriodic || ! cnData.bClamped) {
|
||||
// se la curva è peridica verifco che effettivamente ci sia un numero di punti ripetituti uguale al grado della curva
|
||||
// wrap della curva su se stessa
|
||||
if ( cnData.bPeriodic ) {
|
||||
bool bRepetead = true ;
|
||||
for ( int i = 0 ; i < cnData.nDeg ; ++i) {
|
||||
if ( ! AreSamePointApprox( cnData.vCP[i], cnData.vCP.end()[-cnData.nDeg + i]) ) {
|
||||
bRepetead = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( ! bRepetead){
|
||||
// salvo il vettore dei nodi in caso mi accorga di avere tra le mani una curva unclamped
|
||||
DBLVECTOR vU = cnData.vU ;
|
||||
// se il primo e l'ultimo punto non coincidono allora aggiungo il primo punto in fondo al vettore dei punti di controllo
|
||||
if ( ! AreSamePointApprox( cnData.vCP[0], cnData.vCP.back()) ) {
|
||||
cnData.vCP.push_back( cnData.vCP[0]) ;
|
||||
if ( cnData.bRat)
|
||||
cnData.vW.push_back( cnData.vW[0]) ;
|
||||
}
|
||||
// se effettivamente ho dei nodi in più da togliere allora li tolgo
|
||||
if ( int( cnData.vU.size()) != int(cnData.vCP.size()) + cnData.nDeg - 1) {
|
||||
// devo poi anche togliere i nodi di troppo // presuppongo che la convenzione sia che i nodi di troppo sono alla fine del vettore dei nodi
|
||||
cnData.vU = DBLVECTOR( cnData.vU.begin(), cnData.vU.end() - cnData.nDeg) ;
|
||||
// controllo eventualmente anche i nodi extra
|
||||
// se ne ho due in più ne tolgo uno in cima e uno in fondo
|
||||
if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg + 1 ) // significa che ci sono due nodi extra, uno all'inizio e uno alla fine, da togliere
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end() - 1) ;
|
||||
// se ne ho solo uno in più lo tolgo in cima
|
||||
else if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg)
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end()) ;
|
||||
}
|
||||
// controllo se il vettore dei nodi ha la giusta molteplicità all'inizio e alla fine, sennò ha comunque bisogno di essere resa non periodica
|
||||
double dU0 = cnData.vU[0] ;
|
||||
double dULast = cnData.vU.back() ;
|
||||
bool bSame = true ;
|
||||
for ( int i = 1 ; i < cnData.nDeg ; ++i ) {
|
||||
bSame = bSame && abs(cnData.vU[i] - dU0) < EPS_SMALL ;
|
||||
bSame = bSame && abs(cnData.vU.end()[-( i+ 1)] - dULast) < EPS_SMALL ;
|
||||
}
|
||||
if ( bSame) {
|
||||
cnData.bPeriodic = false ;
|
||||
return true ;
|
||||
}
|
||||
else {
|
||||
// aggiungo i punti ripetuti ( il primo l'ho già aggiunto)
|
||||
for ( int i = 1 ; i < cnData.nDeg ; ++i ) {
|
||||
cnData.vCP.push_back( cnData.vCP[i]) ;
|
||||
if ( cnData.bRat)
|
||||
cnData.vW.push_back( cnData.vW[i]) ;
|
||||
}
|
||||
// recupero il vettore dei nodi
|
||||
cnData.vU = vU ;
|
||||
// verifico se ho nodi extra
|
||||
// se ne ho due in più ne tolgo uno in cima e uno in fondo
|
||||
if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg + 1 ) // significa che ci sono due nodi extra, uno all'inizio e uno alla fine, da togliere
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end() - 1) ;
|
||||
// se ne ho solo uno in più lo tolgo in cima
|
||||
else if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg)
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// qui aggiungo un controllo se la curva è collassata in un punto ( ho un polo), lascio stare
|
||||
bool bCollapsed = true ;
|
||||
Point3d ptFirst = cnData.vCP.front() ;
|
||||
for( int i = 1 ; i < int( cnData.vCP.size()) ; ++i) {
|
||||
if ( ! AreSamePointApprox( ptFirst, cnData.vCP[i])) {
|
||||
bCollapsed = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( bCollapsed)
|
||||
return false ;
|
||||
|
||||
// va trasformata in non-periodica (clamped)
|
||||
// bisogna aumentare la molteplicità dei nodi u_p-1 e u_(m-p+1) fino ad arrivare al grado della nurbs
|
||||
// e poi scartare nodi e punti fuori dalla regione clamped ( al di fuori della regione u_p-1 -> u_(m-p+1))
|
||||
|
||||
// l'agoritmo per l'inserimento dei nodi l' A5.1 del libro delle Nurbs ( Piegl e Tiller), con qualche modifica
|
||||
// agli indici perché uso u_p-1 e u_(m-p+1), anziché u_p e u_m-p
|
||||
|
||||
// comincio ad aumentare la molteplictià del nodo u_m-p+1
|
||||
int nCP = int( cnData.vCP.size()) ;
|
||||
int nU = nCP + cnData.nDeg - 1 ;
|
||||
int nDeg = cnData.nDeg ;
|
||||
PNTVECTOR vBC ;
|
||||
vBC.resize( nDeg + 1) ;
|
||||
DBLVECTOR vBW ;
|
||||
vBW.resize( nDeg + 1) ;
|
||||
|
||||
// trovo il nodo di cui aumentare la molteplicità e ne calcolo la molteplicità
|
||||
int b = nU - nDeg - 1 + 1 ;
|
||||
int i = b ;
|
||||
while ( b > 0 && abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
|
||||
-- b ;
|
||||
int mult = min( i - b + 1, nDeg) ; // mi aspetto che sia 1, ma comunque sarà < nDeg
|
||||
// recupero i punti da modificare
|
||||
if ( ! cnData.bRat) {
|
||||
for ( int i = 0 ; i <= nDeg - mult ; ++ i)
|
||||
vBC[i] = cnData.vCP[b - nDeg + 1 + i] ;
|
||||
}
|
||||
else {
|
||||
for ( int i = 0 ; i <= nDeg - mult ; ++ i) {
|
||||
vBC[i] = cnData.vCP[b - nDeg + 1 + i] * cnData.vW[b - nDeg + 1 + i] ;
|
||||
vBW[i] = cnData.vW[b - nDeg + 1 + i] ;
|
||||
}
|
||||
}
|
||||
|
||||
// salvo i punti inalterati
|
||||
int r = nDeg - mult ; // numero di volte che dovrò inserire il nodo
|
||||
cnData.vCP.resize( nCP + r) ;
|
||||
for ( int p = nCP - 1 ; p > b - mult ; --p) {
|
||||
cnData.vCP[r + p] = cnData.vCP[p] ;
|
||||
}
|
||||
if ( cnData.bRat ) {
|
||||
cnData.vW.resize( nCP + r) ;
|
||||
for ( int p = nCP - 1 ; p > b - mult ; --p) {
|
||||
cnData.vW[r + p] = cnData.vW[p] ;
|
||||
}
|
||||
}
|
||||
|
||||
// procedo all'inserimento
|
||||
int L = 0 ;
|
||||
double alpha ;
|
||||
if ( mult < nDeg) {
|
||||
// inserisco il nodo r volte
|
||||
for ( int j = 1 ; j <= r ; ++ j) {
|
||||
L = b - nDeg + j ;
|
||||
for ( int i = 0; i <= r - j ; ++i) {
|
||||
alpha = (cnData.vU[b] - cnData.vU[L + i])/ ( cnData.vU[i + b + 1] - cnData.vU[L + i]) ;
|
||||
vBC[i] = alpha * vBC[i +1 ] + ( 1 - alpha) * vBC[i] ;
|
||||
if ( cnData.bRat) {
|
||||
vBW[i] = alpha * vBW[i + 1] + ( 1 - alpha) * vBW[i] ;
|
||||
}
|
||||
}
|
||||
cnData.vCP[L + 1] = vBC[0] ;
|
||||
cnData.vCP[b + nDeg - j - mult] = vBC[r - j] ;
|
||||
if ( cnData.bRat ) {
|
||||
cnData.vW[L + 1] = vBW[0] ;
|
||||
cnData.vW[b + nDeg - j - mult] = vBW[r-j] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// allungo il vettore dei nodi e sposto gli ultimi nodi
|
||||
cnData.vU.resize( nU + r) ;
|
||||
for ( int p = nU - 1 ; p > b ; --p)
|
||||
cnData.vU[p + r] = cnData.vU[p] ;
|
||||
// aggiungo i nodi nuovi
|
||||
for ( int p = 0 ; p < r ; ++p)
|
||||
cnData.vU[b + 1 + p] = cnData.vU[b] ;
|
||||
nU = nU + r ;
|
||||
nCP = nCP + r ;
|
||||
|
||||
// aumento la molteplicità del punto u_p-1
|
||||
b = nDeg - 1 ;
|
||||
i = b ;
|
||||
while ( b > 0 && abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
|
||||
-- b ;
|
||||
mult = min( i - b + 1, nDeg) ; // mi aspetto che sia 1, ma comunque sarà < cnData.nDeg
|
||||
// recupero i punti da modificare
|
||||
if ( ! cnData.bRat) {
|
||||
for ( int i = 0 ; i <= nDeg - mult ; ++ i)
|
||||
vBC[i] = cnData.vCP[i] ;
|
||||
}
|
||||
else {
|
||||
for ( int i = 0 ; i <= nDeg - mult ; ++ i) {
|
||||
vBC[i] = cnData.vCP[i] * cnData.vW[i] ;
|
||||
vBW[i] = cnData.vW[i] ;
|
||||
}
|
||||
}
|
||||
|
||||
r = nDeg - mult ;
|
||||
// salvo i punti inalterati
|
||||
cnData.vCP.resize( nCP + r) ;
|
||||
for ( int p = nCP - 1 ; p > b - mult ; --p) {
|
||||
cnData.vCP[r + p] = cnData.vCP[p] ;
|
||||
}
|
||||
if ( cnData.bRat ) {
|
||||
cnData.vW.resize( nCP + r) ;
|
||||
for ( int p = nCP - 1 ; p > b - mult ; --p) {
|
||||
cnData.vW[r + p] = cnData.vW[p] ;
|
||||
}
|
||||
}
|
||||
|
||||
// procedo all'inserimento
|
||||
L = 0 ;
|
||||
if ( mult < nDeg) {
|
||||
// inserisco il nodo r volte
|
||||
for ( int j = 1 ; j <= r ; ++ j) {
|
||||
L = b - nDeg + j ;
|
||||
for ( int i = 0; i <= r - j ; ++i) {
|
||||
alpha = (cnData.vU[b] - cnData.vU[L + i])/ ( cnData.vU[i + b + 1] - cnData.vU[L + i]) ;
|
||||
vBC[i] = alpha * vBC[i + 1] + ( 1 - alpha) * vBC[i] ;
|
||||
if ( cnData.bRat) {
|
||||
vBW[i] = alpha * vBW[i + 1] + ( 1 - alpha) * vBW[i] ;
|
||||
}
|
||||
}
|
||||
cnData.vCP[L + 1] = vBC[0] ;
|
||||
cnData.vCP[b + nDeg - j - mult] = vBC[r - j] ;
|
||||
if ( cnData.bRat ) {
|
||||
cnData.vW[L + 1] = vBW[0] ;
|
||||
cnData.vW[b + nDeg - j - mult] = vBW[r - j] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// allungo il vettore dei nodi e sposto gli ultimi nodi
|
||||
cnData.vU.resize(nU + r) ;
|
||||
for ( int p = nU - 1 ; p > b ; --p)
|
||||
cnData.vU[p+r] = cnData.vU[p] ;
|
||||
// aggiungo i nodi nuovi
|
||||
for ( int p = 0 ; p < r ; ++p)
|
||||
cnData.vU[b + 1 + p] = cnData.vU[b] ;
|
||||
nU = nU + r ;
|
||||
nCP = nCP + r ;
|
||||
|
||||
// rendo la curva chiusa e non periodica eliminando i primi e gli ultimi nDeg punti e nodi
|
||||
cnData.bPeriodic = false ;
|
||||
nCP = nCP - 2 * ( nDeg - 1);
|
||||
nU = nU - 2 * ( nDeg - 1);
|
||||
PNTVECTOR vCP_clamped ;
|
||||
vCP_clamped.resize( nCP) ;
|
||||
DBLVECTOR vU_clamped ;
|
||||
vU_clamped.resize( nU) ;
|
||||
for ( int i = 0 ; i < nCP ; ++i) {
|
||||
if ( ! cnData.bRat)
|
||||
vCP_clamped[i] = cnData.vCP[i + nDeg - 1] ;
|
||||
else
|
||||
vCP_clamped[i] = cnData.vCP[i + nDeg - 1] / cnData.vW[i + nDeg - 1] ;
|
||||
}
|
||||
cnData.vCP = vCP_clamped ;
|
||||
for ( int i = 0 ; i < nU ; ++i) {
|
||||
vU_clamped[i] = cnData.vU[i + nDeg - 1] ;
|
||||
}
|
||||
cnData.vU = vU_clamped ;
|
||||
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -557,11 +1061,11 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
}
|
||||
if ( ! bOk)
|
||||
return nullptr ;
|
||||
|
||||
// se 1 solo intervallo, la Nurbs è già una curva di Bezier
|
||||
|
||||
// se 1 solo intervallo, la Nurbs è già una curva di Bezier
|
||||
if ( nInt == 1) {
|
||||
// creo la curva di Bezier
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return nullptr ;
|
||||
// la inizializzo
|
||||
@@ -577,15 +1081,15 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
// se non è una curva ma un punto, la invalido
|
||||
// se non è una curva ma un punto, la invalido
|
||||
if ( pCrvBez->IsAPoint())
|
||||
pCrvBez->Init( cnData.nDeg, cnData.bRat) ;
|
||||
// restituisco la curva
|
||||
return Release( pCrvBez) ;
|
||||
}
|
||||
|
||||
// altrimenti è equivalente ad una curva composita, la creo
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
// altrimenti è equivalente ad una curva composita, la creo
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return nullptr ;
|
||||
|
||||
@@ -647,12 +1151,12 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
}
|
||||
|
||||
// costruisco la curva di Bezier e la inserisco nella curva composita
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return nullptr ;
|
||||
// se precedente saltata
|
||||
if ( bPrevRejected) {
|
||||
// prendo l'ultimo punto della curva composita per garantire la continuità
|
||||
// prendo l'ultimo punto della curva composita per garantire la continuità
|
||||
Point3d ptEnd ;
|
||||
if ( pCrvCompo->GetEndPoint( ptEnd))
|
||||
vBC[0] = ptEnd ;
|
||||
@@ -672,18 +1176,17 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
// se è una vera curva, la aggiungo alla curva composita
|
||||
// se è una vera curva, la aggiungo alla curva composita
|
||||
if ( ! pCrvBez->IsAPoint()) {
|
||||
if ( ! pCrvCompo->AddCurve( Release( pCrvBez)))
|
||||
return nullptr ;
|
||||
bPrevRejected = false ;
|
||||
}
|
||||
// altrimenti è un punto, la cancello
|
||||
// altrimenti è un punto, la cancello
|
||||
else {
|
||||
pCrvBez.Reset() ;
|
||||
bPrevRejected = true ;
|
||||
}
|
||||
|
||||
// inizializzazioni per la prossima curva di Bezier
|
||||
if ( b < nU - 1) {
|
||||
if ( ! cnData.bRat) {
|
||||
@@ -707,6 +1210,30 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
}
|
||||
}
|
||||
|
||||
// se la curva ha grado 1, manca da aggiungere l'ultimo tratto
|
||||
if ( cnData.nDeg == 1 ) {
|
||||
// costruisco la curva di Bezier e la inserisco nella curva composita
|
||||
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( ! pCrvBez->Init( cnData.nDeg, cnData.bRat))
|
||||
return nullptr ;
|
||||
if ( ! cnData.bRat) {
|
||||
for ( int i = 0 ; i <= cnData.nDeg ; ++ i) {
|
||||
if ( ! pCrvBez->SetControlPoint( i, vBC[i]))
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( int i = 0 ; i <= cnData.nDeg ; ++ i) {
|
||||
if ( ! pCrvBez->SetControlPoint( i, vBC[i] / vBW[i], vBW[i]))
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
if ( ! pCrvBez->IsAPoint()) {
|
||||
if ( ! pCrvCompo->AddCurve( Release( pCrvBez)))
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
// restituisco la curva composita
|
||||
return Release( pCrvCompo) ;
|
||||
}
|
||||
@@ -727,9 +1254,9 @@ FlattenCurve( const ICurve& crCrv, double dToler, double dAngToler, int nFlag)
|
||||
Point3d ptCen ;
|
||||
if ( ! crCrv.GetCentroid( ptCen))
|
||||
return nullptr ;
|
||||
// Verifico se curva già piatta
|
||||
// Verifico se curva già piatta
|
||||
PolyLine PL ;
|
||||
if ( ! crCrv.ApproxWithLines( LIN_TOL_FINE, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
if ( ! crCrv.ApproxWithLines( LIN_TOL_FINE, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL_INT, PL))
|
||||
return nullptr ;
|
||||
bool bFlat = true ;
|
||||
Plane3d plFlat ; plFlat.Set( ptCen, plMid.GetVersN()) ;
|
||||
@@ -740,7 +1267,7 @@ FlattenCurve( const ICurve& crCrv, double dToler, double dAngToler, int nFlag)
|
||||
bFlat = false ;
|
||||
bPoint = PL.GetNextPoint( ptP) ;
|
||||
}
|
||||
// Se curva già piatta, la copio ed esco
|
||||
// Se curva già piatta, la copio ed esco
|
||||
if ( bFlat) {
|
||||
PtrOwner<ICurve> pCrv( crCrv.Clone()) ;
|
||||
if ( IsNull( pCrv))
|
||||
@@ -790,8 +1317,8 @@ ProjectCurveOnPlane( const ICurve& crCrv, const Plane3d& plPlane)
|
||||
{
|
||||
// determino se curva piana e suo eventuale piano
|
||||
Plane3d plCrv ;
|
||||
if ( crCrv.IsFlat( plCrv)) {
|
||||
// se il piano della curva è parallelo a quello di proiezione
|
||||
if ( crCrv.IsFlat( plCrv, false, EPS_SMALL / 2)) {
|
||||
// se il piano della curva è parallelo a quello di proiezione
|
||||
if ( AreSameOrOppositeVectorExact( plCrv.GetVersN(), plPlane.GetVersN())) {
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pCrv( crCrv.Clone()) ;
|
||||
@@ -856,3 +1383,69 @@ AdjustCurveSlope( ICurveComposite* pCrv, double dNini, double dNfin)
|
||||
pCrv->ModifyEnd( ptFin) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
GetCurveVoronoi( const ICurve& crvC)
|
||||
{
|
||||
switch ( crvC.GetType()) {
|
||||
case CRV_LINE : return GetBasicCurveLine( &crvC)->GetVoronoiObject() ;
|
||||
case CRV_ARC : return GetBasicCurveArc( &crvC)->GetVoronoiObject() ;
|
||||
case CRV_BEZIER : return GetBasicCurveBezier( &crvC)->GetVoronoiObject() ;
|
||||
case CRV_COMPO : return GetBasicCurveComposite( &crvC)->GetVoronoiObject() ;
|
||||
}
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveVoronoiDiagram( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nBound)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcVoronoiDiagram( vCrvs, nBound) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveMedialAxis( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nSide)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcCurveFatCurve( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double dRadius, bool bSquareEnds, bool bSquareMids)
|
||||
{
|
||||
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return pVoronoiObj->CalcFatCurve( vCrvs, dRadius, bSquareEnds, bSquareMids) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ResetCurveVoronoi( const ICurve& crvC)
|
||||
{
|
||||
switch ( crvC.GetType()) {
|
||||
case CRV_LINE :
|
||||
GetBasicCurveLine( &crvC)->ResetVoronoiObject() ;
|
||||
break ;
|
||||
case CRV_ARC :
|
||||
GetBasicCurveArc( &crvC)->ResetVoronoiObject() ;
|
||||
break ;
|
||||
case CRV_BEZIER :
|
||||
GetBasicCurveBezier( &crvC)->ResetVoronoiObject() ;
|
||||
break ;
|
||||
case CRV_COMPO :
|
||||
GetBasicCurveComposite( &crvC)->ResetVoronoiObject() ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -13,7 +13,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EgkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool IsClosed( const ICurve& crvC) ;
|
||||
@@ -31,3 +33,4 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
|
||||
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
||||
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
||||
|
||||
+190
-17
@@ -19,19 +19,23 @@
|
||||
#include "BiArcs.h"
|
||||
#include "GeoConst.h"
|
||||
#include "PolygonPlane.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "PolynomialPoint3d.h"
|
||||
#include "Bernstein.h"
|
||||
#include "deCasteljau.h"
|
||||
#include "Voronoi.h"
|
||||
#include "IntersLineLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include "/EgtDev/Include/ENkPolynomial.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include <array>
|
||||
|
||||
using namespace std ;
|
||||
@@ -45,13 +49,14 @@ GEOOBJ_REGISTER( CRV_BEZIER, NGE_C_BEZ, CurveBezier) ;
|
||||
//----------------------------------------------------------------------------
|
||||
CurveBezier::CurveBezier( void)
|
||||
: m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2),
|
||||
m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
m_VtExtr(), m_dThick(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveBezier::~CurveBezier( void)
|
||||
{
|
||||
ResetVoronoiObject() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -75,6 +80,8 @@ CurveBezier::Init( int nDeg, bool bIsRational)
|
||||
m_vWeCtrl.clear() ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -99,6 +106,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
|
||||
// annullo analisi presenza singolarità
|
||||
m_dParSing = - 2 ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -124,6 +133,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
|
||||
// annullo analisi presenza singolarità
|
||||
m_dParSing = - 2 ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -187,6 +198,35 @@ CurveBezier::FromArc( const ICurveArc& crArc)
|
||||
SetControlPoint( 1, ptNew1, dW) ;
|
||||
SetControlPoint( 2, ptNew2, dW) ;
|
||||
SetControlPoint( 3, ptEnd, 1) ;
|
||||
|
||||
//// anziché usare una bezier cubica approssimo le eliche con più bezier quadratiche razionali.
|
||||
//// più è grande l'angolo al centro dell'arco e maggiore sarà l'errore di approssimazione
|
||||
//
|
||||
// // quadratica razionale
|
||||
// // peso del punto di controllo intermedio
|
||||
// double dW = dCosAhalf ;
|
||||
// // calcolo dei punti di controllo
|
||||
// Point3d ptStart ;
|
||||
// crArc.GetStartPoint( ptStart) ;
|
||||
// Point3d ptEnd ;
|
||||
// crArc.GetEndPoint( ptEnd) ;
|
||||
// // Point3d ptMed = Media( ptStart, ptEnd, 0.5) ;
|
||||
// //Vector3d vtDir = ptMed - crArc.GetCenter() ;
|
||||
// // Point3d ptNew = crArc.GetCenter() + vtDir / ( dCosAhalf * dCosAhalf) ;
|
||||
// Vector3d vtStart ; crArc.GetStartDir( vtStart) ;
|
||||
// Vector3d vtEnd ; crArc.GetEndDir( vtEnd) ;
|
||||
// PtrOwner<CurveLine> pCrvLine1( CreateBasicCurveLine()) ;
|
||||
// pCrvLine1->SetPVL( ptStart, vtStart, 10) ;
|
||||
// PtrOwner<CurveLine> pCrvLine2( CreateBasicCurveLine()) ;
|
||||
// pCrvLine2->SetPVL( ptEnd, vtEnd, 10) ;
|
||||
// IntersLineLine ill( *pCrvLine1, *pCrvLine2, false) ;
|
||||
// IntCrvCrvInfo iccInfo ; ill.GetIntCrvCrvInfo( iccInfo) ;
|
||||
// Point3d ptNew = 0.5 * (iccInfo.IciA->ptI + iccInfo.IciB->ptI) ;
|
||||
// // inserimento nella curva dei punti di controllo con i pesi
|
||||
// Init( 2, true) ;
|
||||
// SetControlPoint( 0, ptStart, 1) ;
|
||||
// SetControlPoint( 1, ptNew, dW) ;
|
||||
// SetControlPoint( 2, ptEnd, 1) ;
|
||||
}
|
||||
|
||||
// copio estrusione e spessore
|
||||
@@ -196,6 +236,30 @@ CurveBezier::FromArc( const ICurveArc& crArc)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::FromLine( const ICurveLine& crLine)
|
||||
{
|
||||
if ( ! crLine.IsValid())
|
||||
return false ;
|
||||
double dWeight = 1 ;
|
||||
int nCount = 0 ;
|
||||
Point3d ptStart ; crLine.GetStartPoint( ptStart) ;
|
||||
SetControlPoint( nCount, ptStart, dWeight) ;
|
||||
++nCount ;
|
||||
double dPart = 1. / m_nDeg ;
|
||||
for ( int i = 1 ; i < m_nDeg ; ++i) {
|
||||
double dU = i * dPart ;
|
||||
Point3d ptMid ; crLine.GetPointD1D2( dU, ICurve::FROM_MINUS, ptMid) ;
|
||||
SetControlPoint( nCount, ptMid, dWeight) ;
|
||||
++nCount ;
|
||||
}
|
||||
Point3d ptEnd ; crLine.GetEndPoint( ptEnd) ;
|
||||
SetControlPoint( nCount, ptEnd, dWeight) ;
|
||||
++nCount ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::IsAPoint( void) const
|
||||
@@ -264,7 +328,7 @@ CurveBezier::Clone( void) const
|
||||
bool
|
||||
CurveBezier::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const CurveBezier* pCB = dynamic_cast<const CurveBezier*>( pGObjSrc) ;
|
||||
const CurveBezier* pCB = GetBasicCurveBezier( pGObjSrc) ;
|
||||
if ( pCB == nullptr)
|
||||
return false ;
|
||||
return CopyFrom( *pCB) ;
|
||||
@@ -283,7 +347,10 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
|
||||
m_vWeCtrl = cbSrc.m_vWeCtrl ;
|
||||
m_VtExtr = cbSrc.m_VtExtr ;
|
||||
m_dThick = cbSrc.m_dThick ;
|
||||
m_nTempProp = cbSrc.m_nTempProp ;
|
||||
m_nTempProp[0] = cbSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = cbSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = cbSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = cbSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -421,8 +488,24 @@ CurveBezier::Load( NgeReader& ngeIn)
|
||||
bool
|
||||
CurveBezier::Validate( void)
|
||||
{
|
||||
if ( m_nStatus == TO_VERIFY) {
|
||||
for ( const auto& ptP : m_vPtCtrl) {
|
||||
if ( ! ptP.IsValid()) {
|
||||
m_nStatus = ERR ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( m_nStatus == TO_VERIFY) {
|
||||
for ( const auto& dWe : m_vWeCtrl) {
|
||||
if ( ! isfinite( dWe)) {
|
||||
m_nStatus = ERR ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( m_nStatus == TO_VERIFY)
|
||||
m_nStatus = ( ( m_nDeg > 0 && m_vPtCtrl.size() > 0) ? OK : ERR) ;
|
||||
m_nStatus = ( ( m_nDeg >= 1 && m_vPtCtrl.size() >= 2) ? OK : ERR) ;
|
||||
|
||||
return ( m_nStatus == OK) ;
|
||||
}
|
||||
@@ -445,7 +528,7 @@ CurveBezier::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
else {
|
||||
// costruisco una approssimazione lineare
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, ICurve::APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, APL_STD, PL))
|
||||
return false ;
|
||||
// ciclo sui punti della approssimazione
|
||||
Point3d ptTemp ;
|
||||
@@ -488,7 +571,7 @@ CurveBezier::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
else {
|
||||
// costruisco una approssimazione lineare
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, ICurve::APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_MIN, ANG_TOL_APPROX_DEG, APL_STD, PL))
|
||||
return false ;
|
||||
// ciclo sui punti della approssimazione
|
||||
Point3d ptTemp ;
|
||||
@@ -600,7 +683,7 @@ CurveBezier::GetMidPoint( Point3d& ptMid) const
|
||||
return false ;
|
||||
// determino il valore del parametro a metà lunghezza
|
||||
double dLen, dMid ;
|
||||
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
return false ;
|
||||
// calcolo il punto
|
||||
return GetPointD1D2( dMid, ptMid) ;
|
||||
@@ -615,7 +698,7 @@ CurveBezier::GetCentroid( Point3d& ptCen) const
|
||||
return false ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
if ( ! ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, APL_STD, PL))
|
||||
return false ;
|
||||
// calcolo il centro mediante PolygonPlane
|
||||
Point3d ptP ;
|
||||
@@ -637,7 +720,7 @@ CurveBezier::GetMidDir( Vector3d& vtDir) const
|
||||
return false ;
|
||||
// determino il valore del parametro a metà lunghezza
|
||||
double dLen, dMid ;
|
||||
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
|
||||
return false ;
|
||||
// calcolo la direzione
|
||||
return ::GetTang( *this, dMid, FROM_MINUS, vtDir) ;
|
||||
@@ -1426,7 +1509,7 @@ CurveBezier::ApproxWithArcsXY( double dLinTol, double dAngTolDeg, PolyArc& PA) c
|
||||
|
||||
// costruisco una approssimazione lineare
|
||||
PolyLine PL ;
|
||||
if ( ! ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, PL))
|
||||
if ( ! ApproxWithLines( dLinTol, dAngTolDeg, APL_STD, PL))
|
||||
return false ;
|
||||
|
||||
// approssimo la curva per approssimazioni successive mediante bisezione
|
||||
@@ -1475,7 +1558,7 @@ CurveBezier::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAngTo
|
||||
return false ;
|
||||
if ( ! pCC->FromPolyLine( PL))
|
||||
return false ;
|
||||
pCrv.Set( Release( pCC)) ;
|
||||
pCrv.Set( pCC) ;
|
||||
dMaxDist = 0 ;
|
||||
}
|
||||
// se la polilinea ha un solo punto, esco
|
||||
@@ -1587,6 +1670,8 @@ CurveBezier::Invert( void)
|
||||
for ( int i = 0 ; i < nMid ; ++ i)
|
||||
swap( m_vPtCtrl[i], m_vPtCtrl[m_nDeg-i]) ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1604,6 +1689,8 @@ CurveBezier::ModifyStart( const Point3d& ptNewStart)
|
||||
// modifico il primo punto di controllo
|
||||
m_vPtCtrl[0] = ptNewStart ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1621,6 +1708,8 @@ CurveBezier::ModifyEnd( const Point3d& ptNewEnd)
|
||||
// modifico l'ultimo punto di controllo
|
||||
m_vPtCtrl[m_nDeg] = ptNewEnd ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1645,6 +1734,8 @@ CurveBezier::TrimStartAtParam( double dUTrim)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1669,6 +1760,8 @@ CurveBezier::TrimEndAtParam( double dUTrim)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1735,7 +1828,7 @@ CurveBezier::ExtendStartByLen( double dLenExt)
|
||||
return false ;
|
||||
// determino la lunghezza originale della curva
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
if ( ! GetLengthAtParam( 1, dLen))
|
||||
return false ;
|
||||
// stimo il valore del parametro al nuovo punto iniziale
|
||||
double dUTrim = - dLenExt / dLen ;
|
||||
@@ -1769,6 +1862,9 @@ CurveBezier::ExtendStartByLen( double dLenExt)
|
||||
m_vWeCtrl[i] = vWeCtrl[i] ;
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -1783,7 +1879,7 @@ CurveBezier::ExtendEndByLen( double dLenExt)
|
||||
return false ;
|
||||
// determino la lunghezza originale della curva
|
||||
double dLen ;
|
||||
if ( ! GetLength( dLen))
|
||||
if ( ! GetLengthAtParam( 1, dLen))
|
||||
return false ;
|
||||
// stimo il valore del parametro al nuovo punto finale
|
||||
double dUTrim = 1 + dLenExt / dLen ;
|
||||
@@ -1817,6 +1913,9 @@ CurveBezier::ExtendEndByLen( double dLenExt)
|
||||
m_vWeCtrl[i] = vWeCtrl[i] ;
|
||||
}
|
||||
}
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
return true ;
|
||||
@@ -1830,6 +1929,10 @@ CurveBezier::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// traslo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1852,6 +1955,10 @@ CurveBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// ruoto Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1894,6 +2001,8 @@ CurveBezier::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
|
||||
if ( ! bOk)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1923,6 +2032,8 @@ CurveBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1947,6 +2058,8 @@ CurveBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1971,11 +2084,18 @@ CurveBezier::ToGlob( const Frame3d& frRef)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -1995,11 +2115,18 @@ CurveBezier::ToLoc( const Frame3d& frRef)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->ToLoc( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2019,11 +2146,18 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->LocToLoc( frOri, frDest) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -2035,3 +2169,42 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveBezier::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveBezier::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+43
-23
@@ -19,7 +19,8 @@
|
||||
#include "DllMain.h"
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgtNumCollection.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
@@ -51,10 +52,16 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override { return true ; }
|
||||
@@ -110,7 +117,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
ICurve* CopyParamRange( double dUStart, double dUEnd) const override ;
|
||||
bool Invert( void) override ;
|
||||
bool SimpleOffset( double dDist, int nType = OFF_FILLET) override
|
||||
{ return false ; } // l'offset di crvBezier non è crvBezier tranne in casi molto particolari
|
||||
{ return false ; } // l'offset di crvBezier non è crvBezier tranne in casi molto particolari
|
||||
bool ModifyStart( const Point3d& ptNewStart) override ;
|
||||
bool ModifyEnd( const Point3d& ptNewEnd) override ;
|
||||
bool SetExtrusion( const Vector3d& vtExtr) override
|
||||
@@ -131,6 +138,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
bool SetControlPoint( int nInd, const Point3d& ptCtrl) override ;
|
||||
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
|
||||
bool FromArc( const ICurveArc& crArc) override ;
|
||||
bool FromLine( const ICurveLine& crLine) override ;
|
||||
int GetDegree( void) const override
|
||||
{ return m_nDeg ; }
|
||||
bool IsRational( void) const override
|
||||
@@ -144,11 +152,14 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
CurveBezier( void) ;
|
||||
CurveBezier( const CurveBezier& cbSrc)
|
||||
CurveBezier( const CurveBezier& cbSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( cbSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy constructor error")}
|
||||
CurveBezier& operator =( const CurveBezier& cbSrc)
|
||||
@@ -157,6 +168,8 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool ApproxWithLines( int nStep, PolyLine& PL) const ;
|
||||
bool GetApproxLength( double& dLen) const ;
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveBezier& cbSrc) ;
|
||||
@@ -173,33 +186,40 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
bool ApproxWithArcsXY(double dLinTol, double dAngTolDeg, PolyArc& PA) const;
|
||||
bool BiArcOrSplit(int nLev, PolyLine& PL, double dLinTol, double dAngTolDeg, PolyArc& PA) const;
|
||||
bool ToPowerBase( PolynomialPoint3d& pol3P) const ;
|
||||
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
|
||||
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
static const int MAXDEG = 11 ;
|
||||
static const int MAXDEG = 21 ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDeg ; // grado
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDeg ; // grado
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CurveBezier* CreateBasicCurveBezier( void)
|
||||
{ return (static_cast<CurveBezier*>( CreateGeoObj( CRV_BEZIER))) ; }
|
||||
{ return ( static_cast<CurveBezier*>( CreateGeoObj( CRV_BEZIER))) ; }
|
||||
inline CurveBezier* CloneBasicCurveBezier( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER)
|
||||
return nullptr ;
|
||||
return (static_cast<CurveBezier*>(pGObj->Clone())) ; }
|
||||
return ( static_cast<CurveBezier*>( pGObj->Clone())) ; }
|
||||
inline const CurveBezier* GetBasicCurveBezier( const IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<const CurveBezier*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER)
|
||||
return nullptr ;
|
||||
return ( static_cast<const CurveBezier*>( pGObj)) ; }
|
||||
inline CurveBezier* GetBasicCurveBezier( IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<CurveBezier*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER)
|
||||
return nullptr ;
|
||||
return ( static_cast<CurveBezier*>( pGObj)) ; }
|
||||
|
||||
+70
-12
@@ -16,7 +16,8 @@
|
||||
#include "CurveComposite.h"
|
||||
#include "CalcDerivate.h"
|
||||
#include "BiArcs.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "RemoveCurveDefects.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkPolyArc.h"
|
||||
@@ -56,28 +57,78 @@ ICurve*
|
||||
CurveByApprox::GetCurve( int nType, double dLinTol, double dAngTolDeg, double dLinFea)
|
||||
{
|
||||
// se da approssimare con archi
|
||||
if ( nType == ARCS_CORNER) {
|
||||
if ( nType == ARCS || nType == ARCS_CORNER) {
|
||||
// calcolo approssimazione
|
||||
PolyArc PA ;
|
||||
if ( ! GetArcs( dLinTol, dAngTolDeg, dLinFea, PA))
|
||||
return nullptr ;
|
||||
if ( nType == ARCS) {
|
||||
if ( ! GetArcs( dLinTol, dAngTolDeg, PA))
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! GetArcsCorner( dLinTol, dAngTolDeg, dLinFea, PA))
|
||||
return nullptr ;
|
||||
}
|
||||
// creo la composita formata da questa approssimazione
|
||||
PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ;
|
||||
if ( ! pCC->FromPolyArc( PA))
|
||||
return nullptr ;
|
||||
// elimino eventuali Small Z
|
||||
pCC->RemoveSmallDefects( dLinTol, dAngTolDeg) ;
|
||||
// eventuale fusione di curve compatibili
|
||||
pCC->MergeCurves( dLinTol, dAngTolDeg) ;
|
||||
// restituisco la curva
|
||||
return Release( pCC) ;
|
||||
}
|
||||
// altrimenti con curve di Bezier cubiche
|
||||
// !!! NON ANCORA IMPLEMENTATA !!!
|
||||
else if ( nType == CUBIC_BEZIERS) {
|
||||
// !!! NON ANCORA IMPLEMENTATA !!!
|
||||
return nullptr ;
|
||||
}
|
||||
// tipi non previsti
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveByApprox::GetArcs( double dLinTol, double dAngTolDeg, double dLinFea, PolyArc& PA)
|
||||
CurveByApprox::GetArcs( double dLinTol, double dAngTolDeg, PolyArc& PA)
|
||||
{
|
||||
// pulisco il poliarco
|
||||
PA.Clear() ;
|
||||
|
||||
// calcolo una parametrizzazione
|
||||
if ( ! CalcParameterization())
|
||||
return false ;
|
||||
|
||||
// calcolo le tangenti
|
||||
if ( ! CalcAkimaTangents( false))
|
||||
return false ;
|
||||
|
||||
// approssimo come unico tratto
|
||||
|
||||
// creo la polilinea che unisce i punti
|
||||
PolyLine PL ;
|
||||
int nPnt = int( m_vPnt.size()) ;
|
||||
for ( int j = 0 ; j < nPnt ; ++ j)
|
||||
PL.AddUPoint( j, m_vPnt[j]) ;
|
||||
// verifico se retta verticale
|
||||
BBox3d b3PL ;
|
||||
if ( ! PL.GetLocalBBox( b3PL))
|
||||
return false ;
|
||||
if ( b3PL.GetDimX() < EPS_SMALL && b3PL.GetDimY() < EPS_SMALL) {
|
||||
PA.AddUPoint( 0, m_vPnt[0], 0) ;
|
||||
PA.AddUPoint( nPnt - 1, m_vPnt[nPnt - 1], 0) ;
|
||||
}
|
||||
// altrimenti eseguo l'approssimazione con archi
|
||||
else {
|
||||
if ( ! BiArcOrSplit( 0, PL, dLinTol, dAngTolDeg, PA))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveByApprox::GetArcsCorner( double dLinTol, double dAngTolDeg, double dLinFea, PolyArc& PA)
|
||||
{
|
||||
// pulisco il poliarco
|
||||
PA.Clear() ;
|
||||
@@ -102,9 +153,18 @@ CurveByApprox::GetArcs( double dLinTol, double dAngTolDeg, double dLinFea, PolyA
|
||||
PolyLine PL ;
|
||||
for ( int j = nPrev ; j <= m_vSplits[i] ; ++ j)
|
||||
PL.AddUPoint( j, m_vPnt[j]) ;
|
||||
// eseguo l'approssimazione con archi
|
||||
if ( ! BiArcOrSplit( 0, PL, dLinTol, dAngTolDeg, PA))
|
||||
// verifico se retta verticale
|
||||
BBox3d b3PL ;
|
||||
if ( ! PL.GetLocalBBox( b3PL))
|
||||
return false ;
|
||||
if ( b3PL.GetDimX() < EPS_SMALL && b3PL.GetDimY() < EPS_SMALL) {
|
||||
PA.AddUPoint( m_vSplits[i], m_vPnt[m_vSplits[i]], 0) ;
|
||||
}
|
||||
// altrimenti eseguo l'approssimazione con archi
|
||||
else {
|
||||
if ( ! BiArcOrSplit( 0, PL, dLinTol, dAngTolDeg, PA))
|
||||
return false ;
|
||||
}
|
||||
// salvo fine come prox inizio
|
||||
nPrev = m_vSplits[i] ;
|
||||
}
|
||||
@@ -453,11 +513,9 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
||||
return true ;
|
||||
// costruisco la retta che li unisce
|
||||
PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCC))
|
||||
if ( IsNull( pCC) || ! pCC->FromPolyLine( PL))
|
||||
return false ;
|
||||
if ( ! pCC->FromPolyLine( PL))
|
||||
return false ;
|
||||
pCrv.Set( Release( pCC)) ;
|
||||
pCrv.Set( pCC) ;
|
||||
dMaxDist = 0 ;
|
||||
}
|
||||
// se la polilinea ha un solo punto, esco
|
||||
|
||||
+6
-6
@@ -14,10 +14,10 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CalcDerivate.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveByInterp.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkBiArcs.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkBiArcs.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ CurveByInterp::GetCurve( int nMethod, int nType)
|
||||
// se richiesti biarchi
|
||||
if ( nType == BIARCS) {
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return nullptr ;
|
||||
// ciclo sugli intervalli
|
||||
@@ -83,13 +83,13 @@ CurveByInterp::GetCurve( int nMethod, int nType)
|
||||
// se richieste curve di Bezier cubiche
|
||||
if ( nType == CUBIC_BEZIERS) {
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return nullptr ;
|
||||
// ciclo sugli intervalli
|
||||
for ( int i = 1 ; i < int( m_vPnt.size()) ; ++ i) {
|
||||
// creo una curva di Bezier cubica per ogni intervallo
|
||||
PtrOwner<ICurveBezier> pCBez( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCBez))
|
||||
return nullptr ;
|
||||
pCBez->Init( 3, false) ;
|
||||
|
||||
+750
-216
File diff suppressed because it is too large
Load Diff
+88
-27
@@ -1,12 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2021
|
||||
// EgalTech 2013-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CurveComposite.h Data : 03.04.21 Versione : 2.3d1
|
||||
// File : CurveComposite.h Data : 24.03.22 Versione : 2.4c2
|
||||
// Contenuto : Dichiarazione della classe Curva composita.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 16.04.13 DS Creazione modulo.
|
||||
// 24.03.22 DS Aggiunto metodo AddLineTg.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -20,6 +21,8 @@
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include <deque>
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{
|
||||
@@ -50,10 +53,16 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -141,10 +150,11 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool IsParamAtJoint( double dU) const override ;
|
||||
ICurve* RemoveFirstOrLastCurve( bool bLast = true) override ;
|
||||
bool ChangeStartPoint( double dU) override ;
|
||||
bool AddPoint( const Point3d& ptStart) override ;
|
||||
bool AddPoint( const Point3d& ptStart) override ; // funzione per aggiungere il ptStart prima di usare la funzione AddLine
|
||||
bool AddLine( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddArcTg( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddLineTg( double dLen, bool bEndOrStart = true) override ;
|
||||
bool AddArc2P( const Point3d& ptOther, const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddArcTg( const Point3d& ptNew, bool bEndOrStart = true) override ;
|
||||
bool AddJoint( double dU) override ;
|
||||
bool ModifyJoint( int nU, const Point3d& ptNewJoint) override ;
|
||||
bool RemoveJoint( int nU) override ;
|
||||
@@ -153,22 +163,34 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
bool ModifyCurveToLine( int nCrv) override ;
|
||||
bool ArcsToBezierCurves( void) override ;
|
||||
bool ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDeg) override ;
|
||||
bool StraightArcsToLines( double dLinTol, double dAngTolDeg) override ;
|
||||
bool MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd = true, bool bNeedSameProp = false) override ;
|
||||
bool RemoveSmallParts( double dLinTol, double dAngTolDeg) override ;
|
||||
bool RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes = false) override ;
|
||||
bool RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ;
|
||||
bool IsAPoint( void) const override ;
|
||||
bool IsALine( double dLinTol, Point3d& ptStart, Point3d& ptEnd) const override ;
|
||||
bool IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ;
|
||||
bool SetCurveTempProp( int nCrv, int nProp) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp) const override ;
|
||||
|
||||
bool IsARectangle( double dLinTol, Point3d& ptP, Vector3d& vtL1, Vector3d& vtL2) const override ;
|
||||
bool IsATrapezoid( double dLinTol, Point3d& ptP, Vector3d& vtB1, Vector3d& vtL1, Vector3d& vtB2) const override ;
|
||||
bool SetCurveTempProp( int nCrv, int nProp, int nPropInd = 0) override ;
|
||||
bool GetCurveTempProp( int nCrv, int& nProp, int nPropInd = 0) const override ;
|
||||
bool SetCurveTempParam( int nCrv, double dParam, int nParamInd = 0) override ;
|
||||
bool GetCurveTempParam( int nCrv, double& dParam, int nParamInd = 0) const override ;
|
||||
bool FromPoint( Point3d& ptStart) override ; // funzione per settare la curva ad un unico punto
|
||||
bool GetOnlyPoint( Point3d& ptStart) const override ; // funzione per recuperare l'unico punto da cui è composta la curva ( degenere)
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
CurveComposite( void) ;
|
||||
CurveComposite( const CurveComposite& ccSrc)
|
||||
CurveComposite( const CurveComposite& ccSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( ccSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy constructor error") }
|
||||
CurveComposite& operator =( const CurveComposite& ccSrc)
|
||||
@@ -177,43 +199,82 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool RelocateFrom( CurveComposite& ccSrc) ;
|
||||
bool GetApproxLength( double& dLen) const ;
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveComposite& ccSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool TestClosure( void) ;
|
||||
bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
|
||||
bool AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
|
||||
bool GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ;
|
||||
bool SimpleOffsetXY( double dDist, int nType = OFF_FILLET) ;
|
||||
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
|
||||
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2, IS_A_POINT = 3} ;
|
||||
|
||||
private :
|
||||
typedef std::deque<ICurve*> PCRVSMPL_DEQUE ;
|
||||
typedef PCRVSMPL_DEQUE::iterator PCSD_ITER ;
|
||||
typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
|
||||
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
|
||||
double m_dThick ; // spessore
|
||||
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
mutable PCSD_CONST_ITER m_Iter ; // iteratore
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CurveComposite* CreateBasicCurveComposite( void)
|
||||
{ return (static_cast<CurveComposite*>( CreateGeoObj( CRV_COMPO))) ; }
|
||||
{ return ( static_cast<CurveComposite*>( CreateGeoObj( CRV_COMPO))) ; }
|
||||
inline CurveComposite* CloneBasicCurveComposite( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_COMPO)
|
||||
return nullptr ;
|
||||
return (static_cast<CurveComposite*>(pGObj->Clone())) ; }
|
||||
return ( static_cast<CurveComposite*>( pGObj->Clone())) ; }
|
||||
inline const CurveComposite* GetBasicCurveComposite( const IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<const CurveComposite*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_COMPO)
|
||||
return nullptr ;
|
||||
return ( static_cast<const CurveComposite*>( pGObj)) ; }
|
||||
inline CurveComposite* GetBasicCurveComposite( IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<CurveComposite*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_COMPO)
|
||||
return nullptr ;
|
||||
return ( static_cast<CurveComposite*>( pGObj)) ; }
|
||||
inline CurveComposite* ConvertCurveToBasicComposite( IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || ( pGObj->GetType() & GEO_CURVE) == 0) {
|
||||
delete pGObj ;
|
||||
return nullptr ;
|
||||
}
|
||||
CurveComposite* pCrvCo = CreateBasicCurveComposite() ;
|
||||
if ( pCrvCo == nullptr) {
|
||||
delete pGObj ;
|
||||
return nullptr ;
|
||||
}
|
||||
ICurve* pCrv = static_cast<ICurve*>( pGObj) ;
|
||||
Vector3d vtExtr ;
|
||||
if ( pCrv->GetExtrusion( vtExtr) && ! vtExtr.IsSmall())
|
||||
pCrvCo->SetExtrusion( vtExtr) ;
|
||||
double dThick ;
|
||||
if ( pCrv->GetThickness( dThick) && abs( dThick) > EPS_SMALL)
|
||||
pCrvCo->SetThickness( dThick) ;
|
||||
for ( int i = 0 ; i < 2 ; ++ i) {
|
||||
int nProp = pCrv->GetTempProp( i) ;
|
||||
if ( nProp != 0)
|
||||
pCrvCo->SetTempProp( nProp, i) ;
|
||||
}
|
||||
for ( int i = 0 ; i < 2 ; ++ i) {
|
||||
double dParam = pCrv->GetTempParam( i) ;
|
||||
if ( abs( dParam) > EPS_SMALL)
|
||||
pCrvCo->SetTempParam( dParam, i) ;
|
||||
}
|
||||
pCrvCo->AddCurve( pCrv) ;
|
||||
return pCrvCo ;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
+126
-25
@@ -14,11 +14,13 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveLine.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Voronoi.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <new>
|
||||
|
||||
@@ -29,13 +31,15 @@ GEOOBJ_REGISTER( CRV_LINE, NGE_C_LIN, CurveLine) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveLine::CurveLine( void)
|
||||
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick(), m_nTempProp()
|
||||
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick(),
|
||||
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CurveLine::~CurveLine( void)
|
||||
{
|
||||
ResetVoronoiObject() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -47,6 +51,8 @@ CurveLine::Set( const Point3d& ptStart, const Point3d& ptEnd)
|
||||
m_PtEnd = ptEnd ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -66,6 +72,8 @@ CurveLine::SetPVL( const Point3d& ptStart, const Vector3d& vtDir, double dLen)
|
||||
m_PtEnd = ptStart + vtDelta ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -83,6 +91,8 @@ CurveLine::SetPDL( const Point3d& ptStart, double dDirAngDeg, double dLen)
|
||||
m_PtEnd = ptStart + vtDelta ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -109,7 +119,7 @@ CurveLine::Clone( void) const
|
||||
bool
|
||||
CurveLine::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const CurveLine* pCL = dynamic_cast<const CurveLine*>( pGObjSrc) ;
|
||||
const CurveLine* pCL = GetBasicCurveLine( pGObjSrc) ;
|
||||
if ( pCL == nullptr)
|
||||
return false ;
|
||||
return CopyFrom( *pCL) ;
|
||||
@@ -123,7 +133,10 @@ CurveLine::CopyFrom( const CurveLine& clSrc)
|
||||
return true ;
|
||||
m_VtExtr = clSrc.m_VtExtr ;
|
||||
m_dThick = clSrc.m_dThick ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ;
|
||||
}
|
||||
|
||||
@@ -149,7 +162,7 @@ CurveLine::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
// dati generali di una curva
|
||||
if ( ! CurveDump( *this, sOut, bMM, szNewLine))
|
||||
return false ;
|
||||
// parametri : sono già compresi nei dati generali (PS e PE)
|
||||
// parametri : sono già compresi nei dati generali (PS e PE)
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -210,7 +223,7 @@ CurveLine::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
|
||||
return false ;
|
||||
// assegno il box in locale
|
||||
b3Loc.Set( m_PtStart, m_PtEnd) ;
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
|
||||
Point3d ptMinExtr = b3Loc.GetMin() + m_VtExtr * m_dThick ;
|
||||
Point3d ptMaxExtr = b3Loc.GetMax() + m_VtExtr * m_dThick ;
|
||||
@@ -228,7 +241,7 @@ CurveLine::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// porto gli estremi nel riferimento passato
|
||||
@@ -238,7 +251,7 @@ CurveLine::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
ptFrEnd.ToGlob( frRef) ;
|
||||
// assegno il box nel riferimento
|
||||
b3Ref.Set( ptFrStart, ptFrEnd) ;
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
// se c'è estrusione, devo tenerne conto
|
||||
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
|
||||
Vector3d vtFrExtr = m_VtExtr ;
|
||||
vtFrExtr.ToGlob( frRef) ;
|
||||
@@ -256,7 +269,7 @@ bool
|
||||
CurveLine::Validate( void)
|
||||
{
|
||||
if ( m_nStatus == TO_VERIFY)
|
||||
m_nStatus = ( ! AreSamePointApprox( m_PtStart, m_PtEnd) ? OK : ERR) ;
|
||||
m_nStatus = ( m_PtStart.IsValid() && m_PtEnd.IsValid() && ! AreSamePointApprox( m_PtStart, m_PtEnd) ? OK : ERR) ;
|
||||
|
||||
return ( m_nStatus == OK) ;
|
||||
}
|
||||
@@ -353,10 +366,7 @@ CurveLine::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1,
|
||||
return false ;
|
||||
|
||||
// il parametro U deve essere compreso tra 0 e 1
|
||||
if ( dU < 0)
|
||||
dU = 0 ;
|
||||
else if ( dU > 1)
|
||||
dU = 1 ;
|
||||
dU = Clamp( dU, 0., 1.) ;
|
||||
|
||||
// calcolo del punto
|
||||
ptPos = Media( m_PtStart, m_PtEnd, dU) ;
|
||||
@@ -380,7 +390,7 @@ CurveLine::GetLength( double& dLen) const
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// la lunghezza è la distanza tra gli estremi
|
||||
// la lunghezza è la distanza tra gli estremi
|
||||
dLen = Dist( m_PtStart, m_PtEnd) ;
|
||||
|
||||
return ( dLen > EPS_SMALL) ;
|
||||
@@ -406,7 +416,7 @@ CurveLine::GetLengthAtParam( double dU, double& dLen) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
// la lunghezza totale è la distanza tra gli estremi
|
||||
// la lunghezza totale è la distanza tra gli estremi
|
||||
double dTotLen = Dist( m_PtStart, m_PtEnd) ;
|
||||
|
||||
// fine
|
||||
@@ -438,7 +448,7 @@ CurveLine::GetParamAtLength( double dLen, double& dU) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
// la lunghezza totale è la distanza tra gli estremi
|
||||
// la lunghezza totale è la distanza tra gli estremi
|
||||
double dTotLen = Dist( m_PtStart, m_PtEnd) ;
|
||||
|
||||
// se dopo fine, errore
|
||||
@@ -557,6 +567,8 @@ CurveLine::Invert( void)
|
||||
// inverto i punti estremi
|
||||
swap( m_PtStart, m_PtEnd) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -588,6 +600,8 @@ CurveLine::SimpleOffset( double dDist, int nType)
|
||||
m_PtStart += vtDir * dDist ;
|
||||
m_PtEnd += vtDir * dDist ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -608,6 +622,8 @@ CurveLine::ModifyStart( const Point3d& ptNewStart)
|
||||
// assegno il nuovo inizio
|
||||
m_PtStart = ptNewStart ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -628,6 +644,8 @@ CurveLine::ModifyEnd( const Point3d& ptNewEnd)
|
||||
// assegno la nuova fine
|
||||
m_PtEnd = ptNewEnd ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -639,7 +657,7 @@ bool
|
||||
CurveLine::TrimStartAtParam( double dUTrim)
|
||||
{
|
||||
// riporto i parametri nel loro range
|
||||
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
|
||||
dUTrim = Clamp( dUTrim, 0., 1.) ;
|
||||
|
||||
// recupero lunghezza
|
||||
double dLen ;
|
||||
@@ -655,7 +673,7 @@ bool
|
||||
CurveLine::TrimEndAtParam( double dUTrim)
|
||||
{
|
||||
// riporto i parametri nel loro range
|
||||
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
|
||||
dUTrim = Clamp( dUTrim, 0., 1.) ;
|
||||
|
||||
// recupero lunghezza
|
||||
double dLen ;
|
||||
@@ -703,6 +721,8 @@ CurveLine::TrimStartAtLen( double dLenTrim)
|
||||
if ( dLenTrim > EPS_ZERO)
|
||||
m_PtStart = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -727,6 +747,8 @@ CurveLine::TrimEndAtLen( double dLenTrim)
|
||||
if ( ( dLen - dLenTrim) > EPS_ZERO)
|
||||
m_PtEnd = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -749,6 +771,8 @@ CurveLine::ExtendStartByLen( double dLenExt)
|
||||
// sposto il punto iniziale
|
||||
m_PtStart -= vtDir * dLenExt ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -771,6 +795,8 @@ CurveLine::ExtendEndByLen( double dLenExt)
|
||||
// sposto il punto finale
|
||||
m_PtEnd += vtDir * dLenExt ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -784,6 +810,11 @@ CurveLine::Translate( const Vector3d& vtMove)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// traslo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -801,10 +832,14 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dell'asse di rotazione
|
||||
// verifico validità dell'asse di rotazione
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// ruoto Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -836,6 +871,8 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d
|
||||
if ( AreSamePointApprox( ptNewStart, ptNewEnd))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -861,10 +898,12 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del piano di specchiatura
|
||||
// verifico validità del piano di specchiatura
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -884,10 +923,12 @@ CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& v
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei parametri
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo di Voronoi
|
||||
ResetVoronoiObject() ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -912,10 +953,18 @@ CurveLine::ToGlob( const Frame3d& frRef)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -930,10 +979,18 @@ CurveLine::ToLoc( const Frame3d& frRef)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->ToLoc( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -948,13 +1005,18 @@ CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei frame
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// trasformo Voronoi
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
m_pVoronoiObj->LocToLoc( frOri, frDest) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
@@ -990,3 +1052,42 @@ CurveLine::CalcPointParamPosiz( const Point3d& ptP, bool bOnXY, double& dU, int&
|
||||
nPos = ICurve::PP_MID ; // nell'interno
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::CalcVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// creo oggetto vroni con la curva
|
||||
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Voronoi*
|
||||
CurveLine::GetVoronoiObject() const
|
||||
{
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
|
||||
// se non è stato calcolato, lo calcolo
|
||||
if ( m_pVoronoiObj == nullptr)
|
||||
CalcVoronoiObject() ;
|
||||
|
||||
// restituisco Voronoi
|
||||
return m_pVoronoiObj ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CurveLine::ResetVoronoiObject() const
|
||||
{
|
||||
if ( m_pVoronoiObj != nullptr)
|
||||
delete m_pVoronoiObj ;
|
||||
m_pVoronoiObj = nullptr ;
|
||||
}
|
||||
|
||||
+37
-17
@@ -19,6 +19,8 @@
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
|
||||
class Voronoi ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
{
|
||||
@@ -49,10 +51,16 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // ICurve
|
||||
bool IsSimple( void) const override
|
||||
@@ -138,43 +146,55 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
CurveLine( void) ;
|
||||
CurveLine( const CurveLine& clSrc)
|
||||
CurveLine( const CurveLine& clSrc) : m_pVoronoiObj( nullptr)
|
||||
{ if ( ! CopyFrom( clSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveLine : copy constructor error") }
|
||||
CurveLine& operator =( const CurveLine& clSrc)
|
||||
{ if ( ! CopyFrom( clSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "CurveLine : copy error")
|
||||
return *this ; }
|
||||
Voronoi* GetVoronoiObject( void) const ;
|
||||
void ResetVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
bool CopyFrom( const CurveLine& clSrc) ;
|
||||
bool Validate( void) ;
|
||||
bool Validate( void) ;
|
||||
bool CalcVoronoiObject( void) const ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
Point3d m_PtStart ; // punto iniziale
|
||||
Point3d m_PtEnd ; // punto finale
|
||||
Vector3d m_VtExtr ; // vettore estrusione
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
Point3d m_PtStart ; // punto iniziale
|
||||
Point3d m_PtEnd ; // punto finale
|
||||
Vector3d m_VtExtr ; // vettore estrusione
|
||||
double m_dThick ; // spessore
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable Voronoi* m_pVoronoiObj ; // Voronoi
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline CurveLine* CreateBasicCurveLine( void)
|
||||
{ return (static_cast<CurveLine*>( CreateGeoObj( CRV_LINE))) ; }
|
||||
{ return ( static_cast<CurveLine*>( CreateGeoObj( CRV_LINE))) ; }
|
||||
inline CurveLine* CloneBasicCurveLine( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
|
||||
return nullptr ;
|
||||
return (static_cast<CurveLine*>(pGObj->Clone())) ; }
|
||||
return ( static_cast<CurveLine*>( pGObj->Clone())) ; }
|
||||
inline const CurveLine* GetBasicCurveLine( const IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<const CurveLine*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
|
||||
return nullptr ;
|
||||
return ( static_cast<const CurveLine*>( pGObj)) ; }
|
||||
inline CurveLine* GetBasicCurveLine( IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<CurveLine*>(pGObj)) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
|
||||
return nullptr ;
|
||||
return ( static_cast<CurveLine*>( pGObj)) ; }
|
||||
|
||||
+104
-101
@@ -1,39 +1,42 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
// EgalTech 2020-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DistLineLine.h Data : 06.11.20 Versione : 2.2k1
|
||||
// File : DistLineLine.cpp Data : 10.05.24 Versione : 2.6e3
|
||||
// Contenuto : Implementazione della classe distanza fra elementi lineari.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.11.20 LM Creazione modulo.
|
||||
//
|
||||
// 12.08.22 DS Correzioni e migliorie varie.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "DistLineLine.h"
|
||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||
#include "/EgtDev/Include/EGkGeoConst.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
DistLineLine::DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1,
|
||||
const Point3d& ptSt2, const Point3d& ptEn2,
|
||||
bool bIsSegment1, bool bIsSegment2)
|
||||
{
|
||||
// reset oggetto
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
// calcolo direzione segmenti
|
||||
Vector3d vtD1 = ptEn1 - ptSt1 ;
|
||||
double dLen1 = vtD1.Len() ;
|
||||
Vector3d vtD2 = ptEn2 - ptSt2 ;
|
||||
double dLen2 = vtD1.Len() ;
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) {
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
double dLen2 = vtD2.Len() ;
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL)
|
||||
return ;
|
||||
}
|
||||
vtD1 /= dLen1 ;
|
||||
vtD2 /= dLen2 ;
|
||||
// eseguo
|
||||
Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ;
|
||||
}
|
||||
|
||||
@@ -43,37 +46,43 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1, bool bIsSegment2)
|
||||
{
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) {
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
// reset oggetto
|
||||
m_dSqDist = - 1 ;
|
||||
m_dDist = - 1 ;
|
||||
// verifico segmenti
|
||||
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL)
|
||||
return ;
|
||||
}
|
||||
// eseguo
|
||||
Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetSqDist( double& dSqDist)
|
||||
DistLineLine::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
|
||||
dSqDist = m_dSqDist ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetDist( double& dDist)
|
||||
DistLineLine::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
dDist = sqrt( m_dSqDist) ;
|
||||
|
||||
if ( m_dDist < 0)
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
dDist = m_dDist ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
|
||||
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -84,55 +93,48 @@ DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistLineLine::GetParamsAtMinDistPoints( double& dPar1, double& dPar2)
|
||||
DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
dPar1 = m_dPar1 ;
|
||||
dPar2 = m_dPar2 ;
|
||||
dPos1 = m_dPos1 ;
|
||||
dPos2 = m_dPos2 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Calcola la distanza fra i due elemnti lineari, i punti di minima distanza e
|
||||
// i loro rispettivi parametri.
|
||||
// Se la coppia di punti di minima distanza non è unica ne viene scelta una
|
||||
// in base a comodità di calcolo.
|
||||
// Calcola la distanza fra i due elementi lineari, i punti di minima distanza e le loro posizioni.
|
||||
// Se i due elementi sono paralleli i punti di minimo sono scelti secondo convenienza.
|
||||
void
|
||||
DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1, bool bIsSegment2)
|
||||
{
|
||||
// Caso di elementi lineari paralleli/antiparalleli
|
||||
// Se elementi paralleli o antiparalleli
|
||||
if ( AreSameOrOppositeVectorExact( vtD1, vtD2)) {
|
||||
// Almeno un elemento è una retta
|
||||
if ( ! ( bIsSegment1 && bIsSegment2)) {
|
||||
// Il primo elemento è segmento, quindi deve essere una retta il secondo
|
||||
if ( bIsSegment1) {
|
||||
Vector3d vtStSt = ptSt1 - ptSt2 ;
|
||||
double dLong = vtStSt * vtD2 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD2 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_dPar1 = 0 ;
|
||||
m_dPar2 = dLong ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptSt2 + dLong * vtD2 ;
|
||||
}
|
||||
// Il primo elemento è una retta
|
||||
else {
|
||||
Vector3d vtStSt = ptSt2 - ptSt1 ;
|
||||
double dLong = vtStSt * vtD1 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD1 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_dPar1 = dLong ;
|
||||
m_dPar2 = 0 ;
|
||||
m_ptMinDist1 = ptSt1 + dLong * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 ;
|
||||
}
|
||||
// Se il primo elemento è una retta infinita
|
||||
if ( ! bIsSegment1) {
|
||||
Vector3d vtStSt = ptSt2 - ptSt1 ;
|
||||
double dLong = vtStSt * vtD1 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD1 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dPos1 = dLong ;
|
||||
m_dPos2 = 0 ;
|
||||
m_ptMinDist1 = ptSt1 + dLong * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 ;
|
||||
}
|
||||
// se altrimenti il secondo elemento è una retta infinita
|
||||
else if ( ! bIsSegment2) {
|
||||
Vector3d vtStSt = ptSt1 - ptSt2 ;
|
||||
double dLong = vtStSt * vtD2 ;
|
||||
Vector3d vtDist = vtStSt - dLong * vtD2 ;
|
||||
m_dSqDist = vtDist.SqLen() ;
|
||||
m_dPos1 = 0 ;
|
||||
m_dPos2 = dLong ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptSt2 + dLong * vtD2 ;
|
||||
}
|
||||
// Entrambi gli elementi sono segmenti
|
||||
// altrimenti entrambi gli elementi sono segmenti
|
||||
else {
|
||||
Point3d ptEn1 = ptSt1 + dLen1 * vtD1 ;
|
||||
Point3d ptEn2 = ptSt2 + dLen2 * vtD2 ;
|
||||
@@ -140,7 +142,7 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen
|
||||
Vector3d vtStEn = ptEn2 - ptSt1 ;
|
||||
double dStU = vtStSt * vtD1 ;
|
||||
double dEnU = vtStEn * vtD1 ;
|
||||
// Classifico i punti del segmento segmento in base alla loro
|
||||
// Classifico i punti del secondo segmento in base alla loro
|
||||
// coordinata rispetto all'ordinamento generato dal primo.
|
||||
double dMinPar, dMaxPar ;
|
||||
Point3d ptMinPar, ptMaxPar ;
|
||||
@@ -159,70 +161,71 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen
|
||||
// Possibili posizioni reciproche dei segmenti
|
||||
if ( dMinPar > dLen1) {
|
||||
m_dSqDist = SqDist( ptEn1, ptMinPar) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_ptMinDist1 = ptEn1 ;
|
||||
m_ptMinDist2 = ptMinPar ;
|
||||
m_dPar1 = dLen1 ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPos1 = dLen1 ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
else if ( dMinPar > 0) {
|
||||
m_dSqDist = std::max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_dSqDist = max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_ptMinDist1 = ptSt1 + dMinPar * vtD1 ;
|
||||
m_ptMinDist2 = ptMinPar ;
|
||||
m_dPar1 = dMinPar ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPos1 = dMinPar ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
else if ( dMaxPar > 0) {
|
||||
m_dSqDist = std::max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_dSqDist = max( vtStSt * vtStSt - dStU * dStU, 0.) ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptSt2 + ( ptSt1 - ptSt2) * vtD2 * vtD2 ;
|
||||
m_dPar1 = 0 ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPos1 = 0 ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
else {
|
||||
m_dSqDist = SqDist( ptSt1, ptMaxPar) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
m_ptMinDist1 = ptSt1 ;
|
||||
m_ptMinDist2 = ptMaxPar ;
|
||||
m_dPar1 = 0 ;
|
||||
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
m_dPos1 = 0 ;
|
||||
m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
// Caso generale
|
||||
Vector3d vtDist0 = ptSt2 - ptSt1 ;
|
||||
double dDist01 = vtDist0 * vtD1 ;
|
||||
double dDist02 = vtDist0 * vtD2 ;
|
||||
double dDotD1D2 = vtD1 * vtD2 ;
|
||||
double dT1 = dDist01 + ( ( dDist01 * dDotD1D2 - dDist02) * dDotD1D2) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
double dT2 = ( dDist01 * dDotD1D2 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
double dMin1 = - INFINITO ;
|
||||
double dMax1 = INFINITO ;
|
||||
double dMin2 = - INFINITO ;
|
||||
double dMax2 = INFINITO ;
|
||||
double dSt1On2 = ( ptSt1 - ptSt2) * vtD2 ;
|
||||
double dEn1On2 = ( ptSt1 + dLen1 * vtD1 - ptSt2) * vtD2 ;
|
||||
if ( bIsSegment1) {
|
||||
dMin1 = 0 ;
|
||||
dMax1 = dLen1 ;
|
||||
dMin2 = std::min( dSt1On2, dEn1On2) ;
|
||||
dMax2 = std::max( dSt1On2, dEn1On2) ;
|
||||
else {
|
||||
// Posizioni a distanza minima tra rette illimitate
|
||||
Vector3d vtStSt = ptSt2 - ptSt1 ;
|
||||
double dDist01 = vtStSt * vtD1 ;
|
||||
double dDist02 = vtStSt * vtD2 ;
|
||||
double dDotD1D2 = vtD1 * vtD2 ;
|
||||
double dT1 = ( dDist01 - dDotD1D2 * dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
double dT2 = ( dDotD1D2 * dDist01 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
|
||||
// Posizioni minime e massime sui segmenti
|
||||
double dMin1 = ( bIsSegment1 ? 0 : -INFINITO) ;
|
||||
double dMax1 = ( bIsSegment1 ? dLen1 : INFINITO) ;
|
||||
double dMin2 = ( bIsSegment2 ? 0 : -INFINITO) ;
|
||||
double dMax2 = ( bIsSegment2 ? dLen2 : INFINITO) ;
|
||||
// Se entrambe le posizioni stanno nei segmenti
|
||||
if ( dT1 >= dMin1 && dT1 <= dMax1 && dT2 >= dMin2 && dT2 <= dMax2) {
|
||||
m_dPos1 = dT1 ;
|
||||
m_dPos2 = dT2 ;
|
||||
}
|
||||
// se altrimenti solo la prima sta nel segmento
|
||||
else if ( dT1 >= dMin1 && dT1 <= dMax1) {
|
||||
m_dPos2 = Clamp( dT2, dMin2, dMax2) ;
|
||||
m_dPos1 = Clamp( (( ptSt2 + m_dPos2 * vtD2) - ptSt1) * vtD1, dMin1, dMax1) ;
|
||||
}
|
||||
// se altrimenti solo la seconda sta nel segmento
|
||||
else if ( dT2 >= dMin2 && dT2 <= dMax2) {
|
||||
m_dPos1 = Clamp( dT1, dMin1, dMax1) ;
|
||||
m_dPos2 = Clamp( (( ptSt1 + m_dPos1 * vtD1) - ptSt2) * vtD2, dMin2, dMax2) ;
|
||||
}
|
||||
// altrimenti nessuna sta nel suo segmento
|
||||
else {
|
||||
m_dPos1 = Clamp( dT1, dMin1, dMax1) ;
|
||||
m_dPos2 = Clamp( (( ptSt1 + m_dPos1 * vtD1) - ptSt2) * vtD2, dMin2, dMax2) ;
|
||||
m_dPos1 = Clamp( (( ptSt2 + m_dPos2 * vtD2) - ptSt1) * vtD1, dMin1, dMax1) ;
|
||||
}
|
||||
m_ptMinDist1 = ptSt1 + m_dPos1 * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 + m_dPos2 * vtD2 ;
|
||||
m_dSqDist = SqDist( m_ptMinDist1, m_ptMinDist2) ;
|
||||
}
|
||||
if ( bIsSegment2) {
|
||||
double dSt2On1 = ( ptSt2 - ptSt1) * vtD1 ;
|
||||
double dEn2On1 = ( ptSt2 + dLen2 * vtD2 - ptSt1) * vtD1 ;
|
||||
dMin1 = std::max( dMin1, std::min( dSt2On1, dEn2On1)) ;
|
||||
dMax1 = std::min( dMax1, std::max( dSt2On1, dEn2On1)) ;
|
||||
dMin2 = std::max( dMin2, 0.) ;
|
||||
dMax2 = std::min( dMax2, dLen2) ;
|
||||
}
|
||||
m_dPar1 = Clamp( dT1, dMin1, dMax1) ;
|
||||
m_dPar2 = Clamp( dT2, dMin2, dMax2) ;
|
||||
m_ptMinDist1 = ptSt1 + m_dPar1 * vtD1 ;
|
||||
m_ptMinDist2 = ptSt2 + m_dPar2 * vtD2 ;
|
||||
m_dSqDist = SqDist( m_ptMinDist1, m_ptMinDist2) ;
|
||||
m_dDist = sqrt( m_dSqDist) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DistLineLine.h Data : 06.11.20 Versione : 2.2k1
|
||||
// Contenuto : Dichiarazione della classe distanza fra elementi lineari.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.11.20 LM Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkVector3d.h"
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class DistLineLine
|
||||
{
|
||||
public :
|
||||
DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1,
|
||||
const Point3d& ptSt2, const Point3d& ptEn2,
|
||||
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||
DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol) {
|
||||
double dSqDist ;
|
||||
return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ;
|
||||
}
|
||||
bool IsSmall( void) { return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void) { return IsEpsilon( EPS_ZERO) ; }
|
||||
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) ;
|
||||
bool GetParamsAtMinDistPoints( double& dPar1, double& dPar2) ;
|
||||
|
||||
private :
|
||||
void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||
private:
|
||||
double m_dSqDist ;
|
||||
double m_dDist ;
|
||||
double m_dPar1 ;
|
||||
double m_dPar2 ;
|
||||
Point3d m_ptMinDist1 ;
|
||||
Point3d m_ptMinDist2 ;
|
||||
} ;
|
||||
+5
-6
@@ -122,14 +122,13 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
|
||||
|
||||
// cerco la minima distanza per la polilinea
|
||||
MDCVECTOR vApproxMin ;
|
||||
MDCVECTOR::iterator Iter ;
|
||||
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
|
||||
return ;
|
||||
|
||||
// raffino i punti trovati
|
||||
double dPolishedPar ;
|
||||
Point3d ptPolishedQ ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// eseguo raffinamento
|
||||
if ( PolishMinDistPointCurve( ptP, arArc, *Iter, dPolishedPar, ptPolishedQ)) {
|
||||
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
|
||||
@@ -148,7 +147,7 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetSqDist( double& dSqDist)
|
||||
DistPointArc::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -159,7 +158,7 @@ DistPointArc::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetDist( double& dDist)
|
||||
DistPointArc::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -170,7 +169,7 @@ DistPointArc::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -185,7 +184,7 @@ DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
+9
-8
@@ -27,17 +27,18 @@ class DistPointArc
|
||||
DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
|
||||
|
||||
private :
|
||||
DistPointArc( void) ;
|
||||
|
||||
+13
-17
@@ -14,42 +14,39 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "DistPointCrvAux.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "GeoConst.h"
|
||||
#include "DistPointCrvAux.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcMinDistPointPolyLine( const Point3d& ptP, PolyLine& PL, double dLinTol, MDCVECTOR& vApproxMin)
|
||||
{
|
||||
double dSqDist ;
|
||||
double dPar ;
|
||||
double dUIni ;
|
||||
double dUFin ;
|
||||
Point3d ptIni ;
|
||||
Point3d ptFin ;
|
||||
double dMinDist ;
|
||||
double dSqMinDist ;
|
||||
MinDistCalc approxMin ;
|
||||
|
||||
vApproxMin.reserve( 4) ;
|
||||
vApproxMin.clear() ;
|
||||
|
||||
bool bFound = false ;
|
||||
bool bOnEnd = false ;
|
||||
vApproxMin.reserve( 4) ;
|
||||
vApproxMin.clear() ;
|
||||
double dUIni, dUFin ;
|
||||
Point3d ptIni, ptFin ;
|
||||
double dMinDist, dSqMinDist ;
|
||||
for ( bool bLine = PL.GetFirstULine( &dUIni, &ptIni, &dUFin, &ptFin) ;
|
||||
bLine ;
|
||||
bLine = PL.GetNextULine( &dUIni, &ptIni, &dUFin, &ptFin)) {
|
||||
// calcolo la distanza del punto dal segmento
|
||||
DistPointLine dstPtLn( ptP, ptIni, ptFin) ;
|
||||
double dSqDist ;
|
||||
if ( ! dstPtLn.GetSqDist( dSqDist))
|
||||
continue ;
|
||||
// altro punto con la stessa minima distanza già trovata
|
||||
if ( bFound && abs( dSqDist - dSqMinDist) < 2 * dMinDist * dLinTol) {
|
||||
// salvo i dati nella struttura
|
||||
MinDistCalc approxMin ;
|
||||
approxMin.dDist = dMinDist ;
|
||||
dstPtLn.GetMinDistPoint( approxMin.ptQ) ;
|
||||
double dPar ;
|
||||
dstPtLn.GetParamAtMinDistPoint( dPar) ;
|
||||
approxMin.dPar = ( 1 - dPar) * dUIni + dPar * dUFin ;
|
||||
approxMin.dParMin = dUIni ;
|
||||
@@ -66,8 +63,10 @@ CalcMinDistPointPolyLine( const Point3d& ptP, PolyLine& PL, double dLinTol, MDCV
|
||||
dSqMinDist = dSqDist ;
|
||||
dMinDist = sqrt( dSqMinDist) ;
|
||||
// salvo i dati nella struttura
|
||||
MinDistCalc approxMin ;
|
||||
approxMin.dDist = dMinDist ;
|
||||
dstPtLn.GetMinDistPoint( approxMin.ptQ) ;
|
||||
double dPar ;
|
||||
dstPtLn.GetParamAtMinDistPoint( dPar) ;
|
||||
approxMin.dPar = ( 1 - dPar) * dUIni + dPar * dUFin ;
|
||||
approxMin.dParMin = dUIni ;
|
||||
@@ -157,13 +156,10 @@ bool
|
||||
FilterMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve,
|
||||
const MDCVECTOR& vApproxMin, double& dMinDist, MDPCIVECTOR& Info)
|
||||
{
|
||||
MDCVECTOR::const_iterator Iter ;
|
||||
|
||||
|
||||
// determino i minimi raffinati da tenere
|
||||
bool bFound = false ;
|
||||
bool bLastOnEnd = false ; // flag per ultimo punto su fine del suo intervallo
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.cbegin() ; Iter != vApproxMin.cend() ; ++Iter) {
|
||||
// altro punto con la stessa minima distanza
|
||||
if ( bFound && abs( (*Iter).dDist - dMinDist) < EPS_SMALL) {
|
||||
// se abbastanza lontano e non su bordi intervallino lo aggiungo
|
||||
|
||||
@@ -44,7 +44,6 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
|
||||
// cerco la minima distanza per la polilinea
|
||||
MDCVECTOR vApproxMin ;
|
||||
MDCVECTOR::iterator Iter ;
|
||||
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
|
||||
return ;
|
||||
|
||||
@@ -52,7 +51,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
double dSingP ;
|
||||
if ( CrvBez.GetSingularParam( dSingP) == 0)
|
||||
dSingP = - 1 ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// imposto flag per singolarità agli estremi
|
||||
(*Iter).bParMinSing = abs( (*Iter).dParMin - dSingP) < EPS_SMALL ;
|
||||
(*Iter).bParMaxSing = abs( (*Iter).dParMax - dSingP) < EPS_SMALL ;
|
||||
@@ -61,7 +60,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
// raffino i punti trovati
|
||||
double dPolishedPar ;
|
||||
Point3d ptPolishedQ ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// eseguo raffinamento
|
||||
if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) {
|
||||
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
|
||||
@@ -80,7 +79,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetSqDist( double& dSqDist)
|
||||
DistPointCrvBezier::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -91,7 +90,7 @@ DistPointCrvBezier::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetDist( double& dDist)
|
||||
DistPointCrvBezier::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -102,7 +101,7 @@ DistPointCrvBezier::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -117,7 +116,7 @@ DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
@@ -27,17 +27,18 @@ class DistPointCrvBezier
|
||||
DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& CrvBez) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
|
||||
|
||||
private :
|
||||
DistPointCrvBezier( void) ;
|
||||
|
||||
@@ -89,8 +89,18 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
|
||||
}
|
||||
}
|
||||
// altrimenti aggiungo
|
||||
else
|
||||
m_Info.push_back( aInfo) ;
|
||||
else {
|
||||
if ( dCurrDist < m_dDist) {
|
||||
// aggiorno i minimi
|
||||
m_dDist = dCurrDist ;
|
||||
// inserisco in testa
|
||||
m_Info.insert( m_Info.begin(), aInfo) ;
|
||||
}
|
||||
else {
|
||||
// inserisco in coda
|
||||
m_Info.push_back( aInfo) ;
|
||||
}
|
||||
}
|
||||
// passo al successivo
|
||||
++ i ;
|
||||
}
|
||||
@@ -119,7 +129,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetSqDist( double& dSqDist)
|
||||
DistPointCrvComposite::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -130,7 +140,7 @@ DistPointCrvComposite::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetDist( double& dDist)
|
||||
DistPointCrvComposite::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -141,7 +151,7 @@ DistPointCrvComposite::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -156,7 +166,7 @@ DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
@@ -26,17 +26,18 @@ class DistPointCrvComposite
|
||||
DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
bool GetSqDist( double& dSqDist) const ;
|
||||
bool GetDist( double& dDist) const ;
|
||||
bool IsEpsilon( double dTol) const
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
bool IsSmall( void) const
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
bool IsZero( void) const
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
|
||||
int GetNbrMinDist( void) const
|
||||
{ return (int) m_Info.size() ; }
|
||||
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
|
||||
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
|
||||
|
||||
private :
|
||||
DistPointCrvComposite( void) ;
|
||||
|
||||
+10
-10
@@ -13,10 +13,10 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "DistPointArc.h"
|
||||
#include "DistPointCrvBezier.h"
|
||||
#include "DistPointCrvComposite.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ DistPointCurve::CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSqDist( double& dSqDist)
|
||||
DistPointCurve::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -109,7 +109,7 @@ DistPointCurve::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetDist( double& dDist)
|
||||
DistPointCurve::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
@@ -120,7 +120,7 @@ DistPointCurve::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
@@ -132,7 +132,7 @@ DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag)
|
||||
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -166,7 +166,7 @@ DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFl
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
@@ -178,7 +178,7 @@ DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag)
|
||||
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -209,7 +209,7 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide)
|
||||
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
@@ -257,7 +257,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide)
|
||||
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -278,7 +278,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo)
|
||||
DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
|
||||
+8
-8
@@ -1,19 +1,19 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
// EgalTech 2013-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DistPointLine.cpp Data : 17.12.13 Versione : 1.4l1
|
||||
// File : DistPointLine.cpp Data : 20.05.24 Versione : 2.6e5
|
||||
// Contenuto : Implementazione della classe distanza punto da linea/segmento.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 17.12.13 DS Creazione modulo.
|
||||
//
|
||||
// 20.05.24 DS Reso pubblico in Include.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -95,7 +95,7 @@ DistPointLine::Calculate( const Point3d& ptP,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetSqDist( double& dSqDist)
|
||||
DistPointLine::GetSqDist( double& dSqDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -106,7 +106,7 @@ DistPointLine::GetSqDist( double& dSqDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetDist( double& dDist)
|
||||
DistPointLine::GetDist( double& dDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -119,7 +119,7 @@ DistPointLine::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
|
||||
DistPointLine::GetMinDistPoint( Point3d& ptMinDist) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
@@ -130,7 +130,7 @@ DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointLine::GetParamAtMinDistPoint( double& dParam)
|
||||
DistPointLine::GetParamAtMinDistPoint( double& dParam) const
|
||||
{
|
||||
if ( m_dSqDist < 0)
|
||||
return false ;
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DistPointLine.h Data : 02.01.14 Versione : 1.5a1
|
||||
// Contenuto : Dichiarazione della classe distanza punto da linea/segmento.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 30.12.12 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class DistPointLine
|
||||
{
|
||||
friend class DistPointCurve ;
|
||||
|
||||
public :
|
||||
DistPointLine( const Point3d& ptP,
|
||||
const ICurveLine& crvLine, bool bIsSegment = true) ;
|
||||
DistPointLine( const Point3d& ptP,
|
||||
const Point3d& ptIni, const Point3d& ptFin, bool bIsSegment = true) ;
|
||||
DistPointLine( const Point3d& ptP,
|
||||
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ;
|
||||
|
||||
public :
|
||||
bool GetSqDist( double& dSqDist) ;
|
||||
bool GetDist( double& dDist) ;
|
||||
bool IsEpsilon( double dTol)
|
||||
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||
bool IsSmall( void)
|
||||
{ return IsEpsilon( EPS_SMALL) ; }
|
||||
bool IsZero( void)
|
||||
{ return IsEpsilon( EPS_ZERO) ; }
|
||||
int GetNbrMinDist( void)
|
||||
{ return (( m_dSqDist < 0) ? 0 : 1) ; }
|
||||
bool GetMinDistPoint( Point3d& ptMinDist) ;
|
||||
bool GetParamAtMinDistPoint( double& dParam) ;
|
||||
|
||||
private :
|
||||
DistPointLine( void) ;
|
||||
void Calculate( const Point3d& ptP,
|
||||
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment) ;
|
||||
|
||||
private :
|
||||
double m_dSqDist ;
|
||||
double m_dDist ;
|
||||
double m_dParam ;
|
||||
Point3d m_ptMinDist ;
|
||||
} ;
|
||||
|
||||
+216
-65
@@ -12,8 +12,10 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -24,7 +26,7 @@ using namespace std ;
|
||||
// I casi in cui non vengono trovati box di misura positiva sono quelli in cui o il box A è contenuto
|
||||
// nel box B; uno di questi si verifica se il box A è vuoto.
|
||||
// Nel vettore vBoxDiff vengono restituiti i box la cui unione costituisce la differenza fra A e B.
|
||||
bool
|
||||
static bool
|
||||
BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDiff)
|
||||
{
|
||||
// Svuoto il risultato
|
||||
@@ -92,31 +94,219 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
{
|
||||
// Inizializzo distanza non calcolata
|
||||
m_dDist = - 1. ;
|
||||
// Controllo se la superficie è chiusa
|
||||
m_bIsSurfClosed = tmSurf.IsClosed() ;
|
||||
|
||||
// Lavoro con l'oggetto superficie trimesh di base
|
||||
const SurfTriMesh* pStm = GetBasicSurfTriMesh( &tmSurf) ;
|
||||
if ( pStm == nullptr)
|
||||
return ;
|
||||
|
||||
// Recupero e verifico il box locale della superficie
|
||||
BBox3d b3Stm = tmSurf.GetAllTriaBox() ;
|
||||
BBox3d b3Stm = pStm->GetAllTriaBox() ;
|
||||
if ( b3Stm.IsEmpty())
|
||||
return ;
|
||||
|
||||
// Determino i triangoli vicini e fra di essi cerco quello di minima distanza.
|
||||
// Considero un box centrato nel punto P; finché all'interno del box non trovo un set di triangoli
|
||||
// fra cui quello a distanza minima dal punto P ha distanza minore del minimo semi-lato del box,
|
||||
// continuo a ingrandire il box. La condizione di terminazione garantisce di trovare il tiangolo di
|
||||
// distanza minima della trimesh intera.
|
||||
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
|
||||
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
|
||||
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
|
||||
double dDeltaLen = max( min( min( ptMax.x - ptMin.x, ptMax.y - ptMin.y), ptMax.z - ptMin.z) / 40., 10.) ;
|
||||
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
|
||||
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
|
||||
double dBoxHalfLenY = max( max( ptMin.y - ptP.y, ptP.y - ptMax.y), 0.) + dDeltaLen ;
|
||||
double dBoxHalfLenZ = max( max( ptMin.z - ptP.z, ptP.z - ptMax.z), 0.) + dDeltaLen ;
|
||||
// Considero anche il box precedente per poter analizzare solo lo spazio differenza tra i due
|
||||
// Considero anche il box precedente per poter analizzare solo il volume differenza tra i due
|
||||
BBox3d boxPPrev( ptP) ;
|
||||
BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ;
|
||||
// Variabili distanza minima, indice del triangolo di distanza minima, punto di distanza minima
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
int nMinDistTriaIndex = SVT_NULL ;
|
||||
Point3d ptMinDistPoint ;
|
||||
bool bContinue = true ;
|
||||
// Finché non si verifica la condizione di terminazione ingrandisco il box.
|
||||
pStm->ResetTempInts() ;
|
||||
bool bContinue = true ;
|
||||
|
||||
// creazione del vettore dei triangoli più vicini a ptP
|
||||
vector<pair<int, Triangle3d>> vTria ; // <indice triangolo, Triangolo>
|
||||
while ( bContinue) {
|
||||
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
|
||||
BOXVECTOR vBox ;
|
||||
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
|
||||
// Ciclo sui box differenza
|
||||
bool bCollide = false ;
|
||||
for ( const auto& b3Box : vBox) {
|
||||
// interseco il box con quello della superficie e ne verifico la distanza minima dal punto
|
||||
BBox3d b3Int ;
|
||||
if ( ! b3Box.FindIntersection( b3Stm, b3Int) || b3Int.SqDistFromPoint( ptP) > dMinSqDist)
|
||||
continue ;
|
||||
// ricerca sui triangoli nel box
|
||||
bCollide = true ;
|
||||
INTVECTOR vnIds ;
|
||||
if ( pStm->GetAllTriaOverlapBox( b3Int, vnIds)) {
|
||||
// Ciclo sui triangoli del sotto-box corrente
|
||||
for ( auto nT : vnIds) {
|
||||
int nTriaTemp ;
|
||||
Triangle3d trCurTria ;
|
||||
if ( pStm->GetTempInt( nT, nTriaTemp) && nTriaTemp == 0 && pStm->GetTriangle( nT, trCurTria)) {
|
||||
pStm->SetTempInt( nT, 1) ;
|
||||
DistPointTriangle distPT( ptP, trCurTria) ;
|
||||
double dCurSqDist ;
|
||||
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno
|
||||
if ( distPT.GetSqDist( dCurSqDist)) {
|
||||
if ( abs( dCurSqDist - dMinSqDist) < EPS_SMALL) // se distanze uguali...
|
||||
vTria.emplace_back( make_pair( nT, trCurTria)) ; // aggiungo il triangolo
|
||||
else if ( dCurSqDist < dMinSqDist) { // se minore...
|
||||
vTria.clear() ; // pulisco il vettore
|
||||
dMinSqDist = dCurSqDist ;
|
||||
nMinDistTriaIndex = nT ;
|
||||
distPT.GetMinDistPoint( ptMinDistPoint) ;
|
||||
vTria.emplace_back( make_pair( nT, trCurTria)) ; // aggiungo il triangolo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Se si verifica la condizione di terminazione arresto il ciclo altrimenti aggiorno i box
|
||||
if ( ! bCollide || dMinSqDist < SQ_EPS_SMALL)
|
||||
bContinue = false ;
|
||||
else {
|
||||
boxPPrev = boxP ;
|
||||
boxP.Expand( dDeltaLen) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se non ho trovato nessun triangolo, esco
|
||||
if ( nMinDistTriaIndex == SVT_NULL)
|
||||
return ;
|
||||
|
||||
// salvo la distanza minima
|
||||
m_dDist = sqrt( max( dMinSqDist, 0.)) ;
|
||||
// salvo il punto a distanza minima
|
||||
m_ptMinDistPoint = ptMinDistPoint ;
|
||||
// se il punto è sulla TriMesh...
|
||||
if ( m_dDist < EPS_SMALL) {
|
||||
m_nMinDistTriaIndex = nMinDistTriaIndex ;
|
||||
m_bIsInside = false ;
|
||||
return ;
|
||||
}
|
||||
// se ho un solo triangolo, allora deduco le informazioni da lui
|
||||
else if ( int( vTria.size()) == 1) {
|
||||
m_nMinDistTriaIndex = vTria.back().first ;
|
||||
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * vTria.back().second.GetN() < - EPS_SMALL) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
// controllo se tutti i triangoli a minima distanza forniscono la stessa informazione
|
||||
// ( il punto potrebbe essere esterno a tutti, interno a tutti o indefinito )
|
||||
bool bInside = false ;
|
||||
bool bOutside = false ;
|
||||
for ( int i = 0 ; i < int( vTria.size()) ; ++ i) { // scorro i triangoli a minima distanza
|
||||
if ( ( ptP - vTria[i].second.GetP( 0)) * vTria[i].second.GetN() < - EPS_SMALL)
|
||||
bInside = true ;
|
||||
else
|
||||
bOutside = true ;
|
||||
}
|
||||
|
||||
// inizializzo le variabili membro
|
||||
m_nMinDistTriaIndex = nMinDistTriaIndex ;
|
||||
m_bIsInside = false ;
|
||||
|
||||
// se le informazioni non sono coerenti, allora :
|
||||
// 1) calcolo i centroidi dei triangoli in questione
|
||||
// 2) ottengo il punto medio di questi centroidi
|
||||
// 3) controllo quale triangolo interseca il segmento che parte da ptP e arriva a tale punto
|
||||
// 4) userò questo triangolo per classificare ptP
|
||||
if ( bOutside == bInside) {
|
||||
// calcolo il baricentro complessivo
|
||||
Point3d ptBar_tot ;
|
||||
for ( auto& Tria : vTria)
|
||||
ptBar_tot += Tria.second.GetCentroid() ;
|
||||
ptBar_tot /= int( vTria.size()) ;
|
||||
// per ogni triangolo, cerco quello che interseca il segmento
|
||||
for ( auto& Tria : vTria) {
|
||||
Point3d ptInters1, ptInters2 ;
|
||||
int nType = IntersLineTria( ptP, ptBar_tot, Tria.second, ptInters1, ptInters2) ;
|
||||
if ( nType == ILTT_IN) { // se intersezione ho finito
|
||||
DistPointTriangle( ptP, Tria.second).GetMinDistPoint( m_ptMinDistPoint) ;
|
||||
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * Tria.second.GetN() < - EPS_SMALL) ;
|
||||
m_nMinDistTriaIndex = Tria.first ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // se informazioni coerenti
|
||||
m_bIsInside = bInside ;
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetDist( double& dDist) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
dDist = m_dDist ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
ptMinDistPoint = m_ptMinDistPoint ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
nMinDistIndex = m_nMinDistTriaIndex ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GetSurfTmNearestVertex( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
{
|
||||
// Lavoro con l'oggetto superficie trimesh di base
|
||||
const SurfTriMesh* pStm = GetBasicSurfTriMesh( &tmSurf) ;
|
||||
if ( pStm == nullptr)
|
||||
return SVT_NULL ;
|
||||
|
||||
// Recupero e verifico il box locale della superficie
|
||||
BBox3d b3Stm = pStm->GetAllTriaBox() ;
|
||||
if ( b3Stm.IsEmpty())
|
||||
return SVT_NULL ;
|
||||
|
||||
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
|
||||
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
|
||||
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
|
||||
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
|
||||
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
|
||||
double dBoxHalfLenY = max( max( ptMin.y - ptP.y, ptP.y - ptMax.y), 0.) + dDeltaLen ;
|
||||
double dBoxHalfLenZ = max( max( ptMin.z - ptP.z, ptP.z - ptMax.z), 0.) + dDeltaLen ;
|
||||
// Considero anche il box precedente per poter analizzare solo il volume differenza tra i due
|
||||
BBox3d boxPPrev( ptP) ;
|
||||
BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ;
|
||||
// Variabili distanza minima
|
||||
int nVert = SVT_NULL ;
|
||||
double dMinSqDist = DBL_MAX ;
|
||||
// Finché non si verifica la condizione di terminazione ingrandisco il box.
|
||||
pStm->ResetTempInts() ;
|
||||
bool bContinue = true ;
|
||||
while ( bContinue) {
|
||||
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
|
||||
BOXVECTOR vBox ;
|
||||
@@ -131,18 +321,23 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
// ricerca sui triangoli nel box
|
||||
bCollide = true ;
|
||||
INTVECTOR vnIds ;
|
||||
if ( tmSurf.GetAllTriaOverlapBox( b3Int, vnIds)) {
|
||||
if ( pStm->GetAllTriaOverlapBox( b3Int, vnIds)) {
|
||||
// Ciclo sui triangoli del sotto-box corrente
|
||||
for ( auto nT : vnIds) {
|
||||
Triangle3d trCurTria ;
|
||||
tmSurf.GetTriangle( nT, trCurTria) ;
|
||||
DistPointTriangle distPT( ptP, trCurTria) ;
|
||||
double dCurSqDist ;
|
||||
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno
|
||||
if ( distPT.GetSqDist( dCurSqDist) && dCurSqDist < dMinSqDist) {
|
||||
dMinSqDist = dCurSqDist ;
|
||||
nMinDistTriaIndex = nT ;
|
||||
distPT.GetMinDistPoint( ptMinDistPoint) ;
|
||||
int nTriaTemp ;
|
||||
int nIdVert[3] ;
|
||||
if ( pStm->GetTempInt( nT, nTriaTemp) && nTriaTemp == 0 && pStm->GetTriangle( nT, nIdVert)) {
|
||||
pStm->SetTempInt( nT, 1) ;
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
Point3d ptVert ;
|
||||
if ( ! pStm->GetVertex( nIdVert[i], ptVert))
|
||||
continue ;
|
||||
double dCurrSqDist = SqDist( ptP, ptVert) ;
|
||||
if ( dCurrSqDist < dMinSqDist) {
|
||||
dMinSqDist = dCurrSqDist ;
|
||||
nVert = nIdVert[i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,49 +351,5 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
}
|
||||
}
|
||||
|
||||
if ( nMinDistTriaIndex != SVT_NULL) {
|
||||
m_dDist = sqrt( max( dMinSqDist, 0.)) ;
|
||||
m_nMinDistTriaIndex = nMinDistTriaIndex ;
|
||||
m_ptMinDistPoint = ptMinDistPoint ;
|
||||
Triangle3d trMinDistTria ;
|
||||
tmSurf.GetTriangle( m_nMinDistTriaIndex, trMinDistTria) ;
|
||||
trMinDistTria.Validate() ;
|
||||
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * trMinDistTria.GetN() < - EPS_SMALL) && tmSurf.IsClosed() ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetDist( double& dDist)
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
dDist = m_dDist ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint)
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
ptMinDistPoint = m_ptMinDistPoint ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex)
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
nMinDistIndex = m_nMinDistTriaIndex ;
|
||||
return true ;
|
||||
return nVert ;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "DistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||
|
||||
|
||||
|
||||
@@ -20,4 +20,5 @@
|
||||
int GetEGkDebugLev( void) ;
|
||||
ILogger* GetEGkLogger( void) ;
|
||||
const std::string& GetEGkKey( void) ;
|
||||
bool GetEGkNetHwKey( void) ;
|
||||
int ProcessEvents( int nProg, int nPause) ;
|
||||
|
||||
+16
-1
@@ -16,7 +16,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "FontManager.h"
|
||||
#include "\EgtDev\Include\EGkDllMain.h"
|
||||
#include "\EgtDev\Include\EgnGetModuleVer.h"
|
||||
#include "\EgtDev\Include\EGnGetModuleVer.h"
|
||||
#include "\EgtDev\Include\EgtTrace.h"
|
||||
#include "\EgtDev\Include\SELkLockId.h"
|
||||
|
||||
@@ -115,6 +115,7 @@ GetEGkLogger( void)
|
||||
//-----------------------------------------------------------------------------
|
||||
static string s_sKey ;
|
||||
static int s_nKeyType = KEY_LOCK_TYPE_ANY ;
|
||||
static bool s_bNetHwKey = false ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
@@ -130,6 +131,13 @@ SetEGkKeyType( int nType)
|
||||
s_nKeyType = nType ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
SetEGkNetHwKey( bool bNetHwKey)
|
||||
{
|
||||
s_bNetHwKey = bNetHwKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const string&
|
||||
GetEGkKey( void)
|
||||
@@ -138,6 +146,13 @@ GetEGkKey( void)
|
||||
return s_sKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
GetEGkNetHwKey( void)
|
||||
{
|
||||
return s_bNetHwKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
InitFontManager( const string& sNfeFontDir, const string& sDefaultFont)
|
||||
|
||||
Binary file not shown.
+74
-33
@@ -22,7 +22,7 @@
|
||||
<ProjectGuid>{9A98A202-2853-454A-84CA-DCD1714176C9}</ProjectGuid>
|
||||
<RootNamespace>EgtGeomKernel</RootNamespace>
|
||||
<Keyword>MFCDLLProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -30,7 +30,7 @@
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
@@ -46,12 +46,12 @@
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
@@ -86,6 +86,7 @@
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
<IncludePath>C:\;$(IncludePath)</IncludePath>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
|
||||
@@ -101,6 +102,7 @@
|
||||
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
|
||||
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
|
||||
<IncludePath>C:\;$(IncludePath)</IncludePath>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -114,7 +116,7 @@
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -149,7 +151,8 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -196,7 +199,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -235,14 +238,16 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>\EgtDev\Extern\GeometricToolsEngine</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
|
||||
<IntelJCCErratum>true</IntelJCCErratum>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -275,11 +280,13 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="Attribs.cpp" />
|
||||
<ClCompile Include="BBox3d.cpp" />
|
||||
<ClCompile Include="BiArcs.cpp" />
|
||||
<ClCompile Include="CalcPocketing.cpp" />
|
||||
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
|
||||
<ClCompile Include="CAvToolSurfTm.cpp" />
|
||||
<ClCompile Include="CAvToolTriangle.cpp" />
|
||||
<ClCompile Include="CDeBoxClosedSurfTm.cpp" />
|
||||
<ClCompile Include="CDeBoxTria.cpp" />
|
||||
<ClCompile Include="CDeCapsTria.cpp" />
|
||||
<ClCompile Include="CDeClosedSurfTmClosedSurfTm.cpp" />
|
||||
<ClCompile Include="CDeConeFrustumClosedSurfTm.cpp" />
|
||||
<ClCompile Include="CDeConeFrustumTria.cpp" />
|
||||
@@ -295,19 +302,46 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="CDeTriaTria.cpp" />
|
||||
<ClCompile Include="CDeUtility.cpp" />
|
||||
<ClCompile Include="ChainCurves.cpp" />
|
||||
<ClCompile Include="Circle2P.cpp" />
|
||||
<ClCompile Include="CircleCenTgCurve.cpp" />
|
||||
<ClCompile Include="Color.cpp" />
|
||||
<ClCompile Include="CreateCurveAux.cpp" />
|
||||
<ClCompile Include="CurveByApprox.cpp" />
|
||||
<ClCompile Include="CurveByInterp.cpp" />
|
||||
<ClCompile Include="CurveCompositeOffset.cpp" />
|
||||
<ClCompile Include="IntersCurveSurfTm.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineVolZmap.cpp" />
|
||||
<ClCompile Include="IntersPlaneVolZmap.cpp" />
|
||||
<ClCompile Include="IntersLineSurfBez.cpp" />
|
||||
<ClCompile Include="PolygonElevation.cpp" />
|
||||
<ClCompile Include="Quaternion.cpp" />
|
||||
<ClCompile Include="RotationMinimizingFrame.cpp" />
|
||||
<ClCompile Include="RotationXplaneFrame.cpp" />
|
||||
<ClCompile Include="SbzStandard.cpp" />
|
||||
<ClCompile Include="Voronoi.cpp" />
|
||||
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkDistLineLine.h" />
|
||||
<ClInclude Include="..\Include\EGkDistPointLine.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersCurveSurfTm.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersLineBox.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneBox.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneVolZmap.h" />
|
||||
<ClInclude Include="..\Include\EGkPolygonElevation.h" />
|
||||
<ClInclude Include="..\Include\EGkQuaternion.h" />
|
||||
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
|
||||
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h" />
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
||||
<ClInclude Include="CDeBoxTria.h" />
|
||||
<ClInclude Include="CDeCapsTria.h" />
|
||||
<ClInclude Include="CDeConeFrustumTria.h" />
|
||||
<ClInclude Include="CDeConeTria.h" />
|
||||
<ClInclude Include="CDeConvexTorusTria.h" />
|
||||
@@ -321,7 +355,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="DistPointSurfTm.cpp" />
|
||||
<ClCompile Include="DistPointTria.cpp" />
|
||||
<ClCompile Include="ExtDimension.cpp" />
|
||||
<ClCompile Include="HashGrids1d.cpp" />
|
||||
<ClCompile Include="IntersLineBox.cpp" />
|
||||
<ClCompile Include="IntersLineCaps.cpp" />
|
||||
<ClCompile Include="IntersLineCone.cpp" />
|
||||
<ClCompile Include="IntersLineCyl.cpp" />
|
||||
<ClCompile Include="IntersLineSphere.cpp" />
|
||||
<ClCompile Include="IntersLineSurfStd.cpp" />
|
||||
<ClCompile Include="IntersPlaneBox.cpp" />
|
||||
@@ -330,6 +368,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersPlaneTria.cpp" />
|
||||
<ClCompile Include="IntersSurfTmSurfTm.cpp" />
|
||||
<ClCompile Include="IntersTriaTria.cpp" />
|
||||
<ClCompile Include="OffsetAux.cpp" />
|
||||
<ClCompile Include="Tree.cpp" />
|
||||
<ClCompile Include="MedialAxis.cpp" />
|
||||
<ClCompile Include="OffsetCurve.cpp" />
|
||||
<ClCompile Include="DistPointArc.cpp" />
|
||||
<ClCompile Include="DistPointCrvAux.cpp" />
|
||||
@@ -366,12 +407,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersCurveCurve.cpp" />
|
||||
<ClCompile Include="IntersLineArc.cpp" />
|
||||
<ClCompile Include="IntersLineLine.cpp" />
|
||||
<ClCompile Include="IntersLinePlane.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLinePlane.cpp" />
|
||||
<ClCompile Include="IntersLineSurfTm.cpp" />
|
||||
<ClCompile Include="IntersLineTria.cpp" />
|
||||
<ClCompile Include="Intervals.cpp" />
|
||||
@@ -389,18 +425,21 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="OffsetCurveOnX.cpp" />
|
||||
<ClCompile Include="Polygon3d.cpp" />
|
||||
<ClCompile Include="AdjustLoops.cpp" />
|
||||
<ClCompile Include="RemoveCurveSpikes.cpp" />
|
||||
<ClCompile Include="ProjectCurveSurfTm.cpp" />
|
||||
<ClCompile Include="RemoveCurveDefects.cpp" />
|
||||
<ClCompile Include="SelfIntersCurve.cpp" />
|
||||
<ClCompile Include="SfrCreate.cpp" />
|
||||
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp" />
|
||||
<ClCompile Include="SurfAux.cpp" />
|
||||
<ClCompile Include="SurfBezier.cpp" />
|
||||
<ClCompile Include="SurfFlatRegion.cpp" />
|
||||
<ClCompile Include="SurfFlatRegionBooleans.cpp" />
|
||||
<ClCompile Include="SurfFlatRegionOffset.cpp" />
|
||||
<ClCompile Include="SurfTriMeshBooleans.cpp" />
|
||||
<ClCompile Include="SurfTriMeshCuts.cpp" />
|
||||
<ClCompile Include="SurfTriMeshUtilities.cpp" />
|
||||
<ClCompile Include="TextureData.cpp" />
|
||||
<ClCompile Include="Tool.cpp" />
|
||||
<ClCompile Include="tpp_assert.cpp" />
|
||||
<ClCompile Include="tpp_impl.cpp" />
|
||||
<ClCompile Include="UserObjDefault.cpp" />
|
||||
<ClCompile Include="UserObjFactory.cpp" />
|
||||
<ClCompile Include="OutTsc.cpp" />
|
||||
@@ -431,6 +470,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="VolZmapGraphics.cpp" />
|
||||
<ClCompile Include="VolZmapVolume.cpp" />
|
||||
<ClCompile Include="VolZmap.cpp" />
|
||||
<ClInclude Include="Voronoi.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Include\EGkAngle.h" />
|
||||
@@ -447,14 +487,14 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkChainCurves.h" />
|
||||
<ClInclude Include="..\Include\EGkCircleCenTgCurve.h" />
|
||||
<ClInclude Include="..\Include\EGkColor.h" />
|
||||
<ClInclude Include="..\Include\EgkCurve.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveArc.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveAux.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveBezier.h" />
|
||||
<ClInclude Include="..\Include\EGkCurve.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveArc.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveAux.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveBezier.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveByApprox.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveComposite.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveComposite.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveByInterp.h" />
|
||||
<ClInclude Include="..\Include\EgkCurveLine.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveLine.h" />
|
||||
<ClInclude Include="..\Include\EGkCurveLocal.h" />
|
||||
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h" />
|
||||
<ClInclude Include="..\Include\EGkDistPointCurve.h" />
|
||||
@@ -557,14 +597,12 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="CAvSimpleSurfFrMove.h" />
|
||||
<ClInclude Include="CAvToolSurfTm.h" />
|
||||
<ClInclude Include="CreateCurveAux.h" />
|
||||
<ClInclude Include="DistLineLine.h" />
|
||||
<ClInclude Include="DistPointArc.h" />
|
||||
<ClInclude Include="DistPointCrvAux.h" />
|
||||
<ClInclude Include="DistPointCrvBezier.h" />
|
||||
<ClInclude Include="DistPointCrvComposite.h" />
|
||||
<ClInclude Include="DistPointLine.h" />
|
||||
<ClInclude Include="DllMain.h" />
|
||||
<ClInclude Include="dpoint.hpp" />
|
||||
<ClInclude Include="earcut.hpp" />
|
||||
<ClInclude Include="ExtDimension.h" />
|
||||
<ClInclude Include="ExtText.h" />
|
||||
<ClInclude Include="FontAux.h" />
|
||||
@@ -593,10 +631,16 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="IntersArcArc.h" />
|
||||
<ClInclude Include="IntersCrvCompoCrvCompo.h" />
|
||||
<ClInclude Include="IntersLineArc.h" />
|
||||
<ClInclude Include="IntersLineBox.h" />
|
||||
<ClInclude Include="IntersLineCaps.h" />
|
||||
<ClInclude Include="IntersLineCone.h" />
|
||||
<ClInclude Include="IntersLineCyl.h" />
|
||||
<ClInclude Include="IntersLineLine.h" />
|
||||
<ClInclude Include="IntersLineSurfStd.h" />
|
||||
<ClInclude Include="IntersLineTria.h" />
|
||||
<ClInclude Include="IterManager.h" />
|
||||
<ClInclude Include="OffsetAux.h" />
|
||||
<ClInclude Include="Tree.h" />
|
||||
<ClInclude Include="Material.h" />
|
||||
<ClInclude Include="FontNfe.h" />
|
||||
<ClInclude Include="MC_Tables.h" />
|
||||
@@ -606,16 +650,13 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="ObjGraphicsMgr.h" />
|
||||
<ClInclude Include="FontOs.h" />
|
||||
<ClInclude Include="AdjustLoops.h" />
|
||||
<ClInclude Include="RemoveCurveSpikes.h" />
|
||||
<ClInclude Include="RemoveCurveDefects.h" />
|
||||
<ClInclude Include="SurfAux.h" />
|
||||
<ClInclude Include="SurfBezier.h" />
|
||||
<ClInclude Include="SurfFlatRegion.h" />
|
||||
<ClInclude Include="TextureData.h" />
|
||||
<ClInclude Include="Tool.h" />
|
||||
<ClInclude Include="CAvToolTriangle.h" />
|
||||
<ClInclude Include="tpp_assert.hpp" />
|
||||
<ClInclude Include="tpp_interface.hpp" />
|
||||
<ClInclude Include="triangle.h" />
|
||||
<ClInclude Include="triangle_impl.hpp" />
|
||||
<ClInclude Include="UserObjDefault.h" />
|
||||
<ClInclude Include="OutTsc.h" />
|
||||
<ClInclude Include="PointsPCA.h" />
|
||||
|
||||
+171
-60
@@ -43,15 +43,18 @@
|
||||
<Filter Include="File di origine\GeoOffset">
|
||||
<UniqueIdentifier>{f07670fd-9429-4b7e-ac6d-1c0022e756fb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\GeoCollision">
|
||||
<Filter Include="File di origine\GeoProject">
|
||||
<UniqueIdentifier>{d96752da-1884-4a73-ba1b-5b20b606e469}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\GeoElevation">
|
||||
<UniqueIdentifier>{4c6a9dc5-8fac-4ecd-bde6-3e37e056712e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\GeoCollisionAvoid">
|
||||
<UniqueIdentifier>{ae52e402-3063-45e3-b9f7-1710035a1f56}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\GeoCollisionDetection">
|
||||
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di intestazione\tpp">
|
||||
<UniqueIdentifier>{9596e38a-8880-4ab5-bd65-e1db39c92ac5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="File di origine\tpp">
|
||||
<UniqueIdentifier>{636e60fa-4b24-4a7b-b2e9-74e1c1e8fb31}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Vector3d.cpp">
|
||||
@@ -273,6 +276,9 @@
|
||||
<ClCompile Include="IntersLineSurfTm.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineSurfBez.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CircleCenTgCurve.cpp">
|
||||
<Filter>File di origine\GeoCreate</Filter>
|
||||
</ClCompile>
|
||||
@@ -333,7 +339,7 @@
|
||||
<ClCompile Include="OffsetCurveOnX.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoveCurveSpikes.cpp">
|
||||
<ClCompile Include="RemoveCurveDefects.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Polygon3d.cpp">
|
||||
@@ -372,17 +378,8 @@
|
||||
<ClCompile Include="IntersLineSurfStd.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvToolTriangle.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvToolSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeBoxTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvSimpleSurfFrMove.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersSurfTmSurfTm.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
@@ -400,19 +397,19 @@
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeCylTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeBoxClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeCylClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeSpheTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeSpheClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfBezier.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
@@ -430,40 +427,115 @@
|
||||
<Filter>File di origine\GeoDist</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeTriaTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeConeTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeUtility.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeClosedSurfTmClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeConeFrustumClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeConeFrustumTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeConvexTorusClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeConvexTorusTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeRectPrismoidClosedSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeRectPrismoidTria.cpp">
|
||||
<Filter>File di origine\GeoCollision</Filter>
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tpp_assert.cpp">
|
||||
<Filter>File di origine\tpp</Filter>
|
||||
<ClCompile Include="SurfTriMeshUtilities.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tpp_impl.cpp">
|
||||
<Filter>File di origine\tpp</Filter>
|
||||
<ClCompile Include="SurfTriMeshCuts.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HashGrids1d.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CDeCapsTria.cpp">
|
||||
<Filter>File di origine\GeoCollisionDetection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Circle2P.cpp">
|
||||
<Filter>File di origine\GeoCreate</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MedialAxis.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Tree.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineCyl.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineCone.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineCaps.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ProjectCurveSurfTm.cpp">
|
||||
<Filter>File di origine\GeoProject</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp">
|
||||
<Filter>File di origine\GeoProject</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SurfAux.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CalcPocketing.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OffsetAux.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Voronoi.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PolygonElevation.cpp">
|
||||
<Filter>File di origine\GeoElevation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersCurveSurfTm.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvSimpleSurfFrMove.cpp">
|
||||
<Filter>File di origine\GeoCollisionAvoid</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvToolSurfTm.cpp">
|
||||
<Filter>File di origine\GeoCollisionAvoid</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvToolTriangle.cpp">
|
||||
<Filter>File di origine\GeoCollisionAvoid</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersLineVolZmap.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IntersPlaneVolZmap.cpp">
|
||||
<Filter>File di origine\GeoInters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SbzStandard.cpp">
|
||||
<Filter>File di origine\GeoCreate</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RotationMinimizingFrame.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RotationXplaneFrame.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Quaternion.cpp">
|
||||
<Filter>File di origine\Base</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -521,9 +593,6 @@
|
||||
<ClInclude Include="DistPointArc.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DistPointLine.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DistPointCrvBezier.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
@@ -635,28 +704,28 @@
|
||||
<ClInclude Include="..\Include\EGkChainCurves.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkCurveBezier.h">
|
||||
<ClInclude Include="..\Include\EGkCurveBezier.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkColor.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkCurve.h">
|
||||
<ClInclude Include="..\Include\EGkCurve.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkCurveArc.h">
|
||||
<ClInclude Include="..\Include\EGkCurveArc.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkCurveAux.h">
|
||||
<ClInclude Include="..\Include\EGkCurveAux.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurveByInterp.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkCurveComposite.h">
|
||||
<ClInclude Include="..\Include\EGkCurveComposite.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkCurveLine.h">
|
||||
<ClInclude Include="..\Include\EGkCurveLine.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h">
|
||||
@@ -851,7 +920,7 @@
|
||||
<ClInclude Include="..\Include\EGkIntersLineSurfTm.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoveCurveSpikes.h">
|
||||
<ClInclude Include="RemoveCurveDefects.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkIntersPlanePlane.h">
|
||||
@@ -1046,9 +1115,6 @@
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneBox.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DistLineLine.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CDeUtility.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
@@ -1088,20 +1154,65 @@
|
||||
<ClInclude Include="CDeRectPrismoidTria.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="dpoint.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
<ClInclude Include="earcut.hpp">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tpp_assert.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
<ClInclude Include="IntersLineBox.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tpp_interface.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
<ClInclude Include="CDeCapsTria.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="triangle.h">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
<ClInclude Include="Tree.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="triangle_impl.hpp">
|
||||
<Filter>File di intestazione\tpp</Filter>
|
||||
<ClInclude Include="IntersLineCyl.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IntersLineCone.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IntersLineCaps.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SurfAux.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OffsetAux.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkPolygonElevation.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Voronoi.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkIntersCurveSurfTm.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneVolZmap.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkQuaternion.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkDistLineLine.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkDistPointLine.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
+799
-116
File diff suppressed because it is too large
Load Diff
+46
-9
@@ -28,7 +28,7 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
ExtDimension* Clone( void) const override ;
|
||||
GeoObjType GetType( void) const override ;
|
||||
bool IsValid( void) const override
|
||||
{ return ( m_nType != DT_NONE) ; }
|
||||
{ return ( m_nType != DT_NONE) ; }
|
||||
const std::string& GetTitle( void) const override ;
|
||||
bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
|
||||
bool GetLocalBBox( BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ;
|
||||
@@ -50,10 +50,16 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IExtDimension
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -61,6 +67,15 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
int nDecDigit, const std::string& sFont, double dTextHeight) override ;
|
||||
bool SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const Vector3d& vtDir, const std::string& sText) override ;
|
||||
bool SetRadial( const Point3d& ptCen, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
bool SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
bool SetAngular( const Point3d& ptV, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
bool SetAngularEx( const Point3d& ptV1, const Point3d& ptP1,
|
||||
const Point3d& ptV2, const Point3d& ptP2, const Point3d& ptPos,
|
||||
const Vector3d& vtN, const std::string& sText) override ;
|
||||
const Vector3d& GetNormVersor( void) const override
|
||||
{ return m_vtN ; }
|
||||
const Vector3d& GetDirVersor( void) const override
|
||||
@@ -93,12 +108,16 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
{ return m_dTextHeight ; }
|
||||
bool GetMidPoint( Point3d& ptMid) const override ;
|
||||
bool GetCenterPoint( Point3d& ptCen) const override ;
|
||||
const std::string& GetSubType( void) const override ;
|
||||
bool ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
ExtDimension( void) ;
|
||||
@@ -112,12 +131,12 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
|
||||
private :
|
||||
bool CopyFrom( const ExtDimension& gpSrc) ;
|
||||
const std::string& GetSubType( void) const ;
|
||||
bool Update( void) const ;
|
||||
double GetTextHalfDist( const Point3d& ptText) const ;
|
||||
double GetTextHalfDist( const Point3d& ptText, bool bUseRot = true) const ;
|
||||
bool GetArrowHead( const Point3d& ptTip, const Vector3d& vtDir, PolyLine& PL) const ;
|
||||
bool SetCurrFont( FontManager& fntMgr) const ;
|
||||
bool ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const ;
|
||||
bool GetTextMyBBox( BBox3d& b3Loc) const ;
|
||||
bool GetTextMyBBox( const Point3d& ptPos, BBox3d& b3Loc) const ;
|
||||
bool GetTextLocalBBox( BBox3d& b3Loc) const ;
|
||||
bool GetTextBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
@@ -132,13 +151,14 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
Point3d m_ptP3 ; // terzo punto
|
||||
Point3d m_ptP4 ; // quarto punto
|
||||
Point3d m_ptP5 ; // quinto punto
|
||||
Point3d m_ptP6 ; // sesto punto
|
||||
Point3d m_ptP6 ; // sesto punto; nel caso delle quotature angolari � il centro
|
||||
Point3d m_ptPos ; // posizione ricevuta della quota
|
||||
std::string m_sText ; // testo della quota
|
||||
mutable bool m_bToCalc ; // flag dati effettivi da ricalcolare
|
||||
mutable std::string m_sCalcText ; // testo effettivo della quota
|
||||
mutable Point3d m_ptCalcPos ; // posizione effettiva della quota
|
||||
mutable bool m_bCalcArrowIn ; // flag posizione effettiva delle frecce
|
||||
mutable bool m_bCalcTextOn ; // flag posizione del testo sulla linea di misura
|
||||
mutable Point3d m_ptCalcP7 ; // settimo punto effettivo
|
||||
mutable Point3d m_ptCalcP8 ; // ottavo punto effettivo
|
||||
double m_dExtLineLen ; // lunghezza di estensione della linea
|
||||
@@ -148,5 +168,22 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
|
||||
int m_nDecDigit ; // numero di cifre decimali
|
||||
std::string m_sFont ; // font del testo
|
||||
double m_dTextHeight ; // altezza del testo
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
int m_nTempProp[2] ; // vettore propriet� temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline ExtDimension* CreateBasicExtDimension( void)
|
||||
{ return ( static_cast<ExtDimension*>( CreateGeoObj( EXT_DIMENSION))) ; }
|
||||
inline ExtDimension* CloneBasicExtDimension( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != EXT_DIMENSION)
|
||||
return nullptr ;
|
||||
return ( static_cast<ExtDimension*>( pGObj->Clone())) ; }
|
||||
inline const ExtDimension* GetBasicExtDimension( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != EXT_DIMENSION)
|
||||
return nullptr ;
|
||||
return ( static_cast<const ExtDimension*>( pGObj)) ; }
|
||||
inline ExtDimension* GetBasicExtDimension( IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != EXT_DIMENSION)
|
||||
return nullptr ;
|
||||
return ( static_cast<ExtDimension*>( pGObj)) ; }
|
||||
|
||||
+40
-5
@@ -35,8 +35,9 @@ GEOOBJ_REGISTER( EXT_TEXT, NGE_E_TXT, ExtText) ;
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText::ExtText( void)
|
||||
: m_pSTM( nullptr), m_bNoSTM( false), m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(),
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0), m_nTempProp()
|
||||
{
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0),
|
||||
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -159,7 +160,7 @@ ExtText::Clone( void) const
|
||||
bool
|
||||
ExtText::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const ExtText* pTxt = dynamic_cast<const ExtText*>( pGObjSrc) ;
|
||||
const ExtText* pTxt = GetBasicExtText( pGObjSrc) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
return CopyFrom( *pTxt) ;
|
||||
@@ -184,7 +185,10 @@ ExtText::CopyFrom( const ExtText& clSrc)
|
||||
m_dRatio = clSrc.m_dRatio ;
|
||||
m_dAddAdvance = clSrc.m_dAddAdvance ;
|
||||
m_nInsPos = clSrc.m_nInsPos ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -396,8 +400,11 @@ ExtText::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
bool
|
||||
ExtText::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo
|
||||
m_ptP.Translate( vtMove) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -406,8 +413,15 @@ ExtText::Translate( const Vector3d& vtMove)
|
||||
bool
|
||||
ExtText::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
// verifico validità dell'asse di rotazione
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo
|
||||
return ( m_ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_vtN.Rotate( vtAx, dCosAng, dSinAng) &&
|
||||
m_vtD.Rotate( vtAx, dCosAng, dSinAng)) ;
|
||||
@@ -529,9 +543,18 @@ ExtText::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtD
|
||||
bool
|
||||
ExtText::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToGlob( frRef) &&
|
||||
m_vtN.ToGlob( frRef) &&
|
||||
@@ -542,9 +565,18 @@ ExtText::ToGlob( const Frame3d& frRef)
|
||||
bool
|
||||
ExtText::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToLoc( frRef) &&
|
||||
m_vtN.ToLoc( frRef) &&
|
||||
@@ -558,12 +590,15 @@ ExtText::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToGlob( frOri) && m_ptP.ToLoc( frDest) &&
|
||||
m_vtN.ToGlob( frOri) && m_vtN.ToLoc( frDest) &&
|
||||
@@ -849,7 +884,7 @@ ExtText::GetAuxSurf( void) const
|
||||
// per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale
|
||||
for ( const auto& pSfr : lstSfr) {
|
||||
// recupero la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ;
|
||||
PtrOwner<SurfTriMesh> pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ;
|
||||
if ( pStm != nullptr) {
|
||||
Triangle3d Tria ;
|
||||
int nT = pStm->GetFirstTriangle( Tria) ;
|
||||
|
||||
@@ -50,10 +50,16 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IExtText
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -107,7 +113,10 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
ExtText( void) ;
|
||||
@@ -143,5 +152,22 @@ class ExtText : public IExtText, public IGeoObjRW
|
||||
double m_dRatio ; // rapporto tra larghezza e altezza
|
||||
double m_dAddAdvance ; // avanzamento addizionale tra caratteri
|
||||
int m_nInsPos ; // posizione del punto di inserimento rispetto al testo
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline ExtText* CreateBasicExtText( void)
|
||||
{ return ( static_cast<ExtText*>( CreateGeoObj( EXT_TEXT))) ; }
|
||||
inline ExtText* CloneBasicExtText( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != EXT_TEXT)
|
||||
return nullptr ;
|
||||
return ( static_cast<ExtText*>( pGObj->Clone())) ; }
|
||||
inline const ExtText* GetBasicExtText( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != EXT_TEXT)
|
||||
return nullptr ;
|
||||
return ( static_cast<const ExtText*>( pGObj)) ; }
|
||||
inline ExtText* GetBasicExtText( IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != EXT_TEXT)
|
||||
return nullptr ;
|
||||
return ( static_cast<ExtText*>( pGObj)) ; }
|
||||
|
||||
+145
-73
@@ -15,95 +15,158 @@
|
||||
#include "stdafx.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EgkFilletChamfer.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkFilletChamfer.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EgkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcForFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
const ICurve& cCrv2, const Point3d& ptNear2,
|
||||
const Vector3d& vtNorm, double dRadius,
|
||||
Point3d& ptCen, Point3d& ptTg1, Point3d& ptTg2,
|
||||
int& nSide1, int& nSide2, double& dSinA, double& dTgPar1, double& dTgPar2)
|
||||
{
|
||||
// calcolo un riferimento sul piano perpendicolare alla normale
|
||||
Frame3d frIntr ;
|
||||
if ( ! frIntr.Set( ORIG, vtNorm))
|
||||
return false ;
|
||||
|
||||
// determino il lato di offset della curva 1
|
||||
DistPointCurve dPC1( ptNear2, cCrv1) ;
|
||||
if ( ! dPC1.GetSideAtMinDistPoint( 0, vtNorm, nSide1))
|
||||
return false ;
|
||||
double dOffs1 = ( nSide1 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo gli offset nel piano locale e dal lato opportuno di una copia della curva 1
|
||||
PtrOwner<ICurve> pCopy1( cCrv1.Clone()) ;
|
||||
if ( IsNull( pCopy1))
|
||||
return false ;
|
||||
pCopy1->ToLoc( frIntr) ;
|
||||
pCopy1->SetExtrusion( Z_AX) ;
|
||||
OffsetCurve OffsCrv1 ;
|
||||
OffsCrv1.Make( pCopy1, dOffs1, ICurve::OFF_FILLET) ;
|
||||
ICURVEPOVECTOR vOffs1 ;
|
||||
ICurve* pCrv = OffsCrv1.GetLongerCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
vOffs1.emplace_back( pCrv) ;
|
||||
pCrv = OffsCrv1.GetLongerCurve() ;
|
||||
}
|
||||
if ( vOffs1.empty())
|
||||
return false ;
|
||||
|
||||
// determino il lato di offset della curva 2
|
||||
DistPointCurve dPC2( ptNear1, cCrv2) ;
|
||||
if ( ! dPC2.GetSideAtMinDistPoint( 0, vtNorm, nSide2))
|
||||
return false ;
|
||||
double dOffs2 = ( nSide2 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo gli offset nel piano locale e dal lato opportuno di una copia della curva 2
|
||||
PtrOwner<ICurve> pCopy2( cCrv2.Clone()) ;
|
||||
if ( IsNull( pCopy2))
|
||||
return false ;
|
||||
pCopy2->ToLoc( frIntr) ;
|
||||
pCopy2->SetExtrusion( Z_AX) ;
|
||||
OffsetCurve OffsCrv2 ;
|
||||
OffsCrv2.Make( pCopy2, dOffs2, ICurve::OFF_FILLET) ;
|
||||
ICURVEPOVECTOR vOffs2 ;
|
||||
pCrv = OffsCrv2.GetLongerCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
vOffs2.emplace_back( pCrv) ;
|
||||
pCrv = OffsCrv2.GetLongerCurve() ;
|
||||
}
|
||||
if ( vOffs2.empty())
|
||||
return false ;
|
||||
|
||||
// calcolo le intersezioni tra tutte le curve di offset e seleziono quella più vicina ai punti passati
|
||||
Point3d ptInt1 = P_INVALID, ptInt2 = P_INVALID ;
|
||||
Point3d ptNearI = Media( ptNear1, ptNear2) ;
|
||||
ptNearI.ToLoc( frIntr) ;
|
||||
double dMinDist = INFINITO ;
|
||||
for ( int i = 0 ; i < int( vOffs1.size()) ; i++) {
|
||||
for ( int j = 0 ; j < int( vOffs2.size()) ; j ++) {
|
||||
IntersCurveCurve intCC( *vOffs1[i], *vOffs2[j]) ;
|
||||
if ( intCC.GetIntersCount() == 0)
|
||||
continue ;
|
||||
Point3d ptInt1Curr, ptInt2Curr ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNearI, ptInt1Curr) ||
|
||||
! intCC.GetIntersPointNearTo( 1, ptNearI, ptInt2Curr))
|
||||
return false ;
|
||||
Point3d ptCenCurr = Media( ptInt1Curr, ptInt2Curr) ;
|
||||
double dDist = Dist( ptNearI, ptCenCurr) ;
|
||||
if ( dDist < dMinDist - EPS_SMALL) {
|
||||
dMinDist = dDist ;
|
||||
ptInt1 = ptInt1Curr ;
|
||||
ptInt2 = ptInt2Curr ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non sono state trovate intersezioni esco
|
||||
if ( ! ptInt1.IsValid() || ! ptInt2.IsValid())
|
||||
return false ;
|
||||
|
||||
ptInt1.ToGlob( frIntr) ;
|
||||
ptInt2.ToGlob( frIntr) ;
|
||||
ptCen = Media( ptInt1, ptInt2) ;
|
||||
|
||||
// proiezione del punto di intersezione sulla prima curva
|
||||
DistPointCurve dPCI1( ptInt1, cCrv1) ;
|
||||
int nFlag1 ;
|
||||
if ( ! dPCI1.GetParamAtMinDistPoint( 0, dTgPar1, nFlag1) || nFlag1 != MDPCI_NORMAL)
|
||||
return false ;
|
||||
Vector3d vtTg1 ;
|
||||
if ( ! cCrv1.GetPointTang( dTgPar1, ICurve::FROM_MINUS, ptTg1, vtTg1))
|
||||
return false ;
|
||||
|
||||
// proiezione del punto di intersezione sulla seconda curva
|
||||
DistPointCurve dPCI2( ptInt2, cCrv2) ;
|
||||
int nFlag2 ;
|
||||
if ( ! dPCI2.GetParamAtMinDistPoint( 0, dTgPar2, nFlag2) || nFlag2 != MDPCI_NORMAL)
|
||||
return false ;
|
||||
Vector3d vtTg2 ;
|
||||
if ( ! cCrv2.GetPointTang( dTgPar2, ICurve::FROM_MINUS, ptTg2, vtTg2))
|
||||
return false ;
|
||||
|
||||
// determino rotazione tra le curve
|
||||
dSinA = ( vtTg1 ^ vtTg2) * vtNorm ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveArc*
|
||||
CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
const ICurve& cCrv2, const Point3d& ptNear2,
|
||||
const Vector3d& vtNorm, double dRadius, double& dPar1, double& dPar2)
|
||||
{
|
||||
// verifico validità parametri ricevuti
|
||||
// verifico validità parametri ricevuti
|
||||
if ( &cCrv1 == nullptr || &ptNear1 == nullptr ||
|
||||
&cCrv2 == nullptr || &ptNear2 == nullptr ||
|
||||
&vtNorm == nullptr || &dPar1 == nullptr || &dPar2 == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// calcolo un riferimento sul piano perpendicolare alla normale
|
||||
Frame3d frIntr ;
|
||||
if ( ! frIntr.Set( ORIG, vtNorm))
|
||||
// eseguo calcoli
|
||||
Point3d ptCen, ptTg1, ptTg2 ;
|
||||
int nSide1, nSide2 ;
|
||||
double dSinA, dTgPar1, dTgPar2 ;
|
||||
if ( ! CalcForFillet( cCrv1, ptNear1, cCrv2, ptNear2, vtNorm, dRadius,
|
||||
ptCen, ptTg1, ptTg2, nSide1, nSide2, dSinA, dTgPar1, dTgPar2))
|
||||
return nullptr ;
|
||||
|
||||
// determino il lato di offset della curva 1
|
||||
DistPointCurve dPC1( ptNear2, cCrv1) ;
|
||||
int nSide1 ;
|
||||
if ( ! dPC1.GetSideAtMinDistPoint( 0, vtNorm, nSide1))
|
||||
return nullptr ;
|
||||
double dOffs1 = ( nSide1 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 1
|
||||
PtrOwner<ICurve> pCopy1( cCrv1.Clone()) ;
|
||||
if ( IsNull( pCopy1))
|
||||
return nullptr ;
|
||||
pCopy1->ToLoc( frIntr) ;
|
||||
pCopy1->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy1->SimpleOffset( dOffs1, ICurve::OFF_FILLET))
|
||||
return nullptr ;
|
||||
// se tangenti parallele al contatto con fillet, ricalcolo con raggio più piccolo
|
||||
bool bParallel = ( abs( dSinA) < EPS_SMALL) ;
|
||||
if ( bParallel) {
|
||||
Point3d ptQQQ, ptQQ1, ptQQ2 ;
|
||||
double dQQQ1, dQQQ2 ;
|
||||
if ( ! CalcForFillet( cCrv1, ptNear1, cCrv2, ptNear2, vtNorm, dRadius - 10 * EPS_SMALL,
|
||||
ptQQQ, ptQQ1, ptQQ2, nSide1, nSide2, dSinA, dQQQ1, dQQQ2) || abs( dSinA) < EPS_SMALL)
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
// determino il lato di offset della curva 2
|
||||
DistPointCurve dPC2( ptNear1, cCrv2) ;
|
||||
int nSide2 ;
|
||||
if ( ! dPC2.GetSideAtMinDistPoint( 0, vtNorm, nSide2))
|
||||
return nullptr ;
|
||||
double dOffs2 = ( nSide2 == MDS_RIGHT ? dRadius : - dRadius) ;
|
||||
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 2
|
||||
PtrOwner<ICurve> pCopy2( cCrv2.Clone()) ;
|
||||
if ( IsNull( pCopy2))
|
||||
return nullptr ;
|
||||
pCopy2->ToLoc( frIntr) ;
|
||||
pCopy2->SetExtrusion( Z_AX) ;
|
||||
if ( ! pCopy2->SimpleOffset( dOffs2, ICurve::OFF_FILLET))
|
||||
return nullptr ;
|
||||
|
||||
// calcolo l'intersezione tra le due curve
|
||||
Point3d ptInt1, ptInt2 ;
|
||||
Point3d ptNear1I = ptNear1 ;
|
||||
ptNear1I.ToLoc( frIntr) ;
|
||||
IntersCurveCurve intCC( *pCopy1, *pCopy2) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNear1I, ptInt1) ||
|
||||
! intCC.GetIntersPointNearTo( 1, ptNear1I, ptInt2))
|
||||
return nullptr ;
|
||||
ptInt1.ToGlob( frIntr) ;
|
||||
ptInt2.ToGlob( frIntr) ;
|
||||
|
||||
// proiezione del punto di intersezione sulla prima curva
|
||||
DistPointCurve dPCI1( ptInt1, cCrv1) ;
|
||||
double dTgPar1 ;
|
||||
int nFlag1 ;
|
||||
if ( ! dPCI1.GetParamAtMinDistPoint( 0, dTgPar1, nFlag1) || nFlag1 != MDPCI_NORMAL)
|
||||
return nullptr ;
|
||||
Point3d ptTg1 ;
|
||||
Vector3d vtTg1 ;
|
||||
if ( ! cCrv1.GetPointTang( dTgPar1, ICurve::FROM_MINUS, ptTg1, vtTg1))
|
||||
return nullptr ;
|
||||
|
||||
// proiezione del punto di intersezione sulla seconda curva
|
||||
DistPointCurve dPCI2( ptInt2, cCrv2) ;
|
||||
double dTgPar2 ;
|
||||
int nFlag2 ;
|
||||
if ( ! dPCI2.GetParamAtMinDistPoint( 0, dTgPar2, nFlag2) || nFlag2 != MDPCI_NORMAL)
|
||||
return nullptr ;
|
||||
Point3d ptTg2 ;
|
||||
Vector3d vtTg2 ;
|
||||
if ( ! cCrv2.GetPointTang( dTgPar2, ICurve::FROM_MINUS, ptTg2, vtTg2))
|
||||
return nullptr ;
|
||||
|
||||
// determino rotazione tra le curve
|
||||
bool bCCW = (( vtTg1 ^ vtTg2) * vtNorm) > 0 ;
|
||||
// orientamento tra le curve
|
||||
bool bCCW = ( dSinA > 0) ;
|
||||
|
||||
// assegno i valori dei parametri di trim (+ da inizio, - da fine)
|
||||
if ( bCCW) {
|
||||
@@ -118,8 +181,17 @@ CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
// creo l'arco di fillet
|
||||
PtrOwner<CurveArc> crvFillet( CreateBasicCurveArc()) ;
|
||||
if ( IsNull( crvFillet) ||
|
||||
! crvFillet->SetC2PN( ptInt1, ptTg1, ptTg2, vtNorm))
|
||||
! crvFillet->SetC2PN( ptCen, ptTg1, ptTg2, vtNorm))
|
||||
return nullptr ;
|
||||
// se direzioni agli estremi praticamente parallele
|
||||
if ( bParallel) {
|
||||
// calcolo il verso dell'arco di fillet
|
||||
bool bFilletCcw = ( ( bCCW && nSide1 == nSide2) || ( ! bCCW && nSide1 != nSide2)) ;
|
||||
// si deve verificare se va usato l'arco esplementare
|
||||
bool bArcCcw = ( crvFillet->GetAngCenter() > 0) ;
|
||||
if ( bFilletCcw != bArcCcw)
|
||||
crvFillet->ToExplementary() ;
|
||||
}
|
||||
return Release(crvFillet) ;
|
||||
}
|
||||
|
||||
@@ -129,7 +201,7 @@ CreateChamfer( const ICurve& cCrv1, const Point3d& ptNear1,
|
||||
const ICurve& cCrv2, const Point3d& ptNear2,
|
||||
const Vector3d& vtNorm, double dDist, double& dPar1, double& dPar2)
|
||||
{
|
||||
// verifico validità parametri ricevuti
|
||||
// verifico validità parametri ricevuti
|
||||
if ( &cCrv1 == nullptr || &ptNear1 == nullptr ||
|
||||
&cCrv2 == nullptr || &ptNear2 == nullptr ||
|
||||
&vtNorm == nullptr || &dPar1 == nullptr || &dPar2 == nullptr)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkVector3d.h"
|
||||
#include "/EgtDev/Include/EGtNumCollection.h"
|
||||
#include "/EgtDev/Include/EgtNumCollection.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double AdjustFontRatio( double dRatio) ;
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
+22
-40
@@ -16,8 +16,8 @@
|
||||
#include "FontNfe.h"
|
||||
#include "FontAux.h"
|
||||
#include "FontConst.h"
|
||||
#include "GdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
@@ -81,21 +81,19 @@ NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic,
|
||||
if ( ! m_pGDB->Load( sFont))
|
||||
return false ;
|
||||
// recupero i parametri generali del font (devono essere nel gruppo 1)
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
if ( ! iIter.GoTo( 1))
|
||||
return false ;
|
||||
if ( ! pIter->GoTo( 1))
|
||||
return false ;
|
||||
if ( ! pIter->GetInfo( NFE_H, m_dH) ||
|
||||
! pIter->GetInfo( NFE_HCAP, m_dHCap) ||
|
||||
! pIter->GetInfo( NFE_HX, m_dHx) ||
|
||||
! pIter->GetInfo( NFE_ASC, m_dAsc) ||
|
||||
! pIter->GetInfo( NFE_DESC, m_dDesc) ||
|
||||
! pIter->GetInfo( NFE_ADV, m_dAdv))
|
||||
if ( ! iIter.GetInfo( NFE_H, m_dH) ||
|
||||
! iIter.GetInfo( NFE_HCAP, m_dHCap) ||
|
||||
! iIter.GetInfo( NFE_HX, m_dHx) ||
|
||||
! iIter.GetInfo( NFE_ASC, m_dAsc) ||
|
||||
! iIter.GetInfo( NFE_DESC, m_dDesc) ||
|
||||
! iIter.GetInfo( NFE_ADV, m_dAdv))
|
||||
return false ;
|
||||
if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL)
|
||||
return false ;
|
||||
if ( ! pIter->GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
|
||||
if ( ! iIter.GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
|
||||
m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ;
|
||||
// aggiorno la path del font
|
||||
m_sFont = sFontUp ;
|
||||
@@ -161,11 +159,6 @@ NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
@@ -229,9 +222,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
@@ -265,9 +256,9 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
// copio la curva (trasformando eventuali archi in CurveBezier)
|
||||
ICurve* pCrvNew = CurveToNoArcsCurve( pCrv) ;
|
||||
@@ -281,7 +272,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
// inserisco in lista la nuova curva
|
||||
lstPC.push_back( pCrvNew) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
bIter = iIter.GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
@@ -314,9 +305,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
|
||||
// controllo valore tolleranza lineare
|
||||
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight)
|
||||
@@ -354,9 +343,9 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
// copia temporanea della curva (trasformando eventuali archi in CurveBezier)
|
||||
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
|
||||
@@ -371,7 +360,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
|
||||
lstPL.emplace_back() ;
|
||||
pCrvNew->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, lstPL.back()) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
bIter = iIter.GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
@@ -400,9 +389,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
GdbIterator iIter( m_pGDB) ;
|
||||
|
||||
// controllo valore tolleranza lineare
|
||||
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight)
|
||||
@@ -440,9 +427,9 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
// copia temporanea della curva (trasformando eventuali archi in CurveBezier)
|
||||
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
|
||||
@@ -457,7 +444,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
lstPA.emplace_back() ;
|
||||
pCrv->ApproxWithArcs( dLinTol, dAngTolDeg, lstPA.back()) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
bIter = iIter.GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
@@ -484,11 +471,6 @@ NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECT
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
|
||||
+12
-16
@@ -16,15 +16,15 @@
|
||||
#include "FontOs.h"
|
||||
#include "FontAux.h"
|
||||
#include "FontConst.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
@@ -298,8 +298,7 @@ OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC))
|
||||
return false ;
|
||||
// lo trasformo opportunamente
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
@@ -378,8 +377,7 @@ OsFont::GetRegion( const string& sText, int nInsPos, ISURFFRPLIST& lstSFR) const
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo trasformo opportunamente
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// inverto i percorsi per avere gli esterni CCW
|
||||
(*iIter)->Invert() ;
|
||||
// la trasformo per avere solo archi e rette
|
||||
@@ -465,8 +463,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo approssimo con segmenti di retta
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
@@ -479,7 +476,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
|
||||
if ( vtMove.x > dMaxW)
|
||||
dMaxW = vtMove.x ;
|
||||
// ciclo di pulizia
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
delete (*iIter) ;
|
||||
lstPC.clear() ;
|
||||
}
|
||||
@@ -550,8 +547,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo approssimo con segmenti di arco e retta
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
@@ -564,7 +560,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
|
||||
if ( vtMove.x > dMaxW)
|
||||
dMaxW = vtMove.x ;
|
||||
// ciclo di pulizia
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
delete (*iIter) ;
|
||||
lstPC.clear() ;
|
||||
}
|
||||
@@ -731,7 +727,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC
|
||||
if ( pHeader->dwType == TT_POLYGON_TYPE) {
|
||||
|
||||
// creo curva composita
|
||||
PtrOwner<ICurveComposite> pCCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<CurveComposite> pCCompo( CreateBasicCurveComposite()) ;
|
||||
if ( IsNull( pCCompo))
|
||||
return false ;
|
||||
|
||||
@@ -824,7 +820,7 @@ OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const
|
||||
return false ;
|
||||
|
||||
// creo retta, la imposto e la inserisco nella curva composita
|
||||
PtrOwner<ICurveLine> pCLine( CreateCurveLine()) ;
|
||||
PtrOwner<CurveLine> pCLine( CreateBasicCurveLine()) ;
|
||||
if ( IsNull( pCLine))
|
||||
return false ;
|
||||
if ( ! pCLine->Set( ptStart, ptEnd))
|
||||
@@ -845,7 +841,7 @@ OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo,
|
||||
return false ;
|
||||
|
||||
// creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita
|
||||
PtrOwner<ICurveBezier> pCBezier( CreateCurveBezier()) ;
|
||||
PtrOwner<CurveBezier> pCBezier( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCBezier))
|
||||
return false ;
|
||||
if ( ! pCBezier->Init( 2, false) ||
|
||||
|
||||
+23
-3
@@ -37,6 +37,23 @@ Frame3d::Set( const Point3d& ptOrig, const Vector3d& vtDirX,
|
||||
! m_vtVersZ.Normalize())
|
||||
return false ;
|
||||
|
||||
// se ci sono errori molto piccoli di ortogonalità, li correggo
|
||||
double dOrtXZ = m_vtVersX * m_vtVersZ ;
|
||||
if ( dOrtXZ > EPS_ZERO && dOrtXZ < 10 * EPS_ZERO) {
|
||||
m_vtVersX = OrthoCompo( m_vtVersX, m_vtVersZ) ;
|
||||
m_vtVersX.Normalize() ;
|
||||
}
|
||||
double dOrtYX = m_vtVersY * m_vtVersX ;
|
||||
if ( dOrtYX > EPS_ZERO && dOrtYX < 10 * EPS_ZERO) {
|
||||
m_vtVersY = OrthoCompo( m_vtVersY, m_vtVersX) ;
|
||||
m_vtVersY.Normalize() ;
|
||||
}
|
||||
double dOrtYZ = m_vtVersY * m_vtVersZ ;
|
||||
if ( dOrtYZ > EPS_ZERO && dOrtYZ < 10 * EPS_ZERO) {
|
||||
m_vtVersY = OrthoCompo( m_vtVersY, m_vtVersZ) ;
|
||||
m_vtVersY.Normalize() ;
|
||||
}
|
||||
|
||||
// verifica della ortogonalità dei versori e del senso destrorso
|
||||
if ( ! Verify())
|
||||
return false ;
|
||||
@@ -224,10 +241,10 @@ Frame3d::Set( const Point3d& ptOrig, double dAngCDeg, double dAngADeg, double dA
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Reset( void)
|
||||
Frame3d::Reset( bool bGlob)
|
||||
{
|
||||
m_nType = TOP ;
|
||||
m_nZType = TOP ;
|
||||
m_nType = ( bGlob ? TOP : ERR) ;
|
||||
m_nZType = ( bGlob ? TOP : ERR) ;
|
||||
m_ptOrig = ORIG ;
|
||||
m_vtVersX = X_AX ;
|
||||
m_vtVersY = Y_AX ;
|
||||
@@ -456,6 +473,9 @@ Frame3d::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
bool
|
||||
Frame3d::Verify( void)
|
||||
{
|
||||
// verifica origine
|
||||
if ( ! m_ptOrig.IsValid())
|
||||
return false ;
|
||||
// verifica della ortogonalità dei versori e del senso destrorso
|
||||
double dOrtXY = m_vtVersX * m_vtVersY ;
|
||||
double dOrtYZ = m_vtVersY * m_vtVersZ ;
|
||||
|
||||
+176
-226
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -14,10 +14,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "OutTsc.h"
|
||||
#include "/EgtDev/Include/EgkGdbExecutor.h"
|
||||
#include "/EgtDev/Include/EGkGdbExecutor.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include "/EgtDev/Include/EgtExecMgr.h"
|
||||
#include "/EgtDev/Include/EgkGeoCollection.h"
|
||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||
#include "Tool.h"
|
||||
|
||||
class PolyLine ;
|
||||
|
||||
+10
-2
@@ -101,6 +101,10 @@ GdbGeo::Save( int nBaseId, NgeWriter& ngeOut, INTUNORDSET* pSavedIds) const
|
||||
if ( pGObjRW == nullptr)
|
||||
return false ;
|
||||
|
||||
// eventuali modifiche prima del salvataggio
|
||||
if ( ! pGObjRW->PreSave( * const_cast<GdbGeo*>( this)))
|
||||
return false ;
|
||||
|
||||
// tipo entità e identificativi
|
||||
if ( ! ngeOut.WriteKey( pGObjRW->GetNgeId()))
|
||||
return false ;
|
||||
@@ -124,7 +128,11 @@ GdbGeo::Save( int nBaseId, NgeWriter& ngeOut, INTUNORDSET* pSavedIds) const
|
||||
// parametri geometrici
|
||||
if ( ! ngeOut.WriteKey( NGE_G))
|
||||
return false ;
|
||||
return pGObjRW->Save( ngeOut) ;
|
||||
if ( ! pGObjRW->Save( ngeOut))
|
||||
return false ;
|
||||
|
||||
// eventuali ripristini dopo il salvataggio
|
||||
return pGObjRW->PostSave( * const_cast<GdbGeo*>( this)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -181,7 +189,7 @@ GdbGeo::Load( int nNgeId, NgeReader& ngeIn, int nBaseGdbId, int& nParentId)
|
||||
|
||||
// parametri geometrici
|
||||
IGeoObjRW* pGObjRW = dynamic_cast<IGeoObjRW*>( m_pGeoObj) ;
|
||||
return ( pGObjRW != nullptr && pGObjRW->Load( ngeIn)) ;
|
||||
return ( pGObjRW != nullptr && pGObjRW->Load( ngeIn) && pGObjRW->PostLoad( *this)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -54,6 +54,10 @@ class GdbGeo : public GdbObj
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const GdbGeo* GetGdbGeo( const GdbObj* pGObj)
|
||||
{ return dynamic_cast<const GdbGeo*>(pGObj) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetGdbType() != GDB_TY_GEO)
|
||||
return nullptr ;
|
||||
return static_cast<const GdbGeo*>( pGObj) ; }
|
||||
inline GdbGeo* GetGdbGeo( GdbObj* pGObj)
|
||||
{ return dynamic_cast<GdbGeo*>(pGObj) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetGdbType() != GDB_TY_GEO)
|
||||
return nullptr ;
|
||||
return static_cast<GdbGeo*>( pGObj) ; }
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ GdbGroup::~GdbGroup( void)
|
||||
// nel sorgente aggiorno lista dei riferimenti
|
||||
INTVECTOR vnList ;
|
||||
pGdbObj->GetInfo( GDB_SI_LIST, vnList) ;
|
||||
INTVECTOR::const_iterator iFind = find( vnList.begin(), vnList.end(), m_nId) ;
|
||||
const auto iFind = find( vnList.begin(), vnList.end(), m_nId) ;
|
||||
if ( iFind != vnList.end())
|
||||
vnList.erase( iFind) ;
|
||||
if ( vnList.empty())
|
||||
|
||||
+6
-2
@@ -91,6 +91,10 @@ class GdbGroup : public GdbObj
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const GdbGroup* GetGdbGroup( const GdbObj* pGObj)
|
||||
{ return dynamic_cast<const GdbGroup*>(pGObj) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetGdbType() != GDB_TY_GROUP)
|
||||
return nullptr ;
|
||||
return static_cast<const GdbGroup*>( pGObj) ; }
|
||||
inline GdbGroup* GetGdbGroup( GdbObj* pGObj)
|
||||
{ return dynamic_cast<GdbGroup*>(pGObj) ; }
|
||||
{ if ( pGObj == nullptr || pGObj->GetGdbType() != GDB_TY_GROUP)
|
||||
return nullptr ;
|
||||
return static_cast<GdbGroup*>( pGObj) ; }
|
||||
|
||||
+66
-9
@@ -24,7 +24,7 @@ using namespace std ;
|
||||
IGdbIterator*
|
||||
CreateGdbIterator( IGeomDB* pGDB)
|
||||
{
|
||||
if ( dynamic_cast<GeomDB*>( pGDB) == nullptr)
|
||||
if ( static_cast<GeomDB*>( pGDB) == nullptr)
|
||||
return nullptr ;
|
||||
return static_cast<IGdbIterator*> ( new( nothrow) GdbIterator( pGDB)) ;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ GdbIterator::~GdbIterator( void)
|
||||
bool
|
||||
GdbIterator::SetGDB( IGeomDB* pGDB)
|
||||
{
|
||||
m_pGDB = dynamic_cast<GeomDB*>( pGDB) ;
|
||||
m_pGDB = static_cast<GeomDB*>( pGDB) ;
|
||||
if ( m_pGDB == nullptr)
|
||||
return false ;
|
||||
|
||||
@@ -105,7 +105,7 @@ GdbIterator::GoToFirstInGroup( const IGdbIterator& iIter)
|
||||
return false ;
|
||||
}
|
||||
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -167,7 +167,7 @@ GdbIterator::GoToLastInGroup( const IGdbIterator& iIter)
|
||||
return false ;
|
||||
}
|
||||
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -263,7 +263,7 @@ GdbIterator::GoToFirstNameInGroup( const IGdbIterator& iIter, const string& sNam
|
||||
return false ;
|
||||
}
|
||||
// converto in oggetto iteratore di base
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -345,7 +345,7 @@ GdbIterator::GoToLastNameInGroup( const IGdbIterator& iIter, const string& sName
|
||||
return false ;
|
||||
}
|
||||
// converto in oggetto iteratore di base
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -474,7 +474,7 @@ GdbIterator::GoToFirstGroupInGroup( const IGdbIterator& iIter)
|
||||
return false ;
|
||||
}
|
||||
// converto in oggetto iteratore di base
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -553,7 +553,7 @@ GdbIterator::GoToLastGroupInGroup( const IGdbIterator& iIter)
|
||||
return false ;
|
||||
}
|
||||
// converto in oggetto iteratore di base
|
||||
const GdbIterator* pIter = dynamic_cast<const GdbIterator*> (&iIter) ;
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
|
||||
m_pCurrObj = nullptr ;
|
||||
return false ;
|
||||
@@ -1468,7 +1468,8 @@ GdbIterator::SetInfo( const string& sKey, int nInfo)
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( dInfo)) ;
|
||||
int nErr ;
|
||||
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1618,6 +1619,62 @@ GdbIterator::RemoveInfo( const string& sKey)
|
||||
return m_pCurrObj->RemoveInfo( sKey) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero tutte le Info
|
||||
return m_pCurrObj->GetAllInfo( vsInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::CopyAllInfoFrom( const IGdbIterator& iIter)
|
||||
{
|
||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero l'oggetto sorgente
|
||||
const GdbIterator* pIter = static_cast<const GdbIterator*> (&iIter) ;
|
||||
if ( pIter == nullptr || pIter->m_pGDB != m_pGDB || pIter->m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
const GdbObj* pGdbObjSou = pIter->m_pCurrObj ;
|
||||
|
||||
// copio tutte le Info
|
||||
if ( m_pCurrObj != pGdbObjSou && pGdbObjSou->m_pAttribs != nullptr) {
|
||||
m_pCurrObj->GetSafeAttribs() ;
|
||||
return ( m_pCurrObj->m_pAttribs != nullptr && m_pCurrObj->m_pAttribs->CopyAllInfoFrom( *(pGdbObjSou->m_pAttribs))) ;
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Stipple (significativo solo per curve)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetStipple( int nFactor, int nPattern)
|
||||
{
|
||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
// imposto lo stipple
|
||||
return m_pCurrObj->SetStipple( nFactor, nPattern) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetStipple( int& nFactor, int& nPattern) const
|
||||
{
|
||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||
return false ;
|
||||
// recupero lo stipple
|
||||
return m_pCurrObj->GetStipple( nFactor, nPattern) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// TextureData
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+7
-2
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
// EgalTech 2013-2023
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GdbIterator.h Data : 04.12.13 Versione : 1.4a3
|
||||
// File : GdbIterator.h Data : 09.07.23 Versione : 2.5g1
|
||||
// Contenuto : Dichiarazione della classe GdbIterator.
|
||||
//
|
||||
//
|
||||
@@ -142,6 +142,11 @@ class GdbIterator : public IGdbIterator
|
||||
bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const override ;
|
||||
bool ExistsInfo( const std::string& sKey) const override ;
|
||||
bool RemoveInfo( const std::string& sKey) override ;
|
||||
bool GetAllInfo( STRVECTOR& vsInfo) const override ;
|
||||
bool CopyAllInfoFrom( const IGdbIterator& iIter) override ;
|
||||
// Stipple
|
||||
bool SetStipple( int nFactor, int nPattern) override ;
|
||||
bool GetStipple( int& nFactor, int& nPattern) const override ;
|
||||
// TextureData
|
||||
bool SetTextureName( const std::string& sTxrName) override ;
|
||||
bool SetTextureFrame( const Frame3d& frTxrRef) override ;
|
||||
|
||||
+45
-4
@@ -31,9 +31,9 @@ using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GdbObj::GdbObj( void)
|
||||
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_pTxrData( nullptr), m_pUserObj( nullptr),
|
||||
m_pSelPrev( nullptr), m_pSelNext( nullptr),
|
||||
m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
|
||||
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_nStpFactor( 0), m_nStpPattern( 0), m_pTxrData( nullptr),
|
||||
m_pUserObj( nullptr), m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr),
|
||||
m_pSelNext( nullptr), m_pSelPrev( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ GdbObj::CopyFrom( const GdbObj* pSou)
|
||||
if ( m_pAttribs != nullptr)
|
||||
delete m_pAttribs ;
|
||||
m_pAttribs = nullptr ;
|
||||
// reset stipple
|
||||
m_nStpFactor = 0 ;
|
||||
m_nStpPattern = 0 ;
|
||||
// elimino eventuali dati della texture pre-esistenti
|
||||
if ( m_pTxrData != nullptr)
|
||||
delete m_pTxrData ;
|
||||
@@ -90,6 +93,10 @@ GdbObj::CopyFrom( const GdbObj* pSou)
|
||||
// copio Id
|
||||
m_nId = pSou->m_nId ;
|
||||
|
||||
// copio stipple
|
||||
m_nStpFactor = pSou->m_nStpFactor ;
|
||||
m_nStpPattern = pSou->m_nStpPattern ;
|
||||
|
||||
// copio gli attributi, i dati della texture e UserObj
|
||||
return ( CopyAttribsFrom( pSou) && CopyTextureDataFrom( pSou) && CopyUserObjFrom( pSou)) ;
|
||||
}
|
||||
@@ -855,7 +862,8 @@ GdbObj::SetInfo( const string& sKey, int nInfo)
|
||||
bool
|
||||
GdbObj::SetInfo( const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( dInfo)) ;
|
||||
int nErr ;
|
||||
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1023,6 +1031,39 @@ GdbObj::RemoveInfo( const string& sKey)
|
||||
return m_pAttribs->RemoveInfo( sKey) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::GetAllInfo( STRVECTOR& vsInfo) const
|
||||
{
|
||||
// se non ci sono attributi
|
||||
if ( m_pAttribs == nullptr) {
|
||||
vsInfo.clear() ;
|
||||
return true ;
|
||||
}
|
||||
// recupero tutte le Info
|
||||
return m_pAttribs->GetAllInfo( vsInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Stipple (significativo solo per curve, per ora non viene salvato)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::SetStipple( int nFactor, int nPattern)
|
||||
{
|
||||
m_nStpFactor = nFactor ;
|
||||
m_nStpPattern = nPattern ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::GetStipple( int& nFactor, int& nPattern) const
|
||||
{
|
||||
nFactor = m_nStpFactor ;
|
||||
nPattern = m_nStpPattern ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// TextureData
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -119,6 +119,9 @@ class GdbObj
|
||||
bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const ;
|
||||
bool ExistsInfo( const std::string& sKey) const ;
|
||||
bool RemoveInfo( const std::string& sKey) ;
|
||||
bool GetAllInfo( STRVECTOR& vsInfo) const ;
|
||||
bool SetStipple( int nFactor, int nPattern) ;
|
||||
bool GetStipple( int& nFactor, int& nPattern) const ;
|
||||
bool SaveTextureData( NgeWriter& ngeOut) const ;
|
||||
bool LoadTextureData( NgeReader& ngeIn) ;
|
||||
TextureData* GetTextureData( void)
|
||||
@@ -160,6 +163,8 @@ class GdbObj
|
||||
public :
|
||||
int m_nId ;
|
||||
Attribs* m_pAttribs ;
|
||||
int m_nStpFactor ;
|
||||
int m_nStpPattern ;
|
||||
TextureData* m_pTxrData ;
|
||||
IUserObj* m_pUserObj ;
|
||||
|
||||
|
||||
+6
-2
@@ -50,7 +50,11 @@ const double BEZARC_ANG_CEN_MAX = 90 ;
|
||||
//----------------- Costanti per superfici TriMesh ---------------------------
|
||||
// tolleranza lineare standard
|
||||
const double STM_STD_LIN_TOL = 0.1 ;
|
||||
// angolo limite per definire un edge che è contorno di poligono
|
||||
// angolo limite standard per definire un edge che è contorno di poligono
|
||||
const double STM_STD_BOUNDARY_ANG = 0.1 ;
|
||||
// angolo limite per mediare le normali in un vertice
|
||||
// angolo limite standard per mediare le normali in un vertice
|
||||
const double STM_STD_SMOOTH_ANG = 25.0 ;
|
||||
// distanza limite tra diagonali per quadrilatero con twist
|
||||
const double STM_TWIST_DIAG_DIST = 1.0 ;
|
||||
// angolo limite con twist per mediare le normali in un vertice
|
||||
const double STM_TWIST_SMOOTH_ANG = 35.0 ;
|
||||
|
||||
+6
-3
@@ -29,7 +29,7 @@ GEOOBJ_REGISTER( GEO_FRAME3D, NGE_G_FRM, GeoFrame3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoFrame3d::GeoFrame3d( void)
|
||||
: m_frF(), m_nTempProp()
|
||||
: m_frF(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ GeoFrame3d::Clone( void) const
|
||||
bool
|
||||
GeoFrame3d::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const GeoFrame3d* pGFr = dynamic_cast<const GeoFrame3d*>( pGObjSrc) ;
|
||||
const GeoFrame3d* pGFr = GetBasicGeoFrame3d( pGObjSrc) ;
|
||||
if ( pGFr == nullptr)
|
||||
return false ;
|
||||
return CopyFrom( *pGFr) ;
|
||||
@@ -114,7 +114,10 @@ GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
|
||||
{
|
||||
if ( &gfSrc == this)
|
||||
return true ;
|
||||
m_nTempProp = gfSrc.m_nTempProp ;
|
||||
m_nTempProp[0] = gfSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = gfSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = gfSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = gfSrc.m_dTempParam[1] ;
|
||||
return Set( gfSrc.m_frF) ;
|
||||
}
|
||||
|
||||
|
||||
+31
-5
@@ -57,10 +57,16 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
const IObjGraphics* GetObjGraphics( void) const override
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
void SetTempProp( int nProp) override
|
||||
{ m_nTempProp = nProp ; }
|
||||
int GetTempProp( void) const override
|
||||
{ return m_nTempProp ; }
|
||||
void SetTempProp( int nProp, int nPropInd = 0) override
|
||||
{ if ( nPropInd >= 0 && nPropInd < 2)
|
||||
m_nTempProp[nPropInd] = nProp ; }
|
||||
int GetTempProp( int nPropInd = 0) const override
|
||||
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
||||
void SetTempParam( double dParam, int nParamInd = 0) override
|
||||
{ if ( nParamInd >= 0 && nParamInd < 2)
|
||||
m_dTempParam[nParamInd] = dParam ; }
|
||||
double GetTempParam( int nParamInd = 0) const override
|
||||
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
|
||||
|
||||
public : // IGeoFrame3d
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
@@ -77,7 +83,10 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
bool Save( NgeWriter& ngeOut) const override ;
|
||||
bool PreSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool PostSave( GdbGeo& Wrapper) const override { return true ; }
|
||||
bool Load( NgeReader& ngeIn) override ;
|
||||
bool PostLoad( GdbGeo& Wrapper) override { return true ; }
|
||||
|
||||
public :
|
||||
GeoFrame3d( void) ;
|
||||
@@ -95,5 +104,22 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Frame3d m_frF ; // oggetto
|
||||
int m_nTempProp ; // proprietà temporanea
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline GeoFrame3d* CreateBasicGeoFrame3d( void)
|
||||
{ return ( static_cast<GeoFrame3d*>( CreateGeoObj( GEO_FRAME3D))) ; }
|
||||
inline GeoFrame3d* CloneBasicGeoFrame3d( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_FRAME3D)
|
||||
return nullptr ;
|
||||
return ( static_cast<GeoFrame3d*>( pGObj->Clone())) ; }
|
||||
inline const GeoFrame3d* GetBasicGeoFrame3d( const IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_FRAME3D)
|
||||
return nullptr ;
|
||||
return ( static_cast<const GeoFrame3d*>( pGObj)) ; }
|
||||
inline GeoFrame3d* GetBasicGeoFrame3d( IGeoObj* pGObj)
|
||||
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_FRAME3D)
|
||||
return nullptr ;
|
||||
return ( static_cast<GeoFrame3d*>( pGObj)) ; }
|
||||
|
||||
+7
-3
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
// EgalTech 2014-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GeoObjRW.h Data : 14.03.14 Versione : 1.5d5
|
||||
// File : GeoObjRW.h Data : 08.03.24 Versione : 2.6c2
|
||||
// Contenuto : Dichiarazione della interfaccia IGeoObjRW.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 20.11.13 DS Creazione modulo.
|
||||
//
|
||||
// 08.03.24 DS Aggiunte PreSave, PostSave, PreLoad e PostLoad.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
class NgeWriter ;
|
||||
class NgeReader ;
|
||||
class GdbGeo ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class __declspec( novtable) IGeoObjRW
|
||||
@@ -22,5 +23,8 @@ class __declspec( novtable) IGeoObjRW
|
||||
public :
|
||||
virtual int GetNgeId( void) const = 0 ;
|
||||
virtual bool Save( NgeWriter& ngeOut) const = 0 ;
|
||||
virtual bool PreSave( GdbGeo& Wrapper) const = 0 ;
|
||||
virtual bool PostSave( GdbGeo& Wrapper) const = 0 ;
|
||||
virtual bool Load( NgeReader& ngeIn) = 0 ;
|
||||
virtual bool PostLoad( GdbGeo& Wrapper) = 0 ;
|
||||
} ;
|
||||
|
||||
+6
-3
@@ -28,7 +28,7 @@ GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoPoint3d::GeoPoint3d( void)
|
||||
: m_ptP(), m_nTempProp()
|
||||
: m_ptP(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ GeoPoint3d::Clone( void) const
|
||||
bool
|
||||
GeoPoint3d::CopyFrom( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const GeoPoint3d* pGP = dynamic_cast<const GeoPoint3d*>( pGObjSrc) ;
|
||||
const GeoPoint3d* pGP = GetBasicGeoPoint3d( pGObjSrc) ;
|
||||
if ( pGP == nullptr)
|
||||
return false ;
|
||||
return CopyFrom( *pGP) ;
|
||||
@@ -82,7 +82,10 @@ GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
m_nTempProp = clSrc.m_nTempProp ;
|
||||
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
|
||||
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
|
||||
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
|
||||
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
|
||||
return Set( clSrc.m_ptP) ;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user