Compare commits

..

145 Commits

Author SHA1 Message Date
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
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
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
121 changed files with 13871 additions and 3266 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.
+13 -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,16 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="CurveByApprox.cpp" />
<ClCompile Include="CurveByInterp.cpp" />
<ClCompile Include="CurveCompositeOffset.cpp" />
<ClCompile Include="PolygonElevation.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\EGkIntersLineBox.h" />
<ClInclude Include="..\Include\EGkIntersPlaneBox.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 +347,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 +404,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 +449,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="VolZmapGraphics.cpp" />
<ClCompile Include="VolZmapVolume.cpp" />
<ClCompile Include="VolZmap.cpp" />
<ClInclude Include="Voronoi.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Include\EGkAngle.h" />
@@ -610,6 +620,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" />
+42
View File
@@ -46,6 +46,12 @@
<Filter Include="File di origine\GeoCollision">
<UniqueIdentifier>{865b76ee-b10d-41fc-861c-b48ce52fa277}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\GeoProject">
<UniqueIdentifier>{d96752da-1884-4a73-ba1b-5b20b606e469}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\GeoElevation">
<UniqueIdentifier>{4c6a9dc5-8fac-4ecd-bde6-3e37e056712e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Vector3d.cpp">
@@ -471,6 +477,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 +489,27 @@
<ClCompile Include="IntersLineCaps.cpp">
<Filter>File di origine\GeoInters</Filter>
</ClCompile>
<ClCompile Include="ProjectCurveSurfTm.cpp">
<Filter>File di origine\GeoProject</Filter>
</ClCompile>
<ClCompile Include="SubtractProjectedFacesOnStmFace.cpp">
<Filter>File di origine\GeoProject</Filter>
</ClCompile>
<ClCompile Include="SurfAux.cpp">
<Filter>File di origine\Geo</Filter>
</ClCompile>
<ClCompile Include="CalcPocketing.cpp">
<Filter>File di origine\GeoOffset</Filter>
</ClCompile>
<ClCompile Include="OffsetAux.cpp">
<Filter>File di origine\GeoOffset</Filter>
</ClCompile>
<ClCompile Include="Voronoi.cpp">
<Filter>File di origine\Base</Filter>
</ClCompile>
<ClCompile Include="PolygonElevation.cpp">
<Filter>File di origine\GeoElevation</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -1115,6 +1142,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 +1157,18 @@
<ClInclude Include="SurfAux.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="OffsetAux.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkPolygonElevation.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="Voronoi.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<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) ;
}
//----------------------------------------------------------------------------
+3 -3
View File
@@ -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 ;
+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 ;
}
}
+17 -21
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 ;
+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) ;
+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() ;
}
}
//----------------------------------------------------------------------------
+153 -66
View File
@@ -18,6 +18,7 @@
#include "CurveArc.h"
#include "CurveComposite.h"
#include "SurfTriMesh.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
@@ -25,6 +26,7 @@
#include <algorithm>
#include <thread>
#include <future>
#include <EgtDev/Include/EGkIntersCurves.h>
using namespace std ;
@@ -242,7 +244,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,7 +283,7 @@ 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
@@ -294,7 +296,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 +306,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() ;
@@ -345,8 +347,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))
@@ -383,13 +383,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 +410,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 +426,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 +440,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))
@@ -456,19 +458,28 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
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)
@@ -551,12 +562,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 +592,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 +610,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() ;
@@ -669,7 +680,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
if ( ! PL.ToLoc( frStart) || ! PL.Flatten())
return nullptr ;
// calcolo la superficie
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM))
return nullptr ;
// salvo tolleranza lineare usata
@@ -711,7 +722,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
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) ;
@@ -724,7 +735,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d
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() ;
@@ -751,7 +762,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 +787,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 +801,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
+731
View File
@@ -0,0 +1,731 @@
//----------------------------------------------------------------------------
// EgalTech 2023-2023
//----------------------------------------------------------------------------
// File : EGkSubtractProjectedFacesOnStmFace.h Data : 26.09.23 Versione : 2.5j1
// Contenuto : Dichiarazione della funzione per proiettare facce di TriMesh su una superficie di TriMesh.
//
//
//
// Modifiche : 26.09.23 RE Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "GeoConst.h"
#include "CurveComposite.h"
#include "SurfFlatRegion.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EGkSubtractProjectedFacesOnStmFace.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include <array>
using namespace std ;
//----------------------------------------------------------------------------
// Proiezione sottrazione di facce di TriMesh su una faccia di TriMesh
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
static bool
ImproveCurve( CurveComposite* pCrvCompo, const Frame3d frface, const Plane3d plFace, bool& bSkip)
{
// controllo dei parametri
if ( pCrvCompo == nullptr || ! pCrvCompo->IsValid() ||
! frface.IsValid())
return false ;
// 1) se la curva ha un'area o un perimetro troppo piccolo, la trascuro
double dArea = SQ_EPS_SMALL , dLen = EPS_SMALL ;
Plane3d plCrv ;
if ( ! pCrvCompo->GetArea( plCrv, dArea) || ! pCrvCompo->GetLength( dLen))
return false ;
if ( dArea < 50000 * SQ_EPS_SMALL || dLen < 50 * EPS_SMALL) {
bSkip = true ;
return true ;
}
// 2) Merge per uniformità
if ( ! pCrvCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL))
return false ;
// 3) Rimuoviamo Spikes o Curve a Z
if ( ! pCrvCompo->RemoveSmallDefects( 150 * EPS_SMALL, 2 * ANG_TOL_STD_DEG, true))
return false ;
// 4) Interpoliamo mediante Linee ed Archi
PolyArc PA ;
pCrvCompo->ToLoc( frface) ; // interpolazione nel piano XY
pCrvCompo->ApproxWithArcsEx( 500 * EPS_SMALL, ANG_TOL_STD_DEG, 20.0, PA) ;
pCrvCompo->Clear() ;
pCrvCompo->FromPolyArc( PA) ;
pCrvCompo->ToGlob( frface) ;
// le curve ricavate dalle TriMesh possono presentare dei piccoli errori di approssimazione che non le rendono
// del tutto piane... per sicurezza le proietto sul piano creato
double dS, dE ;
pCrvCompo->GetDomain( dS, dE) ;
PtrOwner<ICurve> pCrv_c( pCrvCompo->CopyParamRange( dS, dE)) ; // da CurveCompo a Curve
if ( IsNull( pCrv_c) || ! pCrv_c->IsValid())
return false ;
PtrOwner<ICurve> pCrv_proj( ProjectCurveOnPlane( *pCrv_c, plFace)) ;
// secondo controllo per l'area e il perimetro
double dAreaCheck = SQ_EPS_SMALL, dLenCheck = EPS_SMALL ;
Plane3d plCheck ;
if ( ! IsNull( pCrv_proj) && pCrv_proj->IsClosed()) {
pCrv_proj->GetArea( plCheck, dAreaCheck) ;
pCrv_proj->GetLength( dLenCheck) ;
if ( dAreaCheck < 50000 * SQ_EPS_SMALL || dLenCheck < 50 * EPS_SMALL) {
bSkip = true ;
return true ;
}
}
// sostituisco la curva ed esco
pCrvCompo->Clear() ;
pCrvCompo->CopyFrom( pCrv_proj) ;
bSkip = false ;
return true ;
}
//----------------------------------------------------------------------------
static bool
GetSfrByStm( const ISurfTriMesh* pStm, ISurfFlatRegion* pSfr, const Plane3d plFace)
{
// controllo validità dei parametri
if ( pStm == nullptr || ! pStm->IsValid() || ! plFace.IsValid())
return false ;
// creo un Frame per il sistema di Riferimento Locale
Frame3d frFace ; frFace.Set( plFace.GetPoint(), plFace.GetVersN()) ;
if ( ! frFace.IsValid())
return false ;
// creo la FlatRegion da resitutiure
SurfFlatRegionByContours SrfChunkDef ;
// recupero i Loop della TriMesh salvandoli in un vettore di PolyLine
POLYLINEVECTOR vPl ;
pStm->GetLoops( vPl) ;
// per ogni PolyLine...
for ( int i = 0 ; i < ( int)vPl.size() ; ++ i) {
// recupero la curva composita
PolyLine PL = vPl[i] ;
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
pCrvCompo->FromPolyLine( PL) ;
// sistemazione varie per la curva ( per creare i loops della FlatRegion)
bool bSkip ; // flag per indicare se la curva è accettabile
if ( ! ImproveCurve( pCrvCompo, frFace, plFace, bSkip))
return false ;
if ( ! bSkip)
SrfChunkDef.AddCurve( Release( pCrvCompo)) ; // aggiungo la curva
}
// recupero la FlatRegion ( controllandone la validità)
PtrOwner<ISurfFlatRegion> pSrfByCurves( SrfChunkDef.GetSurf()) ;
if ( IsNull( pSrfByCurves) || ! pSrfByCurves->IsValid() || pSrfByCurves->GetChunkCount() == 0)
return true ;
// restituisco la FlatRegion
pSfr->Clear() ;
pSfr->CopyFrom( pSrfByCurves) ;
return pSfr != nullptr && pSfr->IsValid() ;
}
//----------------------------------------------------------------------------
static bool
CheckSimpleOverlap( const ICurve* pCrv, const ICurveComposite* pCrvOri, int& nStat, double dToll)
{
// === controllo se una curva semplice è sufficientemente vicina ad una curva composita ===
// controllo dei parametri
if (( pCrv == nullptr || pCrvOri == nullptr || dToll < EPS_SMALL))
return false ;
nStat = 1 ; // 0 -> no overlap | 1 -> overlap
// prendo nMax + 1 punti sulla curva semplice...
const double nMAX = 10.0 ;
for ( int i = 0 ; i <= nMAX ; ++i) {
double dPar = i / nMAX ;
Point3d ptC ; pCrv->GetPointD1D2( dPar, ICurve::FROM_PLUS, ptC) ;
if ( ! pCrvOri->IsPointOn( ptC, dToll)) { // se un punto non è vicino, esco
nStat = 0 ;
return true ;
}
}
return true ;
}
//----------------------------------------------------------------------------
static bool
SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveComposite* pCrvOri, int& nStat,
double dToll)
{
// === Data una sottocurva di una CurveComposite e un'altra composita con le proprietà impostate, spezzo la
// sottocurva in tratti di TmpProps uniformi appropriati ===
// controllo dei parametri
if (( pCrvCheck == nullptr || pCrvOri == nullptr || nInd < 0 || nInd > pCrvCheck->GetCurveCount()
|| dToll < EPS_SMALL))
return false ;
nStat = 1 ; // 0 -> no overlap | 1 -> overlap | 2 -> undefined
// ricavo la curva da controllare
PtrOwner<ICurveComposite> pCrv( GetCurveComposite( pCrvCheck->CopyParamRange( nInd, nInd + 1))) ;
if ( IsNull( pCrv))
return false ;
// controllo se la curva fa overlap ( mediante vicinanza)
if ( ! CheckSimpleOverlap( pCrv, pCrvOri, nStat, dToll))
return false ;
if ( nStat == 0)
return true ;
// ricavo i parametri sulla curva originale di vicinanza
double dUS = 0 ; double dUE = 0 ;
Point3d ptS ; pCrv->GetStartPoint( ptS) ;
Point3d ptE ; pCrv->GetEndPoint( ptE) ;
pCrvOri->GetParamAtPoint( ptS, dUS, dToll) ;
pCrvOri->GetParamAtPoint( ptE, dUE, dToll) ;
// ricavo una approssimazione adeguata dei paramtri dUS e dUE
int nRealDUS = ( int)floor( dUS) ;
int nRealDUE = ( int)ceil( dUE) ;
if ( ceil( dUS) - dUS < EPS_SMALL)
nRealDUS = ( int)ceil( dUS) ;
if ( dUE - floor( dUE) < EPS_SMALL)
nRealDUE = ( int)floor( dUE) ;
if ( nRealDUS == pCrvOri->GetCurveCount())
nRealDUS = 0 ;
// controllo se la vicinanza è relativa a più curve sulla originale con stesse temp prop
bool bHasAllSameProp = true ;
int nProp_prec ; pCrvOri->GetCurveTempProp( nRealDUS, nProp_prec, 0) ;
for ( int u = nRealDUS + 1 ; u < nRealDUE && bHasAllSameProp ; ++ u) {
int nProp_act ;
pCrvOri->GetCurveTempProp( u, nProp_act, 0) ;
if ( nProp_prec != nProp_act)
bHasAllSameProp = false ;
}
if ( bHasAllSameProp) { // se tutte le curve hanno tmpProp uguale...
int nCrv = nRealDUS ;
int nProp0 = 0 ; pCrvOri->GetCurveTempProp( nCrv, nProp0, 0) ;
int nProp1 = 0 ; pCrvOri->GetCurveTempProp( nCrv, nProp1, 1) ;
pCrvCheck->SetCurveTempProp( nInd, nProp0, 0) ;
//pCrvCheck->SetCurveTempProp( nInd, nProp1, 1) ;
return true ;
}
// copio le sottocurve toccate
PtrOwner<ICurveComposite> pCrvOriRange( CloneCurveComposite( pCrvOri)) ;
if ( ! pCrvOriRange->TrimStartEndAtParam( floor( dUS), ceil( dUE)))
pCrvOriRange->Clear() ;
if ( ! pCrvOriRange->IsValid()) {
nStat = 2 ;
return true ;
}
// curva finale da resitutire ( da semplice Curve a CurveComposite)
PtrOwner<CurveComposite> pCrvFinal( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvFinal))
return false ;
// per ogni sottocurva...
double dUProjS = 0 ; double dUProjE = 0 ;
for ( int u = 0 ; u < pCrvOriRange->GetCurveCount() ; ++ u) {
Point3d ptCrvOriE ;
pCrvOriRange->GetPointD1D2( u + 1, ICurve::FROM_MINUS, ptCrvOriE) ;
if ( u == 0)
dUProjS = 0 ;
else
dUProjS = dUProjE ;
if ( u == pCrvOriRange->GetCurveCount() - 1)
dUProjE = 1 ;
else
pCrv->GetParamAtPoint( ptCrvOriE, dUProjE, dToll) ;
PtrOwner<CurveComposite> pCrvRange( GetBasicCurveComposite( pCrv->CopyParamRange( dUProjS, dUProjE))) ;
if ( ! IsNull( pCrvRange) && pCrvRange->IsValid()) {
int nProp0 = 0 ; pCrvOriRange->GetCurveTempProp( u, nProp0, 0) ;
int nProp1 = -1 ; pCrvOriRange->GetCurveTempProp( u, nProp1, 1) ;
pCrvRange->SetCurveTempProp( 0, nProp0, 0) ;
pCrvRange->SetCurveTempProp( 0, nProp1, 1) ;
pCrvFinal->AddCurve( Release( pCrvRange)) ;
}
else {
nStat = 2 ;
return true ;
}
}
// controllo che la CurveComposite ottenuta sia valida e coerente rispetto all'originale ...
if ( pCrvFinal->GetCurveCount() > 0 && pCrvFinal->IsValid()) {
Point3d ptSCheck ; Point3d ptECheck ;
pCrvFinal->GetStartPoint( ptSCheck) ;
pCrvFinal->GetEndPoint( ptECheck) ;
if ( ! AreSamePointApprox( ptS, ptSCheck) || ! AreSamePointApprox( ptE, ptECheck))
nStat = 2 ;
}
else
nStat = 2 ;
// ritorno la curva modificata
if ( nStat != 2) {
pCrvFinal->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ;
PtrOwner<CurveComposite> pCrvToReturn( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvToReturn))
return false ;
// primo tratto di curva della Composita iniziale
PtrOwner<CurveComposite> pCrvA( GetBasicCurveComposite( pCrvCheck->CopyParamRange( 0, nInd))) ;
if ( ! IsNull( pCrvA) && pCrvA->GetCurveCount() > 0 && pCrvA->IsValid()) {
if ( ! pCrvToReturn->AddCurve( Release( pCrvA))) {
nStat = 2 ;
return true ;
}
}
// tratto corrente di curva con proprietà impostate
if ( ! pCrvToReturn->AddCurve( Release( pCrvFinal))) {
nStat = 2 ;
return true ;
}
// ultimo tratto di curva della Composita iniziale
PtrOwner<CurveComposite> pCrvB( GetBasicCurveComposite( pCrvCheck->CopyParamRange( nInd + 1, pCrvCheck->GetCurveCount()))) ;
if ( ! IsNull( pCrvB) && pCrvB->GetCurveCount() > 0 && pCrvB->IsValid())
if( ! pCrvToReturn->AddCurve( Release( pCrvB))) {
nStat = 2 ;
return true ;
}
if ( pCrvToReturn->GetCurveCount() > 0 && pCrvToReturn->IsValid()) {
// imposto i parametri originali alla nuova curva
double dThick ; pCrvCheck->GetThickness( dThick) ;
Vector3d vtExtr ; pCrvCheck->GetExtrusion( vtExtr) ;
int nProp0 = pCrvCheck->GetTempProp( 0) ;
int nProp1 = pCrvCheck->GetTempProp( 1) ;
pCrvCheck->Clear() ;
pCrvCheck->AddCurve( Release( pCrvToReturn)) ;
pCrvCheck->SetExtrusion( vtExtr ) ;
pCrvCheck->SetThickness( dThick) ;
pCrvCheck->SetTempProp( nProp0, 0) ;
pCrvCheck->SetTempProp( nProp1, 1) ;
}
else
nStat = 2 ;
}
return true ;
}
//----------------------------------------------------------------------------
static bool
GetOCCrvsWithProps( const ISurfTriMesh& StmOrig, int nFaceInd, ICRVCOMPOPOVECTOR& vCrvsWithTmpProps)
{
// === Data una TriMesh e una sua faccia, stabilire i lati aperti e chiusi dalle adiacenze ===
// controllo validità dei parametri
if ( ! StmOrig.IsValid())
return false ;
vCrvsWithTmpProps.clear() ;
// recupero i contorni della faccia selezionata
POLYLINEVECTOR vPL ;
StmOrig.GetFacetLoops( nFaceInd, vPL) ;
if ( vPL.empty())
return false ;
// recupero la normale esterna della faccia
Vector3d vtN ;
if ( ! StmOrig.GetFacetNormal( nFaceInd, vtN))
return false ;
// creo la curva a partire dai loop
for ( int i = 0 ; i < int( vPL.size()) ; i++) {
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( vPL[i]) || ! pCrvCompo->IsValid())
return false ;
// imposto a 0 tutti i lati della pCrvCompo
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u)
pCrvCompo->SetCurveTempProp( u, 0, 0) ;
// determino eventuali lati aperti e aggiorno proprietà del contorno
int nInd = 0 ;
double dPar ;
bool bFound = vPL[i].GetFirstU( dPar, true) ;
while ( bFound) {
// recupero il flag
int nFlag = int( dPar) ;
// se non c'è nulla di adiacente, lato aperto
if ( nFlag == SVT_NULL) {
pCrvCompo->SetCurveTempProp( nInd, 1, 0) ; // --> lato aperto
pCrvCompo->SetCurveTempProp( nInd, -1, 1) ; // --> nessuna faccia adiacente
}
// altrimenti verifico se la faccia adiacente forma diedro convesso o concavo
else {
bool bAdjac ;
Point3d ptP1, ptP2 ;
double dAng ;
if ( ! StmOrig.GetFacetsContact( nFaceInd, nFlag, bAdjac, ptP1, ptP2, dAng))
dAng = - ANG_RIGHT ;
if ( dAng > - EPS_ANG_SMALL) {
pCrvCompo->SetCurveTempProp( nInd, 1, 0) ; // --> lato aperto
pCrvCompo->SetCurveTempProp( nInd, -1, 1) ; // --> nessuna faccia adiacente
}
else
// salvo come prop 1 la faccia adiacente
pCrvCompo->SetCurveTempProp( nInd, nFlag, 1) ; // --> il lato chiuso è 0 per default
}
// passo al successivo
++nInd ;
bFound = vPL[i].GetNextU( dPar, true) ;
}
// assegno l'estrusione dalla normale alla faccia
pCrvCompo->SetExtrusion( vtN) ;
// unisco le eventuali parti allineate ( mantenendo le proprietà)
pCrvCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ;
// aggiorno la superficie con il loop
vCrvsWithTmpProps.emplace_back( Release( pCrvCompo)) ;
}
return true ;
}
//----------------------------------------------------------------------------
static bool
SewNewStmFacesWithTmpProps( const ISurfFlatRegion& SfrOCCurves, const Plane3d plFace, ISurfTriMesh* pStmFinal)
{
// controllo dei parametri
if ( ! SfrOCCurves.IsValid())
return false ;
// normale dell faccia
Vector3d vtN = plFace.GetVersN() ;
// Creo la TriMesh derivante dai lati chiusi ( estrusione come la normale)
// scorro tutti i Loop della FlatRegion cercando le curva che derivano da proiezioni
for ( int c = 0 ; c < SfrOCCurves.GetChunkCount() ; ++ c) {
for ( int l = 0 ; l < SfrOCCurves.GetLoopCount( c) ; ++ l) {
// ricavo il Loop
PtrOwner<CurveComposite> pCrvCompoLoop( ConvertCurveToBasicComposite( SfrOCCurves.GetLoop( c, l))) ;
if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid())
return false ;
// scorro le sue sottocurve
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u) {
const ICurve* pCrv_u = pCrvCompoLoop->GetCurve( u) ;
if ( pCrv_u == nullptr)
return false ;
if ( pCrv_u->GetTempProp( 0) == 0) {
// se curve chiuse e derivante da una proeizione...
PtrOwner<ISurfTriMesh> pStmCurrExtr( GetSurfTriMeshByExtrusion( pCrv_u, - 1 * vtN, false)) ;
if ( IsNull( pStmCurrExtr) || ! pStmCurrExtr->IsValid())
return false ;
// controllo l'orientamento corretto della nuova faccia
Vector3d vtNCurr ;
if ( ! pStmCurrExtr->GetFacetNormal( 0, vtNCurr))
return false ;
double dAng ;
if ( vtN.GetAngle( vtNCurr, dAng) && dAng > 0)
pStmCurrExtr->Invert() ;
// aggiungo alla superficie
if ( ! pStmFinal->DoSewing( *pStmCurrExtr))
return false ;
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
static bool
AddClosedEdges( const ISurfTriMesh& StmOrig, int nFaceInd, const ISurfFlatRegion& pSfrOrig,
const Plane3d plFace, ISurfTriMesh* pStmFinal)
{
// controllo validità dei parametri
if ( ! StmOrig.IsValid() || pStmFinal == nullptr || ! pStmFinal->IsValid())
return false ;
// creo un vettore di curve con Flag di lato aperto a partire dalla faccia originale
ICRVCOMPOPOVECTOR vCrvWithTmpProps ;
if ( ! GetOCCrvsWithProps( StmOrig, nFaceInd, vCrvWithTmpProps))
return false ;
// creo la superficie finale da restituire
SurfFlatRegionByContours SfrByC ;
// scorro tutti i loop della FlatRegion della superficie ottenuta dopo la proiezione
for ( int c = 0 ; c < pSfrOrig.GetChunkCount() ; ++ c) {
for ( int l = 0 ; l < pSfrOrig.GetLoopCount( c) ; ++ l) {
// ricavo la curva composita associata al loop corrente
PtrOwner<CurveComposite> pCrvCompoLoop( ConvertCurveToBasicComposite( pSfrOrig.GetLoop( c, l))) ;
if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid())
return false ;
// scorro ogni curva del loop ottenuto
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u) {
bool bFound = false ;
for ( int i = 0 ; i < int( vCrvWithTmpProps.size()) && !bFound ; ++ i) {
int nStat = 0 ;
if ( SetTmpPropByOverlap( pCrvCompoLoop, u, vCrvWithTmpProps[i], nStat, 50 * EPS_SMALL) && nStat == 1)
bFound = true ;
}
// se overlap non trovato, allora la curva deriva da una proiezione, quindi chiusa
if ( ! bFound) {
pCrvCompoLoop->SetCurveTempProp( u, 0, 0) ; // <---- curva chiusa
pCrvCompoLoop->SetCurveTempProp( u, -2, 1) ; // <---- derivante da proiezione
}
}
// inserisco la curva con le proprietà definite
SfrByC.AddCurve( Release( pCrvCompoLoop)) ;
}
}
// recupero la FlatRegion con le curve impostate
PtrOwner<ISurfFlatRegion> pSfrWithTmpProps( SfrByC.GetSurf()) ;
if ( IsNull( pSfrWithTmpProps) || ! pSfrWithTmpProps->IsValid())
return false ;
// creo la TriMesh finale da restituire ed esco
return SewNewStmFacesWithTmpProps( *pSfrWithTmpProps, plFace, pStmFinal) ;
}
//----------------------------------------------------------------------------
bool
SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMPOVECTOR& vStmOthers, bool bOCFlag,
bool& bExistProjection, ISurfTriMesh*& pStmRes, int& nNewFaceNbr)
{
// verifico validità della superificie originale
if ( ! Stm.IsValid())
return false ;
// ricavo la faccia su cui togliere le proiezioni
PtrOwner<ISurfTriMesh> pStm_face( Stm.CloneFacet( nFaceInd)) ;
if ( IsNull( pStm_face) || ! pStm_face->IsValid())
return false ;
// imposto valori di ritorno di default
bExistProjection = false ;
nNewFaceNbr = 1 ;
pStmRes = CreateSurfTriMesh() ;
pStmRes->CopyFrom( pStm_face) ;
// dimensione dei vettori passati come parametri
int nVStm_size = ( int)vStmOthers.size() ;
bool bIsSize0 = ( nVStm_size == 0) ;
if ( bIsSize0) {
// se il vettore delle Trimesh dal proiettare è vuoto, la proeizione è fatta con le altre facce delle TriMesh
PtrOwner<ISurfTriMesh> pStmNoSelFace( Stm.Clone()) ;
if ( IsNull( pStmNoSelFace) || ! pStmNoSelFace->IsValid())
return false ;
// se la superficie ha solo una faccia e cerco di toglierla, allora non devo proiettare nulla...
if ( pStmNoSelFace->GetFacetCount() == 1)
return true ; // il flag BOCFlag non importa, ho tutti lati aperti
// rimuovo la faccia da proiettare
if ( ! pStmNoSelFace->RemoveFacet( nFaceInd))
return false ;
// controllo la validità di questa operazione
if ( IsNull( pStmNoSelFace) || ! pStmNoSelFace->IsValid())
return false ;
// modifico il vettore delle TriMesh e delle loro facce
vStmOthers.emplace_back( Release( pStmNoSelFace)) ;
nVStm_size = 1 ;
// NB. E' adottata questa strategia per evitare di proiettare un numero elevato di facce dovuto alla presenza
// di archi; calcolo la GetSilhouette dell'intero contorno e non come unione delle singole facce proiettate
}
// creo il sistema di riferimento ( inerente alla faccia selezionata)
Point3d ptORIG ;
Vector3d vtN ;
if ( ! pStm_face->GetCentroid( ptORIG) || // ricavo origine
! pStm_face->GetFacetNormal( 0, vtN)) // ricavo normale
return false ;
Frame3d frFace ; frFace.Set( ptORIG, vtN) ;
if ( ! frFace.IsValid())
return false ;
// creo un piano passante per la faccia selezionata ( di normale inversa per il taglio)
// ( tutto ciò che sta nel semipiano negativo della faccia selezionata, non viene proiettato ma tagliato)
Plane3d plFace ;
plFace.Set( ptORIG, -vtN) ;
if ( ! plFace.IsValid())
return false ;
// ricavo il Box3D della faccia selezionata nel frame della faccia stessa
Frame3d frH = frFace ; frH.Invert() ;
BBox3d BBoxSelFace ;
if ( ! pStm_face->GetBBox( frH, BBoxSelFace))
return false ;
// superficie finale della proeizione
PtrOwner<SurfFlatRegion> pSfr_proj( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr_proj))
return false ;
bool bExistProj = false ; // flag per indicare se almeno un triangolo è stato proiettato
// scorro le parti di superfici da proiettare...
for ( int t = 0 ; t < nVStm_size ; ++ t) {
// TriMesh da proiettare
PtrOwner<SurfTriMesh> pStm_CurrProj( CloneBasicSurfTriMesh( vStmOthers[t])) ;
if ( IsNull( pStm_CurrProj) || ! pStm_CurrProj->IsValid())
return false ;
// rimuovo dalla TriMesh tutte le facce che sono perpendicolari e tutte le facce il cui Box3D nel piano di
// proeizione non fa overlap con quello della faccia selezionata
// scorro tutte le facce da proiettare
PtrOwner<SurfTriMesh> pStmForProj_noPerpFaces( CreateBasicSurfTriMesh()) ;
StmFromTriangleSoup StmFts ; StmFts.Start() ;
for ( int f = 0 ; f < pStm_CurrProj->GetFacetCount() ; ++ f) {
Vector3d vtN_curr ;
// se perpendicolari alla faccia selezionata, le trascuro
if ( pStm_CurrProj->GetFacetNormal( f, vtN_curr) && abs( vtN_curr * vtN) > 5 * EPS_SMALL) {
BBox3d BBoxFace_f ;
if ( ! pStm_CurrProj->GetFacetBBox( f, frH, BBoxFace_f))
return false ;
// se non c'è OverlapXY tra i due Box3D, la trascuro
if ( BBoxSelFace.OverlapsXY( BBoxFace_f)) {
PtrOwner<SurfTriMesh> pStm_Currface( pStm_CurrProj->CloneFacet( f)) ;
if ( IsNull( pStm_Currface) || ! pStm_Currface->IsValid())
return false ;
Triangle3d Tria ;
int nT = pStm_Currface->GetFirstTriangle( Tria) ;
while ( nT != SVT_NULL) {
// inserisco il triangolo nella nuova superficie
StmFts.AddTriangle( Tria) ;
// passo al triangolo successivo
nT = pStm_Currface->GetNextTriangle( nT, Tria) ;
}
}
}
}
StmFts.End() ;
pStmForProj_noPerpFaces.Set( GetBasicSurfTriMesh( StmFts.GetSurf())) ;
// se la nuova superficie da proittare non contiene nulla, allora passo alla successiva
if ( ! pStmForProj_noPerpFaces->IsValid())
continue ;
// ricostruisco la nuova superificie semplificata da proiettare
if ( ! pStmForProj_noPerpFaces->Repair() ||
! pStm_CurrProj.Set( Release( pStmForProj_noPerpFaces)) ||
IsNull( pStm_CurrProj) ||
! pStm_CurrProj->IsValid())
return false ;
// taglio la superficie con il piano creato ( la proiezione esclude le parti nel semipiano negativo)
// controllo la validità di questa operazione ( la faccia potrebbe essere tutta nel semipiano negativo)
if ( ! pStm_CurrProj->Cut( plFace, true))
return false ;
if ( IsNull( pStm_CurrProj) || ! pStm_CurrProj->IsValid() || pStm_CurrProj->GetTriangleCount() == 0)
continue ;
// recupero la PolyLine della Silhouette
POLYLINEVECTOR vPL ;
if ( ! pStm_CurrProj->GetSilhouette( vtN, 100 * EPS_SMALL, vPL, true))
return false ;
// converto le curve in composite
// NB. Potrei ottenere più curve, quindi creo la FlatRegion associata
SurfFlatRegionByContours sfrBCProj_face ;
bool bValidCurrProj = false ;
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
PtrOwner<CurveComposite> pCrvCompo( CreateBasicCurveComposite()) ;
if ( IsNull( pCrvCompo))
return false ;
pCrvCompo->FromPolyLine( vPL[i]) ;
bool bSkip = true ; // flag per indicare se la curva è valida
if ( ! ImproveCurve( pCrvCompo, frFace, plFace, bSkip))
return false ;
// se curva ammissibile, creo la sua FlatRegion
if ( ! bSkip) {
bValidCurrProj = true ;
sfrBCProj_face.AddCurve( Release( pCrvCompo)) ;
bExistProj = true ;
}
}
// se proeizione non valida, allora passo all'entità successiva
if ( ! bValidCurrProj)
continue ;
// ricavo la FlatRegion associata alla proiezione delle faccia
PtrOwner<ISurfFlatRegion> pSfr_proj_faceCurr( sfrBCProj_face.GetSurf()) ;
if ( IsNull( pSfr_proj_faceCurr) || ! pSfr_proj_faceCurr->IsValid())
return false ;
// inverto se necessario
if ( AreOppositeVectorApprox( pSfr_proj_faceCurr->GetNormVersor(), vtN))
pSfr_proj_faceCurr->Invert() ;
// la sommo alla regione di proeizione globale
if ( ! pSfr_proj->IsValid() || pSfr_proj->GetChunkCount() == 0)
pSfr_proj.Set( GetBasicSurfFlatRegion( Release( pSfr_proj_faceCurr))) ;
else
if ( ! pSfr_proj->Add( *pSfr_proj_faceCurr))
return false ;
}
// se non c'è nulla da proiettare e flag bOCFlag false, allora esco
if ( ! bExistProj && ! bOCFlag)
return true ;
// FlatRegion associata alla faccia della TriMesh selezionata
PtrOwner<SurfFlatRegion> pSfr_face( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr_face) || ! GetSfrByStm( pStm_face, pSfr_face, plFace) || ! pSfr_face->IsValid())
return false ;
// per sicurezza controllo la coerenza con le normali ( per fare la sottrazione)
if ( AreOppositeVectorApprox( pSfr_face->GetNormVersor(), vtN))
pSfr_face->Invert() ;
// superficie finale da restituire
PtrOwner<SurfTriMesh> pStm_final( CreateBasicSurfTriMesh()) ;
if ( IsNull( pStm_final))
return false ;
// *** se la proiezione esiste...
if ( bExistProj) {
// controllo validità della FlatRegion di proiezione globale
if ( IsNull( pSfr_proj) || ! pSfr_proj->IsValid())
return false ;
// ho una proiezione ...
bExistProjection = true ;
// per sicurezza controllo la coerenza con le normali ( per fare la sottrazione)
if ( AreOppositeVectorApprox( pSfr_proj->GetNormVersor(), vtN))
pSfr_proj->Invert() ;
// sottraggo le FlatRegions ( FlatRegion della faccia selezionata \ FlatRegion proiezione)
if ( ! pSfr_face->Subtract( *pSfr_proj))
return false ;
// controllo validità della sottrazione
if ( IsNull( pSfr_face) || ! pSfr_face->IsValid() || pSfr_face->GetChunkCount() == 0) {
// la proiezione copre completamente la faccia selezionata
delete( pStmRes) ;
pStmRes = nullptr ;
nNewFaceNbr = 0 ;
return true ;
}
// aggiorno il numero di facce creato
nNewFaceNbr = pSfr_face->GetChunkCount() ;
}
// riconverto la FlatRegion in TriMesh ( per restituirla)
const SurfTriMesh* pStm_tmp = pSfr_face->GetAuxSurf() ;
if ( pStm_tmp == nullptr || ! pStm_tmp->IsValid())
return false ;
pStm_final.Set( pStm_tmp->Clone()) ;
if ( IsNull( pStm_final) || ! pStm_final->IsValid())
return false ;
// se richiesto aggiugno delle facce sui lati chiusi
if ( bOCFlag)
if ( ! AddClosedEdges( Stm, nFaceInd, *pSfr_face, plFace, pStm_final))
return false ;
// assegno i valori di ritorno della funzione ed esco
pStmRes->CopyFrom( pStm_final) ;
return pStmRes->IsValid() && pStmRes->GetTriangleCount() > 0 ;
}
+36 -97
View File
@@ -19,10 +19,10 @@
#include "CurveArc.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "SurfBezier.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EGkSurf.h"
#include "/EgtDev/Include/EGkSurfAux.h"
#include "/EgtDev/Include/EGkSurfBezier.h"
using namespace std ;
@@ -31,7 +31,7 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
{
// per rendere una superficie non periodica devo recuperare i punti di controllo, suddivisi in isoparametriche lungo una direzione
// e applicare la trasformazione ad ogni isoparametrica, sostituendola poi a quella originale. ( si mantiene il numero di punti)
if ( snData.bPeriodicU ) {
if ( snData.bPeriodicU || ! snData.bClampedU) {
bool bIsRational = snData.bRat ;
// vettore dei nodi
DBLVECTOR vU ;
@@ -68,7 +68,7 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
}
snData.bPeriodicU = false ;
}
if ( snData.bPeriodicV ) {
if ( snData.bPeriodicV || ! snData.bClampedV) {
bool bIsRational = snData.bRat ;
// vettore dei nodi
DBLVECTOR vV ;
@@ -113,20 +113,6 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
ISurf*
NurbsToBezierSurface(const SNurbsSurfData& snData)
{
//INTVECTOR vInt_sub( 10) ;
//INTMATRIX vInt( 10, vInt_sub) ;
//for ( int i = 0 ; i < 10 ; ++i ) {
// for ( int j = 0 ; j < 10 ; ++j ) {
// vInt[i][j] = i + 10 * j ;
// }
//}
//vInt_sub.resize( 20) ;
//vInt[0].resize( 20) ;
// la superficie Nurbs deve essere in forma canonica
if ( snData.bPeriodicU || snData.bPeriodicV || snData.bExtraKnotes )
return nullptr ;
@@ -139,8 +125,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
return nullptr ;
}
//// numero degli intervalli
//int nInt = nU - 2 * snData.nDeg + 1 ;
// verifico le condizioni agli estremi sui nodi (i primi nDeg nodi e gli ultimi nDeg nodi devono essere uguali tra loro)
bool bOk = true ;
// direzione U
@@ -164,49 +148,15 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
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()) ;
// if ( IsNull( pCrvBez))
// return nullptr ;
// // la inizializzo
// if ( ! pCrvBez->Init( snData.nDeg, snData.bRat))
// return nullptr ;
// for ( int i = 0 ; i <= snData.nDeg ; ++ i) {
// if ( ! snData.bRat) {
// if ( ! pCrvBez->SetControlPoint( i, snData.vCP[i]))
// return nullptr ;
// }
// else {
// if ( ! pCrvBez->SetControlPoint( i, snData.vCP[i], snData.vW[i]))
// return nullptr ;
// }
// }
// // se non ? una curva ma un punto, la invalido
// if ( pCrvBez->IsAPoint())
// pCrvBez->Init( snData.nDeg, snData.bRat) ;
// // restituisco la curva
// return Release( pCrvBez) ;
//}
// algoritmo 5.7 del libro "The NURBS book"//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// creazione delle strips nella direzione U ( trasformo le curve iso con U costante in bezier)
int a = snData.nDegU - 1 ;
int b = snData.nDegU ;
int nb = 0 ; // numero di strisce in U ( lunghezza con U costante)
//PNTVECTOR vBC ;
//vBC.resize( snData.nCPV * snData.nDegU) ;
//for (int row = 0 ; row < snData.nCPV ; ++row ) {
// for ( int i = 0 ; i <= snData.nDegU ; ++i ) {
// vBC[nDegU*row + i] = ( snData.vCP[nCPU*row + i]) ;
// }
//}
vector<Point3d> vCPV( snData.nCPV) ;
vector< vector<Point3d>> mBC (snData.nDegU + 1,vCPV ) ;
vector< vector<Point3d>> mBC_next (snData.nDegU - 1, vCPV) ;
vector< vector<Point3d>> mPC_strip(snData.nDegU + 1, vCPV) ; // matrice che verr? ingrandita e conterr? la superficie met? bezier e met? NURBS
vector< vector<Point3d>> mPC_strip(snData.nDegU + 1, vCPV) ; // matrice che verrà ingrandita e conterrà la superficie metà bezier e metà NURBS
DBLVECTOR vV_W( snData.nCPV) ;
vector<DBLVECTOR> mW( snData.nDegU + 1, vV_W) ;
vector<DBLVECTOR> mW_next( snData.nDegU - 1, vV_W) ;
@@ -230,11 +180,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
}
bool bRef = false ;
// se la superficie ? lineare nel parametro U allora ? gi? in forma di Bezier in questo parametro
if ( b == nU - 1 ) {
nb = 1 ;
}
while ( b < nU - 1) { // qui correggo un probabile errore, mettendo nU anzich? nCPV, come indicato nell'algoritmo
while ( snData.nDegU != 1 ? b < nU - 1 : b < nU) { // qui correggo un probabile errore, mettendo nU anziché nCPV, come indicato nell'algoritmo
int i = b ;
while ( b < nU - 1 && abs( snData.vU[b+1] - snData.vU[b]) < EPS_ZERO)
++ b ;
@@ -249,11 +195,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
for ( int j = 1 ; j <= snData.nDegU - mult ; ++j ) {
int save = r - j ;
int s = mult + j ;
//for ( int row = 0 ; row < snData.nCPV ; ++row) {
// for ( int k = snData.nDegU ; k >= s ; --k ) {
// vBC[nCPU*row + k] = vAlpha[k-s]*vBC[nCPU*row + k] + ( 1 - vAlfa[k-s]) * vBC[nCPU*row + k - 1]
// }
//}
if ( ! snData.bRat ) {
for ( int k = snData.nDegU ; k >= s ; --k ) {
for ( int row = 0 ; row < snData.nCPV ; ++row) {
@@ -318,14 +259,17 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
}
if ( b < nU - 1 ) {
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] ;
}
}
if ( snData.bRat ) {
if ( ! snData.bRat ) {
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] ;
}
}
}
else {
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] * snData.mW[b - snData.nDegU + i + 1][row] ;
mW[i][row] = snData.mW[b - snData.nDegU + i + 1][row] ;
}
}
@@ -333,6 +277,10 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
a = b ;
++b ;
}
else if ( snData.nDegU == 1 && b < nU) {
a = b ;
++b ;
}
}
// se non ho raffinato allora tutti i nodi avevano gi? molteplicit? massima. Converto direttamente in Bezier la dir U
@@ -356,8 +304,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
}
}
}
// devo vedere quante patch ci stanno prendendo i punti che ci sono
//nb = (snData.nCPU - 1) / snData.nDegU ;
}
else
nCPU_ref = snData.nDegU * nb + 1 ; // numero dei punti di controllo in U dopo il raffinamento
@@ -395,11 +341,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
}
bRef = false ;
// se la superficie ? lineare nel parametro V allora ? gi? in forma di Bezier in questo parametro
if ( b == nV - 1 ) {
nc = 1 ;
}
while ( b < nV - 1) {
while ( snData.nDegV != 1 ? b < nV - 1 : b < nV) { // qui correggo un probabile errore, mettendo nU anziché nCPV, come indicato nell'algoritmo
int i = b ;
while ( b < nV - 1 && abs( snData.vV[b+1] - snData.vV[b]) < EPS_ZERO)
++ b ;
@@ -414,11 +356,6 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
for ( int j = 1 ; j <= snData.nDegV - mult ; ++j ) {
int save = r - j ;
int s = mult + j ;
//for ( int row = 0 ; row < snData.nCPV ; ++row) {
// for ( int k = snData.nDegU ; k >= s ; --k ) {
// vBC[nCPU*row + k] = vAlpha1[k-s]*vBC[nCPU*row + k] + ( 1 - vAlpha1[k-s]) * vBC[nCPU*row + k - 1]
// }
//}
if ( ! snData.bRat) {
for ( int k = 0 ; k < nCPU_ref ; ++k) {
for ( int row = snData.nDegV ; row >= s ; --row ) {
@@ -444,7 +381,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
else {
for ( int i = 0 ; i < nCPU_ref ; ++i) {
m_BC1_next[i][save] = m_BC1[i][snData.nDegV] ;
mW1_next[save] = mW1[snData.nDegV] ;
mW1_next[i][save] = mW1[i][snData.nDegV] ;
}
}
}
@@ -490,16 +427,17 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
}
if ( b < nV - 1) {
for (int i = 0 ; i < nCPU_ref ; ++ i ) {
for ( int row = snData.nDegV - mult ; row <= snData.nDegV ; ++ row) {
//m_BC1[i][row] = snData.mCP[i][b - snData.nDegV + row + 1] ;
m_BC1[i][row] = mPC_strip[i][b - snData.nDegV + row + 1] ;
}
}
if ( snData.bRat ) {
if ( ! snData.bRat) {
for (int i = 0 ; i < nCPU_ref ; ++ i ) {
for ( int row = snData.nDegV - mult ; row <= snData.nDegV ; ++ row) {
//mW1[i][row] = snData.mW[i][b - snData.nDegV + row + 1] ;
m_BC1[i][row] = mPC_strip[i][b - snData.nDegV + row + 1] ;
}
}
}
else {
for (int i = 0 ; i < nCPU_ref ; ++ i ) {
for ( int row = snData.nDegV - mult ; row <= snData.nDegV ; ++ row) {
m_BC1[i][row] = mPC_strip[i][b - snData.nDegV + row + 1] * mW_strip[i][b - snData.nDegV + row + 1] ;
mW1[i][row] = mW_strip[i][b - snData.nDegV + row + 1] ;
}
}
@@ -507,7 +445,10 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
a = b ;
++b ;
}
else if ( snData.nDegV == 1 && b < nV) {
a = b ;
++b ;
}
}
// se non ho raffinato allora aggiungo direttamente alle matrici della superficie totale
int nCPV_ref ; // numero dei punti di controllo in V dopo il raffinamento
@@ -532,14 +473,12 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
}
}
}
// devo vedere quante patch ci stanno prendendo i punti che ci sono
//nc = (snData.nCPV - 1) / snData.nDegV ;
}
else
nCPV_ref = snData.nDegV * nc + 1 ;
// finalmente setto la superficie di bezier totale divisa in nb patch in U e nc patch in V
PtrOwner<ISurfBezier> pSrfBz( CreateSurfBezier()) ;
PtrOwner<SurfBezier> pSrfBz( CreateBasicSurfBezier()) ;
if ( IsNull( pSrfBz))
return nullptr ;
pSrfBz->Init(snData.nDegU, snData.nDegV, nb, nc, snData.bRat) ;
@@ -553,9 +492,9 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
else {
for ( int i = 0 ; i < nCPU_ref; ++ i) {
for (int j = 0 ; j < nCPV_ref; ++j) {
pSrfBz->SetControlPoint( i + nCPU_ref * j, mPC_tot[i][j] / mW_tot[i][j], mW_tot[i][j]) ;
pSrfBz->SetControlPoint( i + nCPU_ref * j, mPC_tot[i][j] /*/ mW_tot[i][j]*/, mW_tot[i][j]) ;
}
}
}
return Release( pSrfBz) ;
}
}
-17
View File
@@ -14,20 +14,3 @@
#pragma once
#include "/EgtDev/Include/EGkSurfAux.h"
//----------------------------------------------------------------------------
//bool IsClosed( const ICurve& crvC) ;
//bool IsValidParam( const ICurve& crvC, double dPar, ICurve::Side nSide) ;
//bool IsStartParam( const ICurve& crvC, double dPar) ;
//bool IsEndParam( const ICurve& crvC, double dPar) ;
//bool GetNearestExtremityToPoint( const Point3d& ptP, const ICurve& Curve, bool& bStart) ;
//bool MoveParamToAvoidTg( double& dU, ICurve::Side nSide, const ICurve& Curve) ;
//bool GetTang( const ICurve& crvC, double dU, ICurve::Side nS, Vector3d& vtTang) ;
//bool GetPointTang( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos, Vector3d& vtTang) ;
//bool GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGeom& oDiffG) ;
//bool ImproveCurveParamAtPoint( double& dU, const Point3d& ptP, const ICurve* pCrv) ;
//bool CurveGetAreaXY( const ICurve& crvC, double& dArea) ;
//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) ;
+268 -116
View File
@@ -20,6 +20,9 @@
#include "Bernstein.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "Tree.h"
#include "Triangulate.h"
#include "SurfTriMesh.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
@@ -33,12 +36,10 @@ using namespace std ;
GEOOBJ_REGISTER( SRF_BEZIER, NGE_S_BEZ, SurfBezier) ;
//----------------------------------------------------------------------------
SurfBezier::SurfBezier(void)
SurfBezier::SurfBezier( void)
: m_pSTM( nullptr), m_nStatus( TO_VERIFY), m_nDegU(), m_nDegV(), m_nSpanU(), m_nSpanV(), m_bRat( false),
m_bTrimmed( false), m_pTrimReg( nullptr)
m_bTrimmed( false), m_pTrimReg( nullptr), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}
{
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
}
//----------------------------------------------------------------------------
@@ -53,7 +54,7 @@ SurfBezier::~SurfBezier( void)
bool
SurfBezier::Init( int nDegU, int nDegV, int nSpanU, int nSpanV, bool bIsRational)
{
// verifico validità grado
// verifico validit grado
if ( nDegU < 1 || nDegU > MAXDEG || nDegV < 1 || nDegV > MAXDEG || nSpanU < 1 || nSpanV < 1)
return false ;
@@ -85,7 +86,7 @@ SurfBezier::Init( int nDegU, int nDegV, int nSpanU, int nSpanV, bool bIsRational
bool
SurfBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
{
// verifico validità indice
// verifico validit indice
if ( m_nStatus != OK || m_bRat || nInd < 0 || nInd >= GetDim())
return false ;
@@ -107,7 +108,7 @@ SurfBezier::SetControlPoint( int nInd, const Point3d& ptCtrl)
bool
SurfBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
{
// verifico validità, razionalità e indice
// verifico validit, razionalit e indice
if ( m_nStatus != OK || ! m_bRat || nInd < 0 || nInd >= GetDim())
return false ;
@@ -144,11 +145,20 @@ SurfBezier::SetTrimRegion( const ISurfFlatRegion& sfrTrimReg)
return true ;
}
//----------------------------------------------------------------------------
SurfFlatRegion*
SurfBezier::GetTrimRegion( void) const
{
if ( ! m_bTrimmed || m_pTrimReg == nullptr )
return nullptr ;
return m_pTrimReg ;
}
//----------------------------------------------------------------------------
bool
SurfBezier::GetInfo( int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIsRat, bool& bTrimmed) const
{
// verifico validità superficie
// verifico validit superficie
if ( m_nStatus != OK)
return false ;
// restituisco gradi e flag di razionale
@@ -165,7 +175,7 @@ SurfBezier::GetInfo( int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIs
const Point3d&
SurfBezier::GetControlPoint( int nInd, bool* pbOk) const
{
// verifico validità e indice
// verifico validit e indice
if ( m_nStatus != OK || nInd < 0 || nInd >= GetDim()) {
if ( pbOk != NULL)
*pbOk = false ;
@@ -181,7 +191,7 @@ SurfBezier::GetControlPoint( int nInd, bool* pbOk) const
double
SurfBezier::GetControlWeight( int nInd, bool* pbOk) const
{
// verifico validità, razionalità e indice
// verifico validit, razionalit e indice
if ( m_nStatus != OK || ! m_bRat || nInd < 0 || nInd >= GetDim()) {
if ( pbOk != NULL)
*pbOk = false ;
@@ -219,8 +229,9 @@ SurfBezier::GetArea( double& dArea) const
// inizio con area nulla
dArea = 0 ;
// calcolo l'area
if ( ! GetAuxSurf())
return false ;
if ( m_pSTM == nullptr)
if ( ! GetAuxSurf())
return false ;
return m_pSTM->GetArea( dArea) ;
}
@@ -234,8 +245,9 @@ SurfBezier::GetCentroid( Point3d& ptCen) const
// inizio con centro nell'origine
ptCen = ORIG ;
// calcolo il baricentro
if ( ! GetAuxSurf())
return false ;
if ( m_pSTM == nullptr)
if ( ! GetAuxSurf())
return false ;
return m_pSTM->GetCentroid( ptCen) ;
}
@@ -491,7 +503,7 @@ SurfBezier::GetPointNrmD1D2( double dU, double dV, Side nUs, Side nVs,
if ( vtN.Normalize())
return true ;
// se solo una delle due derivate è piccola, mi sposto lungo il relativo parametro e uso le tangenti
// se solo una delle due derivate piccola, mi sposto lungo il relativo parametro e uso le tangenti
if ( pvtDerU->Len() < EPS_SMALL && pvtDerV->Len() > 10 * EPS_SMALL) {
double dCoeff = ( dU - 1000 * EPS_PARAM < 0. ? 1 : -1) ;
double dUm = dU + 1000 * EPS_PARAM * dCoeff ;
@@ -568,8 +580,14 @@ SurfBezier::CopyFrom( const SurfBezier& sbSrc)
m_vPtCtrl = sbSrc.m_vPtCtrl ;
if ( sbSrc.m_bRat)
m_vWeCtrl = sbSrc.m_vWeCtrl ;
if ( sbSrc.m_bTrimmed) {
m_bTrimmed = true ;
m_pTrimReg = sbSrc.m_pTrimReg->Clone() ;
}
m_nTempProp[0] = sbSrc.m_nTempProp[0] ;
m_nTempProp[1] = sbSrc.m_nTempProp[1] ;
m_dTempParam[0] = sbSrc.m_dTempParam[0] ;
m_dTempParam[1] = sbSrc.m_dTempParam[1] ;
return true ;
}
@@ -592,7 +610,7 @@ SurfBezier::GetTitle( void) const
bool
SurfBezier::Dump( string& sOut, bool bMM, const char* szNewLine) const
{
// verifico validità superficie
// verifico validit superficie
if ( m_nStatus != OK)
sOut += string( "Status=Invalid") + szNewLine ;
// area
@@ -725,7 +743,8 @@ SurfBezier::Load( NgeReader& ngeIn)
}
}
// se trimmata, lettura della regione
if ( m_bTrimmed) {
if ( bTrimmed) {
m_bTrimmed = true ;
// creo l'oggetto
ResetTrimRegion() ;
m_pTrimReg = CreateBasicSurfFlatRegion() ;
@@ -733,7 +752,7 @@ SurfBezier::Load( NgeReader& ngeIn)
return false ;
// ne leggo i dati
IGeoObjRW* pGObjRW = dynamic_cast<IGeoObjRW*>( m_pTrimReg) ;
if ( pGObjRW == nullptr || pGObjRW->Load( ngeIn))
if ( pGObjRW == nullptr || ! pGObjRW->Load( ngeIn))
return false ;
}
@@ -766,8 +785,9 @@ SurfBezier::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
// deve essere preciso
else {
// verifico esistenza trimesh associata
if ( ! GetAuxSurf())
return false ;
if ( m_pSTM == nullptr)
if ( ! GetAuxSurf())
return false ;
// calcolo il box della trimesh
return m_pSTM->GetLocalBBox( b3Loc, nFlag) ;
}
@@ -789,8 +809,9 @@ SurfBezier::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
// deve essere preciso
else {
// verifico esistenza trimesh associata
if ( ! GetAuxSurf())
return false ;
if ( m_pSTM == nullptr)
if ( ! GetAuxSurf())
return false ;
// calcolo il box della trimesh
return m_pSTM->GetBBox( frRef, b3Ref, nFlag) ;
}
@@ -822,7 +843,7 @@ SurfBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, d
// la superficie deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico validità dell'asse di rotazione
// verifico validit dell'asse di rotazione
if ( vtAx.IsSmall())
return false ;
@@ -878,7 +899,7 @@ SurfBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// la superficie deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico validità del piano di specchiatura
// verifico validit del piano di specchiatura
if ( vtNorm.IsSmall())
return false ;
@@ -901,7 +922,7 @@ SurfBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d&
// la superficie deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico validità dei parametri
// verifico validit dei parametri
if ( vtNorm.IsSmall() || vtDir.IsSmall())
return false ;
@@ -923,11 +944,11 @@ SurfBezier::ToGlob( const Frame3d& frRef)
// la superficie deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico validità del frame
// verifico validit del frame
if ( frRef.GetType() == Frame3d::ERR)
return false ;
// se frame identità, non devo fare alcunché
// se frame identit, non devo fare alcunch
if ( IsGlobFrame( frRef))
return true ;
@@ -949,11 +970,11 @@ SurfBezier::ToLoc( const Frame3d& frRef)
// la superficie deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico validità del frame
// verifico validit del frame
if ( frRef.GetType() == Frame3d::ERR)
return false ;
// se frame identità, non devo fare alcunché
// se frame identit, non devo fare alcunch
if ( IsGlobFrame( frRef))
return true ;
@@ -975,11 +996,11 @@ SurfBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
// la superficie deve essere validata
if ( m_nStatus != OK)
return false ;
// verifico validità dei frame
// verifico validit dei frame
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
return false ;
// se i due riferimenti coincidono, non devo fare alcunché
// se i due riferimenti coincidono, non devo fare alcunch
if ( AreSameFrame( frOri, frDest))
return true ;
@@ -1006,28 +1027,23 @@ SurfBezier::Invert( void)
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// inverto
PNTVECTOR vPtCtrl = m_vPtCtrl ;
int l = 0 ;
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
int k = i + ( m_nDegU + 1) * j ;
m_vPtCtrl[l] = vPtCtrl[k] ;
++ l ;
// inverto i punti del parametro U
PNTVECTOR vPtCtrl_inv( m_vPtCtrl.size()) ;
for ( int j = 0 ; j < m_nDegV * m_nSpanV + 1; ++j) {
for ( int i = 0 ; i < m_nDegU * m_nSpanU + 1; ++i) {
vPtCtrl_inv[ i + j * ( m_nDegU * m_nSpanU + 1)] = m_vPtCtrl[ ( m_nDegU * m_nSpanU - i) + j * ( m_nDegU * m_nSpanU + 1)] ;
}
}
if ( m_bRat) {
DBLVECTOR vWeCtrl = m_vWeCtrl ;
int lr = 0 ;
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
int k = i + ( m_nDegU + 1) * j ;
m_vWeCtrl[lr] = vWeCtrl[k] ;
++ lr ;
}
}
m_vPtCtrl = vPtCtrl_inv ;
if ( m_bTrimmed) {
// inverto la flat region di trim
//( la specchio rispetto all'asse verticale)
Point3d pt( m_nSpanU * SBZ_TREG_COEFF/2, 0, 0) ;
Vector3d vt( 1, 0, 0) ;
m_pTrimReg->Mirror( pt, vt) ;
}
swap( m_nDegU, m_nDegV) ;
return true ;
}
@@ -1218,39 +1234,62 @@ SurfBezier::GetCurveOnV( double dU) const
CurveComposite*
SurfBezier::GetLoop( int nLoop) const
{
// Se superficie completa, basta concatenare le 4 isoparametriche di bordo
if ( ! m_bTrimmed) {
// Esiste solo il loop esterno
if ( nLoop != 0)
// Il primo loop sono le 4 isoparametriche di bordo concatenate
if ( ! m_bTrimmed ) {
if ( nLoop != 0 )
return nullptr ;
// Loop
// Loop
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
// prima curva isoparametrica in U con V=0
// prima curva isoparametrica in U con V=0
PtrOwner<CurveComposite> pCrvCoU0( GetCurveOnU( 0)) ;
if ( ! IsNull( pCrvCoU0) && ! pCrvCoU0->IsAPoint())
pLoop->AddCurve( Release( pCrvCoU0)) ;
// seconda curva isoparametrica in V con U=m_nSpanU
// seconda curva isoparametrica in V con U=m_nSpanU
PtrOwner<CurveComposite> pCrvCoV1( GetCurveOnV( m_nSpanU)) ;
if ( ! IsNull( pCrvCoV1) && ! pCrvCoV1->IsAPoint())
pLoop->AddCurve( Release( pCrvCoV1)) ;
// terza curva isoparametrica in U con V=m_nSpanV invertita
// terza curva isoparametrica in U con V=m_nSpanV invertita
PtrOwner<CurveComposite> pCrvCoU1( GetCurveOnU( m_nSpanV)) ;
if ( ! IsNull( pCrvCoU1) && ! pCrvCoU1->IsAPoint()) {
pCrvCoU1->Invert() ;
pLoop->AddCurve( Release( pCrvCoU1)) ;
}
// quarta curva isoparametrica in V con U=0 invertita
// quarta curva isoparametrica in V con U=0 invertita
PtrOwner<CurveComposite> pCrvCoV0( GetCurveOnV( 0)) ;
if ( ! IsNull( pCrvCoV0) && ! pCrvCoV0->IsAPoint()) {
pCrvCoV0->Invert() ;
pLoop->AddCurve( Release( pCrvCoV0)) ;
}
// se loop chiuso lo restituisco, altrimenti errore
// se loop chiuso lo restituisco, altrimenti errore
return ( pLoop->IsClosed() ? Release( pLoop) : nullptr) ;
}
// altrimenti trimmata, per ora non gestita
else
return nullptr ;
// la superficie trimmata, quindi devo cercare nei vari chunck il loop corrispondente
else {
if ( nLoop > m_pTrimReg->GetChunkCount())
return nullptr ;
else {
int nLoopCount = 0 ;
int nChunck = 0, nLoopLoc = 0;
INTVECTOR nLoopCountPerChunck ;
for ( int i = 0 ; i < m_pTrimReg->GetChunkCount() && nLoopCount != nLoop ; ++ i) {
int nLoopCountLoc = 0 ;
for ( int j = 0 ; j < m_pTrimReg->GetLoopCount( i) ; ++ j) {
++ nLoopCountLoc ;
++ nLoopCount ;
if ( nLoopCount != nLoop ) {
nChunck = i ;
nLoopLoc = j ;
break ;
}
}
nLoopCountPerChunck.push_back( nLoopCountLoc) ;
}
if ( nLoopCount < nLoop )
return nullptr ;
PtrOwner<CurveComposite> pLoop( GetBasicCurveComposite( m_pTrimReg->GetLoop( nChunck, nLoopLoc))) ;
return Release( pLoop) ;
}
}
}
//----------------------------------------------------------------------------
@@ -1372,6 +1411,82 @@ SurfBezier::GetCurveOnVApproxLen( double dU) const
return 0 ;
return dLen ;
}
//
////----------------------------------------------------------------------------
//const SurfTriMesh*
//SurfBezier::GetAuxSurf( void) const
//{
// // la superficie deve essere validata
// if ( m_nStatus != OK) {
// ResetAuxSurf() ;
// return nullptr ;
// }
// // se gi calcolata, la restituisco
// if ( m_pSTM != nullptr)
// return m_pSTM ;
// // costruttore della superficie
// StmFromTriangleSoup stmSoup ;
// if ( ! stmSoup.Start())
// return nullptr ;
// // definisco il numero degli step in U e in V
// double dMaxLenU = 0 ;
// for ( int j = 0 ; j <= m_nDegV * m_nSpanV ; ++ j)
// dMaxLenU = max( dMaxLenU, GetCurveOnUApproxLen( double( j) / m_nDegV)) ;
// int nStepU = GetSteps( m_nDegU, m_nSpanU, dMaxLenU, 2) ;
// double dMaxLenV = 0 ;
// for ( int i = 0 ; i <= m_nDegU * m_nSpanU ; ++ i)
// dMaxLenV = max( dMaxLenV, GetCurveOnVApproxLen( double( i) / m_nDegU)) ;
// int nStepV = GetSteps( m_nDegV, m_nSpanV, dMaxLenV, 2) ;
// // prima curva isoparametrica (potrebbe essere un solo punto)
// PolyLine PL1 ;
// GetCurveOnU( 0, nStepU, PL1) ;
// bool bSingle1 = ( PL1.GetPointNbr() == 1) ;
// // ciclo sulle isoparametriche
// for ( int i = 1 ; i <= nStepV ; ++ i) {
// // seconda curva isoparametrica (con tanti punti quanti la prima, oppure uno solo)
// double dV = double( i) * m_nSpanV / nStepV ;
// PolyLine PL2 ;
// GetCurveOnU( dV, nStepU, PL2) ;
// bool bSingle2 = ( PL2.GetPointNbr() == 1) ;
// // inserisco i triangoli della striscia nel costruttore della TriMesh
// Point3d ptP1c, ptP2c ;
// Point3d ptP1n, ptP2n ;
// bool bNext = PL1.GetFirstPoint( ptP1c) && PL2.GetFirstPoint( ptP2c) ;
// if ( bNext) {
// if ( bSingle1 && bSingle2)
// bNext = false ;
// if ( bSingle1)
// ptP1n = ptP1c ;
// else
// bNext = bNext && PL1.GetNextPoint( ptP1n) ;
// if ( bSingle2)
// ptP2n = ptP2c ;
// else
// bNext = bNext && PL2.GetNextPoint( ptP2n) ;
// }
// while ( bNext) {
// // eventuale primo triangolo (con base sui correnti e vertice su P2 successivo)
// if ( ! AreSamePointApprox( ptP1c, ptP2c))
// stmSoup.AddTriangle( ptP2c, ptP1c, ptP2n) ;
// // eventuale secondo triangolo (con vertice su P1 corrente e base sui successivi)
// if ( ! AreSamePointApprox( ptP1n, ptP2n))
// stmSoup.AddTriangle( ptP1c, ptP1n, ptP2n) ;
// // passo alla successiva coppia
// ptP1c = ptP1n ;
// ptP2c = ptP2n ;
// bNext = ( bSingle1 || PL1.GetNextPoint( ptP1n)) && ( bSingle2 || PL2.GetNextPoint( ptP2n)) ;
// }
// // salvo isoparametrica PL2 in PL1
// PL1.GetUPointList().swap( PL2.GetUPointList()) ;
// bSingle1 = bSingle2 ;
// }
// // la completo
// if ( ! stmSoup.End())
// return nullptr ;
// // la salvo
// m_pSTM = GetBasicSurfTriMesh( stmSoup.GetSurf()) ;
// return m_pSTM ;
//}
//----------------------------------------------------------------------------
const SurfTriMesh*
@@ -1382,73 +1497,110 @@ SurfBezier::GetAuxSurf( void) const
ResetAuxSurf() ;
return nullptr ;
}
// se già calcolata, la restituisco
// se gi calcolata, la restituisco
if ( m_pSTM != nullptr)
return m_pSTM ;
// costruttore della superficie
POLYLINEMATRIX vvPL ;
//POLYLINEVECTOR vPL ; // per usare i polygon basic
Tree Tree( this, true) ;
BIPNTVECTOR vTrees ;
Tree.GetIndependentTrees( vTrees) ;
bool bTest = false ; // per debug
for ( int i = 0 ; i < (int) vTrees.size() ; ++ i) {
Point3d ptMin = std::get<0>( vTrees[i]) ;
Point3d ptMax = std::get<1>( vTrees[i]) ;
Tree.SetSurf( this, true, ptMin, ptMax) ;
if ( bTest) {
Tree.BuildTree_test() ; // per debug
//Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ; // per debug
Tree.SetTestMode() ;
}
else {
Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ;
}
Tree.GetPolygons( vvPL) ;
//Tree.GetPolygonsBasic( vPL) ; // per usare i polygon basic
}
//// per usare i polygon basic//////////////////////
//for (int k = 0 ; k < (int)vPL.size(); ++k) {
// vvPL.emplace_back() ;
// vvPL.back().push_back(vPL[k]) ;
//}
//// per usare i polygon basic///////////////////
// qui non sarebbe male stampare un messaggio di errore nel log se avevo un'area da disegnare ma non sono usciti dei poligoni
if ( int(vvPL.size()) == 0)
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Bezier Surface couldn't be triangulated, hence wasn't drawn") ;
StmFromTriangleSoup stmSoup ;
if ( ! stmSoup.Start())
return nullptr ;
// definisco il numero degli step in U e in V
double dMaxLenU = 0 ;
for ( int j = 0 ; j <= m_nDegV * m_nSpanV ; ++ j)
dMaxLenU = max( dMaxLenU, GetCurveOnUApproxLen( double( j) / m_nDegV)) ;
int nStepU = GetSteps( m_nDegU, m_nSpanU, dMaxLenU, 2) ;
double dMaxLenV = 0 ;
for ( int i = 0 ; i <= m_nDegU * m_nSpanU ; ++ i)
dMaxLenV = max( dMaxLenV, GetCurveOnVApproxLen( double( i) / m_nDegU)) ;
int nStepV = GetSteps( m_nDegV, m_nSpanV, dMaxLenV, 2) ;
// prima curva isoparametrica (potrebbe essere un solo punto)
PolyLine PL1 ;
GetCurveOnU( 0, nStepU, PL1) ;
bool bSingle1 = ( PL1.GetPointNbr() == 1) ;
// ciclo sulle isoparametriche
for ( int i = 1 ; i <= nStepV ; ++ i) {
// seconda curva isoparametrica (con tanti punti quanti la prima, oppure uno solo)
double dV = double( i) * m_nSpanV / nStepV ;
PolyLine PL2 ;
GetCurveOnU( dV, nStepU, PL2) ;
bool bSingle2 = ( PL2.GetPointNbr() == 1) ;
// inserisco i triangoli della striscia nel costruttore della TriMesh
Point3d ptP1c, ptP2c ;
Point3d ptP1n, ptP2n ;
bool bNext = PL1.GetFirstPoint( ptP1c) && PL2.GetFirstPoint( ptP2c) ;
if ( bNext) {
if ( bSingle1 && bSingle2)
bNext = false ;
if ( bSingle1)
ptP1n = ptP1c ;
else
bNext = bNext && PL1.GetNextPoint( ptP1n) ;
if ( bSingle2)
ptP2n = ptP2c ;
else
bNext = bNext && PL2.GetNextPoint( ptP2n) ;
// prendo i punti di ogni polyline dell'albero, li triangolo e li porto in 3d
for ( POLYLINEVECTOR vPL : vvPL) {
PNTVECTOR vPnt ;
INTVECTOR vTria ;
Triangulate Tri ;
if ( ! Tri.Make( vPL, vPnt, vTria))
return nullptr ;
// porto i punti in 3d
PNTVECTOR vPnt3d ;
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
Point3d pt3d ;
if ( ! GetPointD1D2( vPnt[i].x / SBZ_TREG_COEFF, vPnt[i].y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3d))
return nullptr ;
vPnt3d.push_back( pt3d) ;
}
while ( bNext) {
// eventuale primo triangolo (con base sui correnti e vertice su P2 successivo)
if ( ! AreSamePointApprox( ptP1c, ptP2c))
stmSoup.AddTriangle( ptP2c, ptP1c, ptP2n) ;
// eventuale secondo triangolo (con vertice su P1 corrente e base sui successivi)
if ( ! AreSamePointApprox( ptP1n, ptP2n))
stmSoup.AddTriangle( ptP1c, ptP1n, ptP2n) ;
// passo alla successiva coppia
ptP1c = ptP1n ;
ptP2c = ptP2n ;
bNext = ( bSingle1 || PL1.GetNextPoint( ptP1n)) && ( bSingle2 || PL2.GetNextPoint( ptP2n)) ;
int nTria = int( vTria.size()) / 3 ;
for ( int i = 0 ; i < nTria ; ++i) {
if ( ! stmSoup.AddTriangle( vPnt3d[vTria[3*i]], vPnt3d[vTria[3*i+1]], vPnt3d[vTria[3*i+2]],
vPnt[vTria[3*i]].x, vPnt[vTria[3*i]].y,
vPnt[vTria[3*i+1]].x, vPnt[vTria[3*i+1]].y,
vPnt[vTria[3*i+2]].x, vPnt[vTria[3*i+2]].y))
return nullptr ;
}
// salvo isoparametrica PL2 in PL1
PL1.GetUPointList().swap( PL2.GetUPointList()) ;
bSingle1 = bSingle2 ;
}
// la completo
}
// la salvo
if ( ! stmSoup.End())
return nullptr ;
// la salvo
m_pSTM = GetBasicSurfTriMesh( stmSoup.GetSurf()) ;
return m_pSTM ;
}
//----------------------------------------------------------------------------
bool
SurfBezier::GetLeaves( vector<tuple<int, Point3d, Point3d>>& vLeaves) const
{
Tree Tree( this, true) ;
BIPNTVECTOR vTrees ;
Tree.GetIndependentTrees( vTrees) ;
for ( int i = 0 ; i < int( vTrees.size()) ; ++ i) {
Point3d ptMin = get<0>( vTrees[i]) ;
Point3d ptMax = get<1>( vTrees[i]) ;
Tree.SetSurf( this, true, ptMin, ptMax) ;
bool bTest = false ; // per debug
if ( bTest) {
Tree.BuildTree_test() ; // per debug
//Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ; // per debug
}
else {
Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ;
}
vector<Cell> vCells ;
Tree.GetLeaves( vCells) ;
for ( int k = 0 ; k < int( vCells.size()) ; ++ k) {
vLeaves.emplace_back( vCells[k].m_nId, vCells[k].GetBottomLeft(), vCells[k].GetTopRight()) ;
}
}
return true ;
}
//----------------------------------------------------------------------------
void
SurfBezier::ResetAuxSurf( void) const
+9 -1
View File
@@ -58,6 +58,11 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
m_nTempProp[nPropInd] = nProp ; }
int GetTempProp( int nPropInd) 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 : // ISurf
bool IsSimple( void) const override
@@ -83,6 +88,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
{ return SetControlPoint( GetInd( nIndU, nIndV), ptCtrl, dW) ; }
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
bool SetTrimRegion( const ISurfFlatRegion& sfrTrimReg) override ;
SurfFlatRegion* GetTrimRegion( void) const override ;
bool GetInfo( int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIsRat, bool& bTrimmed) const override ;
const Point3d& GetControlPoint( int nIndU, int nIndV, bool* pbOk) const override
{ return GetControlPoint( GetInd( nIndU, nIndV), pbOk) ; }
@@ -105,6 +111,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
bool GetControlCurveOnU( int nIndV, PolyLine& plCtrlU) const override ;
bool GetControlCurveOnV( int nIndU, PolyLine& plCtrlV) const override ;
const SurfTriMesh* GetAuxSurf( void) const override ;
bool GetLeaves( std::vector<std::tuple<int, Point3d, Point3d>>& vLeaves) const override ;
public : // IGeoObjRW
int GetNgeId( void) const override ;
@@ -166,7 +173,8 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
int m_nTempProp[2] ; // vettore proprietà temporanee
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
} ;
//-----------------------------------------------------------------------------
+71 -246
View File
@@ -22,6 +22,7 @@
#include "CurveLine.h"
#include "AdjustLoops.h"
#include "GeoConst.h"
#include "Voronoi.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h"
#include "/EgtDev/Include/EGkIntervals.h"
@@ -34,10 +35,8 @@ GEOOBJ_REGISTER( SRF_FLATRGN, NGE_S_FRG, SurfFlatRegion) ;
//----------------------------------------------------------------------------
SurfFlatRegion::SurfFlatRegion( void)
: m_pSTM( nullptr), m_nStatus( TO_VERIFY)
: m_pSTM( nullptr), m_nStatus( TO_VERIFY), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_pVoronoiObj( nullptr)
{
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
}
//----------------------------------------------------------------------------
@@ -60,10 +59,14 @@ SurfFlatRegion::Clear( void)
m_nTempProp[0] = 0 ;
m_nTempProp[1] = 0 ;
m_dTempParam[0] = 0.0 ;
m_dTempParam[1] = 0.0 ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
ResetAuxSurf() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
return true ;
}
@@ -193,6 +196,8 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
return true ;
}
@@ -329,6 +334,8 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
return true ;
}
@@ -403,6 +410,8 @@ SurfFlatRegion::CopyFrom( const SurfFlatRegion& sfrSrc)
m_vExtInd = sfrSrc.m_vExtInd ;
m_nTempProp[0] = sfrSrc.m_nTempProp[0] ;
m_nTempProp[1] = sfrSrc.m_nTempProp[1] ;
m_dTempParam[0] = sfrSrc.m_dTempParam[0] ;
m_dTempParam[1] = sfrSrc.m_dTempParam[1] ;
m_nStatus = sfrSrc.m_nStatus ;
return ( m_nStatus == OK && ! m_vpLoop.empty()) ;
}
@@ -613,6 +622,8 @@ SurfFlatRegion::Translate( const Vector3d& vtMove)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// traslo il riferimento
m_frF.Translate( vtMove) ;
return true ;
@@ -632,6 +643,8 @@ SurfFlatRegion::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// ruoto il riferimento
return m_frF.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
@@ -651,6 +664,8 @@ SurfFlatRegion::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// se scalatura non uniforme, sostituisco eventuali archi con curve di Bezier
if ( abs( dCoeffX - dCoeffY) > EPS_SMALL || abs( dCoeffX - dCoeffZ) > EPS_SMALL) {
@@ -704,6 +719,8 @@ SurfFlatRegion::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// parziale mirror del riferimento (non può essere completa)
Frame3d frTrasf = m_frF ;
@@ -752,6 +769,8 @@ SurfFlatRegion::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// se il piano di scorrimento non coincide con XY intrinseco, converto eventuali archi in curve di Bezier
if ( ! AreSameOrOppositeVectorExact( m_frF.VersZ(), vtNorm)) {
@@ -824,6 +843,8 @@ SurfFlatRegion::ToGlob( const Frame3d& frRef)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// trasformo il riferimento
return m_frF.ToGlob( frRef) ; ;
@@ -847,6 +868,8 @@ SurfFlatRegion::ToLoc( const Frame3d& frRef)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// trasformo il riferimento
return m_frF.ToLoc( frRef) ; ;
@@ -870,6 +893,8 @@ SurfFlatRegion::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
// imposto ricalcolo della grafica
ResetAuxSurf() ;
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// trasformo il riferimento
return m_frF.LocToLoc( frOri, frDest) ; ;
@@ -1400,250 +1425,50 @@ SurfFlatRegion::GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion&
}
}
//----------------------------------------
bool
SurfFlatRegion::GetZigZagInfill( double dStep, bool bStepCorrection, bool bInvert, ICRVCOMPOPOVECTOR& vpCrvs) const
//----------------------------------------------------------------------------
bool
SurfFlatRegion::CalcVoronoiObject() const
{
// ingombro della regione
BBox3d b3Pocket ;
GetLocalBBox( b3Pocket) ;
Point3d ptMin ; double dDimX, dDimY, dDimZ ;
b3Pocket.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ;
if ( m_nStatus != OK)
return false ;
// lunghezza dei contorni
DBLVECTOR vLen( m_vpLoop.size()) ;
for ( size_t i = 0 ; i < vLen.size() ; i++)
m_vpLoop[i]->GetLength( vLen[i]) ;
// passi in Y
double dYStep = dStep ;
int nYStep = static_cast<int>( floor( dDimY / dStep)) ;
int nRef = 0 ;
if ( bStepCorrection) {
// se permesso, lo modifico per coprire uniformemente la regione
nYStep = static_cast<int>( ceil( ( dDimY - 30 * EPS_SMALL) / dStep)) ;
dYStep = ( nYStep > 0 ? ( dDimY - 30 * EPS_SMALL) / nYStep : 0) ;
nRef = ( ( nYStep + ( bInvert ? 0 : 1)) % 2) ;
}
// tratto valido
struct Section {
bool bActive ;
Point3d ptS ;
Point3d ptE ;
double dOs ;
double dOe ;
size_t nIdxS ; // indice del loop a cui appartiene ptS
size_t nIdxE ; // indice del loop a cui appartiene ptE
} ;
// raccolta di tratti
typedef vector<vector<Section>> VECVECSECT ;
VECVECSECT vvSec ;
vvSec.resize( nYStep + 1) ;
// calcolo le linee di svuotatura
int nCount = 0 ;
for ( int i = 0 ; i <= nYStep ; ++ i) {
// determino senso
bool bPlus = (( i % 2) == nRef) ;
// definisco correzione per essere sicura di poter fare primo e ultimo step
double dCorr = 0 ;
if ( i == 0)
dCorr = 10 * EPS_SMALL ;
else if ( i == nYStep)
dCorr = - 10 * EPS_SMALL ;
// definisco la linea
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
const double EXP_LEN = 1.0 ;
Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + dCorr + i * dYStep, ptMin.z + dDimZ) ;
if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX , dDimX + 2 * EXP_LEN)) {
return false ;
}
// calcolo la classificazione della curva rispetto alla regione
CRVCVECTOR ccClass ;
if ( ! GetCurveClassification( *pLine, EPS_SMALL, ccClass))
return false ;
// determino gli intervalli di curva da conservare
Intervals inOk ;
for ( auto& ccOne : ccClass) {
if ( ccOne.nClass == CRVC_IN || ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)
inOk.Add( ccOne.dParS, ccOne.dParE) ;
}
// inserisco i tratti validi (secondo X+ i pari, secondo X- i dispari)
double dParS, dParE ;
bool bFound = ( bPlus ? inOk.GetFirst( dParS, dParE) : inOk.GetLast( dParE, dParS)) ;
while ( bFound) {
// determino i dati della sezione
Section Sect ;
Sect.bActive = true ;
pLine->GetPointD1D2( dParS, ICurve::FROM_PLUS, Sect.ptS) ;
pLine->GetPointD1D2( dParE, ICurve::FROM_MINUS, Sect.ptE) ;
// porto i punti nel riferimento della curva
if ( ! AreSameFrame( m_frF, GLOB_FRM)) {
Sect.ptS.ToLoc( m_frF) ;
Sect.ptE.ToLoc( m_frF) ;
}
// cerco la curva della regione che passa per ptS
bool bCrvFound = false ;
for ( size_t k = 0 ; ! bCrvFound && k < m_vpLoop.size() ; k++) {
bCrvFound = m_vpLoop[k]->GetParamAtPoint( Sect.ptS, Sect.dOs, 10 * EPS_SMALL) ;
if ( bCrvFound)
Sect.nIdxS = k ;
}
if ( ! bCrvFound)
return false ;
// cerco la curva della regione che passa per ptE
bCrvFound = false ;
for ( size_t k = 0 ; ! bCrvFound && k < m_vpLoop.size() ; k++) {
bCrvFound = m_vpLoop[k]->GetParamAtPoint( Sect.ptE, Sect.dOe, 10 * EPS_SMALL) ;
if ( bCrvFound)
Sect.nIdxE = k ;
}
if ( ! bCrvFound)
return false ;
// inserisco nel contenitore
vvSec[i].emplace_back( Sect) ;
++ nCount ;
// recupero intervallo successivo
bFound = ( bPlus ? inOk.GetNext( dParS, dParE) : inOk.GetPrev( dParE, dParS)) ;
}
}
// dominio del contorno
DBLVECTOR vUmax( m_vpLoop.size()) ;
DBLVECTOR vUmin( m_vpLoop.size()) ;
DBLVECTOR vUspan( m_vpLoop.size()) ;
for ( size_t i = 0 ; i < m_vpLoop.size() ; i++) {
m_vpLoop[i]->GetDomain( vUmin[i], vUmax[i]) ;
vUspan[i] = vUmax[i] - vUmin[i] ;
}
// creo i percorsi di svuotatura
vpCrvs.reserve( nCount) ;
int nI = -1, nJ = -1 ;
while ( true) {
// se sezione non valida
if ( nI < 0 || nJ < 0) {
// ricerco la prima valida
for ( int k = 0 ; k < int( vvSec.size()) && nI < 0 ; ++ k) {
for ( int l = 0 ; l < int( vvSec[k].size()) && nJ < 0 ; ++ l) {
if ( vvSec[k][l].bActive) {
nI = k ;
nJ = l ;
}
}
}
// se trovata, creo nuova curva composita
if ( nI >= 0 && nJ >= 0) {
// creo la curva
vpCrvs.emplace_back( CreateCurveComposite()) ;
// aggiungo punto iniziale
vpCrvs.back()->AddPoint( vvSec[nI][nJ].ptS) ;
}
// altrimenti, esco
else
break ;
}
// determino senso
bool bPlus = (( nI % 2) == nRef) ;
// aggiungo la sezione alla curva
Section& Sec = vvSec[nI][nJ] ;
Sec.bActive = false ;
vpCrvs.back()->AddLine( vvSec[nI][nJ].ptE) ;
// cerco nella stessa fila o in quella successiva sezione successiva raccordabile tramite il contorno
double dUstart = Sec.dOe ;
double dUref = ( bPlus ? INFINITO : - INFINITO) ;
int nNextI = -1 ;
int nNextJ = -1 ;
int li = nJ + 1 ;
for ( int k = nI ; k <= nI + 1 && k < int( vvSec.size()) ; ++ k) {
for ( int l = li ; l < int( vvSec[k].size()) ; ++ l) {
if ( ! vvSec[k][l].bActive)
continue ;
// la nuova sezione deve partire dalla stessa curva su cui ci si è fermati
if ( vvSec[k][l].nIdxS != Sec.nIdxE)
continue ;
double dU = vvSec[k][l].dOs ;
if ( bPlus) {
if ( dU < dUstart)
dU += vUspan[Sec.nIdxE] ;
if ( dU < dUref) {
dUref = dU ;
nNextI = k ;
nNextJ = l ;
}
}
else {
if ( dU > dUstart)
dU -= vUspan[Sec.nIdxE] ;
if ( dU > dUref) {
dUref = dU ;
nNextI = k ;
nNextJ = l ;
}
}
}
li = 0 ;
}
// se trovato, aggiungo il tratto di contorno e continuo
if ( nNextI != -1) {
PtrOwner<ICurve> pCopy ;
size_t idx = vvSec[nNextI][nNextJ].nIdxS ;
if ( bPlus) {
if ( dUref > vUmax[idx])
dUref -= vUspan[idx] ;
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUstart, dUref)) ;
if ( ! IsNull( pCopy)) {
double dCLen ; pCopy->GetLength( dCLen) ;
if ( dCLen > 0.5 * vLen[idx]) {
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUref, dUstart)) ;
if ( ! IsNull( pCopy))
pCopy->Invert() ;
}
}
}
else {
if ( dUref < vUmin[idx])
dUref += vUspan[idx] ;
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUref, dUstart)) ;
if ( ! IsNull( pCopy)) {
pCopy->Invert() ;
double dCLen ; pCopy->GetLength( dCLen) ;
if ( dCLen > 0.5 * vLen[idx])
pCopy.Set( m_vpLoop[idx]->CopyParamRange( dUstart, dUref)) ;
}
}
BBox3d b3Copy ;
if ( ! IsNull( pCopy))
pCopy->GetBBox( m_frF, b3Copy) ;
if ( ! b3Copy.IsEmpty() && ( b3Copy.GetMax().y - b3Copy.GetMin().y) < dYStep + 10 * EPS_SMALL) {
vpCrvs.back()->AddCurve( Release( pCopy)) ;
nI = nNextI ;
nJ = nNextJ ;
}
else {
nI = -1 ;
nJ = -1 ;
}
}
else {
nI = -1 ;
nJ = -1 ;
}
}
// porto le curve calcolate nel riferimento globale
if ( ! AreSameFrame( m_frF, GLOB_FRM)) {
for ( int i = 0 ; i < ( int) vpCrvs.size() ; i++)
vpCrvs[i]->ToGlob( m_frF) ;
}
// creo oggetto vroni con la superficie
m_pVoronoiObj = new( std::nothrow) Voronoi( this, false) ;
if ( m_pVoronoiObj == nullptr)
return false ;
return true ;
}
}
//----------------------------------------------------------------------------
void
SurfFlatRegion::ResetVoronoiObject() const
{
if ( m_pVoronoiObj != nullptr)
delete m_pVoronoiObj ;
m_pVoronoiObj = nullptr ;
}
//---------------------------------------------------------------------------
bool
SurfFlatRegion::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound) const
{
// verifico se è stato calcolato
if ( m_pVoronoiObj == nullptr)
if ( ! CalcVoronoiObject())
return false ;
return m_pVoronoiObj->CalcVoronoiDiagram( vCrvs, nBound) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const
{
// verifico se è stato calcolato
if ( m_pVoronoiObj == nullptr)
if ( ! CalcVoronoiObject())
return false ;
return m_pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
}
+18 -4
View File
@@ -22,6 +22,8 @@
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
#include <deque>
class Voronoi ;
//----------------------------------------------------------------------------
class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
{
@@ -57,6 +59,11 @@ class SurfFlatRegion : public ISurfFlatRegion, 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 : // ISurf
bool IsSimple( void) const override
@@ -81,6 +88,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
bool Subtract( const ISurfFlatRegion& Other) override ;
bool Intersect( const ISurfFlatRegion& Other) override ;
bool Offset( double dDist, int nType) override ;
SurfFlatRegion* CreateOffsetSurf( double dDist, int nType) const override ;
bool GetGrossArea( double& dArea) const override ;
const Point3d& GetPlanePoint( void) const override
{ return m_frF.Orig() ; }
@@ -95,7 +103,8 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
bool GetZigZagInfill( double dStep, bool bStepCorrection, bool bInvert, ICRVCOMPOPOVECTOR& vpCrvs) const override ;
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
public : // IGeoObjRW
int GetNgeId( void) const override ;
@@ -104,7 +113,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
public :
SurfFlatRegion( void) ;
SurfFlatRegion( const SurfFlatRegion& stSrc) : m_pSTM( nullptr)
SurfFlatRegion( const SurfFlatRegion& stSrc) : m_pSTM( nullptr), m_pVoronoiObj( nullptr)
{ if ( ! CopyFrom( stSrc))
LOG_ERROR( GetEGkLogger(), "SurfFlatRegion : copy constructor error") }
SurfFlatRegion& operator =( const SurfFlatRegion& stSrc)
@@ -138,7 +147,9 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
int nType1, bool bInvert1, int nType2, bool bInvert2, PCRV_DEQUE& vpCurve) ;
static bool MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop) ;
static SurfFlatRegion* MyNewSurfFromLoops( PCRV_DEQUE& vpLoop) ;
static bool MyTestAndDelete( PCRV_DEQUE& vpCrv) ;
static bool MyTestAndDelete( PCRV_DEQUE& vpCrv) ;
bool CalcVoronoiObject( void) const ;
void ResetVoronoiObject( void) const ;
private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
@@ -147,7 +158,10 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
Frame3d m_frF ; // riferimento intrinseco
PCRV_DEQUE m_vpLoop ; // deque delle curve che formano i loop
INTVECTOR m_vExtInd ; // indice dei loop esterni nel precedente vettore
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
} ;
//-----------------------------------------------------------------------------

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