Compare commits

...

285 Commits

Author SHA1 Message Date
Daniele Bariletti 10f9aeb870 EgtGeomKernel :
- tolte variabili inutili.
2024-02-05 15:53:42 +01:00
Daniele Bariletti c088ac9a08 Merge branch 'master' into ExtDimension_angular 2024-02-05 15:36:55 +01:00
Daniele Bariletti 932f590b61 EgtGeomKernel :
- migliorato il tracing dei loop di trim per sup. di bezier.
2024-02-05 14:56:51 +01:00
Daniele Bariletti df4188002a EgtGeomKernel :
- correzione al CopyFrom delle sup. di Bezier
- ottimizzata la curva di trim nelle sup. di Bezier.
2024-02-05 09:08:38 +01:00
Dario Sassi 005f75a4ba EgtGeomKernel :
- modifica in SurfTriMesh per evitare crash.
2024-02-04 23:54:26 +01:00
Dario Sassi b5a74807ef EgtGeomKernel :
- eliminata variabile inutilizzata.
2024-02-02 16:18:55 +01:00
Dario Sassi 56d7726a58 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-02-02 16:02:46 +01:00
Dario Sassi 9db53c7ee3 EgtGeomKernel 2.6b1 :
- modificata delta per ricalcolo offset con Voronoi (da 1e-14 a 1e-9).
2024-02-02 16:00:12 +01:00
Daniele Bariletti 43c511b86f Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-02-01 17:30:46 +01:00
Daniele Bariletti 7043b2b318 EgtGeomKernel :
- corretti bug di identificazione EdgeIn e EdgeOut nel tracing dei loop
di trim di sup. di Bezier.
2024-02-01 17:30:42 +01:00
Dario Sassi 3c458e9187 EgtGeomKernel :
- in chiusura curve composite uniformato epsilon di controllo (ora sempre EPS_CONNECT = 0.01 * EPS_SMALL).
2024-01-31 11:40:47 +01:00
Dario Sassi 3fc056af67 EgtGeomKernel :
- nelle curve composite aggiunta funzione TestClosure per far coincidere esattamente inizio/fine di curve chiuse
- aggiustamenti per nuovo parametro con errore a ToString di double.
2024-01-31 09:44:41 +01:00
Daniele Bariletti 46dbd17d7b EgtGeomKernel :
- correzione minore.
2024-01-30 16:56:05 +01:00
Daniele Bariletti 86395eb2d1 EgtGeomKernel :
- correzione minore.
2024-01-30 16:24:37 +01:00
Daniele Bariletti 5fbc75e4bd Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-01-30 16:03:58 +01:00
Daniele Bariletti 3d326c9ca2 EgtGeomKernel :
- miglioramenti e correzione di alcuni bug nella triangolazione delle
superfici di bezier.
2024-01-30 16:03:39 +01:00
SaraP 2a43eca91c EgtGeomKernel :
- migliorata gestione delle curve composite chiuse forzando i punti iniziale e finale a coincidere se necessario
- migliorato calcolo area delle polyline nel caso di estremi non perfettamente coincidenti.
2024-01-30 15:50:23 +01:00
Dario Sassi debf3d65ba EgtGeomKernel :
- modifica a OffsetCurve per evitare inutili ricalcoli di Voronoi in caso di suo utilizzo.
2024-01-29 12:57:05 +01:00
Dario Sassi cfe3672f8b Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-01-29 09:17:13 +01:00
Dario Sassi 9dfe558a83 EgtGeomKernel 2.6a2 :
- cambiate interfacce legate a Voronoi reso non più visibile all'esterno della libreria.
2024-01-29 09:15:50 +01:00
Daniele Bariletti cc312f1529 EgtGeomKernel :
- corrette e migliorate le funzioni per
il tracing dei loop di trim delle superifci
 di Bezier
- corretto un bug nella costruzione dei poligoni in superfici bezier
periodiche.
2024-01-24 14:57:16 +01:00
Daniele Bariletti d88de3576d EgtGeomKernel : - correzione del merge. 2024-01-23 09:20:00 +01:00
Daniele Bariletti 9e1d183343 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-01-23 09:03:31 +01:00
Daniele Bariletti 09665eda9f EgtGeomKernel : - piccole correzioni alla
triangolazione delle superfici di Bezier.
2024-01-23 08:53:53 +01:00
SaraP 44d080eae9 EgtGeomKernel :
- correzione in RemoveCurveSmallParts.
2024-01-22 13:22:50 +01:00
Riccardo Elitropi d5e1be8be2 EgtGeomKernel :
- in OffsetCurve modifica merge per stesse proprietà.
2024-01-22 11:26:49 +01:00
Dario Sassi d96660e6d1 EgtGeomKernel :
- correzione verifica collisione tra SurfTrimesh chiusa e Zmap.
2024-01-22 08:37:05 +01:00
SaraP d72f7b6299 EgtGeomKernel :
- correzioni e miglioramenti nel calcolo dei bisettori di Voronoi
- corretto il modo di gestire gli archi per rispettare le tolleranze di vroni
- in GetSurfTriMeshBeveledRectSwept tolto il calcolo in parallelo degli offset se conti fatti con Voronoi.
2024-01-19 10:28:34 +01:00
Dario Sassi 1f77e00f34 EgtGeomKernel 2.6a1 :
- ricompilazione con cambio versione.
2024-01-16 15:14:25 +01:00
SaraP 5c222cc59f EgtGeomKernel :
- in OffsetCurve aggiuto membro per tolleranza lineare
- in SurfFrFromFatCurve aggiunta tolleranza per l'offset.
2024-01-10 10:09:26 +01:00
SaraP 7ee7fea375 EgtGeomKernel :
- correzioni nella verifica di collisione tra triangoli.
2024-01-08 16:00:19 +01:00
SaraP 1c2b127a91 EgtGeomKernel :
- migliorie in RemoveCurveSmallParts per evitare conti superflui introdotti con ultima correzione.
2024-01-08 10:17:15 +01:00
SaraP 0e927d7294 EgtGeomKernel :
- piccola correzione in RemoveCurveSmallParts.
2024-01-05 17:18:40 +01:00
Dario Sassi 0dc918880e EgtGeomKernel :
- piccola modifica della tolleranza movimenti di Collision Avoid per Trimesh.
2024-01-02 15:57:23 +01:00
Dario Sassi ac5fe3ac65 EgtGeomKernel :
- modifiche estetiche.
2023-12-29 13:01:09 +01:00
Dario Sassi a9d6a87317 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2023-12-29 12:56:46 +01:00
Dario Sassi 650540e573 EgtGeomKernel :
- semplificata e ottimizzata creazione di superficie trimesh box standard
- miglioramenti sintattici vari.
2023-12-29 12:55:24 +01:00
Riccardo Elitropi 0ae7e1876b Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2023-12-22 09:30:32 +01:00
Riccardo Elitropi 4e7501ed7f EgtGeomKernel :
- piccola modifica a svuotatura Spiral in CalcPocketing.
2023-12-22 09:28:30 +01:00
Daniele Bariletti 59f5c16c3b EgtGeomKernel :
- correzione alle intersezioni tra trimesh.
2023-12-19 10:19:03 +01:00
Dario Sassi 1280037d1d EgtGeomKernel :
- aggiunti alcuni controlli di sicurezza a NurbsCurveCanonicalize.
2023-12-18 19:55:50 +01:00
Dario Sassi c91c2a9720 EgtGeomKernel :
- aggiunte funzioni per calcolo elevazione di Poligono in Box e in TriMesh chiusa.
2023-12-18 09:28:45 +01:00
Dario Sassi 7c44a6ec82 Merge commit '6277b2eaa8de1273323ff27321721923cb3f8033' 2023-12-18 09:22:33 +01:00
SaraP 6277b2eaa8 EgtGeomKernel :
- correzione offset Voronoi con curve chiuse.
2023-12-15 16:56:32 +01:00
Dario Sassi 92da41d421 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2023-12-15 15:13:00 +01:00
Dario Sassi f7f30854a1 EgtGeomKernel 2.5l3 :
- piccola correzione nel riconoscimento facce di TriMesh.
2023-12-15 15:12:04 +01:00
SaraP 5eea981790 EgtGeomKernel :
- ulteriore correzione offset con Voronoi.
2023-12-14 17:43:54 +01:00
SaraP f52608e15a EgtGeomKernel :
- correzione offset con Voronoi.
2023-12-14 12:34:19 +01:00
Dario Sassi fbbb0739ee EgtgeomKernel :
- correzioni a Zmap per virtual milling con utensile a tronco di cono (coda di rondine).
2023-12-13 11:29:39 +01:00
Dario Sassi 903f0c69bc EgtGeomKernel 2.5l2 :
- aggiunto calcolo edge di superfici trimesh
- piccole modifiche per usare direttamente oggetti anzichè le loro interfacce.
2023-12-11 10:23:30 +01:00
Dario Sassi 2ca801e2ec EgtGeomKernel :
- miglioramento in Collision Avoid grazie alla gestione delle tolleranze sulle parti piatte perpendicolari all'asse in funzione della direzione di allontanamento.
2023-12-07 11:03:23 +01:00
Dario Sassi fc9312f0f2 EgtGeomKernel 2.5l1 :
- ricompilazione con cambio versione.
2023-12-01 16:44:19 +01:00
SaraP c2b36208e7 EgtGeomKernel :
- corretta gestione archi con Voronoi.
2023-11-29 12:45:33 +01:00
Riccardo Elitropi b1e30147ea EgtGeomKernel :
- eliminata la funzione GetZigZagInfill dalla classe SurfFlatRegion ( sostituita da CalcZigZagInfill)
- modifica alle funzioni di Pocketing.
2023-11-29 12:04:52 +01:00
Riccardo Elitropi 4903fcd9d2 EgtGeomKernel :
- correzione Offset per superfici.
2023-11-28 10:31:08 +01:00
SaraP c3de378c7d EgtGeomKernel :
- correzione frame per offset SurfFlatRegion.
2023-11-28 09:58:41 +01:00
Riccardo Elitropi b818f5dcb2 EgtGeomKernel :
- correzione GetSurfFlatRegionFromFatCurve con VRONI.
2023-11-28 09:42:31 +01:00
Riccardo Elitropi 6d2cc32568 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2023-11-27 12:59:36 +01:00
Riccardo Elitropi 9bee3fbb8f EgtGeomKernel :
- piccola correzione CalcPocketing.
2023-11-27 12:59:33 +01:00
Daniele Bariletti cd303ff099 EgtGeomKernel :
- tolte variabili di debug/inutili.
2023-11-27 12:49:01 +01:00
Riccardo Elitropi c192d9a539 EgtGeomKernel :
- aggiunta funzione CalcZigZagInfill.
2023-11-27 12:33:13 +01:00
Dario Sassi fce40ffc38 EgtGeomKernel :
- piccole sistemazioni post Vroni (per usarlo in Offset _VRONI, altrimenti NVRONI).
2023-11-24 12:52:27 +01:00
SaraP 5bd5efafb1 EgtGeomKernel :
- miglioria in AdjustLoops per gestire piccole autointersezioni
- piccola correzione in RemoveCurveSmallParts.
2023-11-23 13:04:05 +01:00
SaraP d6fffd228e EgtGeomKernel 2.5k5 :
- introdotta classe per Voronoi
- aggiunto oggetto Voronoi alle curve e alla SurfFlatRegion
- introdotta la versione Voronoi in OffsetCurve e in SurfFlatRegion::Offset
- aggiunta funzione che calcola una nuova flat region offsettando una flat region esistente
- introdotta la versione Voronoi nel calcolo di una SurfFlatRegion da fat curve
- aggiunto vettore di parametri temporanei di tipo double agli oggetti geometrici.
2023-11-23 13:01:08 +01:00
Daniele Bariletti b96daf4925 EgtGeomKernel :
- piccoli aggiustamenti alla gestione delle surf di Bezier
- correzione ai trim interni a una cella di un Tree di Bezier.
2023-11-23 12:42:47 +01:00
Dario Sassi c755406963 Merge commit 'f378661948be3b57568e9891286fe575444d461e' 2023-11-22 20:16:48 +01:00
Dario Sassi 296b274190 EgtGeomKernel :
- in Polyline aggiunte TempProp e funzioni di Set e  Get relative
- in ProjectCurveOnSurfTm migliorato calcolo normale nei punti proiettati in
- altre piccole migliorie nelle inizializzazioni di oggetti geometrici.
2023-11-22 20:15:56 +01:00
Daniele Bariletti f378661948 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2023-11-22 15:46:42 +01:00
Daniele Bariletti 37fc7b2164 EgtGeomKernel :
- correzioni alle superfici di Bezier ( Load, Invert)
- correzioni al Tree delle Bezier ( SetSurf).
2023-11-22 15:46:18 +01:00
Riccardo Elitropi 91dca91153 EgtGeomKernel 2.5k4 :
- aggiunte funzioni per CalcPocketing.
2023-11-20 11:47:53 +01:00
Dario Sassi e30a2481a2 EgtGeomKernel :
- ridotto step di approssimazione VirtualMilling per movimenti 5assi.
2023-11-20 09:45:16 +01:00
Dario Sassi 70f2f1cb01 EgtGeomKernel 2.5k3 :
- migliorie alla funzione ProjectCurveOnSurfTm.
2023-11-16 18:53:41 +01:00
Dario Sassi c158f8ac3e Merge commit 'a46fbb3f05a39e18574ebea7058d66e141216bf8' 2023-11-16 09:37:32 +01:00
Daniele Bariletti a46fbb3f05 EgtGeomKernel :
- correzione alla triangolazione delle Bezier
- correzione alla conversione da NURBS razionali a Bezier
- correzione della funzione Invert per le Bezier.
2023-11-15 13:04:54 +01:00
Dario Sassi b53a5adca4 EgtGeomKernel :
- piccola correzione in GetOCCrvsWithProps.
2023-11-12 19:27:25 +01:00
Daniele Bariletti 7d6e3dc386 EgtGeomKernel 2.5k2 :
- cambio versione.
2023-11-08 08:46:55 +01:00
Daniele Bariletti f352ca0ae0 Merge branch '3dm_import+trim&mesh' 2023-11-07 17:50:25 +01:00
Daniele Bariletti 68d0198f3f EgtGeomKernel :
- debug.
2023-11-07 17:39:43 +01:00
Daniele Bariletti 0007121340 EgtGeomKernel :
- correzione alla conversione da NURBS a Bezier nel caso razionale.
2023-11-07 17:38:47 +01:00
Daniele Bariletti a6e3c42340 EgtGeomKernel :
- correzione di un errore numerico nel tracking delle curve di trim.
2023-11-07 12:39:49 +01:00
Daniele Bariletti c0c01573ca EgtGeomKernel :
- aggiunta la gestione delle superfici e curve NURBS unclamped.
- correzioni al caso con una sola patch o casi senza raffinazione
dei punti.
2023-11-07 12:34:41 +01:00
Dario Sassi badbef94e6 EgtGeomKernel 2.5k1 :
- aggiunta funzione RemoveCurveSmallParts per eliminare curve semplici molto corte da composite modificando le adiacenti
- aggiunto filtro con funzione precedente in ricostruzione contorni di regioni dopo operazioni booleane
- aggiunto filtro con funzione precedente prima di offset avanzato
- in CurveBezier calcoli resi indipendenti da lunghezza almeno EPS_SMALL.
2023-11-03 17:22:53 +01:00
Daniele Bariletti 610bd48747 EgtGeomKernel :
- debug.
2023-10-23 11:28:14 +02:00
SaraP 2d5657a05a EgtGeomKernel :
- gestito GetAllInfo quando vettore delle info è vuoto.
2023-10-20 12:15:59 +02:00
SaraP 04b47e40b4 EgtGeomKernel 2.5j3 :
- in OffsetCurve l'unione delle parti allineate viene fatta anche per curve estreme ( con ripristino start point).
2023-10-20 08:44:44 +02:00
Daniele Bariletti 5bb1fdaed3 EgtGeomKernel :
- correzione bug nelle sup di Bezier chiuse.
2023-10-19 12:45:48 +02:00
Daniele Bariletti a5714cc85d EgtGeomKernel :
- correzione alla conversione da sup NURBS a Bezier.
2023-10-19 12:44:31 +02:00
Daniele Bariletti 83a4c03979 Merge branch 'Bezier_trim&mesh' into 3dm_import+trim&mesh 2023-10-17 12:20:45 +02:00
Daniele Bariletti e2eb219c5a EgtGeomKernel :
- correzione alla conversione da sup Nurbs a Bezier.
2023-10-17 11:23:08 +02:00
Daniele Bariletti e44b08d669 EgtGeomKernel :
- aggiunta la gestione delle superfici NURBS periodiche
- correzione formattazione e nomi.
2023-10-17 10:02:08 +02:00
Dario Sassi 058814a64b EgtGeomKernel 2.5j2 :
- ricompilazione con cambio versione.
2023-10-11 08:30:55 +02:00
Riccardo Elitropi 3c52ca3fef EgtGeomKernel :
- rimozione parametro in SubtractProjectedFacesOnStmFace
- migliorie varie.
2023-10-10 13:34:31 +02:00
Dario Sassi 9ec04bff06 EgtGeomKernel 2.5j1 :
- riallineamento.
2023-10-09 13:06:09 +02:00
Dario Sassi fd2ba16258 EgtGeomKernel 2.5j1 :
- ricompilazione per chiavi di rete esposte su Internet.
2023-10-09 10:48:48 +02:00
Daniele Bariletti 9b34154a16 EgtGeomKernel :
- corretti gli ultimi errori nel clamping delle curve periodiche.
Manca :
- estensione alle superfici.
2023-10-06 09:08:12 +02:00
Daniele Bariletti 10dd5828ce EgtGeomKernel :
- corretti errori nel clamping delle nurbs periodiche.
2023-10-05 17:29:15 +02:00
Daniele Bariletti bf2a3f0e22 EgtGeomKernel :
- implementazione delle nurbs periodiche; da sistemare.
2023-10-04 16:39:20 +02:00
Daniele Bariletti 38146c6294 EgtGeomKernel :
- corretto un errore nella ricerca info in un layer senza info.
2023-10-04 13:02:56 +02:00
Riccardo Elitropi 18d7e471ae EgtGeomKernel 2.5j1 :
- aggiunta funzione SubtractProjectedFacesOnStmFace
- modifica funzione GetSilhouette con aggiunta di parametro opzionale.
2023-10-04 12:22:17 +02:00
Daniele Bariletti eccf683ef4 EgtGeomKernel :
- aggiunta delle coordintae U e V ai vertici delle TriMesh.
2023-10-02 14:55:04 +02:00
Daniele Bariletti d96ea77db7 EgtGeomKernel :
- correzione su coordinate U e V dei vertici delle TriMesh.
2023-09-26 12:22:32 +02:00
Dario Sassi 041cbe4a8f EgtGeomKernel 2.5i5 :
- ricompilazione a 64bit con Enable Enhanced Instruction Set = Not Set.
2023-09-21 15:25:07 +02:00
Daniele Bariletti 381a137604 EgtGeomKernel :
- introduzione delle nurbs periodiche; da finire.
2023-09-21 14:38:47 +02:00
Daniele Bariletti e5ed9efdd1 EgtGeomKernel :
- corretto un bug nella conversione surf NURBS to Bezier.
2023-09-19 12:36:29 +02:00
Daniele Bariletti 1ec38952ed EgtGeomKernel :
- correzione alla trasformazione NURBS to Bezier.
2023-09-19 10:23:37 +02:00
Daniele Bariletti bfc6439dc0 EgtGeomKernel :
- piccola correzione alle quotature angolari.
2023-09-18 15:04:20 +02:00
Daniele Bariletti 4f16e8263a Merge remote-tracking branch 'origin/master' into ExtDimension_angular 2023-09-18 10:57:31 +02:00
Daniele Bariletti b2bd8f7afe EgtGeomKernel :
- correzione su coordinate U e V ai vertici delle TriMesh.
2023-09-18 10:33:50 +02:00
Daniele Bariletti cb0452a248 EgtGeomKernel :
- aggiunta delle coordinate U e V ai vertici delle TriMesh.
Manca da modificare :
- funzione MoveVertex.
2023-09-18 10:21:49 +02:00
Dario Sassi b7a5123ba9 EgtGeomKernel :
- miglior controllo dei risultati in asportazione materiale da Zmap (virtual milling).
2023-09-18 08:12:24 +02:00
Dario Sassi 29c00caf4a EgtGeomKernel :
- razionalizzazione di alcune funzioni di Zmap per taglio spilloni.
2023-09-14 17:25:04 +02:00
Dario Sassi 73a65d8cf9 EgtGeomKernel :
- correzioni a Zmap con mappa singola
- aggiunto a Zmap e sua interfaccia metodo IsTriDexel.
2023-09-12 16:00:34 +02:00
Daniele Bariletti 419d325409 EgtGeomKernel :
- correzione di bug nel trim di sup di Bezier chiuse
- correzione di bug nella conversione di NURBS in sup di Bezier
2023-09-12 14:49:43 +02:00
Dario Sassi 349c515e3e EgtGeomKernel 2.5i1 :
- corretta SetSawTool di Tool per caso con raggio corner uguale a raggio
- aggiunta prima versione di proiezione curva su superficie trimesh.
2023-09-11 10:38:44 +02:00
Daniele Bariletti 69166fe585 Merge branch '3dm_import' into Bezier_trim&mesh 2023-08-28 16:07:47 +02:00
Daniele Bariletti 0eb19f1735 Merge commit 'c0fe5f14a8f18139e15639856a8ec6799498bdb2' into 3dm_import 2023-08-28 16:07:31 +02:00
Daniele Bariletti 737f4f4ffa EgtGeomKernel :
- correzione alla conversione da NURBS a Bezier.
2023-08-28 16:06:26 +02:00
Daniele Bariletti 8a81c3543e EgtGeomKernel :
- aggiunta della funzione di conversione da superficie NURBS a Bezier
2023-08-28 09:39:34 +02:00
Dario Sassi c0fe5f14a8 EgtGeomKernel :
- in CurveComposite::CopyParamRange si ritorna nullptr anche quando curva risultato viene creata ma è vuota.
2023-08-21 12:06:15 +02:00
Dario Sassi 9fce0bd4f4 EgtGeomKernel :
- aggiunta funzione GetArc2PNB.
2023-08-04 13:20:08 +02:00
Dario Sassi 663784a841 EgtGeomKernel :
- ApproxWithArcsEx di CurveComposite ora approssima in modo avanzato anche le parti che sono già archi o curve di Bezier.
2023-08-04 11:14:06 +02:00
Dario Sassi 238c0ae490 EgtGeomKernel :
- corretto GetBBox di SurfFlatRegion con più parti
- in OffsetCurve migliorato Migliorato angoli esterni di valore circa 180deg.
2023-08-03 17:32:05 +02:00
Dario Sassi c4a4da6945 EgtGeomKernel 2.5h1 :
- in ConvertCurveToBasicComposite aggiunta gestione estrusione, spessore e proprietà temporanee.
2023-08-03 11:16:20 +02:00
DarioS fb62c6d68e EgtGeomKernel 2.5g3 :
- migliorata gestione approssimazione con archi.
2023-07-28 11:22:50 +02:00
DarioS 2ba32eb93c EgtGeomKernel :
- altre piccole ottimizzazioni nel cambio sistema di riferimento.
2023-07-27 10:23:03 +02:00
DarioS 6e34ab6169 EgtGeomKernel :
- piccole ottimizzazioni nel cambio sistema di riferimento.
2023-07-27 09:29:07 +02:00
DarioS 538126cfe5 EgtGeomKernel :
- aggiunti altri controlli per superfici trimesh vuote in CutWithOtherSurf, Cut e GeneralizedCut.
2023-07-21 17:20:09 +02:00
DarioS a0a6bf8377 EgtGeomKernel :
- correzione ad operazioni booleane con TriMesh per gestire superfici vuote senza crash.
2023-07-21 16:41:51 +02:00
DarioS ba05c5307a EgtGeomKernel :
- aggiunta funzione inline ConvertCurveToBasicComposite e suo utilizzo.
2023-07-21 15:11:14 +02:00
DarioS 234878388d EgtGeomKernel 2.5g2 :
- approssimazione con archi di curve composite viene fatta nel piano perpendicolare all'estrusione o se questa non definita nel piano medio della curva
- trim start/end a parametro di curve composite ora irrobustito.
2023-07-19 09:53:11 +02:00
DarioS baac48f7b9 EgtGeomKernel :
- aggiunta gestione Stipple di curve.
2023-07-10 11:14:20 +02:00
DarioS e4815830cd EgtGeomKernel 2.5g1 :
- aggiunta funzione GetSurfTmNearestVertex
- a SurfTriMesh aggiunti metodi MoveVertex e GetAllVertInFacet
- corretta DoCompacting di SurfTriMesh aggiungendo verifica del calcolo della normale dei triangoli.
2023-07-07 17:04:15 +02:00
DarioS b5b48bf4c2 EgtGeomKernel 2.5f6 :
- dove possibile e sicuro sostituiti dynamic_cast con static_cast.
2023-06-30 11:50:07 +02:00
Daniele Bariletti 8279e66cae EgtGeomKernel :
- correzione minore alle superfici di bezier
2023-06-23 16:56:48 +02:00
DarioS 8f84f78b16 EgtGeomKernel 2.5f5 :
- aggiunta gestione lock tra thread diversi delle operazioni di lettura, scrittura, copia e relocate nel DB geometrico tramite classe LockAddErase che usa std::atomic_flag.
2023-06-23 09:15:10 +02:00
Daniele Bariletti 1c34e40289 Merge remote-tracking branch 'origin/HEAD' into Bezier_trim&mesh 2023-06-21 09:31:36 +02:00
Daniele Bariletti e9c22b895b EgtGeomKernel :
- risolti vari bug
- ridotto il calcolo del tree alle bbox delle curve di trim
2023-06-21 09:30:07 +02:00
DarioS 8a3d46416d EgtGeomKernel 2.5f4 :
- corretta IntersSegmentCylinder (qui come cilindro si intende solo la superficie dello stesso)
- corretta e velocizzata AvoidSurfTm di VolZmap nel caso di test con singola map.
2023-06-21 08:26:21 +02:00
Daniele Bariletti ebda605497 EgftGeomKernel :
- sistemati i bug noti
- pulito il codice
Da aggiungere :
- calcolo del tree solo nelle bbox delle curve di trim
2023-06-19 08:50:47 +02:00
DarioS c4f1a7f97b EgtGeomKernel :
- correzioni nella verifica di collisione di Poliedri con Poliedri (superfici trimesh chiuse) o TriDexel (Zmap).
2023-06-19 07:59:05 +02:00
Daniele Bariletti 06a69fa66b EgtGeomKernel :
- pulizia del codice
Problemi :
- bug dovuto a problemi numerici sulle intersezione tra trim e celle
2023-06-15 15:28:04 +02:00
Daniele Bariletti 4daa62db97 EgtGeomKernel :
- risolti i bug noti
- fatti con successo test con superfici e curve complesse
manca
- pulizia del codice.
2023-06-15 10:47:53 +02:00
DarioS 0c1ad4dd86 EgtGeomKernel :
- corretta GetSurfTriMeshBeveledRectSwept con tappi piatti
- corretta AddSurfTriMesh di StmFromTriangleSoup per bOk non inizializzato.
2023-06-13 18:28:41 +02:00
Daniele Bariletti cb1edcf20a EgtGeomKernel :
- sistemati vari bug
Manca
- da testare superfici e trim complessi
2023-06-13 16:40:45 +02:00
DarioS 36547c24c2 EgtGeomKernel 2.5f3 :
- in Close di CurveComposite si usa una tolleranza di EPS_SMALL/10 per verificare se la curva è chiusa
- in OffsetCurve se la curva originale era chiusa e tale va considerata si verifica la chiusura dei risultati ed eventualmente si sistemano.
2023-06-13 15:18:50 +02:00
SaraP 3d4042e274 EgtGeomKernel :
- piccola correzione al concatenameto di curve per FlatRegion nel caso in cui la curva si annulla dopo aggiunta alla composita.
2023-06-13 12:35:33 +02:00
Daniele Bariletti d3d7f94c3a EgtGeomKernel :
- risolti i bug noti
- gestiti problemi numerici al bordo delle celle
Manca
- test in casi più complicati
2023-06-13 11:55:33 +02:00
SaraP b9a8777b96 EgtGeomKernel 2.5f2 :
- aggiornamento versione.
2023-06-12 09:34:08 +02:00
SaraP 6cf009fae3 EgtGeomKernel :
- correzione in GetSurfFlatRegionFromFatCurve.
2023-06-12 09:19:06 +02:00
DarioS 735c12bca7 EgtGeomKernel :
- correzione a Offset di FlatRegion (per evitare problemi si uniscono tratti troppo corti)
- correzione a Offset di Curve per gestione di linee formate da più parti e con riconosciute come piane
- correzione a MergeCurves di CurveComposite per gestione della seconda proprietà.
2023-06-12 08:02:53 +02:00
DarioS 393cac35c5 EgtGeomKernel :
- in creazione linea ora si azzera anche il secondo TempProp.
2023-06-10 11:01:41 +02:00
Daniele Bariletti 1aeb2809fa EgtGeomKernel :
- risolti i bug noti
Da migliorare:
- in caso di curve di trim sul bordo di celle, considero intersecate
quelle esterne
- possibili problemi numerici al bordo delle celle in FindInters
2023-06-09 17:51:47 +02:00
Daniele Bariletti 7cf933ec48 EgtGeomKernel :
- risolti i problemi di trim su superfici di bezier
Problemi noti:
- mancano ancora delle celle
- si formano delle crack
2023-06-07 17:43:23 +02:00
Daniele Bariletti f3346fd1f1 EgtGeomKernel :
- sistemati vari bug nella creazione della superficie trimesh trimmata
si una superficie di bezier
Problemi noti :
- sui casi con un tree reale entro in un loop infinito o seleziono oppure
seleziono un elemento inesistente di un vettore
2023-06-06 16:36:09 +02:00
Daniele Bariletti 579bc5492c EgtGeomKernel :
- sistemati vari bug nella creazione della superficie trimesh trimmata
si una superficie di bezier
Problemi noti :
- sui casi con un tree reale genero dei poligoni sbagliati per le celle
2023-06-06 10:40:03 +02:00
Daniele Bariletti 71ac2fde82 EgtGeomKernel :
- aggiunte tutte le funzionalità per la gestione delle superfici di bezier
con spazio parametrico trimmato
Manca :
- debug.
2023-06-05 12:12:47 +02:00
DarioS 804a434e75 EgtGeomKernel 2.5f1 :
- correzioni a modifiche precedenti legate a gestione chiave di rete.
2023-06-05 08:09:05 +02:00
Daniele Bariletti 56d80f5bdd EgtGeomKernel :
- aggiustati dei bug
- implementati gli strumenti per la gestione delle celle non intersecate
Da aggiungere :
- categorizzazione celle rispetto ai loop.
2023-06-01 15:32:05 +02:00
DarioS 71ba650cc5 EgtGeomKernel 2.5e5 :
- migliorato controllo gestione chiave di rete.
2023-05-30 10:24:23 +02:00
Daniele Bariletti 4704554728 EgtGeomKernel :
- aggiunta la gestione delle aree di trim nested
Da aggiungere :
- gestione delle celle non intersecate dai loop
2023-05-30 09:05:26 +02:00
Daniele Bariletti e4243a2df3 EgtGeomKernel :
- implementato il trim dello spazio parametrico.
Da aggiungere :
- gestione delle celle non intersecate, interne ai loop
Problematiche :
- gestione di aree di trim nested in una cella
2023-05-29 09:02:51 +02:00
DarioS 0a63a4c9a2 EgtGeomKernel 2.5e4 :
- modifiche per verifica collisione con TriMesh chiuse
- aggiunta gestione Capsule.
2023-05-22 14:34:10 +02:00
Daniele Bariletti 967f5aa795 Merge remote-tracking branch 'origin/master' into Bezier_trim&mesh 2023-05-19 12:17:38 +02:00
Daniele Bariletti f0429aefa4 EgtGeomKernel :
- migliorata la robustezza per il calcolo della curvatura
- pulizia del codice
Da aggiungere :
- gestione trim.
2023-05-18 15:07:27 +02:00
Daniele Bariletti c3b8677910 EgtGeomKernel :
- aggiunto lo split preliminare delle patches e impostato come default
- gestito il caso di superfici chiuse come il toro
- corretto un errore sul miglioramento delle prestazioni
Da aggiungere :
- gestione delle sup. trimmate.
2023-05-18 09:48:02 +02:00
Daniele Bariletti 268983804e EgtGeomKernel :
- gestite le superfici bilineari singole e multipatch
- gestite le superfici chiuse o su un parametro o sull'altro
- migliorate le prestazioni.
Da aggiungere :
- split preliminare delle patches
- la gestione delle sup. trimmate
2023-05-17 08:46:33 +02:00
DarioS b78212c3a1 EgtGeomKernel :
- miglioramenti e ottimizzazioni in CD su Zmap per cilindri e tronchi di cono.
2023-05-16 20:26:35 +02:00
DarioS 8420edecb5 EgtGeomKernel :
- miglioramenti negli algoritmi di controllo collisioni tra solidi semplici e Zmap (aumento velocità 2x, 5x).
2023-05-16 09:37:40 +02:00
DarioS 7c6ddf2a6f EgtGeomKernel :
- aggiunto controllo validità coordinate di punti e vettori (isfinite).
2023-05-15 14:50:32 +02:00
DarioS 2d8c815032 EgtGeomKernel 2.5e3 :
- a BBox3d aggiunto 2° metodo Overlaps con box aventi diverso orientamento
- nelle funzioni di Collision Detection migliorato controllo non interne
- nele funzioni Avoid di Zmap si utilizza confronto box con diverso orientamento.
2023-05-14 11:58:48 +02:00
Daniele Bariletti 8c79bbb2b6 EgtGeomKernel :
- completata l'implementazione della tassellazione adattiva per una
superficie di bezier
( si può migliorare il costo di memoria e computazionale)
- manca la gestione del trim dello spazio parametrico.
2023-05-10 15:35:42 +02:00
Daniele Bariletti 2d83c860f2 EgtGeomKernel :
- utilizzo di un binary tree al posto del kd-tree
- implementate le funzioni sul binary tree ( a parte il bilanciamento)
- errori noti : calcolo curvatura per decidere la direzione di split.
2023-05-08 17:02:02 +02:00
DarioS 7023d721f4 EgtGeomKernel :
- modifica a IsFlat per renderla compatibile con l'esecuzione in parallelo.
2023-05-08 09:32:12 +02:00
DarioS 0f530271f0 EgtGeomKernel 2.5e2 :
- aggiunta AddSurfTriMesh a StmFromTriangleSoup
- velocizzazione dei calcoli in GetSurfTriMeshBeveledRectSwept (solidi di AM).
2023-05-08 08:24:04 +02:00
DarioS ec3389633c EgtGeomKernel :
- piccoli ritocchi.
2023-05-04 16:10:31 +02:00
DarioS 5c0848797c EgtGeomKernel 2.5e1 :
- modifiche al recupero dei triangoli che appartengono ad una stessa faccia (eliminata recursione).
2023-05-04 12:37:47 +02:00
Daniele Bariletti 6a3fc0fd97 EgtGeomKernel :
- implementazione delle classi KdTree e Cell
- problemi : bilanciamento albero e uso puntatori
2023-05-03 12:09:58 +02:00
DarioS 545e37b7cd EgtGeomKernel 2.5d5 :
- semplificata la precedente correzione all'offset avanzato delle curve.
2023-04-25 17:40:18 +02:00
DarioS 469e660da0 EgtGeomKernel 2.5d4 :
- in ApproxWithLines di CurveComposite aggiunta gestione tipo approssimazione APL_SPECIAL_INT (come SPECIAL ma con garanzia di tre punti su curve non rettilinee)
- migliorato calcolo AreaXY e Area di Curve grazie al nuovo tipo di approssimazione
- migliorata in Dump gestione decimali di Area
- in OffsetCurve corretto possibile errore con curve chiuse dovuto a mancata unione tratti tra autointersezioni suddiviso tra inizio e fine curva.
2023-04-24 15:47:41 +02:00
Daniele Bariletti 97fd05640b EgtGeomKernel :
- aggiustamenti alla classe ExtDimension
2023-04-19 17:27:04 +02:00
Daniele Bariletti 5d4b220dc7 Merge commit '13b02f51a31192cfb3f9f67f597bff377eb8d02f' into ExtDimension_angular 2023-04-19 15:32:42 +02:00
DarioS 13b02f51a3 EgtGeomKernel :
- corretto riconoscimento interna/esterna tra curve chiuse che non si intersecano.
2023-04-18 19:21:54 +02:00
DarioS d1790d8f07 EgtGeomKernel :
- in Vector3d creata variante di GetRotation con parametro dEpsZero per stabilire soglia una sola soluzione invece di due.
2023-04-17 09:28:25 +02:00
Daniele Bariletti bca419ad63 EgtGeomKernel :
- aggiustamenti alla classe ExtDimension
2023-04-14 09:43:14 +02:00
DarioS c925c6a17a EgtGeomKernel :
- al termine delle operazioni booleane sulle Regioni si eliminano i loop troppo piccoli.
2023-04-11 20:39:10 +02:00
DarioS 00ccfe967e EgtGeomKernel 2.5d3 :
- sistemazioni per quote radiali e diametrali, rimangono da completare le quote angolari.
2023-04-11 19:35:08 +02:00
DarioS 3b5d145f85 Merge remote-tracking branch 'origin/ExtDimension_angular' 2023-04-08 11:41:52 +02:00
DarioS ee4592a113 EgtGeomKernel :
- cambiata soglia di semplificazione angoli esterni in offset curve.
2023-04-07 09:42:44 +02:00
DarioS 35618b1882 EgtGeomKernel 2.5d1 :
- correzione all'offset avanzato di Curve fase 8 di chain per casi con curve che in modifica per concatenazione si annullano.
2023-04-06 18:01:50 +02:00
Daniele Bariletti bde7ff1e5c EgtGeomKernel :
- aggiunto alla classe ExtDimension i sottotipi Angular, Radial e Diametral.
2023-03-31 14:46:26 +02:00
Daniele Bariletti 10f73435bf Merge remote-tracking branch 'origin/master' into ExtDimension_angular 2023-03-31 14:41:56 +02:00
DarioS 21b4af444b EgtGeomKernel :
- aggiustamenti per PtrOwner nuova funzione Set.
2023-03-27 20:40:04 +02:00
DarioS 4410a83631 EgtGeomKernel :
- piccole modifiche per nuovo Set di PtrOwner.
2023-03-27 18:41:16 +02:00
DarioS ca19f9e735 EgtGeomKernel 2.5c3 :
- eliminato memory leak in AddCurve di CurveComposite quando fallisce l'aggiunta di curve partendo da un'altra composita.
2023-03-27 13:31:00 +02:00
DarioS aa8ae0146d EgtGeomKernel :
- ricompilazione con cambio versione.
2023-03-23 10:05:03 +01:00
DarioS 29138a63c8 EgtGeomKernel 2.5c2 :
- nella creazione delle regioni si tiene conto delle proprietà delle curve di contorno nell'unirle.
2023-03-21 14:19:28 +01:00
DarioS 64a904b628 EgtGeomKernel :
- inserita modifica calcolo box archi da Riccardo.
2023-03-20 08:12:18 +01:00
DarioS c939a50a39 Merge commit '68800a1dfa5ac4f35ee67bc5a5d0635fd77fd9e6' 2023-03-17 12:31:47 +01:00
Riccardo Elitropi 27f28b9f28 Merge branch 'develop' 2023-03-16 08:05:15 +01:00
Riccardo Elitropi 053410f43b EgtGeomKernel :
- Offset delle regioni, seconda tmpProp delle curve contiene il loop da cui deriva
2023-03-16 08:03:35 +01:00
DarioS a74949c832 EgtGeomKernel 2.5c1 :
- modifiche a CurveComposite::CopyParamRange se start e end coincidono non devo ritornare alcunché.
2023-03-06 08:31:34 +01:00
DarioS f84aefc82d EgtGeomKernel 2.5b3 :
- migliorato riconoscimento complanarità per contorni che devono generare regioni.
2023-02-27 08:15:40 +01:00
DarioS 133b590e1c EgtGeomKernel :
- ristrette le tolleranze di StraightArcsToLines in OffsetCurve.
2023-02-20 14:41:11 +01:00
DarioS 65909b3366 EgtGeomKernel 2.5b2 :
- in CurveComposite aggiunta funzione StraightArcsToLines
- in OffsetCurve filtraggio prima dell'esecuzione anche con la funzione precedente.
2023-02-20 09:14:23 +01:00
Riccardo Elitropi 68800a1dfa EgtGeomKernel :
- modifica box3d archi.
2023-02-16 14:40:48 +01:00
DarioS 4f60bd24b6 EgtGeomKernel 2.5b1 :
- aggiunte funzioni AdjustAngleInSpan, AngleInRange e AdjustAngleInRange.
2023-02-10 11:26:00 +01:00
DarioS 2f3a6189a7 EgtGeomKernel :
- piccola modifica a SurfTriMesh::Cut per evitare deformazione facce per aggiustamento vertici su piano di taglio.
2023-02-05 15:41:33 +01:00
DarioS 078f730512 EgtGeomKernel 2.5a2 :
- aggiunte funzioni GetAllInfo per recuperare tutte le info di una entità.
2023-01-30 09:40:53 +01:00
DarioS 368bd80c69 EgtGeomKernel :
- piccole migliorie per PCA di curve composite
- si evitano triangolazioni di poligoni con 2 soli lati (segmenti sovrapposti va e vieni).
2023-01-09 10:14:29 +01:00
DarioS e01941644b EgtGeomKernel 2.5a1 :
- ricompilazione con cambio versione.
2023-01-03 08:53:44 +01:00
DarioS 0f3bd716a3 EgtGeomKernel :
- modifiche per più utensili in virtual milling (Zmap).
2022-12-28 19:38:58 +01:00
SaraP 0030b684f3 EgtGeomKernel 2.4l4 :
- nelle polylines modificato il modo in cui vengono calcolati i vertici a minima distanza
- modifiche varie alle polylines.
2022-12-28 14:18:47 +01:00
DarioS 6e6be4e579 EgtGeomKernel :
- aggiunta funzione GetArc2PCN (calcolo arco per due punti con centro vicino a suggerito e normale).
2022-12-20 16:35:02 +01:00
DarioS 3add582efb EgtGeomKernel 2.4l3 :
- ricompilazione con cambio versione.
2022-12-20 11:10:13 +01:00
Riccardo Elitropi bd80f16812 EgtGeomKernel :
- Modifica Medial Axis.
2022-12-15 16:24:58 +01:00
DarioS ffc78b03a7 EgtGeomKernel 2.4l2 :
- corretto riconoscimento topologia intersezioni per autointersezioni di curve.
2022-12-08 10:35:32 +01:00
SaraP 2f6a1f7579 EgtGeomKernel :
- correzione a GetSurfFlatRegionFromFatCurve nel caso di curve quasi chiuse su piani inclinati.
2022-12-07 14:50:53 +01:00
DarioS e890d5f376 EgtGeomKernel 2.4l1 :
- ricompilazione con cambio versione.
2022-12-05 08:13:04 +01:00
SaraP 56b49d4c9f EgtGeomKernel 2.4k7 :
- aggiunta funzione per associare i punti a minima distanza di due polylines
- modifiche nelle trimesh rigate per usare nuova funzione polyline.
2022-12-01 11:26:52 +01:00
DarioS 7ee0e38cec EgtGeomKernel 2.4k6 :
- migliorata IsClosedAndFlat di PolyLine (se non riesce a calcolare il piano chiama IsFlat e quindi usa PCA)
- corretta RemoveCurveSmallZs per caso in cui non riesce a rimuovere il segmento incriminato.
2022-11-28 15:18:28 +01:00
DarioS 817bfa788e EgtGeomKernel :
- migliorata gestione loops per regioni.
2022-11-28 08:24:05 +01:00
DarioS a4bd5a25c2 EgtGeomKernel 2.4k5 :
- correzione in creazione regioni, eliminando curve chiude con diametro di ingombro inferiore a 20 epsilon.
2022-11-24 09:29:58 +01:00
DarioS 7c3b3e516a EgtGeomKernel 2.4k4 :
- correzione a offset di curve (crash su taglio di angoli interni problematici).
2022-11-22 19:24:50 +01:00
DarioS 9e3c8b697a EgtGeomKernel 2.4k3 :
- viene impedito di impostare su entità del DB Nome e Info con valore stringa vuota (si controllava solo il caso di stringa con spazi o equivalenti).
2022-11-21 16:05:56 +01:00
DarioS 775fec489b EgtGeomKernel 2.4k2 :
- corretto calcolo punto a distanza minima da CurveComposite
- aggiunta a CurveComposite funzione RemoveSmallDefects
- modifiche per usare la funzione precednte prima di calcolo offset e creazione regioni.
2022-11-14 08:33:10 +01:00
DarioS 790a75054c EgtGeomKernel :
- velocizzazione della funzione DoCompacting di SurfTriMesh.
2022-11-06 20:06:43 +01:00
DarioS b57421e2c9 EgtGeomKernel 2.4k1 :
-
2022-11-02 15:10:49 +01:00
DarioS a7dea8b1db EgtGeomKernel :
- piccola modifica in approssimazione curve.
2022-10-14 10:46:29 +02:00
DarioS 2808a95e4a EgtGeomKernel 2.4j1 :
- ricompilazione con cambio versione.
2022-10-12 10:34:07 +02:00
DarioS e0a350b148 EgtGeomKernel 2.4i4 :
- a superficie trimesh aggiunta CloneTriangle
- modifiche a Triangulate per gestione MinAngle di triangolo.
2022-10-11 12:27:24 +02:00
DarioS 560a447349 EgtGeomKernel 2.5i3 :
- in ApproxWithArcsEx di CurveComposite rimozione finale punti allineati con tolleranza ridotta.
2022-09-18 19:21:26 +02:00
SaraP 700b2ad5ca EgtGeomKernel :
- piccola miglioria a GetSurfFlatRegionFromFatCurve per gestire interni.
2022-09-13 17:07:04 +02:00
DarioS 85d677a41a EgtGeomKernel :
- piccola miglioria ad ApproxWithArcsEx di CurveComposite (non ancora risolutiva).
2022-09-13 08:10:32 +02:00
DarioS cc200501e9 EgtGeomKernel :
- aggiunta a SurfTriMesh la funzione IsEmpty.
2022-09-09 08:44:52 +02:00
DarioS d59cb55139 EgtGeomKernel :
- migliorata gestione errori in GetSurfFlatRegionFromFatCurve.
2022-09-07 18:52:22 +02:00
DarioS 46052e9d1f EgtGeomKernel 2.4i2 :
- correzione offset curve (non vengono conservate entità troppo piccole).
2022-09-07 12:52:57 +02:00
SaraP b36baf0fab EgtGeomKernel 2.4i1 :
- migliorie alla funzione SurfFlatRegion::GetZigZagInfill.
2022-09-06 09:49:53 +02:00
DarioS f2499d08ba EgtGeomKernel :
- modifica a Frame3d per inizializzazione e Reset come non inizializzato.
2022-08-29 07:16:48 +02:00
DarioS 651b34781b EgtGeomKernel :
- migliorie alla funzione CurveSimpleMedialAxis.
2022-08-24 17:38:49 +02:00
DarioS c57a6db4ae EgtGeomKernel :
- aggiunta funzione CurveSimpleMedialAxis (primi sviluppi).
2022-08-23 11:41:05 +02:00
DarioS 78b9234865 EgtGeomKernel 2.4h2 :
- in CurveArc migliorato controllo valore parametro in ChangeRadius e ChangeAngCenter
- migliorato calcolo fillet con possibilità di arrivare a 180 deg
- aggiunta GetCircle2P per creazione circonferenza da due punti su estremi di un diametro.
2022-08-21 16:16:02 +02:00
DarioS 6238ea1095 EgtGeomKernel 2.4h1 :
- in BBox3d aggiunti GetDimX, GetDimY e GetDimZ
- corretta DistLineLine con parametri punti estremi
- in creazione Stm da due curve (rigata) aggiunta gestione tipo RLT_ISOPAR_SMOOTH.
2022-08-17 19:17:44 +02:00
SaraP de99955e93 EgtGeomKernel 2.4g3 :
- in SurfFlatRegion aggiunta funzione che genera un riempimento a zigzag.
- piccola correzione a IsPointInsidePolyLine.
2022-07-28 16:25:37 +02:00
DarioS c45912a2e4 EgtGeomKernel 2.4g2 :
- modifica a ProjectCurveOnPlane per renderla più efficace.
2022-07-21 07:01:00 +02:00
DarioS 025b4a8b48 EgtGeomKernel 2.4g1 :
- corretto aggiornamento geometria dimensioni lineari senza testo.
2022-07-08 20:15:49 +02:00
DarioS a5802f0731 EgtGeomKernel 2.4f3 :
- corretta gestione raggio corner in definizione utensili per virtual milling.
2022-06-19 11:09:53 +02:00
DarioS 4f0a1460fd EgtGeomKernel 2.4f2 :
- nell'intersezione tra un piano e una superficie trimesh forzo il risultato a stare esattamente nel piano.
2022-06-13 20:13:50 +02:00
DarioS 498e5b37f4 EgtGeomKernel 2.4f1 :
- in accodamento curva a composita con aggiustamento estremo si verifica di non modificare troppo la curva stessa
- in offset curve migliorata gestione concatenamento finale.
2022-06-06 07:01:57 +02:00
SaraP fe0a6ad15d EgtGeomKernel 2.4e4 :
- in AdjustLoops migliorie nella gestione delle autointersezioni.
2022-05-20 10:19:48 +02:00
DarioS 13774ba26a EgtGeomKernel 2.4e3 :
- modifiche per prima gestione chiave di rete.
2022-05-17 08:22:20 +02:00
DarioS d1b22114d0 EgtGeomKernel :
- correzione ad archi di elica per DeltaN significativo ora pari a 1/10 EPS_SMALL.
2022-05-16 12:24:27 +02:00
DarioS 3f2b6b2115 EgtGeomKernel :
- aggiunte prime funzione per verifica collisione con oggetto capsule
- piccoli aggiornamenti alle verifiche di collisione.
2022-05-16 07:51:57 +02:00
DarioS bb8c0f766e EgtGeomKernel :
- corretta CDeBoxClosedSurfTm caso verifica box interno a superficie chiusa
- modificata CDeConeFrustumClosedSurfTm verifica tronco di cono interno a superficie chiusa tramite verifica del centro del cono
- modificata CDeCylClosedSurfTm verifica cilindro interno a superficie chiusa tramite verifica del centro del cilindro
- modificata CDeRectPrismoidClosedSurfTm verifica prismoide retto interno a superficie chiusa tramite verifica del centro del prismoide.
2022-05-14 11:59:43 +02:00
SaraP 76e490a583 EgtGeomKernel :
- modifiche a IntersParPlanesSurfTm.
2022-05-09 11:33:18 +02:00
SaraP ae91e1c51f EgtGeomKernel 2.4e1 :
- aggiunta HashGrids1d
- aggiunta intersezione fra SurfTriMesh e molti piani paralleli.
2022-05-09 09:04:32 +02:00
DarioS 4aff949349 EgtGeomKernel :
- correzioni ad offset di curve per casi da stampa 3d
- modifica a creazione superficie swept.
2022-04-26 08:15:55 +02:00
DarioS 3dcceecab7 EgtGeomKernel 2.4d4 :
- ricompilate versioni a 32bit con v141_xp (VisualStudio 2017 C++ per XP).
2022-04-24 17:08:07 +02:00
DarioS 7b6f1c3e92 EgtGeomKernel :
- aggiunta funzione FromNearestHorizontalOrtho per Vector3d.
2022-04-22 08:53:06 +02:00
DarioS b107596f84 EgtGeomKernel 2.4c2 :
- aggiunto a CurveComposite metodo AddLineTg.
2022-03-24 10:50:38 +01:00
DarioS b11de227f3 EgtGeomKernel :
- per superfici si rende più luminoso il materiale diffuso se deriva da colore.
2022-03-20 18:50:15 +01:00
DarioS f353e65e61 EgtGeomKernel 2.4c1 :
- migliorato calcolo distanza minima tra due linee
- eliminate da Trimesh parti inutili
- in Trimesh calcolo Loop di una faccia risolto problema di ciclo infinito
- in Trimesh aggiunta funzione per eliminare triangoli esattamente sovrapposti.
2022-03-14 09:03:13 +01:00
DarioS de34cfb7e8 EgtGeomKernel :
- sistemate minuscole/maiuscole in #include.
2022-02-26 17:47:48 +01:00
DarioS cb882b9379 EgtGeomKernel 2.4b3 :
- corretto GetMidDir di CurveComposite
- eliminati problemi con trigraph in x64.
2022-02-23 10:48:15 +01:00
DarioS f43951a9e2 EgtGeomKernel 2.4b2 :
- in chiusura di Curva Composita con estremi più vicini di 10*EPS_SMALL si spostano gli estremi a metà strada
- in creazione FlatRegion da FatCurve migliorata gestione curve quasi chiuse.
2022-02-20 19:31:03 +01:00
DarioS 899e371c52 EgtGeomKernel 2.4b1 :
- modificati messaggi di Log di Triangulate per non essere visti come veri errori.
2022-02-08 16:41:53 +01:00
DarioS 555e0e4375 EgtGeomKernel 2.4a4 :
- a CurveComposite aggiunte IsARectangle e IsATrapezoid.
2022-01-24 08:19:06 +01:00
DarioS 8710115634 EgtGeomKernel :
- inserita opzione in compilazioni 64bit per evitare Warning su verifica riferimenti non nulli.
2022-01-09 15:49:58 +01:00
DarioS 4056be90d9 EgtGeomKernel 2.4a3 :
- modifiche a IntersLineBox e IntersPlaneBox
- adattamenti conseguenti.
2022-01-09 15:17:00 +01:00
DarioS 77640f3a6f EgtGeomKernel :
- migliorie a RemoveTJunctions di SurfTriMesh.
2022-01-07 17:13:16 +01:00
DarioS 9b11212d07 EgtGeomKernel 2.4a2 :
- in TriMesh eliminata ResetFaceting e UpdateFaceting ora cerca di ricostruire facce con indice come le eventuali precedenti
- in Trimesh SimplifyFacets cerca di conservare l'identificativo di faccia nei nuovi triangoli
- in Trimesh aggiunta funzione Repair e migliorata SimplifyFacets
- in Trimesh al termine di CutWithOtherSurf si cerca di regolarizzare il risultato.
2022-01-07 10:00:19 +01:00
DarioS 41d76f0c3f EgtGeomKernel 2.4a1 :
- migliorie alle booleane delle superfici trimesh.
2022-01-04 08:03:15 +01:00
DarioS d2b77833fd EgtGeomKernel 2.3l3 :
- altre modifiche per triangolazioni.
2021-12-23 15:44:49 +01:00
LorenzoM 9ac1a56535 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2021-12-23 09:23:38 +01:00
LorenzoM 9aca1f1e25 Migliorie trimesh 2021-12-23 09:22:25 +01:00
DarioS e3c10e9bd3 EgtGeomKernel 2.3l2 :
- aggiunta triangolazione mediante earcut di mapbox
- piccola modifica a calcoli preliminari per triangolazione standard.
2021-12-18 22:50:02 +01:00
LorenzoM e84a34917a Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2021-12-07 10:04:33 +01:00
LorenzoM 009328b31b Migliorie operazioni booleane e intersezione triangoli 2021-12-07 09:43:59 +01:00
DarioS ca83aaa249 EgtGeomKernel 2.3l1 :
- in IntersTriaTria aggiunto riconoscimento triangoli coincidenti
- in IntersTriaTria aggiunta distinzione tra intersezione sovrapposta equiversa e controversa.
2021-12-06 16:47:36 +01:00
DarioS 6cdfdf6db8 EgtGeomKernel 2.3k6 :
- dopo tagli e tagli generalizzati lunghezza minima per SimplfyFacets portata da 500 a 5000 per evitare problemi di adiacenza non trovata tra facce.
2021-11-25 14:47:03 +01:00
DarioS 6628b1ee24 EgtGeomKernel 2.3k5 :
- correzione in RemoveTriangle di TriMesh (controllo validità indice vertice).
2021-11-22 22:56:13 +01:00
DarioS 2d70d27d85 EgtGeomKernel 2.3k4 :
- piccole modifiche estetiche e cambio versione.
2021-11-14 12:32:28 +01:00
LorenzoM 63d62fcc92 Gestione tagli piccoli 2021-11-10 15:39:33 +01:00
LorenzoM b4303d0e0d Gestione dei triangoli giacenti sui rettangoli 2021-11-09 10:53:32 +01:00
DarioS 9369447886 EgtGeomKernel :
- altre migliorie a GeneralizedCut di SurfTriMesh.
2021-11-07 17:17:54 +01:00
DarioS dca713b240 EgtGeomKernel 2.3k3 :
- modifiche per GeneralizedCut di SurfTriMesh
- Cut e GeneralizedCut di SurfTriMesh spostati in nuovo sorgente SurfTriMeshCuts.cpp.
2021-11-07 12:57:53 +01:00
170 changed files with 23582 additions and 8240 deletions
+113 -25
View File
@@ -15,15 +15,30 @@
#include "stdafx.h" #include "stdafx.h"
#include "GeoConst.h" #include "GeoConst.h"
#include "CurveComposite.h" #include "CurveComposite.h"
#include "RemoveCurveSpikes.h" #include "RemoveCurveDefects.h"
#include "AdjustLoops.h" #include "AdjustLoops.h"
#include "/EgtDev/Include/EGkIntersCurves.h" #include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkIntervals.h" #include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <algorithm> #include <algorithm>
using namespace std ; 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 static bool
MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst) MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
@@ -74,39 +89,96 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
Intervals inOk( EPS_PARAM) ; Intervals inOk( EPS_PARAM) ;
inOk.Set( dStart, dEnd) ; inOk.Set( dStart, dEnd) ;
// Tolgo le parti da eliminare // recupero tutte le info delle autointersezioni
IntCrvCrvInfo iccInfo ; 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 // se con sovrapposizione
if ( iccInfo.bOverlap) { if ( vIccInfo[i].bOverlap) {
// se solo touch // se solo touch
if ( ( iccInfo.IciA[0].nPrevTy == iccInfo.IciA[1].nNextTy || if ( ( vIccInfo[i].IciA[0].nPrevTy == vIccInfo[i].IciA[1].nNextTy ||
iccInfo.IciA[0].nPrevTy == ICCT_SPK || iccInfo.IciA[1].nNextTy == ICCT_SPK) && vIccInfo[i].IciA[0].nPrevTy == ICCT_SPK || vIccInfo[i].IciA[1].nNextTy == ICCT_SPK) &&
iccInfo.IciA[0].nPrevTy != ICCT_NULL && iccInfo.IciA[1].nNextTy != ICCT_NULL) { vIccInfo[i].IciA[0].nPrevTy != ICCT_NULL && vIccInfo[i].IciA[1].nNextTy != ICCT_NULL) {
// obbligatoriamente controversi, elimino entrambi i tratti // obbligatoriamente controversi, elimino entrambi i tratti
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciA[1].dU) ; inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciA[1].dU) ;
inOk.Subtract( iccInfo.IciB[0].dU, iccInfo.IciB[1].dU) ; inOk.Subtract( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciB[1].dU) ;
} }
// altrimenti attraversamento // altrimenti attraversamento
else { else {
// elimino la parte interna // elimino la parte interna
if ( iccInfo.bCBOverEq) if ( vIccInfo[i].bCBOverEq)
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciB[0].dU) ; inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciB[0].dU) ;
else 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 // altrimenti
else { else {
// se solo touch // se solo touch
if ( iccInfo.IciA[0].nPrevTy == iccInfo.IciA[0].nNextTy && if ( vIccInfo[i].IciA[0].nPrevTy == vIccInfo[i].IciA[0].nNextTy &&
iccInfo.IciA[0].nPrevTy != ICCT_NULL && iccInfo.IciA[0].nNextTy != ICCT_NULL) { vIccInfo[i].IciA[0].nPrevTy != ICCT_NULL && vIccInfo[i].IciA[0].nNextTy != ICCT_NULL) {
inOk.Subtract( iccInfo.IciA[0].dU, iccInfo.IciA[0].dU) ; inOk.Subtract( vIccInfo[i].IciA[0].dU, vIccInfo[i].IciA[0].dU) ;
inOk.Subtract( iccInfo.IciB[0].dU, iccInfo.IciB[0].dU) ; inOk.Subtract( vIccInfo[i].IciB[0].dU, vIccInfo[i].IciB[0].dU) ;
} }
// altrimenti attraversamento // altrimenti attraversamento
else { 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 ;
}
} }
} }
} }
@@ -179,14 +251,14 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
Point3d ptEnd2 ; pCrvCo2->GetEndPoint( ptEnd2) ; Point3d ptEnd2 ; pCrvCo2->GetEndPoint( ptEnd2) ;
// se aperta, verifico se concatenabile alla principale // se aperta, verifico se concatenabile alla principale
if ( ! AreSamePointEpsilon( ptStart2, ptEnd2, 10 * EPS_SMALL)) { if ( ! AreSamePointEpsilon( ptStart2, ptEnd2, 10 * EPS_SMALL)) {
if ( AreSamePointEpsilon( ptEnd, ptStart2, 10 * EPS_SMALL)) { if ( AreSamePointEpsilon( ptEnd, ptStart2, 100 * EPS_SMALL)) {
pCrvCo->AddCurve( pCrvCo2, true, 10 * EPS_SMALL) ; pCrvCo->AddCurve( pCrvCo2, true, 100 * EPS_SMALL) ;
CrvLst.erase( iIter2) ; CrvLst.erase( iIter2) ;
ptEnd = ptEnd2 ; ptEnd = ptEnd2 ;
iIter2 = next( iIter) ; iIter2 = next( iIter) ;
} }
else if ( AreSamePointEpsilon( ptEnd2, ptStart, 10 * EPS_SMALL)) { else if ( AreSamePointEpsilon( ptEnd2, ptStart, 100 * EPS_SMALL)) {
pCrvCo->AddCurve( pCrvCo2, false, 10 * EPS_SMALL) ; pCrvCo->AddCurve( pCrvCo2, false, 100 * EPS_SMALL) ;
CrvLst.erase( iIter2) ; CrvLst.erase( iIter2) ;
ptStart = ptStart2 ; ptStart = ptStart2 ;
iIter2 = next( iIter) ; iIter2 = next( iIter) ;
@@ -201,6 +273,22 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
++ iIter ; ++ 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 // riporto le curve nel riferimento originale
if ( bNeedRef) { if ( bNeedRef) {
for ( auto pCrv : CrvLst) for ( auto pCrv : CrvLst)
@@ -215,7 +303,7 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst) AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst, bool bNeedSameProp)
{ {
// elimino eventuali sovrapposizioni e accostamenti // elimino eventuali sovrapposizioni e accostamenti
if ( ! MyAdjustLoops( pCurve, CrvLst)) if ( ! MyAdjustLoops( pCurve, CrvLst))
@@ -225,10 +313,10 @@ AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
// se curva composita // se curva composita
CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ; CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ;
if ( pCrvCo != nullptr) { if ( pCrvCo != nullptr) {
// elimino eventuali Spikes e Small Z
pCrvCo->RemoveSmallDefects( 2 * LIN_TOL_MIN, ANG_TOL_STD_DEG, true) ;
// unisco eventuali tratti allineati // unisco eventuali tratti allineati
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ; pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, bNeedSameProp) ;
// elimino eventuali spikes
RemoveCurveSpikes( pCrvCo) ;
} }
} }
+1 -1
View File
@@ -17,4 +17,4 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst) ; bool AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst, bool bNeedSameProp) ;
+54
View File
@@ -63,3 +63,57 @@ AngleInSpan( double dAngDeg, double dAngRefDeg, double dAngSpanDeg)
dAngDiffDeg < dHalfAngSpanDeg + EPS_ANG_SMALL) ; 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) ;
}
+5 -5
View File
@@ -17,10 +17,10 @@
#include "CurveComposite.h" #include "CurveComposite.h"
#include "CreateCurveAux.h" #include "CreateCurveAux.h"
#include "GeoConst.h" #include "GeoConst.h"
#include "/EgtDev/Include/EgkArcCenTgCurvePnt.h" #include "/EgtDev/Include/EGkArcCenTgCurvePnt.h"
#include "/EgtDev/Include/EgkArcSpecial.h" #include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EgkCircleCenTgCurve.h" #include "/EgtDev/Include/EGkCircleCenTgCurve.h"
#include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
@@ -168,7 +168,7 @@ CurveArc* GetArcCenTgCompoPnt( const Point3d& ptCen, const CurveComposite& crvCo
double dSqDist = SqDist( ptNearStart, ptTg) ; double dSqDist = SqDist( ptNearStart, ptTg) ;
if ( dSqDist < dMinSqDist) { if ( dSqDist < dMinSqDist) {
dMinSqDist = dSqDist ; dMinSqDist = dSqDist ;
pCrvArc.Set( Release( pCrvAtmp)) ; pCrvArc.Set( pCrvAtmp) ;
if ( pPtTg != nullptr) if ( pPtTg != nullptr)
*pPtTg = ptTg ; *pPtTg = ptTg ;
} }
+8 -8
View File
@@ -18,9 +18,9 @@
#include "CreateCurveAux.h" #include "CreateCurveAux.h"
#include "DistPointLine.h" #include "DistPointLine.h"
#include "GeoConst.h" #include "GeoConst.h"
#include "/EgtDev/Include/EgkArcPntDirTgCurve.h" #include "/EgtDev/Include/EGkArcPntDirTgCurve.h"
#include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgkArcSpecial.h" #include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
@@ -204,7 +204,7 @@ GetArcPntDirTgArc( const Point3d& ptP, const Vector3d& vtDir, const CurveArc& cr
if ( bOk1) { if ( bOk1) {
double dOffset = ( bOutSide ? crvArcL.GetRadius() : - crvArcL.GetRadius()) ; double dOffset = ( bOutSide ? crvArcL.GetRadius() : - crvArcL.GetRadius()) ;
if ( pCrv1->GetType() == CRV_ARC) if ( pCrv1->GetType() == CRV_ARC)
bOk1 = (dynamic_cast<CurveArc*>(Get(pCrv1)))->ExtendedOffset( dOffset) ; bOk1 = (static_cast<CurveArc*>( Get( pCrv1)))->ExtendedOffset( dOffset) ;
else else
bOk1 = pCrv1->SimpleOffset( dOffset) ; bOk1 = pCrv1->SimpleOffset( dOffset) ;
} }
@@ -235,7 +235,7 @@ GetArcPntDirTgArc( const Point3d& ptP, const Vector3d& vtDir, const CurveArc& cr
if ( bOk2) { if ( bOk2) {
double dOffset = ( bOutSide ? - crvArcL.GetRadius() : crvArcL.GetRadius()) ; double dOffset = ( bOutSide ? - crvArcL.GetRadius() : crvArcL.GetRadius()) ;
if ( pCrv2->GetType() == CRV_ARC) if ( pCrv2->GetType() == CRV_ARC)
bOk2 = (dynamic_cast<CurveArc*>(Get(pCrv2)))->ExtendedOffset( dOffset) ; bOk2 = (static_cast<CurveArc*>( Get( pCrv2)))->ExtendedOffset( dOffset) ;
else else
bOk2 = pCrv2->SimpleOffset( dOffset) ; bOk2 = pCrv2->SimpleOffset( dOffset) ;
} }
@@ -297,7 +297,7 @@ GetArcPntDirTgBezier( const Point3d& ptP, const Vector3d& vtDir, const CurveBezi
return nullptr ; return nullptr ;
// calcolo la circonferenza tangente a questa approssimazione // calcolo la circonferenza tangente a questa approssimazione
Point3d ptTg ; 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)) if ( IsNull( pCrv))
return nullptr ; return nullptr ;
// porto il punto di tangenza della circonferenza esattamente sulla curva di Bezier // 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()) { pCrv = crvCompo.GetNextCurve()) {
// recupero la circonferenza tangente alla curva elementare // recupero la circonferenza tangente alla curva elementare
Point3d ptTg ; 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)) if ( IsNull( pCrvTmp))
continue ; continue ;
// verifico se è la più vicina al punto desiderato // verifico se è la più vicina al punto desiderato
double dSqDist = SqDist( ptNear, ptTg) ; double dSqDist = SqDist( ptNear, ptTg) ;
if ( dSqDist < dMinSqDist) { if ( dSqDist < dMinSqDist) {
dMinSqDist = dSqDist ; dMinSqDist = dSqDist ;
pCrvNew.Set( Release( pCrvTmp)) ; pCrvNew.Set( pCrvTmp) ;
if ( pPtTg != nullptr) if ( pPtTg != nullptr)
*pPtTg = ptTg ; *pPtTg = ptTg ;
} }
+86 -36
View File
@@ -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. // Contenuto : Implementazione funzioni per calcoli speciali archi.
// //
// //
@@ -14,13 +14,12 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "CreateCurveAux.h" #include "CreateCurveAux.h"
#include "/EgtDev/Include/EgkCurveLine.h" #include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EgkArcSpecial.h" #include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Come la CurveArc::Set2PD, ma se raggio infinito restituisce una retta // 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) GetArc2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStartDeg)
{ {
// creo l'oggetto arco // creo l'oggetto arco
ICurveArc* pArc = CreateCurveArc() ; PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
if ( pArc == nullptr) if ( IsNull( pArc))
return nullptr ; return nullptr ;
// inizializzo il puntatore a curva con l'arco
PtrOwner<ICurve> pCrv( pArc) ;
// calcolo l'arco, se ok lo restituisco ed esco // calcolo l'arco, se ok lo restituisco ed esco
if ( pArc->Set2PD( ptStart, ptEnd, dDirStartDeg)) if ( pArc->Set2PD( ptStart, ptEnd, dDirStartDeg))
return Release( pCrv) ; return Release( pArc) ;
// calcolo arco non riuscito, verifico se retta va bene // calcolo arco non riuscito, verifico se retta va bene
Vector3d vtDiff = ptEnd - ptStart ; 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 // 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) { if ( abs( CrossXY( vtDiff, vtDir)) < EPS_SMALL && ScalarXY( vtDiff, vtDir) > EPS_SMALL) {
// creo l'oggetto retta // creo l'oggetto retta
ICurveLine* pLine = CreateCurveLine() ; PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
if ( pLine == nullptr) if ( IsNull( pLine))
return nullptr ; return nullptr ;
// inizializzo il puntatore a curva con la retta
pCrv.Set( pLine) ;
// calcolo retta, se ok la restituisco ed esco // calcolo retta, se ok la restituisco ed esco
if ( pLine->Set( ptStart, ptEnd)) if ( pLine->Set( ptStart, ptEnd))
return Release( pCrv) ; return Release( pLine) ;
} }
return nullptr ; return nullptr ;
@@ -65,34 +60,59 @@ ICurve*
GetArc2PVN( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDirS, const Vector3d& vtN) GetArc2PVN( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDirS, const Vector3d& vtN)
{ {
// creo l'oggetto arco // creo l'oggetto arco
ICurveArc* pArc = CreateCurveArc() ; PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
if ( pArc == nullptr) if ( IsNull( pArc))
return nullptr ; return nullptr ;
// inizializzo il puntatore a curva con l'arco
PtrOwner<ICurve> pCrv( pArc) ;
// calcolo l'arco, se ok lo restituisco ed esco // calcolo l'arco, se ok lo restituisco ed esco
if ( pArc->Set2PVN( ptStart, ptEnd, vtDirS, vtN)) if ( pArc->Set2PVN( ptStart, ptEnd, vtDirS, vtN))
return Release( pCrv) ; return Release( pArc) ;
// calcolo arco non riuscito, verifico se retta va bene // calcolo arco non riuscito, verifico se retta va bene
Vector3d vtDiff = ptEnd - ptStart ; Vector3d vtDiff = ptEnd - ptStart ;
// verifico se i punti sono allineati con la direzione e nel giusto verso nel piano perpendicolare a vtN // 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) { if ( abs( ( vtDiff ^ vtDirS) * vtN) < EPS_SMALL && vtDiff * vtDirS > EPS_SMALL) {
// creo l'oggetto retta // creo l'oggetto retta
ICurveLine* pLine = CreateCurveLine() ; PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
if ( pLine == nullptr) if ( IsNull( pLine))
return nullptr ; return nullptr ;
// inizializzo il puntatore a curva con la retta
pCrv.Set( pLine) ;
// calcolo retta, se ok la restituisco ed esco // calcolo retta, se ok la restituisco ed esco
if ( pLine->Set( ptStart, ptEnd)) if ( pLine->Set( ptStart, ptEnd))
return Release( pCrv) ; return Release( pLine) ;
} }
return nullptr ; 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 // 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) GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd, bool bCirc)
{ {
// creo l'oggetto arco // creo l'oggetto arco
ICurveArc* pArc = CreateCurveArc() ; PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
if ( pArc == nullptr) if ( IsNull( pArc))
return nullptr ; return nullptr ;
// inizializzo il puntatore a curva con l'arco
PtrOwner<ICurve> pCrv( pArc) ;
// calcolo l'arco, se ok lo restituisco ed esco // calcolo l'arco, se ok lo restituisco ed esco
if ( pArc->Set3P( ptStart, ptOther, ptEnd, bCirc)) 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) if ( bCirc)
return nullptr ; 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 // verifico se i punti sono allineati nel giusto verso
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO) { if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO) {
// creo l'oggetto retta // creo l'oggetto retta
ICurveLine* pLine = CreateCurveLine() ; PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
if ( pLine == nullptr) if ( IsNull( pLine))
return nullptr ; return nullptr ;
// inizializzo il puntatore a curva con la retta
pCrv.Set( pLine) ;
// calcolo retta, se ok la restituisco ed esco // calcolo retta, se ok la restituisco ed esco
if ( pLine->Set( ptStart, ptEnd)) if ( pLine->Set( ptStart, ptEnd))
return Release( pCrv) ; return Release( pLine) ;
} }
return nullptr ; 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
View File
@@ -18,7 +18,7 @@
#include "NgeReader.h" #include "NgeReader.h"
#include "GeomDB.h" #include "GeomDB.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgnStringKeyVal.h" #include "/EgtDev/Include/EGnStringKeyVal.h"
using namespace std ; using namespace std ;
@@ -81,8 +81,7 @@ Attribs::Dump( const GeomDB& GDB, string& sOut, bool bMM, const char* szNewLine)
} }
sOut += szNewLine ; sOut += szNewLine ;
// eventuali nome e stringhe informative // eventuali nome e stringhe informative
STRLIST::const_iterator iIter ; for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter)
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter)
sOut += *iIter + szNewLine ; sOut += *iIter + szNewLine ;
return true ; return true ;
@@ -101,7 +100,7 @@ Attribs::Save( NgeWriter& ngeOut) const
// modo // modo
if ( ! ngeOut.WriteUchar( m_Data[MODE], ",")) if ( ! ngeOut.WriteUchar( m_Data[MODE], ","))
return false ; 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]) ; int nStat = (( m_Data[STATUS] > GDB_ST_ON) ? GDB_ST_ON : m_Data[STATUS]) ;
if ( ! ngeOut.WriteUchar( nStat, ",")) if ( ! ngeOut.WriteUchar( nStat, ","))
return false ; return false ;
@@ -118,8 +117,7 @@ Attribs::Save( NgeWriter& ngeOut) const
if ( ! ngeOut.WriteInt( int( m_slInfo.size()), ";", true)) if ( ! ngeOut.WriteInt( int( m_slInfo.size()), ";", true))
return false ; return false ;
// stringhe di info // stringhe di info
STRLIST::const_iterator iIter ; for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter) {
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
if ( ! ngeOut.WriteString( *iIter, nullptr, true)) if ( ! ngeOut.WriteString( *iIter, nullptr, true))
return false ; return false ;
} }
@@ -141,7 +139,7 @@ Attribs::Load( NgeReader& ngeIn)
if ( ! ngeIn.ReadUchar( ucMode, ",")) if ( ! ngeIn.ReadUchar( ucMode, ","))
return false ; return false ;
m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ; 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 ; unsigned char ucStat ;
if ( ! ngeIn.ReadUchar( ucStat, ",")) if ( ! ngeIn.ReadUchar( ucStat, ","))
return false ; return false ;
@@ -177,7 +175,7 @@ Attribs::Load( NgeReader& ngeIn)
bool bool
Attribs::DataFromString( const string& sParam) Attribs::DataFromString( const string& sParam)
{ {
// il primo parametro è diviso in 4 parti // il primo parametro è diviso in 4 parti
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ; Tokenize( sParam, ",", vsParams) ;
// 4 parti // 4 parti
@@ -212,13 +210,12 @@ bool
Attribs::SetName( const string& sName) Attribs::SetName( const string& sName)
{ {
// se nome non valido, esco con errore // se nome non valido, esco con errore
if ( ! IsValidVal( sName)) if ( sName.empty() || ! IsValidVal( sName))
return false ; return false ;
// può essere solo la prima stringa // può essere solo la prima stringa
STRLIST::iterator iIter ; auto iIter = m_slInfo.begin() ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && if ( iIter != m_slInfo.end() && FindKey( *iIter, NAME)) {
FindKey( *iIter, NAME)) {
*iIter = NAME + EQUAL + sName ; *iIter = NAME + EQUAL + sName ;
return true ; return true ;
} }
@@ -237,10 +234,9 @@ Attribs::SetName( const string& sName)
bool bool
Attribs::GetName( string& sName) const Attribs::GetName( string& sName) const
{ {
// può essere solo la prima stringa // può essere solo la prima stringa
STRLIST::const_iterator iIter ; const auto iIter = m_slInfo.cbegin() ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
FindKey( *iIter, NAME)) {
sName = iIter->substr( NAME.length() + 1) ; sName = iIter->substr( NAME.length() + 1) ;
return true ; return true ;
} }
@@ -252,23 +248,18 @@ Attribs::GetName( string& sName) const
bool bool
Attribs::ExistsName( void) const Attribs::ExistsName( void) const
{ {
// può essere solo la prima stringa // può essere solo la prima stringa
STRLIST::const_iterator iIter ; const auto iIter = m_slInfo.cbegin() ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && return ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) ;
FindKey( *iIter, NAME))
return true ;
return false ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Attribs::RemoveName( void) Attribs::RemoveName( void)
{ {
// può essere solo la prima stringa // può essere solo la prima stringa
STRLIST::const_iterator iIter ; const auto iIter = m_slInfo.cbegin() ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
FindKey( *iIter, NAME)) {
m_slInfo.pop_front() ; m_slInfo.pop_front() ;
return true ; return true ;
} }
@@ -282,14 +273,14 @@ bool
Attribs::SetInfo( const string& sKey, const string& sVal) Attribs::SetInfo( const string& sKey, const string& sVal)
{ {
// se chiave o valore non validi, esco con errore // se chiave o valore non validi, esco con errore
if ( ! IsValidKey( sKey) || ! IsValidVal( sVal)) if ( ! IsValidKey( sKey) || sVal.empty() || ! IsValidVal( sVal))
return false ; return false ;
// se è il nome // se è il nome
if ( sKey == NAME) if ( sKey == NAME)
return SetName( sVal) ; 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) { for ( auto iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
if ( FindKey( *iIter, sKey)) { if ( FindKey( *iIter, sKey)) {
*iIter = sKey + EQUAL + sVal ; *iIter = sKey + EQUAL + sVal ;
@@ -356,6 +347,27 @@ Attribs::RemoveInfo( const string& sKey)
return true ; 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 bool
Attribs::CopyAllInfoFrom( const Attribs& attrSou) Attribs::CopyAllInfoFrom( const Attribs& attrSou)
+4 -3
View File
@@ -89,6 +89,7 @@ class Attribs
bool GetInfo( const std::string& sKey, std::string& sVal) const ; bool GetInfo( const std::string& sKey, std::string& sVal) const ;
bool ExistsInfo( const std::string& sKey) const ; bool ExistsInfo( const std::string& sKey) const ;
bool RemoveInfo( const std::string& sKey) ; bool RemoveInfo( const std::string& sKey) ;
bool GetAllInfo( STRVECTOR& vsInfo) const ;
bool CopyAllInfoFrom( const Attribs& attrSou) ; bool CopyAllInfoFrom( const Attribs& attrSou) ;
private : private :
@@ -100,7 +101,7 @@ class Attribs
private : private :
unsigned char m_Data[DIM] ; unsigned char m_Data[DIM] ;
unsigned char m_OldData[DIM] ; unsigned char m_OldData[DIM] ;
int m_Material ; int m_Material ;
Color m_Color ; Color m_Color ;
STRLIST m_slInfo ; STRLIST m_slInfo ;
} ; } ;
+132 -32
View File
@@ -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. // Contenuto : Implementazione della classe axis aligned bounding box BBox3d.
// //
// //
@@ -53,7 +53,8 @@ BBox3d::Set( double dX1, double dY1, double dZ1, double dX2, double dY2, double
bool bool
BBox3d::IsValid( void) const 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.y < ( m_ptMax.y + EPS_SMALL) &&
m_ptMin.z < ( m_ptMax.z + 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 ; 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 bool
BBox3d::GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const BBox3d::GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const
@@ -420,69 +448,141 @@ BBox3d::EnclosesXY( const BBox3d& b3Box) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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 ; 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 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 false ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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 ; 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 false ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool inline bool
BBox3d::FindIntersection( const BBox3d& b3B, BBox3d& b3Int) const 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 ; return false ;
// verifico direttamente la sovrapposizione // 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 ; 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 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 false ;
// calcolo il box intersezione // 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.x = (( m_ptMin.x >= b3Box.m_ptMin.x) ? m_ptMin.x : b3Box.m_ptMin.x) ;
b3Int.m_ptMin.y = (( m_ptMin.y >= b3B.m_ptMin.y) ? m_ptMin.y : b3B.m_ptMin.y) ; 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 >= b3B.m_ptMin.z) ? m_ptMin.z : b3B.m_ptMin.z) ; 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 <= b3B.m_ptMax.x) ? m_ptMax.x : b3B.m_ptMax.x) ; 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 <= b3B.m_ptMax.y) ? m_ptMax.y : b3B.m_ptMax.y) ; 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 <= b3B.m_ptMax.z) ? m_ptMax.z : b3B.m_ptMax.z) ; b3Int.m_ptMax.z = (( m_ptMax.z <= b3Box.m_ptMax.z) ? m_ptMax.z : b3Box.m_ptMax.z) ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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 ; return false ;
// verifico direttamente la sovrapposizione // 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 ; 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 false ;
// calcolo il box intersezione // 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.x = (( m_ptMin.x >= b3Box.m_ptMin.x) ? m_ptMin.x : b3Box.m_ptMin.x) ;
b3Int.m_ptMin.y = (( m_ptMin.y >= b3B.m_ptMin.y) ? m_ptMin.y : b3B.m_ptMin.y) ; 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 + b3B.m_ptMin.z) ; b3Int.m_ptMin.z = 0.5 * ( m_ptMin.z + b3Box.m_ptMin.z) ;
b3Int.m_ptMax.x = (( m_ptMax.x <= b3B.m_ptMax.x) ? m_ptMax.x : b3B.m_ptMax.x) ; 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 <= b3B.m_ptMax.y) ? m_ptMax.y : b3B.m_ptMax.y) ; 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 + b3B.m_ptMax.z) ; b3Int.m_ptMax.z = 0.5 * ( m_ptMax.z + b3Box.m_ptMax.z) ;
return true ; return true ;
} }
+30 -18
View File
@@ -14,12 +14,13 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "BiArcs.h" #include "BiArcs.h"
#include "CurveLine.h"
#include "CurveArc.h" #include "CurveArc.h"
#include "CurveComposite.h"
#include "/EgtDev/Include/EGkAngle.h" #include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EgkCurveLine.h" #include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkArcSpecial.h"
#include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; using namespace std ;
@@ -49,7 +50,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
return nullptr ; return nullptr ;
// preparo la curva composita per i biarchi // preparo la curva composita per i biarchi
PtrOwner<ICurveComposite> pBiArc( CreateCurveComposite()) ; PtrOwner<CurveComposite> pBiArc( CreateBasicCurveComposite()) ;
if ( IsNull( pBiArc)) if ( IsNull( pBiArc))
return nullptr ; 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)) ; pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, 0.5)) ;
} }
else { else {
CurveArc* pArc = GetBasicCurveArc( pJCrv) ; const CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
if ( pArc == nullptr) if ( pArc == nullptr)
return nullptr ; return nullptr ;
double dU = - 1 ; double dU = -1 ;
double dRad = pArc->GetRadius() ; double dRad = pArc->GetRadius() ;
double dSqRad = dRad * dRad ; double dSqRad = dRad * dRad ;
Point3d ptCen = pArc->GetCenter() ; 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 // non c'è intersezione, assegno valore medio
if ( dU < 0.1 || dU > 0.9) if ( dU < -0.5)
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)) ; 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 ; return nullptr ;
// determino la massima distanza tra la curva e il biarco // determino la massima distanza tra la curva e il biarco
Point3d ptP ;
double dSqDist = 0 ; double dSqDist = 0 ;
for ( bool bPnt = PL.GetFirstPoint( ptP) ; const double STEP = 10 ;
bPnt ; Point3d ptCurr ;
bPnt = PL.GetNextPoint( ptP)) { bool bPnt = PL.GetFirstPoint( ptCurr) ;
DistPointCurve dstPC( ptP, *pBiArc) ; Point3d ptPrev = ptCurr ;
double dSqDistPC ; while ( bPnt) {
if ( dstPC.GetSqDist( dSqDistPC) && dSqDistPC > dSqDist) double dLen = Dist( ptCurr, ptPrev) ;
dSqDist = dSqDistPC ; 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) ; 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 // se rotazione nulla, allora segmento di retta tra i due punti
if ( abs( dAngDeg) < EPS_ANG_SMALL) { if ( abs( dAngDeg) < EPS_ANG_SMALL) {
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ; PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
if ( IsNull( pLine) || ! pLine->Set( ptP0, ptP1)) if ( IsNull( pLine) || ! pLine->Set( ptP0, ptP1))
return nullptr ; return nullptr ;
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1 // 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 ; Vector3d vtStart = ptP0 - ptCen ;
double dRad, dAngStart ; double dRad, dAngStart ;
vtStart.ToSpherical( &dRad, nullptr, &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))) if ( IsNull( pArc) || ! pArc->SetXY( ptCen, dRad, dAngStart, dAngDeg, ( ptP1.z - ptP0.z)))
return nullptr ; return nullptr ;
double dDirStartDeg = dAngStart + ( dAngDeg > 0 ? ANG_RIGHT : - ANG_RIGHT) ; double dDirStartDeg = dAngStart + ( dAngDeg > 0 ? ANG_RIGHT : - ANG_RIGHT) ;
+1 -1
View File
@@ -13,7 +13,7 @@
#pragma once #pragma once
#include "/EgtDev/Include/EgkBiArcs.h" #include "/EgtDev/Include/EGkBiArcs.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg, ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
+5 -5
View File
@@ -1,8 +1,8 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2018-2018 // EgalTech 2018-2018
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : CAToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2 // File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
// Contenuto : Implementazione della classe CAToolSurfTm. // Contenuto : Implementazione della classe CAvToolSurfTm.
// //
// //
// //
@@ -301,11 +301,11 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir)
Vector3d vtDirL = vtDir ; vtDirL.ToLoc( m_frMove) ; Vector3d vtDirL = vtDir ; vtDirL.ToLoc( m_frMove) ;
b3Tool.Add( ptTL) ; b3Tool.Add( ptTL) ;
b3Tool.Add( ptTL - vtDirL * m_Tool.GetHeigth()) ; b3Tool.Add( ptTL - vtDirL * m_Tool.GetHeigth()) ;
if ( vtDirL.IsXplus() || vtDirL.IsXminus()) if ( vtDirL.IsX())
b3Tool.Expand( 0, m_Tool.GetRadius(), m_Tool.GetRadius()) ; 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()) ; 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) ; b3Tool.Expand( m_Tool.GetRadius(), m_Tool.GetRadius(), 0) ;
else { else {
double dExpandX = m_Tool.GetRadius() * sqrt( 1 - vtDirL.x * vtDirL.x) ; double dExpandX = m_Tool.GetRadius() * sqrt( 1 - vtDirL.x * vtDirL.x) ;
+12 -10
View File
@@ -146,18 +146,20 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
const Triangle3d& trTria, const Vector3d& vtMove) const Triangle3d& trTria, const Vector3d& vtMove)
{ {
// Non ha senso che il movimento sia in direzione "opposta" a quella dell'asse utensile // 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. ; return -1. ;
// Se avvicinamento non devo fare nulla // Se avvicinamento non devo fare nulla
if ( vtMove * trTria.GetN() < - EPS_ZERO) 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 // se utensile cilindrico
if ( tlTool.GetType() == Tool::CYLMILL) { if ( tlTool.GetType() == Tool::CYLMILL) {
// parametri geometrici // parametri geometrici
double dHeigth = tlTool.GetHeigth() ; double dHeigth = tlTool.GetHeigth() ;
double dRadius = tlTool.GetRadius() ; double dRadius = tlTool.GetRadius() ;
// prima determino l'allontanamento del disco inferiore // 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) if ( dDist < - EPS_SMALL)
return dDist ; return dDist ;
// poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il disco) // 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) if ( dDist2 < - EPS_SMALL)
return dDist2 ; return dDist2 ;
// verifico quello del disco sopra // 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) if ( dDist3 < - EPS_SMALL)
return dDist3 ; return dDist3 ;
return ( dDist + dDist2 + dDist3) ; return ( dDist + dDist2 + dDist3) ;
@@ -189,7 +191,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
return dDist2 ; return dDist2 ;
// verifico quello del disco sopra // verifico quello del disco sopra
Point3d ptDiskUpOrig = ptCylOrig + dDist2 * vtMove ; 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) if ( dDist3 < - EPS_SMALL)
return dDist3 ; return dDist3 ;
return ( dDist + dDist2 + dDist3) ; return ( dDist + dDist2 + dDist3) ;
@@ -199,7 +201,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
// parametri geometrici // parametri geometrici
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ; double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
// prima determino l'allontanamento del disco inferiore // 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) ; trTria, vtMove) ;
if ( dDist < - EPS_SMALL) if ( dDist < - EPS_SMALL)
return dDist ; return dDist ;
@@ -220,7 +222,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
return dDist3 ; return dDist3 ;
// verifico quello del disco sopra // verifico quello del disco sopra
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ; 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) if ( dDist4 < - EPS_SMALL)
return dDist4 ; return dDist4 ;
return ( dDist + dDist2 + dDist3 + 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 dMaxR = max( tlTool.GetRadius(), tlTool.GetTipRadius()) ;
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ; double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
// prima determino l'allontanamento del disco inferiore // 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) ; trTria, vtMove) ;
if ( dDist < - EPS_SMALL) if ( dDist < - EPS_SMALL)
return dDist ; return dDist ;
@@ -266,7 +268,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
return dDist3 ; return dDist3 ;
// verifico quello del disco sopra // verifico quello del disco sopra
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ; 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) if ( dDist4 < - EPS_SMALL)
return dDist4 ; return dDist4 ;
return ( dDist + dDist2 + dDist3 + 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) ; double dRadius = max( ptStart.x, ptEnd.x) ;
// Se disco verso il basso dell'utensile // Se disco verso il basso dell'utensile
if ( ptStart.x > ptEnd.x) 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 // Se disco verso l'alto
else else
dDist2 = CAvDiskTriangle( ptCompOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ; dDist2 = CAvDiskTriangle( ptCompOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
} }
else { else {
// Verifiche curva precedente per eventuale tappo sopra // Verifiche curva precedente per eventuale tappo sopra
+17 -13
View File
@@ -23,16 +23,17 @@ using namespace std ;
bool bool
CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const ISurfTriMesh& Stm) CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const ISurfTriMesh& Stm)
{ {
// recupero BBox del poliedro // Recupero BBox del poliedro
BBox3d b3Poly = Stm.GetAllTriaBox() ; BBox3d b3Poly = Stm.GetAllTriaBox() ;
// calcolo il BBox del parallelepipedo // Calcolo il BBox del parallelepipedo
BBox3d b3Box( ORIG, ORIG + vtDiag) ; BBox3d b3BoxL( ORIG, ORIG + vtDiag) ;
b3Box.Expand( dSafeDist) ; if ( dSafeDist > EPS_SMALL)
b3Box.ToGlob( frBox) ; b3BoxL.Expand( dSafeDist) ;
// confronto i due Box BBox3d b3Box = GetToGlob( b3BoxL, frBox) ;
if ( ! b3Box.Overlaps( b3Poly)) // Se i BBox non interferiscono, non c'è collisione
if ( ! b3Poly.Overlaps( b3Box) || ! b3Poly.Overlaps( frBox, b3BoxL))
return false ; 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 ; INTVECTOR vT ;
Stm.GetAllTriaOverlapBox( b3Box, vT) ; Stm.GetAllTriaOverlapBox( b3Box, vT) ;
for ( int nT : vT) { for ( int nT : vT) {
@@ -45,10 +46,13 @@ CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDi
// Se superficie aperta, non c'è collisione // Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed()) if ( ! Stm.IsClosed())
return false ; return false ;
// Verifico se il box è dentro la superficie tramite calcolo distanza minima. // Se il BBox del parallelepipedo non è interno a quello del poliedro e viceversa, non c'è collisione
Point3d ptBoxOrig, ptBoxMax ; if ( ! b3Poly.Encloses( b3Box) && ! b3Box.Encloses( b3Poly))
b3Box.GetMinMax( ptBoxOrig, ptBoxMax) ; return false ;
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 // Se il box è interno c'è collisione
return DistBoxOrigSurfCalc.IsPointInside() ; return DistBoxCenSurfCalc.IsPointInside() ;
} }
+27 -48
View File
@@ -16,6 +16,7 @@
#include "CDeBoxTria.h" #include "CDeBoxTria.h"
#include "CDeSpheTria.h" #include "CDeSpheTria.h"
#include "CDeCylTria.h" #include "CDeCylTria.h"
#include "CDeCapsTria.h"
#include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGkPlane3d.h"
using namespace std ; using namespace std ;
@@ -99,9 +100,17 @@ CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d
Triangle3d trTriaL = trTria ; Triangle3d trTriaL = trTria ;
trTriaL.ToLoc( frBox) ; trTriaL.ToLoc( frBox) ;
// Calcolo il box locale del triangolo
BBox3d b3TriaL ;
trTriaL.GetLocalBBox( b3TriaL) ;
// Calcolo il box come tale // Calcolo il box come tale
BBox3d b3Box( ORIG, ORIG + vtDiag) ; BBox3d b3Box( ORIG, ORIG + vtDiag) ;
// Se i BBox non interferiscono, non c'è collisione
if ( ! b3Box.Overlaps( b3TriaL))
return false ;
// Compute box center and extents // Compute box center and extents
Point3d ptCen ; Point3d ptCen ;
Vector3d vtExt ; Vector3d vtExt ;
@@ -173,75 +182,45 @@ CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, cons
return CDeSimpleBoxTria( Frame3d(), vtDiag, trTriaL) ; return CDeSimpleBoxTria( Frame3d(), vtDiag, trTriaL) ;
// Verifica preliminare con box esteso // Verifica preliminare con box esteso
Frame3d frEst( Point3d( -dSafeDist, -dSafeDist, -dSafeDist)) ; Frame3d frTmp( Point3d( -dSafeDist, -dSafeDist, -dSafeDist)) ;
if ( ! CDeSimpleBoxTria( frEst, vtDiag + 2 * Vector3d( dSafeDist, dSafeDist, dSafeDist), trTriaL)) if ( ! CDeSimpleBoxTria( frTmp, vtDiag + 2 * Vector3d( dSafeDist, dSafeDist, dSafeDist), trTriaL))
return false ; return false ;
// Tre box aumentati con distanza di sicurezza in un sola dimensione // 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)) if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * X_AX, trTriaL))
return true ; return true ;
frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersY()) ; frTmp.ChangeOrig( Point3d( 0, -dSafeDist, 0)) ;
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Y_AX, trTriaL)) if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Y_AX, trTriaL))
return true ; return true ;
frTmp = frBox ; frTmp.Translate( - dSafeDist * frBox.VersZ()) ; frTmp.ChangeOrig( Point3d( 0, 0, -dSafeDist)) ;
if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Z_AX, trTriaL)) if ( CDeSimpleBoxTria( frTmp, vtDiag + 2 * dSafeDist * Z_AX, trTriaL))
return true ; return true ;
// Sfere centrate negli otto vertici // Capsule centrati sui dodici spigoli
if ( CDeSimpleSpheTria( Point3d( 0, 0, 0), dSafeDist, trTriaL)) if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( vtDiag.x, 0, 0), dSafeDist, trTriaL))
return true ; 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 ; 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 ; 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 ; 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 ; 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 ; 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 ; 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 ; return true ;
if ( CDeSimpleCapsTria( Point3d( 0, 0, 0), Point3d( 0, 0, vtDiag.z), dSafeDist, trTriaL))
// Cilindri centrati sui dodici spigoli
frTmp.Set( Point3d( 0, 0, 0), X_AX) ;
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
return true ; return true ;
frTmp.Set( Point3d( 0, vtDiag.y, 0), X_AX) ; if ( CDeSimpleCapsTria( Point3d( vtDiag.x, 0, 0), Point3d( vtDiag.x, 0, vtDiag.z), dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.x, trTriaL))
return true ; return true ;
frTmp.Set( Point3d( 0, 0, 0), Y_AX) ; if ( CDeSimpleCapsTria( Point3d( vtDiag.x, vtDiag.y, 0), Point3d( vtDiag.x, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frTmp, dSafeDist, vtDiag.y, trTriaL))
return true ; return true ;
frTmp.Set( Point3d( vtDiag.x, 0, 0), Y_AX) ; if ( CDeSimpleCapsTria( Point3d( 0, vtDiag.y, 0), Point3d( 0, vtDiag.y, vtDiag.z), dSafeDist, trTriaL))
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))
return true ; return true ;
return false ; return false ;
+104
View File
@@ -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, double dSafeDist, const Triangle3d& trTria)
{
return CDeSimpleCapsTria( ptP1, ptP2, dR + max( 0., dSafeDist), trTria) ;
}
+19
View File
@@ -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, double dSafeDist, const Triangle3d& trTria) ;
+51 -46
View File
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2020-2020 // EgalTech 2020-2020
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : CDeSurfTmSurfTm.h Data : 13.11.20 Versione : // File : CDeSurfTmSurfTm.h Data : 14.06.23 Versione : 2.5f3
// Contenuto : Implementazione funzione verifica collisione tra // Contenuto : Implementazione funzione verifica collisione tra
// SurfTm e SurfTm. // SurfTm e SurfTm.
// //
@@ -18,8 +18,6 @@
#include "/EgtDev/Include/EGkBBox3d.h" #include "/EgtDev/Include/EGkBBox3d.h"
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
#include "/EgtDev/Include/EGkDistPointSurfTm.h" #include "/EgtDev/Include/EGkDistPointSurfTm.h"
#include <unordered_set>
#include <utility>
using namespace std ; using namespace std ;
@@ -33,63 +31,67 @@ using namespace std ;
// originale traslato di una costante pari alla distanza di sicurezza lungo la // originale traslato di una costante pari alla distanza di sicurezza lungo la
// sua normale. // sua normale.
bool 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. // Recupero le superfici base
if ( ! ( SurfA.IsValid() && SurfB.IsValid()) || ! ( SurfA.IsClosed() && SurfB.IsClosed())) 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 false ; return false ;
// Se i box delle superfici non si intersecano, ho finito. // Se i box delle superfici non si intersecano, ho finito.
BBox3d b3BoxA, b3BoxB ; BBox3d b3BoxA, b3BoxB ;
SurfA.GetLocalBBox( b3BoxA) ; pSrfA->GetLocalBBox( b3BoxA) ;
SurfB.GetLocalBBox( b3BoxB) ; pSrfB->GetLocalBBox( b3BoxB) ;
// Se è necessario, espando il box di una costante additiva pari alla distanza di sicurezza. // Se è necessario, espando il box di B di una costante additiva pari alla distanza di sicurezza.
if ( dSafeDist > EPS_SMALL) if ( dSafeDist > EPS_SMALL)
b3BoxA.Expand( dSafeDist) ; b3BoxB.Expand( dSafeDist) ;
// Se i box non si sovrappongono, non c'è collisione. Ho finito. // Se i box non si sovrappongono, non c'è collisione. Ho finito.
if ( ! b3BoxA.Overlaps( b3BoxB)) if ( ! b3BoxA.Overlaps( b3BoxB))
return false ; 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 ; INTVECTOR vTriaIndex ;
SurfA.GetAllTriaOverlapBox( b3BoxB, vTriaIndex) ; pSrfA->GetAllTriaOverlapBox( b3BoxB, vTriaIndex) ;
// Ciclo sui triangoli della superficie A che cadono nel box della superficie B. // Ciclo sui triangoli della superficie A che interferiscono col box della superficie B.
for ( int nTA : vTriaIndex) { for ( int nTA : vTriaIndex) {
Triangle3d trTriaA ; Triangle3d trTriaA ;
if ( ! ( SurfA.GetTriangle( nTA, trTriaA) && trTriaA.Validate())) if ( ! ( pSrfA->GetTriangle( nTA, trTriaA) && trTriaA.Validate()))
continue ; continue ;
BBox3d b3BoxTriaA ; BBox3d b3BoxTriaA ;
trTriaA.GetLocalBBox( 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) if ( dSafeDist > EPS_SMALL)
b3BoxTriaA.Expand( dSafeDist) ; 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 ; INTVECTOR vNearTria ;
SurfB.GetAllTriaOverlapBox( b3BoxTriaA, vNearTria) ; pSrfB->GetAllTriaOverlapBox( b3BoxTriaA, vNearTria) ;
// Settare tutti i triangoli come già processati. // Settare tutti i triangoli come già processati.
// Al termine della chiamata i TFlags dei triangoli valgono 0. // Al termine della chiamata i TempInt dei triangoli valgono 0.
SurfB.ResetTempInt() ; pSrfB->ResetTempInts() ;
// Ciclo sui triangoli della superficie B che cadono nel box del triangolo corrente della Superficie A. // Ciclo sui triangoli della superficie B che cadono nel box del triangolo corrente della Superficie A.
for ( int nTB : vNearTria) { for ( int nTB : vNearTria) {
// Recupero il triangolo corrente della superficie B. // Recupero il triangolo corrente della superficie B.
// Se triangolo non valido salto al successivo. // Se triangolo non valido salto al successivo.
Triangle3d trTriaB ; Triangle3d trTriaB ;
if ( ! ( SurfB.GetTriangle( nTB, trTriaB) && trTriaB.Validate())) if ( ! ( pSrfB->GetTriangle( nTB, trTriaB) && trTriaB.Validate()))
continue ; continue ;
// Se necessario considero l'offset // Se necessario considero l'offset
if ( dSafeDist > EPS_SMALL) { if ( dSafeDist > EPS_SMALL) {
int nAdjTriaId[3] ; int nAdjTriaId[3] ;
SurfB.GetTriangleAdjacencies( nTB, nAdjTriaId) ; pSrfB->GetTriangleAdjacencies( nTB, nAdjTriaId) ;
// Ciclo sui vertici del triangolo. // Ciclo sui vertici del triangolo.
for ( int nVB = 0 ; nVB < 3 ; ++ nVB) { for ( int nVB = 0 ; nVB < 3 ; ++ nVB) {
// Se il triangolo adiacente al triangolo corrente su questo edge // Se il triangolo adiacente al triangolo corrente su questo edge
// non è stato processato, processo il vertice e l'edge. // non è stato processato, processo il vertice e l'edge.
int nAdjTriaTempFlag ; int nAdjTriaTempFlag ;
if ( ! ( SurfB.GetTriangleTempInt( nAdjTriaId[nVB], nAdjTriaTempFlag) || nAdjTriaTempFlag == 0)) if ( ! ( pSrfB->GetTempInt( nAdjTriaId[nVB], nAdjTriaTempFlag) || nAdjTriaTempFlag == 0))
continue ; 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)) if ( CDeSimpleSpheTria( trTriaB.GetP( nVB), dSafeDist, trTriaA))
return true ; return true ;
// Processo l'edge: se c'è collisione fra triangolo A e cilindro ho finito. // Processo l'edge: se c'è collisione fra triangolo A e cilindro ho finito.
Vector3d vtEdgeV = trTriaB.GetP( nVB) - trTriaB.GetP( ( nVB + 1) % 3) ; Vector3d vtEdgeV = trTriaB.GetP( ( nVB + 1) % 3) - trTriaB.GetP( nVB) ;
double dEdgeLen = vtEdgeV.Len() ; double dEdgeLen = vtEdgeV.Len() ;
vtEdgeV /= dEdgeLen ; vtEdgeV /= dEdgeLen ;
Frame3d frCyl ; Frame3d frCyl ;
@@ -97,22 +99,25 @@ CDeClosedSurfTmClosedSurfTm( const SurfTriMesh& SurfA, const SurfTriMesh& SurfB,
if ( CDeSimpleCylTria( frCyl, dSafeDist, dEdgeLen, trTriaA)) if ( CDeSimpleCylTria( frCyl, dSafeDist, dEdgeLen, trTriaA))
return true ; return true ;
} }
// Traslo il triangolo // Traslo il triangolo
trTriaB.Translate( dSafeDist * trTriaB.GetN()) ; 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)) if ( CDeTriaTria( trTriaA, trTriaB))
return true ; return true ;
// Segno il triangolo come processato: nTFlag = 1 // Segno il triangolo come processato: nTemp = 1
SurfB.SetTempInt( nTB, 1) ; pSrfB->SetTempInt( nTB, 1) ;
} }
} }
// Non ho trovato collisioni fra triangoli delle superfici. // Non ho trovato collisioni fra triangoli delle superfici.
// La collisione c'è se una superficie è dentro l'altra. // 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 ; Point3d ptPointA, ptPointB ;
SurfA.GetFirstVertex( ptPointA) ; pSrfA->GetFirstVertex( ptPointA) ;
SurfB.GetFirstVertex( ptPointB) ; pSrfB->GetFirstVertex( ptPointB) ;
DistPointSurfTm DistPoinASurfB( ptPointA, SurfB) ; DistPointSurfTm DistPoinASrfB( ptPointA, *pSrfB) ;
DistPointSurfTm DistPoinBSurfA( ptPointB, SurfA) ; DistPointSurfTm DistPoinBSrfA( ptPointB, *pSrfA) ;
return ( DistPoinASurfB.IsPointInside() || DistPoinBSurfA.IsPointInside()) ; return ( DistPoinASrfB.IsPointInside() || DistPoinBSrfA.IsPointInside()) ;
} }
+17 -13
View File
@@ -20,31 +20,32 @@
using namespace std ; using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Il sisitema di riferimento deve avere l'asse di simmetria del cono come asse Z e origine nel centro della base. // 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 epsilon, altrimenti è ignorata ed è ininfluente. // 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 del cono deve essere immerso in quello della superficie.
bool bool
CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight, CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
double dSafeDist, const ISurfTriMesh& Stm) double dSafeDist, const ISurfTriMesh& Stm)
{ {
// 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) if ( max( dBaseRad, dTopRad) < EPS_SMALL || dHeight < EPS_SMALL)
return false ; return false ;
// Recupero BBox della trimesh // Recupero BBox della trimesh
BBox3d b3Surf = Stm.GetAllTriaBox() ; BBox3d b3Surf = Stm.GetAllTriaBox() ;
// Calcolo il BBox del tronco di cono // Calcolo il BBox del tronco di cono
double dMaxRad = max( dBaseRad, dTopRad) ; double dMaxRad = max( dBaseRad, dTopRad) ;
BBox3d b3Cone( - dMaxRad, - dMaxRad, 0, dMaxRad, dMaxRad, dHeight) ; BBox3d b3ConeL( Point3d( -dMaxRad, -dMaxRad, 0),
b3Cone.Expand( dSafeDist) ; Point3d( dMaxRad, dMaxRad, dHeight)) ;
// Porto BBox del cono nel sistema della superficie. if ( dSafeDist > EPS_SMALL)
b3Cone.ToGlob( frCone) ; b3ConeL.Expand( dSafeDist) ;
// Se i BBox non interferiscono, ho finito. BBox3d b3Cone = GetToGlob( b3ConeL, frCone) ;
if ( ! b3Cone.Overlaps( b3Surf)) // Se i BBox non interferiscono, non c'è collisione
if ( ! b3Surf.Overlaps( b3Cone) || ! b3Surf.Overlaps( frCone, b3ConeL))
return false ; return false ;
// Recupero i triangoli che interferiscono con il box del cono // Recupero i triangoli che interferiscono con il box del cono
INTVECTOR vT ; INTVECTOR vT ;
Stm.GetAllTriaOverlapBox( b3Cone, 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) { for ( int nT : vT) {
Triangle3d trTria ; Triangle3d trTria ;
if ( Stm.GetTriangle( nT, trTria)) { if ( Stm.GetTriangle( nT, trTria)) {
@@ -55,10 +56,13 @@ CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopR
// Se superficie aperta, non c'è collisione // Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed()) if ( ! Stm.IsClosed())
return false ; return false ;
// 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. // Verifico se il tronco di cono è dentro la superficie tramite calcolo distanza minima.
Point3d ptConeOrig ; Point3d ptConeCen( 0, 0, dHeight / 2) ;
ptConeOrig.ToGlob( frCone) ; ptConeCen.ToGlob( frCone) ;
DistPointSurfTm DistConeOrigSurfCalc( ptConeOrig, Stm) ; DistPointSurfTm DistConeCenSurfCalc( ptConeCen, Stm) ;
// Se il tronco di cono è interno c'è collisione // Se il tronco di cono è interno c'è collisione
return DistConeOrigSurfCalc.IsPointInside() ; return DistConeCenSurfCalc.IsPointInside() ;
} }
+17 -17
View File
@@ -23,42 +23,42 @@ using namespace std ;
// Il toro è posto nel piano XY del suo riferimento, centrato sull'origine. // 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.
bool bool
CDeConvexTorusClosedSurfTm( const Frame3d& frTorusFrame, double dRad1, double dRad2, CDeConvexTorusClosedSurfTm( const Frame3d& frTorus, double dRad1, double dRad2,
double dSafeDist, const ISurfTriMesh& Stm) double dSafeDist, const ISurfTriMesh& Stm)
{ {
// I raggi devono essere non nulli e la superficie ben definita. // I raggi devono essere non nulli e la superficie ben definita.
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL || ! Stm.IsValid()) if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL || ! Stm.IsValid())
return false ; 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) ;
// Box della superficie // 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 // Se i BBox non interferiscono, non c'è collisione
if ( ! b3ConvTorusBox.Overlaps( b3SurfBox)) if ( ! b3Surf.Overlaps( b3Torus) || ! b3Surf.Overlaps( frTorus, b3TorusL))
return false ; return false ;
// Recupero i triangoli che interferiscono con il box del toro // Recupero i triangoli che interferiscono con il box del toro
INTVECTOR vT ; INTVECTOR vT ;
Stm.GetAllTriaOverlapBox( b3ConvTorusBox, vT) ; Stm.GetAllTriaOverlapBox( b3Torus, vT) ;
// Ciclo sui triangoli recuperati // Verifico se il toro interferisce con i triangoli del poliedro presenti nel suo BBox
for ( int nT : vT) { for ( int nT : vT) {
Triangle3d trTria ; Triangle3d trTria ;
if ( Stm.GetTriangle( nT, trTria)) { if ( Stm.GetTriangle( nT, trTria)) {
if ( CDeConvexTorusTria( frTorusFrame, dRad1, dRad2, CT_TOT, dSafeDist, trTria)) if ( CDeConvexTorusTria( frTorus, dRad1, dRad2, CT_TOT, dSafeDist, trTria))
return true ; return true ;
} }
} }
// Se superficie aperta, non c'è collisione // Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed()) if ( ! Stm.IsClosed())
return false ; return false ;
// Verifico se il toro è dentro la superficie tramite calcolo distanza minima. // Se il BBox del toro non è interno a quello del poliedro e viceversa, non c'è collisione
Point3d ptTorusOrig = frTorusFrame.Orig() ; if ( ! b3Surf.Encloses( b3Torus) && ! b3Torus.Encloses( b3Surf))
return false ;
// Verifico se il toro è dentro la superficie tramite calcolo distanza minima del suo centro
Point3d ptTorusOrig = frTorus.Orig() ;
DistPointSurfTm DistConeOrigSurfCalc( ptTorusOrig, Stm) ; DistPointSurfTm DistConeOrigSurfCalc( ptTorusOrig, Stm) ;
// Se il toro è interno c'è collisione // Se il toro è interno c'è collisione
return ( DistConeOrigSurfCalc.IsPointInside()) ; return ( DistConeOrigSurfCalc.IsPointInside()) ;
+22 -17
View File
@@ -23,38 +23,43 @@ using namespace std ;
bool bool
CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const ISurfTriMesh& Stm) CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const ISurfTriMesh& Stm)
{ {
// recupero BBox del poliedro // Recupero BBox del poliedro
BBox3d b3Poly = Stm.GetAllTriaBox() ; BBox3d b3Poly = Stm.GetAllTriaBox() ;
// sistemazioni cilindro // Sistemazioni cilindro
Frame3d frC = frCyl ; Frame3d frMyCyl = frCyl ;
if ( dH < 0) { if ( dH < 0) {
frC.Translate( dH * frC.VersZ()) ; frMyCyl.Translate( dH * frMyCyl.VersZ()) ;
dH = - dH ; dH = - dH ;
} }
// calcolo il BBox del cilindro // Calcolo il BBox del cilindro
BBox3d b3Cyl( -dR, -dR, 0, dR, dR, dH) ; BBox3d b3CylL( Point3d( -dR, -dR, 0),
b3Cyl.Expand( dSafeDist) ; Point3d( dR, dR, dH)) ;
b3Cyl.ToGlob( frC) ; if ( dSafeDist > EPS_SMALL)
// confronto i due Box b3CylL.Expand( dSafeDist) ;
if ( ! b3Cyl.Overlaps( b3Poly)) BBox3d b3Cyl = GetToGlob( b3CylL, frMyCyl) ;
// Se i BBox non interferiscono, non c'è collisione
if ( ! b3Poly.Overlaps( b3Cyl) || ! b3Poly.Overlaps( frMyCyl, b3CylL))
return false ; 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 ; INTVECTOR vT ;
Stm.GetAllTriaOverlapBox( b3Cyl, vT) ; Stm.GetAllTriaOverlapBox( b3Cyl, vT) ;
for ( int nT : vT) { for ( int nT : vT) {
Triangle3d Tria ; Triangle3d Tria ;
if ( Stm.GetTriangle( nT, Tria)) { if ( Stm.GetTriangle( nT, Tria)) {
if ( CDeCylTria( frC, dR, dH, dSafeDist, Tria)) if ( CDeCylTria( frMyCyl, dR, dH, dSafeDist, Tria))
return true ; return true ;
} }
} }
// Se superficie aperta, non c'è collisione // Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed()) if ( ! Stm.IsClosed())
return false ; return false ;
// Verifico se il cilindro è dentro la superficie tramite calcolo distanza minima. // Se il BBox del cilindro non è interno a quello del poliedro e viceversa, non c'è collisione
Point3d ptCylOrig( 0., 0., - dSafeDist) ; if ( ! b3Poly.Encloses( b3Cyl) && ! b3Cyl.Encloses( b3Poly))
ptCylOrig.ToGlob( frC) ; return false ;
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 // Se il cilindro è interno c'è collisione
return ( DistCylOrigSurfCalc.IsPointInside()) ; return ( DistCylCenSurfCalc.IsPointInside()) ;
} }
+16 -14
View File
@@ -37,20 +37,18 @@ CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, dou
// Calcolo il BBox del tronco di piramide // Calcolo il BBox del tronco di piramide
double dMaxLenX = max( dLenghtBaseX, dLenghtTopX) ; double dMaxLenX = max( dLenghtBaseX, dLenghtTopX) ;
double dMaxLenY = max( dLenghtBaseY, dLenghtTopY) ; double dMaxLenY = max( dLenghtBaseY, dLenghtTopY) ;
BBox3d b3Pyr( -dMaxLenX / 2, -dMaxLenY / 2, 0., dMaxLenX / 2, dMaxLenY / 2, dHeight) ; BBox3d b3PyrL( Point3d( -dMaxLenX / 2, -dMaxLenY / 2, 0.),
// Se la distanza di sicurezza è maggiore di epsilon aumento le dimensioni del tronco di piramide. Point3d( dMaxLenX / 2, dMaxLenY / 2, dHeight)) ;
if ( dSafeDist > EPS_SMALL) { if ( dSafeDist > EPS_SMALL)
b3Pyr.Expand( dSafeDist) ; b3PyrL.Expand( dSafeDist) ;
} BBox3d b3Pyr = GetToGlob( b3PyrL, frPrismoid) ;
// Porto BBox del tronco di piramide nel sistema della superficie.
b3Pyr.ToGlob( frPrismoid) ;
// Se i BBox non interferiscono, non c'è collisione // Se i BBox non interferiscono, non c'è collisione
if ( ! b3Pyr.Overlaps( b3Surf)) if ( ! b3Surf.Overlaps( b3Pyr) || ! b3Surf.Overlaps( frPrismoid, b3PyrL))
return false ; return false ;
// Recupero i triangoli che interferiscono con il box del tronco di piramide. // Recupero i triangoli che interferiscono con il box del tronco di piramide.
INTVECTOR vT ; INTVECTOR vT ;
Stm.GetAllTriaOverlapBox( b3Pyr, 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) { for ( int nT : vT) {
Triangle3d trTria ; Triangle3d trTria ;
if ( Stm.GetTriangle( nT, trTria)) { if ( Stm.GetTriangle( nT, trTria)) {
@@ -62,9 +60,13 @@ CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, dou
// Se superficie aperta, non c'è collisione // Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed()) if ( ! Stm.IsClosed())
return false ; return false ;
// Verifico se il tronco di piramide è dentro la superficie tramite calcolo distanza minima. // Se il BBox del tronco di piramide non è interno a quello del poliedro e viceversa, non c'è collisione
Point3d ptPyrOrig = frPrismoid.Orig() ; if ( ! b3Surf.Encloses( b3Pyr) && ! b3Pyr.Encloses( b3Surf))
DistPointSurfTm DistBoxOrigSurfCalc( ptPyrOrig, Stm) ; return false ;
// C'è collisione se il tronco di piramide è interno. // Verifico se il tronco di piramide è dentro la superficie tramite calcolo distanza minima del suo centro
return ( DistBoxOrigSurfCalc.IsPointInside()) ; Point3d ptPyrCen( 0, 0, dHeight / 2) ;
ptPyrCen.ToGlob( frPrismoid) ;
DistPointSurfTm DistPyrCenSurfCalc( ptPyrCen, Stm) ;
// C'è collisione se il tronco di piramide è interno
return ( DistPyrCenSurfCalc.IsPointInside()) ;
} }
+33 -53
View File
@@ -14,6 +14,7 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "CDeRectPrismoidTria.h" #include "CDeRectPrismoidTria.h"
#include "CDeCapsTria.h"
#include "CDeBoxTria.h" #include "CDeBoxTria.h"
#include "CDeCylTria.h" #include "CDeCylTria.h"
#include "CDeSpheTria.h" #include "CDeSpheTria.h"
@@ -141,9 +142,13 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
dHeight < EPS_SMALL || ! trTria.IsValid()) dHeight < EPS_SMALL || ! trTria.IsValid())
return false ; return false ;
// Porto il triangolo nel riferimento del prismoide
Triangle3d trTriaL = trTria ;
trTriaL.ToLoc( frPrismoid) ;
// Se distanza di sicurezza nulla // Se distanza di sicurezza nulla
if ( dSafeDist < EPS_SMALL) 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 // Verifiche con offset esteso
double dHDiffX = ( dLenghtBaseX - dLenghtTopX) / 2 ; double dHDiffX = ( dLenghtBaseX - dLenghtTopX) / 2 ;
@@ -156,37 +161,37 @@ CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLen
double dSecAy = sqrt( 1 + dTgAy * dTgAy) ; double dSecAy = sqrt( 1 + dTgAy * dTgAy) ;
double dOffsBaseY = dSafeDist * ( dSecAy + dTgAy) ; double dOffsBaseY = dSafeDist * ( dSecAy + dTgAy) ;
double dOffsTopY = dSafeDist * ( dSecAy - dTgAy) ; double dOffsTopY = dSafeDist * ( dSecAy - dTgAy) ;
Frame3d frFrame = frPrismoid ; frFrame.Translate( - dSafeDist * frFrame.VersZ()) ; Frame3d frTmp( Point3d( 0, 0, -dSafeDist)) ;
if ( ! CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX + 2 * dOffsBaseX, dLenghtBaseY + 2 * dOffsBaseY, if ( ! CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX + 2 * dOffsBaseX, dLenghtBaseY + 2 * dOffsBaseY,
dLenghtTopX + 2 * dOffsTopX, dLenghtTopY + 2 * dOffsTopY, dHeight + 2 * dSafeDist, trTria)) dLenghtTopX + 2 * dOffsTopX, dLenghtTopY + 2 * dOffsTopY, dHeight + 2 * dSafeDist, trTriaL))
return false ; return false ;
// Offset fine // Offset fine
// Box sotto // Box sotto
frFrame = frPrismoid ; frFrame.Translate( - dSafeDist * frFrame.VersZ()) ; frTmp.ChangeOrig( Point3d( 0, 0, -dSafeDist)) ;
if ( CDeSimpleBoxTria( frFrame, Vector3d( dLenghtBaseX, dLenghtBaseY, dSafeDist), trTria)) if ( CDeSimpleBoxTria( frTmp, Vector3d( dLenghtBaseX, dLenghtBaseY, dSafeDist), trTriaL))
return true ; return true ;
// Box sopra // Box sopra
frFrame = frPrismoid ; frFrame.Translate( dHeight * frFrame.VersZ()) ; frTmp.ChangeOrig( Point3d( 0, 0, dHeight)) ;
if ( CDeSimpleBoxTria( frFrame, Vector3d( dLenghtTopX, dLenghtTopY, dSafeDist), trTria)) if ( CDeSimpleBoxTria( frTmp, Vector3d( dLenghtTopX, dLenghtTopY, dSafeDist), trTriaL))
return true ; return true ;
// Prismoide allungato in X // Prismoide allungato in X
double dHypoX = sqrt( dHDiffX * dHDiffX + dHeight * dHeight) ; double dHypoX = sqrt( dHDiffX * dHDiffX + dHeight * dHeight) ;
double dOffsX = dSafeDist * dHeight / dHypoX ; double dOffsX = dSafeDist * dHeight / dHypoX ;
double dMoveXZ = dSafeDist * dHDiffX / dHypoX ; double dMoveXZ = dSafeDist * dHDiffX / dHypoX ;
frFrame = frPrismoid ; frFrame.Translate( dMoveXZ * frFrame.VersZ()) ; frTmp.ChangeOrig( Point3d( 0, 0, dMoveXZ)) ;
if ( CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX + 2 * dOffsX, dLenghtBaseY, if ( CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX + 2 * dOffsX, dLenghtBaseY,
dLenghtTopX + 2 * dOffsX, dLenghtTopY, dHeight, trTria)) dLenghtTopX + 2 * dOffsX, dLenghtTopY, dHeight, trTriaL))
return true ; return true ;
// Prismoide allungato in Y // Prismoide allungato in Y
double dHypoY = sqrt( dHDiffY * dHDiffY + dHeight * dHeight) ; double dHypoY = sqrt( dHDiffY * dHDiffY + dHeight * dHeight) ;
double dOffsY = dSafeDist * dHeight / dHypoY ; double dOffsY = dSafeDist * dHeight / dHypoY ;
double dMoveYZ = dSafeDist * dHDiffY / dHypoY ; double dMoveYZ = dSafeDist * dHDiffY / dHypoY ;
frFrame = frPrismoid ; frFrame.Translate( dMoveYZ * frFrame.VersZ()) ; frTmp.ChangeOrig( Point3d( 0, 0, dMoveYZ)) ;
if ( CDeSimpleRectPrismoidTria( frFrame, dLenghtBaseX, dLenghtBaseY + 2 * dOffsY, if ( CDeSimpleRectPrismoidTria( frTmp, dLenghtBaseX, dLenghtBaseY + 2 * dOffsY,
dLenghtTopX, dLenghtTopY + 2 * dOffsY, dHeight, trTria)) dLenghtTopX, dLenghtTopY + 2 * dOffsY, dHeight, trTriaL))
return true ; return true ;
// Sfere centrate nei vertici // Vertici
double dHalfBaseX = dLenghtBaseX / 2 ; double dHalfBaseX = dLenghtBaseX / 2 ;
double dHalfBaseY = dLenghtBaseY / 2 ; double dHalfBaseY = dLenghtBaseY / 2 ;
double dHalfTopX = dLenghtTopX / 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), Point3d( dHalfTopX, dHalfTopY, dHeight),
Point3d( -dHalfTopX, dHalfTopY, dHeight)} ; Point3d( -dHalfTopX, dHalfTopY, dHeight)} ;
for ( auto& ptV : vVert) { // Capsule centrati sui dodici spigoli
ptV.ToGlob( frPrismoid) ; if ( CDeSimpleCapsTria( vVert[0], vVert[1], dSafeDist, trTriaL))
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))
return true ; return true ;
frFrame.Set( vVert[1], frPrismoid.VersY()) ; if ( CDeSimpleCapsTria( vVert[1], vVert[2], dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseY, trTria))
return true ; return true ;
frFrame.Set( vVert[2], -frPrismoid.VersX()) ; if ( CDeSimpleCapsTria( vVert[2], vVert[3], dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseX, trTria))
return true ; return true ;
frFrame.Set( vVert[3], -frPrismoid.VersY()) ; if ( CDeSimpleCapsTria( vVert[3], vVert[0], dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtBaseY, trTria))
return true ; return true ;
frFrame.Set( vVert[4], frPrismoid.VersX()) ; if ( CDeSimpleCapsTria( vVert[4], vVert[5], dSafeDist, trTriaL))
if (CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopX, trTria))
return true ; return true ;
frFrame.Set( vVert[5], frPrismoid.VersY()) ; if ( CDeSimpleCapsTria( vVert[5], vVert[6], dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopY, trTria))
return true ; return true ;
frFrame.Set( vVert[6], -frPrismoid.VersX()) ; if ( CDeSimpleCapsTria( vVert[6], vVert[7], dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopX, trTria))
return true ; return true ;
frFrame.Set( vVert[7], -frPrismoid.VersY()) ; if ( CDeSimpleCapsTria( vVert[7], vVert[4], dSafeDist, trTriaL))
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenghtTopY, trTria))
return true ; return true ;
Vector3d vtSeg04 = vVert[4] - vVert[0] ; if ( CDeSimpleCapsTria( vVert[0], vVert[4], dSafeDist, trTriaL))
double dLenSeg04 = vtSeg04.Len() ;
frFrame.Set( vVert[0], vtSeg04) ;
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg04, trTria))
return true ; return true ;
Vector3d vtSeg15 = vVert[5] - vVert[1] ; if ( CDeSimpleCapsTria( vVert[1], vVert[5], dSafeDist, trTriaL))
double dLenSeg15 = vtSeg15.Len() ;
frFrame.Set( vVert[1], vtSeg15) ;
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg15, trTria))
return true ; return true ;
Vector3d vtSeg26 = vVert[6] - vVert[2] ; if ( CDeSimpleCapsTria( vVert[2], vVert[6], dSafeDist, trTriaL))
double dLenSeg26 = vtSeg26.Len() ;
frFrame.Set( vVert[2], vtSeg26) ;
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg26, trTria))
return true ; return true ;
Vector3d vtSeg37 = vVert[7] - vVert[3] ; if ( CDeSimpleCapsTria( vVert[3], vVert[7], dSafeDist, trTriaL))
double dLenSeg37 = vtSeg37.Len();
frFrame.Set( vVert[3], vtSeg37) ;
if ( CDeSimpleCylTria( frFrame, dSafeDist, dLenSeg37, trTria))
return true ; return true ;
return false ; return false ;
+11 -7
View File
@@ -23,15 +23,16 @@ using namespace std ;
bool bool
CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const ISurfTriMesh& Stm) CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const ISurfTriMesh& Stm)
{ {
// recupero BBox del poliedro // Recupero BBox del poliedro
BBox3d b3Poly = Stm.GetAllTriaBox() ; BBox3d b3Poly = Stm.GetAllTriaBox() ;
// calcolo il BBox della sfera // Calcolo il BBox della sfera
BBox3d b3Sphe( ptCen, dR) ; BBox3d b3Sphe( ptCen, dR) ;
b3Sphe.Expand( dSafeDist) ; if ( dSafeDist > EPS_SMALL)
// confronto i due Box b3Sphe.Expand( dSafeDist) ;
// Se i BBox non interferiscono, non c'è collisione
if ( ! b3Sphe.Overlaps( b3Poly)) if ( ! b3Sphe.Overlaps( b3Poly))
return false ; 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 ; INTVECTOR vT ;
Stm.GetAllTriaOverlapBox( b3Sphe, vT) ; Stm.GetAllTriaOverlapBox( b3Sphe, vT) ;
for ( int nT : vT) { for ( int nT : vT) {
@@ -44,8 +45,11 @@ CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const IS
// Se superficie aperta, non c'è collisione // Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed()) if ( ! Stm.IsClosed())
return false ; return false ;
// Verifico se la sfera è dentro la superficie tramite calcolo distanza minima. // 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 del suo centro
DistPointSurfTm DistCenSurfCalc( ptCen, Stm) ; DistPointSurfTm DistCenSurfCalc( ptCen, Stm) ;
// C'è collisione se la sfera è interna. // C'è collisione se la sfera è interna.
return ( DistCenSurfCalc.IsPointInside()) ; return ( DistCenSurfCalc.IsPointInside()) ;
} }
+7 -7
View File
@@ -34,7 +34,7 @@ GetTwoGreater( int nVal0, int nVal1, int nVal2, int& nFirstMaxPos, int& nSecondM
} }
else { else {
nFirstMaxPos = 2 ; nFirstMaxPos = 2 ;
nSecondMaxPos = 1 ; nSecondMaxPos = 0 ;
} }
} }
else if ( nVal0 > nVal2) { else if ( nVal0 > nVal2) {
@@ -109,7 +109,7 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
DistLineLine LineLineDistCalc( ptStA, PtEnA, ptStB, PtEnB) ; DistLineLine LineLineDistCalc( ptStA, PtEnA, ptStB, PtEnB) ;
double dSqSegSegDist ; double dSqSegSegDist ;
LineLineDistCalc.GetSqDist( dSqSegSegDist) ; LineLineDistCalc.GetSqDist( dSqSegSegDist) ;
if ( dSqSegSegDist < EPS_SMALL * EPS_SMALL) if ( dSqSegSegDist < SQ_EPS_SMALL)
return true ; return true ;
} }
} }
@@ -136,14 +136,14 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
vtSegFirstA /= dSegLenFirstA ; vtSegFirstA /= dSegLenFirstA ;
DistLineLine LineLineDistCalcFirstA( ptLineP, vtLineV, 100., trTriaA.GetP( nFirstMaxPosA), vtSegFirstA, dSegLenFirstA, false) ; DistLineLine LineLineDistCalcFirstA( ptLineP, vtLineV, 100., trTriaA.GetP( nFirstMaxPosA), vtSegFirstA, dSegLenFirstA, false) ;
double dIntParStA, dOtherParFirstA ; double dIntParStA, dOtherParFirstA ;
LineLineDistCalcFirstA.GetParamsAtMinDistPoints( dIntParStA, dOtherParFirstA) ; LineLineDistCalcFirstA.GetPositionsAtMinDistPoints( dIntParStA, dOtherParFirstA) ;
// Limito la retta col secondo segmento trovato di A // Limito la retta col secondo segmento trovato di A
Vector3d vtSegSecondA = trTriaA.GetP( ( nSecondMaxPosA + 1) % 3) - trTriaA.GetP( nSecondMaxPosA) ; Vector3d vtSegSecondA = trTriaA.GetP( ( nSecondMaxPosA + 1) % 3) - trTriaA.GetP( nSecondMaxPosA) ;
double dSegLenSecondA = vtSegSecondA.Len() ; double dSegLenSecondA = vtSegSecondA.Len() ;
vtSegSecondA /= dSegLenSecondA ; vtSegSecondA /= dSegLenSecondA ;
DistLineLine LineLineDistCalcSecondA( ptLineP, vtLineV, 100., trTriaA.GetP( nSecondMaxPosA), vtSegSecondA, dSegLenSecondA, false) ; DistLineLine LineLineDistCalcSecondA( ptLineP, vtLineV, 100., trTriaA.GetP( nSecondMaxPosA), vtSegSecondA, dSegLenSecondA, false) ;
double dIntParEnA, dOtherParSecondA ; double dIntParEnA, dOtherParSecondA ;
LineLineDistCalcSecondA.GetParamsAtMinDistPoints( dIntParEnA, dOtherParSecondA) ; LineLineDistCalcSecondA.GetPositionsAtMinDistPoints( dIntParEnA, dOtherParSecondA) ;
// Ordino i parametri lungo la retta di intersezione fra i piani // Ordino i parametri lungo la retta di intersezione fra i piani
if ( dIntParStA > dIntParEnA) { if ( dIntParStA > dIntParEnA) {
swap( dIntParStA, dIntParEnA) ; swap( dIntParStA, dIntParEnA) ;
@@ -163,14 +163,14 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
vtSegFirstB /= dSegLenFirstB ; vtSegFirstB /= dSegLenFirstB ;
DistLineLine LineLineDistCalcFirstB( ptLineP, vtLineV, 100., trTriaB.GetP( nFirstMaxPosB), vtSegFirstB, dSegLenFirstB, false) ; DistLineLine LineLineDistCalcFirstB( ptLineP, vtLineV, 100., trTriaB.GetP( nFirstMaxPosB), vtSegFirstB, dSegLenFirstB, false) ;
double dIntParStB, dOtherParFirstB ; double dIntParStB, dOtherParFirstB ;
LineLineDistCalcFirstB.GetParamsAtMinDistPoints( dIntParStB, dOtherParFirstB) ; LineLineDistCalcFirstB.GetPositionsAtMinDistPoints( dIntParStB, dOtherParFirstB) ;
// Limito la retta col secondo segmento trovato di B // Limito la retta col secondo segmento trovato di B
Vector3d vtSegSecondB = trTriaB.GetP( ( nSecondMaxPosB + 1) % 3) - trTriaB.GetP( nSecondMaxPosB) ; Vector3d vtSegSecondB = trTriaB.GetP( ( nSecondMaxPosB + 1) % 3) - trTriaB.GetP( nSecondMaxPosB) ;
double dSegLenSecondB = vtSegSecondB.Len() ; double dSegLenSecondB = vtSegSecondB.Len() ;
vtSegSecondB /= dSegLenSecondB ; 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 ; double dIntParEnB, dOtherParSecondB ;
LineLineDistCalcSecondB.GetParamsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ; LineLineDistCalcSecondB.GetPositionsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
// Ordino i parametri lungo la retta di intersezione fra i piani // Ordino i parametri lungo la retta di intersezione fra i piani
if ( dIntParStB > dIntParEnB) { if ( dIntParStB > dIntParEnB) {
swap( dIntParStB, dIntParEnB) ; swap( dIntParStB, dIntParEnB) ;
+3315
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -13,9 +13,9 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "/EgtDev/Include/EgkChainCurves.h" #include "/EgtDev/Include/EGkChainCurves.h"
#include "/EgtDev/Include/EgkGeomDB.h" #include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EgkCurve.h" #include "/EgtDev/Include/EGkCurve.h"
#include <algorithm> #include <algorithm>
using namespace std ; using namespace std ;
+44
View File
@@ -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) ;
}
+3 -3
View File
@@ -18,8 +18,8 @@
#include "CreateCurveAux.h" #include "CreateCurveAux.h"
#include "DistPointLine.h" #include "DistPointLine.h"
#include "GeoConst.h" #include "GeoConst.h"
#include "/EgtDev/Include/EgkCircleCenTgCurve.h" #include "/EgtDev/Include/EGkCircleCenTgCurve.h"
#include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; using namespace std ;
@@ -239,7 +239,7 @@ GetCircleCenTgCompo( const Point3d& ptCen, const Vector3d& vtN, const CurveCompo
double dSqDist = SqDist( ptNear, ptTg) ; double dSqDist = SqDist( ptNear, ptTg) ;
if ( dSqDist < dMinSqDist) { if ( dSqDist < dMinSqDist) {
dMinSqDist = dSqDist ; dMinSqDist = dSqDist ;
pCrvArc.Set( Release( pCrvAtmp)) ; pCrvArc.Set( pCrvAtmp) ;
if ( pPtTg != nullptr) if ( pPtTg != nullptr)
*pPtTg = ptTg ; *pPtTg = ptTg ;
} }
+1 -1
View File
@@ -17,7 +17,7 @@
#include "/EgtDev/Include/EGkColor.h" #include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGkAngle.h" #include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGtNumUtils.h" #include "/EgtDev/Include/EgtNumUtils.h"
#include <algorithm> #include <algorithm>
using namespace std ; using namespace std ;
+245 -83
View File
@@ -22,9 +22,12 @@
#include "GeoObjFactory.h" #include "GeoObjFactory.h"
#include "NgeWriter.h" #include "NgeWriter.h"
#include "NgeReader.h" #include "NgeReader.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkAngle.h" #include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EGkUiUnits.h"
#include "/EgtDev/Include/ENkPolynomialRoots.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <new> #include <new>
@@ -59,15 +62,14 @@ class ArcApproxer
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CurveArc::CurveArc( void) CurveArc::CurveArc( void)
: m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(), : m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(),
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick() m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick(), m_nTempProp{0,0}, m_dTempParam{0.0, 0.0}, m_pVoronoiObj( nullptr)
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CurveArc::~CurveArc( void) CurveArc::~CurveArc( void)
{ {
ResetVoronoiObject() ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -90,6 +92,8 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad,
m_VtN.Normalize() ; m_VtN.Normalize() ;
m_VtS.Normalize() ; m_VtS.Normalize() ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -115,6 +119,8 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad)
m_dDeltaN = 0 ; m_dDeltaN = 0 ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -136,6 +142,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad, double dAngIniDeg, double dA
m_dDeltaN = dDeltaZ ; m_dDeltaN = dDeltaZ ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -157,6 +165,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad)
m_dDeltaN = 0 ; m_dDeltaN = 0 ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -219,6 +229,8 @@ CurveArc::Set3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d&
// non c'è DeltaN // non c'è DeltaN
m_dDeltaN = 0 ; m_dDeltaN = 0 ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -266,6 +278,8 @@ CurveArc::Set2PNB( const Point3d& ptIni, const Point3d& ptFin, const Vector3d& v
// calcolo l'angolo al centro // calcolo l'angolo al centro
m_dAngCenDeg = 4 * atan( dBulge) * RADTODEG ; m_dAngCenDeg = 4 * atan( dBulge) * RADTODEG ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -322,6 +336,8 @@ CurveArc::Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStart
m_dDeltaN = - m_dDeltaN ; m_dDeltaN = - m_dDeltaN ;
} }
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -404,6 +420,8 @@ CurveArc::Set2PRS( const Point3d& ptStart, const Point3d& ptEnd, double dRad, bo
( ! bCCW && m_dAngCenDeg > 0))) ( ! bCCW && m_dAngCenDeg > 0)))
m_dAngCenDeg = - m_dAngCenDeg ; m_dAngCenDeg = - m_dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -458,6 +476,8 @@ CurveArc::SetCPA( const Point3d& ptCen, const Point3d& ptStart, double dAngCenDe
// assegno l'angolo al centro // assegno l'angolo al centro
m_dAngCenDeg = dAngCenDeg ; m_dAngCenDeg = dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -513,7 +533,8 @@ CurveArc::SetC2P( const Point3d& ptCen, const Point3d& ptStart, const Point3d& p
bool bDet ; bool bDet ;
if ( ! m_VtS.GetRotation( ( ptNearEnd - m_PtCen), m_VtN, m_dAngCenDeg, bDet) || ! bDet) if ( ! m_VtS.GetRotation( ( ptNearEnd - m_PtCen), m_VtN, m_dAngCenDeg, bDet) || ! bDet)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -566,7 +587,7 @@ CurveArc::Clone( void) const
bool bool
CurveArc::CopyFrom( const IGeoObj* pGObjSrc) CurveArc::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const CurveArc* pCA = dynamic_cast<const CurveArc*>( pGObjSrc) ; const CurveArc* pCA = GetBasicCurveArc( pGObjSrc) ;
if ( pCA == nullptr) if ( pCA == nullptr)
return false ; return false ;
return CopyFrom( *pCA) ; return CopyFrom( *pCA) ;
@@ -582,6 +603,8 @@ CurveArc::CopyFrom( const CurveArc& caSrc)
m_dThick = caSrc.m_dThick ; m_dThick = caSrc.m_dThick ;
m_nTempProp[0] = caSrc.m_nTempProp[0] ; m_nTempProp[0] = caSrc.m_nTempProp[0] ;
m_nTempProp[1] = caSrc.m_nTempProp[1] ; 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, return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad,
caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ; caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ;
} }
@@ -699,29 +722,8 @@ CurveArc::Load( NgeReader& ngeIn)
bool bool
CurveArc::GetLocalBBox( BBox3d& b3Loc, int nFlag) const CurveArc::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
{ {
// verifico lo stato // richiamo della funzione generale
if ( m_nStatus != OK) return GetBBox( GLOB_FRM, b3Loc, nFlag) ;
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 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -736,17 +738,88 @@ CurveArc::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
return false ; return false ;
// assegno il box nel riferimento // assegno il box nel riferimento
b3Ref.Reset() ; b3Ref.Reset() ;
double dLinTol = LIN_TOL_APPROX ;
double dAngTolDeg = ANG_TOL_APPROX_DEG ; // ricavo il riferimento intrinseco dell'arco
if ( ( nFlag & BBF_EXACT) != 0) Frame3d frArc;
dLinTol = LIN_TOL_MIN ; frArc.Set( m_PtCen, ( m_dAngCenDeg > 0 ? m_VtN : -m_VtN), m_VtS) ;
ArcApproxer aAppr( dLinTol, dAngTolDeg, false, *this) ;
double dU ; // pendenza intrinseca
Point3d ptPos ; double dPitch = m_dDeltaN * ( m_dAngCenDeg > 0 ? 1 : -1) / abs( m_dAngCenDeg * DEGTORAD) ;
while ( aAppr.GetPoint( dU, ptPos)) {
ptPos.ToGlob( frRef) ; // cordinate nel frRef dei versori del sistema di riferimento dell'arco
b3Ref.Add( ptPos) ; 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) ;
} }
// 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 // se c'è estrusione, devo tenerne conto
if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) { if ( ! m_VtExtr.IsSmall() && abs( m_dThick) > EPS_SMALL) {
Vector3d vtFrExtr = m_VtExtr ; Vector3d vtFrExtr = m_VtExtr ;
@@ -773,10 +846,10 @@ CurveArc::Validate( void)
m_dAngCenDeg = - ANG_FULL ; m_dAngCenDeg = - ANG_FULL ;
} }
// eseguo il controllo // eseguo il controllo
m_nStatus = ( ( m_VtN.IsNormalized() && m_VtS.IsNormalized() && m_nStatus = ( ( m_PtCen.IsValid() &&
AreOrthoApprox( m_VtN, m_VtS) && m_VtN.IsNormalized() && m_VtS.IsNormalized() && AreOrthoApprox( m_VtN, m_VtS) &&
m_dRad > EPS_SMALL && m_dRad < MAX_ARC_RAD && m_dRad > EPS_SMALL && m_dRad < MAX_ARC_RAD &&
abs( m_dAngCenDeg) > EPS_ANG_ZERO) ? OK : ERR) ; abs( m_dAngCenDeg) > EPS_ANG_ZERO) ? OK : ERR) ;
} }
return ( m_nStatus == OK) ; return ( m_nStatus == OK) ;
@@ -831,7 +904,7 @@ CurveArc::GetEndPoint( Point3d& ptEnd) const
double dAng = m_dAngCenDeg * DEGTORAD ; double dAng = m_dAngCenDeg * DEGTORAD ;
Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ; Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
ptEnd = m_PtCen + m_dRad * vtDir ; 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 ; ptEnd += m_dDeltaN * m_VtN ;
return true ; return true ;
@@ -849,7 +922,7 @@ CurveArc::GetMidPoint( Point3d& ptMid) const
double dAng = 0.5 * m_dAngCenDeg * DEGTORAD ; double dAng = 0.5 * m_dAngCenDeg * DEGTORAD ;
Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ; Vector3d vtDir = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
ptMid = m_PtCen + m_dRad * vtDir ; 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 ; ptMid += ( 0.5 * m_dDeltaN) * m_VtN ;
return true ; return true ;
@@ -877,7 +950,7 @@ CurveArc::GetCentroid( Point3d& ptCen) const
return false ; return false ;
// approssimo la curva con una polilinea // approssimo la curva con una polilinea
PolyLine PL ; 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 ; return false ;
// calcolo il centro mediante PolygonPlane // calcolo il centro mediante PolygonPlane
Point3d ptP ; Point3d ptP ;
@@ -899,17 +972,14 @@ CurveArc::GetDir( double dU, Vector3d& vtDir) const
return false ; return false ;
// il parametro U deve essere compreso tra 0 e 1 // il parametro U deve essere compreso tra 0 e 1
if ( dU < 0) dU = Clamp( dU, 0., 1.) ;
dU = 0 ;
else if ( dU > 1)
dU = 1 ;
// versore al punto nel piano della circonferenza (ruoto m_VtS di dU * m_dAngCenDeg attorno a m_VtN) // versore al punto nel piano della circonferenza (ruoto m_VtS di dU * m_dAngCenDeg attorno a m_VtN)
double dAng = dU * m_dAngCenDeg * DEGTORAD ; double dAng = dU * m_dAngCenDeg * DEGTORAD ;
Vector3d vtRad = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ; Vector3d vtRad = cos( dAng) * m_VtS + sin( dAng) * ( m_VtN ^ m_VtS) ;
// calcolo della tangente nel punto finale // calcolo della tangente nel punto finale
vtDir = ( m_dRad * m_dAngCenDeg * DEGTORAD) * ( m_VtN ^ vtRad) ; 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 ; vtDir += m_dDeltaN * m_VtN ;
// normalizzo // normalizzo
return vtDir.Normalize( EPS_ZERO) ; return vtDir.Normalize( EPS_ZERO) ;
@@ -924,10 +994,7 @@ CurveArc::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1, V
return false ; return false ;
// il parametro U deve essere compreso tra 0 e 1 // il parametro U deve essere compreso tra 0 e 1
if ( dU < 0) dU = Clamp( dU, 0., 1.) ;
dU = 0 ;
else if ( dU > 1)
dU = 1 ;
// versore al punto nel piano della circonferenza (ruoto m_VtS di dU di m_dAngCenDeg attorno a m_VtN) // 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 ; double dAng = dU * m_dAngCenDeg * DEGTORAD ;
@@ -935,13 +1002,13 @@ CurveArc::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1, V
// calcolo del punto // calcolo del punto
ptPos = m_PtCen + m_dRad * vtDir ; 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 ; ptPos += ( dU * m_dDeltaN) * m_VtN ;
// calcolo della derivata prima // calcolo della derivata prima
if ( pvtDer1 != nullptr) { if ( pvtDer1 != nullptr) {
*pvtDer1 = ( m_dRad * m_dAngCenDeg * DEGTORAD) * ( m_VtN ^ vtDir) ; *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 ; *pvtDer1 += m_dDeltaN * m_VtN ;
} }
@@ -963,7 +1030,7 @@ CurveArc::GetLength( double& dLen) const
// lunghezza dell'arco piano // lunghezza dell'arco piano
dLen = m_dRad * abs( m_dAngCenDeg) * DEGTORAD ; dLen = m_dRad * abs( m_dAngCenDeg) * DEGTORAD ;
// aggiunta eventuale parte ortogonale // 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) ; dLen = sqrt( dLen * dLen + m_dDeltaN * m_dDeltaN) ;
return ( dLen > EPS_SMALL) ; return ( dLen > EPS_SMALL) ;
@@ -1204,7 +1271,7 @@ CurveArc::Invert( void)
return false ; return false ;
// il centro va spostato di DeltaN // 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 ; m_PtCen += m_dDeltaN * m_VtN ;
// il versore normale rimane inalterato // il versore normale rimane inalterato
// il versore iniziale diventa quello finale // il versore iniziale diventa quello finale
@@ -1216,6 +1283,8 @@ CurveArc::Invert( void)
// l'incremento sulla normale inverte il segno // l'incremento sulla normale inverte il segno
m_dDeltaN = - m_dDeltaN ; m_dDeltaN = - m_dDeltaN ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1249,6 +1318,8 @@ CurveArc::SimpleOffset( double dDist, int nType)
// aggiorno il raggio // aggiorno il raggio
m_dRad = dNewRad ; m_dRad = dNewRad ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1293,6 +1364,8 @@ CurveArc::MyExtendedOffset( double dDist, bool bAll, int nType)
// aggiorno il raggio // aggiorno il raggio
m_dRad = dNewRad ; m_dRad = dNewRad ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1365,6 +1438,8 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
m_dDeltaN = arcAux.m_dDeltaN ; m_dDeltaN = arcAux.m_dDeltaN ;
} }
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1375,13 +1450,11 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
bool bool
CurveArc::TrimStartAtParam( double dUTrim) CurveArc::TrimStartAtParam( double dUTrim)
{ {
double dLen ;
// riporto i parametri nel loro range // riporto i parametri nel loro range
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ; dUTrim = Clamp( dUTrim, 0., 1.) ;
// recupero lunghezza // recupero lunghezza
double dLen ;
if ( ! GetLength( dLen)) if ( ! GetLength( dLen))
return false ; return false ;
@@ -1393,13 +1466,11 @@ CurveArc::TrimStartAtParam( double dUTrim)
bool bool
CurveArc::TrimEndAtParam( double dUTrim) CurveArc::TrimEndAtParam( double dUTrim)
{ {
double dLen ;
// riporto i parametri nel loro range // riporto i parametri nel loro range
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ; dUTrim = Clamp( dUTrim, 0., 1.) ;
// recupero lunghezza // recupero lunghezza
double dLen ;
if ( ! GetLength( dLen)) if ( ! GetLength( dLen))
return false ; return false ;
@@ -1447,13 +1518,15 @@ CurveArc::TrimStartAtLen( double dLenTrim)
dAngRot = m_dAngCenDeg * dLenTrim / dLen ; dAngRot = m_dAngCenDeg * dLenTrim / dLen ;
m_VtS.Rotate( m_VtN, dAngRot) ; m_VtS.Rotate( m_VtN, dAngRot) ;
m_dAngCenDeg -= dAngRot ; m_dAngCenDeg -= dAngRot ;
if ( abs( m_dDeltaN) > EPS_SMALL) { if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL) {
dMoveN = m_dDeltaN * dLenTrim / dLen ; dMoveN = m_dDeltaN * dLenTrim / dLen ;
m_PtCen.Translate( m_VtN * dMoveN) ; m_PtCen.Translate( m_VtN * dMoveN) ;
m_dDeltaN -= dMoveN ; m_dDeltaN -= dMoveN ;
} }
} }
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1477,10 +1550,12 @@ CurveArc::TrimEndAtLen( double dLenTrim)
// eseguo il trim // eseguo il trim
if ( ( dLen - dLenTrim) > EPS_ZERO) { if ( ( dLen - dLenTrim) > EPS_ZERO) {
m_dAngCenDeg *= dLenTrim / dLen ; m_dAngCenDeg *= dLenTrim / dLen ;
if ( abs( m_dDeltaN) > EPS_SMALL) if ( abs( m_dDeltaN) > 0.1 * EPS_SMALL)
m_dDeltaN *= dLenTrim / dLen ; m_dDeltaN *= dLenTrim / dLen ;
} }
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1524,6 +1599,8 @@ CurveArc::ExtendEndByLen( double dLenExt)
else if ( abs( m_dAngCenDeg) > ANG_FULL) else if ( abs( m_dAngCenDeg) > ANG_FULL)
m_dAngCenDeg = _copysign( ANG_FULL, m_dAngCenDeg) ; m_dAngCenDeg = _copysign( ANG_FULL, m_dAngCenDeg) ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1538,6 +1615,8 @@ CurveArc::Translate( const Vector3d& vtMove)
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1559,6 +1638,8 @@ CurveArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
if ( vtAx.IsSmall()) if ( vtAx.IsSmall())
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1588,6 +1669,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla // verifico non sia nulla
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL) if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari // scalo il centro e le dimensioni lineari
@@ -1615,6 +1698,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla // verifico non sia nulla
if ( abs( dCoeffY) < EPS_ZERO || m_dRad * abs( dCoeffY) <= EPS_SMALL) if ( abs( dCoeffY) < EPS_ZERO || m_dRad * abs( dCoeffY) <= EPS_SMALL)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari // scalo il centro e le dimensioni lineari
@@ -1642,6 +1727,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla // verifico non sia nulla
if ( abs( dCoeffZ) < EPS_ZERO || m_dRad * abs( dCoeffZ) <= EPS_SMALL) if ( abs( dCoeffZ) < EPS_ZERO || m_dRad * abs( dCoeffZ) <= EPS_SMALL)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari // scalo il centro e le dimensioni lineari
@@ -1669,6 +1756,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla // verifico non sia nulla
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL) if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari // scalo il centro e le dimensioni lineari
@@ -1702,6 +1791,8 @@ CurveArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall()) if ( vtNorm.IsSmall())
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1733,6 +1824,8 @@ CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt
! AreSameOrOppositeVectorExact( m_VtN, vtNorm)) ! AreSameOrOppositeVectorExact( m_VtN, vtNorm))
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1756,11 +1849,16 @@ CurveArc::ToGlob( const Frame3d& frRef)
// la curva deve essere validata // la curva deve essere validata
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico validità del frame // verifico validità del frame
if ( frRef.GetType() == Frame3d::ERR) if ( frRef.GetType() == Frame3d::ERR)
return false ; return false ;
// se frame identità, non devo fare alcunché
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1778,11 +1876,16 @@ CurveArc::ToLoc( const Frame3d& frRef)
// la curva deve essere validata // la curva deve essere validata
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico validità del frame // verifico validità del frame
if ( frRef.GetType() == Frame3d::ERR) if ( frRef.GetType() == Frame3d::ERR)
return false ; return false ;
// se frame identità, non devo fare alcunché
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1803,11 +1906,16 @@ CurveArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
// verifico validità dei frame // verifico validità dei frame
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR) if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
return false ; return false ;
// se i due riferimenti coincidono, non devo fare alcunché // se i due riferimenti coincidono, non devo fare alcunché
if ( AreSameFrame( frOri, frDest)) if ( AreSameFrame( frOri, frDest))
return true ; return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// trasformo il centro e i versori // trasformo il centro e i versori
return ( m_PtCen.LocToLoc( frOri, frDest) && return ( m_PtCen.LocToLoc( frOri, frDest) &&
m_VtN.LocToLoc( frOri, frDest) && m_VtN.LocToLoc( frOri, frDest) &&
@@ -1828,6 +1936,8 @@ CurveArc::InvertN( void)
m_dAngCenDeg = - m_dAngCenDeg ; m_dAngCenDeg = - m_dAngCenDeg ;
m_dDeltaN = - m_dDeltaN ; m_dDeltaN = - m_dDeltaN ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1901,9 +2011,15 @@ CurveArc::ChangeRadius( double dNewRadius)
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico validità del raggio
if ( ! ( dNewRadius > EPS_SMALL && dNewRadius < MAX_ARC_RAD))
return false ;
// cambio il raggio // cambio il raggio
m_dRad = dNewRadius ; m_dRad = dNewRadius ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1923,6 +2039,8 @@ CurveArc::ChangeDeltaN( double dNewDeltaN)
// cambio il parametro // cambio il parametro
m_dDeltaN = dNewDeltaN ; m_dDeltaN = dNewDeltaN ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1939,9 +2057,15 @@ CurveArc::ChangeAngCenter( double dNewAngCenDeg)
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico accettabilità angolo
if ( ! ( abs( m_dAngCenDeg) > EPS_ANG_ZERO))
return false ;
// cambio il parametro // cambio il parametro
m_dAngCenDeg = dNewAngCenDeg ; m_dAngCenDeg = dNewAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1966,6 +2090,8 @@ CurveArc::ChangeStartPoint( double dU)
if ( ! vtDir.Normalize()) if ( ! vtDir.Normalize())
return false ; return false ;
m_VtS = vtDir ; m_VtS = vtDir ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
return true ; return true ;
@@ -1985,6 +2111,8 @@ CurveArc::ToExplementary( void)
// basta prendere l'angolo al centro che completa il giro // basta prendere l'angolo al centro che completa il giro
m_dAngCenDeg = - _copysign( ANG_FULL, m_dAngCenDeg) + m_dAngCenDeg ; m_dAngCenDeg = - _copysign( ANG_FULL, m_dAngCenDeg) + m_dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -2014,6 +2142,8 @@ CurveArc::Flip( void)
m_VtS.Normalize() ; m_VtS.Normalize() ;
m_dAngCenDeg = - m_dAngCenDeg ; m_dAngCenDeg = - m_dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -2031,10 +2161,6 @@ CurveArc::Flip( void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc) ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc)
{ {
int nStep ;
double dAngStepDeg ;
// inizializzazioni // inizializzazioni
m_nTotPnt = 0 ; m_nTotPnt = 0 ;
m_nCurrPnt = - 1 ; m_nCurrPnt = - 1 ;
@@ -2052,6 +2178,7 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
dAngTolDeg = min( dAngTolDeg, ANG_TOL_EXT_MAX_DEG) ; dAngTolDeg = min( dAngTolDeg, ANG_TOL_EXT_MAX_DEG) ;
// determinazione dello step angolare // determinazione dello step angolare
double dAngStepDeg ;
double dLinTolRel = dLinTol / arArc.GetRadius() ; double dLinTolRel = dLinTol / arArc.GetRadius() ;
if ( bInside) if ( bInside)
dAngStepDeg = sqrt( 8 * dLinTolRel) * RADTODEG ; dAngStepDeg = sqrt( 8 * dLinTolRel) * RADTODEG ;
@@ -2060,7 +2187,7 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
dAngStepDeg = min( dAngStepDeg, dAngTolDeg) ; dAngStepDeg = min( dAngStepDeg, dAngTolDeg) ;
// dall'angolo al centro ricavo il numero di passi // 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) ; nStep = max( nStep, 1) ;
// sistemo lo step (per il numero intero di passi) // sistemo lo step (per il numero intero di passi)
@@ -2087,10 +2214,6 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
bool bool
ArcApproxer::GetPoint( double& dU, Point3d& ptP) ArcApproxer::GetPoint( double& dU, Point3d& ptP)
{ {
Vector3d vtA1p ;
Vector3d vtA2p ;
// incremento indice punto corrente // incremento indice punto corrente
++ m_nCurrPnt ; ++ m_nCurrPnt ;
@@ -2109,7 +2232,7 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
if ( ! m_bInside && m_nCurrPnt == m_nTotPnt - 1) { if ( ! m_bInside && m_nCurrPnt == m_nTotPnt - 1) {
dU = 1 ; dU = 1 ;
ptP = m_PtCen + m_vtA1 * m_dRad ; 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 ; ptP += ( dU * m_dDeltaN) * m_VtN ;
return true ; return true ;
} }
@@ -2121,8 +2244,8 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
else else
dU = ( m_nCurrPnt - 0.5) / (double) ( m_nTotPnt - 2) ; dU = ( m_nCurrPnt - 0.5) / (double) ( m_nTotPnt - 2) ;
// nuovo valore versori // nuovo valore versori
vtA1p = m_vtA1 ; Vector3d vtA1p = m_vtA1 ;
vtA2p = m_vtA2 ; Vector3d vtA2p = m_vtA2 ;
m_vtA1 = m_dCosA * vtA1p + m_dSinA * vtA2p ; m_vtA1 = m_dCosA * vtA1p + m_dSinA * vtA2p ;
m_vtA2 = - m_dSinA * vtA1p + m_dCosA * vtA2p ; m_vtA2 = - m_dSinA * vtA1p + m_dCosA * vtA2p ;
// calcolo del punto // calcolo del punto
@@ -2130,8 +2253,47 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
ptP = m_PtCen + m_vtA1 * m_dRad ; ptP = m_PtCen + m_vtA1 * m_dRad ;
else else
ptP = m_PtCen + ( vtA1p + m_vtA1) * ( m_dRad / ( 1 + m_dCosA)) ; 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 ; ptP += ( dU * m_dDeltaN) * m_VtN ;
return true ; 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 ;
}
+21 -5
View File
@@ -19,6 +19,8 @@
#include "GeoObjRW.h" #include "GeoObjRW.h"
#include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkCurveArc.h"
class Voronoi ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class CurveArc : public ICurveArc, public IGeoObjRW class CurveArc : public ICurveArc, public IGeoObjRW
{ {
@@ -54,6 +56,11 @@ class CurveArc : public ICurveArc, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // ICurve
bool IsSimple( void) const override bool IsSimple( void) const override
@@ -183,7 +190,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
public : public :
CurveArc( void) ; CurveArc( void) ;
CurveArc( const CurveArc& caSrc) CurveArc( const CurveArc& caSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( caSrc)) { if ( ! CopyFrom( caSrc))
LOG_ERROR( GetEGkLogger(), "CurveArc : copy constructor error")} LOG_ERROR( GetEGkLogger(), "CurveArc : copy constructor error")}
CurveArc& operator =( const CurveArc& caSrc) CurveArc& operator =( const CurveArc& caSrc)
@@ -192,11 +199,14 @@ class CurveArc : public ICurveArc, public IGeoObjRW
return *this ; } return *this ; }
bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ; bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ;
bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ; bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ;
Voronoi* GetVoronoiObject( void) const ;
private : private :
bool CopyFrom( const CurveArc& caSrc) ; bool CopyFrom( const CurveArc& caSrc) ;
bool Validate( void) ; bool Validate( void) ;
bool GetDir( double dU, Vector3d& vtDir) const ; bool GetDir( double dU, Vector3d& vtDir) const ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private : private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
@@ -213,16 +223,22 @@ class CurveArc : public ICurveArc, public IGeoObjRW
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN) Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
} ; } ;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline CurveArc* CreateBasicCurveArc( void) inline CurveArc* CreateBasicCurveArc( void)
{ return (static_cast<CurveArc*>( CreateGeoObj( CRV_ARC))) ; } { return ( static_cast<CurveArc*>( CreateGeoObj( CRV_ARC))) ; }
inline CurveArc* CloneBasicCurveArc( const IGeoObj* pGObj) inline CurveArc* CloneBasicCurveArc( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_ARC) { if ( pGObj == nullptr || pGObj->GetType() != CRV_ARC)
return nullptr ; return nullptr ;
return (static_cast<CurveArc*>(pGObj->Clone())) ; } return ( static_cast<CurveArc*>( pGObj->Clone())) ; }
inline const CurveArc* GetBasicCurveArc( const IGeoObj* pGObj) 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) inline CurveArc* GetBasicCurveArc( IGeoObj* pGObj)
{ return (dynamic_cast<CurveArc*>(pGObj)) ; } { if ( pGObj == nullptr || pGObj->GetType() != CRV_ARC)
return nullptr ;
return ( static_cast<CurveArc*>( pGObj)) ; }
+252 -21
View File
@@ -19,6 +19,7 @@
#include "CurveArc.h" #include "CurveArc.h"
#include "CurveBezier.h" #include "CurveBezier.h"
#include "CurveComposite.h" #include "CurveComposite.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EGkUiUnits.h"
@@ -30,9 +31,8 @@ using namespace std ;
bool bool
IsClosed( const ICurve& crvC) IsClosed( const ICurve& crvC)
{ {
Point3d ptStart ; Point3d ptStart, ptEnd ;
Point3d ptEnd ; return ( crvC.GetStartPoint( ptStart) && crvC.GetEndPoint( ptEnd) && AreSamePointApprox( ptStart, ptEnd)) ;
return ( crvC.GetStartPoint( ptStart) && crvC.GetEndPoint( ptEnd) && AreSamePointApprox( ptStart, ptEnd)) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -295,7 +295,7 @@ CurveGetAreaXY( const ICurve& crvC, double& dArea)
return false ; return false ;
// approssimo la curva con una polilinea // approssimo la curva con una polilinea
PolyLine PL ; 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 // calcolo l'area
double dAreaXY = 0 ; double dAreaXY = 0 ;
PL.GetAreaXY( dAreaXY) ; PL.GetAreaXY( dAreaXY) ;
@@ -314,7 +314,7 @@ CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea)
return false ; return false ;
// approssimo la curva con una polilinea // approssimo la curva con una polilinea
PolyLine PL ; 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 // calcolo l'area
Plane3d plMyPlane ; Plane3d plMyPlane ;
double dMyArea = 0 ; double dMyArea = 0 ;
@@ -366,8 +366,10 @@ CurveDump( const ICurve& crvC, string& sOut, bool bMM, const char* szNewLine)
double dAreaXY ; double dAreaXY ;
if ( CurveGetAreaXY( crvC, 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=" + sOut += string( "Closed") + ( bCCW ? " CCW" : " CW") + " AreaXY=" +
ToString( GetAreaInUiUnits( abs( dAreaXY), bMM),1) + szNewLine ; ToString( dAreaUi, nDec) + szNewLine ;
} }
return true ; return true ;
@@ -509,14 +511,7 @@ CurveToArcsPerpExtrCurve( const ICurve* pCrv, double dLinTol, double dAngTolDeg)
bool bool
NurbsCurveCanonicalize( CNurbsData& cnData) NurbsCurveCanonicalize( CNurbsData& cnData)
{ {
// se periodica // se con nodi extra
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
if ( cnData.bExtraKnotes) { if ( cnData.bExtraKnotes) {
int nKnotesNbr = int( cnData.vU.size()) ; int nKnotesNbr = int( cnData.vU.size()) ;
if ( nKnotesNbr < 4) if ( nKnotesNbr < 4)
@@ -525,7 +520,173 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
for ( int i = 0 ; i < nKnotesNbr - 2 ; ++ i) for ( int i = 0 ; i < nKnotesNbr - 2 ; ++ i)
cnData.vU[i] = cnData.vU[i+1] ; cnData.vU[i] = cnData.vU[i+1] ;
cnData.vU.resize( nKnotesNbr - 2) ; cnData.vU.resize( nKnotesNbr - 2) ;
return true ; }
// se periodica
if ( cnData.bPeriodic || ! cnData.bClamped) {
// 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 ; return true ;
@@ -561,7 +722,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
// 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) { if ( nInt == 1) {
// creo la curva di Bezier // creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ; PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCrvBez)) if ( IsNull( pCrvBez))
return nullptr ; return nullptr ;
// la inizializzo // la inizializzo
@@ -585,7 +746,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
} }
// altrimenti è equivalente ad una curva composita, la creo // altrimenti è equivalente ad una curva composita, la creo
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ; PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo)) if ( IsNull( pCrvCompo))
return nullptr ; return nullptr ;
@@ -647,7 +808,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
} }
// costruisco la curva di Bezier e la inserisco nella curva composita // costruisco la curva di Bezier e la inserisco nella curva composita
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ; PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCrvBez)) if ( IsNull( pCrvBez))
return nullptr ; return nullptr ;
// se precedente saltata // se precedente saltata
@@ -683,7 +844,6 @@ NurbsToBezierCurve( const CNurbsData& cnData)
pCrvBez.Reset() ; pCrvBez.Reset() ;
bPrevRejected = true ; bPrevRejected = true ;
} }
// inizializzazioni per la prossima curva di Bezier // inizializzazioni per la prossima curva di Bezier
if ( b < nU - 1) { if ( b < nU - 1) {
if ( ! cnData.bRat) { if ( ! cnData.bRat) {
@@ -707,6 +867,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 // restituisco la curva composita
return Release( pCrvCompo) ; return Release( pCrvCompo) ;
} }
@@ -729,7 +913,7 @@ FlattenCurve( const ICurve& crCrv, double dToler, double dAngToler, int nFlag)
return nullptr ; return nullptr ;
// Verifico se curva già piatta // Verifico se curva già piatta
PolyLine PL ; 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 ; return nullptr ;
bool bFlat = true ; bool bFlat = true ;
Plane3d plFlat ; plFlat.Set( ptCen, plMid.GetVersN()) ; Plane3d plFlat ; plFlat.Set( ptCen, plMid.GetVersN()) ;
@@ -790,7 +974,7 @@ ProjectCurveOnPlane( const ICurve& crCrv, const Plane3d& plPlane)
{ {
// determino se curva piana e suo eventuale piano // determino se curva piana e suo eventuale piano
Plane3d plCrv ; Plane3d plCrv ;
if ( crCrv.IsFlat( plCrv)) { if ( crCrv.IsFlat( plCrv, false, EPS_SMALL / 2)) {
// se il piano della curva è parallelo a quello di proiezione // se il piano della curva è parallelo a quello di proiezione
if ( AreSameOrOppositeVectorExact( plCrv.GetVersN(), plPlane.GetVersN())) { if ( AreSameOrOppositeVectorExact( plCrv.GetVersN(), plPlane.GetVersN())) {
// copio la curva // copio la curva
@@ -856,3 +1040,50 @@ AdjustCurveSlope( ICurveComposite* pCrv, double dNini, double dNfin)
pCrv->ModifyEnd( ptFin) ; pCrv->ModifyEnd( ptFin) ;
return true ; 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) ;
}
+4 -1
View File
@@ -13,7 +13,9 @@
#pragma once #pragma once
#include "/EgtDev/Include/EgkCurveAux.h" #include "/EgtDev/Include/EGkCurveAux.h"
class Voronoi ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool IsClosed( const ICurve& crvC) ; 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 CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ; bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ; bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
+121 -17
View File
@@ -26,6 +26,7 @@
#include "PolynomialPoint3d.h" #include "PolynomialPoint3d.h"
#include "Bernstein.h" #include "Bernstein.h"
#include "deCasteljau.h" #include "deCasteljau.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EGkUiUnits.h"
@@ -45,15 +46,14 @@ GEOOBJ_REGISTER( CRV_BEZIER, NGE_C_BEZ, CurveBezier) ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CurveBezier::CurveBezier( void) CurveBezier::CurveBezier( void)
: m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2), : m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2),
m_VtExtr(), m_dThick() m_VtExtr(), m_dThick(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CurveBezier::~CurveBezier( void) CurveBezier::~CurveBezier( void)
{ {
ResetVoronoiObject() ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -77,6 +77,8 @@ CurveBezier::Init( int nDeg, bool bIsRational)
m_vWeCtrl.clear() ; m_vWeCtrl.clear() ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -101,6 +103,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
// annullo analisi presenza singolarità // annullo analisi presenza singolarità
m_dParSing = - 2 ; m_dParSing = - 2 ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -126,6 +130,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
// annullo analisi presenza singolarità // annullo analisi presenza singolarità
m_dParSing = - 2 ; m_dParSing = - 2 ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -266,7 +272,7 @@ CurveBezier::Clone( void) const
bool bool
CurveBezier::CopyFrom( const IGeoObj* pGObjSrc) CurveBezier::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const CurveBezier* pCB = dynamic_cast<const CurveBezier*>( pGObjSrc) ; const CurveBezier* pCB = GetBasicCurveBezier( pGObjSrc) ;
if ( pCB == nullptr) if ( pCB == nullptr)
return false ; return false ;
return CopyFrom( *pCB) ; return CopyFrom( *pCB) ;
@@ -287,6 +293,8 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
m_dThick = cbSrc.m_dThick ; m_dThick = cbSrc.m_dThick ;
m_nTempProp[0] = cbSrc.m_nTempProp[0] ; m_nTempProp[0] = cbSrc.m_nTempProp[0] ;
m_nTempProp[1] = cbSrc.m_nTempProp[1] ; m_nTempProp[1] = cbSrc.m_nTempProp[1] ;
m_dTempParam[0] = cbSrc.m_dTempParam[0] ;
m_dTempParam[1] = cbSrc.m_dTempParam[1] ;
return true ; return true ;
} }
@@ -424,8 +432,24 @@ CurveBezier::Load( NgeReader& ngeIn)
bool bool
CurveBezier::Validate( void) 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) 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) ; return ( m_nStatus == OK) ;
} }
@@ -448,7 +472,7 @@ CurveBezier::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
else { else {
// costruisco una approssimazione lineare // costruisco una approssimazione lineare
PolyLine PL ; 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 ; return false ;
// ciclo sui punti della approssimazione // ciclo sui punti della approssimazione
Point3d ptTemp ; Point3d ptTemp ;
@@ -491,7 +515,7 @@ CurveBezier::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
else { else {
// costruisco una approssimazione lineare // costruisco una approssimazione lineare
PolyLine PL ; 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 ; return false ;
// ciclo sui punti della approssimazione // ciclo sui punti della approssimazione
Point3d ptTemp ; Point3d ptTemp ;
@@ -603,7 +627,7 @@ CurveBezier::GetMidPoint( Point3d& ptMid) const
return false ; return false ;
// determino il valore del parametro a metà lunghezza // determino il valore del parametro a metà lunghezza
double dLen, dMid ; double dLen, dMid ;
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid)) if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
return false ; return false ;
// calcolo il punto // calcolo il punto
return GetPointD1D2( dMid, ptMid) ; return GetPointD1D2( dMid, ptMid) ;
@@ -618,7 +642,7 @@ CurveBezier::GetCentroid( Point3d& ptCen) const
return false ; return false ;
// approssimo la curva con una polilinea // approssimo la curva con una polilinea
PolyLine PL ; 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 ; return false ;
// calcolo il centro mediante PolygonPlane // calcolo il centro mediante PolygonPlane
Point3d ptP ; Point3d ptP ;
@@ -640,7 +664,7 @@ CurveBezier::GetMidDir( Vector3d& vtDir) const
return false ; return false ;
// determino il valore del parametro a metà lunghezza // determino il valore del parametro a metà lunghezza
double dLen, dMid ; double dLen, dMid ;
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid)) if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
return false ; return false ;
// calcolo la direzione // calcolo la direzione
return ::GetTang( *this, dMid, FROM_MINUS, vtDir) ; return ::GetTang( *this, dMid, FROM_MINUS, vtDir) ;
@@ -1429,7 +1453,7 @@ CurveBezier::ApproxWithArcsXY( double dLinTol, double dAngTolDeg, PolyArc& PA) c
// costruisco una approssimazione lineare // costruisco una approssimazione lineare
PolyLine PL ; PolyLine PL ;
if ( ! ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, PL)) if ( ! ApproxWithLines( dLinTol, dAngTolDeg, APL_STD, PL))
return false ; return false ;
// approssimo la curva per approssimazioni successive mediante bisezione // approssimo la curva per approssimazioni successive mediante bisezione
@@ -1478,7 +1502,7 @@ CurveBezier::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAngTo
return false ; return false ;
if ( ! pCC->FromPolyLine( PL)) if ( ! pCC->FromPolyLine( PL))
return false ; return false ;
pCrv.Set( Release( pCC)) ; pCrv.Set( pCC) ;
dMaxDist = 0 ; dMaxDist = 0 ;
} }
// se la polilinea ha un solo punto, esco // se la polilinea ha un solo punto, esco
@@ -1590,6 +1614,8 @@ CurveBezier::Invert( void)
for ( int i = 0 ; i < nMid ; ++ i) for ( int i = 0 ; i < nMid ; ++ i)
swap( m_vPtCtrl[i], m_vPtCtrl[m_nDeg-i]) ; swap( m_vPtCtrl[i], m_vPtCtrl[m_nDeg-i]) ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1607,6 +1633,8 @@ CurveBezier::ModifyStart( const Point3d& ptNewStart)
// modifico il primo punto di controllo // modifico il primo punto di controllo
m_vPtCtrl[0] = ptNewStart ; m_vPtCtrl[0] = ptNewStart ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1624,6 +1652,8 @@ CurveBezier::ModifyEnd( const Point3d& ptNewEnd)
// modifico l'ultimo punto di controllo // modifico l'ultimo punto di controllo
m_vPtCtrl[m_nDeg] = ptNewEnd ; m_vPtCtrl[m_nDeg] = ptNewEnd ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1648,6 +1678,8 @@ CurveBezier::TrimStartAtParam( double dUTrim)
return false ; return false ;
} }
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1672,6 +1704,8 @@ CurveBezier::TrimEndAtParam( double dUTrim)
return false ; return false ;
} }
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1738,7 +1772,7 @@ CurveBezier::ExtendStartByLen( double dLenExt)
return false ; return false ;
// determino la lunghezza originale della curva // determino la lunghezza originale della curva
double dLen ; double dLen ;
if ( ! GetLength( dLen)) if ( ! GetLengthAtParam( 1, dLen))
return false ; return false ;
// stimo il valore del parametro al nuovo punto iniziale // stimo il valore del parametro al nuovo punto iniziale
double dUTrim = - dLenExt / dLen ; double dUTrim = - dLenExt / dLen ;
@@ -1772,6 +1806,9 @@ CurveBezier::ExtendStartByLen( double dLenExt)
m_vWeCtrl[i] = vWeCtrl[i] ; m_vWeCtrl[i] = vWeCtrl[i] ;
} }
} }
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
return true ; return true ;
@@ -1786,7 +1823,7 @@ CurveBezier::ExtendEndByLen( double dLenExt)
return false ; return false ;
// determino la lunghezza originale della curva // determino la lunghezza originale della curva
double dLen ; double dLen ;
if ( ! GetLength( dLen)) if ( ! GetLengthAtParam( 1, dLen))
return false ; return false ;
// stimo il valore del parametro al nuovo punto finale // stimo il valore del parametro al nuovo punto finale
double dUTrim = 1 + dLenExt / dLen ; double dUTrim = 1 + dLenExt / dLen ;
@@ -1820,6 +1857,9 @@ CurveBezier::ExtendEndByLen( double dLenExt)
m_vWeCtrl[i] = vWeCtrl[i] ; m_vWeCtrl[i] = vWeCtrl[i] ;
} }
} }
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
return true ; return true ;
@@ -1833,6 +1873,8 @@ CurveBezier::Translate( const Vector3d& vtMove)
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1855,6 +1897,8 @@ CurveBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
if ( vtAx.IsSmall()) if ( vtAx.IsSmall())
return false ; return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1897,6 +1941,8 @@ CurveBezier::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
if ( ! bOk) if ( ! bOk)
return false ; return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1926,6 +1972,8 @@ CurveBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall()) if ( vtNorm.IsSmall())
return false ; return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1950,6 +1998,8 @@ CurveBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
if ( vtNorm.IsSmall() || vtDir.IsSmall()) if ( vtNorm.IsSmall() || vtDir.IsSmall())
return false ; return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1974,11 +2024,16 @@ CurveBezier::ToGlob( const Frame3d& frRef)
// la curva deve essere validata // la curva deve essere validata
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico validità del frame // verifico validità del frame
if ( frRef.GetType() == Frame3d::ERR) if ( frRef.GetType() == Frame3d::ERR)
return false ; return false ;
// se frame identità, non devo fare alcunché
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -1998,11 +2053,16 @@ CurveBezier::ToLoc( const Frame3d& frRef)
// la curva deve essere validata // la curva deve essere validata
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico validità del frame // verifico validità del frame
if ( frRef.GetType() == Frame3d::ERR) if ( frRef.GetType() == Frame3d::ERR)
return false ; return false ;
// se frame identità, non devo fare alcunché
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -2022,11 +2082,16 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
// la curva deve essere validata // la curva deve essere validata
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// verifico validità dei frame // verifico validità dei frame
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR) if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
return false ; return false ;
// se i due riferimenti coincidono, non devo fare alcunché
if ( AreSameFrame( frOri, frDest))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -2038,3 +2103,42 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
return true ; 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 ;
}
+31 -16
View File
@@ -19,7 +19,8 @@
#include "DllMain.h" #include "DllMain.h"
#include "GeoObjRW.h" #include "GeoObjRW.h"
#include "/EgtDev/Include/EGkCurveBezier.h" #include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EgtNumCollection.h"
class Voronoi ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class CurveBezier : public ICurveBezier, public IGeoObjRW class CurveBezier : public ICurveBezier, public IGeoObjRW
@@ -56,6 +57,11 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // ICurve
bool IsSimple( void) const override { return true ; } bool IsSimple( void) const override { return true ; }
@@ -149,7 +155,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
public : public :
CurveBezier( void) ; CurveBezier( void) ;
CurveBezier( const CurveBezier& cbSrc) CurveBezier( const CurveBezier& cbSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( cbSrc)) { if ( ! CopyFrom( cbSrc))
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy constructor error")} LOG_ERROR( GetEGkLogger(), "CurveBezier : copy constructor error")}
CurveBezier& operator =( const CurveBezier& cbSrc) CurveBezier& operator =( const CurveBezier& cbSrc)
@@ -158,6 +164,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
return *this ; } return *this ; }
bool ApproxWithLines( int nStep, PolyLine& PL) const ; bool ApproxWithLines( int nStep, PolyLine& PL) const ;
bool GetApproxLength( double& dLen) const ; bool GetApproxLength( double& dLen) const ;
Voronoi* GetVoronoiObject( void) const ;
private : private :
bool CopyFrom( const CurveBezier& cbSrc) ; bool CopyFrom( const CurveBezier& cbSrc) ;
@@ -175,32 +182,40 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
bool BiArcOrSplit(int nLev, PolyLine& PL, 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& pol3P) const ;
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ; bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private : private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
static const int MAXDEG = 11 ; static const int MAXDEG = 11 ;
private : private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato Status m_nStatus ; // stato
int m_nDeg ; // grado int m_nDeg ; // grado
bool m_bRat ; // flag di razionale/polinomiale bool m_bRat ; // flag di razionale/polinomiale
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare) mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN) Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
} ; } ;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline CurveBezier* CreateBasicCurveBezier( void) inline CurveBezier* CreateBasicCurveBezier( void)
{ return (static_cast<CurveBezier*>( CreateGeoObj( CRV_BEZIER))) ; } { return ( static_cast<CurveBezier*>( CreateGeoObj( CRV_BEZIER))) ; }
inline CurveBezier* CloneBasicCurveBezier( const IGeoObj* pGObj) inline CurveBezier* CloneBasicCurveBezier( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER) { if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER)
return nullptr ; return nullptr ;
return (static_cast<CurveBezier*>(pGObj->Clone())) ; } return ( static_cast<CurveBezier*>( pGObj->Clone())) ; }
inline const CurveBezier* GetBasicCurveBezier( const IGeoObj* pGObj) 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) inline CurveBezier* GetBasicCurveBezier( IGeoObj* pGObj)
{ return (dynamic_cast<CurveBezier*>(pGObj)) ; } { if ( pGObj == nullptr || pGObj->GetType() != CRV_BEZIER)
return nullptr ;
return ( static_cast<CurveBezier*>( pGObj)) ; }
+69 -11
View File
@@ -17,6 +17,7 @@
#include "CalcDerivate.h" #include "CalcDerivate.h"
#include "BiArcs.h" #include "BiArcs.h"
#include "DistPointLine.h" #include "DistPointLine.h"
#include "RemoveCurveDefects.h"
#include "/EgtDev/Include/EGkCurveByApprox.h" #include "/EgtDev/Include/EGkCurveByApprox.h"
#include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPolyLine.h"
#include "/EgtDev/Include/EGkPolyArc.h" #include "/EgtDev/Include/EGkPolyArc.h"
@@ -56,28 +57,78 @@ ICurve*
CurveByApprox::GetCurve( int nType, double dLinTol, double dAngTolDeg, double dLinFea) CurveByApprox::GetCurve( int nType, double dLinTol, double dAngTolDeg, double dLinFea)
{ {
// se da approssimare con archi // se da approssimare con archi
if ( nType == ARCS_CORNER) { if ( nType == ARCS || nType == ARCS_CORNER) {
// calcolo approssimazione // calcolo approssimazione
PolyArc PA ; PolyArc PA ;
if ( ! GetArcs( dLinTol, dAngTolDeg, dLinFea, PA)) if ( nType == ARCS) {
return nullptr ; if ( ! GetArcs( dLinTol, dAngTolDeg, PA))
return nullptr ;
}
else {
if ( ! GetArcsCorner( dLinTol, dAngTolDeg, dLinFea, PA))
return nullptr ;
}
// creo la composita formata da questa approssimazione // creo la composita formata da questa approssimazione
PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ; PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ;
if ( ! pCC->FromPolyArc( PA)) if ( ! pCC->FromPolyArc( PA))
return nullptr ; return nullptr ;
// elimino eventuali Small Z
pCC->RemoveSmallDefects( dLinTol, dAngTolDeg) ;
// eventuale fusione di curve compatibili // eventuale fusione di curve compatibili
pCC->MergeCurves( dLinTol, dAngTolDeg) ; pCC->MergeCurves( dLinTol, dAngTolDeg) ;
// restituisco la curva // restituisco la curva
return Release( pCC) ; return Release( pCC) ;
} }
// altrimenti con curve di Bezier cubiche // altrimenti con curve di Bezier cubiche
// !!! NON ANCORA IMPLEMENTATA !!! else if ( nType == CUBIC_BEZIERS) {
// !!! NON ANCORA IMPLEMENTATA !!!
return nullptr ;
}
// tipi non previsti
return nullptr ; return nullptr ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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 // pulisco il poliarco
PA.Clear() ; PA.Clear() ;
@@ -102,9 +153,18 @@ CurveByApprox::GetArcs( double dLinTol, double dAngTolDeg, double dLinFea, PolyA
PolyLine PL ; PolyLine PL ;
for ( int j = nPrev ; j <= m_vSplits[i] ; ++ j) for ( int j = nPrev ; j <= m_vSplits[i] ; ++ j)
PL.AddUPoint( j, m_vPnt[j]) ; PL.AddUPoint( j, m_vPnt[j]) ;
// eseguo l'approssimazione con archi // verifico se retta verticale
if ( ! BiArcOrSplit( 0, PL, dLinTol, dAngTolDeg, PA)) BBox3d b3PL ;
if ( ! PL.GetLocalBBox( b3PL))
return false ; 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 // salvo fine come prox inizio
nPrev = m_vSplits[i] ; nPrev = m_vSplits[i] ;
} }
@@ -453,11 +513,9 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
return true ; return true ;
// costruisco la retta che li unisce // costruisco la retta che li unisce
PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ; PtrOwner<CurveComposite> pCC( CreateBasicCurveComposite()) ;
if ( IsNull( pCC)) if ( IsNull( pCC) || ! pCC->FromPolyLine( PL))
return false ; return false ;
if ( ! pCC->FromPolyLine( PL)) pCrv.Set( pCC) ;
return false ;
pCrv.Set( Release( pCC)) ;
dMaxDist = 0 ; dMaxDist = 0 ;
} }
// se la polilinea ha un solo punto, esco // se la polilinea ha un solo punto, esco
+6 -6
View File
@@ -14,10 +14,10 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "CalcDerivate.h" #include "CalcDerivate.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "/EgtDev/Include/EGkCurveByInterp.h" #include "/EgtDev/Include/EGkCurveByInterp.h"
#include "/EgtDev/Include/EgkCurveComposite.h" #include "/EgtDev/Include/EGkBiArcs.h"
#include "/EgtDev/Include/EgkBiArcs.h"
#include "/EgtDev/Include/EgkCurveBezier.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
@@ -63,7 +63,7 @@ CurveByInterp::GetCurve( int nMethod, int nType)
// se richiesti biarchi // se richiesti biarchi
if ( nType == BIARCS) { if ( nType == BIARCS) {
// creo la curva composita // creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ; PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo)) if ( IsNull( pCrvCompo))
return nullptr ; return nullptr ;
// ciclo sugli intervalli // ciclo sugli intervalli
@@ -83,13 +83,13 @@ CurveByInterp::GetCurve( int nMethod, int nType)
// se richieste curve di Bezier cubiche // se richieste curve di Bezier cubiche
if ( nType == CUBIC_BEZIERS) { if ( nType == CUBIC_BEZIERS) {
// creo la curva composita // creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ; PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo)) if ( IsNull( pCrvCompo))
return nullptr ; return nullptr ;
// ciclo sugli intervalli // ciclo sugli intervalli
for ( int i = 1 ; i < int( m_vPnt.size()) ; ++ i) { for ( int i = 1 ; i < int( m_vPnt.size()) ; ++ i) {
// creo una curva di Bezier cubica per ogni intervallo // creo una curva di Bezier cubica per ogni intervallo
PtrOwner<ICurveBezier> pCBez( CreateCurveBezier()) ; PtrOwner<CurveBezier> pCBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCBez)) if ( IsNull( pCBez))
return nullptr ; return nullptr ;
pCBez->Init( 3, false) ; pCBez->Init( 3, false) ;
+577 -89
View File
File diff suppressed because it is too large Load Diff
+74 -19
View File
@@ -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. // Contenuto : Dichiarazione della classe Curva composita.
// //
// //
// //
// Modifiche : 16.04.13 DS Creazione modulo. // Modifiche : 16.04.13 DS Creazione modulo.
// 24.03.22 DS Aggiunto metodo AddLineTg.
// //
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -20,6 +21,8 @@
#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkCurveComposite.h"
#include <deque> #include <deque>
class Voronoi ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class CurveComposite : public ICurveComposite, public IGeoObjRW class CurveComposite : public ICurveComposite, public IGeoObjRW
{ {
@@ -55,6 +58,11 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // ICurve
bool IsSimple( void) const override bool IsSimple( void) const override
@@ -144,8 +152,9 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
bool ChangeStartPoint( double dU) override ; bool ChangeStartPoint( double dU) override ;
bool AddPoint( const Point3d& ptStart) override ; bool AddPoint( const Point3d& ptStart) override ;
bool AddLine( const Point3d& ptNew, bool bEndOrStart = true) override ; 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 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 AddJoint( double dU) override ;
bool ModifyJoint( int nU, const Point3d& ptNewJoint) override ; bool ModifyJoint( int nU, const Point3d& ptNewJoint) override ;
bool RemoveJoint( int nU) override ; bool RemoveJoint( int nU) override ;
@@ -154,13 +163,20 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
bool ModifyCurveToLine( int nCrv) override ; bool ModifyCurveToLine( int nCrv) override ;
bool ArcsToBezierCurves( void) override ; bool ArcsToBezierCurves( void) override ;
bool ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDeg) 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 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 RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ;
bool IsAPoint( void) const override ; bool IsAPoint( void) const override ;
bool IsALine( double dLinTol, Point3d& ptStart, Point3d& ptEnd) 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 IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ;
bool SetCurveTempProp( int nCrv, int nProp, int nPropNum = 0) override ; bool IsARectangle( double dLinTol, Point3d& ptP, Vector3d& vtL1, Vector3d& vtL2) const override ;
bool GetCurveTempProp( int nCrv, int& nProp, int nPropNum = 0) 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 ;
public : // IGeoObjRW public : // IGeoObjRW
int GetNgeId( void) const override ; int GetNgeId( void) const override ;
@@ -169,7 +185,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
public : public :
CurveComposite( void) ; CurveComposite( void) ;
CurveComposite( const CurveComposite& ccSrc) CurveComposite( const CurveComposite& ccSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( ccSrc)) { if ( ! CopyFrom( ccSrc))
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy constructor error") } LOG_ERROR( GetEGkLogger(), "CurveComposite : copy constructor error") }
CurveComposite& operator =( const CurveComposite& ccSrc) CurveComposite& operator =( const CurveComposite& ccSrc)
@@ -178,43 +194,82 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
return *this ; } return *this ; }
bool RelocateFrom( CurveComposite& ccSrc) ; bool RelocateFrom( CurveComposite& ccSrc) ;
bool GetApproxLength( double& dLen) const ; bool GetApproxLength( double& dLen) const ;
Voronoi* GetVoronoiObject( void) const ;
private : private :
bool CopyFrom( const CurveComposite& ccSrc) ; bool CopyFrom( const CurveComposite& ccSrc) ;
bool Validate( void) ; bool Validate( void) ;
bool TestClosure( void) ;
bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ; bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
bool AddSimpleCurve( ICurve* pSmplCrv, 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 GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ;
bool SimpleOffsetXY( double dDist, int nType = OFF_FILLET) ; 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 ;
void ResetVoronoiObject( void) const ;
private : private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
private : private :
typedef std::deque<ICurve*> PCRVSMPL_DEQUE ; typedef std::deque<ICurve*> PCRVSMPL_DEQUE ;
typedef PCRVSMPL_DEQUE::iterator PCSD_ITER ;
typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ; typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ;
private : private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato Status m_nStatus ; // stato
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN) Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore double m_dThick ; // spessore
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
int m_nTempProp[2] ; // vettore proprietà temporanee int m_nTempProp[2] ; // vettore proprietà temporanee
mutable PCSD_CONST_ITER m_Iter ; // iteratore double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
mutable PCSD_CONST_ITER m_Iter ; // iteratore
} ; } ;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline CurveComposite* CreateBasicCurveComposite( void) inline CurveComposite* CreateBasicCurveComposite( void)
{ return (static_cast<CurveComposite*>( CreateGeoObj( CRV_COMPO))) ; } { return ( static_cast<CurveComposite*>( CreateGeoObj( CRV_COMPO))) ; }
inline CurveComposite* CloneBasicCurveComposite( const IGeoObj* pGObj) inline CurveComposite* CloneBasicCurveComposite( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_COMPO) { if ( pGObj == nullptr || pGObj->GetType() != CRV_COMPO)
return nullptr ; return nullptr ;
return (static_cast<CurveComposite*>(pGObj->Clone())) ; } return ( static_cast<CurveComposite*>( pGObj->Clone())) ; }
inline const CurveComposite* GetBasicCurveComposite( const IGeoObj* pGObj) 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) 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 ;
}
+2 -2
View File
@@ -17,8 +17,8 @@
#include "CurveLine.h" #include "CurveLine.h"
#include "CurveArc.h" #include "CurveArc.h"
#include "GeoConst.h" #include "GeoConst.h"
#include "/EgtDev/Include/EgkCurve.h" #include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EgkIntersCurves.h" #include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; using namespace std ;
+99 -11
View File
@@ -18,7 +18,9 @@
#include "GeoObjFactory.h" #include "GeoObjFactory.h"
#include "NgeWriter.h" #include "NgeWriter.h"
#include "NgeReader.h" #include "NgeReader.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <new> #include <new>
@@ -29,15 +31,15 @@ GEOOBJ_REGISTER( CRV_LINE, NGE_C_LIN, CurveLine) ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CurveLine::CurveLine( void) CurveLine::CurveLine( void)
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick() : 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)
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[0] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
CurveLine::~CurveLine( void) CurveLine::~CurveLine( void)
{ {
ResetVoronoiObject() ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -49,6 +51,8 @@ CurveLine::Set( const Point3d& ptStart, const Point3d& ptEnd)
m_PtEnd = ptEnd ; m_PtEnd = ptEnd ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -68,6 +72,8 @@ CurveLine::SetPVL( const Point3d& ptStart, const Vector3d& vtDir, double dLen)
m_PtEnd = ptStart + vtDelta ; m_PtEnd = ptStart + vtDelta ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -85,6 +91,8 @@ CurveLine::SetPDL( const Point3d& ptStart, double dDirAngDeg, double dLen)
m_PtEnd = ptStart + vtDelta ; m_PtEnd = ptStart + vtDelta ;
m_nStatus = TO_VERIFY ; m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -111,7 +119,7 @@ CurveLine::Clone( void) const
bool bool
CurveLine::CopyFrom( const IGeoObj* pGObjSrc) CurveLine::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const CurveLine* pCL = dynamic_cast<const CurveLine*>( pGObjSrc) ; const CurveLine* pCL = GetBasicCurveLine( pGObjSrc) ;
if ( pCL == nullptr) if ( pCL == nullptr)
return false ; return false ;
return CopyFrom( *pCL) ; return CopyFrom( *pCL) ;
@@ -127,6 +135,8 @@ CurveLine::CopyFrom( const CurveLine& clSrc)
m_dThick = clSrc.m_dThick ; m_dThick = clSrc.m_dThick ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ; m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ; 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) ; return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ;
} }
@@ -259,7 +269,7 @@ bool
CurveLine::Validate( void) CurveLine::Validate( void)
{ {
if ( m_nStatus == TO_VERIFY) 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) ; return ( m_nStatus == OK) ;
} }
@@ -356,10 +366,7 @@ CurveLine::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d* pvtDer1,
return false ; return false ;
// il parametro U deve essere compreso tra 0 e 1 // il parametro U deve essere compreso tra 0 e 1
if ( dU < 0) dU = Clamp( dU, 0., 1.) ;
dU = 0 ;
else if ( dU > 1)
dU = 1 ;
// calcolo del punto // calcolo del punto
ptPos = Media( m_PtStart, m_PtEnd, dU) ; ptPos = Media( m_PtStart, m_PtEnd, dU) ;
@@ -560,6 +567,8 @@ CurveLine::Invert( void)
// inverto i punti estremi // inverto i punti estremi
swap( m_PtStart, m_PtEnd) ; swap( m_PtStart, m_PtEnd) ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -591,6 +600,8 @@ CurveLine::SimpleOffset( double dDist, int nType)
m_PtStart += vtDir * dDist ; m_PtStart += vtDir * dDist ;
m_PtEnd += vtDir * dDist ; m_PtEnd += vtDir * dDist ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -611,6 +622,8 @@ CurveLine::ModifyStart( const Point3d& ptNewStart)
// assegno il nuovo inizio // assegno il nuovo inizio
m_PtStart = ptNewStart ; m_PtStart = ptNewStart ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -631,6 +644,8 @@ CurveLine::ModifyEnd( const Point3d& ptNewEnd)
// assegno la nuova fine // assegno la nuova fine
m_PtEnd = ptNewEnd ; m_PtEnd = ptNewEnd ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -642,7 +657,7 @@ bool
CurveLine::TrimStartAtParam( double dUTrim) CurveLine::TrimStartAtParam( double dUTrim)
{ {
// riporto i parametri nel loro range // riporto i parametri nel loro range
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ; dUTrim = Clamp( dUTrim, 0., 1.) ;
// recupero lunghezza // recupero lunghezza
double dLen ; double dLen ;
@@ -658,7 +673,7 @@ bool
CurveLine::TrimEndAtParam( double dUTrim) CurveLine::TrimEndAtParam( double dUTrim)
{ {
// riporto i parametri nel loro range // riporto i parametri nel loro range
dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ; dUTrim = Clamp( dUTrim, 0., 1.) ;
// recupero lunghezza // recupero lunghezza
double dLen ; double dLen ;
@@ -706,6 +721,8 @@ CurveLine::TrimStartAtLen( double dLenTrim)
if ( dLenTrim > EPS_ZERO) if ( dLenTrim > EPS_ZERO)
m_PtStart = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ; 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 // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -730,6 +747,8 @@ CurveLine::TrimEndAtLen( double dLenTrim)
if ( ( dLen - dLenTrim) > EPS_ZERO) if ( ( dLen - dLenTrim) > EPS_ZERO)
m_PtEnd = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ; 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 // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -752,6 +771,8 @@ CurveLine::ExtendStartByLen( double dLenExt)
// sposto il punto iniziale // sposto il punto iniziale
m_PtStart -= vtDir * dLenExt ; m_PtStart -= vtDir * dLenExt ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -774,6 +795,8 @@ CurveLine::ExtendEndByLen( double dLenExt)
// sposto il punto finale // sposto il punto finale
m_PtEnd += vtDir * dLenExt ; m_PtEnd += vtDir * dLenExt ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata // con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -787,6 +810,9 @@ CurveLine::Translate( const Vector3d& vtMove)
// la curva deve essere validata // la curva deve essere validata
if ( m_nStatus != OK) if ( m_nStatus != OK)
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -808,6 +834,8 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do
if ( vtAx.IsSmall()) if ( vtAx.IsSmall())
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -839,6 +867,8 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d
if ( AreSamePointApprox( ptNewStart, ptNewEnd)) if ( AreSamePointApprox( ptNewStart, ptNewEnd))
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -868,6 +898,8 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall()) if ( vtNorm.IsSmall())
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -891,6 +923,8 @@ CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& v
if ( vtNorm.IsSmall() || vtDir.IsSmall()) if ( vtNorm.IsSmall() || vtDir.IsSmall())
return false ; return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -919,6 +953,12 @@ CurveLine::ToGlob( const Frame3d& frRef)
if ( frRef.GetType() == Frame3d::ERR) if ( frRef.GetType() == Frame3d::ERR)
return false ; return false ;
// se frame identità, non devo fare alcunché
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -937,6 +977,12 @@ CurveLine::ToLoc( const Frame3d& frRef)
if ( frRef.GetType() == Frame3d::ERR) if ( frRef.GetType() == Frame3d::ERR)
return false ; return false ;
// se frame identità, non devo fare alcunché
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -954,10 +1000,13 @@ CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
// verifico validità dei frame // verifico validità dei frame
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR) if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
return false ; return false ;
// se i due riferimenti coincidono, non devo fare alcunché // se i due riferimenti coincidono, non devo fare alcunché
if ( AreSameFrame( frOri, frDest)) if ( AreSameFrame( frOri, frDest))
return true ; return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
@@ -993,3 +1042,42 @@ CurveLine::CalcPointParamPosiz( const Point3d& ptP, bool bOnXY, double& dU, int&
nPos = ICurve::PP_MID ; // nell'interno nPos = ICurve::PP_MID ; // nell'interno
return true ; 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 ;
}
+28 -12
View File
@@ -19,6 +19,8 @@
#include "GeoObjRW.h" #include "GeoObjRW.h"
#include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveLine.h"
class Voronoi ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class CurveLine : public ICurveLine, public IGeoObjRW class CurveLine : public ICurveLine, public IGeoObjRW
{ {
@@ -54,6 +56,11 @@ class CurveLine : public ICurveLine, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // ICurve
bool IsSimple( void) const override bool IsSimple( void) const override
@@ -143,39 +150,48 @@ class CurveLine : public ICurveLine, public IGeoObjRW
public : public :
CurveLine( void) ; CurveLine( void) ;
CurveLine( const CurveLine& clSrc) CurveLine( const CurveLine& clSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( clSrc)) { if ( ! CopyFrom( clSrc))
LOG_ERROR( GetEGkLogger(), "CurveLine : copy constructor error") } LOG_ERROR( GetEGkLogger(), "CurveLine : copy constructor error") }
CurveLine& operator =( const CurveLine& clSrc) CurveLine& operator =( const CurveLine& clSrc)
{ if ( ! CopyFrom( clSrc)) { if ( ! CopyFrom( clSrc))
LOG_ERROR( GetEGkLogger(), "CurveLine : copy error") LOG_ERROR( GetEGkLogger(), "CurveLine : copy error")
return *this ; } return *this ; }
Voronoi* GetVoronoiObject( void) const ;
private : private :
bool CopyFrom( const CurveLine& clSrc) ; bool CopyFrom( const CurveLine& clSrc) ;
bool Validate( void) ; bool Validate( void) ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private : private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
private : private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato Status m_nStatus ; // stato
Point3d m_PtStart ; // punto iniziale Point3d m_PtStart ; // punto iniziale
Point3d m_PtEnd ; // punto finale Point3d m_PtEnd ; // punto finale
Vector3d m_VtExtr ; // vettore estrusione Vector3d m_VtExtr ; // vettore estrusione
double m_dThick ; // spessore double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
} ; } ;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline CurveLine* CreateBasicCurveLine( void) inline CurveLine* CreateBasicCurveLine( void)
{ return (static_cast<CurveLine*>( CreateGeoObj( CRV_LINE))) ; } { return ( static_cast<CurveLine*>( CreateGeoObj( CRV_LINE))) ; }
inline CurveLine* CloneBasicCurveLine( const IGeoObj* pGObj) inline CurveLine* CloneBasicCurveLine( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE) { if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
return nullptr ; return nullptr ;
return (static_cast<CurveLine*>(pGObj->Clone())) ; } return ( static_cast<CurveLine*>( pGObj->Clone())) ; }
inline const CurveLine* GetBasicCurveLine( const IGeoObj* pGObj) 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) inline CurveLine* GetBasicCurveLine( IGeoObj* pGObj)
{ return (dynamic_cast<CurveLine*>(pGObj)) ; } { if ( pGObj == nullptr || pGObj->GetType() != CRV_LINE)
return nullptr ;
return ( static_cast<CurveLine*>( pGObj)) ; }
+102 -98
View File
@@ -1,13 +1,13 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2020-2020 // EgalTech 2020-2022
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : DistLineLine.h Data : 06.11.20 Versione : 2.2k1 // File : DistLineLine.h Data : 12.08.22 Versione : 2.4h1
// Contenuto : Implementazione della classe distanza fra elementi lineari. // Contenuto : Implementazione della classe distanza fra elementi lineari.
// //
// //
// //
// Modifiche : 06.11.20 LM Creazione modulo. // Modifiche : 06.11.20 LM Creazione modulo.
// // 12.08.22 DS Correzioni e migliorie varie.
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -18,22 +18,26 @@
#include "/EgtDev/Include/EGkGeoConst.h" #include "/EgtDev/Include/EGkGeoConst.h"
#include <algorithm> #include <algorithm>
using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DistLineLine::DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1, DistLineLine::DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1,
const Point3d& ptSt2, const Point3d& ptEn2, const Point3d& ptSt2, const Point3d& ptEn2,
bool bIsSegment1, bool bIsSegment2) bool bIsSegment1, bool bIsSegment2)
{ {
// reset oggetto
m_dSqDist = - 1 ;
m_dDist = - 1 ;
// calcolo direzione segmenti
Vector3d vtD1 = ptEn1 - ptSt1 ; Vector3d vtD1 = ptEn1 - ptSt1 ;
double dLen1 = vtD1.Len() ; double dLen1 = vtD1.Len() ;
Vector3d vtD2 = ptEn2 - ptSt2 ; Vector3d vtD2 = ptEn2 - ptSt2 ;
double dLen2 = vtD1.Len() ; double dLen2 = vtD2.Len() ;
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) { if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL)
m_dSqDist = - 1 ;
m_dDist = - 1 ;
return ; return ;
}
vtD1 /= dLen1 ; vtD1 /= dLen1 ;
vtD2 /= dLen2 ; vtD2 /= dLen2 ;
// eseguo
Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ; Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ;
} }
@@ -43,37 +47,43 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2, const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
bool bIsSegment1, bool bIsSegment2) bool bIsSegment1, bool bIsSegment2)
{ {
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) { // reset oggetto
m_dSqDist = - 1 ; m_dSqDist = - 1 ;
m_dDist = - 1 ; m_dDist = - 1 ;
// verifico segmenti
if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL)
return ; return ;
} // eseguo
Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ; Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistLineLine::GetSqDist( double& dSqDist) DistLineLine::GetSqDist( double& dSqDist) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
dSqDist = m_dSqDist ; dSqDist = m_dSqDist ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistLineLine::GetDist( double& dDist) DistLineLine::GetDist( double& dDist) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
dDist = sqrt( m_dSqDist) ;
if ( m_dDist < 0)
m_dDist = sqrt( m_dSqDist) ;
dDist = m_dDist ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
@@ -84,55 +94,48 @@ DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistLineLine::GetParamsAtMinDistPoints( double& dPar1, double& dPar2) DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
dPar1 = m_dPar1 ; dPos1 = m_dPos1 ;
dPar2 = m_dPar2 ; dPos2 = m_dPos2 ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Calcola la distanza fra i due elemnti lineari, i punti di minima distanza e // Calcola la distanza fra i due elementi lineari, i punti di minima distanza e le loro posizioni.
// i loro rispettivi parametri. // Se i due elementi sono paralleli i punti di minimo sono scelti secondo convenienza.
// Se la coppia di punti di minima distanza non è unica ne viene scelta una
// in base a comodità di calcolo.
void void
DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1, DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2, const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
bool bIsSegment1, bool bIsSegment2) bool bIsSegment1, bool bIsSegment2)
{ {
// Caso di elementi lineari paralleli/antiparalleli // Se elementi paralleli o antiparalleli
if ( AreSameOrOppositeVectorExact( vtD1, vtD2)) { if ( AreSameOrOppositeVectorExact( vtD1, vtD2)) {
// Almeno un elemento è una retta // Se il primo elemento è una retta infinita
if ( ! ( bIsSegment1 && bIsSegment2)) { if ( ! bIsSegment1) {
// Il primo elemento è segmento, quindi deve essere una retta il secondo Vector3d vtStSt = ptSt2 - ptSt1 ;
if ( bIsSegment1) { double dLong = vtStSt * vtD1 ;
Vector3d vtStSt = ptSt1 - ptSt2 ; Vector3d vtDist = vtStSt - dLong * vtD1 ;
double dLong = vtStSt * vtD2 ; m_dSqDist = vtDist.SqLen() ;
Vector3d vtDist = vtStSt - dLong * vtD2 ; m_dPos1 = dLong ;
m_dSqDist = vtDist.SqLen() ; m_dPos2 = 0 ;
m_dDist = sqrt( m_dSqDist) ; m_ptMinDist1 = ptSt1 + dLong * vtD1 ;
m_dPar1 = 0 ; m_ptMinDist2 = ptSt2 ;
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 ;
}
} }
// Entrambi gli elementi sono segmenti // 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 ;
}
// altrimenti entrambi gli elementi sono segmenti
else { else {
Point3d ptEn1 = ptSt1 + dLen1 * vtD1 ; Point3d ptEn1 = ptSt1 + dLen1 * vtD1 ;
Point3d ptEn2 = ptSt2 + dLen2 * vtD2 ; Point3d ptEn2 = ptSt2 + dLen2 * vtD2 ;
@@ -140,7 +143,7 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen
Vector3d vtStEn = ptEn2 - ptSt1 ; Vector3d vtStEn = ptEn2 - ptSt1 ;
double dStU = vtStSt * vtD1 ; double dStU = vtStSt * vtD1 ;
double dEnU = vtStEn * 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. // coordinata rispetto all'ordinamento generato dal primo.
double dMinPar, dMaxPar ; double dMinPar, dMaxPar ;
Point3d ptMinPar, ptMaxPar ; Point3d ptMinPar, ptMaxPar ;
@@ -159,70 +162,71 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen
// Possibili posizioni reciproche dei segmenti // Possibili posizioni reciproche dei segmenti
if ( dMinPar > dLen1) { if ( dMinPar > dLen1) {
m_dSqDist = SqDist( ptEn1, ptMinPar) ; m_dSqDist = SqDist( ptEn1, ptMinPar) ;
m_dDist = sqrt( m_dSqDist) ;
m_ptMinDist1 = ptEn1 ; m_ptMinDist1 = ptEn1 ;
m_ptMinDist2 = ptMinPar ; m_ptMinDist2 = ptMinPar ;
m_dPar1 = dLen1 ; m_dPos1 = dLen1 ;
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ; m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
} }
else if ( dMinPar > 0) { else if ( dMinPar > 0) {
m_dSqDist = std::max( vtStSt * vtStSt - dStU * dStU, 0.) ; m_dSqDist = max( vtStSt * vtStSt - dStU * dStU, 0.) ;
m_dDist = sqrt( m_dSqDist) ;
m_ptMinDist1 = ptSt1 + dMinPar * vtD1 ; m_ptMinDist1 = ptSt1 + dMinPar * vtD1 ;
m_ptMinDist2 = ptMinPar ; m_ptMinDist2 = ptMinPar ;
m_dPar1 = dMinPar ; m_dPos1 = dMinPar ;
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ; m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
} }
else if ( dMaxPar > 0) { else if ( dMaxPar > 0) {
m_dSqDist = std::max( vtStSt * vtStSt - dStU * dStU, 0.) ; m_dSqDist = max( vtStSt * vtStSt - dStU * dStU, 0.) ;
m_dDist = sqrt( m_dSqDist) ;
m_ptMinDist1 = ptSt1 ; m_ptMinDist1 = ptSt1 ;
m_ptMinDist2 = ptSt2 + ( ptSt1 - ptSt2) * vtD2 * vtD2 ; m_ptMinDist2 = ptSt2 + ( ptSt1 - ptSt2) * vtD2 * vtD2 ;
m_dPar1 = 0 ; m_dPos1 = 0 ;
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ; m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
} }
else { else {
m_dSqDist = SqDist( ptSt1, ptMaxPar) ; m_dSqDist = SqDist( ptSt1, ptMaxPar) ;
m_dDist = sqrt( m_dSqDist) ;
m_ptMinDist1 = ptSt1 ; m_ptMinDist1 = ptSt1 ;
m_ptMinDist2 = ptMaxPar ; m_ptMinDist2 = ptMaxPar ;
m_dPar1 = 0 ; m_dPos1 = 0 ;
m_dPar2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ; m_dPos2 = Clamp( ( m_ptMinDist2 - ptSt2) * vtD2, 0., dLen2) ;
} }
} }
return ;
} }
// Caso generale // Caso generale
Vector3d vtDist0 = ptSt2 - ptSt1 ; else {
double dDist01 = vtDist0 * vtD1 ; // Posizioni a distanza minima tra rette illimitate
double dDist02 = vtDist0 * vtD2 ; Vector3d vtStSt = ptSt2 - ptSt1 ;
double dDotD1D2 = vtD1 * vtD2 ; double dDist01 = vtStSt * vtD1 ;
double dT1 = dDist01 + ( ( dDist01 * dDotD1D2 - dDist02) * dDotD1D2) / ( 1 - dDotD1D2 * dDotD1D2) ; double dDist02 = vtStSt * vtD2 ;
double dT2 = ( dDist01 * dDotD1D2 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ; double dDotD1D2 = vtD1 * vtD2 ;
double dMin1 = - INFINITO ; double dT1 = ( dDist01 - dDotD1D2 * dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
double dMax1 = INFINITO ; double dT2 = ( dDotD1D2 * dDist01 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ;
double dMin2 = - INFINITO ; // Posizioni minime e massime sui segmenti
double dMax2 = INFINITO ; double dMin1 = ( bIsSegment1 ? 0 : -INFINITO) ;
double dSt1On2 = ( ptSt1 - ptSt2) * vtD2 ; double dMax1 = ( bIsSegment1 ? dLen1 : INFINITO) ;
double dEn1On2 = ( ptSt1 + dLen1 * vtD1 - ptSt2) * vtD2 ; double dMin2 = ( bIsSegment2 ? 0 : -INFINITO) ;
if ( bIsSegment1) { double dMax2 = ( bIsSegment2 ? dLen2 : INFINITO) ;
dMin1 = 0 ; // Se entrambe le posizioni stanno nei segmenti
dMax1 = dLen1 ; if ( dT1 >= dMin1 && dT1 <= dMax1 && dT2 >= dMin2 && dT2 <= dMax2) {
dMin2 = std::min( dSt1On2, dEn1On2) ; m_dPos1 = dT1 ;
dMax2 = std::max( dSt1On2, dEn1On2) ; 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) ;
} }
+14 -14
View File
@@ -28,26 +28,26 @@ class DistLineLine
bool bIsSegment1 = true, bool bIsSegment2 = true) ; bool bIsSegment1 = true, bool bIsSegment2 = true) ;
public : public :
bool GetSqDist( double& dSqDist) ; bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) ; bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) { bool IsEpsilon( double dTol) const
double dSqDist ; { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; bool IsSmall( void) const
} { return IsEpsilon( EPS_SMALL) ; }
bool IsSmall( void) { return IsEpsilon( EPS_SMALL) ; } bool IsZero( void) const
bool IsZero( void) { return IsEpsilon( EPS_ZERO) ; } { return IsEpsilon( EPS_ZERO) ; }
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) ; bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const ;
bool GetParamsAtMinDistPoints( double& dPar1, double& dPar2) ; bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const ;
private : private :
void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1, void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2, const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
bool bIsSegment1 = true, bool bIsSegment2 = true) ; bool bIsSegment1, bool bIsSegment2) ;
private: private:
double m_dSqDist ; double m_dSqDist ;
double m_dDist ; mutable double m_dDist ;
double m_dPar1 ; double m_dPos1 ;
double m_dPar2 ; double m_dPos2 ;
Point3d m_ptMinDist1 ; Point3d m_ptMinDist1 ;
Point3d m_ptMinDist2 ; Point3d m_ptMinDist2 ;
} ; } ;
+5 -6
View File
@@ -122,14 +122,13 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
// cerco la minima distanza per la polilinea // cerco la minima distanza per la polilinea
MDCVECTOR vApproxMin ; MDCVECTOR vApproxMin ;
MDCVECTOR::iterator Iter ;
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin)) if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
return ; return ;
// raffino i punti trovati // raffino i punti trovati
double dPolishedPar ; double dPolishedPar ;
Point3d ptPolishedQ ; Point3d ptPolishedQ ;
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
// eseguo raffinamento // eseguo raffinamento
if ( PolishMinDistPointCurve( ptP, arArc, *Iter, dPolishedPar, ptPolishedQ)) { if ( PolishMinDistPointCurve( ptP, arArc, *Iter, dPolishedPar, ptPolishedQ)) {
(*Iter).dDist = Dist( ptP, ptPolishedQ) ; (*Iter).dDist = Dist( ptP, ptPolishedQ) ;
@@ -148,7 +147,7 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointArc::GetSqDist( double& dSqDist) DistPointArc::GetSqDist( double& dSqDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -159,7 +158,7 @@ DistPointArc::GetSqDist( double& dSqDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointArc::GetDist( double& dDist) DistPointArc::GetDist( double& dDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -170,7 +169,7 @@ DistPointArc::GetDist( double& dDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -185,7 +184,7 @@ DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
+9 -8
View File
@@ -27,17 +27,18 @@ class DistPointArc
DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ; DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ;
public : public :
bool GetSqDist( double& dSqDist) ; bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) ; bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void) bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; } { return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void) bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; } { return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) { return (int) m_Info.size() ; } int GetNbrMinDist( void) const
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ; { return (int) m_Info.size() ; }
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ; bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
private : private :
DistPointArc( void) ; DistPointArc( void) ;
+1 -4
View File
@@ -156,13 +156,10 @@ bool
FilterMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve, FilterMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve,
const MDCVECTOR& vApproxMin, double& dMinDist, MDPCIVECTOR& Info) const MDCVECTOR& vApproxMin, double& dMinDist, MDPCIVECTOR& Info)
{ {
MDCVECTOR::const_iterator Iter ;
// determino i minimi raffinati da tenere // determino i minimi raffinati da tenere
bool bFound = false ; bool bFound = false ;
bool bLastOnEnd = false ; // flag per ultimo punto su fine del suo intervallo 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 // altro punto con la stessa minima distanza
if ( bFound && abs( (*Iter).dDist - dMinDist) < EPS_SMALL) { if ( bFound && abs( (*Iter).dDist - dMinDist) < EPS_SMALL) {
// se abbastanza lontano e non su bordi intervallino lo aggiungo // se abbastanza lontano e non su bordi intervallino lo aggiungo
+6 -7
View File
@@ -44,7 +44,6 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
// cerco la minima distanza per la polilinea // cerco la minima distanza per la polilinea
MDCVECTOR vApproxMin ; MDCVECTOR vApproxMin ;
MDCVECTOR::iterator Iter ;
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin)) if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
return ; return ;
@@ -52,7 +51,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
double dSingP ; double dSingP ;
if ( CrvBez.GetSingularParam( dSingP) == 0) if ( CrvBez.GetSingularParam( dSingP) == 0)
dSingP = - 1 ; 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 // imposto flag per singolarità agli estremi
(*Iter).bParMinSing = abs( (*Iter).dParMin - dSingP) < EPS_SMALL ; (*Iter).bParMinSing = abs( (*Iter).dParMin - dSingP) < EPS_SMALL ;
(*Iter).bParMaxSing = abs( (*Iter).dParMax - 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 // raffino i punti trovati
double dPolishedPar ; double dPolishedPar ;
Point3d ptPolishedQ ; Point3d ptPolishedQ ;
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
// eseguo raffinamento // eseguo raffinamento
if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) { if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) {
(*Iter).dDist = Dist( ptP, ptPolishedQ) ; (*Iter).dDist = Dist( ptP, ptPolishedQ) ;
@@ -80,7 +79,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvBezier::GetSqDist( double& dSqDist) DistPointCrvBezier::GetSqDist( double& dSqDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -91,7 +90,7 @@ DistPointCrvBezier::GetSqDist( double& dSqDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvBezier::GetDist( double& dDist) DistPointCrvBezier::GetDist( double& dDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -102,7 +101,7 @@ DistPointCrvBezier::GetDist( double& dDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -117,7 +116,7 @@ DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
+9 -8
View File
@@ -27,17 +27,18 @@ class DistPointCrvBezier
DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& CrvBez) ; DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& CrvBez) ;
public : public :
bool GetSqDist( double& dSqDist) ; bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) ; bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void) bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; } { return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void) bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; } { return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) { return (int) m_Info.size() ; } int GetNbrMinDist( void) const
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ; { return (int) m_Info.size() ; }
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ; bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
private : private :
DistPointCrvBezier( void) ; DistPointCrvBezier( void) ;
+16 -6
View File
@@ -89,8 +89,18 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
} }
} }
// altrimenti aggiungo // altrimenti aggiungo
else else {
m_Info.push_back( aInfo) ; 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 // passo al successivo
++ i ; ++ i ;
} }
@@ -119,7 +129,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvComposite::GetSqDist( double& dSqDist) DistPointCrvComposite::GetSqDist( double& dSqDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -130,7 +140,7 @@ DistPointCrvComposite::GetSqDist( double& dSqDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvComposite::GetDist( double& dDist) DistPointCrvComposite::GetDist( double& dDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -141,7 +151,7 @@ DistPointCrvComposite::GetDist( double& dDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -156,7 +166,7 @@ DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
+9 -8
View File
@@ -26,17 +26,18 @@ class DistPointCrvComposite
DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo) ; DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo) ;
public : public :
bool GetSqDist( double& dSqDist) ; bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) ; bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void) bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; } { return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void) bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; } { return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) { return (int) m_Info.size() ; } int GetNbrMinDist( void) const
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ; { return (int) m_Info.size() ; }
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ; bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
private : private :
DistPointCrvComposite( void) ; DistPointCrvComposite( void) ;
+9 -9
View File
@@ -98,7 +98,7 @@ DistPointCurve::CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCurve::GetSqDist( double& dSqDist) DistPointCurve::GetSqDist( double& dSqDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -109,7 +109,7 @@ DistPointCurve::GetSqDist( double& dSqDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointCurve::GetDist( double& dDist) DistPointCurve::GetDist( double& dDist) const
{ {
if ( m_dDist < 0) if ( m_dDist < 0)
return false ; return false ;
@@ -120,7 +120,7 @@ DistPointCurve::GetDist( double& dDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ; return false ;
@@ -132,7 +132,7 @@ DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || m_Info.empty())
return false ; return false ;
@@ -166,7 +166,7 @@ DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFl
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ; return false ;
@@ -178,7 +178,7 @@ DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || m_Info.empty())
return false ; return false ;
@@ -209,7 +209,7 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int&
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ; return false ;
@@ -257,7 +257,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || m_Info.empty())
return false ; return false ;
@@ -278,7 +278,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool 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()) if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ; return false ;
+4 -4
View File
@@ -95,7 +95,7 @@ DistPointLine::Calculate( const Point3d& ptP,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointLine::GetSqDist( double& dSqDist) DistPointLine::GetSqDist( double& dSqDist) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
@@ -106,7 +106,7 @@ DistPointLine::GetSqDist( double& dSqDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointLine::GetDist( double& dDist) DistPointLine::GetDist( double& dDist) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
@@ -119,7 +119,7 @@ DistPointLine::GetDist( double& dDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointLine::GetMinDistPoint( Point3d& ptMinDist) DistPointLine::GetMinDistPoint( Point3d& ptMinDist) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
@@ -130,7 +130,7 @@ DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointLine::GetParamAtMinDistPoint( double& dParam) DistPointLine::GetParamAtMinDistPoint( double& dParam) const
{ {
if ( m_dSqDist < 0) if ( m_dSqDist < 0)
return false ; return false ;
+9 -9
View File
@@ -31,18 +31,18 @@ class DistPointLine
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ; const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ;
public : public :
bool GetSqDist( double& dSqDist) ; bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) ; bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void) bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; } { return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void) bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; } { return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) int GetNbrMinDist( void) const
{ return (( m_dSqDist < 0) ? 0 : 1) ; } { return (( m_dSqDist < 0) ? 0 : 1) ; }
bool GetMinDistPoint( Point3d& ptMinDist) ; bool GetMinDistPoint( Point3d& ptMinDist) const ;
bool GetParamAtMinDistPoint( double& dParam) ; bool GetParamAtMinDistPoint( double& dParam) const ;
private : private :
DistPointLine( void) ; DistPointLine( void) ;
@@ -51,7 +51,7 @@ class DistPointLine
private : private :
double m_dSqDist ; double m_dSqDist ;
double m_dDist ; mutable double m_dDist ;
double m_dParam ; double m_dParam ;
Point3d m_ptMinDist ; Point3d m_ptMinDist ;
} ; } ;
+108 -24
View File
@@ -12,6 +12,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "SurfTriMesh.h"
#include "/EgtDev/Include/EGkDistPointTria.h" #include "/EgtDev/Include/EGkDistPointTria.h"
#include "/EgtDev/Include/EGkDistPointSurfTm.h" #include "/EgtDev/Include/EGkDistPointSurfTm.h"
@@ -24,7 +25,7 @@ using namespace std ;
// I casi in cui non vengono trovati box di misura positiva sono quelli in cui o il box A è contenuto // 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 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. // 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) BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDiff)
{ {
// Svuoto il risultato // Svuoto il risultato
@@ -93,30 +94,33 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
// Inizializzo distanza non calcolata // Inizializzo distanza non calcolata
m_dDist = - 1. ; m_dDist = - 1. ;
// 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 // Recupero e verifico il box locale della superficie
BBox3d b3Stm = tmSurf.GetAllTriaBox() ; BBox3d b3Stm = pStm->GetAllTriaBox() ;
if ( b3Stm.IsEmpty()) if ( b3Stm.IsEmpty())
return ; return ;
// Determino i triangoli vicini e fra di essi cerco quello di minima distanza. // Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
// Considero un box centrato nel punto P; finché all'interno del box non trovo un set di triangoli // Termino quando non trovo più triangoli che possano soddisfare la richiesta.
// 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.
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ; 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 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 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 ; 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 boxPPrev( ptP) ;
BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ; BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ;
// Variabili distanza minima, indice del triangolo di distanza minima, punto di distanza minima // Variabili distanza minima, indice del triangolo di distanza minima, punto di distanza minima
double dMinSqDist = DBL_MAX ; double dMinSqDist = DBL_MAX ;
int nMinDistTriaIndex = SVT_NULL ; int nMinDistTriaIndex = SVT_NULL ;
Point3d ptMinDistPoint ; Point3d ptMinDistPoint ;
bool bContinue = true ;
// Finché non si verifica la condizione di terminazione ingrandisco il box. // Finché non si verifica la condizione di terminazione ingrandisco il box.
pStm->ResetTempInts() ;
bool bContinue = true ;
while ( bContinue) { while ( bContinue) {
// Calcolo il box differenza con il precedente per non esplorare parti già considerate // Calcolo il box differenza con il precedente per non esplorare parti già considerate
BOXVECTOR vBox ; BOXVECTOR vBox ;
@@ -131,18 +135,21 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
// ricerca sui triangoli nel box // ricerca sui triangoli nel box
bCollide = true ; bCollide = true ;
INTVECTOR vnIds ; INTVECTOR vnIds ;
if ( tmSurf.GetAllTriaOverlapBox( b3Int, vnIds)) { if ( pStm->GetAllTriaOverlapBox( b3Int, vnIds)) {
// Ciclo sui triangoli del sotto-box corrente // Ciclo sui triangoli del sotto-box corrente
for ( auto nT : vnIds) { for ( auto nT : vnIds) {
int nTriaTemp ;
Triangle3d trCurTria ; Triangle3d trCurTria ;
tmSurf.GetTriangle( nT, trCurTria) ; if ( pStm->GetTempInt( nT, nTriaTemp) && nTriaTemp == 0 && pStm->GetTriangle( nT, trCurTria)) {
DistPointTriangle distPT( ptP, trCurTria) ; pStm->SetTempInt( nT, 1) ;
double dCurSqDist ; DistPointTriangle distPT( ptP, trCurTria) ;
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno double dCurSqDist ;
if ( distPT.GetSqDist( dCurSqDist) && dCurSqDist < dMinSqDist) { // Se la distanza del triangolo è valida e minore di quella attuale aggiorno
dMinSqDist = dCurSqDist ; if ( distPT.GetSqDist( dCurSqDist) && dCurSqDist < dMinSqDist) {
nMinDistTriaIndex = nT ; dMinSqDist = dCurSqDist ;
distPT.GetMinDistPoint( ptMinDistPoint) ; nMinDistTriaIndex = nT ;
distPT.GetMinDistPoint( ptMinDistPoint) ;
}
} }
} }
} }
@@ -161,15 +168,15 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
m_nMinDistTriaIndex = nMinDistTriaIndex ; m_nMinDistTriaIndex = nMinDistTriaIndex ;
m_ptMinDistPoint = ptMinDistPoint ; m_ptMinDistPoint = ptMinDistPoint ;
Triangle3d trMinDistTria ; Triangle3d trMinDistTria ;
tmSurf.GetTriangle( m_nMinDistTriaIndex, trMinDistTria) ; pStm->GetTriangle( m_nMinDistTriaIndex, trMinDistTria) ;
trMinDistTria.Validate() ; trMinDistTria.Validate() ;
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * trMinDistTria.GetN() < - EPS_SMALL) && tmSurf.IsClosed() ; m_bIsInside = ( ( ptP - m_ptMinDistPoint) * trMinDistTria.GetN() < - EPS_SMALL) && pStm->IsClosed() ;
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointSurfTm::GetDist( double& dDist) DistPointSurfTm::GetDist( double& dDist) const
{ {
// Distanza non valida // Distanza non valida
if ( m_dDist < -EPS_ZERO) if ( m_dDist < -EPS_ZERO)
@@ -181,7 +188,7 @@ DistPointSurfTm::GetDist( double& dDist)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) const
{ {
// Distanza non valida // Distanza non valida
if ( m_dDist < -EPS_ZERO) if ( m_dDist < -EPS_ZERO)
@@ -193,7 +200,7 @@ DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) const
{ {
// Distanza non valida // Distanza non valida
if ( m_dDist < -EPS_ZERO) if ( m_dDist < -EPS_ZERO)
@@ -202,3 +209,80 @@ DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex)
nMinDistIndex = m_nMinDistTriaIndex ; nMinDistIndex = m_nMinDistTriaIndex ;
return true ; 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 ;
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 ;
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] ;
}
}
}
}
}
}
// Se si verifica la condizione di terminazione arresto il ciclo altrimenti aggiorno i box
if ( ! bCollide || dMinSqDist < EPS_SMALL * EPS_SMALL)
bContinue = false ;
else {
boxPPrev = boxP ;
boxP.Expand( dDeltaLen) ;
}
}
return nVert ;
}
+1
View File
@@ -20,4 +20,5 @@
int GetEGkDebugLev( void) ; int GetEGkDebugLev( void) ;
ILogger* GetEGkLogger( void) ; ILogger* GetEGkLogger( void) ;
const std::string& GetEGkKey( void) ; const std::string& GetEGkKey( void) ;
bool GetEGkNetHwKey( void) ;
int ProcessEvents( int nProg, int nPause) ; int ProcessEvents( int nProg, int nPause) ;
+16 -1
View File
@@ -16,7 +16,7 @@
#include "DllMain.h" #include "DllMain.h"
#include "FontManager.h" #include "FontManager.h"
#include "\EgtDev\Include\EGkDllMain.h" #include "\EgtDev\Include\EGkDllMain.h"
#include "\EgtDev\Include\EgnGetModuleVer.h" #include "\EgtDev\Include\EGnGetModuleVer.h"
#include "\EgtDev\Include\EgtTrace.h" #include "\EgtDev\Include\EgtTrace.h"
#include "\EgtDev\Include\SELkLockId.h" #include "\EgtDev\Include\SELkLockId.h"
@@ -115,6 +115,7 @@ GetEGkLogger( void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static string s_sKey ; static string s_sKey ;
static int s_nKeyType = KEY_LOCK_TYPE_ANY ; static int s_nKeyType = KEY_LOCK_TYPE_ANY ;
static bool s_bNetHwKey = false ;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
@@ -130,6 +131,13 @@ SetEGkKeyType( int nType)
s_nKeyType = nType ; s_nKeyType = nType ;
} }
//-----------------------------------------------------------------------------
void
SetEGkNetHwKey( bool bNetHwKey)
{
s_bNetHwKey = bNetHwKey ;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const string& const string&
GetEGkKey( void) GetEGkKey( void)
@@ -138,6 +146,13 @@ GetEGkKey( void)
return s_sKey ; return s_sKey ;
} }
//-----------------------------------------------------------------------------
bool
GetEGkNetHwKey( void)
{
return s_bNetHwKey ;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
InitFontManager( const string& sNfeFontDir, const string& sDefaultFont) InitFontManager( const string& sNfeFontDir, const string& sDefaultFont)
BIN
View File
Binary file not shown.
+45 -12
View File
@@ -22,7 +22,7 @@
<ProjectGuid>{9A98A202-2853-454A-84CA-DCD1714176C9}</ProjectGuid> <ProjectGuid>{9A98A202-2853-454A-84CA-DCD1714176C9}</ProjectGuid>
<RootNamespace>EgtGeomKernel</RootNamespace> <RootNamespace>EgtGeomKernel</RootNamespace>
<Keyword>MFCDLLProj</Keyword> <Keyword>MFCDLLProj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -30,7 +30,7 @@
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -46,7 +46,7 @@
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -116,6 +116,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<EnablePREfast>false</EnablePREfast> <EnablePREfast>false</EnablePREfast>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -151,6 +152,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -197,6 +199,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration> <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -235,7 +238,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<FloatingPointModel>Precise</FloatingPointModel> <FloatingPointModel>Precise</FloatingPointModel>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration> <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
@@ -243,6 +246,8 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<DebugInformationFormat>None</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
<IntelJCCErratum>true</IntelJCCErratum>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -275,11 +280,13 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="Attribs.cpp" /> <ClCompile Include="Attribs.cpp" />
<ClCompile Include="BBox3d.cpp" /> <ClCompile Include="BBox3d.cpp" />
<ClCompile Include="BiArcs.cpp" /> <ClCompile Include="BiArcs.cpp" />
<ClCompile Include="CalcPocketing.cpp" />
<ClCompile Include="CAvSimpleSurfFrMove.cpp" /> <ClCompile Include="CAvSimpleSurfFrMove.cpp" />
<ClCompile Include="CAvToolSurfTm.cpp" /> <ClCompile Include="CAvToolSurfTm.cpp" />
<ClCompile Include="CAvToolTriangle.cpp" /> <ClCompile Include="CAvToolTriangle.cpp" />
<ClCompile Include="CDeBoxClosedSurfTm.cpp" /> <ClCompile Include="CDeBoxClosedSurfTm.cpp" />
<ClCompile Include="CDeBoxTria.cpp" /> <ClCompile Include="CDeBoxTria.cpp" />
<ClCompile Include="CDeCapsTria.cpp" />
<ClCompile Include="CDeClosedSurfTmClosedSurfTm.cpp" /> <ClCompile Include="CDeClosedSurfTmClosedSurfTm.cpp" />
<ClCompile Include="CDeConeFrustumClosedSurfTm.cpp" /> <ClCompile Include="CDeConeFrustumClosedSurfTm.cpp" />
<ClCompile Include="CDeConeFrustumTria.cpp" /> <ClCompile Include="CDeConeFrustumTria.cpp" />
@@ -295,19 +302,25 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="CDeTriaTria.cpp" /> <ClCompile Include="CDeTriaTria.cpp" />
<ClCompile Include="CDeUtility.cpp" /> <ClCompile Include="CDeUtility.cpp" />
<ClCompile Include="ChainCurves.cpp" /> <ClCompile Include="ChainCurves.cpp" />
<ClCompile Include="Circle2P.cpp" />
<ClCompile Include="CircleCenTgCurve.cpp" /> <ClCompile Include="CircleCenTgCurve.cpp" />
<ClCompile Include="Color.cpp" /> <ClCompile Include="Color.cpp" />
<ClCompile Include="CreateCurveAux.cpp" /> <ClCompile Include="CreateCurveAux.cpp" />
<ClCompile Include="CurveByApprox.cpp" /> <ClCompile Include="CurveByApprox.cpp" />
<ClCompile Include="CurveByInterp.cpp" /> <ClCompile Include="CurveByInterp.cpp" />
<ClCompile Include="CurveCompositeOffset.cpp" /> <ClCompile Include="CurveCompositeOffset.cpp" />
<ClCompile Include="PolygonElevation.cpp" />
<ClCompile Include="Voronoi.cpp" />
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" /> <ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" /> <ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" /> <ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" /> <ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkIntersLineBox.h" /> <ClInclude Include="..\Include\EGkIntersLineBox.h" />
<ClInclude Include="..\Include\EGkIntersPlaneBox.h" /> <ClInclude Include="..\Include\EGkIntersPlaneBox.h" />
<ClInclude Include="..\Include\EGkPolygonElevation.h" />
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
<ClInclude Include="CDeBoxTria.h" /> <ClInclude Include="CDeBoxTria.h" />
<ClInclude Include="CDeCapsTria.h" />
<ClInclude Include="CDeConeFrustumTria.h" /> <ClInclude Include="CDeConeFrustumTria.h" />
<ClInclude Include="CDeConeTria.h" /> <ClInclude Include="CDeConeTria.h" />
<ClInclude Include="CDeConvexTorusTria.h" /> <ClInclude Include="CDeConvexTorusTria.h" />
@@ -321,7 +334,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="DistPointSurfTm.cpp" /> <ClCompile Include="DistPointSurfTm.cpp" />
<ClCompile Include="DistPointTria.cpp" /> <ClCompile Include="DistPointTria.cpp" />
<ClCompile Include="ExtDimension.cpp" /> <ClCompile Include="ExtDimension.cpp" />
<ClCompile Include="HashGrids1d.cpp" />
<ClCompile Include="IntersLineBox.cpp" /> <ClCompile Include="IntersLineBox.cpp" />
<ClCompile Include="IntersLineCaps.cpp" />
<ClCompile Include="IntersLineCone.cpp" />
<ClCompile Include="IntersLineCyl.cpp" />
<ClCompile Include="IntersLineSphere.cpp" /> <ClCompile Include="IntersLineSphere.cpp" />
<ClCompile Include="IntersLineSurfStd.cpp" /> <ClCompile Include="IntersLineSurfStd.cpp" />
<ClCompile Include="IntersPlaneBox.cpp" /> <ClCompile Include="IntersPlaneBox.cpp" />
@@ -330,6 +347,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="IntersPlaneTria.cpp" /> <ClCompile Include="IntersPlaneTria.cpp" />
<ClCompile Include="IntersSurfTmSurfTm.cpp" /> <ClCompile Include="IntersSurfTmSurfTm.cpp" />
<ClCompile Include="IntersTriaTria.cpp" /> <ClCompile Include="IntersTriaTria.cpp" />
<ClCompile Include="OffsetAux.cpp" />
<ClCompile Include="Tree.cpp" />
<ClCompile Include="MedialAxis.cpp" />
<ClCompile Include="OffsetCurve.cpp" /> <ClCompile Include="OffsetCurve.cpp" />
<ClCompile Include="DistPointArc.cpp" /> <ClCompile Include="DistPointArc.cpp" />
<ClCompile Include="DistPointCrvAux.cpp" /> <ClCompile Include="DistPointCrvAux.cpp" />
@@ -384,14 +404,18 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="OffsetCurveOnX.cpp" /> <ClCompile Include="OffsetCurveOnX.cpp" />
<ClCompile Include="Polygon3d.cpp" /> <ClCompile Include="Polygon3d.cpp" />
<ClCompile Include="AdjustLoops.cpp" /> <ClCompile Include="AdjustLoops.cpp" />
<ClCompile Include="RemoveCurveSpikes.cpp" /> <ClCompile Include="ProjectCurveSurfTm.cpp" />
<ClCompile Include="RemoveCurveDefects.cpp" />
<ClCompile Include="SelfIntersCurve.cpp" /> <ClCompile Include="SelfIntersCurve.cpp" />
<ClCompile Include="SfrCreate.cpp" /> <ClCompile Include="SfrCreate.cpp" />
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp" />
<ClCompile Include="SurfAux.cpp" />
<ClCompile Include="SurfBezier.cpp" /> <ClCompile Include="SurfBezier.cpp" />
<ClCompile Include="SurfFlatRegion.cpp" /> <ClCompile Include="SurfFlatRegion.cpp" />
<ClCompile Include="SurfFlatRegionBooleans.cpp" /> <ClCompile Include="SurfFlatRegionBooleans.cpp" />
<ClCompile Include="SurfFlatRegionOffset.cpp" /> <ClCompile Include="SurfFlatRegionOffset.cpp" />
<ClCompile Include="SurfTriMeshBooleans.cpp" /> <ClCompile Include="SurfTriMeshBooleans.cpp" />
<ClCompile Include="SurfTriMeshCuts.cpp" />
<ClCompile Include="SurfTriMeshUtilities.cpp" /> <ClCompile Include="SurfTriMeshUtilities.cpp" />
<ClCompile Include="TextureData.cpp" /> <ClCompile Include="TextureData.cpp" />
<ClCompile Include="Tool.cpp" /> <ClCompile Include="Tool.cpp" />
@@ -425,6 +449,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="VolZmapGraphics.cpp" /> <ClCompile Include="VolZmapGraphics.cpp" />
<ClCompile Include="VolZmapVolume.cpp" /> <ClCompile Include="VolZmapVolume.cpp" />
<ClCompile Include="VolZmap.cpp" /> <ClCompile Include="VolZmap.cpp" />
<ClInclude Include="Voronoi.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\Include\EGkAngle.h" /> <ClInclude Include="..\Include\EGkAngle.h" />
@@ -441,14 +466,14 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EGkChainCurves.h" /> <ClInclude Include="..\Include\EGkChainCurves.h" />
<ClInclude Include="..\Include\EGkCircleCenTgCurve.h" /> <ClInclude Include="..\Include\EGkCircleCenTgCurve.h" />
<ClInclude Include="..\Include\EGkColor.h" /> <ClInclude Include="..\Include\EGkColor.h" />
<ClInclude Include="..\Include\EgkCurve.h" /> <ClInclude Include="..\Include\EGkCurve.h" />
<ClInclude Include="..\Include\EgkCurveArc.h" /> <ClInclude Include="..\Include\EGkCurveArc.h" />
<ClInclude Include="..\Include\EgkCurveAux.h" /> <ClInclude Include="..\Include\EGkCurveAux.h" />
<ClInclude Include="..\Include\EgkCurveBezier.h" /> <ClInclude Include="..\Include\EGkCurveBezier.h" />
<ClInclude Include="..\Include\EGkCurveByApprox.h" /> <ClInclude Include="..\Include\EGkCurveByApprox.h" />
<ClInclude Include="..\Include\EgkCurveComposite.h" /> <ClInclude Include="..\Include\EGkCurveComposite.h" />
<ClInclude Include="..\Include\EGkCurveByInterp.h" /> <ClInclude Include="..\Include\EGkCurveByInterp.h" />
<ClInclude Include="..\Include\EgkCurveLine.h" /> <ClInclude Include="..\Include\EGkCurveLine.h" />
<ClInclude Include="..\Include\EGkCurveLocal.h" /> <ClInclude Include="..\Include\EGkCurveLocal.h" />
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h" /> <ClInclude Include="..\Include\EGkCurvePointDiffGeom.h" />
<ClInclude Include="..\Include\EGkDistPointCurve.h" /> <ClInclude Include="..\Include\EGkDistPointCurve.h" />
@@ -558,6 +583,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="DistPointCrvComposite.h" /> <ClInclude Include="DistPointCrvComposite.h" />
<ClInclude Include="DistPointLine.h" /> <ClInclude Include="DistPointLine.h" />
<ClInclude Include="DllMain.h" /> <ClInclude Include="DllMain.h" />
<ClInclude Include="earcut.hpp" />
<ClInclude Include="ExtDimension.h" /> <ClInclude Include="ExtDimension.h" />
<ClInclude Include="ExtText.h" /> <ClInclude Include="ExtText.h" />
<ClInclude Include="FontAux.h" /> <ClInclude Include="FontAux.h" />
@@ -586,10 +612,16 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="IntersArcArc.h" /> <ClInclude Include="IntersArcArc.h" />
<ClInclude Include="IntersCrvCompoCrvCompo.h" /> <ClInclude Include="IntersCrvCompoCrvCompo.h" />
<ClInclude Include="IntersLineArc.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="IntersLineLine.h" />
<ClInclude Include="IntersLineSurfStd.h" /> <ClInclude Include="IntersLineSurfStd.h" />
<ClInclude Include="IntersLineTria.h" /> <ClInclude Include="IntersLineTria.h" />
<ClInclude Include="IterManager.h" /> <ClInclude Include="IterManager.h" />
<ClInclude Include="OffsetAux.h" />
<ClInclude Include="Tree.h" />
<ClInclude Include="Material.h" /> <ClInclude Include="Material.h" />
<ClInclude Include="FontNfe.h" /> <ClInclude Include="FontNfe.h" />
<ClInclude Include="MC_Tables.h" /> <ClInclude Include="MC_Tables.h" />
@@ -599,7 +631,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="ObjGraphicsMgr.h" /> <ClInclude Include="ObjGraphicsMgr.h" />
<ClInclude Include="FontOs.h" /> <ClInclude Include="FontOs.h" />
<ClInclude Include="AdjustLoops.h" /> <ClInclude Include="AdjustLoops.h" />
<ClInclude Include="RemoveCurveSpikes.h" /> <ClInclude Include="RemoveCurveDefects.h" />
<ClInclude Include="SurfAux.h" />
<ClInclude Include="SurfBezier.h" /> <ClInclude Include="SurfBezier.h" />
<ClInclude Include="SurfFlatRegion.h" /> <ClInclude Include="SurfFlatRegion.h" />
<ClInclude Include="TextureData.h" /> <ClInclude Include="TextureData.h" />
+98 -8
View File
@@ -46,6 +46,12 @@
<Filter Include="File di origine\GeoCollision"> <Filter Include="File di origine\GeoCollision">
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier> <UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
</Filter> </Filter>
<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>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Vector3d.cpp"> <ClCompile Include="Vector3d.cpp">
@@ -327,7 +333,7 @@
<ClCompile Include="OffsetCurveOnX.cpp"> <ClCompile Include="OffsetCurveOnX.cpp">
<Filter>File di origine\GeoOffset</Filter> <Filter>File di origine\GeoOffset</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="RemoveCurveSpikes.cpp"> <ClCompile Include="RemoveCurveDefects.cpp">
<Filter>File di origine\GeoInters</Filter> <Filter>File di origine\GeoInters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Polygon3d.cpp"> <ClCompile Include="Polygon3d.cpp">
@@ -456,6 +462,54 @@
<ClCompile Include="SurfTriMeshUtilities.cpp"> <ClCompile Include="SurfTriMeshUtilities.cpp">
<Filter>File di origine\Geo</Filter> <Filter>File di origine\Geo</Filter>
</ClCompile> </ClCompile>
<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\GeoCollision</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>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h"> <ClInclude Include="stdafx.h">
@@ -626,28 +680,28 @@
<ClInclude Include="..\Include\EGkChainCurves.h"> <ClInclude Include="..\Include\EGkChainCurves.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EgkCurveBezier.h"> <ClInclude Include="..\Include\EGkCurveBezier.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EGkColor.h"> <ClInclude Include="..\Include\EGkColor.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EgkCurve.h"> <ClInclude Include="..\Include\EGkCurve.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EgkCurveArc.h"> <ClInclude Include="..\Include\EGkCurveArc.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EgkCurveAux.h"> <ClInclude Include="..\Include\EGkCurveAux.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EGkCurveByInterp.h"> <ClInclude Include="..\Include\EGkCurveByInterp.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EgkCurveComposite.h"> <ClInclude Include="..\Include\EGkCurveComposite.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EgkCurveLine.h"> <ClInclude Include="..\Include\EGkCurveLine.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h"> <ClInclude Include="..\Include\EGkCurvePointDiffGeom.h">
@@ -842,7 +896,7 @@
<ClInclude Include="..\Include\EGkIntersLineSurfTm.h"> <ClInclude Include="..\Include\EGkIntersLineSurfTm.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="RemoveCurveSpikes.h"> <ClInclude Include="RemoveCurveDefects.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\EGkIntersPlanePlane.h"> <ClInclude Include="..\Include\EGkIntersPlanePlane.h">
@@ -1079,6 +1133,42 @@
<ClInclude Include="CDeRectPrismoidTria.h"> <ClInclude Include="CDeRectPrismoidTria.h">
<Filter>File di intestazione</Filter> <Filter>File di intestazione</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="earcut.hpp">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="IntersLineBox.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="CDeCapsTria.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Tree.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<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>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="EgtGeomKernel.rc"> <ResourceCompile Include="EgtGeomKernel.rc">
+698 -111
View File
File diff suppressed because it is too large Load Diff
+32 -2
View File
@@ -55,6 +55,11 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // IExtDimension
bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -62,6 +67,12 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
int nDecDigit, const std::string& sFont, double dTextHeight) override ; int nDecDigit, const std::string& sFont, double dTextHeight) override ;
bool SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptPos, bool SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptPos,
const Vector3d& vtN, const Vector3d& vtDir, const std::string& sText) override ; 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& ptP1, const Point3d& ptV, const Point3d& ptP2, const Point3d& ptPos,
const Vector3d& vtN, const std::string& sText) override ;
const Vector3d& GetNormVersor( void) const override const Vector3d& GetNormVersor( void) const override
{ return m_vtN ; } { return m_vtN ; }
const Vector3d& GetDirVersor( void) const override const Vector3d& GetDirVersor( void) const override
@@ -119,6 +130,7 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
bool GetArrowHead( const Point3d& ptTip, const Vector3d& vtDir, PolyLine& PL) const ; bool GetArrowHead( const Point3d& ptTip, const Vector3d& vtDir, PolyLine& PL) const ;
bool SetCurrFont( FontManager& fntMgr) const ; bool SetCurrFont( FontManager& fntMgr) const ;
bool ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const ; bool ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const ;
bool GetTextMyBBox( BBox3d& b3Loc) const ;
bool GetTextMyBBox( const Point3d& ptPos, BBox3d& b3Loc) const ; bool GetTextMyBBox( const Point3d& ptPos, BBox3d& b3Loc) const ;
bool GetTextLocalBBox( BBox3d& b3Loc) const ; bool GetTextLocalBBox( BBox3d& b3Loc) const ;
bool GetTextBBox( const Frame3d& frRef, BBox3d& b3Ref) const ; bool GetTextBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
@@ -133,13 +145,14 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
Point3d m_ptP3 ; // terzo punto Point3d m_ptP3 ; // terzo punto
Point3d m_ptP4 ; // quarto punto Point3d m_ptP4 ; // quarto punto
Point3d m_ptP5 ; // quinto 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 Point3d m_ptPos ; // posizione ricevuta della quota
std::string m_sText ; // testo della quota std::string m_sText ; // testo della quota
mutable bool m_bToCalc ; // flag dati effettivi da ricalcolare mutable bool m_bToCalc ; // flag dati effettivi da ricalcolare
mutable std::string m_sCalcText ; // testo effettivo della quota mutable std::string m_sCalcText ; // testo effettivo della quota
mutable Point3d m_ptCalcPos ; // posizione effettiva della quota mutable Point3d m_ptCalcPos ; // posizione effettiva della quota
mutable bool m_bCalcArrowIn ; // flag posizione effettiva delle frecce 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_ptCalcP7 ; // settimo punto effettivo
mutable Point3d m_ptCalcP8 ; // ottavo punto effettivo mutable Point3d m_ptCalcP8 ; // ottavo punto effettivo
double m_dExtLineLen ; // lunghezza di estensione della linea double m_dExtLineLen ; // lunghezza di estensione della linea
@@ -149,5 +162,22 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
int m_nDecDigit ; // numero di cifre decimali int m_nDecDigit ; // numero di cifre decimali
std::string m_sFont ; // font del testo std::string m_sFont ; // font del testo
double m_dTextHeight ; // altezza del testo double m_dTextHeight ; // altezza del testo
int m_nTempProp[2] ; // vettore proprietŕ temporanee 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)) ; }
+37 -5
View File
@@ -35,10 +35,9 @@ GEOOBJ_REGISTER( EXT_TEXT, NGE_E_TXT, ExtText) ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
ExtText::ExtText( void) ExtText::ExtText( void)
: m_pSTM( nullptr), m_bNoSTM( false), m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(), : 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_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0),
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -161,7 +160,7 @@ ExtText::Clone( void) const
bool bool
ExtText::CopyFrom( const IGeoObj* pGObjSrc) ExtText::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const ExtText* pTxt = dynamic_cast<const ExtText*>( pGObjSrc) ; const ExtText* pTxt = GetBasicExtText( pGObjSrc) ;
if ( pTxt == nullptr) if ( pTxt == nullptr)
return false ; return false ;
return CopyFrom( *pTxt) ; return CopyFrom( *pTxt) ;
@@ -188,6 +187,8 @@ ExtText::CopyFrom( const ExtText& clSrc)
m_nInsPos = clSrc.m_nInsPos ; m_nInsPos = clSrc.m_nInsPos ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ; m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ; m_nTempProp[1] = clSrc.m_nTempProp[1] ;
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
return true ; return true ;
} }
@@ -399,8 +400,11 @@ ExtText::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
bool bool
ExtText::Translate( const Vector3d& vtMove) ExtText::Translate( const Vector3d& vtMove)
{ {
// imposto ricalcolo della grafica
ResetAuxSurf() ; ResetAuxSurf() ;
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// eseguo
m_ptP.Translate( vtMove) ; m_ptP.Translate( vtMove) ;
return true ; return true ;
} }
@@ -409,8 +413,15 @@ ExtText::Translate( const Vector3d& vtMove)
bool bool
ExtText::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) 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() ; ResetAuxSurf() ;
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// eseguo
return ( m_ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) && return ( m_ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_vtN.Rotate( vtAx, dCosAng, dSinAng) && m_vtN.Rotate( vtAx, dCosAng, dSinAng) &&
m_vtD.Rotate( vtAx, dCosAng, dSinAng)) ; m_vtD.Rotate( vtAx, dCosAng, dSinAng)) ;
@@ -532,9 +543,18 @@ ExtText::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtD
bool bool
ExtText::ToGlob( const Frame3d& frRef) 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 // imposto ricalcolo della grafica
ResetAuxSurf() ; ResetAuxSurf() ;
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// trasformo punto e versori // trasformo punto e versori
return ( m_ptP.ToGlob( frRef) && return ( m_ptP.ToGlob( frRef) &&
m_vtN.ToGlob( frRef) && m_vtN.ToGlob( frRef) &&
@@ -545,9 +565,18 @@ ExtText::ToGlob( const Frame3d& frRef)
bool bool
ExtText::ToLoc( const Frame3d& frRef) 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 // imposto ricalcolo della grafica
ResetAuxSurf() ; ResetAuxSurf() ;
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// trasformo punto e versori // trasformo punto e versori
return ( m_ptP.ToLoc( frRef) && return ( m_ptP.ToLoc( frRef) &&
m_vtN.ToLoc( frRef) && m_vtN.ToLoc( frRef) &&
@@ -561,12 +590,15 @@ ExtText::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
// verifico validità dei frame // verifico validità dei frame
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR) if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
return false ; return false ;
// se i due riferimenti coincidono, non devo fare alcunché // se i due riferimenti coincidono, non devo fare alcunché
if ( AreSameFrame( frOri, frDest)) if ( AreSameFrame( frOri, frDest))
return true ; return true ;
// imposto ricalcolo della grafica // imposto ricalcolo della grafica
ResetAuxSurf() ; ResetAuxSurf() ;
m_OGrMgr.Reset() ; m_OGrMgr.Reset() ;
// trasformo punto e versori // trasformo punto e versori
return ( m_ptP.ToGlob( frOri) && m_ptP.ToLoc( frDest) && return ( m_ptP.ToGlob( frOri) && m_ptP.ToLoc( frDest) &&
m_vtN.ToGlob( frOri) && m_vtN.ToLoc( frDest) && m_vtN.ToGlob( frOri) && m_vtN.ToLoc( frDest) &&
@@ -852,7 +884,7 @@ ExtText::GetAuxSurf( void) const
// per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale // per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale
for ( const auto& pSfr : lstSfr) { for ( const auto& pSfr : lstSfr) {
// recupero la superficie trimesh // 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) { if ( pStm != nullptr) {
Triangle3d Tria ; Triangle3d Tria ;
int nT = pStm->GetFirstTriangle( Tria) ; int nT = pStm->GetFirstTriangle( Tria) ;
+22
View File
@@ -55,6 +55,11 @@ class ExtText : public IExtText, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // IExtText
bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -145,4 +150,21 @@ class ExtText : public IExtText, public IGeoObjRW
double m_dAddAdvance ; // avanzamento addizionale tra caratteri double m_dAddAdvance ; // avanzamento addizionale tra caratteri
int m_nInsPos ; // posizione del punto di inserimento rispetto al testo int m_nInsPos ; // posizione del punto di inserimento rispetto al testo
int m_nTempProp[2] ; // vettore proprietà temporanee 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)) ; }
+107 -71
View File
@@ -15,13 +15,90 @@
#include "stdafx.h" #include "stdafx.h"
#include "CurveArc.h" #include "CurveArc.h"
#include "CurveLine.h" #include "CurveLine.h"
#include "/EgtDev/Include/EgkFilletChamfer.h" #include "/EgtDev/Include/EGkFilletChamfer.h"
#include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgkIntersCurves.h" #include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; 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 l'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) ;
if ( ! pCopy1->SimpleOffset( dOffs1, ICurve::OFF_FILLET))
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 l'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) ;
if ( ! pCopy2->SimpleOffset( dOffs2, ICurve::OFF_FILLET))
return false ;
// calcolo l'intersezione tra le due curve
Point3d ptInt1, ptInt2 ;
Point3d ptNearI = Media( ptNear1, ptNear2) ;
ptNearI.ToLoc( frIntr) ;
IntersCurveCurve intCC( *pCopy1, *pCopy2) ;
if ( ! intCC.GetIntersPointNearTo( 0, ptNearI, ptInt1) ||
! intCC.GetIntersPointNearTo( 1, ptNearI, ptInt2))
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* ICurveArc*
CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1, CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
@@ -34,76 +111,26 @@ CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
&vtNorm == nullptr || &dPar1 == nullptr || &dPar2 == nullptr) &vtNorm == nullptr || &dPar1 == nullptr || &dPar2 == nullptr)
return nullptr ; return nullptr ;
// calcolo un riferimento sul piano perpendicolare alla normale // eseguo calcoli
Frame3d frIntr ; Point3d ptCen, ptTg1, ptTg2 ;
if ( ! frIntr.Set( ORIG, vtNorm)) 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 ; return nullptr ;
// determino il lato di offset della curva 1 // se tangenti parallele al contatto con fillet, ricalcolo con raggio più piccolo
DistPointCurve dPC1( ptNear2, cCrv1) ; bool bParallel = ( abs( dSinA) < EPS_SMALL) ;
int nSide1 ; if ( bParallel) {
if ( ! dPC1.GetSideAtMinDistPoint( 0, vtNorm, nSide1)) Point3d ptQQQ, ptQQ1, ptQQ2 ;
return nullptr ; double dQQQ1, dQQQ2 ;
double dOffs1 = ( nSide1 == MDS_RIGHT ? dRadius : - dRadius) ; if ( ! CalcForFillet( cCrv1, ptNear1, cCrv2, ptNear2, vtNorm, dRadius - 10 * EPS_SMALL,
// calcolo l'offset nel piano locale e dal lato opportuno di una copia della curva 1 ptQQQ, ptQQ1, ptQQ2, nSide1, nSide2, dSinA, dQQQ1, dQQQ2) || abs( dSinA) < EPS_SMALL)
PtrOwner<ICurve> pCopy1( cCrv1.Clone()) ; return nullptr ;
if ( IsNull( pCopy1)) }
return nullptr ;
pCopy1->ToLoc( frIntr) ;
pCopy1->SetExtrusion( Z_AX) ;
if ( ! pCopy1->SimpleOffset( dOffs1, ICurve::OFF_FILLET))
return nullptr ;
// determino il lato di offset della curva 2 // orientamento tra le curve
DistPointCurve dPC2( ptNear1, cCrv2) ; bool bCCW = ( dSinA > 0) ;
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 ;
// assegno i valori dei parametri di trim (+ da inizio, - da fine) // assegno i valori dei parametri di trim (+ da inizio, - da fine)
if ( bCCW) { if ( bCCW) {
@@ -118,8 +145,17 @@ CreateFillet( const ICurve& cCrv1, const Point3d& ptNear1,
// creo l'arco di fillet // creo l'arco di fillet
PtrOwner<CurveArc> crvFillet( CreateBasicCurveArc()) ; PtrOwner<CurveArc> crvFillet( CreateBasicCurveArc()) ;
if ( IsNull( crvFillet) || if ( IsNull( crvFillet) ||
! crvFillet->SetC2PN( ptInt1, ptTg1, ptTg2, vtNorm)) ! crvFillet->SetC2PN( ptCen, ptTg1, ptTg2, vtNorm))
return nullptr ; 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) ; return Release(crvFillet) ;
} }
+1 -1
View File
@@ -14,7 +14,7 @@
#pragma once #pragma once
#include "/EgtDev/Include/EGkVector3d.h" #include "/EgtDev/Include/EGkVector3d.h"
#include "/EgtDev/Include/EGtNumCollection.h" #include "/EgtDev/Include/EgtNumCollection.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
double AdjustFontRatio( double dRatio) ; double AdjustFontRatio( double dRatio) ;
+2 -2
View File
@@ -17,9 +17,9 @@
#include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnFileUtils.h"
using namespace std ; using namespace std ;
+22 -40
View File
@@ -16,8 +16,8 @@
#include "FontNfe.h" #include "FontNfe.h"
#include "FontAux.h" #include "FontAux.h"
#include "FontConst.h" #include "FontConst.h"
#include "GdbIterator.h"
#include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkCurveComposite.h"
@@ -81,21 +81,19 @@ NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic,
if ( ! m_pGDB->Load( sFont)) if ( ! m_pGDB->Load( sFont))
return false ; return false ;
// recupero i parametri generali del font (devono essere nel gruppo 1) // recupero i parametri generali del font (devono essere nel gruppo 1)
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ; GdbIterator iIter( m_pGDB) ;
if ( IsNull( pIter)) if ( ! iIter.GoTo( 1))
return false ; return false ;
if ( ! pIter->GoTo( 1)) if ( ! iIter.GetInfo( NFE_H, m_dH) ||
return false ; ! iIter.GetInfo( NFE_HCAP, m_dHCap) ||
if ( ! pIter->GetInfo( NFE_H, m_dH) || ! iIter.GetInfo( NFE_HX, m_dHx) ||
! pIter->GetInfo( NFE_HCAP, m_dHCap) || ! iIter.GetInfo( NFE_ASC, m_dAsc) ||
! pIter->GetInfo( NFE_HX, m_dHx) || ! iIter.GetInfo( NFE_DESC, m_dDesc) ||
! pIter->GetInfo( NFE_ASC, m_dAsc) || ! iIter.GetInfo( NFE_ADV, m_dAdv))
! pIter->GetInfo( NFE_DESC, m_dDesc) ||
! pIter->GetInfo( NFE_ADV, m_dAdv))
return false ; return false ;
if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL) if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL)
return false ; return false ;
if ( ! pIter->GetInfo( NFE_ITALIC, m_dItalicShearCoeff)) if ( ! iIter.GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ; m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ;
// aggiorno la path del font // aggiorno la path del font
m_sFont = sFontUp ; 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()) if ( m_pGDB == nullptr || m_sFont.empty())
return false ; return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
// calcolo i fattori di scala // calcolo i fattori di scala
double dScaY = m_dHeight / m_dHCap ; double dScaY = m_dHeight / m_dHCap ;
double dScaX = dScaY * m_dRatio ; double dScaX = dScaY * m_dRatio ;
@@ -229,9 +222,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
return false ; return false ;
// creo un iteratore // creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ; GdbIterator iIter( m_pGDB) ;
if ( IsNull( pIter))
return false ;
// calcolo i fattori di scala // calcolo i fattori di scala
double dScaY = m_dHeight / m_dHCap ; 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) if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
nGroup = NFE_ERR_CHAR ; nGroup = NFE_ERR_CHAR ;
// ciclo sulle entità geometriche del carattere // ciclo sulle entità geometriche del carattere
bool bIter = pIter->GoToFirstInGroup( nGroup) ; bool bIter = iIter.GoToFirstInGroup( nGroup) ;
while ( bIter) { while ( bIter) {
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
if ( pCrv != nullptr) { if ( pCrv != nullptr) {
// copio la curva (trasformando eventuali archi in CurveBezier) // copio la curva (trasformando eventuali archi in CurveBezier)
ICurve* pCrvNew = CurveToNoArcsCurve( pCrv) ; ICurve* pCrvNew = CurveToNoArcsCurve( pCrv) ;
@@ -281,7 +272,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
// inserisco in lista la nuova curva // inserisco in lista la nuova curva
lstPC.push_back( pCrvNew) ; lstPC.push_back( pCrvNew) ;
} }
bIter = pIter->GoToNext() ; bIter = iIter.GoToNext() ;
} }
// recupero lo spostamento per il prossimo carattere // recupero lo spostamento per il prossimo carattere
double dAdvance ; double dAdvance ;
@@ -314,9 +305,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
return false ; return false ;
// creo un iteratore // creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ; GdbIterator iIter( m_pGDB) ;
if ( IsNull( pIter))
return false ;
// controllo valore tolleranza lineare // controllo valore tolleranza lineare
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight) 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) if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
nGroup = NFE_ERR_CHAR ; nGroup = NFE_ERR_CHAR ;
// ciclo sulle entità geometriche del carattere // ciclo sulle entità geometriche del carattere
bool bIter = pIter->GoToFirstInGroup( nGroup) ; bool bIter = iIter.GoToFirstInGroup( nGroup) ;
while ( bIter) { while ( bIter) {
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
if ( pCrv != nullptr) { if ( pCrv != nullptr) {
// copia temporanea della curva (trasformando eventuali archi in CurveBezier) // copia temporanea della curva (trasformando eventuali archi in CurveBezier)
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ; PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
@@ -371,7 +360,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
lstPL.emplace_back() ; lstPL.emplace_back() ;
pCrvNew->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, lstPL.back()) ; pCrvNew->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, lstPL.back()) ;
} }
bIter = pIter->GoToNext() ; bIter = iIter.GoToNext() ;
} }
// recupero lo spostamento per il prossimo carattere // recupero lo spostamento per il prossimo carattere
double dAdvance ; double dAdvance ;
@@ -400,9 +389,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
return false ; return false ;
// creo un iteratore // creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ; GdbIterator iIter( m_pGDB) ;
if ( IsNull( pIter))
return false ;
// controllo valore tolleranza lineare // controllo valore tolleranza lineare
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight) 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) if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
nGroup = NFE_ERR_CHAR ; nGroup = NFE_ERR_CHAR ;
// ciclo sulle entità geometriche del carattere // ciclo sulle entità geometriche del carattere
bool bIter = pIter->GoToFirstInGroup( nGroup) ; bool bIter = iIter.GoToFirstInGroup( nGroup) ;
while ( bIter) { while ( bIter) {
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
if ( pCrv != nullptr) { if ( pCrv != nullptr) {
// copia temporanea della curva (trasformando eventuali archi in CurveBezier) // copia temporanea della curva (trasformando eventuali archi in CurveBezier)
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ; PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
@@ -457,7 +444,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
lstPA.emplace_back() ; lstPA.emplace_back() ;
pCrv->ApproxWithArcs( dLinTol, dAngTolDeg, lstPA.back()) ; pCrv->ApproxWithArcs( dLinTol, dAngTolDeg, lstPA.back()) ;
} }
bIter = pIter->GoToNext() ; bIter = iIter.GoToNext() ;
} }
// recupero lo spostamento per il prossimo carattere // recupero lo spostamento per il prossimo carattere
double dAdvance ; double dAdvance ;
@@ -484,11 +471,6 @@ NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECT
if ( m_pGDB == nullptr || m_sFont.empty()) if ( m_pGDB == nullptr || m_sFont.empty())
return false ; return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
// calcolo i fattori di scala // calcolo i fattori di scala
double dScaY = m_dHeight / m_dHCap ; double dScaY = m_dHeight / m_dHCap ;
double dScaX = dScaY * m_dRatio ; double dScaX = dScaY * m_dRatio ;
+12 -16
View File
@@ -16,15 +16,15 @@
#include "FontOs.h" #include "FontOs.h"
#include "FontAux.h" #include "FontAux.h"
#include "FontConst.h" #include "FontConst.h"
#include "CurveLine.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "SurfFlatRegion.h" #include "SurfFlatRegion.h"
#include "GeoConst.h" #include "GeoConst.h"
#include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkCurveAux.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/EGkSfrCreate.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.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)) if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC))
return false ; return false ;
// lo trasformo opportunamente // lo trasformo opportunamente
ICURVEPLIST::iterator iIter ; for ( auto iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
for ( iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
// trasformazioni // trasformazioni
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ; (*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
(*iIter)->Translate( vtMove) ; (*iIter)->Translate( vtMove) ;
@@ -378,8 +377,7 @@ OsFont::GetRegion( const string& sText, int nInsPos, ISURFFRPLIST& lstSFR) const
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC)) if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
return false ; return false ;
// lo trasformo opportunamente // lo trasformo opportunamente
ICURVEPLIST::iterator iIter ; for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
// inverto i percorsi per avere gli esterni CCW // inverto i percorsi per avere gli esterni CCW
(*iIter)->Invert() ; (*iIter)->Invert() ;
// la trasformo per avere solo archi e rette // 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)) if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
return false ; return false ;
// lo approssimo con segmenti di retta // lo approssimo con segmenti di retta
ICURVEPLIST::iterator iIter ; for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
// trasformazioni // trasformazioni
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ; (*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
(*iIter)->Translate( vtMove) ; (*iIter)->Translate( vtMove) ;
@@ -479,7 +476,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
if ( vtMove.x > dMaxW) if ( vtMove.x > dMaxW)
dMaxW = vtMove.x ; dMaxW = vtMove.x ;
// ciclo di pulizia // ciclo di pulizia
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
delete (*iIter) ; delete (*iIter) ;
lstPC.clear() ; lstPC.clear() ;
} }
@@ -550,8 +547,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC)) if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
return false ; return false ;
// lo approssimo con segmenti di arco e retta // lo approssimo con segmenti di arco e retta
ICURVEPLIST::iterator iIter ; for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
// trasformazioni // trasformazioni
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ; (*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
(*iIter)->Translate( vtMove) ; (*iIter)->Translate( vtMove) ;
@@ -564,7 +560,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
if ( vtMove.x > dMaxW) if ( vtMove.x > dMaxW)
dMaxW = vtMove.x ; dMaxW = vtMove.x ;
// ciclo di pulizia // ciclo di pulizia
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
delete (*iIter) ; delete (*iIter) ;
lstPC.clear() ; lstPC.clear() ;
} }
@@ -731,7 +727,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC
if ( pHeader->dwType == TT_POLYGON_TYPE) { if ( pHeader->dwType == TT_POLYGON_TYPE) {
// creo curva composita // creo curva composita
PtrOwner<ICurveComposite> pCCompo( CreateCurveComposite()) ; PtrOwner<CurveComposite> pCCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCCompo)) if ( IsNull( pCCompo))
return false ; return false ;
@@ -824,7 +820,7 @@ OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const
return false ; return false ;
// creo retta, la imposto e la inserisco nella curva composita // creo retta, la imposto e la inserisco nella curva composita
PtrOwner<ICurveLine> pCLine( CreateCurveLine()) ; PtrOwner<CurveLine> pCLine( CreateBasicCurveLine()) ;
if ( IsNull( pCLine)) if ( IsNull( pCLine))
return false ; return false ;
if ( ! pCLine->Set( ptStart, ptEnd)) if ( ! pCLine->Set( ptStart, ptEnd))
@@ -845,7 +841,7 @@ OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo,
return false ; return false ;
// creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita // creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita
PtrOwner<ICurveBezier> pCBezier( CreateCurveBezier()) ; PtrOwner<CurveBezier> pCBezier( CreateBasicCurveBezier()) ;
if ( IsNull( pCBezier)) if ( IsNull( pCBezier))
return false ; return false ;
if ( ! pCBezier->Init( 2, false) || if ( ! pCBezier->Init( 2, false) ||
+6 -3
View File
@@ -224,10 +224,10 @@ Frame3d::Set( const Point3d& ptOrig, double dAngCDeg, double dAngADeg, double dA
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Frame3d::Reset( void) Frame3d::Reset( bool bGlob)
{ {
m_nType = TOP ; m_nType = ( bGlob ? TOP : ERR) ;
m_nZType = TOP ; m_nZType = ( bGlob ? TOP : ERR) ;
m_ptOrig = ORIG ; m_ptOrig = ORIG ;
m_vtVersX = X_AX ; m_vtVersX = X_AX ;
m_vtVersY = Y_AX ; m_vtVersY = Y_AX ;
@@ -456,6 +456,9 @@ Frame3d::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
bool bool
Frame3d::Verify( void) Frame3d::Verify( void)
{ {
// verifica origine
if ( ! m_ptOrig.IsValid())
return false ;
// verifica della ortogonalità dei versori e del senso destrorso // verifica della ortogonalità dei versori e del senso destrorso
double dOrtXY = m_vtVersX * m_vtVersY ; double dOrtXY = m_vtVersX * m_vtVersY ;
double dOrtYZ = m_vtVersY * m_vtVersZ ; double dOrtYZ = m_vtVersY * m_vtVersZ ;
+57 -107
View File
@@ -1423,8 +1423,7 @@ GdbExecutor::CurveArcChangeRadius( const STRVECTOR& vsParams)
if ( ! GetLengthParam( vsParams[1], dNewRad)) if ( ! GetLengthParam( vsParams[1], dNewRad))
return false ; return false ;
// esecuzione // esecuzione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero l'arco // recupero l'arco
ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ; ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCrvArc == nullptr) if ( pCrvArc == nullptr)
@@ -1452,8 +1451,7 @@ GdbExecutor::CurveArcChangeDeltaN( const STRVECTOR& vsParams)
if ( ! GetLengthParam( vsParams[1], dNewDeltaN)) if ( ! GetLengthParam( vsParams[1], dNewDeltaN))
return false ; return false ;
// esecuzione // esecuzione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero l'arco // recupero l'arco
ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ; ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCrvArc == nullptr) if ( pCrvArc == nullptr)
@@ -1686,8 +1684,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams)
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ; return false ;
// esecuzione // esecuzione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero la curva // recupero la curva
int nIdCrv = *Iter ; int nIdCrv = *Iter ;
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ; const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ;
@@ -1722,7 +1719,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams)
if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) { if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) {
// se richiesto, cancello le curve originali // se richiesto, cancello le curve originali
if ( bErase) { if ( bErase) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->Erase( *Iter)) if ( ! m_pGDB->Erase( *Iter))
return false ; return false ;
} }
@@ -2309,8 +2306,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams)
if ( ! StmFts.Start()) if ( ! StmFts.Start())
return false ; return false ;
// Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova // Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero la superficie sorgente // recupero la superficie sorgente
const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ; const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
if ( pStmS == nullptr) if ( pStmS == nullptr)
@@ -2340,7 +2336,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams)
if ( AddGeoObj( vsParams[0], vsParams[1], pSTM)) { if ( AddGeoObj( vsParams[0], vsParams[1], pSTM)) {
// se richiesto, cancello le curve originali // se richiesto, cancello le curve originali
if ( bErase) { if ( bErase) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->Erase( *Iter)) if ( ! m_pGDB->Erase( *Iter))
return false ; return false ;
} }
@@ -2534,8 +2530,7 @@ GdbExecutor::SurfTriMeshDoCompacting( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// opero sui diversi oggetti // opero sui diversi oggetti
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero la superficie // recupero la superficie
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ; ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
if ( pStm == nullptr) if ( pStm == nullptr)
@@ -2572,8 +2567,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[1], vnNames)) if ( ! GetNamesParam( vsParams[1], vnNames))
return false ; return false ;
// esecuzione // esecuzione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero la superficie da cucire // recupero la superficie da cucire
const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ; const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
if ( pStmS == nullptr) if ( pStmS == nullptr)
@@ -2590,7 +2584,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
} }
// se richiesto, cancello le superfici cucite alla prima // se richiesto, cancello le superfici cucite alla prima
if ( bErase) { if ( bErase) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter)
m_pGDB->Erase( *Iter) ; m_pGDB->Erase( *Iter) ;
} }
return true ; return true ;
@@ -5432,8 +5426,7 @@ GdbExecutor::TextOutline( const STRVECTOR& vsParams)
pTXT->GetOutline( lstPCRV) ; pTXT->GetOutline( lstPCRV) ;
// inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento // inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento
bool bOk = true ; bool bOk = true ;
ICURVEPLIST::iterator iIter ; for ( auto iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
(*iIter)->LocToLoc( frTXT, frDest) ; (*iIter)->LocToLoc( frTXT, frDest) ;
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) { if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) {
delete (*iIter) ; delete (*iIter) ;
@@ -5510,8 +5503,7 @@ GdbExecutor::GetNamesParam( const string& sParam, INTVECTOR& vnNames)
// converto in interi // converto in interi
vnNames.clear() ; vnNames.clear() ;
vnNames.reserve( vsNames.size()) ; vnNames.reserve( vsNames.size()) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
int nId = GetIdParam( *Iter) ; int nId = GetIdParam( *Iter) ;
if ( nId != GDB_ID_SEL) { if ( nId != GDB_ID_SEL) {
@@ -5538,8 +5530,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
// divido in parti // divido in parti
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ; Tokenize( sParam, ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// se 2 parti, allora Z = 0 // se 2 parti, allora Z = 0
if ( vsParams.size() == 2) { if ( vsParams.size() == 2) {
@@ -5594,8 +5585,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ; Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
// ci deve essere almeno un parametro // ci deve essere almeno un parametro
if ( vsParams.size() < 1) if ( vsParams.size() < 1)
@@ -5747,8 +5737,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
// divido in parti // divido in parti
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ; Tokenize( sParam, ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// se 2 parti, allora Z = 0 // se 2 parti, allora Z = 0
if ( vsParams.size() == 2) { if ( vsParams.size() == 2) {
@@ -5778,8 +5767,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ; Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
// ci deve essere almeno un parametro // ci deve essere almeno un parametro
if ( vsParams.size() < 1) if ( vsParams.size() < 1)
@@ -5962,8 +5950,7 @@ GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PolyLin
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPoints) ; Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPoints) ;
// converto in punti // converto in punti
PL.Clear() ; PL.Clear() ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
for ( Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
if ( GetIdParam( *Iter) == GDB_ID_SEL) { if ( GetIdParam( *Iter) == GDB_ID_SEL) {
int nId = m_pGDB->GetFirstSelectedObj() ; int nId = m_pGDB->GetFirstSelectedObj() ;
@@ -5997,8 +5984,7 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d
// divido in parti // divido in parti
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsParams) ; Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
// se 4 parti, sono 3 coordinate e un peso // se 4 parti, sono 3 coordinate e un peso
@@ -6037,8 +6023,7 @@ GdbExecutor::GetPointWsParam( const string& sParam, const Frame3d& frPnt, PolyAr
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPointWs) ; Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPointWs) ;
// converto in punti // converto in punti
PA.Clear() ; PA.Clear() ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
for ( Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
Point3d ptP ; Point3d ptP ;
double dBulge ; double dBulge ;
@@ -6059,8 +6044,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ; Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// ci deve essere almeno un parametro // ci deve essere almeno un parametro
if ( vsParams.size() < 1) if ( vsParams.size() < 1)
@@ -6082,8 +6066,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ; Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// ci deve essere almeno un parametro // ci deve essere almeno un parametro
if ( vsParams.size() < 1) if ( vsParams.size() < 1)
@@ -6118,8 +6101,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ; Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
// ci deve essere almeno un parametro // ci deve essere almeno un parametro
if ( vsParams.size() < 1) if ( vsParams.size() < 1)
@@ -6263,8 +6245,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
// divido in parti ed elimino spazi iniziali/finali // divido in parti ed elimino spazi iniziali/finali
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sTmp, ",", "(", ")", vsParams) ; Tokenize( sTmp, ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
// verifico siano 4 parti e le converto // verifico siano 4 parti e le converto
if ( vsParams.size() != 4) if ( vsParams.size() != 4)
@@ -6291,8 +6272,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d&
// divido in parti ed elimino spazi iniziali/finali // divido in parti ed elimino spazi iniziali/finali
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sTmp, ",", "(", ")", vsParams) ; Tokenize( sTmp, ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ; Trim( (*Iter), " \t\r\n") ;
// se c'è un parametro è l'origine // se c'è un parametro è l'origine
Point3d ptOrig ; Point3d ptOrig ;
@@ -6358,8 +6338,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
// divido in parti // divido in parti
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ; Tokenize( sParam, ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// devono essere 3 o 4 parametri ( Red, Green, Blue [, Alpha]) // devono essere 3 o 4 parametri ( Red, Green, Blue [, Alpha])
if ( vsParams.size() != 3 && vsParams.size() != 4) if ( vsParams.size() != 3 && vsParams.size() != 4)
@@ -6387,8 +6366,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ; Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// ci deve essere un parametro // ci deve essere un parametro
if ( vsParams.size() != 1) if ( vsParams.size() != 1)
@@ -6421,8 +6399,7 @@ GdbExecutor::GetMaterialParam( const string& sParam, bool& bByParent, int& nMat)
// recupero i parametri associati // recupero i parametri associati
STRVECTOR vsParams ; STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ; Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ; for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ; Trim( (*Iter), " \t\r\n()") ;
// ci deve essere un parametro // ci deve essere un parametro
if ( vsParams.size() != 1) if ( vsParams.size() != 1)
@@ -6479,8 +6456,7 @@ GdbExecutor::ExecuteLevel( const string& sCmd2, const STRVECTOR& vsParams)
else else
return false ; return false ;
// esecuzione impostazione livello // esecuzione impostazione livello
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetLevel( *Iter, nLevel)) if ( ! m_pGDB->SetLevel( *Iter, nLevel))
return false ; return false ;
} }
@@ -6511,8 +6487,7 @@ GdbExecutor::ExecuteMode( const string& sCmd2, const STRVECTOR& vsParams)
else else
return false ; return false ;
// esecuzione impostazione modo // esecuzione impostazione modo
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetMode( *Iter, nMode)) if ( ! m_pGDB->SetMode( *Iter, nMode))
return false ; return false ;
} }
@@ -6543,8 +6518,7 @@ GdbExecutor::ExecuteStatus( const string& sCmd2, const STRVECTOR& vsParams)
else else
return false ; return false ;
// esecuzione impostazione stato // esecuzione impostazione stato
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetStatus( *Iter, nStat)) if ( ! m_pGDB->SetStatus( *Iter, nStat))
return false ; return false ;
} }
@@ -6565,8 +6539,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione selezione // esecuzione selezione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SelectObj( *Iter)) if ( ! m_pGDB->SelectObj( *Iter))
return false ; return false ;
} }
@@ -6610,8 +6583,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams)
nFilter = EXT_TEXT ; nFilter = EXT_TEXT ;
} }
// esecuzione selezione di tutti gli oggetti di ogni gruppo // esecuzione selezione di tutti gli oggetti di ogni gruppo
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SelectGroupObjs( *Iter, nFilter)) if ( ! m_pGDB->SelectGroupObjs( *Iter, nFilter))
return false ; return false ;
} }
@@ -6635,8 +6607,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione deselezione // esecuzione deselezione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->DeselectObj( *Iter)) if ( ! m_pGDB->DeselectObj( *Iter))
return false ; return false ;
} }
@@ -6652,8 +6623,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione deselezione di tutti gli oggetti di ogni gruppo // esecuzione deselezione di tutti gli oggetti di ogni gruppo
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->DeselectGroupObjs( *Iter)) if ( ! m_pGDB->DeselectGroupObjs( *Iter))
return false ; return false ;
} }
@@ -6710,8 +6680,7 @@ GdbExecutor::MaterialColor( const STRVECTOR& vsParams)
if ( ! GetColorParam( vsParams[1], bByParent, cCol)) if ( ! GetColorParam( vsParams[1], bByParent, cCol))
return false ; return false ;
// esecuzione impostazione colore // esecuzione impostazione colore
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( bByParent) { if ( bByParent) {
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT)) if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
return false ; return false ;
@@ -6741,8 +6710,7 @@ GdbExecutor::MaterialMaterial( const STRVECTOR& vsParams)
if ( ! GetMaterialParam( vsParams[1], bByParent, nMat)) if ( ! GetMaterialParam( vsParams[1], bByParent, nMat))
return false ; return false ;
// esecuzione impostazione colore // esecuzione impostazione colore
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( bByParent) { if ( bByParent) {
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT)) if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
return false ; return false ;
@@ -6789,8 +6757,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetStringParam( vsParams[1], sName)) if ( ! GetStringParam( vsParams[1], sName))
return false ; return false ;
// eseguo assegnazione nome // eseguo assegnazione nome
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetName( *Iter, sName)) if ( ! m_pGDB->SetName( *Iter, sName))
return false ; return false ;
} }
@@ -6806,8 +6773,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// eseguo rimozione nome // eseguo rimozione nome
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->RemoveName( *Iter)) if ( ! m_pGDB->RemoveName( *Iter))
return false ; return false ;
} }
@@ -6839,8 +6805,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetStringParam( vsParams[2], sInfo)) if ( ! GetStringParam( vsParams[2], sInfo))
return false ; return false ;
// eseguo assegnazione Info di data Key // eseguo assegnazione Info di data Key
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->SetInfo( *Iter, sKey, sInfo)) if ( ! m_pGDB->SetInfo( *Iter, sKey, sInfo))
return false ; return false ;
} }
@@ -6860,8 +6825,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetStringParam( vsParams[1], sKey)) if ( ! GetStringParam( vsParams[1], sKey))
return false ; return false ;
// eseguo rimozione nome Info di data Key // eseguo rimozione nome Info di data Key
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->RemoveInfo( *Iter, sKey)) if ( ! m_pGDB->RemoveInfo( *Iter, sKey))
return false ; return false ;
} }
@@ -7010,8 +6974,7 @@ GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams)
// recupero flag per globale // recupero flag per globale
bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ;
// esecuzione rilocazioni // esecuzione rilocazioni
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( bGlob) { if ( bGlob) {
if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter)) if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter))
return false ; return false ;
@@ -7036,8 +6999,7 @@ GdbExecutor::ExecuteErase( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione cancellazioni // esecuzione cancellazioni
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( ! m_pGDB->Erase( *Iter)) if ( ! m_pGDB->Erase( *Iter))
return false ; return false ;
} }
@@ -7079,8 +7041,7 @@ GdbExecutor::ExecuteTranslate( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetVectorParam( vsParams[1], frRef, vtVN)) if ( ! GetVectorParam( vsParams[1], frRef, vtVN))
return false ; return false ;
// esecuzione traslazioni // esecuzione traslazioni
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
switch ( nTraType) { switch ( nTraType) {
case TRA_LOC : case TRA_LOC :
if ( ! m_pGDB->Translate( *Iter, vtVN)) if ( ! m_pGDB->Translate( *Iter, vtVN))
@@ -7144,8 +7105,7 @@ GdbExecutor::ExecuteRotate( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! FromString( vsParams[3], dAngDeg)) if ( ! FromString( vsParams[3], dAngDeg))
return false ; return false ;
// esecuzione rotazioni // esecuzione rotazioni
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
switch ( nRotType) { switch ( nRotType) {
case ROT_LOC : case ROT_LOC :
if ( ! m_pGDB->Rotate( *Iter, ptPC, vtVN, dAngDeg)) if ( ! m_pGDB->Rotate( *Iter, ptPC, vtVN, dAngDeg))
@@ -7214,8 +7174,7 @@ GdbExecutor::ExecuteScale( const string& sCmd2, const STRVECTOR& vsParams)
! FromString( vsParams[4], dCoeffZ)) ! FromString( vsParams[4], dCoeffZ))
return false ; return false ;
// esecuzione scalature // esecuzione scalature
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
switch ( nScaType) { switch ( nScaType) {
case SCA_LOC : case SCA_LOC :
if ( ! m_pGDB->Scale( *Iter, frFrame, dCoeffX, dCoeffY, dCoeffZ)) if ( ! m_pGDB->Scale( *Iter, frFrame, dCoeffX, dCoeffY, dCoeffZ))
@@ -7273,8 +7232,7 @@ GdbExecutor::ExecuteMirror( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetVectorParam( vsParams[2], frRef, vtVN)) if ( ! GetVectorParam( vsParams[2], frRef, vtVN))
return false ; return false ;
// esecuzione specchiature // esecuzione specchiature
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
switch ( nMirType) { switch ( nMirType) {
case MIR_LOC : case MIR_LOC :
if ( ! m_pGDB->Mirror( *Iter, ptPC, vtVN)) if ( ! m_pGDB->Mirror( *Iter, ptPC, vtVN))
@@ -7340,8 +7298,7 @@ GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! FromString( vsParams[4], dCoeff)) if ( ! FromString( vsParams[4], dCoeff))
return false ; return false ;
// esecuzione scorrimenti // esecuzione scorrimenti
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
switch ( nMirType) { switch ( nMirType) {
case MIR_LOC : case MIR_LOC :
if ( ! m_pGDB->Shear( *Iter, ptPC, vtNorm, vtDir, dCoeff)) if ( ! m_pGDB->Shear( *Iter, ptPC, vtNorm, vtDir, dCoeff))
@@ -7400,8 +7357,7 @@ GdbExecutor::CurveModifyInvert( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione inversione curve // esecuzione inversione curve
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
ICurve* pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter)) ; ICurve* pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCurve == nullptr || ! pCurve->Invert()) if ( pCurve == nullptr || ! pCurve->Invert())
return false ; return false ;
@@ -7518,8 +7474,7 @@ GdbExecutor::CurveModifyTrim( const STRVECTOR& vsParams, int nTrimType)
if ( ! FromString( vsParams[1], dPar)) if ( ! FromString( vsParams[1], dPar))
return false ; return false ;
// esecuzione trim // esecuzione trim
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
ICurve* pCurve ; ICurve* pCurve ;
if ( ( pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter))) != nullptr) { if ( ( pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter))) != nullptr) {
switch ( nTrimType) { switch ( nTrimType) {
@@ -7718,8 +7673,7 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
// preparo i dati per il concatenamento // preparo i dati per il concatenamento
ChainCurves chainC ; ChainCurves chainC ;
chainC.Init( bAllowInvert, dToler, int( vnNames.size())) ; chainC.Init( bAllowInvert, dToler, int( vnNames.size())) ;
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero la curva e il suo riferimento // recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( *Iter)) ; ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCrv == nullptr) if ( pCrv == nullptr)
@@ -7748,10 +7702,9 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
if ( IsNull( pCrvCompo)) if ( IsNull( pCrvCompo))
return false ; return false ;
// recupero le curve semplici e le inserisco nella curva composita // recupero le curve semplici e le inserisco nella curva composita
INTVECTOR::iterator Iter2 ; for ( auto Iter = vIds.cbegin() ; Iter != vIds.cend() ; ++Iter) {
for ( Iter2 = vIds.begin() ; Iter2 != vIds.end() ; ++Iter2) { int nId = abs( *Iter) ;
int nId = abs( *Iter2) ; bool bInvert = ( *Iter < 0) ;
bool bInvert = ( *Iter2 < 0) ;
// recupero la curva e il suo riferimento // recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ; ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr) if ( pCrv == nullptr)
@@ -7806,8 +7759,7 @@ GdbExecutor::SurfModifyInvert( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione inversione normale superficie // esecuzione inversione normale superficie
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
ISurf* pSurf = GetSurf( m_pGDB->GetGeoObj( *Iter)) ; ISurf* pSurf = GetSurf( m_pGDB->GetGeoObj( *Iter)) ;
if ( pSurf == nullptr || ! pSurf->Invert()) if ( pSurf == nullptr || ! pSurf->Invert())
return false ; return false ;
@@ -7921,7 +7873,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
sText += "<br/> " ; sText += "<br/> " ;
sText += " U=" + ToString( aInfo.IciA[j].dU,7) + " P=(" + ToString( aInfo.IciA[j].ptI,4) + ")" ; sText += " U=" + ToString( aInfo.IciA[j].dU,7) + " P=(" + ToString( aInfo.IciA[j].ptI,4) + ")" ;
switch( aInfo.IciA[j].nPrevTy) { switch( aInfo.IciA[j].nPrevTy) {
case ICCT_NULL : sText += " ??-" ; break ; case ICCT_NULL : sText += " ?" "?-" ; break ;
case ICCT_IN : sText += " IN-" ; break ; case ICCT_IN : sText += " IN-" ; break ;
case ICCT_OUT : sText += " OUT-" ; break ; case ICCT_OUT : sText += " OUT-" ; break ;
case ICCT_ON : sText += " ON-" ; break ; case ICCT_ON : sText += " ON-" ; break ;
@@ -7940,7 +7892,7 @@ GdbExecutor::ExecuteOutTextIcci( const string& sCmd2, const STRVECTOR& vsParams)
sText += string( "<br/>") + ( aInfo.bCBOverEq ? " + " : " - ") ; sText += string( "<br/>") + ( aInfo.bCBOverEq ? " + " : " - ") ;
sText += " U=" + ToString( aInfo.IciB[j].dU,7) + " P=(" + ToString( aInfo.IciB[j].ptI,4) + ")" ; sText += " U=" + ToString( aInfo.IciB[j].dU,7) + " P=(" + ToString( aInfo.IciB[j].ptI,4) + ")" ;
switch( aInfo.IciB[j].nPrevTy) { switch( aInfo.IciB[j].nPrevTy) {
case ICCT_NULL : sText += " ??-" ; break ; case ICCT_NULL : sText += " ?" "?-" ; break ;
case ICCT_IN : sText += " IN-" ; break ; case ICCT_IN : sText += " IN-" ; break ;
case ICCT_OUT : sText += " OUT-" ; break ; case ICCT_OUT : sText += " OUT-" ; break ;
case ICCT_ON : sText += " ON-" ; break ; case ICCT_ON : sText += " ON-" ; break ;
@@ -8049,8 +8001,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione // esecuzione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero l'oggetto ed eseguo l'output // recupero l'oggetto ed eseguo l'output
if ( ! OutGroupTsc( *Iter, nFlag)) if ( ! OutGroupTsc( *Iter, nFlag))
return false ; return false ;
@@ -8073,8 +8024,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames)) if ( ! GetNamesParam( vsParams[0], vnNames))
return false ; return false ;
// esecuzione // esecuzione
INTVECTOR::iterator Iter ; for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
// recupero l'oggetto ed eseguo l'output // recupero l'oggetto ed eseguo l'output
if ( ! m_OutTsc.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag)) if ( ! m_OutTsc.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag))
return false ; return false ;
+2 -2
View File
@@ -14,10 +14,10 @@
#pragma once #pragma once
#include "OutTsc.h" #include "OutTsc.h"
#include "/EgtDev/Include/EgkGdbExecutor.h" #include "/EgtDev/Include/EGkGdbExecutor.h"
#include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EgtPerfCounter.h"
#include "/EgtDev/Include/EgtExecMgr.h" #include "/EgtDev/Include/EgtExecMgr.h"
#include "/EgtDev/Include/EgkGeoCollection.h" #include "/EgtDev/Include/EGkGeoCollection.h"
#include "Tool.h" #include "Tool.h"
class PolyLine ; class PolyLine ;
+6 -2
View File
@@ -54,6 +54,10 @@ class GdbGeo : public GdbObj
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
inline const GdbGeo* GetGdbGeo( const GdbObj* pGObj) 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) 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
View File
@@ -44,7 +44,7 @@ GdbGroup::~GdbGroup( void)
// nel sorgente aggiorno lista dei riferimenti // nel sorgente aggiorno lista dei riferimenti
INTVECTOR vnList ; INTVECTOR vnList ;
pGdbObj->GetInfo( GDB_SI_LIST, 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()) if ( iFind != vnList.end())
vnList.erase( iFind) ; vnList.erase( iFind) ;
if ( vnList.empty()) if ( vnList.empty())
+6 -2
View File
@@ -91,6 +91,10 @@ class GdbGroup : public GdbObj
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
inline const GdbGroup* GetGdbGroup( const GdbObj* pGObj) 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) 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
View File
@@ -24,7 +24,7 @@ using namespace std ;
IGdbIterator* IGdbIterator*
CreateGdbIterator( IGeomDB* pGDB) CreateGdbIterator( IGeomDB* pGDB)
{ {
if ( dynamic_cast<GeomDB*>( pGDB) == nullptr) if ( static_cast<GeomDB*>( pGDB) == nullptr)
return nullptr ; return nullptr ;
return static_cast<IGdbIterator*> ( new( nothrow) GdbIterator( pGDB)) ; return static_cast<IGdbIterator*> ( new( nothrow) GdbIterator( pGDB)) ;
} }
@@ -53,7 +53,7 @@ GdbIterator::~GdbIterator( void)
bool bool
GdbIterator::SetGDB( IGeomDB* pGDB) GdbIterator::SetGDB( IGeomDB* pGDB)
{ {
m_pGDB = dynamic_cast<GeomDB*>( pGDB) ; m_pGDB = static_cast<GeomDB*>( pGDB) ;
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
@@ -105,7 +105,7 @@ GdbIterator::GoToFirstInGroup( const IGdbIterator& iIter)
return false ; 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) { if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
m_pCurrObj = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
@@ -167,7 +167,7 @@ GdbIterator::GoToLastInGroup( const IGdbIterator& iIter)
return false ; 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) { if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
m_pCurrObj = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
@@ -263,7 +263,7 @@ GdbIterator::GoToFirstNameInGroup( const IGdbIterator& iIter, const string& sNam
return false ; return false ;
} }
// converto in oggetto iteratore di base // 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) { if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
m_pCurrObj = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
@@ -345,7 +345,7 @@ GdbIterator::GoToLastNameInGroup( const IGdbIterator& iIter, const string& sName
return false ; return false ;
} }
// converto in oggetto iteratore di base // 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) { if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
m_pCurrObj = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
@@ -474,7 +474,7 @@ GdbIterator::GoToFirstGroupInGroup( const IGdbIterator& iIter)
return false ; return false ;
} }
// converto in oggetto iteratore di base // 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) { if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
m_pCurrObj = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
@@ -553,7 +553,7 @@ GdbIterator::GoToLastGroupInGroup( const IGdbIterator& iIter)
return false ; return false ;
} }
// converto in oggetto iteratore di base // 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) { if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) {
m_pCurrObj = nullptr ; m_pCurrObj = nullptr ;
return false ; return false ;
@@ -1468,7 +1468,8 @@ GdbIterator::SetInfo( const string& sKey, int nInfo)
bool bool
GdbIterator::SetInfo( const string& sKey, double dInfo) 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) ; 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 // TextureData
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
+7 -2
View File
@@ -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. // Contenuto : Dichiarazione della classe GdbIterator.
// //
// //
@@ -142,6 +142,11 @@ class GdbIterator : public IGdbIterator
bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const override ; bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const override ;
bool ExistsInfo( const std::string& sKey) const override ; bool ExistsInfo( const std::string& sKey) const override ;
bool RemoveInfo( const std::string& sKey) 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 // TextureData
bool SetTextureName( const std::string& sTxrName) override ; bool SetTextureName( const std::string& sTxrName) override ;
bool SetTextureFrame( const Frame3d& frTxrRef) override ; bool SetTextureFrame( const Frame3d& frTxrRef) override ;
+44 -4
View File
@@ -31,10 +31,9 @@ using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GdbObj::GdbObj( void) GdbObj::GdbObj( void)
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_pTxrData( nullptr), m_pUserObj( nullptr), : m_nId( GDB_ID_NULL), m_pAttribs( nullptr), m_nStpFactor( 0), m_nStpPattern( 0), m_pTxrData( nullptr),
m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr), m_pUserObj( nullptr), m_pGDB( nullptr), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr),
m_pSelNext( nullptr), m_pSelPrev( nullptr) m_pSelNext( nullptr), m_pSelPrev( nullptr)
{ {
} }
@@ -73,6 +72,9 @@ GdbObj::CopyFrom( const GdbObj* pSou)
if ( m_pAttribs != nullptr) if ( m_pAttribs != nullptr)
delete m_pAttribs ; delete m_pAttribs ;
m_pAttribs = nullptr ; m_pAttribs = nullptr ;
// reset stipple
m_nStpFactor = 0 ;
m_nStpPattern = 0 ;
// elimino eventuali dati della texture pre-esistenti // elimino eventuali dati della texture pre-esistenti
if ( m_pTxrData != nullptr) if ( m_pTxrData != nullptr)
delete m_pTxrData ; delete m_pTxrData ;
@@ -91,6 +93,10 @@ GdbObj::CopyFrom( const GdbObj* pSou)
// copio Id // copio Id
m_nId = pSou->m_nId ; 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 // copio gli attributi, i dati della texture e UserObj
return ( CopyAttribsFrom( pSou) && CopyTextureDataFrom( pSou) && CopyUserObjFrom( pSou)) ; return ( CopyAttribsFrom( pSou) && CopyTextureDataFrom( pSou) && CopyUserObjFrom( pSou)) ;
} }
@@ -856,7 +862,8 @@ GdbObj::SetInfo( const string& sKey, int nInfo)
bool bool
GdbObj::SetInfo( const string& sKey, double dInfo) GdbObj::SetInfo( const string& sKey, double dInfo)
{ {
return SetInfo( sKey, ToString( dInfo)) ; int nErr ;
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -1024,6 +1031,39 @@ GdbObj::RemoveInfo( const string& sKey)
return m_pAttribs->RemoveInfo( 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 // TextureData
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
+5
View File
@@ -119,6 +119,9 @@ class GdbObj
bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const ; bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const ;
bool ExistsInfo( const std::string& sKey) const ; bool ExistsInfo( const std::string& sKey) const ;
bool RemoveInfo( const std::string& sKey) ; 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 SaveTextureData( NgeWriter& ngeOut) const ;
bool LoadTextureData( NgeReader& ngeIn) ; bool LoadTextureData( NgeReader& ngeIn) ;
TextureData* GetTextureData( void) TextureData* GetTextureData( void)
@@ -160,6 +163,8 @@ class GdbObj
public : public :
int m_nId ; int m_nId ;
Attribs* m_pAttribs ; Attribs* m_pAttribs ;
int m_nStpFactor ;
int m_nStpPattern ;
TextureData* m_pTxrData ; TextureData* m_pTxrData ;
IUserObj* m_pUserObj ; IUserObj* m_pUserObj ;
+6 -2
View File
@@ -50,7 +50,11 @@ const double BEZARC_ANG_CEN_MAX = 90 ;
//----------------- Costanti per superfici TriMesh --------------------------- //----------------- Costanti per superfici TriMesh ---------------------------
// tolleranza lineare standard // tolleranza lineare standard
const double STM_STD_LIN_TOL = 0.1 ; 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 ; 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 ; 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 ;
+4 -4
View File
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_FRAME3D, NGE_G_FRM, GeoFrame3d) ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GeoFrame3d::GeoFrame3d( void) GeoFrame3d::GeoFrame3d( void)
: m_frF() : m_frF(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -104,7 +102,7 @@ GeoFrame3d::Clone( void) const
bool bool
GeoFrame3d::CopyFrom( const IGeoObj* pGObjSrc) GeoFrame3d::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const GeoFrame3d* pGFr = dynamic_cast<const GeoFrame3d*>( pGObjSrc) ; const GeoFrame3d* pGFr = GetBasicGeoFrame3d( pGObjSrc) ;
if ( pGFr == nullptr) if ( pGFr == nullptr)
return false ; return false ;
return CopyFrom( *pGFr) ; return CopyFrom( *pGFr) ;
@@ -118,6 +116,8 @@ GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
return true ; return true ;
m_nTempProp[0] = gfSrc.m_nTempProp[0] ; m_nTempProp[0] = gfSrc.m_nTempProp[0] ;
m_nTempProp[1] = gfSrc.m_nTempProp[1] ; 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) ; return Set( gfSrc.m_frF) ;
} }
+22
View File
@@ -62,6 +62,11 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 public : // IGeoFrame3d
bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -97,4 +102,21 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Frame3d m_frF ; // oggetto Frame3d m_frF ; // oggetto
int m_nTempProp[2] ; // vettore proprietà temporanee 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)) ; }
+4 -4
View File
@@ -28,10 +28,8 @@ GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GeoPoint3d::GeoPoint3d( void) GeoPoint3d::GeoPoint3d( void)
: m_ptP() : m_ptP(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -72,7 +70,7 @@ GeoPoint3d::Clone( void) const
bool bool
GeoPoint3d::CopyFrom( const IGeoObj* pGObjSrc) GeoPoint3d::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const GeoPoint3d* pGP = dynamic_cast<const GeoPoint3d*>( pGObjSrc) ; const GeoPoint3d* pGP = GetBasicGeoPoint3d( pGObjSrc) ;
if ( pGP == nullptr) if ( pGP == nullptr)
return false ; return false ;
return CopyFrom( *pGP) ; return CopyFrom( *pGP) ;
@@ -86,6 +84,8 @@ GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
return true ; return true ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ; m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ; 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) ; return Set( clSrc.m_ptP) ;
} }
+22
View File
@@ -62,6 +62,11 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 : // IGeoPoint3d public : // IGeoPoint3d
bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -91,4 +96,21 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Point3d m_ptP ; // oggetto Point3d m_ptP ; // oggetto
int m_nTempProp[2] ; // vettore proprietà temporanee int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ; } ;
//-----------------------------------------------------------------------------
inline GeoPoint3d* CreateBasicGeoPoint3d( void)
{ return ( static_cast<GeoPoint3d*>( CreateGeoObj( GEO_PNT3D))) ; }
inline GeoPoint3d* CloneBasicGeoPoint3d( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_PNT3D)
return nullptr ;
return ( static_cast<GeoPoint3d*>( pGObj->Clone())) ; }
inline const GeoPoint3d* GetBasicGeoPoint3d( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_PNT3D)
return nullptr ;
return ( static_cast<const GeoPoint3d*>( pGObj)) ; }
inline GeoPoint3d* GetBasicGeoPoint3d( IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_PNT3D)
return nullptr ;
return ( static_cast<GeoPoint3d*>( pGObj)) ; }
+4 -4
View File
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_VECT3D, NGE_G_VEC, GeoVector3d) ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GeoVector3d::GeoVector3d( void) GeoVector3d::GeoVector3d( void)
: m_vtV() : m_vtV(), m_ptBase(), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
{ {
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -88,7 +86,7 @@ GeoVector3d::Clone( void) const
bool bool
GeoVector3d::CopyFrom( const IGeoObj* pGObjSrc) GeoVector3d::CopyFrom( const IGeoObj* pGObjSrc)
{ {
const GeoVector3d* pGV = dynamic_cast<const GeoVector3d*>( pGObjSrc) ; const GeoVector3d* pGV = GetBasicGeoVector3d( pGObjSrc) ;
if ( pGV == nullptr) if ( pGV == nullptr)
return false ; return false ;
return CopyFrom( *pGV) ; return CopyFrom( *pGV) ;
@@ -102,6 +100,8 @@ GeoVector3d::CopyFrom( const GeoVector3d& clSrc)
return true ; return true ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ; m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ; 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_vtV, clSrc.m_ptBase) ; return Set( clSrc.m_vtV, clSrc.m_ptBase) ;
} }
+22
View File
@@ -70,6 +70,11 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; } m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; } { 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 : // IGeoVector3d public : // IGeoVector3d
bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -106,4 +111,21 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
Vector3d m_vtV ; // oggetto Vector3d m_vtV ; // oggetto
Point3d m_ptBase ; // punto base da cui tracciare il vettore Point3d m_ptBase ; // punto base da cui tracciare il vettore
int m_nTempProp[2] ; // vettore proprietà temporanee int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ; } ;
//-----------------------------------------------------------------------------
inline GeoVector3d* CreateBasicGeoVector3d( void)
{ return ( static_cast<GeoVector3d*>( CreateGeoObj( GEO_VECT3D))) ; }
inline GeoVector3d* CloneBasicGeoVector3d( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_VECT3D)
return nullptr ;
return ( static_cast<GeoVector3d*>( pGObj->Clone())) ; }
inline const GeoVector3d* GetBasicGeoVector3d( const IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_VECT3D)
return nullptr ;
return ( static_cast<const GeoVector3d*>( pGObj)) ; }
inline GeoVector3d* GetBasicGeoVector3d( IGeoObj* pGObj)
{ if ( pGObj == nullptr || pGObj->GetType() != GEO_VECT3D)
return nullptr ;
return ( static_cast<GeoVector3d*>( pGObj)) ; }
+169 -29
View File
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2013-2013 // EgalTech 2013-2023
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : GeomDB.cpp Data : 08.04.13 Versione : 1.3a5 // File : GeomDB.cpp Data : 29.05.23 Versione : 2.5e5
// Contenuto : Implementazione della classe GeomDB. // Contenuto : Implementazione della classe GeomDB.
// //
// //
@@ -21,17 +21,40 @@
#include "NgeReader.h" #include "NgeReader.h"
#include "NgeWriter.h" #include "NgeWriter.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/SELkLockId.h" #include "/EgtDev/Include/EGnGetKeyData.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EgtNumCollection.h" #include "/EgtDev/Include/EgtNumCollection.h"
#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/SELkLockId.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include <new> #include <new>
#include <stack> #include <stack>
#include <thread>
using namespace std ; using namespace std ;
//----------------------------------------------------------------------------
class LockAddErase
{
public :
LockAddErase(std::atomic_flag& bAddEraseOn, bool bUse = true): m_bAddEraseOn( bAddEraseOn), m_bUse( bUse)
{ if ( ! m_bUse) return ;
while ( m_bAddEraseOn.test_and_set()) {
this_thread::sleep_for( chrono::nanoseconds{ 1}) ;
}
} ;
~LockAddErase( void)
{ if ( ! m_bUse) return ;
m_bAddEraseOn.clear() ;
} ;
private :
std::atomic_flag& m_bAddEraseOn ;
bool m_bUse ;
} ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
IGeomDB* IGeomDB*
CreateGeomDB( void) CreateGeomDB( void)
@@ -39,20 +62,25 @@ CreateGeomDB( void)
// verifico la chiave e le opzioni // verifico la chiave e le opzioni
unsigned int nOpt1, nOpt2 ; unsigned int nOpt1, nOpt2 ;
int nOptExpDays ; int nOptExpDays ;
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ; nOpt1, nOpt2, nOptExpDays) ;
if ( ! GetEGkNetHwKey())
nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
// controllo i risultati
if ( nRet != KEY_OK && ! EqualNoCase( GetEGkKey(), "EGkBase")) { if ( nRet != KEY_OK && ! EqualNoCase( GetEGkKey(), "EGkBase")) {
if ( nRet != KEY_OK) { if ( nRet != KEY_OK) {
string sErr = "Error on Key (GKC/" + ToString( nRet) + ")" ; string sErr = "Error on Key (GKC/" + ToString( nRet) + ")" ;
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ; LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
return nullptr ; return nullptr ;
} }
if ( (nOpt1 & KEYOPT_EGK_BASE) == 0 || nOptExpDays < GetCurrDay()) { if ( ( nOpt1 & KEYOPT_EGK_BASE) == 0 || nOptExpDays < GetCurrDay()) {
string sErr = "Error on Key (GKC/OPT)" ; string sErr = "Error on Key (GKC/OPT)" ;
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ; LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
return nullptr ; return nullptr ;
} }
} }
// creo il GeomDB // creo il GeomDB
return static_cast<IGeomDB*> ( new( nothrow) GeomDB) ; return static_cast<IGeomDB*> ( new( nothrow) GeomDB) ;
} }
@@ -62,6 +90,7 @@ CreateGeomDB( void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
GeomDB::GeomDB( void) GeomDB::GeomDB( void)
{ {
m_bAddEraseOn.clear() ;
m_GrpRadix.SetGeomDB( this) ; m_GrpRadix.SetGeomDB( this) ;
m_GrpRadix.m_nId = GDB_ID_ROOT ; m_GrpRadix.m_nId = GDB_ID_ROOT ;
m_GrpRadix.SetMaterial( Color()) ; m_GrpRadix.SetMaterial( Color()) ;
@@ -274,14 +303,18 @@ GeomDB::Save( int nId, const string& sFileOut, int nFlag) const
// verifico la chiave e le opzioni // verifico la chiave e le opzioni
unsigned int nOpt1, nOpt2 ; unsigned int nOpt1, nOpt2 ;
int nOptExpDays ; int nOptExpDays ;
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ; nOpt1, nOpt2, nOptExpDays) ;
if ( ! GetEGkNetHwKey())
nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
// controllo i risultati
if ( nRet != KEY_OK) { if ( nRet != KEY_OK) {
string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ; string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ;
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ; LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
return false ; return false ;
} }
if ( (nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) { if ( ( nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) {
string sErr = "Error on Key (GKS/OPT)" ; string sErr = "Error on Key (GKS/OPT)" ;
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ; LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
return false ; return false ;
@@ -384,14 +417,18 @@ GeomDB::Save( const INTVECTOR& vId, const string& sFileOut, int nFlag) const
// verifico la chiave e le opzioni // verifico la chiave e le opzioni
unsigned int nOpt1, nOpt2 ; unsigned int nOpt1, nOpt2 ;
int nOptExpDays ; int nOptExpDays ;
int nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ; nOpt1, nOpt2, nOptExpDays) ;
if ( ! GetEGkNetHwKey())
nRet = GetKeyOptions( GetEGkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
// controllo i risultati
if ( nRet != KEY_OK) { if ( nRet != KEY_OK) {
string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ; string sErr = "Error on Key (GKS/" + ToString( nRet) + ")" ;
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ; LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
return false ; return false ;
} }
if ( (nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) { if ( ( nOpt1 & KEYOPT_EGK_SAVE) == 0 || nOptExpDays < GetCurrDay()) {
string sErr = "Error on Key (GKS/OPT)" ; string sErr = "Error on Key (GKS/OPT)" ;
LOG_ERROR( GetEGkLogger(), sErr.c_str()) ; LOG_ERROR( GetEGkLogger(), sErr.c_str()) ;
return false ; return false ;
@@ -416,7 +453,7 @@ GeomDB::Save( const INTVECTOR& vId, const string& sFileOut, int nFlag) const
return false ; return false ;
// ciclo sugli oggetti da esportare // ciclo sugli oggetti da esportare
unordered_set<int> usSavedId ; INTUNORDSET usSavedId ;
for ( const auto nId : vId) { for ( const auto nId : vId) {
// se già salvato, passo oltre // se già salvato, passo oltre
@@ -513,7 +550,10 @@ GeomDB::SaveHeader( NgeWriter& ngeOut) const
// LockId del sistema come commento // LockId del sistema come commento
string sLockId ; string sLockId ;
if ( ! GetLockId( sLockId)) { if ( GetEGkNetHwKey()) {
sLockId = "NET-000000" ;
}
else if ( ! GetLockId( sLockId)) {
LOG_ERROR( GetEGkLogger(), "Error on Key (1)") LOG_ERROR( GetEGkLogger(), "Error on Key (1)")
return false ; return false ;
} }
@@ -578,25 +618,32 @@ GeomDB::GetGdbObj( int nId) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTestId) GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bLockAddErase, bool bTestId)
{ {
// verifico validità oggetto puntato // verifico validità oggetto puntato
if ( pGObj == nullptr) if ( pGObj == nullptr)
return false ; return false ;
// se richiesta, verifica validità e unicità del nome // verifico validità del riferimento
if ( bTestId && ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId))) if ( nRefId < GDB_ID_ROOT)
return false ; return false ;
// oggetto e riferimento non possono essere la stessa cosa // oggetto e riferimento non possono essere la stessa cosa
if ( pGObj->m_nId == nRefId) if ( pGObj->m_nId == nRefId)
return ( ! IS_GDB_SON( nSonBeforeAfter)) ; return ( ! IS_GDB_SON( nSonBeforeAfter)) ;
// verifico unicità esecuzione, se necessaria
LockAddErase Lock( m_bAddEraseOn, bLockAddErase) ;
// cerco il riferimento // cerco il riferimento
GdbObj* pGRef = GetGdbObj( nRefId) ; GdbObj* pGRef = GetGdbObj( nRefId) ;
if ( pGRef == nullptr) if ( pGRef == nullptr)
return false ; return false ;
// se richiesta, verifica validità e unicità del nome
if ( bTestId && ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId)))
return false ;
// assegno il riferimento al DB geometrico // assegno il riferimento al DB geometrico
pGObj->SetGeomDB( this) ; pGObj->SetGeomDB( this) ;
@@ -612,7 +659,7 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe
} }
// inserisco come figlio, in testa alla lista del padre // inserisco come figlio, in testa alla lista del padre
else if ( nSonBeforeAfter == GDB_FIRST_SON){ else if ( nSonBeforeAfter == GDB_FIRST_SON){
GdbGroup* pGroup = dynamic_cast<GdbGroup*> ( pGRef) ; GdbGroup* pGroup = ::GetGdbGroup( pGRef) ;
if ( pGroup == nullptr) if ( pGroup == nullptr)
return false ; return false ;
// inserisco in testa alla lista del padre // inserisco in testa alla lista del padre
@@ -621,7 +668,7 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe
} }
// inserisco come figlio, in coda alla lista del padre // inserisco come figlio, in coda alla lista del padre
else { else {
GdbGroup* pGroup = dynamic_cast<GdbGroup*> ( pGRef) ; GdbGroup* pGroup = ::GetGdbGroup( pGRef) ;
if ( pGroup == nullptr) if ( pGroup == nullptr)
return false ; return false ;
// inserisco in coda alla lista del padre // inserisco in coda alla lista del padre
@@ -650,6 +697,8 @@ GeomDB::InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& fr
// verifico validità apparente RefId // verifico validità apparente RefId
if ( nRefId < GDB_ID_ROOT) if ( nRefId < GDB_ID_ROOT)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// verifico validità Id // verifico validità Id
if ( nId <= GDB_ID_ROOT) if ( nId <= GDB_ID_ROOT)
nId = m_IdManager.GetNewId() ; nId = m_IdManager.GetNewId() ;
@@ -664,7 +713,7 @@ GeomDB::InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& fr
// assegno riferimento // assegno riferimento
pGdbGroup->SetFrame( frFrame) ; pGdbGroup->SetFrame( frFrame) ;
// inserisco nel DB // inserisco nel DB
if ( ! InsertInGeomDB( pGdbGroup, nRefId, nSonBeforeAfter)) { if ( ! InsertInGeomDB( pGdbGroup, nRefId, nSonBeforeAfter, false)) {
delete pGdbGroup ; delete pGdbGroup ;
return GDB_ID_NULL ; return GDB_ID_NULL ;
} }
@@ -685,6 +734,8 @@ GeomDB::InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj
{ {
// assegno GeoObj a gestore puntatore con rilascio automatico // assegno GeoObj a gestore puntatore con rilascio automatico
PtrOwner<IGeoObj> pRPGeoObj( pGeoObj) ; PtrOwner<IGeoObj> pRPGeoObj( pGeoObj) ;
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// verifico validità identificativo // verifico validità identificativo
if ( nId <= GDB_ID_ROOT) if ( nId <= GDB_ID_ROOT)
nId = m_IdManager.GetNewId() ; nId = m_IdManager.GetNewId() ;
@@ -702,7 +753,7 @@ GeomDB::InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj
// assegno dati // assegno dati
pGdbGeo->m_pGeoObj = Release( pRPGeoObj) ; pGdbGeo->m_pGeoObj = Release( pRPGeoObj) ;
// inserisco nel DB // inserisco nel DB
if ( ! InsertInGeomDB( pGdbGeo, nRefId, nSonBeforeAfter)) { if ( ! InsertInGeomDB( pGdbGeo, nRefId, nSonBeforeAfter, false)) {
delete pGdbGeo ; delete pGdbGeo ;
return GDB_ID_NULL ; return GDB_ID_NULL ;
} }
@@ -1185,6 +1236,9 @@ GeomDB::GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag) con
int int
GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob) GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob)
{ {
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// verifico Id destinazione // verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT) if ( nIdDest <= GDB_ID_ROOT)
nIdDest = m_IdManager.GetNewId() ; nIdDest = m_IdManager.GetNewId() ;
@@ -1227,7 +1281,7 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGl
} }
// inserisco nel DB (non rilascio il puntatore) // inserisco nel DB (non rilascio il puntatore)
if ( ! InsertInGeomDB( pGdODest, nRefId, nSonBeforeAfter)) if ( ! InsertInGeomDB( pGdODest, nRefId, nSonBeforeAfter, false))
return GDB_ID_NULL ; return GDB_ID_NULL ;
// rilascio il puntatore // rilascio il puntatore
@@ -1239,10 +1293,17 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGl
bool bool
GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob)
{ {
// l'oggetto e il riferimento non possono coincidere // verifico validità del riferimento
if ( nRefId < GDB_ID_ROOT)
return false ;
// l'oggetto e il riferimento non possono coincidere
if ( nId == nRefId) if ( nId == nRefId)
return ( ! IS_GDB_SON( nSonBeforeAfter)) ; return ( ! IS_GDB_SON( nSonBeforeAfter)) ;
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// verifico esistenza dell'oggetto // verifico esistenza dell'oggetto
GdbObj* pGdbObj = GetGdbObj( nId) ; GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr) if ( pGdbObj == nullptr)
@@ -1286,7 +1347,7 @@ GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob)
pGdbObj->Remove() ; pGdbObj->Remove() ;
// lo inserisco nella posizione opportuna // lo inserisco nella posizione opportuna
if ( ! InsertInGeomDB( pGdbObj, nRefId, nSonBeforeAfter, false)) { if ( ! InsertInGeomDB( pGdbObj, nRefId, nSonBeforeAfter, false, false)) {
// in caso di errore (condizione assai remota qui) cancello tutto // in caso di errore (condizione assai remota qui) cancello tutto
m_IdManager.RemoveObj( pGdbObj->m_nId) ; m_IdManager.RemoveObj( pGdbObj->m_nId) ;
m_SelManager.RemoveObj( pGdbObj) ; m_SelManager.RemoveObj( pGdbObj) ;
@@ -1367,9 +1428,14 @@ GeomDB::GetNewId( void) const
bool bool
GeomDB::ChangeId( int nId, int nNewId) GeomDB::ChangeId( int nId, int nNewId)
{ {
// se Id non validi, ritorno errore
if ( nId <= GDB_ID_ROOT || nNewId <= GDB_ID_ROOT)
return false ;
// se Id identici, non faccio alcunché // se Id identici, non faccio alcunché
if ( nNewId == nId) if ( nNewId == nId)
return true ; return true ;
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// verifico nuovo Id // verifico nuovo Id
if ( ExistsObj( nNewId)) if ( ExistsObj( nNewId))
return false ; return false ;
@@ -1410,7 +1476,10 @@ GeomDB::Erase( GdbObj* pGdbObj)
if ( pGdbObj == nullptr || pGdbObj == &m_GrpRadix) if ( pGdbObj == nullptr || pGdbObj == &m_GrpRadix)
return false ; return false ;
// notifico eventuale UserObj // verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// notifico eventuale UserObj
if ( pGdbObj->m_pUserObj != nullptr) { if ( pGdbObj->m_pUserObj != nullptr) {
// recupero il successivo // recupero il successivo
const GdbObj* pGdbNext = pGdbObj->GetNext() ; const GdbObj* pGdbNext = pGdbObj->GetNext() ;
@@ -1435,6 +1504,10 @@ GeomDB::RemoveGeoObjAndErase( int nId)
// non si può cancellare il gruppo radice (escludo anche Id non validi) // non si può cancellare il gruppo radice (escludo anche Id non validi)
if ( nId <= GDB_ID_ROOT) if ( nId <= GDB_ID_ROOT)
return nullptr ; return nullptr ;
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// recupero l'oggetto geometrico // recupero l'oggetto geometrico
GdbGeo* pGdbGeo = ::GetGdbGeo( m_IdManager.FindObj( nId)) ; GdbGeo* pGdbGeo = ::GetGdbGeo( m_IdManager.FindObj( nId)) ;
if ( pGdbGeo == nullptr) if ( pGdbGeo == nullptr)
@@ -1442,6 +1515,7 @@ GeomDB::RemoveGeoObjAndErase( int nId)
IGeoObj* pGeoObj = pGdbGeo->m_pGeoObj ; IGeoObj* pGeoObj = pGdbGeo->m_pGeoObj ;
// annullo il riferimento alla geometria nell'entità // annullo il riferimento alla geometria nell'entità
pGdbGeo->m_pGeoObj = nullptr ; pGdbGeo->m_pGeoObj = nullptr ;
// tolgo dalla lista e disalloco // tolgo dalla lista e disalloco
pGdbGeo->Remove() ; pGdbGeo->Remove() ;
delete pGdbGeo ; delete pGdbGeo ;
@@ -1477,6 +1551,10 @@ GeomDB::EmptyGroup( GdbObj* pGdbObj)
GdbGroup* pGrp = ::GetGdbGroup( pGdbObj) ; GdbGroup* pGrp = ::GetGdbGroup( pGdbObj) ;
if ( pGrp == nullptr) if ( pGrp == nullptr)
return false ; return false ;
// verifico unicità esecuzione
LockAddErase Lock( m_bAddEraseOn) ;
// lo svuoto // lo svuoto
return pGrp->Clear() ; return pGrp->Clear() ;
} }
@@ -2521,6 +2599,9 @@ GeomDB::GetCalcMaterial( const GdbObj* pGdbObj, Material& mMat) const
Color cCol ; Color cCol ;
if ( pGdbObj->GetCalcMaterial( cCol)) { if ( pGdbObj->GetCalcMaterial( cCol)) {
mMat.Set( cCol) ; mMat.Set( cCol) ;
Color cDiff = cCol ;
cDiff.Intensify( 1.25) ;
mMat.SetDiffuse( cDiff) ;
return true ; return true ;
} }
} }
@@ -2704,7 +2785,8 @@ GeomDB::SetInfo( int nId, const string& sKey, int nInfo)
bool bool
GeomDB::SetInfo( int nId, const string& sKey, double dInfo) GeomDB::SetInfo( int nId, const string& sKey, double dInfo)
{ {
return SetInfo( nId, sKey, ToString( dInfo)) ; int nErr ;
return ( SetInfo( nId, sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -2874,6 +2956,19 @@ GeomDB::RemoveInfo( int nId, const string& sKey)
return pGdbObj->RemoveInfo( sKey) ; return pGdbObj->RemoveInfo( sKey) ;
} }
//----------------------------------------------------------------------------
bool
GeomDB::GetAllInfo( int nId, STRVECTOR& vsInfo) const
{
// recupero l'oggetto
const GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr)
return false ;
// recupero tutte le Info
return pGdbObj->GetAllInfo( vsInfo) ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
GeomDB::CopyAllInfoFrom( int nId, int nSouId) GeomDB::CopyAllInfoFrom( int nId, int nSouId)
@@ -2883,7 +2978,7 @@ GeomDB::CopyAllInfoFrom( int nId, int nSouId)
if ( pGdbObj == nullptr) if ( pGdbObj == nullptr)
return false ; return false ;
// recupero l'oggetto sorgente // recupero l'oggetto sorgente
GdbObj* pGdbObjSou = GetGdbObj( nSouId) ; const GdbObj* pGdbObjSou = GetGdbObj( nSouId) ;
if ( pGdbObjSou == nullptr) if ( pGdbObjSou == nullptr)
return false ; return false ;
@@ -2896,6 +2991,51 @@ GeomDB::CopyAllInfoFrom( int nId, int nSouId)
return true ; return true ;
} }
//----------------------------------------------------------------------------
// Stipple (significativo solo per curve)
//----------------------------------------------------------------------------
bool
GeomDB::DumpStipple( int nId, string& sOut, bool bMM, const char* szNewLine) const
{
// recupero l'oggetto
const GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr)
return false ;
// eseguo il dump
if ( pGdbObj->m_nStpFactor != 0) {
// nome della texture
sOut += "Stipple=" ;
sOut += ToString( pGdbObj->m_nStpFactor) ;
sOut += "-" + ToString( pGdbObj->m_nStpPattern, 1, 16) ;
sOut += szNewLine ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetStipple( int nId, int nFactor, int nPattern)
{
// recupero l'oggetto
GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr)
return false ;
// imposto lo stipple
return pGdbObj->SetStipple( nFactor, nPattern) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetStipple( int nId, int& nFactor, int& nPattern) const
{
// recupero l'oggetto
const GdbObj* pGdbObj = GetGdbObj( nId) ;
if ( pGdbObj == nullptr)
return false ;
// recupero lo stipple
return pGdbObj->GetStipple( nFactor, nPattern) ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// TextureData // TextureData
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -2907,7 +3047,7 @@ GeomDB::DumpTextureData( int nId, string& sOut, bool bMM, const char* szNewLine)
if ( pGdbObj == nullptr) if ( pGdbObj == nullptr)
return false ; return false ;
// eseguo il dump // eseguo il dump
if ( pGdbObj->m_pTxrData != nullptr) if ( pGdbObj->m_pTxrData != nullptr)
return pGdbObj->m_pTxrData->Dump( *this, sOut, bMM, szNewLine) ; return pGdbObj->m_pTxrData->Dump( *this, sOut, bMM, szNewLine) ;
else else
return true ; return true ;
+21 -14
View File
@@ -1,13 +1,13 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2013-2014 // EgalTech 2013-2023
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : GeomDB.h Data : 03.12.14 Versione : 1.5l1 // File : GeomDB.h Data : 09.07.23 Versione : 2.5g1
// Contenuto : Dichiarazione della classe GeomDB. // Contenuto : Dichiarazione della classe GeomDB.
// //
// //
// //
// Modifiche : 22.01.13 DS Creazione modulo. // Modifiche : 22.01.13 DS Creazione modulo.
// 03.12.14 DS Aggiunta gestione riferimento di griglia. //
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -20,6 +20,7 @@
#include "SelManager.h" #include "SelManager.h"
#include "GdbMaterialMgr.h" #include "GdbMaterialMgr.h"
#include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGeomDB.h"
#include <atomic>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class GeomDB : public IGeomDB class GeomDB : public IGeomDB
@@ -179,7 +180,12 @@ class GeomDB : public IGeomDB
bool GetInfo( int nId, const std::string& sKey, STRVECTOR& vsInfo) const override ; bool GetInfo( int nId, const std::string& sKey, STRVECTOR& vsInfo) const override ;
bool ExistsInfo( int nId, const std::string& sKey) const override ; bool ExistsInfo( int nId, const std::string& sKey) const override ;
bool RemoveInfo( int nId, const std::string& sKey) override ; bool RemoveInfo( int nId, const std::string& sKey) override ;
bool GetAllInfo( int nId, STRVECTOR& vsInfo) const override ;
bool CopyAllInfoFrom( int nId, int nSouId) override ; bool CopyAllInfoFrom( int nId, int nSouId) override ;
// Stipple (significativo solo per curve)
bool DumpStipple( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
bool SetStipple( int nId, int nFactor, int nPattern) override ;
bool GetStipple( int nId, int& nFactor, int& nPattern) const override ;
// TextureData // TextureData
bool DumpTextureData( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; bool DumpTextureData( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
bool SetTextureName( int nId, const std::string& sTxrName) override ; bool SetTextureName( int nId, const std::string& sTxrName) override ;
@@ -221,14 +227,14 @@ class GeomDB : public IGeomDB
GdbObj* GetGdbObj( int nId) ; GdbObj* GetGdbObj( int nId) ;
const GdbObj* GetGdbObj( int nId) const ; const GdbObj* GetGdbObj( int nId) const ;
GdbGeo* GetGdbGeo( int nId) GdbGeo* GetGdbGeo( int nId)
{ return dynamic_cast<GdbGeo*>( GetGdbObj( nId)) ; } { return ::GetGdbGeo( GetGdbObj( nId)) ; }
const GdbGeo* GetGdbGeo( int nId) const const GdbGeo* GetGdbGeo( int nId) const
{ return dynamic_cast<const GdbGeo*>( GetGdbObj( nId)) ; } { return ::GetGdbGeo( GetGdbObj( nId)) ; }
GdbGroup* GetGdbGroup( int nId) GdbGroup* GetGdbGroup( int nId)
{ return dynamic_cast<GdbGroup*>( GetGdbObj( nId)) ; } { return ::GetGdbGroup( GetGdbObj( nId)) ; }
const GdbGroup* GetGdbGroup( int nId) const const GdbGroup* GetGdbGroup( int nId) const
{ return dynamic_cast<const GdbGroup*>( GetGdbObj( nId)) ; } { return ::GetGdbGroup( GetGdbObj( nId)) ; }
bool InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTestId = true) ; bool InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bLockAddErase = true, bool bTestId = true) ;
int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob) ; int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob) ;
bool Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) ; bool Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) ;
bool Erase( GdbObj* pGObj) ; bool Erase( GdbObj* pGObj) ;
@@ -252,10 +258,11 @@ class GeomDB : public IGeomDB
{ return m_IterManager.RemoveGdbIterator( pIter) ; } { return m_IterManager.RemoveGdbIterator( pIter) ; }
private : private :
IdManager m_IdManager ; // gestore del nuovo Id IdManager m_IdManager ; // gestore del nuovo Id
IterManager m_IterManager ; // gestore lista iteratori attivi IterManager m_IterManager ; // gestore lista iteratori attivi
SelManager m_SelManager ; // gestore lista oggetti selezionati SelManager m_SelManager ; // gestore lista oggetti selezionati
GdbMaterialMgr m_MatManager ; // gestore lista materiali GdbMaterialMgr m_MatManager ; // gestore lista materiali
GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB
Frame3d m_GridFrame ; // riferimento della griglia Frame3d m_GridFrame ; // riferimento della griglia
std::atomic_flag m_bAddEraseOn ; // flag esecuzione inserimento o cancellazione in corso (per multi thread)
} ; } ;
+759
View File
@@ -0,0 +1,759 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2018
//----------------------------------------------------------------------------
// File : HashGrids1d.cpp Data : 02.05.22 Versione : 2.4e1
// Contenuto : Funzioni della classe HashGrids1d.
//
//
//
// Modifiche : 04.07.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "/EgtDev/Include/EGkHashGrids1d.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include <algorithm>
using namespace std ;
//----------------------------------------------------------------------------
const size_t CellCount = 16 ;
const size_t cellVectorSize = 16 ;
const size_t occupiedCellsVectorSize = 256 ;
const size_t minimalGridDensity = 1 ;
const size_t gridActivationThreshold = 64 ;
const double hierarchyFactor = 2 ;
const double MIN_CELL_SIZE = 5.0 ;
//----------------------------------------------------------------------------
// HashGrid1d
//----------------------------------------------------------------------------
class HashGrid1d
{
private :
struct Cell
{
HashGrids1d::PtrObjVector* m_Objs ; // Vettore dei puntatori agli oggetti nella cella, come puntatore
int* m_neighborOffset ; // Puntatore ad array con offsets per accedere direttamente ai vicini
size_t m_occupiedCellsId ; // Indice della cella nel vettore delle celle occupate
Cell( void)
: m_Objs( nullptr), m_neighborOffset( nullptr), m_occupiedCellsId( 0) {}
} ;
typedef vector<Cell*> CellVector ;
public :
explicit HashGrid1d( double dCellSpan) ;
~HashGrid1d( void) ;
double GetCellSpan( void) const
{ return m_dCellSpan ; }
void Add( HashGrids1d::ObjData& obj) ;
void Remove( HashGrids1d::ObjData& obj) ;
void Update( HashGrids1d::ObjData& obj) ;
void Find( const BBox3d& b3Test, INTVECTOR& vnIds) ;
void Clear( void) ;
private :
void InitNeighborOffsets( void) ;
size_t Hash( const Point3d& ptP) const ;
void Add( HashGrids1d::ObjData& obj, Cell* cell) ;
void Remove( HashGrids1d::ObjData& obj, Cell* cell) ;
void Enlarge( void) ;
static inline bool PowerOfTwo( size_t number) ;
private :
Cell* m_cell ; // Vettore di celle della griglia
size_t m_CellCount ; // Numero di celle allocate in direzione Z
size_t m_HashMask ; // Maschera di bit per calcolo hash
size_t m_enlargementThreshold ; // Soglia corrente per incremetare le dimensioni della griglia
double m_dCellSpan ; // Dimensione di una cella (cubica) della griglia
double m_dInvCellSpan ; // Inverso della dimensione di una cella
CellVector m_occupiedCells ; // Vettore delle celle occupate in questa griglia
size_t m_objCount ; // Numero di oggetti presenti in questa griglia
int m_stdNeighborOffset[3] ; // Array degli offset standard per le adiacenze
BBox3d m_b3Grid ; // Box totale degli oggetti inseriti in questa griglia
} ;
//----------------------------------------------------------------------------
HashGrid1d::HashGrid1d( double dCellSpan)
{
// Initialization of all member variables and ...
m_CellCount = PowerOfTwo( CellCount) ? CellCount : 16 ;
m_HashMask = m_CellCount - 1 ;
m_enlargementThreshold = m_CellCount / minimalGridDensity ;
// allocazione dell'array lineare che rappresenta lo hash grid.
m_cell = new Cell[ m_CellCount] ;
// ogni cella è già inizializzata come vuota
// imposto gli offset ai vicini
InitNeighborOffsets() ;
m_dCellSpan = max( dCellSpan, 10 * EPS_SMALL) ;
m_dInvCellSpan = 1. / dCellSpan ;
m_occupiedCells.reserve( occupiedCellsVectorSize) ;
m_objCount = 0 ;
}
//----------------------------------------------------------------------------
HashGrid1d::~HashGrid1d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
delete[] m_cell ;
}
//----------------------------------------------------------------------------
void
HashGrid1d::Add( HashGrids1d::ObjData& obj)
{
// If adding the body will cause the total number of bodies assigned to this grid to exceed the
// enlargement threshold, the size of this hash grid must be increased.
if ( m_objCount == m_enlargementThreshold)
Enlarge() ;
// Calculate (and store) the hash value (= the body's cell association) and ...
size_t h = Hash( obj.box.GetMin()) ;
obj.nHash = h ;
// ... insert the body into the corresponding cell.
Cell* pCell = m_cell + h ;
Add( obj, pCell) ;
++ m_objCount ;
// Aggiorno box di griglia
m_b3Grid.Add( obj.box) ;
}
//----------------------------------------------------------------------------
void
HashGrid1d::Remove( HashGrids1d::ObjData& obj)
{
// The stored hash value (= the body's cell association) is used in order to directly access the
// cell from which this body will be removed.
Cell* pCell = m_cell + obj.nHash ;
Remove( obj, pCell) ;
-- m_objCount ;
}
//----------------------------------------------------------------------------
void
HashGrid1d::Update( HashGrids1d::ObjData& obj)
{
// The hash value is recomputed based on the body's current spatial location.
size_t newHash = Hash( obj.box.GetMin()) ;
size_t oldHash = obj.nHash ;
// If this new hash value is identical to the hash value of the previous time step, the body
// remains assigned to its current grid cell.
if ( newHash == oldHash)
return ;
// Only if the hash value changes, the cell association has to be changed, too - meaning, the
// body has to be removed from its currently assigned cell and ...
Cell* pCell = m_cell + oldHash ;
Remove( obj, pCell) ;
obj.nHash = newHash ;
// ... stored in the cell that corresponds to the new hash value.
pCell = m_cell + newHash ;
Add( obj, pCell) ;
// Aggiorno box di griglia
m_b3Grid.Add( obj.box) ;
}
//----------------------------------------------------------------------------
void
HashGrid1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds)
{
// Limito il box a quello di griglia
BBox3d b3Int ;
if ( ! b3Test.FindIntersection( m_b3Grid, b3Int))
return ;
// Recupero gli estremi del box
Point3d ptMin ;
double dXDim, dYDim, dZDim ;
if ( ! b3Int.GetMinDim( ptMin, dXDim, dYDim, dZDim))
return ;
// Sposto p.to minimo in meno di una cella (oggetti possono occupare 2 celle) e allargo tutto di EPS_SMALL
ptMin -= Vector3d( 0, 0, 1) * ( m_dCellSpan + EPS_SMALL) ;
dZDim += m_dCellSpan + 2 * EPS_SMALL ;
// Numero di celle da esplorare sull'asse Z
int nZSpan = min( static_cast<int>( ceil( dZDim * m_dInvCellSpan)), int( m_CellCount)) ;
//string sOut = "Celle=" + ToString( int( m_CellCount)) + " Occupate=" + ToString( int(m_occupiedCells.size())) + " Span=" + ToString( nZSpan) ;
//LOG_INFO( GetEGkLogger(), sOut.c_str()) ;
// Se conviene verificare queste celle
if ( nZSpan < 5 * int( m_occupiedCells.size())) {
// cella di base
int nZ = static_cast<int>( Hash( ptMin)) ;
for ( int i = 0 ; i <= nZSpan ; ++ i) {
// inserisco in lista gli oggetti della cella
if ( m_cell[nZ].m_Objs != nullptr) {
for ( auto pObj : *( m_cell[nZ].m_Objs)) {
if ( b3Int.Overlaps( pObj->box))
vnIds.push_back( pObj->nId) ;
}
}
// passo alla successiva in Z+
nZ += m_cell[nZ].m_neighborOffset[2] ;
}
}
// altrimenti verifico direttamente tutte e sole quelle occupate
else {
// ciclo sulle celle occupate
for ( auto cell : m_occupiedCells) {
// inserisco in lista gli oggetti della cella
if ( cell->m_Objs != nullptr) {
for ( auto pObj : *(cell->m_Objs)) {
if ( b3Int.Overlaps( pObj->box))
vnIds.push_back( pObj->nId) ;
}
}
}
}
}
//----------------------------------------------------------------------------
void
HashGrid1d::Clear( void)
{
for ( auto cell : m_occupiedCells) {
delete cell->m_Objs ;
cell->m_Objs = nullptr ;
}
m_occupiedCells.clear() ;
m_objCount = 0 ;
m_b3Grid.Reset() ;
}
//----------------------------------------------------------------------------
void
HashGrid1d::InitNeighborOffsets( void)
{
int nc = static_cast<int>( m_CellCount) ;
// Initialization of the grid-global offset array that is valid for all inner cells in the hash grid.
m_stdNeighborOffset[0] = -1 ;
m_stdNeighborOffset[1] = 0 ;
m_stdNeighborOffset[2] = 1 ;
// Allocation and initialization of the offset arrays of all the border cells. All inner cells
// are set to point to the grid-global offset array.
Cell* c = m_cell ;
for ( int i = 0 ; i < nc ; ++ i, ++ c) {
// cella di bordo
if ( i == 0) {
c->m_neighborOffset = new int[3] ;
c->m_neighborOffset[0] = nc - 1 ;
c->m_neighborOffset[1] = 0 ;
c->m_neighborOffset[2] = 1 ;
}
else if ( i == nc - 1) {
c->m_neighborOffset = new int[3] ;
c->m_neighborOffset[0] = -1 ;
c->m_neighborOffset[1] = 0 ;
c->m_neighborOffset[2] = -nc + 1 ;
}
// cella interna
else {
c->m_neighborOffset = m_stdNeighborOffset ;
}
}
}
//----------------------------------------------------------------------------
size_t
HashGrid1d::Hash( const Point3d& ptP) const
{
size_t nHash ;
if ( ptP.z < 0) {
double i = ( - ptP.z ) * m_dInvCellSpan ;
nHash = m_CellCount - 1 - ( static_cast<size_t>( i ) & m_HashMask) ;
}
else {
double i = ptP.z * m_dInvCellSpan ;
nHash = static_cast<size_t>( i ) & m_HashMask ;
}
return nHash ;
}
//----------------------------------------------------------------------------
void
HashGrid1d::Add( HashGrids1d::ObjData& obj, Cell* cell)
{
// If this cell is already occupied by other bodies, which means the pointer to the body
// container holds a valid address and thus the container itself is properly initialized, then
// the body is simply added to this already existing body container. Note that the index position
// is memorized (=> "body->setCellId()") in order to ensure constant time removal.
if ( cell->m_Objs != nullptr) {
obj.nCellId = cell->m_Objs->size() ;
cell->m_Objs->push_back( &obj) ;
}
// If, however, the cell is still empty, then the object container, first of all, must be created
// (i.e., allocated) and properly initialized (i.e., sufficient initial storage capacity must be
// reserved). Furthermore, the cell must be inserted into the grid-global vector 'm_occupiedCells'
// in which all cells that are currently occupied by bodies are recorded.
else {
cell->m_Objs = new HashGrids1d::PtrObjVector ;
cell->m_Objs->reserve( cellVectorSize) ;
obj.nCellId = 0 ;
cell->m_Objs->push_back( &obj) ;
cell->m_occupiedCellsId = m_occupiedCells.size() ;
m_occupiedCells.push_back( cell) ;
}
}
//----------------------------------------------------------------------------
void
HashGrid1d::Remove( HashGrids1d::ObjData& obj, Cell* cell )
{
// If the body is the last body that is stored in this cell ...
if ( cell->m_Objs->size() == 1) {
// ... the cell's body container is destroyed and ...
delete cell->m_Objs ;
cell->m_Objs = nullptr ;
// ... the cell is removed from the grid-global vector 'm_occupiedCells' that records all
// body-occupied cells. Since the cell memorized its index (=> 'm_occupiedCellsId') in this
// vector, it can be removed in constant time, O(1).
if ( cell->m_occupiedCellsId == m_occupiedCells.size() - 1) {
m_occupiedCells.pop_back() ;
}
else {
Cell* lastCell = m_occupiedCells.back() ;
m_occupiedCells.pop_back() ;
lastCell->m_occupiedCellsId = cell->m_occupiedCellsId ;
m_occupiedCells[ cell->m_occupiedCellsId ] = lastCell ;
}
}
// If the body is *not* the last body that is stored in this cell ...
else {
size_t cellId = obj.nCellId ;
// ... the body is removed from the cell's body container. Since the body memorized its
// index (=> 'cellId') in this container, it can be removed in constant time, O(1).
if ( cellId == cell->m_Objs->size() - 1) {
cell->m_Objs->pop_back() ;
}
else {
HashGrids1d::ObjData* lastElement = cell->m_Objs->back() ;
cell->m_Objs->pop_back() ;
lastElement->nCellId = cellId ;
(*cell->m_Objs)[ cellId] = lastElement ;
}
}
}
//----------------------------------------------------------------------------
void
HashGrid1d::Enlarge( void)
{
HashGrids1d::PtrObjVector PObjVecTemp ;
PObjVecTemp.reserve( m_objCount) ;
// All objs that are assigned to this grid are temporarily removed, ...
for ( auto cell = m_occupiedCells.begin() ; cell < m_occupiedCells.end() ; ++ cell) {
HashGrids1d::PtrObjVector* cellBodies = (*cell)->m_Objs ;
for ( auto e = cellBodies->begin() ; e < cellBodies->end() ; ++ e) {
PObjVecTemp.push_back( *e) ;
}
}
// ... the grid's current data structures are deleted, ...
Clear() ;
for ( auto pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
delete[] m_cell ;
// ... the number of cells is doubled in each coordinate direction, ...
m_CellCount *= 2 ;
m_HashMask = m_CellCount - 1 ;
// ... a new threshold for enlarging this hash grid is set, ...
m_enlargementThreshold = m_CellCount / minimalGridDensity ;
// ... a new linear array of cells representing this enlarged hash grid is allocated and ...
m_cell = new Cell[ m_CellCount] ;
// ... initialized, and finally ...
InitNeighborOffsets() ;
// ... all previously removed objs are reinserted.
for ( auto p = PObjVecTemp.begin() ; p < PObjVecTemp.end() ; ++ p) {
Add( **p) ;
}
}
//----------------------------------------------------------------------------
bool
HashGrid1d::PowerOfTwo( size_t number)
{
return ( ( number > 0) && ( ( number & ( number - 1)) == 0)) ;
}
//----------------------------------------------------------------------------
// HashGrids1d
//----------------------------------------------------------------------------
HashGrids1d::HashGrids1d( void)
{
try {
// Finchè il numero di oggetti non supera la soglia non si usano le griglie
m_nonGridObjs.reserve( gridActivationThreshold) ;
m_bActivate = true ;
m_bGridActive = false ;
}
catch(...) {
LOG_ERROR( GetEGkLogger(), "Error in HashGrids1d constructor") ;
}
}
//----------------------------------------------------------------------------
HashGrids1d::~HashGrids1d( void)
{
// Delete all grids that are stored in the grid hierarchy (=> m_GridList).
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
}
//----------------------------------------------------------------------------
void
HashGrids1d::SetActivationGrid( bool bActivate)
{
m_bActivate = bActivate ;
}
//----------------------------------------------------------------------------
bool
HashGrids1d::Add( int nObjId, const BBox3d& box)
{
try {
// The body is marked as being added to 'm_objsToAdd' by setting the grid pointer to nullptr and
// setting the cell-ID to '0'. Additionally, the hash value is used to memorize the body's
// index position in the 'm_objsToAdd' vector.
m_ObjsList.emplace_back( nObjId, box, nullptr, m_objsToAdd.size(), 0) ;
// inserisco nel Map
m_ObjsMap.emplace( nObjId, &(m_ObjsList.back())) ;
// Temporarily add the body to 'm_objsToAdd'. As soon as "findContacts()" is called, all
// bodies stored in 'm_objsToAdd' are finally inserted into the data structure.
m_objsToAdd.push_back( &(m_ObjsList.back())) ;
// Aggiorno il box complessivo
m_b3Objs.Add( box) ;
return true ;
}
catch(...) {
LOG_ERROR( GetEGkLogger(), "Error in HashGrids1d::Add") ;
return false ;
}
}
//----------------------------------------------------------------------------
bool
HashGrids1d::Modify( int nObjId, const BBox3d& box)
{
// Cerco l'oggetto con l'Id voluto
auto iIter = m_ObjsMap.find( nObjId) ;
if ( iIter == m_ObjsMap.end())
return false ;
ObjData* pObj = iIter->second ;
if ( pObj == nullptr)
return false ;
// Modifico il suo box
pObj->box = box ;
// Aggiorno il box complessivo
m_b3Objs.Add( box) ;
return true ;
}
//----------------------------------------------------------------------------
bool
HashGrids1d::Remove( int nObjId)
{
// Cerco l'oggetto con l'Id voluto
auto iIter = m_ObjsMap.find( nObjId) ;
if ( iIter == m_ObjsMap.end())
return false ;
ObjData* pObj = iIter->second ;
if ( pObj == nullptr)
return false ;
// Recupero la griglia di appartenenza
HashGrid1d* pGrid = pObj->pHGrid ;
// The body is stored in a hash grid from which it must be removed.
if ( pGrid != nullptr) {
pGrid->Remove( *pObj) ;
}
// The body's grid pointer is equal to nullptr.
// => The body is either stored in 'm_objsToAdd' (-> cell-ID = 0) or 'm_nonGridObjs' (-> cell-ID = 1).
else {
if ( pObj->nCellId == 0) {
// the body's hash value => index of this body in 'm_objsToAdd'
if ( pObj->nHash == m_objsToAdd.size() - 1) {
m_objsToAdd.pop_back() ;
}
else if ( pObj->nHash < m_objsToAdd.size()) {
ObjData* pLastObj = m_objsToAdd.back() ;
m_objsToAdd.pop_back() ;
pLastObj->nHash = pObj->nHash ;
m_objsToAdd[ pObj->nHash] = pLastObj ;
}
else
return false ;
}
else {
// the body's hash value => index of this body in 'm_nonGridObjs'
if ( pObj->nHash == m_nonGridObjs.size() - 1) {
m_nonGridObjs.pop_back();
}
else if ( pObj->nHash < m_nonGridObjs.size()) {
ObjData* pLastObj = m_nonGridObjs.back() ;
m_nonGridObjs.pop_back() ;
pLastObj->nHash = pObj->nHash ;
m_nonGridObjs[ pObj->nHash] = pLastObj ;
}
else
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
HashGrids1d::Update( void)
{
try {
// Salvo stato di precedente attivazione delle griglie
bool bGridActivePrev = m_bGridActive ;
// Inseriamo gli oggetti presenti nel vettore m_objsToAdd
if ( m_objsToAdd.size() > 0 ) {
for ( auto pObj : m_objsToAdd) {
if ( m_bGridActive)
addGrid( *pObj) ;
else
addList( *pObj) ;
}
m_objsToAdd.clear() ;
}
// Aggiorniamo per eventuali modifiche agli oggetti già precedentemente presenti nelle griglie
if ( bGridActivePrev) {
for ( auto& Obj : m_ObjsList) {
HashGrid1d* pGrid = Obj.pHGrid ;
if ( pGrid != nullptr) {
double dSize = 0 ;
Obj.box.GetDiameter( dSize) ;
double dCellSpan = pGrid->GetCellSpan() ;
if ( dSize >= dCellSpan || dSize < ( dCellSpan / hierarchyFactor)) {
pGrid->Remove( Obj) ;
addGrid( Obj) ;
}
else {
pGrid->Update( Obj) ;
}
}
}
}
return true ;
}
catch(...) {
LOG_ERROR( GetEGkLogger(), "Error in HashGrids1d::Update") ;
return false ;
}
}
//----------------------------------------------------------------------------
bool
HashGrids1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
{
// pulisco il risultato
vnIds.clear() ;
vnIds.reserve( 128) ;
// limito con box globale
BBox3d b3Int ;
if ( ! b3Test.FindIntersection( m_b3Objs, b3Int))
return false ;
// ricerca nelle griglie
if ( m_bGridActive) {
for ( auto pGrid : m_GridList)
pGrid->Find( b3Int, vnIds) ;
}
// ricerca negli oggetti fuori griglia
for ( auto pObj : m_nonGridObjs) {
if ( b3Int.Overlaps( pObj->box))
vnIds.push_back( pObj->nId) ;
}
// ordino il risultato ed elimino gli indici ripetuti
sort( vnIds.begin(), vnIds.end()) ;
vnIds.erase( unique( vnIds.begin(), vnIds.end()), vnIds.end()) ;
return ( vnIds.size() > 0) ;
}
//----------------------------------------------------------------------------
void
HashGrids1d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_objsToAdd.clear() ;
m_b3Objs.Reset() ;
}
//----------------------------------------------------------------------------
void
HashGrids1d::addGrid( ObjData& obj)
{
double size = - 1 ;
obj.box.GetDiameter( size) ;
// If the body is finite in size, it must be assigned to a grid with suitably sized cells.
if ( size > - EPS_ZERO) {
size = max( size, MIN_CELL_SIZE) ;
HashGrid1d* pGrid = nullptr ;
if ( m_GridList.empty()) {
// If no hash grid yet exists in the hierarchy, an initial hash grid is created
// based on the body's size.
pGrid = new HashGrid1d( size * sqrt( hierarchyFactor)) ;
}
else {
// Check the hierarchy for a hash grid with suitably sized cells - if such a grid does not
// yet exist, it will be created.
double cellSpan = 0;
for ( auto g = m_GridList.begin(); g != m_GridList.end(); ++ g) {
pGrid = *g;
cellSpan = pGrid->GetCellSpan();
if ( size < cellSpan) {
cellSpan /= hierarchyFactor ;
if ( size < cellSpan ) {
while ( size < cellSpan)
cellSpan /= hierarchyFactor ;
pGrid = new HashGrid1d( cellSpan * hierarchyFactor) ;
m_GridList.insert( g, pGrid) ;
}
pGrid->Add( obj) ;
obj.pHGrid = pGrid ;
return ;
}
}
while ( size >= cellSpan)
cellSpan *= hierarchyFactor ;
pGrid = new HashGrid1d( cellSpan) ;
}
pGrid->Add( obj) ;
obj.pHGrid = pGrid ;
m_GridList.push_back( pGrid) ;
return ;
}
// The body - which is infinite in size - is marked as being added to 'm_nonGridObjs' by setting
// the grid pointer to nullptr and setting the cell-ID to '1'. Additionally, the hash value is used
// to memorize the body's index position in the 'm_nonGridObjs' vector.
obj.pHGrid = nullptr ;
obj.nHash = m_nonGridObjs.size() ;
obj.nCellId = 1 ;
m_nonGridObjs.push_back( &obj) ;
}
//----------------------------------------------------------------------------
void
HashGrids1d::addList( ObjData& obj)
{
// Se abilitato e superata la soglia ...
if ( m_bActivate && m_nonGridObjs.size() == gridActivationThreshold) {
if ( gridActivationThreshold > 0) {
// all objs stored in 'm_nonGridObjs' are inserted in grids
for ( size_t i = 0; i < gridActivationThreshold; ++i ) {
addGrid( *m_nonGridObjs[i] );
}
// ... the 'm_nonGridObjs' vector is cleared ...
m_nonGridObjs.clear() ;
}
addGrid( obj) ;
// ... and the usage of the hierarchical hash grids is activated irrevocably.
m_bGridActive = true ;
return ;
}
// The body is marked as being added to 'm_nonGridObjs' by setting the grid pointer to nullptr and
// setting the cell-ID to '1'. Additionally, the hash value is used to memorize the body's index
// position in the 'm_nonGridObjs' vector.
obj.pHGrid = nullptr ;
obj.nHash = m_nonGridObjs.size() ;
obj.nCellId = 1 ;
m_nonGridObjs.push_back( &obj) ;
}
+1 -1
View File
@@ -15,7 +15,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "DllMain.h" #include "DllMain.h"
#include "/EgtDev/Include/EGkHashGrids2d.h" #include "/EgtDev/Include/EGkHashGrids2d.h"
#include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include <algorithm> #include <algorithm>
using namespace std ; using namespace std ;
+1 -2
View File
@@ -15,7 +15,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "DllMain.h" #include "DllMain.h"
#include "/EgtDev/Include/EGkHashGrids3d.h" #include "/EgtDev/Include/EGkHashGrids3d.h"
#include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include <algorithm> #include <algorithm>
using namespace std ; using namespace std ;
@@ -684,7 +684,6 @@ HashGrids3d::Update( void)
double dSize = 0 ; double dSize = 0 ;
Obj.box.GetDiameter( dSize) ; Obj.box.GetDiameter( dSize) ;
double dCellSpan = pGrid->GetCellSpan() ; double dCellSpan = pGrid->GetCellSpan() ;
if ( dSize >= dCellSpan || dSize < ( dCellSpan / hierarchyFactor)) { if ( dSize >= dCellSpan || dSize < ( dCellSpan / hierarchyFactor)) {
pGrid->Remove( Obj) ; pGrid->Remove( Obj) ;
addGrid( Obj) ; addGrid( Obj) ;
+7 -7
View File
@@ -15,7 +15,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "IntersCrvCompoCrvCompo.h" #include "IntersCrvCompoCrvCompo.h"
#include "CurveAux.h" #include "CurveAux.h"
#include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkAngle.h" #include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGkHashGrids2d.h" #include "/EgtDev/Include/EGkHashGrids2d.h"
#include <algorithm> #include <algorithm>
@@ -541,7 +541,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
for ( int i = 0 ; i < m_nNumInters ; ++ i) { for ( int i = 0 ; i < m_nNumInters ; ++ i) {
// se il tipo di accostamento per la curva A non è definito // se il tipo di accostamento per la curva A non è definito
if ( m_Info[i].IciA[0].nPrevTy == ICCT_NULL) { if ( m_Info[i].IciA[0].nPrevTy == ICCT_NULL) {
if ( i > 0 || bCrvAClosed) { if ( i > 0 || ( bCrvAClosed && ! bAutoInters)) {
int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ; int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ;
m_Info[i].IciA[0].nPrevTy = ( m_Info[j].bOverlap ? m_Info[j].IciA[1].nNextTy : m_Info[j].IciA[0].nNextTy) ; m_Info[i].IciA[0].nPrevTy = ( m_Info[j].bOverlap ? m_Info[j].IciA[1].nNextTy : m_Info[j].IciA[0].nNextTy) ;
} }
@@ -549,7 +549,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
// se il tipo di allontanamento per la curva A non è definito // se il tipo di allontanamento per la curva A non è definito
int ki = ( m_Info[i].bOverlap ? 1 : 0) ; int ki = ( m_Info[i].bOverlap ? 1 : 0) ;
if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL) { if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
if ( i < m_nNumInters - 1 || bCrvAClosed) { if ( i < m_nNumInters - 1 || ( bCrvAClosed && ! bAutoInters)) {
int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ; int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ;
m_Info[i].IciA[ki].nNextTy = m_Info[j].IciA[0].nPrevTy ; m_Info[i].IciA[ki].nNextTy = m_Info[j].IciA[0].nPrevTy ;
} }
@@ -561,14 +561,14 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
for ( int i = 0 ; i < m_nNumInters ; ++ i) { for ( int i = 0 ; i < m_nNumInters ; ++ i) {
// se il tipo di accostamento per la curva B non è definito // se il tipo di accostamento per la curva B non è definito
if ( m_Info[i].IciB[0].nPrevTy == ICCT_NULL) { if ( m_Info[i].IciB[0].nPrevTy == ICCT_NULL) {
if ( i > 0 || bCrvBClosed) { if ( i > 0 || ( bCrvBClosed && ! bAutoInters)) {
int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ; int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ;
m_Info[i].IciB[0].nPrevTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nNextTy : m_Info[j].IciB[0].nNextTy) ; m_Info[i].IciB[0].nPrevTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nNextTy : m_Info[j].IciB[0].nNextTy) ;
} }
} }
// se il tipo di allontanamento per la curva B non è definito // se il tipo di allontanamento per la curva B non è definito
if ( m_Info[i].IciB[0].nNextTy == ICCT_NULL) { if ( m_Info[i].IciB[0].nNextTy == ICCT_NULL) {
if ( i < m_nNumInters - 1 || bCrvBClosed) { if ( i < m_nNumInters - 1 || ( bCrvBClosed && ! bAutoInters)) {
int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ; int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ;
m_Info[i].IciB[0].nNextTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nPrevTy : m_Info[j].IciB[0].nPrevTy) ; m_Info[i].IciB[0].nNextTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nPrevTy : m_Info[j].IciB[0].nPrevTy) ;
} }
@@ -702,9 +702,9 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
// assegno sottoindici (considero solo intersezioni overlap) // assegno sottoindici (considero solo intersezioni overlap)
int ki = 0 ; int ki = 0 ;
int kj = 1 ; int kj = 1 ;
// verifico se entrambe overlap, la precedente termina con ON e la successiva inizia con ON // verifico se entrambe overlap con lo stesso verso, la precedente termina con ON e la successiva inizia con ON
// sia sulla curva A sia sulla curva B (tenendo conto del senso equiverso/controverso) // sia sulla curva A sia sulla curva B (tenendo conto del senso equiverso/controverso)
if ( m_Info[j].bOverlap && m_Info[i].bOverlap && if ( m_Info[j].bOverlap && m_Info[i].bOverlap && m_Info[j].bCBOverEq == m_Info[i].bCBOverEq &&
m_Info[j].IciA[kj].nNextTy == ICCT_ON && m_Info[i].IciA[ki].nPrevTy == ICCT_ON && m_Info[j].IciA[kj].nNextTy == ICCT_ON && m_Info[i].IciA[ki].nPrevTy == ICCT_ON &&
GetCrvBDirANext( m_Info[j]) == ICCT_ON && GetCrvBDirAPrev( m_Info[i]) == ICCT_ON) { GetCrvBDirANext( m_Info[j]) == ICCT_ON && GetCrvBDirAPrev( m_Info[i]) == ICCT_ON) {
// CurvaA : riporto il secondo punto del successivo sul secondo punto del precedente // CurvaA : riporto il secondo punto del successivo sul secondo punto del precedente
+2 -5
View File
@@ -23,7 +23,7 @@
#include "/EgtDev/Include/EGkIntersCurves.h" #include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGkPlane3d.h"
#include "/EgtDev/Include/EGtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <algorithm> #include <algorithm>
using namespace std ; using namespace std ;
@@ -659,11 +659,8 @@ IntersCurveCurve::CalcCurveInOrOut( const ICurve* pCurveA, const ICurve* pCurveB
bool bool
IntersCurveCurve::GetCurveOutClass( const ICurve* pCurve, int& nClass) IntersCurveCurve::GetCurveOutClass( const ICurve* pCurve, int& nClass)
{ {
PolyLine PL ;
if ( ! pCurve->ApproxWithLines( LIN_TOL_APPROX, ANG_TOL_APPROX_DEG, ICurve::APL_SPECIAL, PL))
return false ;
double dArea ; double dArea ;
if ( ! PL.GetAreaXY( dArea)) if ( ! pCurve->GetAreaXY( dArea))
return false ; return false ;
nClass = (( dArea > 0) ? CRVC_OUT : CRVC_IN) ; nClass = (( dArea > 0) ? CRVC_OUT : CRVC_IN) ;
return true ; return true ;
+127 -108
View File
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// EgalTech 2020-2020 // EgalTech 2020-2022
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// File : IntersLineBox.cpp Data : 07.05.20 Versione : 2.2e1 // File : IntersLineBox.cpp Data : 08.01.22 Versione : 2.4a3
// Contenuto : Implementazione della intersezione linea/box. // Contenuto : Implementazione della intersezione linea/box.
// //
// //
@@ -13,13 +13,77 @@
//--------------------------- Include ---------------------------------------- //--------------------------- Include ----------------------------------------
#include "stdafx.h" #include "stdafx.h"
#include "SurfTriMesh.h" #include "IntersLineBox.h"
#include "/EgtDev/Include/EGkIntersLineBox.h" #include "/EgtDev/Include/EGkIntersLineBox.h"
#include "/EgtDev/Include/EGkIntersLineSurfTm.h" #include "/EgtDev/Include/EgtNumUtils.h"
#include <algorithm> #include <algorithm>
using namespace std ; using namespace std ;
//----------------------------------------------------------------------------
// Linea e box allineato assi devono essere nel medesimo sistema di riferimento.
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineBox( const Point3d& ptL, const Vector3d& vtL,
const Point3d& ptMin, const Point3d& ptMax,
double& dU1, double& dU2)
{
// Verifico il versore
if ( vtL.IsSmall())
return false ;
// Verifico gli estremi del box
if ( ptMin.x > ptMax.x + EPS_SMALL ||
ptMin.y > ptMax.y + EPS_SMALL ||
ptMin.z > ptMax.z + EPS_SMALL)
return false ;
// Casi di intersezione impossibile
if ( abs( vtL.x) < EPS_ZERO && ( ptL.x < ptMin.x - EPS_SMALL || ptL.x > ptMax.x + EPS_SMALL))
return false ;
if ( abs( vtL.y) < EPS_ZERO && ( ptL.y < ptMin.y - EPS_SMALL || ptL.y > ptMax.y + EPS_SMALL))
return false ;
if ( abs( vtL.z) < EPS_ZERO && ( ptL.z < ptMin.z - EPS_SMALL || ptL.z > ptMax.z + EPS_SMALL))
return false ;
// Parametri degli estremi della retta
dU1 = -INFINITO ;
dU2 = INFINITO ;
// Confronto con piani YZ (perpendicolari ad asse X)
if ( vtL.x > EPS_ZERO) {
dU1 = max( dU1, ( ptMin.x - ptL.x) / vtL.x) ;
dU2 = min( dU2, ( ptMax.x - ptL.x) / vtL.x) ;
}
else if ( vtL.x < -EPS_ZERO) {
dU1 = max( dU1, ( ptMax.x - ptL.x) / vtL.x) ;
dU2 = min( dU2, ( ptMin.x - ptL.x) / vtL.x) ;
}
// Confronto con piani ZX (perpendicolari ad asse Y)
if ( vtL.y > EPS_ZERO) {
dU1 = max( dU1, ( ptMin.y - ptL.y) / vtL.y) ;
dU2 = min( dU2, ( ptMax.y - ptL.y) / vtL.y) ;
}
else if ( vtL.y < -EPS_ZERO) {
dU1 = max( dU1, ( ptMax.y - ptL.y) / vtL.y) ;
dU2 = min( dU2, ( ptMin.y - ptL.y) / vtL.y) ;
}
// Confronto con piani XY (perpendicolari ad asse Z)
if ( vtL.z > EPS_ZERO) {
dU1 = max( dU1, ( ptMin.z - ptL.z) / vtL.z) ;
dU2 = min( dU2, ( ptMax.z - ptL.z) / vtL.z) ;
}
else if ( vtL.z < -EPS_ZERO){
dU1 = max( dU1, ( ptMax.z - ptL.z) / vtL.z) ;
dU2 = min( dU2, ( ptMin.z - ptL.z) / vtL.z) ;
}
return ( dU2 >= dU1) ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
IntersLineBox( const Point3d& ptL1, const Point3d& ptL2, const BBox3d& b3Box, INTDBLVECTOR& vInters, bool bFinite) IntersLineBox( const Point3d& ptL1, const Point3d& ptL2, const BBox3d& b3Box, INTDBLVECTOR& vInters, bool bFinite)
@@ -38,114 +102,69 @@ bool
IntersLineBox( const Point3d& ptL, const Vector3d& vtL, double dLen, const BBox3d& b3Box, INTDBLVECTOR& vInters, bool bFinite) IntersLineBox( const Point3d& ptL, const Vector3d& vtL, double dLen, const BBox3d& b3Box, INTDBLVECTOR& vInters, bool bFinite)
{ {
// Recupero i dati del Box // Recupero i dati del Box
Point3d ptMin ; Point3d ptMin, ptMax ;
double dDimX, dDimY, dDimZ ; if ( ! b3Box.GetMinMax( ptMin, ptMax))
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimZ))
return false ; return false ;
// Contorno di base
PolyLine PL ; // Pulisco vettore intersezioni
PL.AddUPoint( 0, ptMin) ; vInters.clear() ;
PL.AddUPoint( 1, ptMin + Vector3d( dDimX, 0, 0)) ;
PL.AddUPoint( 2, ptMin + Vector3d( dDimX, dDimY, 0)) ; // Eseguo intersezione della linea completa
PL.AddUPoint( 3, ptMin + Vector3d( 0, dDimY, 0)) ; double dU1, dU2 ;
PL.Close() ; bool bInters = IntersLineBox( ptL, vtL, b3Box.GetMin(), b3Box.GetMax(), dU1, dU2) ;
// Vettore altezza
Vector3d vtExtr( 0, 0, dDimZ) ; // Se non c'è intersezione
// Creo la superficie trimesh equivalente if ( ! bInters || ( bFinite && ( dU1 > dLen + EPS_SMALL || dU2 < -EPS_SMALL)))
SurfTriMesh Stm ; return true ;
if ( ! Stm.CreateByExtrusion( PL, vtExtr))
return false ; // Se le due intersezioni coincidono
SurfTriMesh StmBot ; if ( ( dU2 - dU1) < EPS_SMALL) {
if ( ! StmBot.CreateByFlatContour( PL)) double dU = ( dU1 + dU2) / 2 ;
return false ; if ( ! bFinite) {
StmBot.Invert() ; vInters.emplace_back( ILBT_TOUCH, dU) ;
SurfTriMesh StmTop ;
if ( ! StmTop.CreateByFlatContour( PL))
return false ;
StmTop.Translate( vtExtr) ;
if ( ! Stm.DoSewing( StmBot) || ! Stm.DoSewing( StmTop))
return false ;
// Calcolo l'intersezione
ILSIVECTOR vInfo ;
if ( ! IntersLineSurfTm( ptL, vtL, dLen, Stm, vInfo, bFinite))
return false ;
// ciclo sulle intersezioni
double dUcurr = -INFINITO ;
for ( const auto& Info : vInfo) {
// se intersezione puntuale
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
int nFlag = ILBT_TOUCH ;
if ( Info.dCosDN > EPS_ZERO)
nFlag = ILBT_OUT ;
else if ( Info.dCosDN < -EPS_ZERO)
nFlag = ILBT_IN ;
vInters.emplace_back( nFlag, Info.dU) ;
dUcurr = Info.dU ;
} }
// se altrimenti intersezione con coincidenza else {
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { if ( dU > - EPS_SMALL && dU < dLen + EPS_SMALL)
if ( Info.dU > dUcurr - EPS_SMALL) vInters.emplace_back( ILBT_TOUCH, Clamp( dU, 0., dLen)) ;
vInters.emplace_back( ILBT_TG_INI, Info.dU) ;
vInters.emplace_back( ILBT_TG_FIN, Info.dU2) ;
dUcurr = Info.dU2 ;
} }
} return true ;
// elimino intersezioni ripetute
for ( size_t j = 1 ; j < vInters.size() ; ) {
// intersezione precedente
size_t i = j - 1 ;
// se sono dello stesso tipo, elimino una delle due
if ( vInters[i].first == vInters[j].first) {
// se entranti elimino la prima
if ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_TG_INI)
vInters.erase( vInters.begin() + i) ;
// altrimenti la seconda
else
vInters.erase( vInters.begin() + j) ;
if ( i > 0)
-- j ;
continue ;
}
// se hanno lo stesso parametro
else if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) {
// se una entrante e l'altra uscente, cambio in touch ed elimino la seconda
if ( ( vInters[i].first == ILBT_IN && vInters[j].first == ILBT_OUT) ||
( vInters[i].first == ILBT_OUT && vInters[j].first == ILBT_IN)) {
vInters[i].first = ILBT_TOUCH ;
vInters.erase( vInters.begin() + j) ;
if ( i > 0)
-- j ;
continue ;
}
// se prima puntuale e l'altra inizio o fine di coincidenza, elimino la prima
else if ( ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_OUT || vInters[i].first == ILBT_TOUCH) &&
( vInters[j].first == ILBT_TG_INI || vInters[j].first == ILBT_TG_FIN)) {
vInters.erase( vInters.begin() + i) ;
if ( i > 0)
-- j ;
continue ;
}
// se prima inizio o fine di coincidenza e l'altra puntuale, elimino la seconda
else if ( ( vInters[i].first == ILBT_TG_INI || vInters[i].first == ILBT_TG_FIN) &&
( vInters[j].first == ILBT_IN || vInters[j].first == ILBT_OUT || vInters[j].first == ILBT_TOUCH)) {
vInters.erase( vInters.begin() + j) ;
if ( i > 0)
-- j ;
continue ;
}
// se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe
else if ( ( vInters[i].first == ILBT_TG_FIN && vInters[j].first == ILBT_TG_INI) ||
( vInters[i].first == ILBT_TG_INI && vInters[j].first == ILBT_TG_FIN)) {
vInters.erase( vInters.begin() + j) ;
vInters.erase( vInters.begin() + i) ;
if ( i > 0)
-- j ;
continue ;
}
}
// passo alla successiva
++ j ;
} }
// Se sono due intersezioni con la linea giacente su una faccia del box
if ( ( abs( vtL.x) < EPS_ZERO && ( abs( ptL.x - ptMin.x) < EPS_SMALL || abs( ptL.x - ptMax.x) < EPS_SMALL)) ||
( abs( vtL.y) < EPS_ZERO && ( abs( ptL.y - ptMin.y) < EPS_SMALL || abs( ptL.y - ptMax.y) < EPS_SMALL)) ||
( abs( vtL.z) < EPS_ZERO && ( abs( ptL.z - ptMin.z) < EPS_SMALL || abs( ptL.z - ptMax.z) < EPS_SMALL))) {
if ( ! bFinite) {
vInters.emplace_back( ILBT_TG_INI, dU1) ;
vInters.emplace_back( ILBT_TG_FIN, dU2) ;
}
else {
if ( dU1 > dLen - EPS_SMALL)
vInters.emplace_back( ILBT_IN, dLen) ;
else if ( dU2 < EPS_SMALL)
vInters.emplace_back( ILBT_OUT, 0) ;
else {
vInters.emplace_back( ILBT_TG_INI, Clamp( dU1, 0., dLen)) ;
vInters.emplace_back( ILBT_TG_FIN, Clamp( dU2, 0., dLen)) ;
}
}
return true ;
}
// Altrimenti sono due intersezioni con attraversamento
if ( ! bFinite) {
vInters.emplace_back( ILBT_IN, dU1) ;
vInters.emplace_back( ILBT_OUT, dU2) ;
}
else {
if ( dU1 > dLen - EPS_SMALL)
vInters.emplace_back( ILBT_IN, dLen) ;
else if ( dU2 < EPS_SMALL)
vInters.emplace_back( ILBT_OUT, 0) ;
else {
vInters.emplace_back( ILBT_IN, Clamp( dU1, 0., dLen)) ;
vInters.emplace_back( ILBT_OUT, Clamp( dU2, 0., dLen)) ;
}
}
return true ; return true ;
} }
+34
View File
@@ -0,0 +1,34 @@
//----------------------------------------------------------------------------
// EgalTech 2022-2022
//----------------------------------------------------------------------------
// File : IntersLineBox.h Data : 08.01.22 Versione : 2.4a3
// Contenuto : Dichiarazione delle funzioni base per intersezione linea/box.
//
//
//
// Modifiche : 08.01.22 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkPoint3d.h"
//----------------------------------------------------------------------------
// Linea e box allineato agli assi sono nel medesimo riferimento.
// Con intersezione viene restituito true e i parametri in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineBox( const Point3d& ptL, const Vector3d& vtL,
const Point3d& ptMin, const Point3d& ptMax,
double& dU1, double& dU2) ;
//----------------------------------------------------------------------------
inline bool
TestIntersLineBox( const Point3d& ptL, const Vector3d& vtL,
const Point3d& ptMin, const Point3d& ptMax)
{
double dU1, dU2 ;
return IntersLineBox( ptL, vtL, ptMin, ptMax, dU1, dU2) ;
}
+58
View File
@@ -0,0 +1,58 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : IntersLineCaps.cpp Data : 22.05.23 Versione : 2.5e3
// Contenuto : Implementazione della intersezione linea/capsule.
//
//
//
// Modifiche : 22.05.23 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "IntersLineCaps.h"
#include "DistLineLine.h"
#include "/EgtDev/Include/EGkIntersLineSphere.h"
using namespace std ;
//----------------------------------------------------------------------------
// Linea e capsule sono nel medesimo riferimento.
// Il capsule è definito con centri delle due estremità, e raggio.
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineCaps( const Point3d& ptL, const Vector3d& vtL,
const Point3d& ptCaps1, const Point3d& ptCaps2, double dRad,
double& dU1, double& dU2)
{
// Determino versore e lunghezza asse Capsule
Vector3d vtCaps = ptCaps2 - ptCaps1 ;
double dLen = vtCaps.Len() ;
if ( dLen < EPS_SMALL) {
Point3d ptInt1, ptInt2 ;
if ( IntersLineSphere( ptL, vtL, Media( ptCaps1, ptCaps2), dRad, ptInt1, ptInt2) != ILST_SEC)
return false ;
dU1 = ( ptInt1 - ptL) * vtL ;
dU2 = ( ptInt2 - ptL) * vtL ;
return true ;
}
vtCaps /= dLen ;
// Distanza tra la linea e il segmento asse del capsule
DistLineLine dstLL( ptL, vtL, 1, ptCaps1, vtCaps, dLen, false, true) ;
double dSqDist ;
if ( dstLL.GetSqDist( dSqDist) && dSqDist >= dRad * dRad)
return false ;
// Calcolo i punti di intersezione
Point3d ptRef, ptTmp ;
dstLL.GetMinDistPoints( ptRef, ptTmp) ;
double dSqDelta = dRad * dRad - dSqDist ;
double dDist = sqrt( dSqDelta) ;
dU1 = ( ptRef - ptL) * vtL - dDist ;
dU2 = dU1 + 2 * dDist ;
return true ;
}
+25
View File
@@ -0,0 +1,25 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : IntersLineCaps.h Data : 22.05.23 Versione : 2.5e4
// Contenuto : Dichiarazione funzioni base per intersezione linea/capsule.
//
//
//
// Modifiche : 22.05.23 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkPoint3d.h"
//----------------------------------------------------------------------------
// Linea e capsule sono nel medesimo riferimento.
// Il capsule è definito con centri delle due estremità, e raggio.
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
//----------------------------------------------------------------------------
bool IntersLineCaps( const Point3d& ptL, const Vector3d& vtL,
const Point3d& ptCaps1, const Point3d& ptCaps2, double dRad,
double& dU1, double& dU2) ;
+138
View File
@@ -0,0 +1,138 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : IntersLineCone.cpp Data : 16.05.23 Versione : 2.5e3
// Contenuto : Implementazione della intersezione linea/tronco di cono.
//
//
//
// Modifiche : 16.05.23 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "IntersLineCone.h"
#include "IntersLineCyl.h"
#include "/EgtDev/Include/ENkPolynomialRoots.h"
using namespace std ;
//----------------------------------------------------------------------------
// Linea e tronco di cono sono nel medesimo riferimento.
// Il tronco di cono è centrato sull'asse Z e appoggiato con RMin sul piano XY.
// In caso di intersezione viene restituito true e i parametri in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineCone( const Point3d& ptL, const Vector3d& vtL,
double dRadMin, double dRadMax, double dHeight,
double& dU1, double& dU2)
{
// Verifico il versore
if ( vtL.IsSmall())
return false ;
// Verifico il tronco di cono
if ( ( dRadMin < EPS_SMALL && dRadMax < EPS_SMALL) || dHeight < EPS_SMALL)
return false ;
// Se è un cilindro, rimando a questo
if ( abs( dRadMax - dRadMin) < EPS_SMALL)
return IntersLineCyl( ptL, vtL, ( dRadMin + dRadMax) / 2, dHeight, dU1, dU2) ;
// Se raggi invertiti, li scambio
if ( dRadMin > dRadMax)
swap( dRadMin, dRadMax) ;
// Tangente dell'angolo di semi-apertura del cono
double dTanTheta = ( dRadMax - dRadMin) / dHeight ;
double dSqTanTheta = dTanTheta * dTanTheta ;
double dSqCosTheta = 1 / ( 1 + dSqTanTheta) ;
// Determino le eventuali intersezioni con le due basi a quota minima e massima (solo se linea non giace sul cono)
int nBasInt = 0 ;
if ( abs( vtL.z) > EPS_ZERO) {
// le linee tangenti al cono non sono considerate intersecanti
bool bSameHAng = ( abs( abs( vtL.x) - abs( vtL.y)) < EPS_SMALL && abs( dSqCosTheta - vtL.z * vtL.z) < 2 * abs( vtL.z) * EPS_SMALL) ;
double EpsRad = ( bSameHAng ? - EPS_SMALL : EPS_SMALL) ;
Point3d ptInt1 = ptL + ( ( 0 - ptL.z) / vtL.z) * vtL ;
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dRadMin * dRadMin + 2 * dRadMin * EpsRad) {
dU1 = ( ptInt1 - ptL) * vtL ;
nBasInt += 1 ;
}
Point3d ptInt2 = ptL + ( ( dHeight - ptL.z) / vtL.z) * vtL ;
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y < dRadMax * dRadMax + 2 * dRadMax * EpsRad) {
dU2 = ( ptInt2 - ptL) * vtL ;
nBasInt += 2 ;
}
}
// Se la linea interseca entrambe le basi, si sono trovate le due intersezioni
if ( nBasInt == 3) {
if ( dU1 > dU2)
swap( dU1, dU2) ;
// Trovate intersezioni
return true ;
}
// Posizione del vertice del cono
double dDeltaH = ( dRadMin < EPS_SMALL ? 0 : dRadMin / dTanTheta) ;
// Sposto il punto di passaggio della linea di conseguenza
Point3d ptMyL = ptL + Z_AX * dDeltaH ;
// Determino le intersezioni con la superficie laterale del cono
DBLVECTOR vdCoeff{ ptMyL.x * ptMyL.x + ptMyL.y * ptMyL.y - ptMyL.z * ptMyL.z * dSqTanTheta,
2 * ( ptMyL.x * vtL.x + ptMyL.y * vtL.y - ptMyL.z * vtL.z * dSqTanTheta),
vtL.x * vtL.x + vtL.y * vtL.y - vtL.z * vtL.z * dSqTanTheta} ;
DBLVECTOR vdRoots ;
int nRoot = PolynomialRoots( 2, vdCoeff, vdRoots) ;
// Elimino le soluzioni cha danno intersezioni fuori dai limiti in Z del tronco di cono
if ( nRoot == 2) {
double dIntZ2 = ptL.z + vdRoots[1] * vtL.z ;
if ( dIntZ2 < 0 - EPS_SMALL || dIntZ2 > dHeight + EPS_SMALL)
-- nRoot ;
}
if ( nRoot >= 1) {
double dIntZ1 = ptL.z + vdRoots[0] * vtL.z ;
if ( dIntZ1 < 0 - EPS_SMALL || dIntZ1 > dHeight + EPS_SMALL) {
if ( nRoot == 2)
vdRoots[0] = vdRoots[1] ;
-- nRoot ;
}
}
// Due soluzioni: la retta interseca due volte la superficie laterale
if ( nRoot == 2) {
dU1 = vdRoots[0] ;
dU2 = vdRoots[1] ;
if ( dU1 > dU2)
swap( dU1, dU2) ;
// Trovate intersezioni
return true ;
}
// Una soluzione : la retta interseca la superficie laterale e un piano
else if ( nRoot == 1) {
// Se piano superiore
if ( nBasInt == 2) {
dU1 = vdRoots[0] ;
}
// altrimenti piano inferiore
else if ( nBasInt == 1) {
dU2 = vdRoots[0] ;
}
// altrimenti niente
else
return false ;
if ( dU1 > dU2)
swap( dU1, dU2) ;
// Trovate intersezioni
return true ;
}
// Nessuna soluzione : nessuna intersezione
else
return false ;
}
+35
View File
@@ -0,0 +1,35 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : IntersLineCone.h Data : 16.05.23 Versione : 2.5e3
// Contenuto : Dichiarazione funzioni base per intersezione linea/cono tronco.
//
//
//
// Modifiche : 16.05.23 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkPoint3d.h"
//----------------------------------------------------------------------------
// Linea e tronco di cono sono nel medesimo riferimento.
// Il tronco di cono è centrato sull'asse Z e appoggiato con RMin sul piano XY.
// Con intersezione viene restituito true e i parametri in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineCone( const Point3d& ptL, const Vector3d& vtL,
double dRadMin, double dRadMax, double dHeight,
double& dU1, double& dU2) ;
//----------------------------------------------------------------------------
inline bool
TestIntersLineCone( const Point3d& ptL, const Vector3d& vtL,
double dRadMin, double dRadMax, double dHeight)
{
double dU1, dU2 ;
return IntersLineCone( ptL, vtL, dRadMin, dRadMax, dHeight, dU1, dU2) ;
}

Some files were not shown because too many files have changed in this diff Show More