Compare commits

...

169 Commits

Author SHA1 Message Date
Riccardo Elitropi 104726c5ee EgtGeomKernel :
- migliorie varie.
2024-03-19 09:01:46 +01:00
Riccardo Elitropi e2445c0a15 EgtGeomKernel :
- modifica Swept con vettore statico.
- aggiunta Swep con FlatRegion come sezione
- migliorie varie.
2024-03-18 13:20:35 +01:00
Riccardo Elitropi 9880fa0173 EgtGeomKernel :
- migliorie varie.
2024-03-15 13:17:41 +01:00
Riccardo Elitropi d276809906 EgtGeomKernel :
- Swept con o senza caps mediante RMF
- inizio stesura codice per frame statico
- migliorie varie.
2024-03-14 13:04:09 +01:00
Riccardo Elitropi 4268da4a1f EgtGeomKernel :
- primo codice di test con Caps per funzione Swept con guida non piana.
2024-03-11 13:22:37 +01:00
Riccardo Elitropi 4f485d0e87 EgtGeomKernel :
- primo codice di prova per creazione Swept.
2024-03-07 16:53:19 +01:00
Riccardo Elitropi d48348fa1c EgtGeomKernel :
- pulizia codice.
2024-03-07 10:51:59 +01:00
Riccardo Elitropi 003dd0bdef EgtGeomKernel :
- codice di prova per RMF.
2024-03-06 16:29:36 +01:00
Riccardo Elitropi ec109908fa EgtGeomKernel :
- inizio stesura codice per Rotation Minimize Frame.
2024-03-05 16:20:28 +01:00
SaraP 3630b85632 EgtGeomKernel :
- corretto errore offset regioni con Voronoi.
2024-03-04 16:19:27 +01:00
Dario Sassi fdce6e1853 EgtGeomKernel 2.6c1 :
- piccolissima aggiunta a offset di regioni.
2024-03-02 11:52:34 +01:00
SaraP 8ffa9d7fb7 EgtGeomKernel :
- corretto errore offset con Voronoi.
2024-03-01 16:50:55 +01:00
Dario Sassi 360484c9af EgtGeomKernel :
- correzioni a RemoveAlignedPoints di Polyline (si usano indici e non il parametro U come ordine dei punti).
2024-02-29 08:47:44 +01:00
Dario Sassi 47606bffcd Merge remote-tracking branch 'origin/Douglas-Peucker' 2024-02-28 17:36:44 +01:00
Dario Sassi aea99a635f EgtGeomKernel :
- eliminati salvataggi di debug dalle booleanne delle trimesh.
2024-02-27 18:25:01 +01:00
Dario Sassi ce139c6925 EgtGeomKernel 2.6b4 :
- aggiunta funzione GetSurfTriMeshTransSwept per creare superficie swept di traslazione.
2024-02-27 18:18:13 +01:00
SaraP 5dcf5f5616 EgtGeomKernel :
- in Voronoi deallocata memoria non utilizzata.
2024-02-27 14:27:17 +01:00
Dario Sassi 451ef8356b EgtGeomKernel :
- aggiunta funzione IntersCurveSurfTm
- funzioni di intersezione Line e Plane con Zmap separate dall'oggetto per l'interfaccia
2024-02-26 15:00:15 +01:00
Riccardo Elitropi 6e810f050e Merge commit 'bd90fc2b59f3167c57dc9f13d2a99b40c63883bc' 2024-02-21 17:04:26 +01:00
Riccardo Elitropi 6bfb5c619f Merge commit 'fae6a7cd78972d7b91457994d525dba16d4e5945' into Douglas-Peucker 2024-02-21 16:55:28 +01:00
Riccardo Elitropi bd90fc2b59 Merge commit 'fae6a7cd78972d7b91457994d525dba16d4e5945' into BoolStm 2024-02-21 16:54:51 +01:00
Riccardo Elitropi 5800093e53 EgtGeomKernel :
- correzione inversione delle isole ordinate per area.
- migliorie varie.
2024-02-21 16:49:28 +01:00
SaraP fae6a7cd78 EgtGeomKernel :
- corretto errore offset regione.
2024-02-20 15:50:29 +01:00
Riccardo Elitropi 65daddfced EgtGeomKernel :
- piccole modifiche.
2024-02-20 13:10:20 +01:00
Riccardo Elitropi 95915b16e5 EgtGeomKernel :
- migliorie per Stm booleans.
2024-02-19 13:07:50 +01:00
Dario Sassi ddade325c4 EgtGeomKernel 2.6b3 :
- standardizzate le funzione Collision Detection sia per trimesh sia per Zmap (ex Avoid...)
- nelle funzioni Cde ora se arrivano geometrie errate si ritorna collisione (maggior sicurezza).
2024-02-16 08:43:15 +01:00
Riccardo Elitropi 46b91bb49d Merge commit '47e79756d17ae312d89d3617289bccabcb4bcf66' into BoolStm 2024-02-14 08:32:48 +01:00
Dario Sassi c8ce0a242e EgtGeomKernel 2.6b2 :
- a ProjectCurveOnSurfTm aggiunto parametro dMaxSegmLen per massima distanza tra punti risultanti.
2024-02-13 14:34:31 +01:00
Riccardo Elitropi 8be2246249 Merge commit '47e79756d17ae312d89d3617289bccabcb4bcf66' into Douglas-Peucker 2024-02-13 12:37:57 +01:00
Daniele Bariletti 47e79756d1 EgtGeomKernel :
- corretto bug nella triangolazione delle sup. di Bezier.
2024-02-12 12:53:57 +01:00
SaraP 595421bcdd EgtGeomKernel :
- gestone delle eccezioni di vroni
- correzioni varie.
2024-02-12 12:22:24 +01:00
Daniele Bariletti 517a66b0fe EgtGeomKernel :
- aggiunta di commenti al codice di triangolazione per le bezier.
2024-02-06 15:57:11 +01:00
Riccardo Elitropi 56cff98cf3 EgtGeomKernel :
- miglioria codice.
2024-02-06 13:15:13 +01:00
Riccardo Elitropi 3168bee865 Merge commit '7cd83efd97d2ab771362e2b18eb3db62bd9fb6e4' into Douglas-Peucker 2024-02-06 10:24:43 +01:00
Riccardo Elitropi 3d2f8c1495 EgtGeomKernel :
- approsimazione PolyLine con Douglas-Peucker.
2024-02-06 10:23:22 +01:00
Daniele Bariletti 7cd83efd97 Merge branch 'ExtDimension_angular' 2024-02-05 15:54:09 +01:00
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
Riccardo Elitropi 751ea085a6 Merge commit '1280037d1dfe7821c6efd45953cb7cf1e3705ecb' into BoolStm 2023-12-22 09:24:54 +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
Riccardo Elitropi 15ed754512 EgtGeomKernel :
- gestiti più chunk per la triangolaziome ( MakeAdvanced)
- piccole modifiche a Intersezione e creazione di Stm da curve.
2023-12-07 13:13:28 +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
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
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 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 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 8279e66cae EgtGeomKernel :
- correzione minore alle superfici di bezier
2023-06-23 16:56:48 +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
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
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
Daniele Bariletti cb1edcf20a EgtGeomKernel :
- sistemati vari bug
Manca
- da testare superfici e trim complessi
2023-06-13 16:40:45 +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
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
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
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
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
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
Daniele Bariletti 6a3fc0fd97 EgtGeomKernel :
- implementazione delle classi KdTree e Cell
- problemi : bilanciamento albero e uso puntatori
2023-05-03 12:09:58 +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
Daniele Bariletti bca419ad63 EgtGeomKernel :
- aggiustamenti alla classe ExtDimension
2023-04-14 09:43:14 +02:00
129 changed files with 15222 additions and 3395 deletions
+30 -5
View File
@@ -149,11 +149,36 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
}
// altrimenti attraversamento
else {
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 ;
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 ;
}
}
}
}
+2 -2
View File
@@ -297,7 +297,7 @@ GetArcPntDirTgBezier( const Point3d& ptP, const Vector3d& vtDir, const CurveBezi
return nullptr ;
// calcolo la circonferenza tangente a questa approssimazione
Point3d ptTg ;
PtrOwner<ICurve> pCrv( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg))) ;
PtrOwner<ICurve> pCrv( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg)) ;
if ( IsNull( pCrv))
return nullptr ;
// porto il punto di tangenza della circonferenza esattamente sulla curva di Bezier
@@ -330,7 +330,7 @@ GetArcPntDirTgCompo( const Point3d& ptP, const Vector3d& vtDir, const CurveCompo
pCrv = crvCompo.GetNextCurve()) {
// recupero la circonferenza tangente alla curva elementare
Point3d ptTg ;
PtrOwner<ICurve> pCrvTmp( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg))) ;
PtrOwner<ICurve> pCrvTmp( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg)) ;
if ( IsNull( pCrvTmp))
continue ;
// verifico se è la più vicina al punto desiderato
+23 -29
View File
@@ -81,8 +81,7 @@ Attribs::Dump( const GeomDB& GDB, string& sOut, bool bMM, const char* szNewLine)
}
sOut += szNewLine ;
// eventuali nome e stringhe informative
STRLIST::const_iterator iIter ;
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter)
for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter)
sOut += *iIter + szNewLine ;
return true ;
@@ -101,7 +100,7 @@ Attribs::Save( NgeWriter& ngeOut) const
// modo
if ( ! ngeOut.WriteUchar( m_Data[MODE], ","))
return false ;
// stato (se SEL è convertito in ON)
// stato (se SEL è convertito in ON)
int nStat = (( m_Data[STATUS] > GDB_ST_ON) ? GDB_ST_ON : m_Data[STATUS]) ;
if ( ! ngeOut.WriteUchar( nStat, ","))
return false ;
@@ -118,8 +117,7 @@ Attribs::Save( NgeWriter& ngeOut) const
if ( ! ngeOut.WriteInt( int( m_slInfo.size()), ";", true))
return false ;
// stringhe di info
STRLIST::const_iterator iIter ;
for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter) {
if ( ! ngeOut.WriteString( *iIter, nullptr, true))
return false ;
}
@@ -141,7 +139,7 @@ Attribs::Load( NgeReader& ngeIn)
if ( ! ngeIn.ReadUchar( ucMode, ","))
return false ;
m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
// stato (se SEL è convertito in ON)
// stato (se SEL è convertito in ON)
unsigned char ucStat ;
if ( ! ngeIn.ReadUchar( ucStat, ","))
return false ;
@@ -177,7 +175,7 @@ Attribs::Load( NgeReader& ngeIn)
bool
Attribs::DataFromString( const string& sParam)
{
// il primo parametro è diviso in 4 parti
// il primo parametro è diviso in 4 parti
STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ;
// 4 parti
@@ -215,10 +213,9 @@ Attribs::SetName( const string& sName)
if ( sName.empty() || ! IsValidVal( sName))
return false ;
// può essere solo la prima stringa
STRLIST::iterator iIter ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
FindKey( *iIter, NAME)) {
// può essere solo la prima stringa
auto iIter = m_slInfo.begin() ;
if ( iIter != m_slInfo.end() && FindKey( *iIter, NAME)) {
*iIter = NAME + EQUAL + sName ;
return true ;
}
@@ -237,10 +234,9 @@ Attribs::SetName( const string& sName)
bool
Attribs::GetName( string& sName) const
{
// può essere solo la prima stringa
STRLIST::const_iterator iIter ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
FindKey( *iIter, NAME)) {
// può essere solo la prima stringa
const auto iIter = m_slInfo.cbegin() ;
if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
sName = iIter->substr( NAME.length() + 1) ;
return true ;
}
@@ -252,23 +248,18 @@ Attribs::GetName( string& sName) const
bool
Attribs::ExistsName( void) const
{
// può essere solo la prima stringa
STRLIST::const_iterator iIter ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
FindKey( *iIter, NAME))
return true ;
return false ;
// può essere solo la prima stringa
const auto iIter = m_slInfo.cbegin() ;
return ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) ;
}
//----------------------------------------------------------------------------
bool
Attribs::RemoveName( void)
{
// può essere solo la prima stringa
STRLIST::const_iterator iIter ;
if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() &&
FindKey( *iIter, NAME)) {
// può essere solo la prima stringa
const auto iIter = m_slInfo.cbegin() ;
if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) {
m_slInfo.pop_front() ;
return true ;
}
@@ -285,11 +276,11 @@ Attribs::SetInfo( const string& sKey, const string& sVal)
if ( ! IsValidKey( sKey) || sVal.empty() || ! IsValidVal( sVal))
return false ;
// se è il nome
// se è il nome
if ( sKey == NAME)
return SetName( sVal) ;
// se esiste già una stringa con quella chiave la sostituisco
// se esiste già una stringa con quella chiave la sostituisco
for ( auto iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) {
if ( FindKey( *iIter, sKey)) {
*iIter = sKey + EQUAL + sVal ;
@@ -362,8 +353,11 @@ Attribs::GetAllInfo( STRVECTOR& vsInfo) const
{
// riservo spazio opportuno per il vettore delle stringhe
vsInfo.clear() ;
if ( (int) m_slInfo.size() == 0)
// 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() ;
+6 -6
View File
@@ -14,10 +14,10 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "BiArcs.h"
#include "CurveLine.h"
#include "CurveArc.h"
#include "CurveComposite.h"
#include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgtNumUtils.h"
@@ -50,7 +50,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
return nullptr ;
// preparo la curva composita per i biarchi
PtrOwner<ICurveComposite> pBiArc( CreateCurveComposite()) ;
PtrOwner<CurveComposite> pBiArc( CreateBasicCurveComposite()) ;
if ( IsNull( pBiArc))
return nullptr ;
@@ -95,7 +95,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, 0.5)) ;
}
else {
CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
const CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
if ( pArc == nullptr)
return nullptr ;
double dU = -1 ;
@@ -172,7 +172,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
// se rotazione nulla, allora segmento di retta tra i due punti
if ( abs( dAngDeg) < EPS_ANG_SMALL) {
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
if ( IsNull( pLine) || ! pLine->Set( ptP0, ptP1))
return nullptr ;
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1
@@ -194,7 +194,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
Vector3d vtStart = ptP0 - ptCen ;
double dRad, dAngStart ;
vtStart.ToSpherical( &dRad, nullptr, &dAngStart) ;
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
if ( IsNull( pArc) || ! pArc->SetXY( ptCen, dRad, dAngStart, dAngDeg, ( ptP1.z - ptP0.z)))
return nullptr ;
double dDirStartDeg = dAngStart + ( dAngDeg > 0 ? ANG_RIGHT : - ANG_RIGHT) ;
+2 -2
View File
@@ -1,8 +1,8 @@
//----------------------------------------------------------------------------
// EgalTech 2018-2018
//----------------------------------------------------------------------------
// File : CAToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
// Contenuto : Implementazione della classe CAToolSurfTm.
// File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
// Contenuto : Implementazione della classe CAvToolSurfTm.
//
//
//
+13 -11
View File
@@ -146,18 +146,20 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
const Triangle3d& trTria, const Vector3d& vtMove)
{
// Non ha senso che il movimento sia in direzione "opposta" a quella dell'asse utensile
if ( vtMove * vtToolAx < - EPS_ZERO)
if ( vtMove * vtToolAx < - 10 * EPS_ZERO)
return -1. ;
// Se avvicinamento non devo fare nulla
if ( vtMove * trTria.GetN() < - EPS_ZERO)
return 0. ;
return 0. ;
// Tolleranza su dischi (parti piatte perpendicolari all'asse utensile)
double dEpsilon = ( vtMove * vtToolAx > 0.5 ? 0 : EPS_SMALL) ;
// se utensile cilindrico
if ( tlTool.GetType() == Tool::CYLMILL) {
// parametri geometrici
double dHeigth = tlTool.GetHeigth() ;
double dRadius = tlTool.GetRadius() ;
// prima determino l'allontanamento del disco inferiore
double dDist = CAvDiskTriangle( ptToolOrig - ( dHeigth - EPS_SMALL) * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
double dDist = CAvDiskTriangle( ptToolOrig - ( dHeigth - dEpsilon) * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
if ( dDist < - EPS_SMALL)
return dDist ;
// poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il disco)
@@ -165,7 +167,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
if ( dDist2 < - EPS_SMALL)
return dDist2 ;
// verifico quello del disco sopra
double dDist3 = CAvDiskTriangle( ptToolOrig - EPS_SMALL * vtToolAx + ( dDist + dDist2) * vtMove, vtToolAx, dRadius, trTria, vtMove) ;
double dDist3 = CAvDiskTriangle( ptToolOrig - dEpsilon * vtToolAx + ( dDist + dDist2) * vtMove, vtToolAx, dRadius, trTria, vtMove) ;
if ( dDist3 < - EPS_SMALL)
return dDist3 ;
return ( dDist + dDist2 + dDist3) ;
@@ -189,7 +191,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
return dDist2 ;
// verifico quello del disco sopra
Point3d ptDiskUpOrig = ptCylOrig + dDist2 * vtMove ;
double dDist3 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
double dDist3 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
if ( dDist3 < - EPS_SMALL)
return dDist3 ;
return ( dDist + dDist2 + dDist3) ;
@@ -199,7 +201,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
// parametri geometrici
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
// prima determino l'allontanamento del disco inferiore
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - EPS_SMALL) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - dEpsilon) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
trTria, vtMove) ;
if ( dDist < - EPS_SMALL)
return dDist ;
@@ -220,7 +222,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
return dDist3 ;
// verifico quello del disco sopra
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ;
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
if ( dDist4 < - EPS_SMALL)
return dDist4 ;
return ( dDist + dDist2 + dDist3 + dDist4) ;
@@ -247,7 +249,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
double dMaxR = max( tlTool.GetRadius(), tlTool.GetTipRadius()) ;
double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ;
// prima determino l'allontanamento del disco inferiore
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - EPS_SMALL) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
double dDist = CAvDiskTriangle( ptToolOrig - ( tlTool.GetHeigth() - dEpsilon) * vtToolAx, vtToolAx, tlTool.GetTipRadius(),
trTria, vtMove) ;
if ( dDist < - EPS_SMALL)
return dDist ;
@@ -266,7 +268,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
return dDist3 ;
// verifico quello del disco sopra
Point3d ptDiskUpOrig = ptCylOrig + vtMove * dDist3 ;
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - EPS_SMALL * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
double dDist4 = CAvDiskTriangle( ptDiskUpOrig - dEpsilon * vtToolAx, vtToolAx, tlTool.GetRadius(), trTria, vtMove) ;
if ( dDist4 < - EPS_SMALL)
return dDist4 ;
return ( dDist + dDist2 + dDist3 + dDist4) ;
@@ -299,10 +301,10 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d&
double dRadius = max( ptStart.x, ptEnd.x) ;
// Se disco verso il basso dell'utensile
if ( ptStart.x > ptEnd.x)
dDist2 = CAvDiskTriangle( ptCompOrig + EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
dDist2 = CAvDiskTriangle( ptCompOrig + dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
// Se disco verso l'alto
else
dDist2 = CAvDiskTriangle( ptCompOrig - EPS_SMALL * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
dDist2 = CAvDiskTriangle( ptCompOrig - dEpsilon * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ;
}
else {
// Verifiche curva precedente per eventuale tappo sopra
+15 -5
View File
@@ -19,10 +19,23 @@
using namespace std ;
//----------------------------------------------------------------------------
// Il sistema di riferimento è allineato con il box e ha origine in un suo vertice.
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL.
// Il sistema di riferimento del box è riferito a quello della superficie.
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const ISurfTriMesh& Stm)
CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, const ISurfTriMesh& Stm, double dSafeDist)
{
// Se il box non è ben definito non ha senso proseguire
if ( vtDiag.IsSmall())
return true ;
// Se superficie non valida o aperta, non ha senso proseguire
if ( ! Stm.IsValid() || ! Stm.IsClosed())
return true ;
// Recupero BBox del poliedro
BBox3d b3Poly = Stm.GetAllTriaBox() ;
// Calcolo il BBox del parallelepipedo
@@ -39,13 +52,10 @@ CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDi
for ( int nT : vT) {
Triangle3d Tria ;
if ( Stm.GetTriangle( nT, Tria)) {
if ( CDeBoxTria( frBox, vtDiag, dSafeDist, Tria))
if ( CDeBoxTria( frBox, vtDiag, Tria, dSafeDist))
return true ;
}
}
// Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed())
return false ;
// Se il BBox del parallelepipedo non è interno a quello del poliedro e viceversa, non c'è collisione
if ( ! b3Poly.Encloses( b3Box) && ! b3Box.Encloses( b3Poly))
return false ;
+1 -1
View File
@@ -171,7 +171,7 @@ CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d
//----------------------------------------------------------------------------
bool
CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const Triangle3d& trTria)
CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d& trTria, double dSafeDist)
{
// Porto il triangolo nel riferimento del box
Triangle3d trTriaL = trTria ;
+1 -1
View File
@@ -17,4 +17,4 @@
//----------------------------------------------------------------------------
bool CDeSimpleBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d& trTria) ;
bool CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const Triangle3d& trTria) ;
bool CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, const Triangle3d& trTria, double dSafeDist) ;
+1 -1
View File
@@ -97,7 +97,7 @@ CDeSimpleCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Tr
//----------------------------------------------------------------------------
bool
CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, double dSafeDist, const Triangle3d& trTria)
CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria, double dSafeDist)
{
return CDeSimpleCapsTria( ptP1, ptP2, dR + max( 0., dSafeDist), trTria) ;
}
+1 -1
View File
@@ -16,4 +16,4 @@
//----------------------------------------------------------------------------
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) ;
bool CDeCapsTria( const Point3d& ptP1, const Point3d& ptP2, double dR, const Triangle3d& trTria, double dSafeDist) ;
+8 -7
View File
@@ -22,24 +22,25 @@
using namespace std ;
//----------------------------------------------------------------------------
// La funzione restituisce true in caso di collisone, false in caso di assenza
// di collisione o inconsistenza dei parametri di input.
// Le due superfici devono essere espresse nel medesimo sistema di riferimento.
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL.
// Se necessario cerco la collisione con un offset della superficie B costituito
// da sfere centrate nei vertici, cilindri con i segmenti per asse e il triangolo
// originale traslato di una costante pari alla distanza di sicurezza lungo la
// sua normale.
// da sfere centrate nei vertici, cilindri con gli spigoli per asse e il triangolo
// originale traslato della distanza di sicurezza lungo la sua normale.
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeClosedSurfTmClosedSurfTm( const ISurfTriMesh& SurfA, const ISurfTriMesh& SurfB, double dSafeDist)
{
// Recupero le superfici base
const SurfTriMesh* pSrfA = GetBasicSurfTriMesh( &SurfA) ;
const SurfTriMesh* pSrfB = GetBasicSurfTriMesh( &SurfB) ;
// Se le superfici non sono valide o non sono chiuse, non ha senso proseguire.
// 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 true ;
// Se i box delle superfici non si intersecano, ho finito.
BBox3d b3BoxA, b3BoxB ;
pSrfA->GetLocalBBox( b3BoxA) ;
+12 -8
View File
@@ -21,15 +21,22 @@ using namespace std ;
//----------------------------------------------------------------------------
// 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.
// Il sistema di riferimento del cono deve essere immerso in quello della superficie.
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL, altrimenti è ignorata ed è ininfluente.
// Il sistema di riferimento del cono è riferito a quello della superficie.
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
double dSafeDist, const ISurfTriMesh& Stm)
const ISurfTriMesh& Stm, double dSafeDist)
{
// Se il tronco di cono non è ben definito non ha senso proseguire
if ( max( dBaseRad, dTopRad) < EPS_SMALL || dHeight < EPS_SMALL)
return false ;
return true ;
// Se superficie non valida o aperta, non ha senso proseguire
if ( ! Stm.IsValid() || ! Stm.IsClosed())
return true ;
// Recupero BBox della trimesh
BBox3d b3Surf = Stm.GetAllTriaBox() ;
// Calcolo il BBox del tronco di cono
@@ -49,13 +56,10 @@ CDeConeFrustumClosedSurfTm( const Frame3d& frCone, double dBaseRad, double dTopR
for ( int nT : vT) {
Triangle3d trTria ;
if ( Stm.GetTriangle( nT, trTria)) {
if ( CDeConeFrustumTria( frCone, dBaseRad, dTopRad, dHeight, dSafeDist, trTria))
if ( CDeConeFrustumTria( frCone, dBaseRad, dTopRad, dHeight, trTria, dSafeDist))
return true ;
}
}
// Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed())
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 ;
+4 -4
View File
@@ -134,7 +134,7 @@ CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad,
// La distanza di sicurezza ha effetto solo se maggiore di epsilon, altrimenti è ignorata ed è ininfluente.
bool
CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
double dSafeDist, const Triangle3d& trTria)
const Triangle3d& trTria, double dSafeDist)
{
// Se il tronco di cono o il triangolo non sono ben definiti non procedo
if ( max( dBaseRad, dTopRad) < EPS_SMALL || dHeight < EPS_SMALL || ! trTria.IsValid())
@@ -142,7 +142,7 @@ CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, doub
// Se è un cilindro chiamo la routine apposita.
if ( abs( dBaseRad - dTopRad) < EPS_SMALL)
return CDeCylTria( frCone, max( dBaseRad, dTopRad), dHeight, dSafeDist, trTria) ;
return CDeCylTria( frCone, max( dBaseRad, dTopRad), dHeight, trTria, dSafeDist) ;
// Se il raggio di base è maggiore del raggio top cambio il sistema di riferimento.
double dMinRad = dBaseRad ;
@@ -156,11 +156,11 @@ CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, doub
// Se è un cono, chiamo la routine apposita
if ( dMinRad < EPS_SMALL)
return CDeConeTria( frMyCone, dMaxRad, dHeight, dSafeDist, trTria) ;
return CDeConeTria( frMyCone, dMaxRad, dHeight, trTria, dSafeDist) ;
// Se distanza di sicurezza nulla
if ( dSafeDist < EPS_SMALL)
return CDeSimpleConeFrustumTria( frMyCone, dBaseRad, dTopRad, dHeight, trTria ) ;
return CDeSimpleConeFrustumTria( frMyCone, dBaseRad, dTopRad, dHeight, trTria) ;
// Verifica preliminare con tronco di cono esteso
double dDiffRad = dMaxRad - dMinRad ;
+1 -2
View File
@@ -20,6 +20,5 @@
// Il sistema di riferimento deve avere l'origine nel centro della base minore e l'asse
// di simmetria del cono, rivolto verso la direzione di apertura, come asse Z.
bool CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad, double dHeight, const Triangle3d& trTria) ;
// Il sistema di riferimento ha l'asse Z coincidente con l'asse di simmetria del cono e l'origine nel centro della base.
bool CDeConeFrustumTria( const Frame3d& frCone, double dBaseRad, double dTopRad, double dHeight,
double dSafeDist, const Triangle3d& trTria) ;
const Triangle3d& trTria, double dSafeDist) ;
+1 -1
View File
@@ -111,7 +111,7 @@ CDeSimpleConeTria( const Frame3d& frCone, double dRad, double dHeight, const Tri
//----------------------------------------------------------------------------
bool
CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, double dSafeDist, const Triangle3d& trTria)
CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, const Triangle3d& trTria, double dSafeDist)
{
// Verifico validità del cono
if ( dRad < EPS_SMALL || dHeight < EPS_SMALL)
+1 -1
View File
@@ -19,4 +19,4 @@
//----------------------------------------------------------------------------
// Il sistema di riferimento ha asse Z coincidente con l'asse del cono e origine nel vertice del cono (punto più basso).
bool CDeSimpleConeTria( const Frame3d& frCone, double dRad, double dHeight, const Triangle3d& trTria) ;
bool CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, double dSafeDist, const Triangle3d& trTria) ;
bool CDeConeTria( const Frame3d& frCone, double dRad, double dHeight, const Triangle3d& trTria, double dSafeDist) ;
+13 -10
View File
@@ -18,17 +18,23 @@
using namespace std ;
//----------------------------------------------------------------------------
// Il toro convesso è il disco limitato dalla sola parte esterna del toro.
// Il toro convesso è il solido a disco limitato dalla sola parte esterna del toro.
// Raggio principale R1, raggio secondario R2.
// Il toro è posto nel piano XY del suo riferimento, centrato sull'origine.
// La funzione restituisce true in caso di collisione.
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeConvexTorusClosedSurfTm( const Frame3d& frTorus, double dRad1, double dRad2,
double dSafeDist, const ISurfTriMesh& Stm)
const ISurfTriMesh& Stm, double dSafeDist)
{
// I raggi devono essere non nulli e la superficie ben definita.
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL || ! Stm.IsValid())
return false ;
// I raggi devono essere non nulli
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL)
return true ;
// Se superficie non valida o aperta, non ha senso proseguire
if ( ! Stm.IsValid() || ! Stm.IsClosed())
return true ;
// Box della superficie
BBox3d b3Surf = Stm.GetAllTriaBox() ;
// Box del toro (sempre completo)
@@ -47,13 +53,10 @@ CDeConvexTorusClosedSurfTm( const Frame3d& frTorus, double dRad1, double dRad2,
for ( int nT : vT) {
Triangle3d trTria ;
if ( Stm.GetTriangle( nT, trTria)) {
if ( CDeConvexTorusTria( frTorus, dRad1, dRad2, CT_TOT, dSafeDist, trTria))
if ( CDeConvexTorusTria( frTorus, dRad1, dRad2, CT_TOT, trTria, dSafeDist))
return true ;
}
}
// Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed())
return false ;
// Se il BBox del toro non è interno a quello del poliedro e viceversa, non c'è collisione
if ( ! b3Surf.Encloses( b3Torus) && ! b3Torus.Encloses( b3Surf))
return false ;
+2 -2
View File
@@ -61,7 +61,7 @@ CDeSimpleConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, in
bool bContinue = plyApprox.GetFirstPoint( ptSt) && plyApprox.GetNextPoint( ptEn) ;
while ( bContinue && ! bCollision) {
frConus.Set( Point3d( 0., 0., ptSt.z), Frame3d::TOP) ;
bCollision = CDeConeFrustumTria( frConus, ptSt.x, ptEn.x, ptEn.z - ptSt.z, 0., trMyTria) ;
bCollision = CDeSimpleConeFrustumTria( frConus, ptSt.x, ptEn.x, ptEn.z - ptSt.z, trMyTria) ;
ptSt = ptEn ;
bContinue = plyApprox.GetNextPoint( ptEn) ;
}
@@ -71,7 +71,7 @@ CDeSimpleConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, in
//----------------------------------------------------------------------------
bool
CDeConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, int nCtType,
double dSafeDist, const Triangle3d& trTria)
const Triangle3d& trTria, double dSafeDist)
{
// I raggi devono essere non nulli e il triangolo ben definito.
if ( dRad1 < EPS_SMALL || dRad2 < EPS_SMALL || ! trTria.IsValid())
+1 -1
View File
@@ -28,4 +28,4 @@ enum ConvexTorusType { CT_INF = -1, CT_SUP = 1, CT_TOT = 0} ;
bool CDeSimpleConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, int nCtType,
const Triangle3d& trTria) ;
bool CDeConvexTorusTria( const Frame3d& frTorus, double dRad1, double dRad2, int nCtType,
double dSafeDist, const Triangle3d& trTria) ;
const Triangle3d& trTria, double dSafeDist) ;
+18 -8
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2020-2020
// EgalTech 2020-2024
//----------------------------------------------------------------------------
// File : CDCylSurfTm.cpp Data : 09.01.20 Versione : 2.2a2
// File : CDCylSurfTm.cpp Data : 15.02.24 Versione : 2.6b2
// Contenuto : Implementazione della verifica di collisione tra
// Cylinder e Closed SurftriMesh.
//
@@ -19,17 +19,30 @@
using namespace std ;
//----------------------------------------------------------------------------
// Il sistema di riferimento deve avere l'asse di simmetria del cilindro come asse Z e origine nel centro della base o del top.
// La distanza di sicurezza ha effetto solo se maggiore di EPS_SMALL, altrimenti è ignorata ed è ininfluente.
// Il sistema di riferimento del cilindro è riferito a quello della superficie.
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const ISurfTriMesh& Stm)
CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, const ISurfTriMesh& Stm, double dSafeDist)
{
// Il cilindro deve essere ben definito
if ( dR < EPS_SMALL || dH < EPS_SMALL)
return true ;
// Se superficie non valida o aperta, non ha senso proseguire
if ( ! Stm.IsValid() || ! Stm.IsClosed())
return true ;
// Recupero BBox del poliedro
BBox3d b3Poly = Stm.GetAllTriaBox() ;
// Sistemazioni cilindro
Frame3d frMyCyl = frCyl ;
if ( dH < 0) {
frMyCyl.Translate( dH * frMyCyl.VersZ()) ;
dH = - dH ;
dH = -dH ;
}
// Calcolo il BBox del cilindro
BBox3d b3CylL( Point3d( -dR, -dR, 0),
@@ -46,13 +59,10 @@ CDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, double dSafeDist
for ( int nT : vT) {
Triangle3d Tria ;
if ( Stm.GetTriangle( nT, Tria)) {
if ( CDeCylTria( frMyCyl, dR, dH, dSafeDist, Tria))
if ( CDeCylTria( frMyCyl, dR, dH, Tria, dSafeDist))
return true ;
}
}
// Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed())
return false ;
// Se il BBox del cilindro non è interno a quello del poliedro e viceversa, non c'è collisione
if ( ! b3Poly.Encloses( b3Cyl) && ! b3Cyl.Encloses( b3Poly))
return false ;
+1 -1
View File
@@ -84,7 +84,7 @@ CDeSimpleCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d&
//----------------------------------------------------------------------------
bool
CDeCylTria( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const Triangle3d& trTria)
CDeCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d& trTria, double dSafeDist)
{
// Se distanza di sicurezza nulla
if ( dSafeDist < EPS_SMALL)
+1 -1
View File
@@ -16,4 +16,4 @@
//----------------------------------------------------------------------------
bool CDeSimpleCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d& trTria) ;
bool CDeCylTria( const Frame3d& frCyl, double dR, double dH, double dSafeDist, const Triangle3d& trTria) ;
bool CDeCylTria( const Frame3d& frCyl, double dR, double dH, const Triangle3d& trTria, double dSafeDist) ;
+12 -8
View File
@@ -22,16 +22,23 @@ using namespace std ;
// Il sistema di riferimento deve avere l'origine nel centro della Base, asse X lungo
// un segmento della stessa e asse Z ortogonale alle basi e diretta verso la base Top.
// Il sistema di riferimento della piramide deve essere immerso in quello della superficie.
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
double dLenghtTopX, double dLenghtTopY, double dHeight,
double dSafeDist, const ISurfTriMesh& Stm)
const ISurfTriMesh& Stm, double dSafeDist)
{
// Se il tronco di piramide non è definito o la superficie non ben definita non ha senso proseguire.
// Se il tronco di piramide non è definito non ha senso proseguire.
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
max( dLenghtBaseY, dLenghtTopY) < EPS_SMALL ||
dHeight < EPS_SMALL || ! Stm.IsValid())
return false ;
dHeight < EPS_SMALL)
return true ;
// Se superficie non valida o aperta, non ha senso proseguire
if ( ! Stm.IsValid() || ! Stm.IsClosed())
return true ;
// Recupero BBox della trimesh
BBox3d b3Surf = Stm.GetAllTriaBox() ;
// Calcolo il BBox del tronco di piramide
@@ -53,13 +60,10 @@ CDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dLenghtBaseX, dou
Triangle3d trTria ;
if ( Stm.GetTriangle( nT, trTria)) {
if ( CDeRectPrismoidTria( frPrismoid, dLenghtBaseX, dLenghtBaseY, dLenghtTopX, dLenghtTopY, dHeight,
dSafeDist, trTria))
trTria, dSafeDist))
return true ;
}
}
// Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed())
return false ;
// Se il BBox del tronco di piramide non è interno a quello del poliedro e viceversa, non c'è collisione
if ( ! b3Surf.Encloses( b3Pyr) && ! b3Pyr.Encloses( b3Surf))
return false ;
+1 -1
View File
@@ -134,7 +134,7 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl
bool
CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
double dLenghtTopX, double dLenghtTopY, double dHeight,
double dSafeDist, const Triangle3d& trTria)
const Triangle3d& trTria, double dSafeDist)
{
// Se il tronco di piramide o il triangolo non sono ben definiti non procedo
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
+1 -1
View File
@@ -26,4 +26,4 @@ bool CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX,
// asse X lungo un lato della stessa e asse Z ortogonale alle basi e diretta verso la base Top.
bool CDeRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
double dLenghtTopX, double dLenghtTopY, double dHeight,
double dSafeDist, const Triangle3d& trTria) ;
const Triangle3d& trTria, double dSafeDist) ;
+12 -5
View File
@@ -19,10 +19,20 @@
using namespace std ;
//----------------------------------------------------------------------------
// La funzione restituisce :
// - true in caso di collisione o inconsistenza dei parametri di input
// - false in caso di assenza di collisione.
//----------------------------------------------------------------------------
bool
CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const ISurfTriMesh& Stm)
CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, const ISurfTriMesh& Stm, double dSafeDist)
{
// Il raggio deve essere non nullo
if ( dR < EPS_SMALL)
return true ;
// Se superficie non valida o aperta, non ha senso proseguire
if ( ! Stm.IsValid() || ! Stm.IsClosed())
return true ;
// Recupero BBox del poliedro
BBox3d b3Poly = Stm.GetAllTriaBox() ;
// Calcolo il BBox della sfera
@@ -38,13 +48,10 @@ CDeSpheClosedSurfTm( const Point3d& ptCen, double dR, double dSafeDist, const IS
for ( int nT : vT) {
Triangle3d Tria ;
if ( Stm.GetTriangle( nT, Tria)) {
if ( CDeSpheTria( ptCen, dR, dSafeDist, Tria))
if ( CDeSpheTria( ptCen, dR, Tria, dSafeDist))
return true ;
}
}
// Se superficie aperta, non c'è collisione
if ( ! Stm.IsClosed())
return false ;
// 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 ;
+1 -1
View File
@@ -31,7 +31,7 @@ CDeSimpleSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria)
//----------------------------------------------------------------------------
bool
CDeSpheTria( const Point3d& ptCen, double dR, double dSafeDist, const Triangle3d& trTria)
CDeSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria, double dSafeDist)
{
return CDeSimpleSpheTria( ptCen, dR + max( 0., dSafeDist), trTria) ;
}
+1 -1
View File
@@ -16,4 +16,4 @@
//----------------------------------------------------------------------------
bool CDeSimpleSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria) ;
bool CDeSpheTria( const Point3d& ptCen, double dR, double dSafeDist, const Triangle3d& trTria) ;
bool CDeSpheTria( const Point3d& ptCen, double dR, const Triangle3d& trTria, double dSafeDist) ;
+2 -2
View File
@@ -34,7 +34,7 @@ GetTwoGreater( int nVal0, int nVal1, int nVal2, int& nFirstMaxPos, int& nSecondM
}
else {
nFirstMaxPos = 2 ;
nSecondMaxPos = 1 ;
nSecondMaxPos = 0 ;
}
}
else if ( nVal0 > nVal2) {
@@ -168,7 +168,7 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB)
Vector3d vtSegSecondB = trTriaB.GetP( ( nSecondMaxPosB + 1) % 3) - trTriaB.GetP( nSecondMaxPosB) ;
double dSegLenSecondB = vtSegSecondB.Len() ;
vtSegSecondB /= dSegLenSecondB ;
DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosA), vtSegSecondB, dSegLenSecondB, false) ;
DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosB), vtSegSecondB, dSegLenSecondB, false) ;
double dIntParEnB, dOtherParSecondB ;
LineLineDistCalcSecondB.GetPositionsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ;
// Ordino i parametri lungo la retta di intersezione fra i piani
+1 -1
View File
@@ -368,4 +368,4 @@ ClampSegmentOutPlane( const Plane3d& plPlane, Point3d& ptSegP, const Vector3d& v
dSegLen -= dIntersLen ;
}
return true ;
}
}
+3315
View File
File diff suppressed because it is too large Load Diff
+116 -6
View File
@@ -22,6 +22,7 @@
#include "GeoObjFactory.h"
#include "NgeWriter.h"
#include "NgeReader.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h"
@@ -61,15 +62,14 @@ class ArcApproxer
//----------------------------------------------------------------------------
CurveArc::CurveArc( void)
: m_nStatus( TO_VERIFY), m_PtCen(), m_VtN(), m_VtS(), m_dRad(),
m_dAngCenDeg(), m_dDeltaN(), m_VtExtr(), m_dThick()
m_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)
{
ResetVoronoiObject() ;
}
//----------------------------------------------------------------------------
@@ -91,7 +91,9 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad,
// sistemo i versori
m_VtN.Normalize() ;
m_VtS.Normalize() ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -117,6 +119,8 @@ CurveArc::Set( const Point3d& ptCen, const Vector3d& vtN, double dRad)
m_dDeltaN = 0 ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -138,6 +142,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad, double dAngIniDeg, double dA
m_dDeltaN = dDeltaZ ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -159,6 +165,8 @@ CurveArc::SetXY( const Point3d& ptCen, double dRad)
m_dDeltaN = 0 ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -221,6 +229,8 @@ CurveArc::Set3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d&
// non c'è DeltaN
m_dDeltaN = 0 ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -268,6 +278,8 @@ CurveArc::Set2PNB( const Point3d& ptIni, const Point3d& ptFin, const Vector3d& v
// calcolo l'angolo al centro
m_dAngCenDeg = 4 * atan( dBulge) * RADTODEG ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -324,6 +336,8 @@ CurveArc::Set2PD( const Point3d& ptStart, const Point3d& ptEnd, double dDirStart
m_dDeltaN = - m_dDeltaN ;
}
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -406,6 +420,8 @@ CurveArc::Set2PRS( const Point3d& ptStart, const Point3d& ptEnd, double dRad, bo
( ! bCCW && m_dAngCenDeg > 0)))
m_dAngCenDeg = - m_dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -460,6 +476,8 @@ CurveArc::SetCPA( const Point3d& ptCen, const Point3d& ptStart, double dAngCenDe
// assegno l'angolo al centro
m_dAngCenDeg = dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -515,7 +533,8 @@ CurveArc::SetC2P( const Point3d& ptCen, const Point3d& ptStart, const Point3d& p
bool bDet ;
if ( ! m_VtS.GetRotation( ( ptNearEnd - m_PtCen), m_VtN, m_dAngCenDeg, bDet) || ! bDet)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -584,6 +603,8 @@ CurveArc::CopyFrom( const CurveArc& caSrc)
m_dThick = caSrc.m_dThick ;
m_nTempProp[0] = caSrc.m_nTempProp[0] ;
m_nTempProp[1] = caSrc.m_nTempProp[1] ;
m_dTempParam[0] = caSrc.m_dTempParam[0] ;
m_dTempParam[1] = caSrc.m_dTempParam[1] ;
return Set( caSrc.m_PtCen, caSrc.m_VtN, caSrc.m_dRad,
caSrc.m_VtS, caSrc.m_dAngCenDeg, caSrc.m_dDeltaN) ;
}
@@ -1261,7 +1282,9 @@ CurveArc::Invert( void)
m_dAngCenDeg = - m_dAngCenDeg ;
// l'incremento sulla normale inverte il segno
m_dDeltaN = - m_dDeltaN ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1295,6 +1318,8 @@ CurveArc::SimpleOffset( double dDist, int nType)
// aggiorno il raggio
m_dRad = dNewRad ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1339,6 +1364,8 @@ CurveArc::MyExtendedOffset( double dDist, bool bAll, int nType)
// aggiorno il raggio
m_dRad = dNewRad ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1411,6 +1438,8 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
m_dDeltaN = arcAux.m_dDeltaN ;
}
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1496,6 +1525,8 @@ CurveArc::TrimStartAtLen( double dLenTrim)
}
}
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1523,6 +1554,8 @@ CurveArc::TrimEndAtLen( double dLenTrim)
m_dDeltaN *= dLenTrim / dLen ;
}
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1566,6 +1599,8 @@ CurveArc::ExtendEndByLen( double dLenExt)
else if ( abs( m_dAngCenDeg) > ANG_FULL)
m_dAngCenDeg = _copysign( ANG_FULL, m_dAngCenDeg) ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1580,6 +1615,8 @@ CurveArc::Translate( const Vector3d& vtMove)
if ( m_nStatus != OK)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1601,6 +1638,8 @@ CurveArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
if ( vtAx.IsSmall())
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1630,6 +1669,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari
@@ -1657,6 +1698,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla
if ( abs( dCoeffY) < EPS_ZERO || m_dRad * abs( dCoeffY) <= EPS_SMALL)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari
@@ -1684,6 +1727,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla
if ( abs( dCoeffZ) < EPS_ZERO || m_dRad * abs( dCoeffZ) <= EPS_SMALL)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari
@@ -1711,6 +1756,8 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// verifico non sia nulla
if ( abs( dCoeffX) < EPS_ZERO || m_dRad * abs( dCoeffX) <= EPS_SMALL)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
// scalo il centro e le dimensioni lineari
@@ -1744,6 +1791,8 @@ CurveArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall())
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1775,6 +1824,8 @@ CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt
! AreSameOrOppositeVectorExact( m_VtN, vtNorm))
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1806,6 +1857,8 @@ CurveArc::ToGlob( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1831,6 +1884,8 @@ CurveArc::ToLoc( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1856,6 +1911,8 @@ CurveArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
if ( AreSameFrame( frOri, frDest))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1879,6 +1936,8 @@ CurveArc::InvertN( void)
m_dAngCenDeg = - m_dAngCenDeg ;
m_dDeltaN = - m_dDeltaN ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1959,6 +2018,8 @@ CurveArc::ChangeRadius( double dNewRadius)
// cambio il raggio
m_dRad = dNewRadius ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1978,6 +2039,8 @@ CurveArc::ChangeDeltaN( double dNewDeltaN)
// cambio il parametro
m_dDeltaN = dNewDeltaN ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2001,6 +2064,8 @@ CurveArc::ChangeAngCenter( double dNewAngCenDeg)
// cambio il parametro
m_dAngCenDeg = dNewAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2025,6 +2090,8 @@ CurveArc::ChangeStartPoint( double dU)
if ( ! vtDir.Normalize())
return false ;
m_VtS = vtDir ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
return true ;
@@ -2044,6 +2111,8 @@ CurveArc::ToExplementary( void)
// basta prendere l'angolo al centro che completa il giro
m_dAngCenDeg = - _copysign( ANG_FULL, m_dAngCenDeg) + m_dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2073,6 +2142,8 @@ CurveArc::Flip( void)
m_VtS.Normalize() ;
m_dAngCenDeg = - m_dAngCenDeg ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2187,3 +2258,42 @@ ArcApproxer::GetPoint( double& dU, Point3d& ptP)
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 ;
}
+15 -3
View File
@@ -19,6 +19,8 @@
#include "GeoObjRW.h"
#include "/EgtDev/Include/EGkCurveArc.h"
class Voronoi ;
//----------------------------------------------------------------------------
class CurveArc : public ICurveArc, public IGeoObjRW
{
@@ -54,6 +56,11 @@ class CurveArc : public ICurveArc, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // ICurve
bool IsSimple( void) const override
@@ -183,7 +190,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
public :
CurveArc( void) ;
CurveArc( const CurveArc& caSrc)
CurveArc( const CurveArc& caSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( caSrc))
LOG_ERROR( GetEGkLogger(), "CurveArc : copy constructor error")}
CurveArc& operator =( const CurveArc& caSrc)
@@ -192,11 +199,14 @@ class CurveArc : public ICurveArc, public IGeoObjRW
return *this ; }
bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ;
bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ;
Voronoi* GetVoronoiObject( void) const ;
private :
bool CopyFrom( const CurveArc& caSrc) ;
bool Validate( void) ;
bool GetDir( double dU, Vector3d& vtDir) const ;
bool GetDir( double dU, Vector3d& vtDir) const ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
@@ -212,7 +222,9 @@ class CurveArc : public ICurveArc, public IGeoObjRW
double m_dDeltaN ; // variazione di quota lungo VtN della fine rispetto all'inizio
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietŕ temporanee
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
} ;
//-----------------------------------------------------------------------------
+59 -17
View File
@@ -19,6 +19,7 @@
#include "CurveArc.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h"
@@ -522,7 +523,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
}
// se periodica
if ( cnData.bPeriodic) {
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))
@@ -540,9 +541,9 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
vBW.resize( nDeg + 1) ;
// trovo il nodo di cui aumentare la molteplicità e ne calcolo la molteplicità
int b = nU - nDeg - 1 +1;
int b = nU - nDeg - 1 + 1 ;
int i = b ;
while ( abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
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
@@ -573,14 +574,11 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
// procedo all'inserimento
int L = 0 ;
double alpha ;
double num, den ;
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) {
num = (cnData.vU[b] - cnData.vU[L + i]) ;
den = ( cnData.vU[i + b + 1] - cnData.vU[L + 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) {
@@ -597,7 +595,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
}
// allungo il vettore dei nodi e sposto gli ultimi nodi
cnData.vU.resize(nU + r) ;
cnData.vU.resize( nU + r) ;
for ( int p = nU - 1 ; p > b ; --p)
cnData.vU[p + r] = cnData.vU[p] ;
// aggiungo i nodi nuovi
@@ -607,9 +605,9 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
nCP = nCP + r ;
// aumento la molteplicità del punto u_p-1
b = nDeg -1;
b = nDeg - 1 ;
i = b ;
while ( abs( cnData.vU[b] - cnData.vU[b - 1]) < EPS_ZERO)
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
@@ -720,11 +718,11 @@ NurbsToBezierCurve( const CNurbsData& cnData)
}
if ( ! bOk)
return nullptr ;
// se 1 solo intervallo, la Nurbs è già una curva di Bezier
if ( nInt == 1) {
// creo la curva di Bezier
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCrvBez))
return nullptr ;
// la inizializzo
@@ -748,7 +746,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
}
// altrimenti è equivalente ad una curva composita, la creo
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo))
return nullptr ;
@@ -779,7 +777,6 @@ NurbsToBezierCurve( const CNurbsData& cnData)
int b = cnData.nDeg ;
bool bPrevRejected = false ;
// ciclo
int n = 0 ; // debug
while ( b < nU - 1) {
int i = b ;
while ( b < nU - 1 && abs( cnData.vU[b+1] - cnData.vU[b]) < EPS_ZERO)
@@ -811,7 +808,7 @@ NurbsToBezierCurve( const CNurbsData& cnData)
}
// costruisco la curva di Bezier e la inserisco nella curva composita
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCrvBez))
return nullptr ;
// se precedente saltata
@@ -847,8 +844,6 @@ NurbsToBezierCurve( const CNurbsData& cnData)
pCrvBez.Reset() ;
bPrevRejected = true ;
}
// debug
++n ;
// inizializzazioni per la prossima curva di Bezier
if ( b < nU - 1) {
if ( ! cnData.bRat) {
@@ -875,7 +870,7 @@ 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<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
PtrOwner<CurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
if ( ! pCrvBez->Init( cnData.nDeg, cnData.bRat))
return nullptr ;
if ( ! cnData.bRat) {
@@ -1045,3 +1040,50 @@ AdjustCurveSlope( ICurveComposite* pCrv, double dNini, double dNfin)
pCrv->ModifyEnd( ptFin) ;
return true ;
}
//----------------------------------------------------------------------------
Voronoi*
GetCurveVoronoi( const ICurve& crvC)
{
switch ( crvC.GetType()) {
case CRV_LINE : return GetBasicCurveLine( &crvC)->GetVoronoiObject() ;
case CRV_ARC : return GetBasicCurveArc( &crvC)->GetVoronoiObject() ;
case CRV_BEZIER : return GetBasicCurveBezier( &crvC)->GetVoronoiObject() ;
case CRV_COMPO : return GetBasicCurveComposite( &crvC)->GetVoronoiObject() ;
}
return nullptr ;
}
//----------------------------------------------------------------------------
bool
CalcCurveVoronoiDiagram( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nBound)
{
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
if ( pVoronoiObj == nullptr)
return false ;
return pVoronoiObj->CalcVoronoiDiagram( vCrvs, nBound) ;
}
//----------------------------------------------------------------------------
bool
CalcCurveMedialAxis( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, int nSide)
{
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
if ( pVoronoiObj == nullptr)
return false ;
return pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
}
//----------------------------------------------------------------------------
bool
CalcCurveFatCurve( const ICurve& crvC, ICURVEPOVECTOR& vCrvs, double dRadius, bool bSquareEnds, bool bSquareMids)
{
Voronoi* pVoronoiObj = GetCurveVoronoi( crvC) ;
if ( pVoronoiObj == nullptr)
return false ;
return pVoronoiObj->CalcFatCurve( vCrvs, dRadius, bSquareEnds, bSquareMids) ;
}
+3
View File
@@ -15,6 +15,8 @@
#include "/EgtDev/Include/EGkCurveAux.h"
class Voronoi ;
//----------------------------------------------------------------------------
bool IsClosed( const ICurve& crvC) ;
bool IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide) ;
@@ -31,3 +33,4 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
+87 -9
View File
@@ -26,6 +26,7 @@
#include "PolynomialPoint3d.h"
#include "Bernstein.h"
#include "deCasteljau.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h"
@@ -45,15 +46,14 @@ GEOOBJ_REGISTER( CRV_BEZIER, NGE_C_BEZ, CurveBezier) ;
//----------------------------------------------------------------------------
CurveBezier::CurveBezier( void)
: m_nStatus( TO_VERIFY), m_nDeg(), m_bRat( false), m_dParSing( -2),
m_VtExtr(), m_dThick()
m_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)
{
ResetVoronoiObject() ;
}
//----------------------------------------------------------------------------
@@ -77,6 +77,8 @@ CurveBezier::Init( int nDeg, bool bIsRational)
m_vWeCtrl.clear() ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -101,6 +103,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
// annullo analisi presenza singolarità
m_dParSing = - 2 ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -126,6 +130,8 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
// annullo analisi presenza singolarità
m_dParSing = - 2 ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -287,6 +293,8 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
m_dThick = cbSrc.m_dThick ;
m_nTempProp[0] = cbSrc.m_nTempProp[0] ;
m_nTempProp[1] = cbSrc.m_nTempProp[1] ;
m_dTempParam[0] = cbSrc.m_dTempParam[0] ;
m_dTempParam[1] = cbSrc.m_dTempParam[1] ;
return true ;
}
@@ -440,9 +448,8 @@ CurveBezier::Validate( void)
}
}
}
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) ;
}
@@ -620,7 +627,7 @@ CurveBezier::GetMidPoint( Point3d& ptMid) const
return false ;
// determino il valore del parametro a metà lunghezza
double dLen, dMid ;
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
return false ;
// calcolo il punto
return GetPointD1D2( dMid, ptMid) ;
@@ -657,7 +664,7 @@ CurveBezier::GetMidDir( Vector3d& vtDir) const
return false ;
// determino il valore del parametro a metà lunghezza
double dLen, dMid ;
if ( ! GetLength( dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
if ( ! GetLengthAtParam( 1, dLen) || ! GetParamAtLength( 0.5 * dLen, dMid))
return false ;
// calcolo la direzione
return ::GetTang( *this, dMid, FROM_MINUS, vtDir) ;
@@ -1607,6 +1614,8 @@ CurveBezier::Invert( void)
for ( int i = 0 ; i < nMid ; ++ i)
swap( m_vPtCtrl[i], m_vPtCtrl[m_nDeg-i]) ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1624,6 +1633,8 @@ CurveBezier::ModifyStart( const Point3d& ptNewStart)
// modifico il primo punto di controllo
m_vPtCtrl[0] = ptNewStart ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1641,6 +1652,8 @@ CurveBezier::ModifyEnd( const Point3d& ptNewEnd)
// modifico l'ultimo punto di controllo
m_vPtCtrl[m_nDeg] = ptNewEnd ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1665,6 +1678,8 @@ CurveBezier::TrimStartAtParam( double dUTrim)
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1689,6 +1704,8 @@ CurveBezier::TrimEndAtParam( double dUTrim)
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -1755,7 +1772,7 @@ CurveBezier::ExtendStartByLen( double dLenExt)
return false ;
// determino la lunghezza originale della curva
double dLen ;
if ( ! GetLength( dLen))
if ( ! GetLengthAtParam( 1, dLen))
return false ;
// stimo il valore del parametro al nuovo punto iniziale
double dUTrim = - dLenExt / dLen ;
@@ -1789,6 +1806,9 @@ CurveBezier::ExtendStartByLen( double dLenExt)
m_vWeCtrl[i] = vWeCtrl[i] ;
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
return true ;
@@ -1803,7 +1823,7 @@ CurveBezier::ExtendEndByLen( double dLenExt)
return false ;
// determino la lunghezza originale della curva
double dLen ;
if ( ! GetLength( dLen))
if ( ! GetLengthAtParam( 1, dLen))
return false ;
// stimo il valore del parametro al nuovo punto finale
double dUTrim = 1 + dLenExt / dLen ;
@@ -1837,6 +1857,9 @@ CurveBezier::ExtendEndByLen( double dLenExt)
m_vWeCtrl[i] = vWeCtrl[i] ;
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
return true ;
@@ -1850,6 +1873,8 @@ CurveBezier::Translate( const Vector3d& vtMove)
if ( m_nStatus != OK)
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1872,6 +1897,8 @@ CurveBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
if ( vtAx.IsSmall())
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1914,6 +1941,8 @@ CurveBezier::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
if ( ! bOk)
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1943,6 +1972,8 @@ CurveBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall())
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1967,6 +1998,8 @@ CurveBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
if ( vtNorm.IsSmall() || vtDir.IsSmall())
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1999,6 +2032,8 @@ CurveBezier::ToGlob( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2026,6 +2061,8 @@ CurveBezier::ToLoc( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2053,6 +2090,8 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
if ( AreSameFrame( frOri, frDest))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2064,3 +2103,42 @@ CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
return true ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::CalcVoronoiObject() const
{
if ( m_nStatus != OK)
return false ;
// creo oggetto vroni con la curva
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
if ( m_pVoronoiObj == nullptr)
return false ;
return true ;
}
//----------------------------------------------------------------------------
Voronoi*
CurveBezier::GetVoronoiObject() const
{
if ( m_nStatus != OK)
return nullptr ;
// se non è stato calcolato, lo calcolo
if ( m_pVoronoiObj == nullptr)
CalcVoronoiObject() ;
// restituisco Voronoi
return m_pVoronoiObj ;
}
//----------------------------------------------------------------------------
void
CurveBezier::ResetVoronoiObject() const
{
if ( m_pVoronoiObj != nullptr)
delete m_pVoronoiObj ;
m_pVoronoiObj = nullptr ;
}
+24 -13
View File
@@ -19,7 +19,8 @@
#include "DllMain.h"
#include "GeoObjRW.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EgtNumCollection.h"
class Voronoi ;
//----------------------------------------------------------------------------
class CurveBezier : public ICurveBezier, public IGeoObjRW
@@ -56,6 +57,11 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // ICurve
bool IsSimple( void) const override { return true ; }
@@ -149,7 +155,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
public :
CurveBezier( void) ;
CurveBezier( const CurveBezier& cbSrc)
CurveBezier( const CurveBezier& cbSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( cbSrc))
LOG_ERROR( GetEGkLogger(), "CurveBezier : copy constructor error")}
CurveBezier& operator =( const CurveBezier& cbSrc)
@@ -158,6 +164,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
return *this ; }
bool ApproxWithLines( int nStep, PolyLine& PL) const ;
bool GetApproxLength( double& dLen) const ;
Voronoi* GetVoronoiObject( void) const ;
private :
bool CopyFrom( const CurveBezier& cbSrc) ;
@@ -174,23 +181,27 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
bool ApproxWithArcsXY(double dLinTol, double dAngTolDeg, PolyArc& PA) const;
bool BiArcOrSplit(int nLev, PolyLine& PL, double dLinTol, double dAngTolDeg, PolyArc& PA) const;
bool ToPowerBase( PolynomialPoint3d& pol3P) const ;
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
bool ToPowerBase( PolynomialPoint3d& pol3Num, Polynomial& polDen) const ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
static const int MAXDEG = 11 ;
private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato
int m_nDeg ; // grado
bool m_bRat ; // flag di razionale/polinomiale
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato
int m_nDeg ; // grado
bool m_bRat ; // flag di razionale/polinomiale
mutable double m_dParSing ; // eventuale parametro della singolarità (-1=no, -2=da calcolare)
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
} ;
//-----------------------------------------------------------------------------
+5 -5
View File
@@ -14,10 +14,10 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "CalcDerivate.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "/EgtDev/Include/EGkCurveByInterp.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkBiArcs.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -63,7 +63,7 @@ CurveByInterp::GetCurve( int nMethod, int nType)
// se richiesti biarchi
if ( nType == BIARCS) {
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo))
return nullptr ;
// ciclo sugli intervalli
@@ -83,13 +83,13 @@ CurveByInterp::GetCurve( int nMethod, int nType)
// se richieste curve di Bezier cubiche
if ( nType == CUBIC_BEZIERS) {
// creo la curva composita
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo))
return nullptr ;
// ciclo sugli intervalli
for ( int i = 1 ; i < int( m_vPnt.size()) ; ++ i) {
// creo una curva di Bezier cubica per ogni intervallo
PtrOwner<ICurveBezier> pCBez( CreateCurveBezier()) ;
PtrOwner<CurveBezier> pCBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCBez))
return nullptr ;
pCBez->Init( 3, false) ;
+213 -30
View File
@@ -26,6 +26,7 @@
#include "GeoObjFactory.h"
#include "NgeWriter.h"
#include "NgeReader.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkCurveByApprox.h"
#include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
@@ -37,15 +38,17 @@
using namespace std ;
//----------------------------------------------------------------------------
static const double EPS_CONNECT = 0.01 * EPS_SMALL ;
//----------------------------------------------------------------------------
GEOOBJ_REGISTER( CRV_COMPO, NGE_C_CMP, CurveComposite) ;
//----------------------------------------------------------------------------
CurveComposite::CurveComposite( void)
: m_nStatus( TO_VERIFY), m_VtExtr(), m_dThick(), m_ptStart(), m_Iter( m_CrvSmplS.end())
: m_nStatus( TO_VERIFY), m_VtExtr(), m_dThick(), m_ptStart(),
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr), m_Iter( m_CrvSmplS.end())
{
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
}
//----------------------------------------------------------------------------
@@ -69,8 +72,12 @@ CurveComposite::Clear( void)
m_ptStart = ORIG ;
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
m_dTempParam[0] = 0.0 ;
m_dTempParam[1] = 0.0 ;
m_Iter = m_CrvSmplS.end() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -114,6 +121,8 @@ CurveComposite::AddCurve( const ICurve& cCrv, bool bEndOrStart, double dLinTol)
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -141,6 +150,8 @@ CurveComposite::AddCurve( ICurve* pCrv, bool bEndOrStart, double dLinTol)
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -163,6 +174,8 @@ CurveComposite::AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart, dou
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -205,7 +218,7 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
// verifico sia in continuità con il finale attuale
Point3d ptEnd ;
GetEndPoint( ptEnd) ;
if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, 0.01 * EPS_SMALL)) {
if ( ! AreSamePointEpsilon( ptCrvStart, ptEnd, EPS_CONNECT)) {
// se in tolleranza, modifico l'inizio dell'entità
if ( SqDist( ptCrvStart, ptEnd) < ( dLinTol * dLinTol)) {
// lunghezza della curva originale
@@ -227,11 +240,18 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
// verifico sia in continuità con l'iniziale attuale
Point3d ptStart ;
GetStartPoint( ptStart) ;
if ( ! AreSamePointEpsilon( ptCrvEnd, ptStart, 0.01 * EPS_SMALL)) {
if ( ! AreSamePointEpsilon( ptCrvEnd, ptStart, EPS_CONNECT)) {
// se in tolleranza, modifico la fine dell'entità
if ( SqDist( ptCrvEnd, ptStart) < ( dLinTol * dLinTol)) {
// lunghezza della curva originale
double dOldLen ; pCrv->GetLength( dOldLen) ;
// eseguo modifica
if ( ! pCrv->ModifyEnd( ptStart))
return false ;
// verifico che la lunghezza non sia variata troppo
double dNewLen ; pCrv->GetLength( dNewLen) ;
if ( abs( dNewLen - dOldLen) > 10 * dLinTol)
return false ;
}
else
return false ;
@@ -248,7 +268,10 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT
// aggiorno lo stato
m_nStatus = OK ;
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
return TestClosure() ;
}
//----------------------------------------------------------------------------
@@ -264,7 +287,7 @@ CurveComposite::Close( void)
! GetEndPoint( ptEnd))
return false ;
// se distanza inferiore al limite ridotto, non faccio alcunché
if ( AreSamePointEpsilon( ptStart, ptEnd, EPS_SMALL / 10))
if ( AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT))
return true ;
// se molto vicini li modifico
if ( AreSamePointEpsilon( ptStart, ptEnd, 10 * EPS_SMALL)) {
@@ -280,6 +303,9 @@ CurveComposite::Close( void)
! AddSimpleCurve( Release( pLine)))
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -323,6 +349,8 @@ CurveComposite::FromSplit( const ICurve& cCrv, int nParts)
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -348,7 +376,7 @@ CurveComposite::FromPolyLine( const PolyLine& PL)
if ( AreSamePointApprox( ptIni, ptFin))
continue ;
// creo il segmento di retta
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
PtrOwner<CurveLine> pCrvLine( CreateBasicCurveLine()) ;
if ( IsNull( pCrvLine))
return false ;
// assegno i punti estremi
@@ -564,6 +592,8 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc)
m_dThick = ccSrc.m_dThick ;
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
m_dTempParam[0] = ccSrc.m_dTempParam[0] ;
m_dTempParam[1] = ccSrc.m_dTempParam[1] ;
for ( auto& pCrv : ccSrc.m_CrvSmplS) {
if ( ! AddCurve( *pCrv))
return false ;
@@ -582,6 +612,8 @@ CurveComposite::RelocateFrom( CurveComposite& ccSrc)
m_dThick = ccSrc.m_dThick ;
m_nTempProp[0] = ccSrc.m_nTempProp[0] ;
m_nTempProp[1] = ccSrc.m_nTempProp[1] ;
m_dTempParam[0] = ccSrc.m_dTempParam[0] ;
m_dTempParam[1] = ccSrc.m_dTempParam[1] ;
for ( ICurve* pCrv = ccSrc.RemoveFirstOrLastCurve( false) ;
pCrv != nullptr ;
pCrv = ccSrc.RemoveFirstOrLastCurve( false)) {
@@ -805,8 +837,7 @@ CurveComposite::Validate( void)
Point3d ptStart ;
// ciclo su tutte le curve
int nCount = 0 ;
PCSD_CONST_ITER Iter ;
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
// verifico validità della curva e sua semplicità
if ( ! (*Iter)->IsValid() || (*Iter)->GetType() == CRV_COMPO) {
m_nStatus = ERR ;
@@ -829,9 +860,32 @@ CurveComposite::Validate( void)
m_nStatus = ( nCount > 0 ? OK : TO_VERIFY) ;
}
// verifico chiusura
TestClosure() ;
return ( m_nStatus == OK) ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::TestClosure( void)
{
// se non è chiusa, esco subito
if ( ! IsClosed())
return true ;
// verifico ed eventualmente aggiusto coincidenza punti estremi
Point3d ptStart ; m_CrvSmplS.front()->GetStartPoint( ptStart) ;
Point3d ptEnd ; m_CrvSmplS.back()->GetEndPoint( ptEnd) ;
// se distanza superiore al limite ridotto forzo i punti a coincidere
if ( ! AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT)) {
Point3d ptM = Media( ptStart, ptEnd) ;
if ( ! m_CrvSmplS.front()->ModifyStart( ptM) ||
! m_CrvSmplS.back()->ModifyEnd( ptM))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::IsFlat( Plane3d& plPlane, bool bUseExtrusion, double dToler) const
@@ -1161,8 +1215,7 @@ CurveComposite::GetLength( double& dLen) const
// ciclo di calcolo
dLen = 0 ;
PCSD_CONST_ITER Iter ;
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
double dLenCrvSmpl ;
if ( (*Iter)->GetLength( dLenCrvSmpl))
dLen += dLenCrvSmpl ;
@@ -1188,8 +1241,7 @@ CurveComposite::GetLengthAtParam( double dU, double& dLen) const
// ciclo di calcolo
dLen = 0 ;
double dUToGo = dU ;
PCSD_CONST_ITER Iter ;
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
// dominio parametrico della curva semplice
double dParStart, dParEnd ;
(*Iter)->GetDomain( dParStart, dParEnd) ;
@@ -1237,8 +1289,7 @@ CurveComposite::GetParamAtLength( double dLen, double& dU) const
// ciclo di calcolo
dU = 0 ;
double dLenToGo = dLen ;
PCSD_CONST_ITER Iter ;
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) {
// lunghezza della curva semplice
double dCrvLen ;
if ( ! (*Iter)->GetLength( dCrvLen))
@@ -1618,6 +1669,8 @@ CurveComposite::Invert( void)
// inverto l'ordine della lista
reverse( m_CrvSmplS.begin(), m_CrvSmplS.end()) ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1672,6 +1725,8 @@ CurveComposite::ModifyStart( const Point3d& ptNewStart)
if ( ! pCrv->ModifyStart( ptNewStart))
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1693,6 +1748,8 @@ CurveComposite::ModifyEnd( const Point3d& ptNewEnd)
if ( ! pCrv->ModifyEnd( ptNewEnd))
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1943,8 +2000,10 @@ CurveComposite::ModifyJoint( int nU, const Point3d& ptNewJoint)
// elimino la curva originale
delete( pNextCrv) ;
}
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2006,6 +2065,8 @@ CurveComposite::RemoveJoint( int nU)
m_CrvSmplS.erase( m_CrvSmplS.begin() + nNextCrv) ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2091,6 +2152,8 @@ CurveComposite::MoveCurve( int nCrv, const Vector3d& vtMove)
// traslo la curva corrente
pCrv->Translate( vtMove) ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2124,6 +2187,8 @@ CurveComposite::ModifyCurveToArc( int nCrv, const Point3d& ptMid)
// elimino la curva originale
delete( pCrv) ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2160,6 +2225,8 @@ CurveComposite::ModifyCurveToLine( int nCrv)
// elimino la curva originale
delete( pCrv) ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2175,6 +2242,8 @@ CurveComposite::TrimStartAtParam( double dUTrim)
if ( dUTrim < -EPS_PARAM || dUTrim > dMaxU - EPS_PARAM)
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2216,6 +2285,8 @@ CurveComposite::TrimEndAtParam( double dUTrim)
if ( dUTrim < EPS_PARAM || dUTrim > dMaxU + EPS_PARAM)
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2360,6 +2431,8 @@ CurveComposite::TrimStartAtLen( double dLenTrim)
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2423,6 +2496,8 @@ CurveComposite::TrimEndAtLen( double dLenTrim)
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2446,6 +2521,8 @@ CurveComposite::ExtendStartByLen( double dLenExt)
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
return true ;
@@ -2473,6 +2550,8 @@ CurveComposite::ExtendEndByLen( double dLenExt)
return false ;
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
return true ;
@@ -2485,6 +2564,9 @@ CurveComposite::Translate( const Vector3d& vtMove)
// la curva deve essere validata
if ( m_nStatus != OK)
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2506,6 +2588,8 @@ CurveComposite::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn
if ( vtAx.IsSmall())
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2547,6 +2631,8 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
abs( vtDelta.z * dCoeffZ) < EPS_SMALL)
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2617,6 +2703,8 @@ CurveComposite::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall())
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2641,6 +2729,8 @@ CurveComposite::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector
if ( vtNorm.IsSmall() || vtDir.IsSmall())
return false ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2678,6 +2768,8 @@ CurveComposite::ToGlob( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2706,6 +2798,8 @@ CurveComposite::ToLoc( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2734,6 +2828,8 @@ CurveComposite::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
if ( AreSameFrame( frOri, frDest))
return true ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2847,6 +2943,8 @@ CurveComposite::RemoveFirstOrLastCurve( bool bLast)
// la curva composita deve essere validata
if ( m_nStatus != OK)
return nullptr ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// recupero la curva semplice iniziale o finale e la tolgo dalla lista
if ( ! m_CrvSmplS.empty()) {
@@ -2937,6 +3035,8 @@ CurveComposite::ArcsToBezierCurves( void)
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -2983,6 +3083,8 @@ CurveComposite::ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDe
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -3016,6 +3118,8 @@ CurveComposite::StraightArcsToLines( double dLinTol, double dAngTolDeg)
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -3026,6 +3130,14 @@ CurveComposite::StraightArcsToLines( double dLinTol, double dAngTolDeg)
static int
MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAngTol, bool bNeedSameProp)
{
// verifico compatibilità delle proprietà
int nTpr0P = pCrvP->GetTempProp( 0) ;
int nTpr0C = pCrvC->GetTempProp( 0) ;
int nTpr1P = pCrvP->GetTempProp( 1) ;
int nTpr1C = pCrvC->GetTempProp( 1) ;
if ( bNeedSameProp && ( nTpr0P != nTpr0C || nTpr1P != nTpr1C))
return 0 ;
// se precedente molto corta
double dLenP ;
if ( pCrvP->GetLength( dLenP) && dLenP < dCurrLinTol) {
@@ -3045,14 +3157,7 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
Point3d ptEnd ;
return ( pCrvC->GetEndPoint( ptEnd) && pCrvP->ModifyEnd( ptEnd) ? 1 : 0) ;
}
}
// verifico compatibilità delle proprietà
int nTpr0P = pCrvP->GetTempProp( 0) ;
int nTpr0C = pCrvC->GetTempProp( 0) ;
int nTpr1P = pCrvP->GetTempProp( 1) ;
int nTpr1C = pCrvC->GetTempProp( 1) ;
if ( bNeedSameProp && ( nTpr0P != nTpr0C || nTpr1P != nTpr1C))
return 0 ;
}
// coefficiente deduzione tolleranza
const double COEFF_TOL = 0.7 ;
// se entrambe rette
@@ -3220,17 +3325,26 @@ CurveComposite::MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd,
}
}
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::RemoveSmallParts( double dLinTol, double dAngTolDeg)
{
return ( RemoveCurveSmallParts( this, dLinTol)) ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes)
{
return (( ! bAlsoSpikes || RemoveCurveSpikes( this, dLinTol)) && RemoveCurveSmallZs(this, dLinTol)) ;
return (( ! bAlsoSpikes || RemoveCurveSpikes( this, dLinTol)) && RemoveCurveSmallZs( this, dLinTol)) ;
}
//----------------------------------------------------------------------------
@@ -3553,7 +3667,7 @@ CurveComposite::IsATrapezoid( double dLinTol, Point3d& ptP, Vector3d& vtB1, Vect
//----------------------------------------------------------------------------
bool
CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropInd)
{
// la curva deve essere validata
if ( m_nStatus != OK)
@@ -3562,13 +3676,13 @@ CurveComposite::SetCurveTempProp( int nCrv, int nProp, int nPropNum)
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
return false ;
// eseguo assegnazione
m_CrvSmplS[nCrv]->SetTempProp( nProp, nPropNum) ;
m_CrvSmplS[nCrv]->SetTempProp( nProp, nPropInd) ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropInd) const
{
// la curva deve essere validata
if ( m_nStatus != OK)
@@ -3577,6 +3691,75 @@ CurveComposite::GetCurveTempProp( int nCrv, int& nProp, int nPropNum) const
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
return false ;
// eseguo recupero
nProp = m_CrvSmplS[nCrv]->GetTempProp( nPropNum) ;
nProp = m_CrvSmplS[nCrv]->GetTempProp( nPropInd) ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::SetCurveTempParam( int nCrv, double dParam, int nParamInd)
{
// la curva deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico che l'indice sia nei limiti
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
return false ;
// eseguo assegnazione
m_CrvSmplS[nCrv]->SetTempParam( dParam, nParamInd) ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::GetCurveTempParam( int nCrv, double& dParam, int nParamInd) const
{
// la curva deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico che l'indice sia nei limiti
if ( nCrv < 0 || nCrv >= int( m_CrvSmplS.size()))
return false ;
// eseguo recupero
dParam = m_CrvSmplS[nCrv]->GetTempParam( nParamInd) ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveComposite::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*
CurveComposite::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
CurveComposite::ResetVoronoiObject() const
{
if ( m_pVoronoiObj != nullptr)
delete m_pVoronoiObj ;
m_pVoronoiObj = nullptr ;
}
+35 -15
View File
@@ -21,6 +21,8 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include <deque>
class Voronoi ;
//----------------------------------------------------------------------------
class CurveComposite : public ICurveComposite, public IGeoObjRW
{
@@ -53,9 +55,14 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
{ return m_OGrMgr.GetObjGraphics() ; }
void SetTempProp( int nProp, int nPropInd = 0) override
{ if ( nPropInd >= 0 && nPropInd < 2)
m_nTempProp[nPropInd] = nProp ; }
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // ICurve
bool IsSimple( void) const override
@@ -158,6 +165,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
bool ArcsBezierCurvesToArcsPerpExtr( double dLinTol, double dAngTolDeg) override ;
bool StraightArcsToLines( double dLinTol, double dAngTolDeg) override ;
bool MergeCurves( double dLinTol, double dAngTolDeg, bool bStartEnd = true, bool bNeedSameProp = false) override ;
bool RemoveSmallParts( double dLinTol, double dAngTolDeg) override ;
bool RemoveSmallDefects( double dLinTol, double dAngTolDeg, bool bAlsoSpikes = false) override ;
bool RemoveUndercutOnY( double dLinTol, double dAngTolDeg) override ;
bool IsAPoint( void) const override ;
@@ -165,9 +173,11 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
bool IsACircle( double dLinTol, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const override ;
bool IsARectangle( double dLinTol, Point3d& ptP, Vector3d& vtL1, Vector3d& vtL2) const override ;
bool IsATrapezoid( double dLinTol, Point3d& ptP, Vector3d& vtB1, Vector3d& vtL1, Vector3d& vtB2) const override ;
bool SetCurveTempProp( int nCrv, int nProp, int nPropNum = 0) override ;
bool GetCurveTempProp( int nCrv, int& nProp, int nPropNum = 0) 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
int GetNgeId( void) const override ;
bool Save( NgeWriter& ngeOut) const override ;
@@ -175,7 +185,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
public :
CurveComposite( void) ;
CurveComposite( const CurveComposite& ccSrc)
CurveComposite( const CurveComposite& ccSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( ccSrc))
LOG_ERROR( GetEGkLogger(), "CurveComposite : copy constructor error") }
CurveComposite& operator =( const CurveComposite& ccSrc)
@@ -184,33 +194,38 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
return *this ; }
bool RelocateFrom( CurveComposite& ccSrc) ;
bool GetApproxLength( double& dLen) const ;
Voronoi* GetVoronoiObject( void) const ;
private :
bool CopyFrom( const CurveComposite& ccSrc) ;
bool Validate( void) ;
bool TestClosure( void) ;
bool AddCurveByRelocate( CurveComposite& ccSrc, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
bool AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ;
bool GetIndSCurveAndLocPar( double dU, Side nS, int& nSCrv, double& dLocU) const ;
bool SimpleOffsetXY( double dDist, int nType = OFF_FILLET) ;
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
bool IsOneCircle( Point3d& ptCen, Vector3d& vtN, double& dRad, bool& bCCW) const ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
private :
typedef std::deque<ICurve*> PCRVSMPL_DEQUE ;
typedef PCRVSMPL_DEQUE::iterator PCSD_ITER ;
typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ;
private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
int m_nTempProp[2] ; // vettore proprietà temporanee
mutable PCSD_CONST_ITER m_Iter ; // iteratore
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato
PCRVSMPL_DEQUE m_CrvSmplS ; // deque di curve semplici
Vector3d m_VtExtr ; // vettore estrusione (normalmente coincide con m_VtN)
double m_dThick ; // spessore
Point3d m_ptStart ; // punto iniziale per composita vuota per Add di linee o archi
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
mutable PCSD_CONST_ITER m_Iter ; // iteratore
} ;
//-----------------------------------------------------------------------------
@@ -250,6 +265,11 @@ inline CurveComposite* ConvertCurveToBasicComposite( IGeoObj* pGObj)
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 ;
}
+83 -3
View File
@@ -18,6 +18,7 @@
#include "GeoObjFactory.h"
#include "NgeWriter.h"
#include "NgeReader.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -30,15 +31,15 @@ GEOOBJ_REGISTER( CRV_LINE, NGE_C_LIN, CurveLine) ;
//----------------------------------------------------------------------------
CurveLine::CurveLine( void)
: m_nStatus( TO_VERIFY), m_PtStart(), m_PtEnd(), m_VtExtr(), m_dThick()
: m_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[1] = 0 ;
}
//----------------------------------------------------------------------------
CurveLine::~CurveLine( void)
{
ResetVoronoiObject() ;
}
//----------------------------------------------------------------------------
@@ -50,6 +51,8 @@ CurveLine::Set( const Point3d& ptStart, const Point3d& ptEnd)
m_PtEnd = ptEnd ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -69,6 +72,8 @@ CurveLine::SetPVL( const Point3d& ptStart, const Vector3d& vtDir, double dLen)
m_PtEnd = ptStart + vtDelta ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -86,6 +91,8 @@ CurveLine::SetPDL( const Point3d& ptStart, double dDirAngDeg, double dLen)
m_PtEnd = ptStart + vtDelta ;
m_nStatus = TO_VERIFY ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -128,6 +135,8 @@ CurveLine::CopyFrom( const CurveLine& clSrc)
m_dThick = clSrc.m_dThick ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
return Set( clSrc.m_PtStart, clSrc.m_PtEnd) ;
}
@@ -558,6 +567,8 @@ CurveLine::Invert( void)
// inverto i punti estremi
swap( m_PtStart, m_PtEnd) ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -589,6 +600,8 @@ CurveLine::SimpleOffset( double dDist, int nType)
m_PtStart += vtDir * dDist ;
m_PtEnd += vtDir * dDist ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -609,6 +622,8 @@ CurveLine::ModifyStart( const Point3d& ptNewStart)
// assegno il nuovo inizio
m_PtStart = ptNewStart ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -629,6 +644,8 @@ CurveLine::ModifyEnd( const Point3d& ptNewEnd)
// assegno la nuova fine
m_PtEnd = ptNewEnd ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -704,6 +721,8 @@ CurveLine::TrimStartAtLen( double dLenTrim)
if ( dLenTrim > EPS_ZERO)
m_PtStart = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -728,6 +747,8 @@ CurveLine::TrimEndAtLen( double dLenTrim)
if ( ( dLen - dLenTrim) > EPS_ZERO)
m_PtEnd = Media( m_PtStart, m_PtEnd, ( dLenTrim / dLen)) ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -750,6 +771,8 @@ CurveLine::ExtendStartByLen( double dLenExt)
// sposto il punto iniziale
m_PtStart -= vtDir * dLenExt ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -772,6 +795,8 @@ CurveLine::ExtendEndByLen( double dLenExt)
// sposto il punto finale
m_PtEnd += vtDir * dLenExt ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// con i controlli sopra fatti rimane validata, ma la grafica va ricalcolata
m_OGrMgr.Reset() ;
@@ -786,6 +811,8 @@ CurveLine::Translate( const Vector3d& vtMove)
if ( m_nStatus != OK)
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -807,6 +834,8 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do
if ( vtAx.IsSmall())
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -838,6 +867,8 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d
if ( AreSamePointApprox( ptNewStart, ptNewEnd))
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -867,6 +898,8 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
if ( vtNorm.IsSmall())
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -890,6 +923,8 @@ CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& v
if ( vtNorm.IsSmall() || vtDir.IsSmall())
return false ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -922,6 +957,8 @@ CurveLine::ToGlob( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -944,6 +981,8 @@ CurveLine::ToLoc( const Frame3d& frRef)
if ( IsGlobFrame( frRef))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -966,6 +1005,8 @@ CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
if ( AreSameFrame( frOri, frDest))
return true ;
// imposto ricalcolo di Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
@@ -1001,3 +1042,42 @@ CurveLine::CalcPointParamPosiz( const Point3d& ptP, bool bOnXY, double& dU, int&
nPos = ICurve::PP_MID ; // nell'interno
return true ;
}
//----------------------------------------------------------------------------
bool
CurveLine::CalcVoronoiObject() const
{
if ( m_nStatus != OK)
return false ;
// creo oggetto vroni con la curva
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
if ( m_pVoronoiObj == nullptr)
return false ;
return true ;
}
//----------------------------------------------------------------------------
Voronoi*
CurveLine::GetVoronoiObject() const
{
if ( m_nStatus != OK)
return nullptr ;
// se non è stato calcolato, lo calcolo
if ( m_pVoronoiObj == nullptr)
CalcVoronoiObject() ;
// restituisco Voronoi
return m_pVoronoiObj ;
}
//----------------------------------------------------------------------------
void
CurveLine::ResetVoronoiObject() const
{
if ( m_pVoronoiObj != nullptr)
delete m_pVoronoiObj ;
m_pVoronoiObj = nullptr ;
}
+21 -9
View File
@@ -19,6 +19,8 @@
#include "GeoObjRW.h"
#include "/EgtDev/Include/EGkCurveLine.h"
class Voronoi ;
//----------------------------------------------------------------------------
class CurveLine : public ICurveLine, public IGeoObjRW
{
@@ -54,6 +56,11 @@ class CurveLine : public ICurveLine, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // ICurve
bool IsSimple( void) const override
@@ -143,29 +150,34 @@ class CurveLine : public ICurveLine, public IGeoObjRW
public :
CurveLine( void) ;
CurveLine( const CurveLine& clSrc)
CurveLine( const CurveLine& clSrc) : m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( clSrc))
LOG_ERROR( GetEGkLogger(), "CurveLine : copy constructor error") }
CurveLine& operator =( const CurveLine& clSrc)
{ if ( ! CopyFrom( clSrc))
LOG_ERROR( GetEGkLogger(), "CurveLine : copy error")
return *this ; }
Voronoi* GetVoronoiObject( void) const ;
private :
bool CopyFrom( const CurveLine& clSrc) ;
bool Validate( void) ;
bool Validate( void) ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato
Point3d m_PtStart ; // punto iniziale
Point3d m_PtEnd ; // punto finale
Vector3d m_VtExtr ; // vettore estrusione
double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Status m_nStatus ; // stato
Point3d m_PtStart ; // punto iniziale
Point3d m_PtEnd ; // punto finale
Vector3d m_VtExtr ; // vettore estrusione
double m_dThick ; // spessore
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
mutable Voronoi* m_pVoronoiObj ; // Voronoi
} ;
//-----------------------------------------------------------------------------
+4 -4
View File
@@ -59,7 +59,7 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d
//----------------------------------------------------------------------------
bool
DistLineLine::GetSqDist( double& dSqDist)
DistLineLine::GetSqDist( double& dSqDist) const
{
if ( m_dSqDist < 0)
return false ;
@@ -70,7 +70,7 @@ DistLineLine::GetSqDist( double& dSqDist)
//----------------------------------------------------------------------------
bool
DistLineLine::GetDist( double& dDist)
DistLineLine::GetDist( double& dDist) const
{
if ( m_dSqDist < 0)
return false ;
@@ -83,7 +83,7 @@ DistLineLine::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const
{
if ( m_dSqDist < 0)
return false ;
@@ -94,7 +94,7 @@ DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2)
//----------------------------------------------------------------------------
bool
DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2)
DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const
{
if ( m_dSqDist < 0)
return false ;
+11 -11
View File
@@ -28,16 +28,16 @@ class DistLineLine
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
public :
bool GetSqDist( double& dSqDist) ;
bool GetDist( double& dDist) ;
bool IsEpsilon( double dTol) {
double dSqDist ;
return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ;
}
bool IsSmall( void) { return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void) { return IsEpsilon( EPS_ZERO) ; }
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) ;
bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) ;
bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; }
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const ;
bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const ;
private :
void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
@@ -45,7 +45,7 @@ class DistLineLine
bool bIsSegment1, bool bIsSegment2) ;
private:
double m_dSqDist ;
double m_dDist ;
mutable double m_dDist ;
double m_dPos1 ;
double m_dPos2 ;
Point3d m_ptMinDist1 ;
+5 -6
View File
@@ -122,14 +122,13 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
// cerco la minima distanza per la polilinea
MDCVECTOR vApproxMin ;
MDCVECTOR::iterator Iter ;
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
return ;
// raffino i punti trovati
double dPolishedPar ;
Point3d ptPolishedQ ;
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
// eseguo raffinamento
if ( PolishMinDistPointCurve( ptP, arArc, *Iter, dPolishedPar, ptPolishedQ)) {
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
@@ -148,7 +147,7 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc)
//----------------------------------------------------------------------------
bool
DistPointArc::GetSqDist( double& dSqDist)
DistPointArc::GetSqDist( double& dSqDist) const
{
if ( m_dDist < 0)
return false ;
@@ -159,7 +158,7 @@ DistPointArc::GetSqDist( double& dSqDist)
//----------------------------------------------------------------------------
bool
DistPointArc::GetDist( double& dDist)
DistPointArc::GetDist( double& dDist) const
{
if ( m_dDist < 0)
return false ;
@@ -170,7 +169,7 @@ DistPointArc::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{
if ( m_dDist < 0)
return false ;
@@ -185,7 +184,7 @@ DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
//----------------------------------------------------------------------------
bool
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{
if ( m_dDist < 0)
return false ;
+9 -8
View File
@@ -27,17 +27,18 @@ class DistPointArc
DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ;
public :
bool GetSqDist( double& dSqDist) ;
bool GetDist( double& dDist) ;
bool IsEpsilon( double dTol)
bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void)
bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void)
bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
int GetNbrMinDist( void) const
{ return (int) m_Info.size() ; }
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
private :
DistPointArc( void) ;
+1 -4
View File
@@ -156,13 +156,10 @@ bool
FilterMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve,
const MDCVECTOR& vApproxMin, double& dMinDist, MDPCIVECTOR& Info)
{
MDCVECTOR::const_iterator Iter ;
// determino i minimi raffinati da tenere
bool bFound = false ;
bool bLastOnEnd = false ; // flag per ultimo punto su fine del suo intervallo
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
for ( auto Iter = vApproxMin.cbegin() ; Iter != vApproxMin.cend() ; ++Iter) {
// altro punto con la stessa minima distanza
if ( bFound && abs( (*Iter).dDist - dMinDist) < EPS_SMALL) {
// se abbastanza lontano e non su bordi intervallino lo aggiungo
+6 -7
View File
@@ -44,7 +44,6 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
// cerco la minima distanza per la polilinea
MDCVECTOR vApproxMin ;
MDCVECTOR::iterator Iter ;
if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin))
return ;
@@ -52,7 +51,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
double dSingP ;
if ( CrvBez.GetSingularParam( dSingP) == 0)
dSingP = - 1 ;
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
// imposto flag per singolarità agli estremi
(*Iter).bParMinSing = abs( (*Iter).dParMin - dSingP) < EPS_SMALL ;
(*Iter).bParMaxSing = abs( (*Iter).dParMax - dSingP) < EPS_SMALL ;
@@ -61,7 +60,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
// raffino i punti trovati
double dPolishedPar ;
Point3d ptPolishedQ ;
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
// eseguo raffinamento
if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) {
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
@@ -80,7 +79,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
//----------------------------------------------------------------------------
bool
DistPointCrvBezier::GetSqDist( double& dSqDist)
DistPointCrvBezier::GetSqDist( double& dSqDist) const
{
if ( m_dDist < 0)
return false ;
@@ -91,7 +90,7 @@ DistPointCrvBezier::GetSqDist( double& dSqDist)
//----------------------------------------------------------------------------
bool
DistPointCrvBezier::GetDist( double& dDist)
DistPointCrvBezier::GetDist( double& dDist) const
{
if ( m_dDist < 0)
return false ;
@@ -102,7 +101,7 @@ DistPointCrvBezier::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{
if ( m_dDist < 0)
return false ;
@@ -117,7 +116,7 @@ DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
//----------------------------------------------------------------------------
bool
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{
if ( m_dDist < 0)
return false ;
+9 -8
View File
@@ -27,17 +27,18 @@ class DistPointCrvBezier
DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& CrvBez) ;
public :
bool GetSqDist( double& dSqDist) ;
bool GetDist( double& dDist) ;
bool IsEpsilon( double dTol)
bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void)
bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void)
bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
int GetNbrMinDist( void) const
{ return (int) m_Info.size() ; }
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
private :
DistPointCrvBezier( void) ;
+4 -4
View File
@@ -129,7 +129,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
//----------------------------------------------------------------------------
bool
DistPointCrvComposite::GetSqDist( double& dSqDist)
DistPointCrvComposite::GetSqDist( double& dSqDist) const
{
if ( m_dDist < 0)
return false ;
@@ -140,7 +140,7 @@ DistPointCrvComposite::GetSqDist( double& dSqDist)
//----------------------------------------------------------------------------
bool
DistPointCrvComposite::GetDist( double& dDist)
DistPointCrvComposite::GetDist( double& dDist) const
{
if ( m_dDist < 0)
return false ;
@@ -151,7 +151,7 @@ DistPointCrvComposite::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{
if ( m_dDist < 0)
return false ;
@@ -166,7 +166,7 @@ DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag
//----------------------------------------------------------------------------
bool
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{
if ( m_dDist < 0)
return false ;
+9 -8
View File
@@ -26,17 +26,18 @@ class DistPointCrvComposite
DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo) ;
public :
bool GetSqDist( double& dSqDist) ;
bool GetDist( double& dDist) ;
bool IsEpsilon( double dTol)
bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void)
bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void)
bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void) { return (int) m_Info.size() ; }
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ;
int GetNbrMinDist( void) const
{ return (int) m_Info.size() ; }
bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ;
bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ;
private :
DistPointCrvComposite( void) ;
+9 -9
View File
@@ -98,7 +98,7 @@ DistPointCurve::CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve)
//----------------------------------------------------------------------------
bool
DistPointCurve::GetSqDist( double& dSqDist)
DistPointCurve::GetSqDist( double& dSqDist) const
{
if ( m_dDist < 0)
return false ;
@@ -109,7 +109,7 @@ DistPointCurve::GetSqDist( double& dSqDist)
//----------------------------------------------------------------------------
bool
DistPointCurve::GetDist( double& dDist)
DistPointCurve::GetDist( double& dDist) const
{
if ( m_dDist < 0)
return false ;
@@ -120,7 +120,7 @@ DistPointCurve::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const
{
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ;
@@ -132,7 +132,7 @@ DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
//----------------------------------------------------------------------------
bool
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag)
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag) const
{
if ( m_dDist < 0 || m_Info.empty())
return false ;
@@ -166,7 +166,7 @@ DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFl
//----------------------------------------------------------------------------
bool
DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const
{
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ;
@@ -178,7 +178,7 @@ DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
//----------------------------------------------------------------------------
bool
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag)
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag) const
{
if ( m_dDist < 0 || m_Info.empty())
return false ;
@@ -209,7 +209,7 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int&
//----------------------------------------------------------------------------
bool
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide)
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) const
{
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ;
@@ -257,7 +257,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
//----------------------------------------------------------------------------
bool
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide)
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) const
{
if ( m_dDist < 0 || m_Info.empty())
return false ;
@@ -278,7 +278,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i
//----------------------------------------------------------------------------
bool
DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo)
DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) const
{
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
return false ;
+4 -4
View File
@@ -95,7 +95,7 @@ DistPointLine::Calculate( const Point3d& ptP,
//----------------------------------------------------------------------------
bool
DistPointLine::GetSqDist( double& dSqDist)
DistPointLine::GetSqDist( double& dSqDist) const
{
if ( m_dSqDist < 0)
return false ;
@@ -106,7 +106,7 @@ DistPointLine::GetSqDist( double& dSqDist)
//----------------------------------------------------------------------------
bool
DistPointLine::GetDist( double& dDist)
DistPointLine::GetDist( double& dDist) const
{
if ( m_dSqDist < 0)
return false ;
@@ -119,7 +119,7 @@ DistPointLine::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
DistPointLine::GetMinDistPoint( Point3d& ptMinDist) const
{
if ( m_dSqDist < 0)
return false ;
@@ -130,7 +130,7 @@ DistPointLine::GetMinDistPoint( Point3d& ptMinDist)
//----------------------------------------------------------------------------
bool
DistPointLine::GetParamAtMinDistPoint( double& dParam)
DistPointLine::GetParamAtMinDistPoint( double& dParam) const
{
if ( m_dSqDist < 0)
return false ;
+9 -9
View File
@@ -31,18 +31,18 @@ class DistPointLine
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ;
public :
bool GetSqDist( double& dSqDist) ;
bool GetDist( double& dDist) ;
bool IsEpsilon( double dTol)
bool GetSqDist( double& dSqDist) const ;
bool GetDist( double& dDist) const ;
bool IsEpsilon( double dTol) const
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
bool IsSmall( void)
bool IsSmall( void) const
{ return IsEpsilon( EPS_SMALL) ; }
bool IsZero( void)
bool IsZero( void) const
{ return IsEpsilon( EPS_ZERO) ; }
int GetNbrMinDist( void)
int GetNbrMinDist( void) const
{ return (( m_dSqDist < 0) ? 0 : 1) ; }
bool GetMinDistPoint( Point3d& ptMinDist) ;
bool GetParamAtMinDistPoint( double& dParam) ;
bool GetMinDistPoint( Point3d& ptMinDist) const ;
bool GetParamAtMinDistPoint( double& dParam) const ;
private :
DistPointLine( void) ;
@@ -51,7 +51,7 @@ class DistPointLine
private :
double m_dSqDist ;
double m_dDist ;
mutable double m_dDist ;
double m_dParam ;
Point3d m_ptMinDist ;
} ;
+3 -3
View File
@@ -176,7 +176,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
//----------------------------------------------------------------------------
bool
DistPointSurfTm::GetDist( double& dDist)
DistPointSurfTm::GetDist( double& dDist) const
{
// Distanza non valida
if ( m_dDist < -EPS_ZERO)
@@ -188,7 +188,7 @@ DistPointSurfTm::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint)
DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) const
{
// Distanza non valida
if ( m_dDist < -EPS_ZERO)
@@ -200,7 +200,7 @@ DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint)
//----------------------------------------------------------------------------
bool
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex)
DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) const
{
// Distanza non valida
if ( m_dDist < -EPS_ZERO)
BIN
View File
Binary file not shown.
+26 -1
View File
@@ -238,7 +238,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<OmitFramePointers>true</OmitFramePointers>
<FloatingPointModel>Precise</FloatingPointModel>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
@@ -280,6 +280,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="Attribs.cpp" />
<ClCompile Include="BBox3d.cpp" />
<ClCompile Include="BiArcs.cpp" />
<ClCompile Include="CalcPocketing.cpp" />
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
<ClCompile Include="CAvToolSurfTm.cpp" />
<ClCompile Include="CAvToolTriangle.cpp" />
@@ -308,12 +309,28 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="CurveByApprox.cpp" />
<ClCompile Include="CurveByInterp.cpp" />
<ClCompile Include="CurveCompositeOffset.cpp" />
<ClCompile Include="IntersCurveSurfTm.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="IntersLineVolZmap.cpp" />
<ClCompile Include="IntersPlaneVolZmap.cpp" />
<ClCompile Include="PolygonElevation.cpp" />
<ClCompile Include="RotationMinimizeFrame.cpp" />
<ClCompile Include="Voronoi.cpp" />
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" />
<ClInclude Include="..\Include\EGkIntersCurveSurfTm.h" />
<ClInclude Include="..\Include\EGkIntersLineBox.h" />
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h" />
<ClInclude Include="..\Include\EGkIntersPlaneBox.h" />
<ClInclude Include="..\Include\EGkIntersPlaneVolZmap.h" />
<ClInclude Include="..\Include\EGkPolygonElevation.h" />
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
<ClInclude Include="CDeBoxTria.h" />
<ClInclude Include="CDeCapsTria.h" />
<ClInclude Include="CDeConeFrustumTria.h" />
@@ -342,6 +359,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="IntersPlaneTria.cpp" />
<ClCompile Include="IntersSurfTmSurfTm.cpp" />
<ClCompile Include="IntersTriaTria.cpp" />
<ClCompile Include="OffsetAux.cpp" />
<ClCompile Include="Tree.cpp" />
<ClCompile Include="MedialAxis.cpp" />
<ClCompile Include="OffsetCurve.cpp" />
<ClCompile Include="DistPointArc.cpp" />
@@ -397,9 +416,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="OffsetCurveOnX.cpp" />
<ClCompile Include="Polygon3d.cpp" />
<ClCompile Include="AdjustLoops.cpp" />
<ClCompile Include="ProjectCurveSurfTm.cpp" />
<ClCompile Include="RemoveCurveDefects.cpp" />
<ClCompile Include="SelfIntersCurve.cpp" />
<ClCompile Include="SfrCreate.cpp" />
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp" />
<ClCompile Include="SurfAux.cpp" />
<ClCompile Include="SurfBezier.cpp" />
<ClCompile Include="SurfFlatRegion.cpp" />
@@ -440,6 +461,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="VolZmapGraphics.cpp" />
<ClCompile Include="VolZmapVolume.cpp" />
<ClCompile Include="VolZmap.cpp" />
<ClInclude Include="RotationMinimizeFrame.h" />
<ClInclude Include="Voronoi.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Include\EGkAngle.h" />
@@ -610,6 +633,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="IntersLineSurfStd.h" />
<ClInclude Include="IntersLineTria.h" />
<ClInclude Include="IterManager.h" />
<ClInclude Include="OffsetAux.h" />
<ClInclude Include="Tree.h" />
<ClInclude Include="Material.h" />
<ClInclude Include="FontNfe.h" />
<ClInclude Include="MC_Tables.h" />
+96 -27
View File
@@ -43,7 +43,16 @@
<Filter Include="File di origine\GeoOffset">
<UniqueIdentifier>{f07670fd-9429-4b7e-ac6d-1c0022e756fb}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\GeoCollision">
<Filter Include="File di origine\GeoProject">
<UniqueIdentifier>{d96752da-1884-4a73-ba1b-5b20b606e469}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\GeoElevation">
<UniqueIdentifier>{4c6a9dc5-8fac-4ecd-bde6-3e37e056712e}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\GeoCollisionAvoid">
<UniqueIdentifier>{ae52e402-3063-45e3-b9f7-1710035a1f56}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\GeoCollisionDetection">
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
</Filter>
</ItemGroup>
@@ -366,17 +375,8 @@
<ClCompile Include="IntersLineSurfStd.cpp">
<Filter>File di origine\GeoInters</Filter>
</ClCompile>
<ClCompile Include="CAvToolTriangle.cpp">
<Filter>File di origine\GeoCollision</Filter>
</ClCompile>
<ClCompile Include="CAvToolSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
</ClCompile>
<ClCompile Include="CDeBoxTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
</ClCompile>
<ClCompile Include="CAvSimpleSurfFrMove.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="IntersSurfTmSurfTm.cpp">
<Filter>File di origine\GeoInters</Filter>
@@ -394,19 +394,19 @@
<Filter>File di origine\Geo</Filter>
</ClCompile>
<ClCompile Include="CDeCylTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeBoxClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeCylClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeSpheTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeSpheClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="SurfBezier.cpp">
<Filter>File di origine\Geo</Filter>
@@ -424,34 +424,34 @@
<Filter>File di origine\GeoDist</Filter>
</ClCompile>
<ClCompile Include="CDeTriaTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeConeTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeUtility.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeClosedSurfTmClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeConeFrustumClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeConeFrustumTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeConvexTorusClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeConvexTorusTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeRectPrismoidClosedSurfTm.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="CDeRectPrismoidTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="SurfTriMeshUtilities.cpp">
<Filter>File di origine\Geo</Filter>
@@ -463,7 +463,7 @@
<Filter>File di origine\Base</Filter>
</ClCompile>
<ClCompile Include="CDeCapsTria.cpp">
<Filter>File di origine\GeoCollision</Filter>
<Filter>File di origine\GeoCollisionDetection</Filter>
</ClCompile>
<ClCompile Include="Circle2P.cpp">
<Filter>File di origine\GeoCreate</Filter>
@@ -471,6 +471,9 @@
<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>
@@ -480,9 +483,48 @@
<ClCompile Include="IntersLineCaps.cpp">
<Filter>File di origine\GeoInters</Filter>
</ClCompile>
<ClCompile Include="ProjectCurveSurfTm.cpp">
<Filter>File di origine\GeoProject</Filter>
</ClCompile>
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp">
<Filter>File di origine\GeoProject</Filter>
</ClCompile>
<ClCompile Include="SurfAux.cpp">
<Filter>File di origine\Geo</Filter>
</ClCompile>
<ClCompile Include="CalcPocketing.cpp">
<Filter>File di origine\GeoOffset</Filter>
</ClCompile>
<ClCompile Include="OffsetAux.cpp">
<Filter>File di origine\GeoOffset</Filter>
</ClCompile>
<ClCompile Include="Voronoi.cpp">
<Filter>File di origine\Base</Filter>
</ClCompile>
<ClCompile Include="PolygonElevation.cpp">
<Filter>File di origine\GeoElevation</Filter>
</ClCompile>
<ClCompile Include="IntersCurveSurfTm.cpp">
<Filter>File di origine\GeoInters</Filter>
</ClCompile>
<ClCompile Include="CAvSimpleSurfFrMove.cpp">
<Filter>File di origine\GeoCollisionAvoid</Filter>
</ClCompile>
<ClCompile Include="CAvToolSurfTm.cpp">
<Filter>File di origine\GeoCollisionAvoid</Filter>
</ClCompile>
<ClCompile Include="CAvToolTriangle.cpp">
<Filter>File di origine\GeoCollisionAvoid</Filter>
</ClCompile>
<ClCompile Include="IntersLineVolZmap.cpp">
<Filter>File di origine\GeoInters</Filter>
</ClCompile>
<ClCompile Include="IntersPlaneVolZmap.cpp">
<Filter>File di origine\GeoInters</Filter>
</ClCompile>
<ClCompile Include="RotationMinimizeFrame.cpp">
<Filter>File di origine\Geo</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -1115,6 +1157,9 @@
<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>
@@ -1127,6 +1172,30 @@
<ClInclude Include="SurfAux.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="OffsetAux.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkPolygonElevation.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="Voronoi.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkIntersCurveSurfTm.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkIntersPlaneVolZmap.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="RotationMinimizeFrame.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtGeomKernel.rc">
+297 -288
View File
@@ -2,7 +2,7 @@
// EgalTech 2019-2019
//----------------------------------------------------------------------------
// File : ExtDimension.cpp Data : 27.12.19 Versione : 2.2a1
// Contenuto : Implementazione della classe Dimension (quota).
// Contenuto : Implementazione della classe Dimension ( quota).
//
//
//
@@ -50,10 +50,9 @@ GEOOBJ_REGISTER( EXT_DIMENSION, NGE_E_DIM, ExtDimension) ;
//----------------------------------------------------------------------------
ExtDimension::ExtDimension( void)
: m_dExtLineLen( STD_EXTLINELEN), m_dArrowLen( STD_ARROWLEN), m_dTextDist( STD_TEXTDIST),
m_bLenIsMM( true), m_nDecDigit( STD_DECDIGIT), m_sFont( STD_FONT), m_dTextHeight( STD_TEXTHEIGHT)
m_bLenIsMM( true), m_nDecDigit( STD_DECDIGIT), m_sFont( STD_FONT), m_dTextHeight( STD_TEXTHEIGHT),
m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
{
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
}
//----------------------------------------------------------------------------
@@ -64,7 +63,7 @@ ExtDimension::~ExtDimension( void)
//----------------------------------------------------------------------------
bool
ExtDimension::SetStyle( double dExtLineLen, double dArrowLen, double dTextDist, bool bLenIsMM,
int nDecDigit, const string& sFont, double dTextHeight)
int nDecDigit, const string& sFont, double dTextHeight)
{
m_dExtLineLen = max( dExtLineLen, MIN_EXTLINELEN) ;
m_dArrowLen = max( dArrowLen, MIN_ARROWLEN) ;
@@ -94,7 +93,7 @@ ExtDimension::SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d
// verifico che i punti di misura non siano coincidenti
if ( AreSamePointApprox( m_ptP1, m_ptP2))
return false ;
// direzione di riferimento (nel piano perpendicolare a vtN)
// direzione di riferimento ( nel piano perpendicolare a vtN)
m_vtDir = vtDir ;
if ( m_vtDir.IsSmall())
m_vtDir = m_ptP2 - m_ptP1 ;
@@ -138,7 +137,7 @@ ExtDimension::SetLinear( const Point3d& ptP1, const Point3d& ptP2, const Point3d
bool
ExtDimension::SetRadial( const Point3d& ptCen, const Point3d& ptPos,
const Vector3d& vtN, const string& sText)
{
{ // il punto m_ptP6 viene utilizzato per il centro
// dichiaro quota non ancora determinata
m_nType = DT_NONE ;
// verifico la definizione del versore normale e del versore X
@@ -146,25 +145,20 @@ ExtDimension::SetRadial( const Point3d& ptCen, const Point3d& ptPos,
m_vtDir = ptPos - ptCen ;
if ( ! m_vtN.Normalize() || ! m_vtDir.Normalize())
return false ;
// porto i punti nel piano definito da ptCen e vtN
m_ptP6 = ptCen ;
m_ptPos = ptPos - ( ptPos - m_ptP6) * m_vtN * m_vtN ;
m_ptP1 = ptCen ;
m_ptPos = ptPos - ( ptPos - m_ptP5) * m_vtN * m_vtN ;
m_ptP3 = m_ptP1 ;
m_ptP5 = m_ptP1 ;
m_ptP2 = m_ptPos ;
m_ptP4 = m_ptPos ;
m_ptP6 = m_ptPos ;
// verifico che i punti di misura non siano coincidenti
if ( AreSamePointApprox( m_ptP5, m_ptPos))
if ( AreSamePointApprox( m_ptP6, m_ptPos))
return false ;
// assegnazione del testo
// assegnazione del testo
m_sText = sText ;
// assegno il tipo
// assegno il tipo
m_nType = DT_RADIAL ;
// imposto da calcolare
// imposto da calcolare
m_bToCalc = true ;
m_OGrMgr.Reset() ;
@@ -175,7 +169,7 @@ ExtDimension::SetRadial( const Point3d& ptCen, const Point3d& ptPos,
bool
ExtDimension::SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
const Vector3d& vtN, const string& sText)
{
{ // il punto m_ptP6 viene utilizzato per il centro
// dichiaro quota non ancora determinata
m_nType = DT_NONE ;
// verifico la definizione del versore normale e del versore X
@@ -183,26 +177,21 @@ ExtDimension::SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
m_vtDir = ptPos - ptCen ;
if ( ! m_vtN.Normalize() || ! m_vtDir.Normalize())
return false ;
// porto i punti nel piano definito da ptP1 e vtN
m_ptPos = ptPos - ( ptPos - ptCen) * m_vtN * m_vtN ;
// porto i punti nel piano definito da ptP6 e vtN
m_ptP6 = ptCen ;
m_ptPos = ptPos - ( ptPos - m_ptP6) * m_vtN * m_vtN ;
m_ptP2 = m_ptPos ;
m_ptP6 = m_ptPos ;
m_ptP4 = m_ptPos ;
// ottengo il punto diametralmente opposto a ptPos
m_ptP1 = ptCen - ( m_ptPos - ptCen) ;
m_ptP5 = m_ptP1 ;
m_ptP3 = m_ptP1 ;
// verifico che i punti di misura non siano coincidenti
if ( AreSamePointApprox( m_ptP5, m_ptPos))
return false ;
// assegnazione del testo
// assegnazione del testo
m_sText = sText ;
// assegno il tipo
// assegno il tipo
m_nType = DT_DIAMETRAL ;
// imposto da calcolare
// imposto da calcolare
m_bToCalc = true ;
m_OGrMgr.Reset() ;
@@ -211,7 +200,7 @@ ExtDimension::SetDiametral( const Point3d& ptCen, const Point3d& ptPos,
//----------------------------------------------------------------------------
bool
ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptV, const Point3d& ptPos,
ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptV, const Point3d& ptP2, const Point3d& ptPos,
const Vector3d& vtN, const string& sText)
{
// dichiaro quota non ancora determinata
@@ -223,32 +212,25 @@ ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3
// porto i punti nel piano definito da P1 e N
m_ptP1 = ptP1 ;
m_ptP2 = ptP2 - ( ptP2 - m_ptP1) * m_vtN * m_vtN ;
m_ptP5 = ptV - ( ptV - m_ptP1) * m_vtN * m_vtN ;
m_ptP6 = ptV - ( ptV - m_ptP1) * m_vtN * m_vtN ;
m_ptPos = ptPos - ( ptPos - m_ptP1) * m_vtN * m_vtN ;
// verifico che i punti di misura non siano coincidenti
if ( AreSamePointApprox( m_ptP1, m_ptP2) || AreSamePointApprox( m_ptP1, m_ptP5) || AreSamePointApprox( m_ptP2, m_ptP5))
if ( AreSamePointApprox( m_ptP1, m_ptP2) || AreSamePointApprox( m_ptP1, m_ptP6) || AreSamePointApprox( m_ptP2, m_ptP5))
return false ;
// calcolo le direzioni su cui giacciono i due lati dell'angolo
Vector3d vtLine1 = m_ptP1 - m_ptP5 ;
Vector3d vtLine2 = m_ptP2 - m_ptP5 ;
double dLen1 = vtLine1.Len() ;
double dLen2 = vtLine2.Len() ;
if ( ! vtLine1.Normalize() || ! vtLine2.Normalize())
return false ;
// direzione di riferimento (nel piano perpendicolare a vtN)
m_vtDir = m_ptPos - m_ptP5 ;
// direzione di riferimento ( nel piano perpendicolare a vtN)
m_vtDir = m_ptPos - m_ptP6 ;
double dLenDir = m_vtDir.Len() ;
// controllo se è testo o se è la misura
double dHalfDist ;
double dFactor ;
if ( m_sCalcText.find( IS_MEASURE) != string::npos) {
dHalfDist = GetTextHalfDist( m_ptPos) ;
m_sCalcText = "300.00" ;
double dHalfDist = GetTextHalfDist( m_ptPos) ;
dFactor = 2.5 * dHalfDist ;
m_sCalcText = "" ;
}
else {
dHalfDist = GetTextHalfDist( m_ptPos) ;
double dHalfDist = GetTextHalfDist( m_ptPos) ;
dFactor = 2.5 * dHalfDist ;
}
// allungo m_vtDir se è troppo vicino al centro
@@ -256,24 +238,26 @@ ExtDimension::SetAngular( const Point3d& ptP1, const Point3d& ptP2, const Point3
Vector3d vtDir_n = m_vtDir ;
if ( ! vtDir_n.Normalize())
return false ;
m_ptPos = m_ptP5 + dFactor * vtDir_n ;
m_ptPos = m_ptP6 + dFactor * vtDir_n ;
// ricalcolo m_vtDir
m_vtDir = m_ptPos - m_ptP5 ;
m_vtDir = m_ptPos - m_ptP6 ;
dLenDir = m_vtDir.Len() ;
}
// calcolo le direzioni su cui giacciono i due lati dell'angolo
Vector3d vtLine1 = m_ptP1 - m_ptP6 ;
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
double dLen1 = vtLine1.Len() ;
double dLen2 = vtLine2.Len() ;
if ( ! vtLine1.Normalize() || ! vtLine2.Normalize())
return false ;
// segnalo se i punti che definiscono i lati sono più lontani dal centro di ptPos
bool bPt1Close = false ;
bool bPt2Close = false ;
if ( dLenDir < dLen1)
bPt1Close = true ;
if ( dLenDir < dLen2)
bPt2Close = true ;
bool bPt1Close = ( dLenDir < dLen1 ? true : false) ;
bool bPt2Close = ( dLenDir < dLen2 ? true : false) ;
m_ptP5 = m_ptP1 + ( dLenDir - dLen1) * vtLine1 ;
m_ptP6 = m_ptP2 + ( dLenDir - dLen2) * vtLine2 ;
Point3d ptP5_bis = m_ptP2 + ( dLenDir - dLen2) * vtLine2 ;
m_ptP3 = m_ptP5 + ( bPt1Close ? - vtLine1 : vtLine1) * m_dExtLineLen ;
m_ptP4 = m_ptP6 + ( bPt2Close ? - vtLine2 : vtLine2) * m_dExtLineLen ;
m_ptP4 = ptP5_bis + ( bPt2Close ? - vtLine2 : vtLine2) * m_dExtLineLen ;
// assegnazione del testo
m_sText = sText ;
// assegno il tipo
@@ -333,6 +317,7 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
m_sCalcText = clSrc.m_sCalcText ;
m_ptCalcPos = clSrc.m_ptCalcPos ;
m_bCalcArrowIn = clSrc.m_bCalcArrowIn ;
m_bCalcTextOn = clSrc.m_bCalcTextOn ;
m_ptCalcP7 = clSrc.m_ptCalcP7 ;
m_ptCalcP8 = clSrc.m_ptCalcP8 ;
m_dExtLineLen = clSrc.m_dExtLineLen ;
@@ -344,6 +329,8 @@ ExtDimension::CopyFrom( const ExtDimension& clSrc)
m_dTextHeight = clSrc.m_dTextHeight ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
return true ;
}
@@ -379,15 +366,15 @@ ExtDimension::Dump( string& sOut, bool bMM, const char* szNewLine) const
{
// parametri
sOut += GetSubType() + szNewLine ;
sOut += "VN(" + ToString( m_vtN, 3) + ") " + szNewLine ;
sOut += "VD(" + ToString( m_vtDir, 3) + ") " + szNewLine ;
sOut += "P1(" + ToString( GetInUiUnits( m_ptP1, bMM), 3) + ") " + szNewLine ;
sOut += "P2(" + ToString( GetInUiUnits( m_ptP2, bMM), 3) + ") " + szNewLine ;
sOut += "P3(" + ToString( GetInUiUnits( m_ptP3, bMM), 3) + ") " + szNewLine ;
sOut += "P4(" + ToString( GetInUiUnits( m_ptP4, bMM), 3) + ") " + szNewLine ;
sOut += "P5(" + ToString( GetInUiUnits( m_ptP5, bMM), 3) + ") " + szNewLine ;
sOut += "P6(" + ToString( GetInUiUnits( m_ptP6, bMM), 3) + ") " + szNewLine ;
sOut += "Pos(" + ToString( GetInUiUnits( m_ptPos, bMM), 3) + ") " + szNewLine ;
sOut += "VN( " + ToString( m_vtN, 3) + ") " + szNewLine ;
sOut += "VD( " + ToString( m_vtDir, 3) + ") " + szNewLine ;
sOut += "P1( " + ToString( GetInUiUnits( m_ptP1, bMM), 3) + ") " + szNewLine ;
sOut += "P2( " + ToString( GetInUiUnits( m_ptP2, bMM), 3) + ") " + szNewLine ;
sOut += "P3( " + ToString( GetInUiUnits( m_ptP3, bMM), 3) + ") " + szNewLine ;
sOut += "P4( " + ToString( GetInUiUnits( m_ptP4, bMM), 3) + ") " + szNewLine ;
sOut += "P5( " + ToString( GetInUiUnits( m_ptP5, bMM), 3) + ") " + szNewLine ;
sOut += "P6( " + ToString( GetInUiUnits( m_ptP6, bMM), 3) + ") " + szNewLine ;
sOut += "Pos( " + ToString( GetInUiUnits( m_ptPos, bMM), 3) + ") " + szNewLine ;
sOut += "Txt=" + m_sText + szNewLine ;
sOut += "El=" + ToString( GetInUiUnits( m_dExtLineLen, bMM), 3) +
" Al=" + ToString( GetInUiUnits( m_dArrowLen, bMM), 3) +
@@ -528,7 +515,7 @@ ExtDimension::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
return true ;
}
else if ( m_nType == DT_RADIAL) {
b3Loc.Set( m_ptP5) ;
b3Loc.Set( m_ptP6) ;
b3Loc.Add( m_ptPos) ;
// ingombro del testo
BBox3d b3Text ;
@@ -537,7 +524,7 @@ ExtDimension::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
return true ;
}
else if ( m_nType == DT_DIAMETRAL) {
b3Loc.Set( m_ptP5) ;
b3Loc.Set( m_ptP6) ;
b3Loc.Add( m_ptPos) ;
// ingombro del testo
BBox3d b3Text ;
@@ -551,6 +538,7 @@ ExtDimension::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
b3Loc.Add( m_ptP3) ;
b3Loc.Add( m_ptP4) ;
b3Loc.Set( m_ptP5) ;
b3Loc.Set( m_ptP6) ;
b3Loc.Add( m_ptCalcP7) ;
b3Loc.Add( m_ptCalcP8) ;
// ingombro del testo
@@ -574,7 +562,7 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
Update() ;
// se valido
if ( m_nType == DT_LINEAR) {
// ingombro dei punti (portati nel riferimento passato)
// ingombro dei punti ( portati nel riferimento passato)
Point3d ptFrP1 = m_ptP1 ;
ptFrP1.ToGlob( frRef) ;
b3Ref.Set( ptFrP1) ;
@@ -600,8 +588,8 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
return true ;
}
else if ( m_nType == DT_RADIAL) {
// ingombro dei punti (portati nel riferimento passato)
Point3d ptFrP5 = m_ptP5 ;
// ingombro dei punti ( portati nel riferimento passato)
Point3d ptFrP5 = m_ptP6 ;
ptFrP5.ToGlob( frRef) ;
b3Ref.Set( ptFrP5) ;
Point3d ptFrPos = m_ptPos ;
@@ -614,8 +602,8 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
return true ;
}
else if ( m_nType == DT_DIAMETRAL) {
// ingombro dei punti (portati nel riferimento passato)
Point3d ptFrP5 = m_ptP5 ;
// ingombro dei punti ( portati nel riferimento passato)
Point3d ptFrP5 = m_ptP6 ;
ptFrP5.ToGlob( frRef) ;
b3Ref.Set( ptFrP5) ;
Point3d ptFrPos = m_ptPos ;
@@ -628,9 +616,6 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
return true ;
}
else if ( m_nType == DT_ANGULAR) {
Point3d ptFrP5 = m_ptP5 ;
ptFrP5.ToGlob( frRef) ;
b3Ref.Set( ptFrP5) ;
Point3d ptFrP1 = m_ptP1 ;
ptFrP1.ToGlob( frRef) ;
b3Ref.Add( ptFrP1) ;
@@ -643,6 +628,12 @@ ExtDimension::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
Point3d ptFrP4 = m_ptP4 ;
ptFrP4.ToGlob( frRef) ;
b3Ref.Add( ptFrP4) ;
Point3d ptFrP5 = m_ptP5 ;
ptFrP5.ToGlob( frRef) ;
b3Ref.Set( ptFrP5) ;
Point3d ptFrP6 = m_ptP6 ;
ptFrP6.ToGlob( frRef) ;
b3Ref.Set( ptFrP6) ;
Point3d ptFrP7 = m_ptCalcP7 ;
ptFrP7.ToGlob( frRef) ;
b3Ref.Add( ptFrP7) ;
@@ -697,14 +688,14 @@ ExtDimension::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
// se valido
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
return ( m_vtN.Rotate( vtAx, dCosAng, dSinAng) &&
m_vtDir.Rotate( vtAx, dCosAng, dSinAng) &&
m_ptP1.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP2.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP3.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP4.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP5.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP6.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptPos.Rotate( ptAx, vtAx, dCosAng, dSinAng)) ;
m_vtDir.Rotate( vtAx, dCosAng, dSinAng) &&
m_ptP1.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP2.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP3.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP4.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP5.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptP6.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
m_ptPos.Rotate( ptAx, vtAx, dCosAng, dSinAng)) ;
}
else
return false ;
@@ -738,6 +729,8 @@ ExtDimension::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, doubl
return false ;
if ( ! m_ptP2.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
return false ;
if ( ! m_ptP6.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
return false ;
if ( ! m_ptPos.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
return false ;
// ricalcolo completamente la quota
@@ -745,11 +738,11 @@ ExtDimension::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, doubl
case DT_LINEAR :
return SetLinear( m_ptP1, m_ptP2, m_ptPos, m_vtN, m_vtDir, m_sText) ;
case DT_RADIAL :
return SetRadial( m_ptP5, m_ptPos, m_vtN, m_sText) ;
return SetRadial( m_ptP6, m_ptPos, m_vtN, m_sText) ;
case DT_DIAMETRAL :
return SetDiametral( m_ptP5, m_ptPos, m_vtN, m_sText) ;
return SetDiametral( m_ptP6, m_ptPos, m_vtN, m_sText) ;
case DT_ANGULAR :
return SetAngular( m_ptP5, m_ptP1, m_ptP2, m_ptPos, m_vtN, m_sText) ;
return SetAngular( m_ptP1, m_ptP6, m_ptP2, m_ptPos, m_vtN, m_sText) ;
default :
return false ;
}
@@ -772,12 +765,12 @@ ExtDimension::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// se valido
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
// eseguo il mirror dei versori
// eseguo il mirror dei versori
if ( ! m_vtN.Mirror( vtNorm))
return false ;
if ( ! m_vtDir.Mirror( vtNorm))
return false ;
// eseguo il mirror dei punti
// eseguo il mirror dei punti
if ( ! m_ptP1.Mirror( ptOn, vtNorm))
return false ;
if ( ! m_ptP2.Mirror( ptOn, vtNorm))
@@ -826,6 +819,8 @@ ExtDimension::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d
return false ;
if ( ! m_ptP2.Shear( ptOn, vtNorm, vtDir, dCoeff))
return false ;
if ( ! m_ptP6.Shear( ptOn, vtNorm, vtDir, dCoeff))
return false ;
if ( ! m_ptPos.Shear( ptOn, vtNorm, vtDir, dCoeff))
return false ;
// ricalcolo completamente la quota
@@ -833,11 +828,11 @@ ExtDimension::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d
case DT_LINEAR :
return SetLinear( m_ptP1, m_ptP2, m_ptPos, m_vtN, m_vtDir, m_sText) ;
case DT_RADIAL :
return SetRadial( m_ptP5, m_ptPos, m_vtN, m_sText) ;
return SetRadial( m_ptP6, m_ptPos, m_vtN, m_sText) ;
case DT_DIAMETRAL :
return SetDiametral( m_ptP5, m_ptPos, m_vtN, m_sText) ;
return SetDiametral( m_ptP6, m_ptPos, m_vtN, m_sText) ;
case DT_ANGULAR :
return SetAngular( m_ptP5, m_ptP1, m_ptP2, m_ptPos, m_vtN, m_sText) ;
return SetAngular( m_ptP1, m_ptP6, m_ptP2, m_ptPos, m_vtN, m_sText) ;
default :
return false ;
}
@@ -864,16 +859,16 @@ ExtDimension::ToGlob( const Frame3d& frRef)
// se valido
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
// trasformo punto e versori
// trasformo punto e versori
return ( m_vtN.ToGlob( frRef) &&
m_vtDir.ToGlob( frRef) &&
m_ptP1.ToGlob( frRef) &&
m_ptP2.ToGlob( frRef) &&
m_ptP3.ToGlob( frRef) &&
m_ptP4.ToGlob( frRef) &&
m_ptP5.ToGlob( frRef) &&
m_ptP6.ToGlob( frRef) &&
m_ptPos.ToGlob( frRef)) ;
m_vtDir.ToGlob( frRef) &&
m_ptP1.ToGlob( frRef) &&
m_ptP2.ToGlob( frRef) &&
m_ptP3.ToGlob( frRef) &&
m_ptP4.ToGlob( frRef) &&
m_ptP5.ToGlob( frRef) &&
m_ptP6.ToGlob( frRef) &&
m_ptPos.ToGlob( frRef)) ;
}
else
return false ;
@@ -897,16 +892,16 @@ ExtDimension::ToLoc( const Frame3d& frRef)
// se valido
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
// trasformo punto e versori
// trasformo punto e versori
return ( m_vtN.ToLoc( frRef) &&
m_vtDir.ToLoc( frRef) &&
m_ptP1.ToLoc( frRef) &&
m_ptP2.ToLoc( frRef) &&
m_ptP3.ToLoc( frRef) &&
m_ptP4.ToLoc( frRef) &&
m_ptP5.ToLoc( frRef) &&
m_ptP6.ToLoc( frRef) &&
m_ptPos.ToLoc( frRef)) ;
m_vtDir.ToLoc( frRef) &&
m_ptP1.ToLoc( frRef) &&
m_ptP2.ToLoc( frRef) &&
m_ptP3.ToLoc( frRef) &&
m_ptP4.ToLoc( frRef) &&
m_ptP5.ToLoc( frRef) &&
m_ptP6.ToLoc( frRef) &&
m_ptPos.ToLoc( frRef)) ;
}
else
return false ;
@@ -932,14 +927,14 @@ ExtDimension::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
if ( m_nType >= DT_LINEAR && m_nType <= DT_ANGULAR) {
// trasformo punto e versori
return ( m_vtN.ToGlob( frOri) && m_vtN.ToLoc( frDest) &&
m_vtDir.ToGlob( frOri) && m_vtDir.ToLoc( frDest) &&
m_ptP1.ToGlob( frOri) && m_ptP1.ToLoc( frDest) &&
m_ptP2.ToGlob( frOri) && m_ptP2.ToLoc( frDest) &&
m_ptP3.ToGlob( frOri) && m_ptP3.ToLoc( frDest) &&
m_ptP4.ToGlob( frOri) && m_ptP4.ToLoc( frDest) &&
m_ptP5.ToGlob( frOri) && m_ptP5.ToLoc( frDest) &&
m_ptP6.ToGlob( frOri) && m_ptP6.ToLoc( frDest) &&
m_ptPos.ToGlob( frOri) && m_ptPos.ToLoc( frDest)) ;
m_vtDir.ToGlob( frOri) && m_vtDir.ToLoc( frDest) &&
m_ptP1.ToGlob( frOri) && m_ptP1.ToLoc( frDest) &&
m_ptP2.ToGlob( frOri) && m_ptP2.ToLoc( frDest) &&
m_ptP3.ToGlob( frOri) && m_ptP3.ToLoc( frDest) &&
m_ptP4.ToGlob( frOri) && m_ptP4.ToLoc( frDest) &&
m_ptP5.ToGlob( frOri) && m_ptP5.ToLoc( frDest) &&
m_ptP6.ToGlob( frOri) && m_ptP6.ToLoc( frDest) &&
m_ptPos.ToGlob( frOri) && m_ptPos.ToLoc( frDest)) ;
}
else
return false ;
@@ -992,7 +987,7 @@ ExtDimension::Update( void) const
else
m_ptCalcPos = m_ptCalcP8 + m_vtDir * dHalfDist ;
}
// dichiaro ricalcolo eseguito
// dichiaro ricalcolo eseguito
m_bToCalc = false ;
return true ;
}
@@ -1011,21 +1006,27 @@ ExtDimension::Update( void) const
ReplaceString( m_sCalcText, IS_MEASURE, sVal) ;
}
// punto di inserimento del testo
m_ptCalcPos = ( m_ptP5 + m_ptP6) / 2 ;
m_ptCalcPos = ( m_ptP5 + m_ptP2) / 2 ;
// alzo il testo dalla linea di misura
BBox3d b3Text ;
if ( ! GetTextMyBBox( b3Text) && ! b3Text.IsEmpty())
return false ;
double dHeight = b3Text.GetMax().y - b3Text.GetMin().y ;
Vector3d vtPerpDir = m_ptPos - m_ptP5 ;
vtPerpDir.Normalize() ;
if ( ! vtPerpDir.Rotate( m_vtN, 90))
Vector3d vtPerpDir = m_ptPos - m_ptP6 ;
if ( ! vtPerpDir.Normalize())
return false ;
// calcolo il frame dell'arco per valutare la posizione del testo
Frame3d frRef ;
if ( ! frRef.Set( m_ptP6, m_vtN))
return false ;
double dAngDeg = 0 ;
if ( ! m_vtDir.GetAngle( frRef.VersX(), dAngDeg) || ! vtPerpDir.Rotate( m_vtN, ( dAngDeg < 90 ? 90 : -90)))
return false ;
m_ptCalcPos = m_ptCalcPos + 0.6 * dHeight * vtPerpDir ;
// semidistanza di interruzione
double dHalfDist = GetTextHalfDist( m_ptCalcPos) ;
// lunghezza della linea di misura
double dLen = ( m_ptP6 - m_ptP5).Len() ;
double dLen = Dist( m_ptP1, m_ptP2) ;
// determino come orientare le frecce e dove mettere il testo
if ( dLen - 2 * m_dArrowLen >= 2 * dHalfDist) {
m_bCalcArrowIn = true ;
@@ -1038,7 +1039,7 @@ ExtDimension::Update( void) const
m_bCalcArrowIn = false ;
m_bCalcTextOn = true ;
m_ptCalcP7 = m_ptP5 - m_vtDir * 2 * m_dArrowLen ;
m_ptCalcP8 = m_ptP6 + m_vtDir * 2 * m_dArrowLen ;
m_ptCalcP8 = m_ptP2 + m_vtDir * 2 * m_dArrowLen ;
}
// stanno fuori sia le frecce sia il testo
else {
@@ -1046,7 +1047,8 @@ ExtDimension::Update( void) const
m_bCalcTextOn = false ;
// metto la quotatura dal lato di ptPos
Vector3d vtRad = m_ptPos - m_ptP5 ;
vtRad.Normalize() ;
if ( ! vtRad.Normalize())
return false ;
m_ptCalcPos = m_ptPos + vtRad * ( dHalfDist + 2 * m_dArrowLen) ;
}
// dichiaro ricalcolo eseguito
@@ -1056,9 +1058,11 @@ ExtDimension::Update( void) const
case DT_ANGULAR : {
// angolo
double dAngDeg, dAngDeg1, dAngDeg2 = 0 ;
Vector3d vtLine1 = m_ptP1 - m_ptP5 ;
Vector3d vtLine2 = m_ptP2 - m_ptP5 ;
Vector3d vtLine3 = m_ptPos - m_ptP5 ;
Vector3d vtLine1 = m_ptP1 - m_ptP6 ;
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
Vector3d vtLine3 = m_ptPos - m_ptP6 ;
// calcolo gli angoli tra m_ptPos e i due punti che identificano i lati dell'angolo
// per capire se sto calcolando l'angolo interno o esterno
if ( ! vtLine1.GetAngle( vtLine2, dAngDeg) || ! vtLine1.GetAngle( vtLine3, dAngDeg1) || ! vtLine2.GetAngle( vtLine3, dAngDeg2))
return false ;
if ( dAngDeg < dAngDeg1 + dAngDeg2 - EPS_SMALL || dAngDeg > dAngDeg1 + dAngDeg2 + EPS_SMALL)
@@ -1066,14 +1070,17 @@ ExtDimension::Update( void) const
// testo
m_sCalcText = m_sText ;
if ( m_sCalcText.find( IS_MEASURE) != string::npos) {
// calcolo gli angoli tra m_ptPos e i due punti che identificano i lati dell'angolo
// per capire se sto calcolando l'angolo interno o esterno
string sAngDeg = ToString( dAngDeg, m_nDecDigit) ;
ReplaceString( m_sCalcText, IS_MEASURE, sAngDeg + "°") ;
}
// calcolo ptP5_bis
double dLen2 = vtLine2.Len() ;
if ( ! vtLine2.Normalize())
return false ;
Point3d ptP5_bis = m_ptP2 + ( m_vtDir.Len() - dLen2) * vtLine2 ;
// calcolo l'arco su cui metterò la misura
PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
if ( IsNull( pCrvPos) || ! pCrvPos->Set3P( m_ptP6, m_ptPos, m_ptP5, false))
if ( IsNull( pCrvPos) || ! pCrvPos->Set3P( ptP5_bis, m_ptPos, m_ptP5, false))
return false ;
// punto di inserimento del testo
pCrvPos->GetMidPoint( m_ptCalcPos) ;
@@ -1084,15 +1091,14 @@ ExtDimension::Update( void) const
if ( ! pCrvPos->GetLength( dLen))
return false ;
// calcolo anche lo spazio ad una distanza dal centro maggiorata
double dLenPos = 0 ;
double dDist = Dist( m_ptCalcPos, m_ptP5) ;
dLenPos = dDist * dAngDeg * DEGTORAD ;
// determino come orientare le frecce e dove mettere il testo
double dU ;
double dDist = Dist( m_ptCalcPos, m_ptP6) ;
double dLenPos = dDist * dAngDeg * DEGTORAD ;
// determino come orientare le frecce e dove mettere il testo
// frecce e testo dentro
if ( dLen - 2 * m_dArrowLen >= 2 * dHalfDist) {
m_bCalcArrowIn = true ;
m_bCalcTextOn = true ;
double dU ;
pCrvPos->GetParamAtLength( dLen / 2. + dHalfDist, dU) ;
pCrvPos->GetPointD1D2( dU, ICurve::FROM_MINUS, m_ptCalcP7) ;
pCrvPos->GetParamAtLength( dLen / 2. - dHalfDist, dU) ;
@@ -1103,12 +1109,11 @@ ExtDimension::Update( void) const
else if ( dLen > 2 * dHalfDist || ( dLen < 2 * dHalfDist && dLenPos > 2 * dHalfDist)) {
m_bCalcArrowIn = false ;
m_bCalcTextOn = true ;
double dU ;
pCrvPos->GetParamAtLength( dLen / 2. + dHalfDist, dU) ;
pCrvPos->GetPointD1D2( dU, ICurve::FROM_MINUS, m_ptCalcP7) ;
pCrvPos->GetParamAtLength( dLen / 2. - dHalfDist, dU) ;
pCrvPos->GetPointD1D2( dU, ICurve::FROM_MINUS, m_ptCalcP8) ;
//pCrvPosExt->GetStartPoint( m_ptCalcP8) ;
//pCrvPosExt->GetEndPoint( m_ptCalcP7) ;
if ( dLen < 2 * dHalfDist) {
m_ptCalcPos += ( m_ptCalcPos - m_ptP5) ;
m_bCalcTextOn = false ;
@@ -1118,11 +1123,9 @@ ExtDimension::Update( void) const
else {
m_bCalcArrowIn = false ;
m_bCalcTextOn = false ;
//pCrvPosExt->GetStartPoint( m_ptCalcP8) ;
//pCrvPosExt->GetEndPoint( m_ptCalcP7) ;
vtLine1.Normalize() ;
vtLine2.Normalize() ;
if ( Dist( m_ptPos, m_ptP5) < Dist( m_ptPos, m_ptP6)) {
if ( Dist( m_ptPos, m_ptP5) < Dist( m_ptPos, ptP5_bis)) {
Vector3d vtDirEnd ;
pCrvPos->GetEndDir( vtDirEnd) ;
m_ptCalcPos = m_ptP5 + dHalfDist * ( vtDirEnd + vtLine1) ;
@@ -1130,7 +1133,7 @@ ExtDimension::Update( void) const
else {
Vector3d vtDirStart ;
pCrvPos->GetStartDir( vtDirStart) ;
m_ptCalcPos = m_ptP6 + dHalfDist * ( - vtDirStart + vtLine2) ;
m_ptCalcPos = ptP5_bis + dHalfDist * ( - vtDirStart + vtLine2) ;
}
}
// dichiaro ricalcolo eseguito
@@ -1155,12 +1158,18 @@ ExtDimension::GetMidPoint( Point3d& ptMid) const
ptMid = ( m_ptP1 + m_ptP2) / 2;
return true ;
case DT_ANGULAR :
{ PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
if ( ! pCrvPos->Set3P( m_ptP6, m_ptPos, m_ptP5, false))
return false ;
pCrvPos->GetMidPoint( ptMid) ;
return true ;
}
{ // calcolo ptP5_bis
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
double dLen2 = vtLine2.Len() ;
if ( ! vtLine2.Normalize())
return false ;
Point3d ptP5_bis = m_ptP2 + ( m_vtDir.Len() - dLen2) * vtLine2 ;
Vector3d vtMid = ( ptP5_bis + m_ptP5) / 2 - m_ptP6 ;
if ( ! vtMid.Normalize())
return false ;
ptMid = m_ptP6 + vtMid * m_vtDir.Len() ;
return true;
}
default :
return false ;
}
@@ -1180,7 +1189,7 @@ ExtDimension::GetCenterPoint( Point3d& ptCen) const
case DT_RADIAL :
case DT_DIAMETRAL :
case DT_ANGULAR :
ptCen = m_ptP5 ;
ptCen = m_ptP6 ;
return true ;
default :
return false ;
@@ -1195,153 +1204,154 @@ ExtDimension::ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST&
Update() ;
// se quota valida
switch ( m_nType) {
case DT_LINEAR : {
// prima linea di riferimento
case DT_LINEAR : {
// prima linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP1) ;
lstPL.back().AddUPoint( 1, m_ptP3) ;
// seconda linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP2) ;
lstPL.back().AddUPoint( 1, m_ptP4) ;
// se non c'è testo, linea di misura intera
if ( IsEmptyOrSpaces( m_sCalcText)) {
lstPL.emplace_back() ;
lstPL.back().AddUPoint(0, m_ptP1) ;
lstPL.back().AddUPoint(1, m_ptP3) ;
// seconda linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint(0, m_ptP2) ;
lstPL.back().AddUPoint(1, m_ptP4) ;
// se non c'è testo, linea di misura intera
if ( IsEmptyOrSpaces(m_sCalcText)) {
lstPL.emplace_back() ;
lstPL.back().AddUPoint(0, m_ptP5) ;
lstPL.back().AddUPoint(1, m_ptP6) ;
}
// altrimenti, linea di misura divisa in due parti
else {
// prima parte
lstPL.emplace_back() ;
lstPL.back().AddUPoint(0, m_ptP5) ;
lstPL.back().AddUPoint(1, m_ptCalcP7) ;
// seconda parte
lstPL.emplace_back() ;
lstPL.back().AddUPoint(0, m_ptP6) ;
lstPL.back().AddUPoint(1, m_ptCalcP8) ;
}
// frecce
lstPL.emplace_back() ;
GetArrowHead(m_ptP5, ( m_bCalcArrowIn ? -m_vtDir : m_vtDir), lstPL.back()) ;
lstPL.emplace_back() ;
GetArrowHead(m_ptP6, ( m_bCalcArrowIn ? m_vtDir : -m_vtDir), lstPL.back()) ;
// testo
POLYLINELIST lstTxt;
if ( ApproxTextWithLines(dLinTol, dAngTolDeg, lstTxt))
lstPL.splice(lstPL.end(), lstTxt) ;
return true ;
lstPL.back().AddUPoint( 0, m_ptP5) ;
lstPL.back().AddUPoint( 1, m_ptP6) ;
}
case DT_RADIAL :
case DT_DIAMETRAL : {
Vector3d vtRad = m_ptPos - m_ptP5 ;
vtRad.Normalize() ;
// prima linea di riferimento
// altrimenti, linea di misura divisa in due parti
else {
// prima parte
lstPL.emplace_back() ;
lstPL.back().AddUPoint(0, m_ptP1) ;
lstPL.back().AddUPoint(1, m_ptP2) ;
// freccia
lstPL.back().AddUPoint( 0, m_ptP5) ;
lstPL.back().AddUPoint( 1, m_ptCalcP7) ;
// seconda parte
lstPL.emplace_back() ;
GetArrowHead(m_ptP6, ( m_bCalcArrowIn ? vtRad : - vtRad), lstPL.back()) ;
Point3d ptArrowTail ;
if ( ! m_bCalcArrowIn) {
lstPL.emplace_back() ;
ptArrowTail = m_ptP6 + vtRad * m_dArrowLen * 2 ;
lstPL.back().AddUPoint(0, m_ptP6) ;
lstPL.back().AddUPoint(1, ptArrowTail) ;
}
if ( m_nType == DT_DIAMETRAL) {
lstPL.emplace_back() ;
GetArrowHead(m_ptP5, ( m_bCalcArrowIn ? - vtRad : vtRad), lstPL.back()) ;
if ( ! m_bCalcArrowIn) {
lstPL.emplace_back() ;
ptArrowTail = m_ptP5 - vtRad * m_dArrowLen * 2 ;
lstPL.back().AddUPoint(0, m_ptP5) ;
lstPL.back().AddUPoint(1, ptArrowTail) ;
}
}
// testo
POLYLINELIST lstTxt;
if ( ApproxTextWithLines(dLinTol, dAngTolDeg, lstTxt))
lstPL.splice(lstPL.end(), lstTxt) ;
return true ;
lstPL.back().AddUPoint( 0, m_ptP6) ;
lstPL.back().AddUPoint( 1, m_ptCalcP8) ;
}
case DT_ANGULAR : {
// approssimerò l'arco con una polyline
PolyLine plApprox ;
// cerca nel geom kernel delle tolleranze standard
double dLinTol = 0.01 ;
double dAngTolDeg = 0.01 ;
// prima linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP1) ;
lstPL.back().AddUPoint( 1, m_ptP3) ;
// seconda linea di riferimento
// frecce
lstPL.emplace_back() ;
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? -m_vtDir : m_vtDir), lstPL.back()) ;
lstPL.emplace_back() ;
GetArrowHead( m_ptP6, ( m_bCalcArrowIn ? m_vtDir : -m_vtDir), lstPL.back()) ;
// testo
POLYLINELIST lstTxt;
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
lstPL.splice( lstPL.end(), lstTxt) ;
return true ;
}
case DT_RADIAL :
case DT_DIAMETRAL : {
// prima linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP1) ;
lstPL.back().AddUPoint( 1, m_ptP2) ;
// freccia
lstPL.emplace_back() ;
Vector3d vtRad = m_ptPos - m_ptP6 ;
vtRad.Normalize() ;
GetArrowHead( m_ptP2, ( m_bCalcArrowIn ? vtRad : - vtRad), lstPL.back()) ;
if ( ! m_bCalcArrowIn) {
lstPL.emplace_back() ;
Point3d ptArrowTail = m_ptP2 + vtRad * m_dArrowLen * 2 ;
lstPL.back().AddUPoint( 0, m_ptP2) ;
lstPL.back().AddUPoint( 1, m_ptP4) ;
// curva per l'arco
PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
if ( IsNull( pCrvPos))
return false ;
double dHalfDist = GetTextHalfDist( m_ptCalcPos) ;
// se non ho testo
if ( IsEmptyOrSpaces( m_sCalcText)) {
if ( ! pCrvPos->SetC2PN( m_ptP5, m_ptP6, m_ptP5, m_vtN) || ! pCrvPos->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
return false ;
lstPL.emplace_back( plApprox) ;
}
// altrimenti, linea di misura divisa in due parti
else {
// prima parte
if ( ! pCrvPos->SetC2PN( m_ptP5, m_ptP5, m_ptCalcP7, m_vtN) || ! pCrvPos->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
return false ;
lstPL.emplace_back( plApprox) ;
// seconda parte
if ( ! pCrvPos->SetC2PN( m_ptP5, m_ptP6, m_ptCalcP8, m_vtN) || ! pCrvPos->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
return false ;
lstPL.emplace_back( plApprox) ;
}
// frecce
Vector3d vtStartDir ;
Vector3d vtEndDir ;
if ( ! pCrvPos->Set3P( m_ptP6, m_ptPos, m_ptP5, false))
return false ;
pCrvPos->GetStartDir( vtStartDir) ;
pCrvPos->GetEndDir( vtEndDir) ;
//storto la punta delle frecce su una direzione mediata tra l'arco e la perpendicolare al lato
double dFactor = 1 / ( 0.6 * m_vtDir.Len()) ; // questo fattore dipende direttamente dalla distanza di m_ptPos dal centro e smorza lo scostamento
Vector3d vtLine1 = m_ptP1 - m_ptP5 ;
Vector3d vtLine2 = m_ptP2 - m_ptP5 ;
vtLine1.Normalize() ;
vtLine2.Normalize() ;
// se però le frecce sono fuori non le storto e faccio le code dritte anziché curvilinee
lstPL.back().AddUPoint( 1, ptArrowTail) ;
}
if ( m_nType == DT_DIAMETRAL) {
lstPL.emplace_back() ;
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? - vtRad : vtRad), lstPL.back()) ;
if ( ! m_bCalcArrowIn) {
Point3d ptArrowTail1, ptArrowTail2 ;
ptArrowTail1 = m_ptP5 + vtEndDir * m_dArrowLen *2 ;
lstPL.emplace_back() ;
Point3d ptArrowTail = m_ptP5 - vtRad * m_dArrowLen * 2 ;
lstPL.back().AddUPoint( 0, m_ptP5) ;
lstPL.back().AddUPoint( 1, ptArrowTail1) ;
ptArrowTail2 = m_ptP6 - vtStartDir * m_dArrowLen *2 ;
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP6) ;
lstPL.back().AddUPoint( 1, ptArrowTail2) ;
dFactor = 0 ;
lstPL.back().AddUPoint( 1, ptArrowTail) ;
}
lstPL.emplace_back() ;
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? vtEndDir : - vtEndDir) + vtLine1 * dFactor, lstPL.back()) ;
lstPL.emplace_back() ;
GetArrowHead( m_ptP6, ( m_bCalcArrowIn ? - vtStartDir : vtStartDir) + vtLine2 * dFactor, lstPL.back()) ;
// testo
POLYLINELIST lstTxt ;
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
lstPL.splice( lstPL.end(), lstTxt) ;
return true ;
}
default:
// testo
POLYLINELIST lstTxt;
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
lstPL.splice( lstPL.end(), lstTxt) ;
return true ;
}
case DT_ANGULAR : {
// prima linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP1) ;
lstPL.back().AddUPoint( 1, m_ptP3) ;
// seconda linea di riferimento
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP2) ;
lstPL.back().AddUPoint( 1, m_ptP4) ;
// curva per l'arco
PtrOwner<CurveArc> pCrvPos( CreateBasicCurveArc()) ;
if ( IsNull( pCrvPos))
return false ;
// calcolo ptP5_bis
Vector3d vtLine2 = m_ptP2 - m_ptP6 ;
double dLen2 = vtLine2.Len() ;
if ( ! vtLine2.Normalize())
return false ;
Point3d ptP5_bis = m_ptP2 + ( m_vtDir.Len() - dLen2) * vtLine2 ;
// approssimerò l'arco con una polyline
PolyLine plApprox ;
double dLinTol = 0.01 ;
double dAngTolDeg = 0.01 ;
// se non ho testo
if ( IsEmptyOrSpaces( m_sCalcText) || ! m_bCalcTextOn) {
if ( ! pCrvPos->SetC2PN( m_ptP6, ptP5_bis, m_ptP5, m_vtN) || ! pCrvPos->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
return false ;
lstPL.emplace_back( plApprox) ;
}
// altrimenti, linea di misura divisa in due parti
else {
// prima parte
if ( ! pCrvPos->SetC2PN( m_ptP6, m_ptP5, m_ptCalcP7, m_vtN) || ! pCrvPos->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
return false ;
lstPL.emplace_back( plApprox) ;
// seconda parte
if ( ! pCrvPos->SetC2PN( m_ptP6, ptP5_bis, m_ptCalcP8, m_vtN) || ! pCrvPos->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plApprox))
return false ;
lstPL.emplace_back( plApprox) ;
}
// frecce
if ( ! pCrvPos->Set3P( ptP5_bis, m_ptPos, m_ptP5, false))
return false ;
Vector3d vtStartDir ;
Vector3d vtEndDir ;
pCrvPos->GetStartDir( vtStartDir) ;
pCrvPos->GetEndDir( vtEndDir) ;
//storto la punta delle frecce su una direzione mediata tra l'arco e la perpendicolare al lato
double dFactor = 1 / ( 0.6 * m_vtDir.Len()) ;// questo fattore dipende direttamente dalla distanza di m_ptPos dal centro e smorza lo scostamento
// se però le frecce sono fuori non le storto e faccio le code dritte anziché curvilinee
if ( ! m_bCalcArrowIn) {
Point3d ptArrowTail1, ptArrowTail2 ;
ptArrowTail1 = m_ptP5 + vtEndDir * m_dArrowLen *2 ;
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, m_ptP5) ;
lstPL.back().AddUPoint( 1, ptArrowTail1) ;
ptArrowTail2 = ptP5_bis - vtStartDir * m_dArrowLen *2 ;
lstPL.emplace_back() ;
lstPL.back().AddUPoint( 0, ptP5_bis) ;
lstPL.back().AddUPoint( 1, ptArrowTail2) ;
dFactor = 0 ;
}
lstPL.emplace_back() ;
Vector3d vtLine1 = m_ptP1 - m_ptP6 ;
if ( ! vtLine1.Normalize())
return false ;
GetArrowHead( m_ptP5, ( m_bCalcArrowIn ? vtEndDir : - vtEndDir) + vtLine1 * dFactor, lstPL.back()) ;
lstPL.emplace_back() ;
GetArrowHead( ptP5_bis, ( m_bCalcArrowIn ? - vtStartDir : vtStartDir) + vtLine2 * dFactor, lstPL.back()) ;
// testo
POLYLINELIST lstTxt ;
if ( ApproxTextWithLines( dLinTol, dAngTolDeg, lstTxt))
lstPL.splice( lstPL.end(), lstTxt) ;
return true ;
}
default:
return false ;
}
}
//----------------------------------------------------------------------------
@@ -1419,12 +1429,11 @@ ExtDimension::ApproxTextWithLines( double dLinTol, double dAngTolDeg, POLYLINELI
Frame3d frRef ;
if ( ! frRef.Set( m_ptCalcPos, m_vtN))
return false ;
// oriento il testo con il raggio/diametro, ma solo se il testo è dentro la circonferenza
if ( ( m_nType == DT_RADIAL || m_nType == DT_DIAMETRAL) && m_bCalcTextOn) {
double dAngDeg = 0 ;
Vector3d vtRad = m_ptPos - m_ptP5 ;
m_vtDir.GetAngle( vtRad, dAngDeg) ;
if ( ! frRef.Set( m_ptCalcPos, m_vtN, ( dAngDeg > 90 ? - vtRad : vtRad)))
m_vtDir.GetAngle( frRef.VersX(), dAngDeg) ;
if ( ! frRef.Set( m_ptCalcPos, m_vtN, ( dAngDeg > 90 ? - m_vtDir : m_vtDir)))
return false ;
}
+9 -3
View File
@@ -55,6 +55,11 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // IExtDimension
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -66,7 +71,7 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
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& ptP2, const Point3d& ptV, const Point3d& ptPos,
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
{ return m_vtN ; }
@@ -140,7 +145,7 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
Point3d m_ptP3 ; // terzo punto
Point3d m_ptP4 ; // quarto punto
Point3d m_ptP5 ; // quinto punto
Point3d m_ptP6 ; // sesto punto
Point3d m_ptP6 ; // sesto punto; nel caso delle quotature angolari il centro
Point3d m_ptPos ; // posizione ricevuta della quota
std::string m_sText ; // testo della quota
mutable bool m_bToCalc ; // flag dati effettivi da ricalcolare
@@ -157,7 +162,8 @@ class ExtDimension : public IExtDimension, public IGeoObjRW
int m_nDecDigit ; // numero di cifre decimali
std::string m_sFont ; // font del testo
double m_dTextHeight ; // altezza del testo
int m_nTempProp[2] ; // vettore proprietà temporanee
int m_nTempProp[2] ; // vettore propriet temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ;
//-----------------------------------------------------------------------------
+6 -5
View File
@@ -35,10 +35,9 @@ GEOOBJ_REGISTER( EXT_TEXT, NGE_E_TXT, ExtText) ;
//----------------------------------------------------------------------------
ExtText::ExtText( void)
: m_pSTM( nullptr), m_bNoSTM( false), m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(),
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0)
{
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 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}
{
}
//----------------------------------------------------------------------------
@@ -188,6 +187,8 @@ ExtText::CopyFrom( const ExtText& clSrc)
m_nInsPos = clSrc.m_nInsPos ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
return true ;
}
@@ -883,7 +884,7 @@ ExtText::GetAuxSurf( void) const
// per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale
for ( const auto& pSfr : lstSfr) {
// recupero la superficie trimesh
PtrOwner<ISurfTriMesh> pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ;
PtrOwner<SurfTriMesh> pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ;
if ( pStm != nullptr) {
Triangle3d Tria ;
int nT = pStm->GetFirstTriangle( Tria) ;
+7 -1
View File
@@ -55,6 +55,11 @@ class ExtText : public IExtText, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // IExtText
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -144,7 +149,8 @@ class ExtText : public IExtText, public IGeoObjRW
double m_dRatio ; // rapporto tra larghezza e altezza
double m_dAddAdvance ; // avanzamento addizionale tra caratteri
int m_nInsPos ; // posizione del punto di inserimento rispetto al testo
int m_nTempProp[2] ; // vettore proprietà temporanee
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ;
//-----------------------------------------------------------------------------
+22 -40
View File
@@ -16,8 +16,8 @@
#include "FontNfe.h"
#include "FontAux.h"
#include "FontConst.h"
#include "GdbIterator.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
@@ -81,21 +81,19 @@ NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic,
if ( ! m_pGDB->Load( sFont))
return false ;
// recupero i parametri generali del font (devono essere nel gruppo 1)
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
GdbIterator iIter( m_pGDB) ;
if ( ! iIter.GoTo( 1))
return false ;
if ( ! pIter->GoTo( 1))
return false ;
if ( ! pIter->GetInfo( NFE_H, m_dH) ||
! pIter->GetInfo( NFE_HCAP, m_dHCap) ||
! pIter->GetInfo( NFE_HX, m_dHx) ||
! pIter->GetInfo( NFE_ASC, m_dAsc) ||
! pIter->GetInfo( NFE_DESC, m_dDesc) ||
! pIter->GetInfo( NFE_ADV, m_dAdv))
if ( ! iIter.GetInfo( NFE_H, m_dH) ||
! iIter.GetInfo( NFE_HCAP, m_dHCap) ||
! iIter.GetInfo( NFE_HX, m_dHx) ||
! iIter.GetInfo( NFE_ASC, m_dAsc) ||
! iIter.GetInfo( NFE_DESC, m_dDesc) ||
! iIter.GetInfo( NFE_ADV, m_dAdv))
return false ;
if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL)
return false ;
if ( ! pIter->GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
if ( ! iIter.GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ;
// aggiorno la path del font
m_sFont = sFontUp ;
@@ -161,11 +159,6 @@ NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3
if ( m_pGDB == nullptr || m_sFont.empty())
return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
// calcolo i fattori di scala
double dScaY = m_dHeight / m_dHCap ;
double dScaX = dScaY * m_dRatio ;
@@ -229,9 +222,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
GdbIterator iIter( m_pGDB) ;
// calcolo i fattori di scala
double dScaY = m_dHeight / m_dHCap ;
@@ -265,9 +256,9 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
nGroup = NFE_ERR_CHAR ;
// ciclo sulle entità geometriche del carattere
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
while ( bIter) {
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
if ( pCrv != nullptr) {
// copio la curva (trasformando eventuali archi in CurveBezier)
ICurve* pCrvNew = CurveToNoArcsCurve( pCrv) ;
@@ -281,7 +272,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
// inserisco in lista la nuova curva
lstPC.push_back( pCrvNew) ;
}
bIter = pIter->GoToNext() ;
bIter = iIter.GoToNext() ;
}
// recupero lo spostamento per il prossimo carattere
double dAdvance ;
@@ -314,9 +305,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
GdbIterator iIter( m_pGDB) ;
// controllo valore tolleranza lineare
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight)
@@ -354,9 +343,9 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
nGroup = NFE_ERR_CHAR ;
// ciclo sulle entità geometriche del carattere
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
while ( bIter) {
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
if ( pCrv != nullptr) {
// copia temporanea della curva (trasformando eventuali archi in CurveBezier)
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
@@ -371,7 +360,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub
lstPL.emplace_back() ;
pCrvNew->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, lstPL.back()) ;
}
bIter = pIter->GoToNext() ;
bIter = iIter.GoToNext() ;
}
// recupero lo spostamento per il prossimo carattere
double dAdvance ;
@@ -400,9 +389,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
GdbIterator iIter( m_pGDB) ;
// controllo valore tolleranza lineare
if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight)
@@ -440,9 +427,9 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP)
nGroup = NFE_ERR_CHAR ;
// ciclo sulle entità geometriche del carattere
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
bool bIter = iIter.GoToFirstInGroup( nGroup) ;
while ( bIter) {
const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ;
if ( pCrv != nullptr) {
// copia temporanea della curva (trasformando eventuali archi in CurveBezier)
PtrOwner<ICurve> pCrvNew( CurveToNoArcsCurve( pCrv)) ;
@@ -457,7 +444,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl
lstPA.emplace_back() ;
pCrv->ApproxWithArcs( dLinTol, dAngTolDeg, lstPA.back()) ;
}
bIter = pIter->GoToNext() ;
bIter = iIter.GoToNext() ;
}
// recupero lo spostamento per il prossimo carattere
double dAdvance ;
@@ -484,11 +471,6 @@ NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECT
if ( m_pGDB == nullptr || m_sFont.empty())
return false ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
if ( IsNull( pIter))
return false ;
// calcolo i fattori di scala
double dScaY = m_dHeight / m_dHCap ;
double dScaX = dScaY * m_dRatio ;
+11 -14
View File
@@ -16,15 +16,15 @@
#include "FontOs.h"
#include "FontAux.h"
#include "FontConst.h"
#include "CurveLine.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "SurfFlatRegion.h"
#include "GeoConst.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkCurve.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
@@ -298,8 +298,7 @@ OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC))
return false ;
// lo trasformo opportunamente
ICURVEPLIST::iterator iIter ;
for ( iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
for ( auto iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
// trasformazioni
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
(*iIter)->Translate( vtMove) ;
@@ -464,8 +463,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
return false ;
// lo approssimo con segmenti di retta
ICURVEPLIST::iterator iIter ;
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
// trasformazioni
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
(*iIter)->Translate( vtMove) ;
@@ -478,7 +476,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl
if ( vtMove.x > dMaxW)
dMaxW = vtMove.x ;
// ciclo di pulizia
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
delete (*iIter) ;
lstPC.clear() ;
}
@@ -549,8 +547,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
return false ;
// lo approssimo con segmenti di arco e retta
ICURVEPLIST::iterator iIter ;
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
// trasformazioni
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
(*iIter)->Translate( vtMove) ;
@@ -563,7 +560,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double
if ( vtMove.x > dMaxW)
dMaxW = vtMove.x ;
// ciclo di pulizia
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
delete (*iIter) ;
lstPC.clear() ;
}
@@ -730,7 +727,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC
if ( pHeader->dwType == TT_POLYGON_TYPE) {
// creo curva composita
PtrOwner<ICurveComposite> pCCompo( CreateCurveComposite()) ;
PtrOwner<CurveComposite> pCCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCCompo))
return false ;
@@ -823,7 +820,7 @@ OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const
return false ;
// creo retta, la imposto e la inserisco nella curva composita
PtrOwner<ICurveLine> pCLine( CreateCurveLine()) ;
PtrOwner<CurveLine> pCLine( CreateBasicCurveLine()) ;
if ( IsNull( pCLine))
return false ;
if ( ! pCLine->Set( ptStart, ptEnd))
@@ -844,7 +841,7 @@ OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo,
return false ;
// creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita
PtrOwner<ICurveBezier> pCBezier( CreateCurveBezier()) ;
PtrOwner<CurveBezier> pCBezier( CreateBasicCurveBezier()) ;
if ( IsNull( pCBezier))
return false ;
if ( ! pCBezier->Init( 2, false) ||
+56 -106
View File
@@ -1423,8 +1423,7 @@ GdbExecutor::CurveArcChangeRadius( const STRVECTOR& vsParams)
if ( ! GetLengthParam( vsParams[1], dNewRad))
return false ;
// esecuzione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero l'arco
ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCrvArc == nullptr)
@@ -1452,8 +1451,7 @@ GdbExecutor::CurveArcChangeDeltaN( const STRVECTOR& vsParams)
if ( ! GetLengthParam( vsParams[1], dNewDeltaN))
return false ;
// esecuzione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero l'arco
ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCrvArc == nullptr)
@@ -1686,8 +1684,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams)
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest))
return false ;
// esecuzione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero la curva
int nIdCrv = *Iter ;
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))) {
// se richiesto, cancello le curve originali
if ( bErase) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->Erase( *Iter))
return false ;
}
@@ -2309,8 +2306,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams)
if ( ! StmFts.Start())
return false ;
// Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero la superficie sorgente
const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
if ( pStmS == nullptr)
@@ -2340,7 +2336,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams)
if ( AddGeoObj( vsParams[0], vsParams[1], pSTM)) {
// se richiesto, cancello le curve originali
if ( bErase) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->Erase( *Iter))
return false ;
}
@@ -2534,8 +2530,7 @@ GdbExecutor::SurfTriMeshDoCompacting( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// opero sui diversi oggetti
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero la superficie
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
if ( pStm == nullptr)
@@ -2572,8 +2567,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[1], vnNames))
return false ;
// esecuzione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero la superficie da cucire
const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ;
if ( pStmS == nullptr)
@@ -2590,7 +2584,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
}
// se richiesto, cancello le superfici cucite alla prima
if ( bErase) {
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter)
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter)
m_pGDB->Erase( *Iter) ;
}
return true ;
@@ -3079,7 +3073,7 @@ GdbExecutor::VolZmapBBoxZmapIntersection( const STRVECTOR& vsParams)
return false ;
bool bInt ;
bInt = ! pZmap->AvoidBox( frBBoxFrame, ptEnd - ORIG) ;
bInt = pZmap->CDeBox( frBBoxFrame, ptEnd - ORIG) ;
return true ;
}*/
@@ -5432,8 +5426,7 @@ GdbExecutor::TextOutline( const STRVECTOR& vsParams)
pTXT->GetOutline( lstPCRV) ;
// inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento
bool bOk = true ;
ICURVEPLIST::iterator iIter ;
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
for ( auto iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
(*iIter)->LocToLoc( frTXT, frDest) ;
if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) {
delete (*iIter) ;
@@ -5510,8 +5503,7 @@ GdbExecutor::GetNamesParam( const string& sParam, INTVECTOR& vnNames)
// converto in interi
vnNames.clear() ;
vnNames.reserve( vsNames.size()) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
for ( auto Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
Trim( (*Iter), " \t\r\n()") ;
int nId = GetIdParam( *Iter) ;
if ( nId != GDB_ID_SEL) {
@@ -5538,8 +5530,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
// divido in parti
STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// se 2 parti, allora Z = 0
if ( vsParams.size() == 2) {
@@ -5594,8 +5585,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ;
// ci deve essere almeno un parametro
if ( vsParams.size() < 1)
@@ -5747,8 +5737,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
// divido in parti
STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// se 2 parti, allora Z = 0
if ( vsParams.size() == 2) {
@@ -5778,8 +5767,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ;
// ci deve essere almeno un parametro
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) ;
// converto in punti
PL.Clear() ;
STRVECTOR::iterator Iter ;
for ( Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
for ( auto Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) {
Trim( (*Iter), " \t\r\n") ;
if ( GetIdParam( *Iter) == GDB_ID_SEL) {
int nId = m_pGDB->GetFirstSelectedObj() ;
@@ -5997,8 +5984,7 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d
// divido in parti
STRVECTOR vsParams ;
Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ;
// 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) ;
// converto in punti
PA.Clear() ;
STRVECTOR::iterator Iter ;
for ( Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
for ( auto Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) {
Trim( (*Iter), " \t\r\n") ;
Point3d ptP ;
double dBulge ;
@@ -6059,8 +6044,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// ci deve essere almeno un parametro
if ( vsParams.size() < 1)
@@ -6082,8 +6066,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen)
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// ci deve essere almeno un parametro
if ( vsParams.size() < 1)
@@ -6118,8 +6101,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ;
// ci deve essere almeno un parametro
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
STRVECTOR vsParams ;
Tokenize( sTmp, ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ;
// verifico siano 4 parti e le converto
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
STRVECTOR vsParams ;
Tokenize( sTmp, ",", "(", ")", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n") ;
// se c'è un parametro è l'origine
Point3d ptOrig ;
@@ -6358,8 +6338,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
// divido in parti
STRVECTOR vsParams ;
Tokenize( sParam, ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// devono essere 3 o 4 parametri ( Red, Green, Blue [, Alpha])
if ( vsParams.size() != 3 && vsParams.size() != 4)
@@ -6387,8 +6366,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// ci deve essere un parametro
if ( vsParams.size() != 1)
@@ -6421,8 +6399,7 @@ GdbExecutor::GetMaterialParam( const string& sParam, bool& bByParent, int& nMat)
// recupero i parametri associati
STRVECTOR vsParams ;
Tokenize( sParam.substr( 1), ",", vsParams) ;
STRVECTOR::iterator Iter ;
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
Trim( (*Iter), " \t\r\n()") ;
// ci deve essere un parametro
if ( vsParams.size() != 1)
@@ -6479,8 +6456,7 @@ GdbExecutor::ExecuteLevel( const string& sCmd2, const STRVECTOR& vsParams)
else
return false ;
// esecuzione impostazione livello
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SetLevel( *Iter, nLevel))
return false ;
}
@@ -6511,8 +6487,7 @@ GdbExecutor::ExecuteMode( const string& sCmd2, const STRVECTOR& vsParams)
else
return false ;
// esecuzione impostazione modo
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SetMode( *Iter, nMode))
return false ;
}
@@ -6543,8 +6518,7 @@ GdbExecutor::ExecuteStatus( const string& sCmd2, const STRVECTOR& vsParams)
else
return false ;
// esecuzione impostazione stato
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SetStatus( *Iter, nStat))
return false ;
}
@@ -6565,8 +6539,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione selezione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SelectObj( *Iter))
return false ;
}
@@ -6610,8 +6583,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams)
nFilter = EXT_TEXT ;
}
// esecuzione selezione di tutti gli oggetti di ogni gruppo
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SelectGroupObjs( *Iter, nFilter))
return false ;
}
@@ -6635,8 +6607,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione deselezione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->DeselectObj( *Iter))
return false ;
}
@@ -6652,8 +6623,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione deselezione di tutti gli oggetti di ogni gruppo
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->DeselectGroupObjs( *Iter))
return false ;
}
@@ -6710,8 +6680,7 @@ GdbExecutor::MaterialColor( const STRVECTOR& vsParams)
if ( ! GetColorParam( vsParams[1], bByParent, cCol))
return false ;
// esecuzione impostazione colore
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( bByParent) {
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
return false ;
@@ -6741,8 +6710,7 @@ GdbExecutor::MaterialMaterial( const STRVECTOR& vsParams)
if ( ! GetMaterialParam( vsParams[1], bByParent, nMat))
return false ;
// esecuzione impostazione colore
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( bByParent) {
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
return false ;
@@ -6789,8 +6757,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetStringParam( vsParams[1], sName))
return false ;
// eseguo assegnazione nome
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SetName( *Iter, sName))
return false ;
}
@@ -6806,8 +6773,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// eseguo rimozione nome
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->RemoveName( *Iter))
return false ;
}
@@ -6839,8 +6805,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetStringParam( vsParams[2], sInfo))
return false ;
// eseguo assegnazione Info di data Key
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->SetInfo( *Iter, sKey, sInfo))
return false ;
}
@@ -6860,8 +6825,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetStringParam( vsParams[1], sKey))
return false ;
// eseguo rimozione nome Info di data Key
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->RemoveInfo( *Iter, sKey))
return false ;
}
@@ -7010,8 +6974,7 @@ GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams)
// recupero flag per globale
bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ;
// esecuzione rilocazioni
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( bGlob) {
if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter))
return false ;
@@ -7036,8 +6999,7 @@ GdbExecutor::ExecuteErase( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione cancellazioni
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
if ( ! m_pGDB->Erase( *Iter))
return false ;
}
@@ -7079,8 +7041,7 @@ GdbExecutor::ExecuteTranslate( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetVectorParam( vsParams[1], frRef, vtVN))
return false ;
// esecuzione traslazioni
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
switch ( nTraType) {
case TRA_LOC :
if ( ! m_pGDB->Translate( *Iter, vtVN))
@@ -7144,8 +7105,7 @@ GdbExecutor::ExecuteRotate( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! FromString( vsParams[3], dAngDeg))
return false ;
// esecuzione rotazioni
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
switch ( nRotType) {
case ROT_LOC :
if ( ! m_pGDB->Rotate( *Iter, ptPC, vtVN, dAngDeg))
@@ -7214,8 +7174,7 @@ GdbExecutor::ExecuteScale( const string& sCmd2, const STRVECTOR& vsParams)
! FromString( vsParams[4], dCoeffZ))
return false ;
// esecuzione scalature
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
switch ( nScaType) {
case SCA_LOC :
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))
return false ;
// esecuzione specchiature
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
switch ( nMirType) {
case MIR_LOC :
if ( ! m_pGDB->Mirror( *Iter, ptPC, vtVN))
@@ -7340,8 +7298,7 @@ GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! FromString( vsParams[4], dCoeff))
return false ;
// esecuzione scorrimenti
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
switch ( nMirType) {
case MIR_LOC :
if ( ! m_pGDB->Shear( *Iter, ptPC, vtNorm, vtDir, dCoeff))
@@ -7400,8 +7357,7 @@ GdbExecutor::CurveModifyInvert( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione inversione curve
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
ICurve* pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCurve == nullptr || ! pCurve->Invert())
return false ;
@@ -7518,8 +7474,7 @@ GdbExecutor::CurveModifyTrim( const STRVECTOR& vsParams, int nTrimType)
if ( ! FromString( vsParams[1], dPar))
return false ;
// esecuzione trim
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
ICurve* pCurve ;
if ( ( pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter))) != nullptr) {
switch ( nTrimType) {
@@ -7718,8 +7673,7 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
// preparo i dati per il concatenamento
ChainCurves chainC ;
chainC.Init( bAllowInvert, dToler, int( vnNames.size())) ;
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
if ( pCrv == nullptr)
@@ -7748,10 +7702,9 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams)
if ( IsNull( pCrvCompo))
return false ;
// recupero le curve semplici e le inserisco nella curva composita
INTVECTOR::iterator Iter2 ;
for ( Iter2 = vIds.begin() ; Iter2 != vIds.end() ; ++Iter2) {
int nId = abs( *Iter2) ;
bool bInvert = ( *Iter2 < 0) ;
for ( auto Iter = vIds.cbegin() ; Iter != vIds.cend() ; ++Iter) {
int nId = abs( *Iter) ;
bool bInvert = ( *Iter < 0) ;
// recupero la curva e il suo riferimento
ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
@@ -7806,8 +7759,7 @@ GdbExecutor::SurfModifyInvert( const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione inversione normale superficie
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
ISurf* pSurf = GetSurf( m_pGDB->GetGeoObj( *Iter)) ;
if ( pSurf == nullptr || ! pSurf->Invert())
return false ;
@@ -8049,8 +8001,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero l'oggetto ed eseguo l'output
if ( ! OutGroupTsc( *Iter, nFlag))
return false ;
@@ -8073,8 +8024,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams)
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// esecuzione
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) {
// recupero l'oggetto ed eseguo l'output
if ( ! m_OutTsc.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag))
return false ;
+1 -1
View File
@@ -44,7 +44,7 @@ GdbGroup::~GdbGroup( void)
// nel sorgente aggiorno lista dei riferimenti
INTVECTOR vnList ;
pGdbObj->GetInfo( GDB_SI_LIST, vnList) ;
INTVECTOR::const_iterator iFind = find( vnList.begin(), vnList.end(), m_nId) ;
const auto iFind = find( vnList.begin(), vnList.end(), m_nId) ;
if ( iFind != vnList.end())
vnList.erase( iFind) ;
if ( vnList.empty())
+2 -1
View File
@@ -1468,7 +1468,8 @@ GdbIterator::SetInfo( const string& sKey, int nInfo)
bool
GdbIterator::SetInfo( const string& sKey, double dInfo)
{
return SetInfo( sKey, ToString( dInfo)) ;
int nErr ;
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
}
//----------------------------------------------------------------------------
+2 -1
View File
@@ -862,7 +862,8 @@ GdbObj::SetInfo( const string& sKey, int nInfo)
bool
GdbObj::SetInfo( const string& sKey, double dInfo)
{
return SetInfo( sKey, ToString( dInfo)) ;
int nErr ;
return ( SetInfo( sKey, ToString( dInfo, 6, &nErr)) && nErr == 0) ;
}
//----------------------------------------------------------------------------
+3 -3
View File
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_FRAME3D, NGE_G_FRM, GeoFrame3d) ;
//----------------------------------------------------------------------------
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 ;
}
//----------------------------------------------------------------------------
@@ -118,6 +116,8 @@ GeoFrame3d::CopyFrom( const GeoFrame3d& gfSrc)
return true ;
m_nTempProp[0] = gfSrc.m_nTempProp[0] ;
m_nTempProp[1] = gfSrc.m_nTempProp[1] ;
m_dTempParam[0] = gfSrc.m_dTempParam[0] ;
m_dTempParam[1] = gfSrc.m_dTempParam[1] ;
return Set( gfSrc.m_frF) ;
}
+6
View File
@@ -62,6 +62,11 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // IGeoFrame3d
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -97,6 +102,7 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Frame3d m_frF ; // oggetto
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ;
//-----------------------------------------------------------------------------
+3 -3
View File
@@ -28,10 +28,8 @@ GEOOBJ_REGISTER( GEO_PNT3D, NGE_G_PNT, GeoPoint3d) ;
//----------------------------------------------------------------------------
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 ;
}
//----------------------------------------------------------------------------
@@ -86,6 +84,8 @@ GeoPoint3d::CopyFrom( const GeoPoint3d& clSrc)
return true ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
return Set( clSrc.m_ptP) ;
}
+6
View File
@@ -62,6 +62,11 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // IGeoPoint3d
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -91,6 +96,7 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
Point3d m_ptP ; // oggetto
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ;
//-----------------------------------------------------------------------------
+3 -3
View File
@@ -29,10 +29,8 @@ GEOOBJ_REGISTER( GEO_VECT3D, NGE_G_VEC, GeoVector3d) ;
//----------------------------------------------------------------------------
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 ;
}
//----------------------------------------------------------------------------
@@ -102,6 +100,8 @@ GeoVector3d::CopyFrom( const GeoVector3d& clSrc)
return true ;
m_nTempProp[0] = clSrc.m_nTempProp[0] ;
m_nTempProp[1] = clSrc.m_nTempProp[1] ;
m_dTempParam[0] = clSrc.m_dTempParam[0] ;
m_dTempParam[1] = clSrc.m_dTempParam[1] ;
return Set( clSrc.m_vtV, clSrc.m_ptBase) ;
}
+6
View File
@@ -70,6 +70,11 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd = 0) const override
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
void SetTempParam( double dParam, int nParamInd = 0) override
{ if ( nParamInd >= 0 && nParamInd < 2)
m_dTempParam[nParamInd] = dParam ; }
double GetTempParam( int nParamInd = 0) const override
{ return (( nParamInd >= 0 && nParamInd < 2) ? m_dTempParam[nParamInd] : 0.0) ; }
public : // IGeoVector3d
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
@@ -106,6 +111,7 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
Vector3d m_vtV ; // oggetto
Point3d m_ptBase ; // punto base da cui tracciare il vettore
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ;
//-----------------------------------------------------------------------------
+2 -1
View File
@@ -2785,7 +2785,8 @@ GeomDB::SetInfo( int nId, const string& sKey, int nInfo)
bool
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) ;
}
//----------------------------------------------------------------------------
+223
View File
@@ -0,0 +1,223 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : IntersCurveSurfTm.cpp Data : 23.02.24 Versione : 2.6b4
// Contenuto : Implementazione della intersezione curva/superficie trimesh.
//
//
//
// Modifiche : 23.02.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GeoConst.h"
#include "/EgtDev/Include/EGkIntersLineTria.h"
#include "/EgtDev/Include/EGkIntersCurveSurfTm.h"
using namespace std ;
//----------------------------------------------------------------------------
static void
UpdateInfoIntersCurveSurfTm( const Point3d& ptL, const Vector3d& vtDir, double dLen, double dUs, double dUe,
int nT, const Triangle3d& Tria, ICSIVECTOR& vInfo)
{
Point3d ptInt, ptInt2 ;
int nRes = IntersLineTria( ptL, vtDir, dLen, Tria, ptInt, ptInt2, true) ;
if ( nRes == ILTT_IN || nRes == ILTT_EDGE || nRes == ILTT_VERT) {
double dU = dUs + ( ptInt - ptL) * vtDir / dLen * ( dUe - dUs) ;
double dCosDN = vtDir * Tria.GetN() ;
vInfo.emplace_back( nRes, dU, nT, dCosDN, ptInt) ;
}
else if ( nRes == ILTT_SEGM || nRes == ILTT_SEGM_ON_EDGE) {
double dU = dUs + ( ptInt - ptL) * vtDir / dLen * ( dUe - dUs) ;
double dU2 = dUs + ( ptInt2 - ptL) * vtDir / dLen * ( dUe - dUs) ;
double dCosDN = vtDir * Tria.GetN() ;
vInfo.emplace_back( nRes, dU, dU2, nT, dCosDN, ptInt, ptInt2) ;
}
}
//----------------------------------------------------------------------------
static void
OrderInfoIntersCurveSurfTm( ICSIVECTOR& vInfo)
{
// se non trovati, esco
if ( vInfo.size() == 0)
return ;
// ordino il vettore delle intersezioni secondo il senso crescente del parametro di linea
sort( vInfo.begin(), vInfo.end(),
[]( const IntCrvStmInfo& a, const IntCrvStmInfo& b)
{ double dUa = ( ( a.nILTT == ILTT_SEGM || a.nILTT == ILTT_SEGM_ON_EDGE) ? ( a.dU + a.dU2) / 2 : a.dU) ;
double dUb = ( ( b.nILTT == ILTT_SEGM || b.nILTT == ILTT_SEGM_ON_EDGE) ? ( b.dU + b.dU2) / 2 : b.dU) ;
return ( dUa < dUb) ; }) ;
}
//----------------------------------------------------------------------------
// Intersezione di una curva con una superficie TriMesh
//----------------------------------------------------------------------------
bool
IntersCurveSurfTm( const ICurve& Curve, const ISurfTriMesh& Stm, double dLinTol, ICSIVECTOR& vInfo)
{
// verifico i parametri ricevuti
if ( & Curve == nullptr || &Stm == nullptr || &vInfo == nullptr)
return false ;
dLinTol = max( dLinTol, EPS_SMALL) ;
vInfo.clear() ;
// approssimo la curva con una spezzata
PolyLine PL ;
if ( ! Curve.ApproxWithLines( dLinTol, ANG_TOL_APPROX_DEG, ICurve::APL_SPECIAL, PL))
return false ;
// per ogni segmento dell'approssimante cerco l'intersezione con la superficie
double dParS, dParE ;
Point3d ptStart, ptEnd ;
bool bFound = PL.GetFirstULine( &dParS, &ptStart, &dParE, &ptEnd) ;
while ( bFound) {
Vector3d vtDir = ptEnd - ptStart ;
double dLen = vtDir.Len() ;
if ( dLen > EPS_SMALL) {
vtDir /= dLen ;
// cerco i triangoli intersecati dal segmento
const double BOX_STEP = 10 ;
int nStep = int( ceil( dLen / BOX_STEP)) ;
Vector3d vtStep = dLen / nStep * vtDir ;
INTVECTOR vPrevT ;
for ( int i = 0 ; i < nStep ; ++ i) {
BBox3d b3Box( ptStart + i * vtStep, ptStart + ( i + 1) * vtStep) ;
INTVECTOR vT ;
if ( Stm.GetAllTriaOverlapBox( b3Box, vT)) {
for ( auto nT : vT) {
// se triangolo non ancora intersecato
if ( find( vPrevT.begin(), vPrevT.end(), nT) == vPrevT.end()) {
vPrevT.emplace_back( nT) ;
Triangle3d Tria ;
Stm.GetTriangle( nT, Tria) ;
// aggiorno info con intersezione
UpdateInfoIntersCurveSurfTm( ptStart, vtDir, dLen, dParS, dParE, nT, Tria, vInfo) ;
}
}
}
}
}
// passo al segmento successivo
bFound = PL.GetNextULine( &dParS, &ptStart, &dParE, &ptEnd) ;
}
// ordino il vettore delle eventuali intersezioni secondo il senso crescente del parametro di linea
OrderInfoIntersCurveSurfTm( vInfo) ;
return true ;
}
//----------------------------------------------------------------------------
bool
IntersCurveSurfTmExt( const ICurve& Curve, const ISurfTriMesh& Stm, double dLinTol, INTDBLVECTOR& vInters)
{
ICSIVECTOR vInfo ;
vInters.clear() ;
return ( IntersCurveSurfTm( Curve, Stm, dLinTol, vInfo) && FilterCurveSurfTmInters( Curve, vInfo, vInters)) ;
}
//----------------------------------------------------------------------------
bool
FilterCurveSurfTmInters( const ICurve& Curve, const ICSIVECTOR& vInfo, INTDBLVECTOR& vInters)
{
// verifico i parametri ricevuti
if ( & Curve == nullptr || &vInfo == nullptr || &vInters == nullptr)
return false ;
vInters.clear() ;
// info sulla curva
bool bClosedCrv = Curve.IsClosed() ;
double dParSCrv, dParECrv ;
Curve.GetDomain( dParSCrv, dParECrv) ;
// ciclo sulle intersezioni
for ( const auto& Info : vInfo) {
// se intersezione puntuale
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
int nFlag = CSIT_NONE ;
if ( Info.dCosDN > EPS_ZERO)
nFlag = CSIT_IN_OUT ;
else if ( Info.dCosDN < -EPS_ZERO)
nFlag = CSIT_OUT_IN ;
vInters.emplace_back( nFlag, Info.dU) ;
}
// se altrimenti intersezione con coincidenza
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
vInters.emplace_back( CSIT_IN_ON, Info.dU) ;
vInters.emplace_back( CSIT_ON_IN, Info.dU2) ;
}
}
// elimino intersezioni ripetute
int nStart = ( bClosedCrv ? 0 : 1) ;
for ( int j = nStart ; j < int( vInters.size()) ; ) {
// intersezione precedente
int i = ( j > 0 ? j - 1 : int( vInters.size()) - 1) ;
// se hanno lo stesso parametro
if ( abs( vInters[i].second - vInters[j].second) < EPS_PARAM ||
( bClosedCrv && abs( vInters[i].second - dParECrv) < EPS_PARAM && abs( vInters[j].second - dParSCrv) < EPS_PARAM)) {
// flag per eseguita cancellazione
bool bSomeErased = false ;
// se sono entrambe entranti o uscenti, elimino la seconda
if ( ( vInters[i].first == CSIT_OUT_IN && vInters[j].first == CSIT_OUT_IN) ||
( vInters[i].first == CSIT_IN_OUT && vInters[j].first == CSIT_IN_OUT)) {
vInters.erase( vInters.begin() + j) ;
bSomeErased = true ;
}
// se una entrante e l'altra uscente, cambio in touch da fuori ed elimino la seconda
else if ( vInters[i].first == CSIT_OUT_IN && vInters[j].first == CSIT_IN_OUT) {
vInters[i].first = CSIT_OUT_OUT ;
vInters.erase( vInters.begin() + j) ;
bSomeErased = true ;
}
// se una uscente e l'altra entrante, cambio in touch da dentro ed elimino la seconda
else if ( vInters[i].first == CSIT_IN_OUT && vInters[j].first == CSIT_OUT_IN) {
vInters[i].first = CSIT_IN_IN ;
vInters.erase( vInters.begin() + j) ;
bSomeErased = true ;
}
// se una touch da fuori o da dentro e l'altra entrante o uscente, elimino la prima
else if ( ( vInters[i].first == CSIT_OUT_OUT || vInters[i].first == CSIT_IN_IN) &&
( vInters[j].first == CSIT_OUT_IN || vInters[j].first == CSIT_IN_OUT)) {
vInters.erase( vInters.begin() + i) ;
bSomeErased = true ;
}
// se una entrante o uscente e l'altra touch da fuori o da dentro, elimino la seconda
else if ( ( vInters[i].first == CSIT_OUT_IN || vInters[i].first == CSIT_IN_OUT) &&
( vInters[j].first == CSIT_OUT_OUT || vInters[j].first == CSIT_IN_IN)) {
vInters.erase( vInters.begin() + j) ;
bSomeErased = true ;
}
// se una puntuale e l'altra inizio di coincidenza, elimino la prima
else if ( ( vInters[i].first == CSIT_OUT_IN || vInters[i].first == CSIT_IN_OUT || vInters[i].first == CSIT_NONE) &&
( vInters[j].first == CSIT_IN_ON || vInters[j].first == CSIT_OUT_ON)) {
vInters[j].first = ( vInters[i].first == CSIT_IN_OUT ? CSIT_IN_ON : CSIT_OUT_ON) ;
vInters.erase( vInters.begin() + i) ;
bSomeErased = true ;
}
// se una fine di coincidenza e l'altra puntuale, elimino la seconda
else if ( ( vInters[i].first == CSIT_ON_IN || vInters[i].first == CSIT_ON_OUT) &&
( vInters[j].first == CSIT_OUT_IN || vInters[j].first == CSIT_IN_OUT || vInters[j].first == CSIT_NONE)) {
vInters[i].first = ( vInters[j].first == CSIT_IN_OUT ? CSIT_ON_OUT : CSIT_ON_IN) ;
vInters.erase( vInters.begin() + j) ;
bSomeErased = true ;
}
// se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe
else if ( ( vInters[i].first == CSIT_ON_IN || vInters[i].first == CSIT_ON_OUT) &&
( vInters[j].first == CSIT_IN_ON || vInters[j].first == CSIT_OUT_ON)) {
vInters.erase( vInters.begin() + j) ;
vInters.erase( vInters.begin() + ( j > 0 ? i : i - 1)) ;
bSomeErased = true ;
}
if ( bSomeErased) {
if ( j > 0)
-- j ;
continue ;
}
}
// passo alla successiva
++ j ;
}
return true ;
}
+1 -1
View File
@@ -22,7 +22,7 @@ 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.
// In caso di intersezione viene restituito true e i parametri lunghezza in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineBox( const Point3d& ptL, const Vector3d& vtL,
+1 -1
View File
@@ -17,7 +17,7 @@
//----------------------------------------------------------------------------
// Linea e box allineato agli assi sono nel medesimo riferimento.
// Con intersezione viene restituito true e i parametri in dU1 e dU2.
// Con intersezione viene restituito true e i parametri lunghezza in dU1 e dU2.
//----------------------------------------------------------------------------
bool
IntersLineBox( const Point3d& ptL, const Vector3d& vtL,
+73 -8
View File
@@ -21,7 +21,7 @@
using namespace std ;
//----------------------------------------------------------------------------
void
static void
UpdateInfoIntersLineSurfTm( const Point3d& ptL, const Vector3d& vtDir, double dLen,
int nT, const Triangle3d& Tria, ILSIVECTOR& vInfo, bool bFinite)
{
@@ -41,7 +41,7 @@ UpdateInfoIntersLineSurfTm( const Point3d& ptL, const Vector3d& vtDir, double dL
}
//----------------------------------------------------------------------------
void
static void
OrderInfoIntersLineSurfTm( ILSIVECTOR& vInfo)
{
// se non trovati, esco
@@ -81,7 +81,7 @@ IntersLineSurfTm( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
// lo ingrandisco per non avere problemi con faccia piana su piani canonici
b3Stm.Expand( 10 * EPS_SMALL) ;
double dU1, dU2 ;
if ( ! IntersLineBox( ptL, vtL, b3Stm.GetMin() , b3Stm.GetMax(), dU1, dU2))
if ( ! IntersLineBox( ptL, vtDir, b3Stm.GetMin() , b3Stm.GetMax(), dU1, dU2))
return true ;
if ( bFinite) {
dU1 = max( dU1, 0.) ;
@@ -89,12 +89,12 @@ IntersLineSurfTm( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
if ( dU2 - dU1 < EPS_SMALL)
return true ;
}
Point3d ptStart = ptL + dU1 * vtL ;
Point3d ptStart = ptL + dU1 * vtDir ;
double dLenEff = dU2 - dU1 ;
// cerco i triangoli intersecati dalla linea
const double BOX_STEP = 10 ;
int nStep = int( ceil( dLenEff / BOX_STEP)) ;
Vector3d vtStep = dLenEff / nStep * vtL ;
Vector3d vtStep = dLenEff / nStep * vtDir ;
INTVECTOR vPrevT ;
for ( int i = 0 ; i < nStep ; ++ i) {
BBox3d b3Box( ptStart + i * vtStep, ptStart + ( i + 1) * vtStep) ;
@@ -156,13 +156,13 @@ IntersParLinesSurfTm::IntersParLinesSurfTm( const Frame3d& frLines, const ISurfT
bool
IntersParLinesSurfTm::GetInters( const Point3d& ptL, double dLen, ILSIVECTOR& vInfo, bool bFinite) const
{
// verifico validità
if ( ! m_bOk)
return false ;
// verifico parametro di ritorno
if ( &vInfo == nullptr)
return false ;
vInfo.clear() ;
// verifico validità
if ( ! m_bOk)
return false ;
// calcolo box linea (nel riferimento)
BBox3d b3Line ;
@@ -189,3 +189,68 @@ IntersParLinesSurfTm::GetInters( const Point3d& ptL, double dLen, ILSIVECTOR& vI
return true ;
}
//----------------------------------------------------------------------------
bool
FilterLineSurfTmInters( const ILSIVECTOR& vInfo, INTDBLVECTOR& vInters)
{
// ciclo sulle intersezioni
for ( const auto& Info : vInfo) {
// se intersezione puntuale
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
int nFlag = LST_TOUCH ;
if ( Info.dCosDN > EPS_ZERO)
nFlag = LST_OUT ;
else if ( Info.dCosDN < -EPS_ZERO)
nFlag = LST_IN ;
vInters.emplace_back( nFlag, Info.dU) ;
}
// se altrimenti intersezione con coincidenza
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
vInters.emplace_back( LST_TG_INI, Info.dU) ;
vInters.emplace_back( LST_TG_FIN, Info.dU2) ;
}
}
// elimino intersezioni ripetute
for ( size_t j = 1 ; j < vInters.size() ; ) {
// intersezione precedente
size_t i = j - 1 ;
// se hanno lo stesso parametro
if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) {
// se sono entrambe entranti o uscenti, elimino la seconda
if ( ( vInters[i].first == LST_IN && vInters[j].first == LST_IN) ||
( vInters[i].first == LST_OUT && vInters[j].first == LST_OUT)) {
vInters.erase( vInters.begin() + j) ;
continue ;
}
// se una entrante e l'altra uscente, cambio in touch ed elimino la seconda
else if ( ( vInters[i].first == LST_IN && vInters[j].first == LST_OUT) ||
( vInters[i].first == LST_OUT && vInters[j].first == LST_IN)) {
vInters[i].first = LST_TOUCH ;
vInters.erase( vInters.begin() + j) ;
continue ;
}
// se una puntuale e l'altra inizio di coincidenza, elimino la prima
else if ( ( vInters[i].first == LST_IN || vInters[i].first == LST_OUT || vInters[i].first == LST_TOUCH) && vInters[j].first == LST_TG_INI) {
vInters.erase( vInters.begin() + i) ;
continue ;
}
// se una fine di coincidenza e l'altra puntuale, elimino la seconda
else if ( vInters[i].first == LST_TG_FIN && ( vInters[j].first == LST_IN || vInters[j].first == LST_OUT || vInters[j].first == LST_TOUCH)) {
vInters.erase( vInters.begin() + j) ;
continue ;
}
// se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe
else if ( i > 0 && vInters[i].first == LST_TG_FIN && vInters[j].first == LST_TG_INI) {
vInters.erase( vInters.begin() + j) ;
vInters.erase( vInters.begin() + i) ;
-- j ;
continue ;
}
}
// passo alla successiva
++ j ;
}
return true ;
}
+106
View File
@@ -0,0 +1,106 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : IntersLineVolZmap.cpp Data : 22.02.24 Versione : 2.6b4
// Contenuto : Implementazione della intersezione linea/VolZmap.
//
//
//
// Modifiche : 22.02.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "VolZmap.h"
#include "/EgtDev/Include/EGkIntersLineVolZmap.h"
using namespace std ;
//----------------------------------------------------------------------------
// Intersezione di una linea con la superficie di un solido VolZmap
//----------------------------------------------------------------------------
bool
IntersLineVolZmap( const Point3d& ptL, const Vector3d& vtL, const IVolZmap& Vzm, ILZIVECTOR& vInfo)
{
// verifico linea
Vector3d vtDir = vtL ;
if ( ! vtDir.Normalize( EPS_ZERO))
return false ;
// verifico volume
const VolZmap* pVzm = GetBasicVolZmap( &Vzm) ;
if ( pVzm == nullptr)
return false ;
// verifico parametro di ritorno
if ( &vInfo == nullptr)
return false ;
// eseguo intersezione
return pVzm->GetLineIntersection( ptL, vtL, vInfo) ;
}
//----------------------------------------------------------------------------
bool
FilterLineVolZmapInters( const ILZIVECTOR& vInfo, INTDBLVECTOR& vInters)
{
// ciclo sulle intersezioni
for ( const auto& Info : vInfo) {
// se intersezione puntuale
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
int nFlag = LZT_TOUCH ;
if ( Info.dCosDN > EPS_ZERO)
nFlag = LZT_OUT ;
else if ( Info.dCosDN < -EPS_ZERO)
nFlag = LZT_IN ;
vInters.emplace_back( nFlag, Info.dU) ;
}
// se altrimenti intersezione con coincidenza
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
vInters.emplace_back( LZT_TG_INI, Info.dU) ;
vInters.emplace_back( LZT_TG_FIN, Info.dU2) ;
}
}
// elimino intersezioni ripetute
for ( size_t j = 1 ; j < vInters.size() ; ) {
// intersezione precedente
size_t i = j - 1 ;
// se hanno lo stesso parametro
if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) {
// se sono entrambe entranti o uscenti, elimino la seconda
if ( ( vInters[i].first == LZT_IN && vInters[j].first == LZT_IN) ||
( vInters[i].first == LZT_OUT && vInters[j].first == LZT_OUT)) {
vInters.erase( vInters.begin() + j) ;
continue ;
}
// se una entrante e l'altra uscente, cambio in touch ed elimino la seconda
else if ( ( vInters[i].first == LZT_IN && vInters[j].first == LZT_OUT) ||
( vInters[i].first == LZT_OUT && vInters[j].first == LZT_IN)) {
vInters[i].first = LZT_TOUCH ;
vInters.erase( vInters.begin() + j) ;
continue ;
}
// se una puntuale e l'altra inizio di coincidenza, elimino la prima
else if ( ( vInters[i].first == LZT_IN || vInters[i].first == LZT_OUT || vInters[i].first == LZT_TOUCH) && vInters[j].first == LZT_TG_INI) {
vInters.erase( vInters.begin() + i) ;
continue ;
}
// se una fine di coincidenza e l'altra puntuale, elimino la seconda
else if ( vInters[i].first == LZT_TG_FIN && ( vInters[j].first == LZT_IN || vInters[j].first == LZT_OUT || vInters[j].first == LZT_TOUCH)) {
vInters.erase( vInters.begin() + j) ;
continue ;
}
// se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe
else if ( i > 0 && vInters[i].first == LZT_TG_FIN && vInters[j].first == LZT_TG_INI) {
vInters.erase( vInters.begin() + j) ;
vInters.erase( vInters.begin() + i) ;
-- j ;
continue ;
}
}
// passo alla successiva
++ j ;
}
return true ;
}
+37
View File
@@ -0,0 +1,37 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : IntersPlaneVolZmap.cpp Data : 22.02.24 Versione : 2.6b4
// Contenuto : Implementazione della intersezione piano/VolZmap.
//
//
//
// Modifiche : 22.02.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "VolZmap.h"
#include "/EgtDev/Include/EGkIntersPlaneVolZmap.h"
using namespace std ;
//----------------------------------------------------------------------------
// Intersezione di unpiano con la superficie di un solido VolZmap
//----------------------------------------------------------------------------
bool
IntersPlaneVolZmap( const Plane3d& plPlane, const IVolZmap& Vzm, ICURVEPOVECTOR& vpLoop)
{
// verifico volume
const VolZmap* pVzm = GetBasicVolZmap( &Vzm) ;
if ( pVzm == nullptr)
return false ;
// verifico parametro di ritorno
if ( &vpLoop == nullptr)
return false ;
// eseguo intersezione
return pVzm->GetPlaneIntersection( plPlane, vpLoop) ;
}
+3 -3
View File
@@ -119,12 +119,12 @@ IntersTriaTria( const Triangle3d& trTria1, const Triangle3d& trTria2, Point3d& p
Point3d ptSt1, ptEn1 ;
int nRes1 = IntersCoplanarLineTria( ptL, vtL, 100.0, trTria1, ptSt1, ptEn1, false) ;
// limito la liena di intersezione con il secondo triangolo
// limito la linea di intersezione con il secondo triangolo
Point3d ptSt2, ptEn2 ;
int nRes2 = IntersCoplanarLineTria( ptL, vtL, 100.0, trTria2, ptSt2, ptEn2, false) ;
// eseguo classificazione
double dIntStU, dIntEnU;
double dIntStU, dIntEnU ;
int nIntType = FindTriaTriaIntersType( trTria1, trTria2, ptL, vtL,
( ptSt1 - ptL) * vtL, ( ptEn1 - ptL) * vtL,
( ptSt2 - ptL) * vtL, ( ptEn2 - ptL) * vtL,
@@ -234,7 +234,7 @@ int
FindTriaTriaIntersType( const Triangle3d& trTria1, const Triangle3d& trTria2, const Point3d& ptLineSt, const Vector3d& vtLineDir,
double dStU1, double dEnU1, double dStU2, double dEnU2, int nRes1, int nRes2, double& dIntStU, double& dIntEnU)
{
// Controllo su validit input
// Controllo su validità input
if ( ! ( trTria1.IsValid() && trTria2.IsValid() && vtLineDir.IsNormalized()))
return ITTT_NO ;
// Casi
+2 -4
View File
@@ -26,8 +26,7 @@ class IterManager
{
public :
bool IsGdbIteratorInList( GdbIterator* pIter)
{ PGDBI_LIST::const_iterator Iter ;
for ( Iter = m_IterList.begin() ; Iter != m_IterList.end() ; ++ Iter) {
{ for ( auto Iter = m_IterList.cbegin() ; Iter != m_IterList.cend() ; ++ Iter) {
if ( *Iter == pIter)
return true ;
}
@@ -41,8 +40,7 @@ class IterManager
catch (...) { return false ;}
return true ; }
bool RemoveGdbIterator( GdbIterator* pIter)
{ PGDBI_LIST::iterator Iter ;
for ( Iter = m_IterList.begin() ; Iter != m_IterList.end() ; ++ Iter) {
{ for ( auto Iter = m_IterList.cbegin() ; Iter != m_IterList.cend() ; ++ Iter) {
if ( *Iter == pIter) {
m_IterList.erase( Iter) ;
return true ;
+179
View File
@@ -0,0 +1,179 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : OffsetAux.cpp Data : 23.11.23 Versione : 2.5k5
// Contenuto : Implementazione di alcune funzioni di utilità per gli offset delle curve.
//
//
//
// Modifiche : 23.11.23 SP Creazione modulo spostando alcune funzioni da OffsetCurve.cpp.
//
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "OffsetAux.h"
#include "CurveArc.h"
#include "CurveLine.h"
#include "GeoConst.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
IdentifyFillets( ICurveComposite* pCrvCo, double dDist)
{
// identifico le sottocurve di tipo fillet e assegno loro temp param 1.0 per riconoscerle nella funzione AdjustCurveFillets
for ( int i = 0 ; i < pCrvCo->GetCurveCount() ; i ++) {
// recupero la curva
PtrOwner<ICurve> pCrv( pCrvCo->GetCurve(i)->Clone()) ;
if ( IsNull( pCrv))
return false ;
if ( IsFillet( pCrv, dDist))
pCrvCo->SetCurveTempParam( i, 1.0) ;
else
pCrvCo->SetCurveTempParam( i, 0.0) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
IsFillet( ICurve* pCrv, double dDist)
{
// deve essere un arco
if ( pCrv->GetType() != CRV_ARC)
return false ;
CurveArc* pArc = GetBasicCurveArc( pCrv) ;
// deve avere raggio uguale alla distanza di offset
if ( abs( pArc->GetRadius() - abs( dDist)) > EPS_SMALL)
return false ;
// deve essere CCW se offset a destra e CW se offset a sinistra
return ( pArc->GetAngCenter() * dDist > 0) ;
}
//----------------------------------------------------------------------------
bool
AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType)
{
ICURVEPLIST CrvLst ;
PtrOwner<ICurve> pCrv( pCrvCo->RemoveFirstOrLastCurve( false)) ;
while ( ! IsNull( pCrv)) {
// se identificato come fillet lo trasformo in smusso o estensione
if ( pCrv->GetTempParam() > EPS_SMALL) {
CurveComposite ccTemp ;
ModifyFillet( pCrv, dDist, nType, ccTemp) ;
// metto in lista le curve risultanti
if ( ccTemp.GetCurveCount() > 0) {
PtrOwner<ICurve> pCrv2( ccTemp.RemoveFirstOrLastCurve( false)) ;
while ( ! IsNull( pCrv2)) {
CrvLst.push_back( Release( pCrv2)) ;
pCrv2.Set( ccTemp.RemoveFirstOrLastCurve( false)) ;
}
}
}
// altrimenti salvo in lista
else
CrvLst.push_back( Release( pCrv)) ;
// passo alla curva successiva
pCrv.Set( pCrvCo->RemoveFirstOrLastCurve( false)) ;
}
// rimetto le curve nella composita
for ( auto pCrv : CrvLst) {
pCrvCo->AddCurve( pCrv) ;
}
// unisco tratti allineati
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
return true ;
}
//----------------------------------------------------------------------------
bool
ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux)
{
// la curva deve essere un arco
CurveArc* pArc = GetBasicCurveArc( pCrv) ;
if ( pArc == nullptr)
return false ;
// angolo al centro dell'arco
double dAngDeg = pArc->GetAngCenter() ;
// elimino dal tipo le parti estranee all'angolo esterno
nType &= ( ICurve::OFF_FILLET | ICurve::OFF_CHAMFER | ICurve::OFF_EXTEND) ;
// se l'angolo esterno supera il retto, offset extend diventa offset chamfer
if ( nType == ICurve::OFF_EXTEND && abs( dAngDeg) > ANG_RIGHT + EPS_ANG_SMALL)
nType = ICurve::OFF_CHAMFER ;
// se angolo esterno molto piccolo, semplifico tutto
const double SMALL_EXT_ANG = 1.0 ;
bool bAngSmall = ( abs( dAngDeg) < SMALL_EXT_ANG) ;
if ( bAngSmall)
nType = ICurve::OFF_EXTEND ;
switch ( nType) {
case ICurve::OFF_CHAMFER :
{
// lunghezza aggiuntiva in tangenza
double dLen = abs( dDist) * tan( abs( dAngDeg) / 4 * DEGTORAD) ;
// punti di costruzione smusso
Point3d ptP1, ptP1a, ptP2a, ptP2 ;
if ( ! pArc->GetStartPoint( ptP1) || ! pArc->GetEndPoint( ptP2))
return false ;
Vector3d vtDir1, vtDir2 ;
if ( ! pArc->GetStartDir( vtDir1) || ! pArc->GetEndDir( vtDir2))
return false ;
ptP1a = ptP1 + vtDir1 * dLen ;
ptP2a = ptP2 - vtDir2 * dLen ;
// aggiungo una nuova linea
PtrOwner<CurveLine> pLine1( CreateBasicCurveLine()) ;
if ( IsNull( pLine1) || ! pLine1->Set( ptP1, ptP1a))
return false ;
if ( ! ccAux.AddCurve( Release( pLine1)))
return false ;
// tratto intermedio
PtrOwner<CurveLine> pLine2( CreateBasicCurveLine()) ;
if ( IsNull( pLine2) || ! pLine2->Set( ptP1a, ptP2a))
return false ;
if ( ! ccAux.AddCurve( Release( pLine2)))
return false ;
// aggiungo una nuova linea
PtrOwner<CurveLine> pLine3( CreateBasicCurveLine()) ;
if ( IsNull( pLine3) || ! pLine3->Set( ptP2a, ptP2))
return false ;
if ( ! ccAux.AddCurve( Release( pLine3)))
return false ;
return true ;
}
break ;
case ICurve::OFF_EXTEND :
{
// lunghezza aggiuntiva in tangenza
double dLen = abs( dDist) * tan( abs( dAngDeg) / 2 * DEGTORAD) ;
// punti di costruzione estensione
Point3d ptP1, ptPc, ptP2 ;
if ( ! pArc->GetStartPoint( ptP1) || ! pArc->GetEndPoint( ptP2))
return false ;
Vector3d vtDir1, vtDir2 ;
if ( ! pArc->GetStartDir( vtDir1) || ! pArc->GetEndDir( vtDir2))
return false ;
ptPc = ptP1 + vtDir1 * dLen ;
// aggiungo una nuova linea
PtrOwner<CurveLine> pLine1( CreateBasicCurveLine()) ;
if ( IsNull( pLine1) || ! pLine1->Set( ptP1, ptPc))
return false ;
if ( ! ccAux.AddCurve( Release( pLine1)))
return false ;
// aggiungo una nuova linea
PtrOwner<CurveLine> pLine2( CreateBasicCurveLine()) ;
if ( IsNull( pLine2) || ! pLine2->Set( ptPc, ptP2))
return false ;
if ( ! ccAux.AddCurve( Release( pLine2)))
return false ;
return true ;
}
}
return false ;
}
+21
View File
@@ -0,0 +1,21 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : OffsetAux.h Data : 23.11.23 Versione : 2.5k5
// Contenuto : Dichiarazione di alcune funzioni di utilità per gli offset delle curve.
//
//
//
// Modifiche : 23.11.23 SP Creazione modulo spostando alcune funzioni da OffsetCurve.cpp.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "CurveComposite.h"
//----------------------------------------------------------------------------
bool IdentifyFillets( ICurveComposite* pCrvCo, double dDist) ;
bool IsFillet( ICurve* pCrv, double dDist) ;
bool AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType) ;
bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
+547 -619
View File
File diff suppressed because it is too large Load Diff
+14 -26
View File
@@ -147,8 +147,7 @@ PolyArc::EraseLastUPoint( void)
bool
PolyArc::AddOffsetToU( double dOffset)
{
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->dU += dOffset ;
return true ;
@@ -173,8 +172,7 @@ PolyArc::ParamLinearTransform( double dStartU, double dEndU)
else
return false ;
// eseguo la riparametrizzazione
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->dU = dStartU + dCoeff * ( iter->dU - dOriStartU) ;
return true ;
}
@@ -183,8 +181,7 @@ PolyArc::ParamLinearTransform( double dStartU, double dEndU)
bool
PolyArc::SetElevation( double dZ)
{
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.z = dZ ;
return true ;
@@ -194,8 +191,7 @@ PolyArc::SetElevation( double dZ)
bool
PolyArc::AddElevation( double dZ)
{
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.z += dZ ;
return true ;
@@ -206,8 +202,7 @@ bool
PolyArc::Translate( const Vector3d& vtMove)
{
// il vettore estrusione non subisce modifiche
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.Translate( vtMove) ;
return true ;
@@ -218,8 +213,7 @@ bool
PolyArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
m_vtExtr.Rotate( vtAx, dCosAng, dSinAng) ;
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
return true ;
@@ -230,8 +224,7 @@ bool
PolyArc::Scale( const Frame3d& frRef, double dCoeff)
{
m_vtExtr.Scale( frRef, dCoeff, dCoeff, dCoeff) ;
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.Scale( frRef, dCoeff, dCoeff, dCoeff) ;
return true ;
@@ -242,8 +235,7 @@ bool
PolyArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
{
m_vtExtr.Mirror( vtNorm) ;
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
iter->ptP.Mirror( ptOn, vtNorm) ;
iter->dB *= - 1 ;
}
@@ -256,8 +248,7 @@ bool
PolyArc::ToGlob( const Frame3d& frRef)
{
m_vtExtr.ToGlob( frRef) ;
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.ToGlob( frRef) ;
return true ;
@@ -268,8 +259,7 @@ bool
PolyArc::ToLoc( const Frame3d& frRef)
{
m_vtExtr.ToLoc( frRef) ;
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.ToLoc( frRef) ;
return true ;
@@ -284,8 +274,7 @@ PolyArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
return true ;
// ciclo sui punti
m_vtExtr.LocToLoc( frOri, frDest) ;
UPNTBLIST::iterator iter ;
for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter)
iter->ptP.LocToLoc( frOri, frDest) ;
return true ;
@@ -319,8 +308,7 @@ PolyArc::Split( double dU, PolyArc& PA)
// pulisco la polilinea destinazione
PA.Clear() ;
// ricerca del punto in cui dividere
UPNTBLIST::const_iterator iter ;
iter = m_lUPointBs.begin() ;
auto iter = m_lUPointBs.begin() ;
while ( iter != m_lUPointBs.end() && iter->dU < ( dU + EPS_PARAM))
++ iter ;
if ( iter == m_lUPointBs.end())
@@ -585,7 +573,7 @@ PolyArc::Invert( bool bInvertU)
// inverto la lista
m_lUPointBs.reverse() ;
// sposto il bulge all'estremo iniziale di ogni tratto (l'ultimo non conta) e lo inverto
for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
if ( next( iter) != m_lUPointBs.end())
iter->dB = - next( iter)->dB ;
else
@@ -596,7 +584,7 @@ PolyArc::Invert( bool bInvertU)
// recupero il primo valore di U che è il vecchio finale ed è il riferimento di inversione
double dUfin = m_lUPointBs.front().dU ;
// ciclo su tutti gli elementi
for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) {
iter->dU = dUfin - iter->dU ;
}
}
+93 -76
View File
@@ -28,9 +28,8 @@ using namespace std ;
//----------------------------------------------------------------------------
PolyLine::PolyLine( void)
: m_nRejected( 0), m_nTempProp{0,0}, m_iter( m_lUPoints.end())
{
m_nRejected = 0 ;
m_iter = m_lUPoints.end() ;
}
//----------------------------------------------------------------------------
@@ -140,8 +139,7 @@ PolyLine::EraseLastUPoint( void)
bool
PolyLine::AddOffsetToU( double dOffset)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->second += dOffset ;
return true ;
@@ -151,8 +149,7 @@ PolyLine::AddOffsetToU( double dOffset)
bool
PolyLine::Translate( const Vector3d& vtMove)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.Translate( vtMove) ;
return true ;
@@ -162,8 +159,7 @@ PolyLine::Translate( const Vector3d& vtMove)
bool
PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
return true ;
@@ -173,8 +169,7 @@ PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
bool
PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
return true ;
@@ -184,8 +179,7 @@ PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
bool
PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.Mirror( ptOn, vtNorm) ;
return true ;
@@ -195,8 +189,7 @@ PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
bool
PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
return true ;
@@ -206,8 +199,7 @@ PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt
bool
PolyLine::ToGlob( const Frame3d& frRef)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.ToGlob( frRef) ;
return true ;
@@ -217,8 +209,7 @@ PolyLine::ToGlob( const Frame3d& frRef)
bool
PolyLine::ToLoc( const Frame3d& frRef)
{
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.ToLoc( frRef) ;
return true ;
@@ -232,8 +223,7 @@ PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
if ( AreSameFrame( frOri, frDest))
return true ;
// ciclo sui punti
PNTULIST::iterator iter ;
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
iter->first.LocToLoc( frOri, frDest) ;
return true ;
@@ -655,6 +645,12 @@ PolyLine::GetAreaXY( double& dArea) const
for ( bool bFound = GetFirstLine( ptIni, ptFin) ; bFound ; bFound = GetNextLine( ptIni, ptFin)) {
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ; // projection on xy
}
// considero anche la linea tra l'ultimo e il primo punto perchè in alcuni casi potrebbero definire area
// significativa anche se sono coincidenti per le nostre tolleranze
ptIni = ptFin ;
GetFirstPoint( ptFin) ;
if ( ! AreSamePointExact( ptIni, ptFin))
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ;
dArea = 0.5 * dArea ;
return true ;
}
@@ -684,7 +680,7 @@ PolyLine::GetMaxDistanceFromLine( const Point3d& ptLine, const Vector3d& vtLine,
bool
PolyLine::AdjustForMaxSegmentLen( double dMaxLen)
{
PNTULIST::iterator iter = m_lUPoints.begin() ;
auto iter = m_lUPoints.begin() ;
// se non ci sono punti, esco subito
if ( iter == m_lUPoints.end())
return false ;
@@ -725,15 +721,42 @@ PolyLine::AdjustForMaxSegmentLen( double dMaxLen)
return true ;
}
//----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static bool
PointsInTolerance( const PNTVECTOR& vRPT, const Point3d& ptP1, const Point3d& ptP2, double dSqTol)
DouglasPeuckerSimplification( const PNTUVECTOR& vPtU, const double dSqTol, const int nIndStart,
const int nIndEnd, INTVECTOR& vInd)
{
for ( const auto& ptQ : vRPT) {
double dSqDist ;
if ( ! DistPointLine( ptQ, ptP1, ptP2).GetSqDist( dSqDist) || dSqDist > dSqTol)
// se indici uguali, ritorno
if ( nIndStart == nIndEnd)
return true ;
// distanza massima e indice del punto associato
double dMaxSqDist = 0. ;
int nMaxInd = 0 ;
// scorro i punti intermedi tra nIndStart e nIndEnd
for ( int i = nIndStart + 1 ; i < nIndEnd ; ++ i) {
double dCurrSqDist = 0. ;
// distanza tra il punto attuale e la retta tra i punti di indici nIndStart ed nIndEnd
DistPointLine DPL( vPtU[i].first, vPtU[nIndStart].first, vPtU[nIndEnd].first) ;
if ( DPL.GetSqDist( dCurrSqDist) && dCurrSqDist > dMaxSqDist) {
// aggiorno i parametri
dMaxSqDist = dCurrSqDist ;
nMaxInd = i ;
}
}
// se la distanza massima trovata è sopra la tolleranza, allora controllo la parte di PolyLine tra
// (nIndStart, nMaxInd) e quella tra (nMaxInd, nIndEnd)
if ( dMaxSqDist > dSqTol) {
// inserisco il punto
vInd.push_back( nMaxInd) ;
// split
if ( ! DouglasPeuckerSimplification( vPtU, dSqTol, nIndStart, nMaxInd, vInd) ||
! DouglasPeuckerSimplification( vPtU, dSqTol, nMaxInd, nIndEnd, vInd))
return false ;
}
return true ;
}
@@ -747,59 +770,53 @@ PolyLine::RemoveAlignedPoints( double dToler)
// controllo minimo valore di tolleranza
dToler = max( dToler, LIN_TOL_MIN) ;
double dSqTol = dToler * dToler ;
// si analizza la distanza di un punto dal segmento che unisce precedente e successivo
// punto precedente
auto precP = m_lUPoints.begin() ;
// punto corrente
auto currP = next( precP) ;
// punto successivo
auto nextP = next( currP) ;
// lista dei punti appena rimossi
PNTVECTOR vRPT ; vRPT.reserve( 20) ;
// mentre esiste un successivo
while ( nextP != m_lUPoints.end()) {
// distanza del punto corrente dal segmento che unisce gli adiacenti
DistPointLine dPL( currP->first, precP->first, nextP->first) ;
double dSqDist ;
// se da eliminare
if ( dPL.GetSqDist( dSqDist) && dSqDist < dSqTol && PointsInTolerance( vRPT, precP->first, nextP->first, dSqTol)) {
// aggiungo il punto nella lista dei rimossi
vRPT.emplace_back( currP->first) ;
// elimino il punto
m_lUPoints.erase( currP) ;
// avanzo con corrente e successivo
currP = nextP ;
++ nextP ;
}
// altrimenti da tenere
else {
// cancello la lista dei rimossi
vRPT.clear() ;
// avanzo il terzetto di uno step
precP = currP ;
currP = nextP ;
++ nextP ;
}
// vettore contenente i punti della polyline
PNTUVECTOR vPtU ; vPtU.reserve( m_lUPoints.size()) ;
for ( const auto& ptCurr : m_lUPoints)
vPtU.emplace_back( ptCurr) ;
// vettore indici dei punti rimanenti
INTVECTOR vInd ; vInd.reserve( vPtU.size()) ;
// se aperta
if ( ! IsClosed()) {
// considero tutti i punti della PolyLine
vInd.push_back( 0) ;
if ( ! DouglasPeuckerSimplification( vPtU, dSqTol, 0, int( vPtU.size()) - 1, vInd))
return false ;
vInd.push_back( vPtU.size() - 1) ;
}
// se curva chiusa con almeno 4 punti, devo analizzare il terzetto attorno alla chiusura
if ( IsClosed() && m_lUPoints.size() >= 4) {
// precP e currP sono già corretti
// il primo punto ripete l'ultimo (geometricamente coincide con currP)
auto firstP = m_lUPoints.begin() ;
// questo è il vero successivo
nextP = next( firstP) ;
// distanza del punto corrente dal segmento che unisce gli adiacenti
DistPointLine dPL( currP->first, precP->first, nextP->first) ;
double dSqDist ;
// se da eliminare
if ( dPL.GetSqDist( dSqDist) && dSqDist < dSqTol && PointsInTolerance( vRPT, precP->first, nextP->first, dSqTol)) {
// faccio coincidere il primo punto con il precedente
firstP->first = precP->first ;
// elimino il punto corrente
m_lUPoints.erase( currP) ;
// altrimenti chiusa
else {
// cerco il punto più distante dal primo
double dMaxDist = 0. ;
int nMaxInd = 0 ;
for ( int i = 1 ; i < int( vPtU.size()) ; ++ i) {
double dCurrDist = Dist( vPtU[0].first, vPtU[i].first) ;
if ( dCurrDist > dMaxDist) {
dMaxDist = dCurrDist ;
nMaxInd = i ;
}
}
// recupero due PolyLine di approssimazione
vInd.push_back( 0) ;
if ( ! DouglasPeuckerSimplification( vPtU, dSqTol, 0, nMaxInd, vInd))
return false ;
vInd.push_back( nMaxInd) ;
if ( ! DouglasPeuckerSimplification( vPtU, dSqTol, nMaxInd, int( vPtU.size()) - 1, vInd))
return false ;
vInd.push_back( vPtU.size() - 1) ;
}
// ordino in senso crescente
sort( vInd.begin(), vInd.end()) ;
// rimetto in lista i soli punti rimasti
m_lUPoints.clear() ;
for ( auto Ind : vInd)
m_lUPoints.push_back( vPtU[Ind]) ;
return true ;
}
+12
View File
@@ -471,6 +471,18 @@ Polygon3d::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
return true ;
}
//----------------------------------------------------------------------------
bool
Polygon3d::GetLocalBBox( BBox3d& b3Loc) const
{
// assegno il box in locale, scorrendo tutti i punti del contorno
b3Loc.Reset() ;
for ( const auto& ptP : m_vVert)
b3Loc.Add( ptP) ;
return true ;
}
//----------------------------------------------------------------------------
void
Polygon3d::Invert( void)
+224
View File
@@ -0,0 +1,224 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : PolygonElevation.cpp Data : 17.12.23 Versione : 2.5l3
// Contenuto : Implementazione di funzioni per calcolo elevazione di
// un poligono (faccia piana) in solidi di diverso tipo.
//
//
// Modifiche : 17.12.23 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "CurveLine.h"
#include "CurveComposite.h"
#include "/EgtDev/Include/EGkIntersLineBox.h"
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
#include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkPolygonElevation.h"
using namespace std ;
//-------------------------------------------------------------------------------
bool
PolygonElevationInBBox( const Polygon3d& pgFacet, const BBox3d& b3Box, bool bAcceptOutFacet, double& dElev)
{
// verifico validità del poligono e del box
if ( ! pgFacet.IsValid() || b3Box.IsEmpty())
return false ;
// se richiesto, verifico che la faccia sia contenuta nel box
if ( ! bAcceptOutFacet) {
BBox3d b3Fac ;
if ( ! pgFacet.GetLocalBBox( b3Fac))
return false ;
BBox3d b3ExpBox = b3Box ; b3ExpBox.Expand( 100 * EPS_SMALL) ;
if ( ! b3ExpBox.Encloses( b3Fac)) {
dElev = -1 ;
return true ;
}
}
// recupero centro, normale e contorno delle faccia poligonale
Point3d ptCen = pgFacet.GetCentroid() ;
Vector3d vtN = pgFacet.GetVersN() ;
PolyLine PL = pgFacet.GetPolyLine() ;
// calcolo elevazione massima del contorno della faccia
const double RAY_LEN = 100000 ;
dElev = 0 ;
Point3d ptP ;
bool bFound = PL.GetFirstPoint( ptP) ;
while ( bFound) {
INTDBLVECTOR vInters ;
IntersLineBox( ptP, vtN, RAY_LEN, b3Box, vInters, true) ;
for ( int i = 0 ; i < int( vInters.size()) ; ++ i) {
if ( i == 0 && ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_TG_INI)) {
if ( ! bAcceptOutFacet && vInters[i].second > 100 * EPS_SMALL) {
dElev = -1 ;
return true ;
}
}
else if ( vInters[i].first == ILBT_OUT || vInters[i].first == ILBT_TG_FIN)
dElev = max( dElev, vInters[i].second) ;
}
bFound = PL.GetNextPoint( ptP, true) ;
}
// calcolo elevazione massima degli eventuali spigoli (e vertici) del box dalla parte positiva della faccia e che cadono in essa
BIPNTVECTOR vEdges( 12) ;
vEdges[0].first = b3Box.GetMin() ; vEdges[0].second = vEdges[0].first + b3Box.GetDimX() * X_AX ;
vEdges[1].first = vEdges[0].second ; vEdges[1].second = vEdges[1].first + b3Box.GetDimY() * Y_AX ;
vEdges[2].first = vEdges[1].second ; vEdges[2].second = vEdges[0].first + b3Box.GetDimY() * Y_AX ;
vEdges[3].first = vEdges[2].second ; vEdges[3].second = vEdges[0].first ;
vEdges[4].first = vEdges[0].first + b3Box.GetDimZ() * Z_AX ; vEdges[4].second = vEdges[0].second + b3Box.GetDimZ() * Z_AX ;
vEdges[5].first = vEdges[1].first + b3Box.GetDimZ() * Z_AX ; vEdges[5].second = vEdges[1].second + b3Box.GetDimZ() * Z_AX ;
vEdges[6].first = vEdges[2].first + b3Box.GetDimZ() * Z_AX ; vEdges[6].second = vEdges[2].second + b3Box.GetDimZ() * Z_AX ;
vEdges[7].first = vEdges[3].first + b3Box.GetDimZ() * Z_AX ; vEdges[7].second = vEdges[3].second + b3Box.GetDimZ() * Z_AX ;
vEdges[8].first = vEdges[0].first ; vEdges[8].second = vEdges[4].first ;
vEdges[9].first = vEdges[1].first ; vEdges[9].second = vEdges[5].first ;
vEdges[10].first = vEdges[2].first ; vEdges[10].second = vEdges[6].first ;
vEdges[11].first = vEdges[3].first ; vEdges[11].second = vEdges[7].first ;
// porto tutto nel riferimento intrinseco della faccia (già calcolato in quello del box)
Frame3d frOcs ; frOcs.Set( ptCen, vtN) ;
PL.ToLoc( frOcs) ;
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
vEdges[i].first.ToLoc( frOcs) ;
vEdges[i].second.ToLoc( frOcs) ;
}
// calcolo la curva di loop
CurveComposite ccLoop ;
if ( ! ccLoop.FromPolyLine( PL))
return false ;
// eseguo i calcoli di elevazione
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
// se sta sul piano o sotto, lo salto
if ( vEdges[i].first.z < EPS_SMALL && vEdges[i].second.z < EPS_SMALL)
continue ;
// calcolo il segmento di linea
CurveLine clLine ;
if ( ! clLine.Set( vEdges[i].first, vEdges[i].second))
return false ;
// l'elevazione va aggiornata con la massima Z delle eventuali intersezioni dell'edge con il loop
IntersCurveCurve intLL( clLine, ccLoop) ;
IntCrvCrvInfo aInfo ;
for ( int j = 0 ; intLL.GetIntCrvCrvInfo( j, aInfo) ; ++ j) {
dElev = max( dElev, aInfo.IciA[0].ptI.z) ;
if ( aInfo.bOverlap)
dElev = max( dElev, aInfo.IciA[1].ptI.z) ;
// se prima intersezione va da interno ad esterno allora devo considerare il punto iniziale del segmento (vertice)
if ( j == 0 && aInfo.IciA[0].nPrevTy == ICCT_IN)
dElev = max( dElev, vEdges[i].first.z) ;
// c'è anche il caso di ultima intersezione da esterno a interno, ma vertice già considerato nel caso precedente
}
}
return true ;
}
//-------------------------------------------------------------------------------
bool
PolygonElevationInClosedSurfTm( const Polygon3d& pgFacet, const ISurfTriMesh& CldStm, bool bAcceptOutFacet, double& dElev)
{
// verifico validità del poligono e della superficie
if ( ! pgFacet.IsValid() || ! CldStm.IsValid() || ! CldStm.IsClosed())
return false ;
// se superficie vuota
if ( CldStm.IsEmpty()) {
dElev = ( bAcceptOutFacet ? 0 : -1) ;
return true ;
}
// se richiesto, verifico sia contenuta nel box della superficie chiusa
if ( ! bAcceptOutFacet) {
BBox3d b3Fac ;
if ( ! pgFacet.GetLocalBBox( b3Fac))
return false ;
BBox3d b3ExpCldStm ; CldStm.GetLocalBBox( b3ExpCldStm) ; b3ExpCldStm.Expand( 100 * EPS_SMALL) ;
if ( ! b3ExpCldStm.Encloses( b3Fac)) {
dElev = -1 ;
return true ;
}
}
// recupero centro, normale e contorno delle faccia poligonale
Point3d ptCen = pgFacet.GetCentroid() ;
Vector3d vtN = pgFacet.GetVersN() ;
PolyLine PL = pgFacet.GetPolyLine() ;
// calcolo elevazione massima del contorno della faccia
const double RAY_LEN = 100000 ;
dElev = 0 ;
Point3d ptP ;
bool bFound = PL.GetFirstPoint( ptP) ;
while ( bFound) {
ILSIVECTOR vInters ;
IntersLineSurfTm( ptP, vtN, RAY_LEN, CldStm, vInters, true) ;
for ( int i = 0 ; i < int( vInters.size()) ; ++ i) {
const auto& Inters = vInters[i] ;
if ( i == 0 && Inters.nILTT != ILTT_NO && Inters.dCosDN < -EPS_ZERO) {
if ( ! bAcceptOutFacet && Inters.dU > 100 * EPS_SMALL) {
dElev = -1 ;
return true ;
}
}
else if ( ( Inters.nILTT == ILTT_VERT || Inters.nILTT == ILTT_EDGE || Inters.nILTT == ILTT_IN) && Inters.dCosDN > EPS_ZERO)
dElev = max( dElev, Inters.dU) ;
else if ( Inters.nILTT == ILTT_SEGM || Inters.nILTT == ILTT_SEGM_ON_EDGE)
dElev = max( dElev, Inters.dU2) ;
}
bFound = PL.GetNextPoint( ptP, true) ;
}
// calcolo elevazione massima degli eventuali spigoli (e vertici) della superficie chiusa dalla parte positiva della faccia e che cadono in essa
int nEdgeCnt = CldStm.GetEdgeCount() ;
if ( nEdgeCnt < 0)
return false ;
BIPNTVECTOR vEdges ;
vEdges.reserve( nEdgeCnt) ;
for ( int i = 0 ; i < nEdgeCnt ; ++ i) {
Point3d ptP1, ptP2 ; double dAng ;
CldStm.GetEdge( i, ptP1, ptP2, dAng) ;
vEdges.emplace_back( ptP1, ptP2) ;
}
// porto tutto nel riferimento intrinseco della faccia (già calcolato in quello della superficie chiusa)
Frame3d frOcs ; frOcs.Set( ptCen, vtN) ;
PL.ToLoc( frOcs) ;
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
vEdges[i].first.ToLoc( frOcs) ;
vEdges[i].second.ToLoc( frOcs) ;
}
// calcolo la curva di loop
CurveComposite ccLoop ;
if ( ! ccLoop.FromPolyLine( PL))
return false ;
// eseguo i calcoli di elevazione
for ( int i = 0 ; i < int( vEdges.size()) ; ++ i) {
// se sta sul piano o sotto, lo salto
if ( vEdges[i].first.z < EPS_SMALL && vEdges[i].second.z < EPS_SMALL)
continue ;
// calcolo il segmento di linea
CurveLine clLine ;
if ( ! clLine.Set( vEdges[i].first, vEdges[i].second))
return false ;
// l'elevazione va aggiornata con la massima Z delle eventuali intersezioni dell'edge con il loop
IntersCurveCurve intLL( clLine, ccLoop) ;
IntCrvCrvInfo aInfo ;
for ( int j = 0 ; intLL.GetIntCrvCrvInfo( j, aInfo) ; ++ j) {
dElev = max( dElev, aInfo.IciA[0].ptI.z) ;
if ( aInfo.bOverlap)
dElev = max( dElev, aInfo.IciA[1].ptI.z) ;
// se prima intersezione va da interno ad esterno allora devo considerare il punto iniziale del segmento (vertice)
if ( j == 0 && aInfo.IciA[0].nPrevTy == ICCT_IN)
dElev = max( dElev, vEdges[i].first.z) ;
// se ultima intersezione va da esterno a interno allora devo considerare il punto finale del segmento (vertice)
else if ( j == intLL.GetIntersCount() - 1 && aInfo.IciA[ aInfo.bOverlap ? 1 : 0].nNextTy == ICCT_IN)
dElev = max( dElev, vEdges[i].second.z) ;
}
}
return true ;
}
+142
View File
@@ -0,0 +1,142 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : ProjectCurveSurfTm.cpp Data : 16.11.23 Versione : 2.5kh3
// Contenuto : Implementazione funzioni proiezione curve su superficie Trimesh.
//
//
//
// Modifiche : 31.08.23 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DistPointLine.h"
#include "GeoConst.h"
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
#include "/EgtDev/Include/EGkProjectCurveSurfTm.h"
using namespace std ;
//----------------------------------------------------------------------------
static bool
PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext, double dSqTol)
{
for ( int i = nPrec + 1 ; i < nCurr ; ++ i) {
double dSqDist ;
if ( ! DistPointLine( vPt5ax[i].ptP, vPt5ax[nPrec].ptP, vPt5ax[nNext].ptP).GetSqDist( dSqDist) || dSqDist > dSqTol)
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vector3d& vtDir, double dLinTol, double dMaxSegmLen,
PNT5AXVECTOR& vPt5ax)
{
// controllo le tolleranze
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
dMaxSegmLen = max( dMaxSegmLen, 10 * EPS_SMALL) ;
// approssimo la curva con una polilinea entro la metà della tolleranza
PolyLine PL ;
if ( ! crCrv.ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
return false ;
const double MAX_SEG_LEN = min( dMaxSegmLen, 1.) ;
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
return false ;
// Oggetto per calcolo massivo intersezioni tra linee di proiezione e superficie
Frame3d frRefLine ;
if ( ! frRefLine.Set( ORIG, vtDir))
return false ;
IntersParLinesSurfTm intPLSTM( frRefLine, tmSurf) ;
// Vettore locale dei punti risultanti
PNT5AXVECTOR vMyPt5ax ;
vMyPt5ax.reserve( PL.GetPointNbr()) ;
// proietto i punti della polilinea sulla superficie
double dU ;
Point3d ptP ;
bool bFound = PL.GetFirstUPoint( &dU, &ptP) ;
while ( bFound) {
Point3d ptL = GetToLoc( ptP, frRefLine) ;
ILSIVECTOR vIntRes ;
intPLSTM.GetInters( ptL, 1, vIntRes, false) ;
if ( vIntRes.size() > 0) {
// calcolo il punto
int nI = int( vIntRes.size()) - 1 ;
Point3d ptInt ;
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
ptInt = vIntRes[nI].ptI2 ;
else
ptInt = vIntRes[nI].ptI ;
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
Triangle3dEx trTria ;
if ( ! tmSurf.GetTriangle( vIntRes[nI].nT, trTria))
return false ;
Vector3d vtN ;
double dU, dV, dW ;
if ( BarycentricCoord( ptInt, trTria, dU, dV, dW))
vtN = dU * trTria.GetVertexNorm( 0) + dV * trTria.GetVertexNorm( 1) + dW * trTria.GetVertexNorm( 2) ;
if ( ! vtN.Normalize())
vtN = trTria.GetN() ;
// aggiungo al vettore dei proiettati
vMyPt5ax.emplace_back( ptInt, vtN, dU, 1) ;
}
bFound = PL.GetNextUPoint( &dU, &ptP) ;
}
// rimuovo i punti allineati entro la tolleranza e non più lontani tra loro del massimo
double dSqMaxLen = dMaxSegmLen * dMaxSegmLen ;
double dSqTol = dLinTol * dLinTol ;
int nPrec = 0 ;
int nCurr = 1 ;
int nNext = 2 ;
while ( nNext < int( vMyPt5ax.size())) {
bool bRemove = false ;
// lunghezza del segmento che unisce gli adiacenti
double dSqLen = SqDist( vMyPt5ax[nPrec].ptP, vMyPt5ax[nNext].ptP) ;
// se lunghezza inferiore al massimo, passo agli altri controlli
if ( dSqLen <= dSqMaxLen) {
// distanza del punto corrente dal segmento che unisce gli adiacenti
DistPointLine dPL( vMyPt5ax[nCurr].ptP, vMyPt5ax[nPrec].ptP, vMyPt5ax[nNext].ptP) ;
double dSqDist ;
// se distanza inferiore a tolleranza lineare
if ( dPL.GetSqDist( dSqDist) && dSqDist < dSqTol && PointsInTolerance( vMyPt5ax, nPrec, nCurr, nNext, dSqTol)) {
// verifico se errore angolare inferiore a limite
double dPar ; dPL.GetParamAtMinDistPoint( dPar) ;
Vector3d vtNew = Media( vMyPt5ax[nPrec].vtDir, vMyPt5ax[nNext].vtDir, dPar) ;
if ( vtNew.Normalize() && vtNew * vMyPt5ax[nCurr].vtDir > cos( 2 * DEGTORAD))
bRemove = true ;
}
}
// se da eliminare
if ( bRemove) {
// dichiaro da eliminare il punto
vMyPt5ax[nCurr].nFlag = -1 ;
// avanzo con corrente e successivo
nCurr = nNext ;
++ nNext ;
}
// altrimenti da tenere
else {
// avanzo il terzetto di uno step
nPrec = nCurr ;
nCurr = nNext ;
++ nNext ;
}
}
// copio i punti rimasti nel vettore di ritorno
vPt5ax.clear() ;
for ( const auto& Pt5ax : vMyPt5ax) {
if ( Pt5ax.nFlag != -1)
vPt5ax.emplace_back( Pt5ax) ;
}
return true ;
}
+70
View File
@@ -135,3 +135,73 @@ RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol)
return true ;
}
//----------------------------------------------------------------------------
bool
RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol)
{
// verifico validità curva
if ( pCurve == nullptr)
return false ;
// verifico e sistemo tolleranza lineare
dLinTol = max( dLinTol, EPS_SMALL) ;
// recupero il numero di curve semplici componenti la composta
int nCrvCount = pCurve->GetCurveCount() ;
if ( nCrvCount < 2 || ( nCrvCount < 3 && pCurve->IsClosed()))
return true ;
// se aperta, verifico le due curve agli estremi
if ( ! pCurve->IsClosed()) {
// curva iniziale
const ICurve* pFirstCrv = pCurve->GetFirstCurve() ;
double dFirstLen ; pFirstCrv->GetLength( dFirstLen) ;
if ( dFirstLen < dLinTol) {
Point3d ptStart ; pFirstCrv->GetStartPoint( ptStart) ;
delete( pCurve->RemoveFirstOrLastCurve( false)) ;
pCurve->ModifyStart( ptStart) ;
-- nCrvCount ;
}
// curva finale
const ICurve* pLastCrv = pCurve->GetLastCurve() ;
double dLastLen ; pLastCrv->GetLength( dLastLen) ;
if ( dLastLen < dLinTol) {
Point3d ptEnd ; pLastCrv->GetStartPoint( ptEnd) ;
delete( pCurve->RemoveFirstOrLastCurve( true)) ;
pCurve->ModifyEnd( ptEnd) ;
-- nCrvCount ;
}
}
// ciclo sulle curve elementari della composita
int nStart = pCurve->IsClosed() ? 0 : 1 ;
int nEnd = pCurve->IsClosed() ? nCrvCount : nCrvCount - 1 ;
for ( int i = nStart ; i < nEnd ; ++ i) {
// recupero la curva corrente
const ICurve* pCurrCrv = pCurve->GetCurve( i) ;
// se la curva corrente è troppo corta
double dLen ; pCurrCrv->GetLength( dLen) ;
if ( dLen < dLinTol) {
// recupero il punto medio della curva
Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ;
// rimuovo il segmento
if ( pCurve->RemoveJoint( i)) {
// porto il nuovo estremo sul punto medio
pCurve->ModifyJoint( i, ptMid) ;
// aggiorno valore di i tenendo conto che ModifyJoint potrebbe modificare la curva precedente
// che quindi va ricontrollata
i = max( i - 2, nStart - 1) ;
// aggiorno valore di nEnd ( ModifyJoint potrebbe aver rimosso la curva precedente e la successiva)
nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ;
}
// altrimenti rimuovo anche il successivo
else if ( pCurve->RemoveJoint( i + 1)) {
pCurve->RemoveJoint( i) ;
pCurve->ModifyJoint( i, ptMid) ;
i = max( i - 2, nStart - 1) ;
nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ;
}
}
}
return true ;
}
+3 -2
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2017-2022
//----------------------------------------------------------------------------
// File : RemoveCurveDefects.h Data : 13.11.22 Versione : 2.4k2
// File : RemoveCurveDefects.h Data : 03.11.23 Versione : 2.5k1
// Contenuto : Dichiarazione funzioni rimozione difetti curve.
//
//
//
// Modifiche : 02.10.17 DS Creazione modulo.
//
// 03.11.23 DS Aggiunta RemoveCurveSmallParts.
//
//----------------------------------------------------------------------------
@@ -19,3 +19,4 @@
//----------------------------------------------------------------------------
bool RemoveCurveSpikes( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
bool RemoveCurveSmallZs( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
bool RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol = EPS_SMALL) ;
+265
View File
@@ -0,0 +1,265 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : RotationMinimizeFrame.cpp Data : 05.03.24 Versione : 2.6c1
// Contenuto : Classe per RotationMinimizeFrame
//
//
//
// Modifiche : 05.03.24 RE Creazione modulo.
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "RotationMinimizeFrame.h"
#include "GeoConst.h"
using namespace std ;
RotationMinimizeFrame::RotationMinimizeFrame( const ICurve* pCrv, const Frame3d& fr_Start)
{
// assegno i parametri
m_pCrv = pCrv->Clone() ;
m_Frame0 = fr_Start ;
}
//----------------------------------------------------------------------------
RotationMinimizeFrame::~RotationMinimizeFrame( void)
{
Clear() ;
}
//----------------------------------------------------------------------------
bool
RotationMinimizeFrame::Clear( void)
{
// pulizia della curva
if ( m_pCrv != nullptr)
delete m_pCrv ;
m_pCrv = nullptr ;
// reset del frame di partenza
m_Frame0.Reset() ;
return true ;
}
//----------------------------------------------------------------------------
bool
RotationMinimizeFrame::IsValid()
{
// controllo validità della curva
if ( m_pCrv == nullptr || ! m_pCrv->IsValid())
return false ;
// controllo del frame iniziale
if ( ! m_Frame0.IsValid())
return false ;
// controllo che l'origine del frame sia sulla curva e che l'asse Z sia tangente alla curva
Point3d ptS ;
Vector3d vtZ ;
if ( ! m_pCrv->GetPointD1D2( 0., ICurve::FROM_MINUS, ptS, &vtZ) ||
! vtZ.Normalize() ||
! AreSamePointApprox( ptS, m_Frame0.Orig()) ||
! AreSameVectorEpsilon( vtZ, m_Frame0.VersZ(), 5 * EPS_SMALL))
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
RotationMinimizeFrame::GetFrameAtLength( const Frame3d& frAct, const double dLenNext, Frame3d& frNext)
{
/*
Double Reflection
Computation of Rotation Minimizing Frame in Computer Graphics
Wenping Wang Bert Juttler Dayue Zheng Yang Liu
*/
// ricavo i parametri dal frame
if ( ! frAct.IsValid())
return false ;
// origine del frame e versori ( ptAct, [ vt_r, vt_s, vt_t])
Point3d ptCurr = frAct.Orig() ;
Vector3d vt_r = frAct.VersX() ;
Vector3d vt_t = frAct.VersZ() ;
// ( vt_s è implicito )
double dUNext ; // parametro sulla curva nello step successivo
Point3d ptNext ; // punto sulla curva allo step successivo
// parametro (i+1)-esimo sulla curva
if ( ! m_pCrv->GetParamAtLength( dLenNext, dUNext))
return false ;
// punto (i+1)-esimo sulla curva e suo vettore tangente
Vector3d vt_t_next ;
if ( ! m_pCrv->GetPointD1D2( dUNext, ICurve::FROM_MINUS, ptNext, &vt_t_next) ||
! vt_t_next.IsValid() || ! vt_t_next.Normalize()) // versore tangente
return false ;
// controllo per casi degeneri
if ( AreSamePointEpsilon( ptCurr, ptNext, EPS_ZERO) || // non esiste il piano R1
abs(( ptNext - ptCurr) * ( vt_t_next + vt_t)) < EPS_ZERO) // non esiste il piano R2
return false ;
// ricavo il vettore di riflessione rispetto al piano R1
Vector3d vR1_norm = ptNext - ptCurr ;
if ( ! vR1_norm.IsValid())
return false ;
// parametro di riflessione per R1
double dPar1 = vR1_norm * vR1_norm ;
// riflessione rispetto al piano R1 ( sistema sinistrorso L )
Vector3d vt_r_L = vt_r - ( 2 / dPar1) * ( vR1_norm * vt_r) * vR1_norm ;
Vector3d vt_t_L = vt_t - ( 2 / dPar1) * ( vR1_norm * vt_t) * vR1_norm ;
// ricavo il vettore di riflessione rispetto al piano R1
Vector3d vR2_norm = vt_t_next - vt_t_L ;
if ( ! vR2_norm.IsValid())
return false ;
// parametro di riflessione per R2
double dPar2 = vR2_norm * vR2_norm ;
// versore r del nuovo frame
Vector3d vt_r_next = vt_r_L - ( 2 / dPar2) * ( vR2_norm * vt_r_L) * vR2_norm ;
// versore t del nuovo frame
Vector3d vt_s_next = vt_t_next ^ vt_r_next ;
// imposto il nuovo frame
frNext.Set( ptNext, vt_r_next, vt_s_next, vt_t_next) ;
if ( ! frNext.IsValid()) { // il frame potrebbe non essere nelle tolleranze...
// ... sistemo ricavando il versore "s" mediante "t" ed "r" ...
frNext.Set( ptNext, vt_t_next, vt_r_next) ;
if ( ! frNext.IsValid())
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
RotationMinimizeFrame::GetFramesByStep( FRAME3DVECTOR& vRMFrames, double dStep, bool bUniform)
{
// controllo sullo step
dStep = max( 10 * EPS_SMALL, dStep) ;
// controllo validità
if ( ! IsValid()) {
Clear() ;
return false ;
}
// calcolo lunghezza della curva
double dLen = 0. ;
if ( ! m_pCrv->GetLength( dLen))
return false ;
// in prima posizione viene inserito il frame iniziale
vRMFrames.push_back( m_Frame0) ;
// ricavo il numero degli step
int nStep = int( ceil( dLen / dStep)) ;
if ( nStep == 0) // se non ho step allora serve sono il frame iniziale
return true ;
// lunghezza della curva identificata dal punto successivo
double dLenNext ;
// step corrente
double dMyStep = dStep ;
if ( bUniform)
dMyStep = dLen / nStep ;
// ciclo sugli step in cui la curva è suddivisa
for ( int i = 0 ; i < nStep ; ++ i) {
// ricavo la lunghezza della curva relativo allo step (i+1)-esimo
dLenNext = min( dLen - 10 * EPS_SMALL, ( i + 1) * dMyStep) ;
// ricavo il frame alla lunghezza calcolata
Frame3d frNext ;
if ( ! GetFrameAtLength( vRMFrames[i], dLenNext, frNext))
return false ;
// aggiornamento vettore dei frame
vRMFrames.push_back( frNext) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
RotationMinimizeFrame::GetFramesBySplit( FRAME3DVECTOR& vRMFrames, int nIntervals)
{
// controllo sul numero di intervalli
nIntervals = max( 1, nIntervals) ;
// ricavo lo step associato
double dLen = 0 ;
if ( ! m_pCrv->GetLength( dLen))
return false ;
// ricavo lo step associato
double dStep = dLen / nIntervals ;
return GetFramesByStep( vRMFrames, dStep) ;
}
//----------------------------------------------------------------------------
bool
RotationMinimizeFrame::GetFramesByTollerance( FRAME3DVECTOR& vRMFrames, double dTol)
{
// controllo sulla tolleranza
dTol = max( EPS_SMALL, dTol) ;
// controllo validità
if ( ! IsValid()) {
Clear() ;
return false ;
}
// ricavo la PolyLine associata alla curva mediante tale tolleranza
PolyLine PL ;
if ( ! m_pCrv->ApproxWithLines( dTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
return false ;
// ricavo la lunghezza della curva
double dCrvLen = 0 ;
if ( ! m_pCrv->GetLength( dCrvLen))
return false ;
// devo calcolare il RMF su ogni punto ricavato dall'approssimazione
Point3d ptCurr ;
bool bPoint = PL.GetFirstPoint( ptCurr) ;
bool bFirst = true ;
while ( bPoint) {
if ( bFirst) {
// in prima posizione viene inserito il frame iniziale
vRMFrames.push_back( m_Frame0) ;
bFirst = false ;
}
else {
// ricavo la lunghezza della curva al punto corrente
double dLen = 0. ;
if ( ! m_pCrv->GetLengthAtPoint( ptCurr, dLen))
return false ;
// per sicurezza controllo che sia minore della lunghezza complessiva
dLen = min( dCrvLen - 10 * EPS_SMALL , dLen) ;
// ricavo il Frame associato a tale lunghezza
Frame3d frNext ;
if ( ! GetFrameAtLength( vRMFrames.back(), dLen, frNext))
return false ;
vRMFrames.emplace_back( frNext) ;
}
// passo al punto successivo
bPoint = PL.GetNextPoint( ptCurr) ;
}
return true ;
}
+44
View File
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : RotationMinimizeFrame.h Data : 05.03.24 Versione : 2.6c1
// Contenuto : Dichiarazione della classe RotationMinimizeFrame
//
//
//
// Modifiche : 05.03.24 RE Creazione modulo.
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkFrame3d.h"
#include "/EgtDev/Include/EGkCurve.h"
#include <vector>
//----------------------------------------------------------------------------
typedef std::vector<Frame3d> FRAME3DVECTOR ;
//----------------------------------------------------------------------------
class RotationMinimizeFrame
{
public :
RotationMinimizeFrame( const ICurve* pCrv, const Frame3d& fr_Start) ;
~RotationMinimizeFrame( void) ;
public :
bool GetFramesByStep( FRAME3DVECTOR& vRMFrames, double dStep, bool bUniform = false) ;
bool GetFramesBySplit( FRAME3DVECTOR& vRMFrames, int nIntervals) ;
bool GetFramesByTollerance( FRAME3DVECTOR& vRMFrames, double dTol) ;
private :
bool Clear( void) ;
bool IsValid( void) ;
bool GetFrameAtLength( const Frame3d& frAct, const double dLenNext, Frame3d& frNext) ;
private :
ICurve* m_pCrv ; // curva per il calcolo del rotation minimize frame
Frame3d m_Frame0 ; // frame iniziale della curva
} ;
+203 -181
View File
@@ -19,6 +19,7 @@
#include "SurfFlatRegion.h"
#include "AdjustLoops.h"
#include "GeoConst.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkPolyLine.h"
#include "/EgtDev/Include/EGkBiArcs.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
@@ -114,9 +115,11 @@ GetSurfFlatRegionDisk( double dRadius)
//-------------------------------------------------------------------------------
ISurfFlatRegion*
GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids)
GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids, double dOffsLinTol)
{
// mi impossesso della curva
// metodo di calcolo impostato da USE_VORONOI
// mi impossesso della curva
PtrOwner<ICurve> pCurve( pCrv) ;
if ( IsNull( pCurve))
return nullptr ;
@@ -124,200 +127,219 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
Vector3d vtExtr ; pCrv->GetExtrusion( vtExtr) ;
if ( vtExtr.IsSmall())
vtExtr = Z_AX ;
PtrOwner<CurveComposite> pCompo1 ;
if ( ! pCompo1.Set( ConvertCurveToBasicComposite( Release( pCurve))))
return nullptr ;
pCompo1->SetExtrusion( vtExtr) ;
// se distanza tra gli estremi minore di due volte il raggio la chiudo, purchè curva abbastanza lunga
Point3d ptStart, ptEnd, ptMid ;
Vector3d vtStart, vtEnd ;
pCompo1->GetStartPoint( ptStart) ;
pCompo1->GetStartDir( vtStart) ;
pCompo1->GetEndPoint( ptEnd) ;
pCompo1->GetEndDir( vtEnd) ;
pCompo1->GetMidPoint( ptMid) ;
if ( AreSamePointEpsilon( ptStart, ptEnd, 2 * dRadius) && Dist( ptStart, ptMid) > 2 * dRadius && Dist( ptEnd, ptMid) > 2 * dRadius) {
if ( AreSamePointEpsilon( ptStart, ptEnd, max( 0.1 * dRadius, 10 * EPS_SMALL))) {
Point3d ptNew = Media( ptStart, ptEnd) ;
pCompo1->ModifyStart( ptNew) ;
pCompo1->ModifyEnd( ptNew) ;
}
else {
// piano della curva
Frame3d frLoc ;
if ( ! AreSameVectorApprox( vtExtr, Z_AX))
frLoc.Set( ptStart, vtExtr) ;
// costruisco il biarco nel piano della curva
ptStart.ToLoc( frLoc) ;
ptEnd.ToLoc( frLoc) ;
Vector3d vtELoc( vtEnd) ; vtELoc.ToLoc( frLoc) ;
Vector3d vtSLoc( vtStart) ; vtSLoc.ToLoc( frLoc) ;
double dAngEnd ; vtELoc.ToSpherical( nullptr, nullptr, &dAngEnd) ;
double dAngStart ; vtSLoc.ToSpherical( nullptr, nullptr, &dAngStart) ;
PtrOwner<ICurve> pClose( GetBiArc( ptEnd, dAngEnd, ptStart, dAngStart, 0.5)) ;
// aggiungo il biarco
if ( ! IsNull( pClose)) {
// porto il biarco in globale
pClose->ToGlob( frLoc) ;
pCompo1->AddCurve( Release( pClose)) ;
}
else
pCompo1->Close() ;
}
}
// tipo di offset
int nOffsType = ( bSquareMids ? ICurve::OFF_EXTEND : ICurve::OFF_FILLET) ;
// se curva chiusa
if ( pCompo1->IsClosed()) {
// fondo le curve allineate
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
// ne faccio una copia e la inverto
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
if ( IsNull( pCompo2) || ! pCompo2->Invert())
return nullptr ;
// per creare la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
// offset della prima curva a destra del raggio
OffsetCurve OffsCrv1 ;
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
while ( pOffs1 != nullptr) {
SfrCntr.AddCurve( pOffs1) ;
pOffs1 = OffsCrv1.GetLongerCurve() ;
}
// offset della seconda curva a destra del raggio (è invertita rispetto alla precedente)
OffsetCurve OffsCrv2 ;
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
// ----------------- CALCOLO STANDARD --------------------------------
if ( ! USE_VORONOI) {
PtrOwner<CurveComposite> pCompo1 ;
if ( ! pCompo1.Set( ConvertCurveToBasicComposite( Release( pCurve))))
return nullptr ;
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
while ( pOffs2 != nullptr) {
SfrCntr.AddCurve( pOffs2) ;
pOffs2 = OffsCrv2.GetLongerCurve() ;
pCompo1->SetExtrusion( vtExtr) ;
// se distanza tra gli estremi minore di due volte il raggio la chiudo, purchè curva abbastanza lunga
Point3d ptStart, ptEnd, ptMid ;
Vector3d vtStart, vtEnd ;
pCompo1->GetStartPoint( ptStart) ;
pCompo1->GetStartDir( vtStart) ;
pCompo1->GetEndPoint( ptEnd) ;
pCompo1->GetEndDir( vtEnd) ;
pCompo1->GetMidPoint( ptMid) ;
if ( AreSamePointEpsilon( ptStart, ptEnd, 2 * dRadius) && Dist( ptStart, ptMid) > 2 * dRadius && Dist( ptEnd, ptMid) > 2 * dRadius) {
if ( AreSamePointEpsilon( ptStart, ptEnd, max( 0.1 * dRadius, 10 * EPS_SMALL))) {
Point3d ptNew = Media( ptStart, ptEnd) ;
pCompo1->ModifyStart( ptNew) ;
pCompo1->ModifyEnd( ptNew) ;
}
else {
// piano della curva
Frame3d frLoc ;
if ( ! AreSameVectorApprox( vtExtr, Z_AX))
frLoc.Set( ptStart, vtExtr) ;
// costruisco il biarco nel piano della curva
ptStart.ToLoc( frLoc) ;
ptEnd.ToLoc( frLoc) ;
Vector3d vtELoc( vtEnd) ; vtELoc.ToLoc( frLoc) ;
Vector3d vtSLoc( vtStart) ; vtSLoc.ToLoc( frLoc) ;
double dAngEnd ; vtELoc.ToSpherical( nullptr, nullptr, &dAngEnd) ;
double dAngStart ; vtSLoc.ToSpherical( nullptr, nullptr, &dAngStart) ;
PtrOwner<ICurve> pClose( GetBiArc( ptEnd, dAngEnd, ptStart, dAngStart, 0.5)) ;
// aggiungo il biarco
if ( ! IsNull( pClose)) {
// porto il biarco in globale
pClose->ToGlob( frLoc) ;
pCompo1->AddCurve( Release( pClose)) ;
}
else
pCompo1->Close() ;
}
}
// creo la regione
return SfrCntr.GetSurf() ;
}
// altrimenti
else {
// se richiesti estremi squadrati, la allungo del raggio alle due estremità
if ( bSquareEnds) {
pCompo1->ExtendStartByLen( dRadius) ;
pCompo1->ExtendEndByLen( dRadius) ;
}
// fondo le curve allineate
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
// ne faccio una copia e la inverto
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
if ( IsNull( pCompo2) || ! pCompo2->Invert())
return nullptr ;
// creo la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
// offset della prima curva a destra del raggio
OffsetCurve OffsCrv1 ;
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
if ( pOffs1 == nullptr)
return nullptr ;
pCompo1->Clear() ;
while ( pOffs1 != nullptr) {
if ( pOffs1->IsClosed())
// tipo di offset
int nOffsType = ( bSquareMids ? ICurve::OFF_EXTEND : ICurve::OFF_FILLET) ;
// se curva chiusa
if ( pCompo1->IsClosed()) {
// fondo le curve allineate
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
// ne faccio una copia e la inverto
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
if ( IsNull( pCompo2) || ! pCompo2->Invert())
return nullptr ;
// per creare la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
// offset della prima curva a destra del raggio
OffsetCurve OffsCrv1( dOffsLinTol) ;
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
while ( pOffs1 != nullptr) {
SfrCntr.AddCurve( pOffs1) ;
else
pCompo1->AddCurve( pOffs1) ;
pOffs1 = OffsCrv1.GetLongerCurve() ;
}
// offset della seconda curva a destra del raggio
OffsetCurve OffsCrv2 ;
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
if ( pOffs2 == nullptr)
return nullptr ;
pCompo2->Clear() ;
while ( pOffs2 != nullptr) {
if ( pOffs2->IsClosed())
pOffs1 = OffsCrv1.GetLongerCurve() ;
}
// offset della seconda curva a destra del raggio (è invertita rispetto alla precedente)
OffsetCurve OffsCrv2( dOffsLinTol) ;
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
while ( pOffs2 != nullptr) {
SfrCntr.AddCurve( pOffs2) ;
else
pCompo2->AddCurve( pOffs2) ;
pOffs2 = OffsCrv2.GetLongerCurve() ;
pOffs2 = OffsCrv2.GetLongerCurve() ;
}
// creo la regione
return SfrCntr.GetSurf() ;
}
// se estremi squadrati
if ( bSquareEnds) {
// aggiungo alla prima curva una linea che la unisca alla seconda
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
Point3d ptEnd1, ptStart2 ;
if ( IsNull( pLine) ||
! pCompo1->GetEndPoint( ptEnd1) ||
! pCompo2->GetStartPoint( ptStart2) ||
! pLine->Set( ptEnd1, ptStart2) ||
! pCompo1->AddCurve( Release( pLine)))
return nullptr ;
// unisco le due curve composite e le chiudo
if ( ! pCompo1->AddCurve( Release( pCompo2)) || ! pCompo1->Close())
return nullptr ;
}
// altrimenti estremi arrotondati
// altrimenti
else {
// aggiungo alla prima curva un arco che la unisca alla seconda
PtrOwner<CurveArc> pArc1( CreateBasicCurveArc()) ;
Point3d ptEnd1, ptStart2 ;
Vector3d vtEnd1, vtStart2 ;
if ( IsNull( pArc1) ||
! pCompo1->GetEndPoint( ptEnd1) ||
! pCompo1->GetEndDir( vtEnd1) ||
! pCompo2->GetStartPoint( ptStart2) ||
! pCompo2->GetStartDir( vtStart2))
// se richiesti estremi squadrati, la allungo del raggio alle due estremità
if ( bSquareEnds) {
pCompo1->ExtendStartByLen( dRadius) ;
pCompo1->ExtendEndByLen( dRadius) ;
}
// fondo le curve allineate
pCompo1->MergeCurves( LIN_TOL_FINE, ANG_TOL_STD_DEG) ;
// ne faccio una copia e la inverto
PtrOwner<CurveComposite> pCompo2( pCompo1->Clone()) ;
if ( IsNull( pCompo2) || ! pCompo2->Invert())
return nullptr ;
// verifico se arco tangente alla prima o alla seconda curva
if ( AreSameVectorApprox( vtEnd1, vtEnd)) {
if ( ! pArc1->Set2PVN( ptEnd1, ptStart2, vtEnd1, vtExtr) ||
! pCompo1->AddCurve( Release( pArc1)))
// creo la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
// offset della prima curva a destra del raggio
OffsetCurve OffsCrv1( dOffsLinTol) ;
if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ;
if ( pOffs1 == nullptr)
return nullptr ;
pCompo1->Clear() ;
while ( pOffs1 != nullptr) {
if ( pOffs1->IsClosed())
SfrCntr.AddCurve( pOffs1) ;
else
pCompo1->AddCurve( pOffs1) ;
pOffs1 = OffsCrv1.GetLongerCurve() ;
}
// offset della seconda curva a destra del raggio
OffsetCurve OffsCrv2( dOffsLinTol) ;
if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType))
return nullptr ;
ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ;
if ( pOffs2 == nullptr)
return nullptr ;
pCompo2->Clear() ;
while ( pOffs2 != nullptr) {
if ( pOffs2->IsClosed())
SfrCntr.AddCurve( pOffs2) ;
else
pCompo2->AddCurve( pOffs2) ;
pOffs2 = OffsCrv2.GetLongerCurve() ;
}
// se estremi squadrati
if ( bSquareEnds) {
// aggiungo alla prima curva una linea che la unisca alla seconda
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
Point3d ptEnd1, ptStart2 ;
if ( IsNull( pLine) ||
! pCompo1->GetEndPoint( ptEnd1) ||
! pCompo2->GetStartPoint( ptStart2) ||
! pLine->Set( ptEnd1, ptStart2) ||
! pCompo1->AddCurve( Release( pLine)))
return nullptr ;
// unisco le due curve composite e le chiudo
if ( ! pCompo1->AddCurve( Release( pCompo2)) || ! pCompo1->Close())
return nullptr ;
}
// altrimenti estremi arrotondati
else {
if ( ! pArc1->Set2PVN( ptStart2, ptEnd1, -vtStart2, vtExtr) ||
! pArc1->Invert() ||
! pCompo1->AddCurve( Release( pArc1)))
// aggiungo alla prima curva un arco che la unisca alla seconda
PtrOwner<CurveArc> pArc1( CreateBasicCurveArc()) ;
Point3d ptEnd1, ptStart2 ;
Vector3d vtEnd1, vtStart2 ;
if ( IsNull( pArc1) ||
! pCompo1->GetEndPoint( ptEnd1) ||
! pCompo1->GetEndDir( vtEnd1) ||
! pCompo2->GetStartPoint( ptStart2) ||
! pCompo2->GetStartDir( vtStart2))
return nullptr ;
// verifico se arco tangente alla prima o alla seconda curva
if ( AreSameVectorApprox( vtEnd1, vtEnd)) {
if ( ! pArc1->Set2PVN( ptEnd1, ptStart2, vtEnd1, vtExtr) ||
! pCompo1->AddCurve( Release( pArc1)))
return nullptr ;
}
else {
if ( ! pArc1->Set2PVN( ptStart2, ptEnd1, -vtStart2, vtExtr) ||
! pArc1->Invert() ||
! pCompo1->AddCurve( Release( pArc1)))
return nullptr ;
}
// aggiungo alla seconda curva un arco che la unisca alla prima
PtrOwner<CurveArc> pArc2( CreateBasicCurveArc()) ;
Point3d ptEnd2, ptStart1 ;
Vector3d vtEnd2, vtStart1 ;
if ( IsNull( pArc2) ||
! pCompo2->GetEndPoint( ptEnd2) ||
! pCompo2->GetEndDir( vtEnd2) ||
! pCompo1->GetStartPoint( ptStart1) ||
! pCompo1->GetStartDir( vtStart1))
return nullptr ;
// verifico se arco tangente alla seconda o alla prima curva
if ( AreOppositeVectorApprox( vtEnd2, vtStart)) {
if ( ! pArc2->Set2PVN( ptEnd2, ptStart1, vtEnd2, vtExtr) ||
! pCompo2->AddCurve( Release( pArc2)))
return nullptr ;
}
else {
if ( ! pArc2->Set2PVN( ptStart1, ptEnd2, -vtStart1, vtExtr) ||
! pArc2->Invert() ||
! pCompo2->AddCurve( Release( pArc2)))
return nullptr ;
}
// unisco le due curve composite
if ( ! pCompo1->AddCurve( Release( pCompo2)))
return nullptr ;
}
// aggiungo alla seconda curva un arco che la unisca alla prima
PtrOwner<CurveArc> pArc2( CreateBasicCurveArc()) ;
Point3d ptEnd2, ptStart1 ;
Vector3d vtEnd2, vtStart1 ;
if ( IsNull( pArc2) ||
! pCompo2->GetEndPoint( ptEnd2) ||
! pCompo2->GetEndDir( vtEnd2) ||
! pCompo1->GetStartPoint( ptStart1) ||
! pCompo1->GetStartDir( vtStart1))
return nullptr ;
// verifico se arco tangente alla seconda o alla prima curva
if ( AreOppositeVectorApprox( vtEnd2, vtStart)) {
if ( ! pArc2->Set2PVN( ptEnd2, ptStart1, vtEnd2, vtExtr) ||
! pCompo2->AddCurve( Release( pArc2)))
return nullptr ;
}
else {
if ( ! pArc2->Set2PVN( ptStart1, ptEnd2, -vtStart1, vtExtr) ||
! pArc2->Invert() ||
! pCompo2->AddCurve( Release( pArc2)))
return nullptr ;
}
// unisco le due curve composite
if ( ! pCompo1->AddCurve( Release( pCompo2)))
return nullptr ;
SfrCntr.AddCurve( Release( pCompo1)) ;
return SfrCntr.GetSurf() ;
}
SfrCntr.AddCurve( Release( pCompo1)) ;
return SfrCntr.GetSurf() ;
}
// ---------------------- CALCOLO CON VORONOI ------------------------------------
else {
// calcolo la fat curve con Voronoi
ICURVEPOVECTOR vFatCurves ;
if ( ! CalcCurveFatCurve( *pCurve, vFatCurves, dRadius, bSquareEnds, bSquareMids))
return nullptr ;
// costruisco la superficie a partire dalle curve
SurfFlatRegionByContours SfrCntr( false, false) ;
for ( int i = 0 ; i < ( int)vFatCurves.size() ; i++)
SfrCntr.AddCurve( Release( vFatCurves[i])) ;
return SfrCntr.GetSurf() ;
}
}
//----------------------------------------------------------------------------
+591 -95
View File
@@ -1,4 +1,4 @@
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : StmFromCurves.cpp Data : 01.02.15 Versione : 1.6b1
@@ -18,13 +18,17 @@
#include "CurveArc.h"
#include "CurveComposite.h"
#include "SurfTriMesh.h"
#include "Voronoi.h"
#include "RotationMinimizeFrame.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include <algorithm>
#include <thread>
#include <future>
#include <EgtDev/Include/EGkIntersCurves.h>
using namespace std ;
@@ -108,9 +112,9 @@ GetSurfTriMeshByExtrusion( const ICurve* pCurve, const Vector3d& vtExtr,
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByExtrusion( PL, vtExtr))
return nullptr ;
// se da fare, metto i tappi sulle estremità
// se da fare, metto i tappi sulle estremità
if ( bDoCapEnds) {
// creo la prima superficie di estremità
// creo la prima superficie di estremità
SurfTriMesh STM1 ;
if ( ! STM1.CreateByFlatContour( PL))
return nullptr ;
@@ -154,7 +158,7 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d&
for ( int i = 0 ; i < int( vPL.size()) ; ++ i)
vPL[i].Invert() ;
}
// creo la prima superficie di estremità
// creo la prima superficie di estremità
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL))
return nullptr ;
@@ -242,7 +246,7 @@ GetSurfTriMeshByRevolve( const ICurve* pCurve, const Point3d& ptAx, const Vector
PL.Invert() ;
}
// creo e setto la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, ANG_FULL, dStepRotDeg, 0))
return nullptr ;
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
@@ -281,12 +285,12 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
return nullptr ;
}
// creo e setto la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, dAngRotDeg, dStepRotDeg, dMove))
return nullptr ;
// se richiesti caps
if ( bCapEnds) {
// determino se la sezione è chiusa e piatta
// determino se la sezione è chiusa e piatta
Plane3d plPlane ; double dArea ;
bool bSectClosedFlat = PL.IsClosedAndFlat( plPlane, dArea, 10 * EPS_SMALL) ;
// determino non sia una semplice rivoluzione
@@ -294,7 +298,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
// se sezione chiusa e piatta e non rivoluzione, posso aggiungere i tappi
if ( bSectClosedFlat && ! bRevolved) {
// aggiungo il cap sull'inizio
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
return nullptr ;
pSTM->DoSewing( *pSci) ;
@@ -304,7 +308,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto
vtMove *= dMove ;
PL.Translate( vtMove) ;
PL.Rotate( ptAx, vtAx, dAngRotDeg) ;
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
return nullptr ;
pSce->Invert() ;
@@ -330,7 +334,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
return nullptr ;
Vector3d vtNorm = plGuide.GetVersN() ;
// determino se la guida è chiusa
// determino se la guida è chiusa
bool bGuideClosed = pGuide->IsClosed() ;
// curve di offset
OffsetCurve OffsCrvR ;
@@ -345,8 +349,6 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
PtrOwner<ICurve> pCrvL( OffsCrvL.GetLongerCurve()) ;
if ( IsNull( pCrvL))
return nullptr ;
PtrOwner<ICurve> pCrvRb ;
PtrOwner<ICurve> pCrvLb ;
// costruisco le parti di superficie
PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
if ( IsNull( pSrfTop))
@@ -373,7 +375,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
pSTM->SetSmoothAngle( 20) ;
// se guida aperta e tappi piatti
if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
// verifico che le due estremità siano chiuse e piatte
// verifico che le due estremità siano chiuse e piatte
POLYLINEVECTOR vPL ;
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
return nullptr ;
@@ -383,13 +385,13 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
return nullptr ;
// aggiungo il cap sull'inizio
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
return nullptr ;
pSci->Invert() ;
pSTM->DoSewing( *pSci) ;
// aggiungo il cap sulla fine
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
return nullptr ;
pSce->Invert() ;
@@ -410,7 +412,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
PLStart.AddUPoint( 1, ptStart + dDimH / 2 * vtStart) ;
PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dDimV * vtNorm) ;
PLStart.AddUPoint( 3, ptStart - dDimV * vtNorm) ;
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
return nullptr ;
pSci->Invert() ;
@@ -426,7 +428,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
PLEnd.AddUPoint( 1, ptEnd + dDimH / 2 * vtEnd) ;
PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dDimV * vtNorm) ;
PLEnd.AddUPoint( 3, ptEnd - dDimV * vtNorm) ;
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
return nullptr ;
pSce->Invert() ;
@@ -440,6 +442,8 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
static ISurfTriMesh*
GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol)
{
// metodo di calcolo impostato da USE_VORONOI
// verifico che la linea guida sia piana
Plane3d plGuide ;
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
@@ -450,25 +454,34 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
Point3d ptCen ;
pGuide->GetStartPoint( ptCen) ;
ptCen -= dDimV / 2 * vtNorm ;
// determino se la guida è chiusa
// determino se la guida è chiusa
bool bGuideClosed = pGuide->IsClosed() ;
// curve di offset
const int NUM_OFFS = 4 ;
OffsetCurve vOffsCrv[NUM_OFFS] ;
double vDist[NUM_OFFS] = { dDimH / 2 - dBevelH, -dDimH / 2 + dBevelH, dDimH / 2, -dDimH / 2} ;
future<bool> vRes[NUM_OFFS] ;
for ( int i = 0 ; i < NUM_OFFS ; ++ i)
vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ;
bool bOk = true ;
int nFin = 0 ;
while ( nFin < NUM_OFFS) {
for ( int i = 0 ; i < NUM_OFFS ; ++ i) {
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
bOk = vRes[i].get() && bOk ;
++ nFin ;
if ( ! USE_VORONOI) {
future<bool> vRes[NUM_OFFS] ;
for ( int i = 0 ; i < NUM_OFFS ; ++ i)
vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ;
bool bOk = true ;
int nFin = 0 ;
while ( nFin < NUM_OFFS) {
for ( int i = 0 ; i < NUM_OFFS ; ++ i) {
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
bOk = vRes[i].get() && bOk ;
++ nFin ;
}
}
}
}
}
else {
// se Voronoi non è possibile calcolare gli offset di una stessa curva in parallelo
for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i)
bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ;
}
if ( ! bOk ||
vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 ||
vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0)
@@ -541,7 +554,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
StmFromTriangleSoup stmCapSoup ;
if ( ! stmCapSoup.Start( nBuckets))
return nullptr ;
// verifico che le due estremità siano chiuse e piatte
// verifico che le due estremità siano chiuse e piatte
POLYLINEVECTOR vPL ;
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
return nullptr ;
@@ -551,12 +564,12 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
return nullptr ;
// calcolo il cap sull'inizio
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
return nullptr ;
pSci->Invert() ;
// calcolo il cap sulla fine
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
return nullptr ;
pSce->Invert() ;
@@ -581,7 +594,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
PLStart.AddUPoint( 3, ptStart + dDimH / 2 * vtStart - ( dDimV - dBevelV) * vtNorm) ;
PLStart.AddUPoint( 4, ptStart + ( dDimH / 2 - dBevelH) * vtStart - dDimV * vtNorm) ;
PLStart.AddUPoint( 5, ptStart - dDimV * vtNorm) ;
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
return nullptr ;
pSci->Invert() ;
@@ -599,7 +612,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
PLEnd.AddUPoint( 3, ptEnd + dDimH / 2 * vtEnd - ( dDimV - dBevelV) * vtNorm) ;
PLEnd.AddUPoint( 4, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd - dDimV * vtNorm) ;
PLEnd.AddUPoint( 5, ptEnd - dDimV * vtNorm) ;
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
return nullptr ;
pSce->Invert() ;
@@ -640,46 +653,286 @@ GetSurfTriMeshRectSwept( double dDimH, double dDimV, double dBevelH, double dBev
//-------------------------------------------------------------------------------
ISurfTriMesh*
GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol)
GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol, Vector3d* vtStatic)
{
// verifica parametri
if ( pSect == nullptr || pGuide == nullptr)
return nullptr ;
// calcolo la polilinea che approssima la sezione
PolyLine PL ;
if ( ! pSect->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
return nullptr ;
// determino se la sezione è chiusa
// determino se la sezione è chiusa
bool bSectClosed = PL.IsClosed() ;
// determino se la guida è chiusa
bool bGuideClosed = pGuide->IsClosed() ;
// definisco la superficie da restituire ( definendo la sua tolleranza )
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM))
return nullptr ;
pSTM->SetLinearTolerance( dLinTol) ;
// calcolo punto e versore tangente iniziale
Point3d ptStart ; pGuide->GetStartPoint( ptStart) ;
Vector3d vtStart ; pGuide->GetStartDir( vtStart) ;
// inizializzazione del frame iniziale ( viene definito a seconda dei casi )
Frame3d frStart ;
/* GUIDA PIANA */
// verifico che la linea guida sia piana
Plane3d plGuide ;
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
return nullptr ;
// determino se la guida è chiusa
bool bGuideClosed = pGuide->IsClosed() ;
// riferimento all'inizio della linea guida
Frame3d frStart ;
Point3d ptStart ;
pGuide->GetStartPoint( ptStart) ;
Vector3d vtStart ;
pGuide->GetStartDir( vtStart) ;
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL)) {
/*
La guida non è piana, l'estrusione può essere definita mediante :
( 1) un versore statico
( 2) mediante l'algoritmo del Rotation Minimize Frame
*/
// recupero la sezione dalla PolyLine approssimata come Curva
PtrOwner<CurveComposite> pSecLocApprox( CreateBasicCurveComposite()) ;
if ( IsNull( pSecLocApprox) ||
! pSecLocApprox->FromPolyLine( PL) ||
! pSecLocApprox->IsValid())
return nullptr ;
// recupero il frame iniziale sulla guida ( Origine sul punto iniziale e asse Z tangente )
frStart.Set( ptStart, vtStart) ;
if ( ! frStart.IsValid())
return nullptr ;
// tengo in memoria il frame nel punto iniziale e finale della guida in caso di caps
Frame3d frCaps_start ;
Frame3d frCaps_end ;
if ( vtStatic != nullptr) { // (1) versore statico
// creo il piano di proiezione con normale definita dal vettore
Plane3d plProj ;
plProj.Set( ORIG, *vtStatic) ;
if ( ! plProj.IsValid())
return nullptr ;
// porto la sezione nel frame definito dalla guida, tenendo il versore X del frame nel piano
// definito da vtStatic
Vector3d vtX = vtStart ; // versore tangente alla curva
vtX.Rotate( *vtStatic, 90) ; // ruoto di 90 gradi rispetto a vtStatic
OrthoCompo( vtX, *vtStatic) ; // tengo la componente nel piano
vtX.Normalize() ; // normalizzo
Frame3d frInitial ; frInitial.Set( ptStart, vtStart, vtX) ; // creo il frame
if ( ! frInitial.IsValid())
return nullptr ;
// porto la sezione nel riferimento
pSecLocApprox->ToLoc( frInitial) ;
PL.ToLoc( frInitial) ; //... porto anche la PolyLine del bordo della sezione
// approssimo la guida mediante la tolleranza richiesta
PolyLine PL_G ;
if ( ! pGuide->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL_G))
return nullptr ;
// punto attuale e punto successivo sulla guida su cui definire il frame
Point3d ptCurr, ptSucc ;
if ( ! PL_G.GetFirstPoint( ptCurr))
return nullptr ;
bool bNextPoint = PL_G.GetNextPoint( ptSucc) ;
if ( ! bNextPoint)
return nullptr ;
// parametro attuale e successivo riferito ai punti sulla guida
double dParCurr = 0 ;
double dParSucc ;
// versore attuale e successivo riferito ai punti sulla guida
Vector3d vtTanCurr, vtTanSucc ;
if ( ! pGuide->GetStartDir( vtTanCurr))
return nullptr ;
// frame iniziale e successivo riferito alla curva
Frame3d frCurr, frSucc ;
bool bFirstIter = true ; // per salvare il frame iniziale nel caso di caps
while ( bNextPoint) { // finchè recupero un punto sucessivo...
// recupero il parametro successivo riferito alla guida
if ( ! pGuide->GetParamAtPoint( ptSucc, dParSucc))
return nullptr ;
// recupero il versore tangente riferito al punto successivo sulla guida
if ( ! pGuide->GetPointD1D2( dParSucc, ICurve::FROM_MINUS, ptSucc, &vtTanSucc) ||
! vtTanSucc.Normalize())
return nullptr ;
// creazione del frame nel punto corrente
Vector3d vtX_curr = vtTanCurr ;
vtX_curr.Rotate( *vtStatic, 90) ;
OrthoCompo( vtX_curr, *vtStatic) ;
vtX_curr.Normalize() ;
frCurr.Set( ptCurr, vtTanCurr, vtX_curr) ;
if ( ! frCurr.IsValid())
return nullptr ;
// memorizzo il primo frame di caso di caps
if ( bFirstIter) {
frCaps_start = frCurr ;
bFirstIter = false ;
}
// creazione del frame nel punto successivo
Vector3d vtX_succ = vtTanSucc ;
vtX_succ.Rotate( *vtStatic, 90) ;
OrthoCompo( vtX_curr, *vtStatic) ;
vtX_succ.Normalize() ;
frSucc.Set( ptSucc, vtTanSucc, vtX_succ) ;
if ( ! frSucc.IsValid())
return nullptr ;
frCaps_end = frSucc ; // aggiorno il frame finale ad ogni step
// definisco la sezione allo step corrente
PtrOwner<ICurve> pSecCurr( pSecLocApprox->Clone()) ;
if ( IsNull( pSecCurr) || ! pSecCurr->IsValid())
return nullptr ;
// considero la sezione ( in locale ) come vista dal globale
if ( ! pSecCurr->ToGlob( frCurr))
return nullptr ;
// definisco la sezione allo step successivo
PtrOwner<ICurve> pSecSucc( pSecLocApprox->Clone()) ;
if ( IsNull( pSecSucc) || ! pSecSucc->IsValid())
return nullptr ;
// considero la sezione ( in locale ) come vista dal globale
if ( ! pSecSucc->ToGlob( frSucc))
return nullptr ;
// creo la rigata tra queste due sezioni
PtrOwner<ISurfTriMesh> pSr( GetSurfTriMeshRuled( pSecCurr, pSecSucc, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
if ( IsNull( pSr) || ! pSr->IsValid())
return nullptr ;
// attacco la rigata alla superficie da restituire
pSTM->DoSewing( *pSr) ;
// aggiornamento dei parametri
ptCurr = ptSucc ; // il punto corrente diventa il successivo
bNextPoint = PL_G.GetNextPoint( ptSucc) ; // il successivo lo recupero dalla PolyLine
vtTanCurr = vtTanSucc ; // il versore tangete corrente diventa il successivo
}
// la superficie definita dal RMF è invertita, il versore Z è diretto come la tangente della curva
pSTM->Invert() ;
}
else { // (2) Rotation Minimize Frame
// porto la PolyLine e la curva della sezione nel riferimento nel punto iniziale della guida
pSecLocApprox->ToLoc( frStart) ;
PL.ToLoc( frStart) ;
// calcolo il vettore di Frames campionati lungo la guida mediante la tolleranza definita
RotationMinimizeFrame RMF( pGuide, frStart) ;
FRAME3DVECTOR vRMF ;
if ( ! RMF.GetFramesByTollerance( vRMF, dLinTol) || vRMF.empty())
return nullptr ;
// per ogni RMF calcolato, la sezione va roto-traslata lungo la guida
for ( int i = 0 ; i < int( vRMF.size()) - 1 ; ++ i) {
// definisco la sezione allo step corrente
PtrOwner<ICurve> pSecCurr( pSecLocApprox->Clone()) ;
if ( IsNull( pSecCurr) || ! pSecCurr->IsValid())
return nullptr ;
// considero la sezione ( in locale ) come vista dal globale
if ( ! pSecCurr->ToGlob( vRMF[i]))
return nullptr ;
// definisco la sezione allo step successivo
PtrOwner<ICurve> pSecSucc( pSecLocApprox->Clone()) ;
if ( IsNull( pSecSucc) || ! pSecSucc->IsValid())
return nullptr ;
// considero la sezione ( in locale ) come vista dal globale
if ( ! pSecSucc->ToGlob( vRMF[i+1]))
return nullptr ;
// creo la rigata tra queste due sezioni
PtrOwner<ISurfTriMesh> pSr( GetSurfTriMeshRuled( pSecCurr, pSecSucc, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
if ( IsNull( pSr) || ! pSr->IsValid())
return nullptr ;
// attacco la rigata alla superficie da restituire
pSTM->DoSewing( *pSr) ;
}
// la superficie definita dal RMF è invertita, il versore Z è diretto come la tangente della curva
pSTM->Invert() ;
// assegno frame iniziale e finale per caps
frCaps_start = vRMF[0] ;
frCaps_end = vRMF.back() ;
}
// se richiesti caps e sezione chiusa e guida aperta
// (1) vtStatic, (2) Rotation Minimize Frame
if ( bCapEnds && bSectClosed && ! bGuideClosed) {
// aggiungo il cap sull'inizio ( portandolo nel frame del punto iniziale della guida )
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
return nullptr ;
pSci->ToGlob( frCaps_start) ;
// unisco
pSTM->DoSewing( *pSci) ;
// aggiungo il cap sulla fine ( portandolo nel frame del punto finale della guida )
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
return nullptr ;
pSce->ToGlob( frCaps_end) ;
pSce->Invert() ; // il versore z è definito dalle tangenti alla curva
// unisco
pSTM->DoSewing( *pSce) ;
}
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
double dVol ;
if ( pSTM->GetVolume( dVol) && dVol < 0)
pSTM->Invert() ;
// restituisco la superficie
return Release( pSTM) ;
}
/*
GUIDA PIANA
La guida è piana, l'estrusione viene definita mediante Offset della guida sulla sezione
*/
// il frame iniziale è definito dal versore tangente e dalla normale al piano
// che contiene la guida
Vector3d vtNorm = plGuide.GetVersN() ;
frStart.Set( ptStart, -vtStart, vtStart ^ vtNorm) ;
// porto la sezione in questo riferimento e ve la appiattisco
if ( ! PL.ToLoc( frStart) || ! PL.Flatten())
return nullptr ;
// calcolo la superficie
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
if ( IsNull( pSTM))
return nullptr ;
// salvo tolleranza lineare usata
pSTM->SetLinearTolerance( dLinTol) ;
// superficie swept
PtrOwner<ICurve> pPrevCrv ;
Point3d ptP ;
bool bPoint = PL.GetFirstPoint( ptP) ;
while ( bPoint) {
// nuova curva
// nuova curva ( definita dall'Offset )
OffsetCurve OffsCrv ;
if ( ! OffsCrv.Make( pGuide, ptP.x, ICurve::OFF_FILLET) || OffsCrv.GetCurveCount() == 0)
return nullptr ;
@@ -687,21 +940,28 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
if ( IsNull( pCurrCrv))
return nullptr ;
pCurrCrv->Translate( ptP.y * frStart.VersY()) ;
// se esiste la curva precedente, costruisco la rigata (di tipo minima distanza)
// se esiste la curva precedente, costruisco la rigata ( di tipo minima distanza)
if ( ! IsNull( pPrevCrv)) {
PtrOwner<ISurfTriMesh> pSr( GetSurfTriMeshRuled( pPrevCrv, pCurrCrv, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
if ( IsNull( pSr))
return nullptr ;
// unisco
pSTM->DoSewing( *pSr) ;
}
// salvo la curva come prossima precedente
pPrevCrv.Set( pCurrCrv) ;
// prossimo punto
bPoint = PL.GetNextPoint( ptP) ;
}
// se richiesti caps e sezione chiusa e guida aperta
if ( bCapEnds && bSectClosed && ! bGuideClosed) {
// verifico che le due estremità siano chiuse e piatte
// verifico che le due estremità siano chiuse e piatte
POLYLINEVECTOR vPL ;
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
return nullptr ;
@@ -710,12 +970,16 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
return nullptr ;
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
return nullptr ;
// aggiungo il cap sull'inizio
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
return nullptr ;
pSci->ToGlob( frStart) ;
// unisco
pSTM->DoSewing( *pSci) ;
// riferimento alla fine della linea guida
Frame3d frEnd ;
Point3d ptEnd ;
@@ -723,14 +987,170 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
Vector3d vtEnd ;
pGuide->GetEndDir( vtEnd) ;
frEnd.Set( ptEnd, -vtEnd, vtEnd ^ vtNorm) ;
// aggiungo il cap sulla fine
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
return nullptr ;
pSce->Invert() ;
pSce->ToGlob( frEnd) ;
// unisco
pSTM->DoSewing( *pSce) ;
}
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
double dVol ;
if ( pSTM->GetVolume( dVol) && dVol < 0)
pSTM->Invert() ;
// restituisco la superficie
return Release( pSTM) ;
}
//-------------------------------------------------------------------------------
ISurfTriMesh*
GetSurfTriMeshSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, bool bCapEnds,
double dLinTol, Vector3d* vtStatic)
{
// verifica dei parametri
if ( pSfrSect == nullptr || pGuide == nullptr)
return nullptr ;
// creo la Trimesh da restituire
PtrOwner<ISurfTriMesh> pStmSwept( CreateBasicSurfTriMesh()) ;
if ( IsNull( pStmSwept) || ! pStmSwept->AdjustTopology())
return nullptr ;
StmFromTriangleSoup StmSoup ;
StmSoup.Start() ;
// per ogni loop della superficie, creo una Swept
for ( int c = 0 ; c < pSfrSect->GetChunkCount() ; ++ c) {
for ( int l = 0 ; l < pSfrSect->GetLoopCount( c) ; ++ l) {
// recupero il loop
PtrOwner<ICurve> pCrvLoop( pSfrSect->GetLoop( c, l)) ;
if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
return nullptr ;
// creo la Trimesh Swept
PtrOwner<ISurfTriMesh> pStmLoopSwept( GetSurfTriMeshSwept( pCrvLoop, pGuide, false, dLinTol, vtStatic)) ;
if ( IsNull( pStmLoopSwept) || ! pStmLoopSwept->IsValid())
return nullptr ;
// aggiungo la Swept ricavata al risultato finale ( come triangoli )
StmSoup.AddSurfTriMesh( *pStmLoopSwept) ;
}
}
StmSoup.End() ;
if ( ! pStmSwept.Set( StmSoup.GetSurf()) || IsNull( pStmSwept) ||
! pStmSwept->IsValid() || ! pStmSwept->AdjustTopology())
return nullptr ;
// se rischista chiusura...
// NB. Controllo solo che al guida non sia chiusa, la sezione derivando da una Flatregion è chiusa per
// definizione
if ( bCapEnds && ! pGuide->IsClosed()) {
// creo il cap sull'inizio e lo attacco alla swept ( è già in posizione giusta )
PtrOwner<ISurfTriMesh> pSci( pSfrSect->GetAuxSurf()->Clone()) ;
if ( IsNull( pSci) || ! pSci->IsValid())
return nullptr ;
pStmSwept->DoSewing( *pSci) ;
// recupero i loops alla fine
POLYLINEVECTOR vPL ;
if ( ! pStmSwept->GetLoops( vPL))
return nullptr ;
// creo la superficie alla fine e la attacco
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
if ( ! pSce->CreateByRegion( vPL))
return nullptr ;
// attacco la superficie finale alla swept
pSce->Invert() ;
pStmSwept->DoSewing( *pSce) ;
}
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
double dVol ;
if ( pStmSwept->GetVolume( dVol) && dVol < 0)
pStmSwept->Invert() ;
return Release( pStmSwept) ;
}
//-------------------------------------------------------------------------------
ISurfTriMesh*
GetSurfTriMeshTransSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol)
{
// verifica parametri
if ( pSect == nullptr || pGuide == nullptr)
return nullptr ;
// determino se la sezione è chiusa
bool bSectClosed = pSect->IsClosed() ;
// punto iniziale della sezione e vettore a inizio guida
Point3d ptStart ;
if ( ! pSect->GetStartPoint( ptStart))
return nullptr ;
Point3d ptGuide ;
if ( ! pGuide->GetStartPoint( ptGuide))
return nullptr ;
Vector3d vtDelta = ptStart - ptGuide ;
// calcolo la polilinea che approssima la guida
PolyLine PLG ;
if ( ! pGuide->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLG))
return nullptr ;
// determino se la guida è chiusa
bool bGuideClosed = PLG.IsClosed() ;
// calcolo la superficie
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM))
return nullptr ;
// salvo tolleranza lineare usata
pSTM->SetLinearTolerance( dLinTol) ;
// superficie swept
PtrOwner<ICurve> pPrevCrv ;
Point3d ptP ;
bool bPoint = PLG.GetFirstPoint( ptP) ;
while ( bPoint) {
// nuova curva
PtrOwner<ICurve> pCurrCrv( pSect->Clone()) ;
if ( IsNull( pCurrCrv))
return nullptr ;
pCurrCrv->Translate( ptP - ptStart + vtDelta) ;
// se esiste la curva precedente, costruisco la rigata (di tipo minima distanza)
if ( ! IsNull( pPrevCrv)) {
PtrOwner<ISurfTriMesh> pSr( GetSurfTriMeshRuled( pPrevCrv, pCurrCrv, ISurfTriMesh::RLT_ISOPAR, dLinTol)) ;
if ( IsNull( pSr))
return nullptr ;
pSTM->DoSewing( *pSr) ;
}
// salvo la curva come prossima precedente
pPrevCrv.Set( pCurrCrv) ;
// prossimo punto
bPoint = PLG.GetNextPoint( ptP) ;
}
// se richiesti caps e sezione chiusa e guida aperta
if ( bCapEnds && bSectClosed && ! bGuideClosed) {
// calcolo la polilinea che approssima la sezione
PolyLine PLS ;
if ( ! pSect->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLS))
return nullptr ;
// verifico che la sezione sia chiusa e piatta
Plane3d plSect ; double dArea ;
if ( PLS.IsClosedAndFlat( plSect, dArea, 100 * EPS_SMALL)) {
// aggiungo il cap sull'inizio
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PLS))
return nullptr ;
pSci->Invert() ;
Point3d ptGi ; PLG.GetFirstPoint( ptGi) ;
pSci->Translate( ptGi - ptStart + vtDelta) ;
pSTM->DoSewing( *pSci) ;
// aggiungo il cap sulla fine
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PLS))
return nullptr ;
Point3d ptGe ; PLG.GetLastPoint( ptGe) ;
pSce->Translate( ptGe - ptStart + vtDelta) ;
pSTM->DoSewing( *pSce) ;
}
}
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
double dVol ;
if ( pSTM->GetVolume( dVol) && dVol < 0)
@@ -751,7 +1171,7 @@ GetSurfTriMeshRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol)
if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
return nullptr ;
// creo e setto la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByPointCurve( ptP, PL))
return nullptr ;
// salvo tolleranza lineare usata
@@ -776,7 +1196,7 @@ GetSurfTriMeshRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, do
if ( ! pCurve2->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL2))
return nullptr ;
// creo e setto la superficie trimesh
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByTwoCurves( PL1, PL2, nType))
return nullptr ;
// salvo tolleranza lineare usata
@@ -790,56 +1210,132 @@ bool
CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
POLYLINEVECTOR& vPL, Vector3d& vtN)
{
// se non ho curve, non faccio nulla
if ( int( vpCurve.size()) == 0)
return true ;
// calcolo le polilinee che approssimano le curve
POLYLINEVECTOR vPLtmp ;
vPLtmp.resize( vpCurve.size()) ;
vPL.resize( vpCurve.size()) ;
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPLtmp[i]))
if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPL[i]))
return false ;
}
// ne calcolo l'area e genero un ordine in senso decrescente
typedef pair<int,double> INDAREA ; // coppia indice, area
typedef vector<INDAREA> INDAREAVECTOR ; // vettore di coppie indice, area
INDAREAVECTOR vArea ;
vArea.reserve( vPLtmp.size()) ;
Vector3d vtN0 ;
for ( int i = 0 ; i < int( vPLtmp.size()) ; ++ i) {
// verifico chiusura, calcolo piano medio e area
// ricavo versore normale
Plane3d plPlane ; double dArea ;
if ( ! vPL[0].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
return false ;
vtN = plPlane.GetVersN() ;
typedef std::pair<int,double> INDAREA ;
std::vector<INDAREA> m_vArea ;
// calcolo piano medio e area delle curve
m_vArea.reserve( vPL.size()) ;
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
// calcolo piano medio e area
Plane3d plPlane ;
double dArea ;
if ( ! vPLtmp[i].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea))
return false ;
// imposto la normale del primo contorno come riferimento
if ( i == 0)
vtN0 = plPlane.GetVersN() ;
// verifico che le normali siano molto vicine
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN0))
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN))
return false ;
// assegno il segno all'area secondo il verso della normale
if ( ( plPlane.GetVersN() * vtN0) > 0)
vArea.emplace_back( i, dArea) ;
if ( ( plPlane.GetVersN() * vtN) > 0)
m_vArea.emplace_back( i, dArea) ;
else
vArea.emplace_back( i, - dArea) ;
m_vArea.emplace_back( i, - dArea) ;
}
sort( vArea.begin(), vArea.end(),
// ordino in senso decrescente sull'area
sort( m_vArea.begin(), m_vArea.end(),
[]( const INDAREA& a, const INDAREA& b) { return ( abs( a.second) > abs( b.second)) ; }) ;
// sposto le polilinee nel vettore da restituire secondo l'ordine
vPL.clear() ;
vPL.resize( vPLtmp.size()) ;
bool bCCW = true ;
for ( int i = 0 ; i < int( vPLtmp.size()) ; ++ i) {
// scambio
swap( vPL[i], vPLtmp[vArea[i].first]) ;
// verifico senso di rotazione del contorno esterno
if ( i == 0)
bCCW = ( vArea[i].second > 0) ;
// aggiusto gli altri contorni
else {
if ( ( bCCW && vArea[i].second > 0) || ( ! bCCW && vArea[i].second < 0))
vPL[i].Invert() ;
}
// dalle PolyLine passo alle curve nel piano XY ( prendo la prima come riferimento, trascuro le Z delle successive)
Frame3d frRef ; frRef.Set( ORIG, vtN) ;
if ( ! frRef.IsValid())
return false ;
ICRVCOMPOPOVECTOR vCrvCompo( int( vPL.size())) ;
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
vCrvCompo[i].Set( CreateCurveComposite()) ;
vCrvCompo[i]->FromPolyLine( vPL[i]) ;
vCrvCompo[i]->ToLoc( frRef) ;
}
// restituisco la normale positiva alla regione
vtN = ( bCCW ? vtN0 : - vtN0) ;
// creo una matrice di interi ; ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle
// successive i loop interni
INTMATRIX vnPLIndMat ;
// vettore di indici per ordinare le PolyLine
INTVECTOR vPL_IndOrder ; vPL_IndOrder.resize( int( vPL.size())) ;
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i)
vPL_IndOrder[i] = m_vArea[i].first ;
// aggiungo le diverse curve
bool bFirstCrv ;
Plane3d plExtLoop ;
double dAreaExtLoop = 0. ;
do {
bFirstCrv = true ;
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i) {
// recupero indice di percorso e verifico sia valido
int j = m_vArea[i].first ;
if ( j < 0)
continue ;
// lo inserisco come esterno...
if ( bFirstCrv) {
vnPLIndMat.push_back({ j}) ;
m_vArea[i].first = -1 ;
dAreaExtLoop = m_vArea[i].second ;
// inverto se necessario
if ( m_vArea[i].second < EPS_SMALL) {
vPL[j].Invert() ;
vCrvCompo[j]->Invert() ;
dAreaExtLoop *= -1 ;
}
bFirstCrv = false ;
}
// ... altrimenti verifico se il loop è interno o no
else {
// il loop è interno se è sia interno al loop esterno della riga di vnPLIndMat e allo stesso tempo
// esterno a tutti i loop già inseriti nella riga attuale.
// verifica rispetto loop esterno
IntersCurveCurve ccInt( *vCrvCompo[vnPLIndMat.back().front()], *vCrvCompo[j]) ;
CRVCVECTOR ccClass ;
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
! ccInt.GetCurveClassification( 1, EPS_SMALL, ccClass) ||
ccClass.empty() || ccClass[0].nClass != CRVC_IN)
continue ;
// verifica rispetto ai loop interni
bool bOk = true ;
for ( int k = 1 ; k < int( vnPLIndMat.back().size()) ; ++ k) {
IntersCurveCurve ccInt2( *vCrvCompo[vnPLIndMat.back()[k]], *vCrvCompo[j]) ;
CRVCVECTOR ccClass2 ;
if ( ccInt2.GetCrossOrOverlapIntersCount() > 0 ||
! ccInt2.GetCurveClassification( 1, EPS_SMALL, ccClass2) ||
ccClass2.empty() || ccClass2[0].nClass != CRVC_IN) {
bOk = false ;
break ;
}
}
if ( bOk) {
// inserisco nella matrice
vnPLIndMat.back().push_back( j) ;
m_vArea[i].first = -1 ;
// inverto se necessario
if ( m_vArea[i].second * dAreaExtLoop > 0.) {
vPL[j].Invert() ;
vCrvCompo[j]->Invert() ;
}
}
}
}
} while ( ! bFirstCrv) ;
// ordino le PolyLine per area
POLYLINEVECTOR vPL_tmp ;
for ( int i = 0 ; i < int( vPL_IndOrder.size()) ; ++ i)
vPL_tmp.push_back( vPL[ vPL_IndOrder[i]]) ;
swap( vPL, vPL_tmp) ;
return true ;
}
+6 -6
View File
@@ -4,7 +4,7 @@
// File : StmFromTriangleSoup.cpp Data : 07.05.23 Versione : 2.5e2
// Contenuto : Implementazione della classe StmFromTriangleSoup, per creare
// una superficie trimesh da un insieme di triangoli
// (può essere disordinato come STL o può essere una superficie).
// (può essere disordinato come STL o può essere una superficie).
//
// Modifiche : 19.05.14 DS Creazione modulo.
//
@@ -53,7 +53,7 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria)
// ciclo sui tre vertici
int nIdV[3] ;
for ( int i = 0 ; i < 3 ; ++ i) {
// verifico se vertice già presente
// verifico se vertice già presente
int nId ;
if ( ! m_VertGrid.Find( Tria.GetP( i), 2 * EPS_SMALL, nId)) {
// aggiungo il vertice
@@ -77,7 +77,7 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria)
//----------------------------------------------------------------------------
bool
StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2,
const double dU0, const double dV0,const double dU1, const double dV1,const double dU2, const double dV2)
double dU0, double dV0, double dU1, double dV1, double dU2, double dV2)
{
// verifico inizializzazione
if ( m_pSTM == nullptr)
@@ -100,13 +100,13 @@ StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, cons
//----------------------------------------------------------------------------
int
StmFromTriangleSoup::AddVertex( const Point3d& ptP, const double dU, const double dV)
StmFromTriangleSoup::AddVertex( const Point3d& ptP, double dU, double dV)
{
// verifico se già presente
// verifico se già presente
int nId ;
if ( m_VertGrid.Find( ptP, 2 * EPS_SMALL, nId))
return nId ;
// aggiungo il vertice
// aggiungo il vertice
if ( ( nId = m_pSTM->AddVertex( ptP, dU, dV)) == SVT_NULL)
return SVT_NULL ;
m_VertGrid.InsertPoint( ptP, nId) ;
+28 -26
View File
@@ -26,34 +26,36 @@ using namespace std ;
static SurfTriMesh*
GetStandardSurfTriMeshBox( double dDimX, double dDimY, double dHeight)
{
// creo la polilinea del contorno della base
PolyLine PL ;
int nU = 0 ;
PL.AddUPoint( nU, Point3d( 0, 0, 0)) ;
PL.AddUPoint( ++ nU, Point3d( dDimX, 0, 0)) ;
PL.AddUPoint( ++ nU, Point3d( dDimX, dDimY, 0)) ;
PL.AddUPoint( ++ nU, Point3d( 0, dDimY, 0)) ;
PL.AddUPoint( ++ nU, Point3d( 0, 0, 0)) ;
if ( dHeight < 0)
PL.Invert() ;
// vettore altezza (estrusione)
Vector3d vtExtr( 0, 0, dHeight) ;
// creo e setto la superficie trimesh laterale
// creo oggetto vuoto
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByExtrusion( PL, vtExtr))
if ( IsNull( pSTM))
return nullptr ;
// creo la prima superficie di estremità
SurfTriMesh STM1 ;
if ( ! STM1.CreateByFlatContour( PL))
// assegno i vertici
double dBotZ = 0, dTopZ = dHeight ;
if ( dBotZ > dTopZ)
swap( dBotZ, dTopZ) ;
if ( pSTM->AddVertex( Point3d( 0, 0, dBotZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( 0, 0, dTopZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( dDimX, 0, dBotZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( dDimX, 0, dTopZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( dDimX, dDimY, dBotZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( dDimX, dDimY, dTopZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( 0, dDimY, dBotZ)) == SVT_NULL ||
pSTM->AddVertex( Point3d( 0, dDimY, dTopZ)) == SVT_NULL)
return nullptr ;
// la copio
SurfTriMesh STM2 = STM1 ;
// inverto la prima superficie
STM1.Invert() ;
// traslo la seconda
STM2.Translate( Vector3d( 0, 0, dHeight)) ;
// le unisco alla superficie del fianco
if ( ! pSTM->DoSewing( STM1) || ! pSTM->DoSewing( STM2))
// definisco i triangoli
int aVertId[12][3]{{ 1, 0, 2}, { 1, 2, 3},
{ 3, 2, 4}, { 3, 4, 5},
{ 5, 4, 6}, { 5, 6, 7},
{ 7, 6, 0}, { 7, 0, 1},
{ 0, 4, 2}, { 6, 4, 0},
{ 1, 3, 5}, { 7, 1, 5}} ;
for ( int i = 0 ; i < 12 ; ++ i) {
if ( pSTM->AddTriangle( aVertId[i]) == SVT_NULL)
return nullptr ;
}
// sistemo la topologia
if ( ! pSTM->AdjustTopology())
return nullptr ;
// restituisco la superficie
return Release( pSTM) ;
@@ -255,7 +257,7 @@ GetSurfTriMeshPlaneInBox( const Plane3d& plPlane, const BBox3d& b3Box, bool bOnE
if ( ! Polyg.FromPlaneTrimmedWithBox( plPlane, b3Box.GetMin(), b3Box.GetMax(), bOnEq, bOnCt))
return nullptr ;
// creo la trimesh con questo contorno
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pStm( CreateBasicSurfTriMesh()) ;
if ( IsNull( pStm) || ! pStm->CreateByFlatContour( Polyg.GetPolyLine()))
return nullptr ;
// restituisco la superficie

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