Compare commits

...

213 Commits

Author SHA1 Message Date
Dario Sassi da8f40db17 EgtGeomKernel 2.6j1 :
- ricompilazione con cambio versione.
2024-10-10 15:43:05 +02:00
Riccardo Elitropi 5468e3f4fa EgtGeomKernel :
- in CalcPocketing rilassati i vincoli sulla regione di incidenza dei lati aperti e migliorata la gestione delle curve singole.
2024-10-10 13:02:42 +02:00
Daniele Bariletti 88684e305f Merge branch 'MoreBezier' 2024-10-04 15:40:24 +02:00
Daniele Bariletti f8ca8029d7 Merge remote-tracking branch 'origin/HEAD' into MoreBezier 2024-10-04 15:20:46 +02:00
Daniele Bariletti aa9c46cbb5 EgtGeomKernel :
- aggiunte la surfBz SweptInPlane e Swept3D.
2024-10-04 15:20:31 +02:00
Daniele Bariletti f0cf3c9559 EgtGeomKernel :
- rimozione memory leak
- corretto bug nella triangolazione bezier.
2024-10-04 14:57:23 +02:00
Riccardo Elitropi 9a638b9470 EgtGeomKernel :
- In CalcPocketing corretti errori per casi a trapezio
- migliorata la gestione delle curve singole di svuotatura.
2024-10-04 12:57:20 +02:00
Dario Sassi b07fbfc72e Merge commit 'a98b6bcc09a707b1c42a025b8e85a85801465f08' 2024-10-02 17:26:01 +02:00
Dario Sassi 0317c37557 EgtGeomKernel 2.6j1 :
- piccoli ritocchi a superfici di Bezier.
2024-10-02 17:25:24 +02:00
Riccardo Elitropi a98b6bcc09 EgtGeomKernel :
- in CalcPocketing estesi i percorsi OneWay
- piccole migliorie su selezione punto iniziale per curve singole.
2024-10-02 13:13:16 +02:00
Riccardo Elitropi c19861a911 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-10-01 12:41:19 +02:00
Riccardo Elitropi 8f8597d442 EgtGeomKernel :
- In CalcPocketing, piccola modifica in lavorazioni Conformal.
2024-10-01 12:41:15 +02:00
Dario Sassi 0c0eb9ef8f EgtGeomKernel 2.6i2 :
- ricompilazione con cambio versione.
2024-09-26 19:58:03 +02:00
Riccardo Elitropi 4ffb7087bd EgtGeomKernel :
- In CalcPocketing, migliorati i percorsi Conformal.
2024-09-26 12:22:51 +02:00
Dario Sassi dc070c4556 EgtgeomKernel :
- aggiunta funzione GetLoopCurveCount a FlatRegion.
2024-09-23 13:01:07 +02:00
Riccardo Elitropi 60729d5f39 EgtGeomKernel :
- Semplificazione codice in CalcPocketing.
2024-09-20 09:29:02 +02:00
SaraP da7e9dd6e2 EgtGeomKernel :
- aggiunte funzioni per calcolare Voronoi e medial axis di più curve.
2024-09-19 16:28:19 +02:00
Riccardo Elitropi aeff9fb418 EgtGeomKernel :
- in sgrossature, aggiunta modalità CONFORMAL_ZIGZAG e CONFORMAL_ONEWAY.
2024-09-19 09:06:40 +02:00
Daniele Bariletti e9e897593b EgtGeomKernel :
- modificata la CreateBySetOfCurves.
2024-09-17 17:27:31 +02:00
Daniele Bariletti bfc09d135c EgtGeomKernel :
- aggiunta la funzione IsLine per le bezier
- aggiunta funzione SurfBzSweptInPlane
- aggiunta la funzione InterpolatePointSetWithBezier.
2024-09-17 17:19:20 +02:00
SaraP 0998d0fffc EgtGeomKernel :
- correzione errore nel calcolo offset con Voronoi.
2024-09-10 16:17:50 +02:00
Daniele Bariletti 93c87ee720 EgtGeomKernel :
- correzione alla triangolazione delle bilineari bezier.
2024-09-10 12:30:01 +02:00
Daniele Bariletti a67a0502fa EgtGeomKernel :
- correzioni alla triangolazione di una surf di bezier (split iniziale).
2024-09-10 09:19:28 +02:00
Daniele Bariletti cec0a48be4 EgtGeomKernel :
- correzione alla SurfBzByScrewing.
2024-09-10 09:18:21 +02:00
Daniele Bariletti 0cc63d40eb EgtGeomKernel :
- piccole correzioni
- tolti commenti.
2024-09-10 09:17:59 +02:00
Dario Sassi 623eb6e630 EgtGeomKernel 2.6i1 :
- ricompilazione con cambio versione.
2024-09-05 17:37:54 +02:00
Dario Sassi 1f22299096 Merge commit '3f6c439983dee4957cb04a9b69dd01492ef38954' 2024-09-05 17:10:03 +02:00
Daniele Bariletti 3f6c439983 Merge branch 'MoreBezier' 2024-09-05 15:03:27 +02:00
Daniele Bariletti 8e22267476 EgtGeomKernel :
- piccole correzioni.
2024-09-05 12:13:28 +02:00
Daniele Bariletti aa2b6ccde5 EgtGeomKernel :
- modifica degli argomenti della funzione CalcRegionPolyLines.
2024-09-05 12:09:28 +02:00
Daniele Bariletti ec6cb79a8d EgtGeomKernel :
- correzione alla SurfTmByRegionExtrusion
- correzione alla SurfBzByScrewing.
2024-09-05 11:37:24 +02:00
Daniele Bariletti 76dceb4fc9 EgtGeomKernel :
- aggiunto un commento.
2024-09-05 08:53:15 +02:00
Daniele Bariletti b1564f7de0 EgtGeomKernel :
- aggiunto un commento.
2024-09-05 08:52:57 +02:00
Daniele Bariletti 21e4bd6d93 Merge branch 'master' into MoreBezier 2024-09-04 15:56:45 +02:00
Daniele Bariletti 2101d72abe Merge branch 'MoreBezier' 2024-09-04 15:50:24 +02:00
Daniele Bariletti 7a01f67c8b EgtGeomKernel :
- aggiunto un argomento alla CalcRegionPolyLines.
2024-09-04 15:50:01 +02:00
Daniele Bariletti 2267343afe EgtGeomKernel :
- correzione ai CopyFrom di CurveComposite e di SurfBezier.
2024-09-04 08:57:39 +02:00
Daniele Bariletti 9a5fe24781 EgtGeomKernel :
- correzione alle SbzByRegion.
2024-09-03 09:25:17 +02:00
Daniele Bariletti 4050aa11c5 EgtGeomKernel :
- aggiunto un limite di iterazioni per l'approssimazione con bezier cubiche
- correzione alla MakeNonRational.
2024-09-02 09:47:45 +02:00
Daniele Bariletti b75ddae396 Merge branch 'MoreBezier' 2024-08-30 16:16:25 +02:00
Daniele Bariletti 2d3f8487ee Merge remote-tracking branch 'origin/HEAD' into MoreBezier 2024-08-30 15:04:46 +02:00
SaraP 964647d7e6 EgtGeomKernel 2.6h3 :
- estensione del calcolo degli offset con Voronoi al caso di più curve scollegate tra loro.
2024-08-30 14:49:47 +02:00
Daniele Bariletti f78dd0fa83 EgtGewomKernel :
- correzione alle curve di bezier.
2024-08-30 14:46:59 +02:00
Daniele Bariletti 55ce22b06c EgtGeomKernel :
- piccoli aggiustamenti stilistici.
2024-08-29 10:05:45 +02:00
Daniele Bariletti 50df4f3503 Merge branch 'master' into MoreBezier 2024-08-29 09:23:08 +02:00
Daniele Bariletti 5c8f0c79f6 Merge commit '2b4090619bd13636d11a1684cd19a5b8a1ca4539' into MoreBezier 2024-08-29 09:21:42 +02:00
Daniele Bariletti de3f187ddf EgtGeomKernel :
- unificazione del codice per la CalcRegionPolyLines e modifiche collegate.
2024-08-29 09:20:00 +02:00
Daniele Bariletti f649954ee1 EgtGeomKernel :
- pulizia codice.
2024-08-28 09:35:27 +02:00
Daniele Bariletti 6e08f2a878 EgtGeomKernel :
- modifica alla MakeNonRational
- modifica alla EditCurveBezier ( si può scegliere liberamente il grado)
- aggiunte funzioni per uniformare le curve da usare per la creazione di sup di Beizer.
- piccola correzione alla triangolazione.
2024-08-26 17:07:51 +02:00
Dario Sassi 887922a715 EgtGeomKernel :
- migliorie a CalcAuxSurf di SurfFlatRegion (per casi di piccolissima dimensione).
2024-08-23 18:59:40 +02:00
Dario Sassi 640fef2e0a Merge commit '4f3fe68283f537bb933439a78ef909025408c904' 2024-08-23 09:21:22 +02:00
Daniele Bariletti 1a338a1a82 EgtGeomKernel :
- aggiunte le approssimazioni di bezier con bezier cubiche.
2024-08-22 15:57:53 +02:00
Riccardo Elitropi 4f3fe68283 EgtGeomKernel :
- aggiunta in CalcPocketing la gestione dei punti iniziali
- migliorie varie.
2024-08-22 12:54:25 +02:00
Dario Sassi 3908e11d18 EgtGeomKernel 2.6h2 :
- modifiche per permettere Mark di tipo 2.
2024-08-22 09:10:04 +02:00
Daniele Bariletti 4e6c5112e4 EgtGeomKernel :
- aggiunta di funzioni e modifica di funzioni per la gestione delle curve di bezier.
2024-08-09 17:35:47 +02:00
Daniele Bariletti e1ab88302f EgtGeomKernel :
- correzioni e miglioramenti alla triangolazione delle bezier.
2024-08-09 17:33:26 +02:00
Riccardo Elitropi 2b4090619b EgtGeomKernel :
- In CalcPocketing miglorate le Feed, le regioni non svuotate e le lavorazioni ConformalZigZag.
2024-08-06 15:11:11 +02:00
Dario Sassi b90289e42b EgtGeomKernel :
- piccole velocizzazioni per biarchi
- modifiche per unificazioni AreSamePoint***.
2024-08-06 14:42:25 +02:00
SaraP 5e84408685 EgtGeomKernel 2.6h1 :
- migliorato calcolo distanza nell'approssimazione con archi.
2024-08-05 16:50:35 +02:00
Daniele Bariletti b53c2f833a Merge branch 'MoreBezier' 2024-08-05 10:07:42 +02:00
Daniele Bariletti b5fcceaa75 Merge branch 'master' into MoreBezier 2024-08-05 08:46:27 +02:00
Daniele Bariletti f0bfbb6c85 EgtGeomKernel :
- correzioni e migliorie alla triangolazione con le bezier.
2024-08-02 15:12:35 +02:00
Daniele Bariletti 2710f735d1 EgtGeomKernel :
- correzioni e migliorie alla triangolazione delle bezier.
2024-08-01 16:24:16 +02:00
Daniele Bariletti ddffbd2c88 EgtGeomKernel :
- correzioni e migliorie alla triangolazione delle bezier.
2024-07-31 17:43:18 +02:00
SaraP fde952499d EgtGeomKernel :
- correzione in AssociatePolyLinesMinDistPoints.
2024-07-31 14:22:22 +02:00
Riccardo Elitropi b28102a8cc EgtGeomKernel :
In CalcPocketing per lavorazioni CONFORMAL_ZIGZAG aggiunta gestione aree non svuotate.
2024-07-30 18:34:37 +02:00
Daniele Bariletti f46db233dc EgtGeomKernel :
- ottimizzazione della triangolazione bezier.
2024-07-30 16:23:35 +02:00
Riccardo Elitropi df10b45c6b EgtGeomKernel :
- in CalcPocketing aggiunta lavorazione CONFORMAL_ZIGZAG
- migliorie varie.
2024-07-30 14:01:17 +02:00
Daniele Bariletti 1b13580340 EgtGeomKernel :
- correzioni alla triangolazione con le bezier.
2024-07-29 17:32:04 +02:00
Daniele Bariletti 742305b99b EgtGeomKernel :
- correzioni e miglioramenti alla triangolazione delle bezier.
2024-07-29 15:25:28 +02:00
Dario Sassi 1261de4dbb EgtGeomKernel 2.6g6 :
- ricompilazione con cambio versione.
2024-07-29 10:14:02 +02:00
Daniele Bariletti b50588f974 EgtGeomKernel :
- correzioni e migliorie alla triangolazione delle bezier.
2024-07-26 17:28:29 +02:00
Daniele Bariletti 9b87de9fa2 EgtGeomKernel :
- correzioni e migliorie alla triangolazione con le bezier.
2024-07-25 16:25:05 +02:00
Riccardo Elitropi 5bab4a9aa8 EgtGeomKernel :
- aggiunti percorsi di bordo In CalcPocketing per ZigZag e OneWay
- correzione punti per entrate
- migliorie varie.
2024-07-25 12:30:08 +02:00
Daniele Bariletti c3e7d3d8c7 EgtGeomKernel :
- miglioramenti alla triangolazione delle bezier.
2024-07-24 10:13:45 +02:00
Daniele Bariletti 89c22ffd06 EgtGeomKernel :
- correzioni e miglioramenti per la triangolazione bezier.
2024-07-24 09:27:38 +02:00
Riccardo Elitropi 5375752609 EgtGeomKernel :
- in CalcPocketing aggiunto un frame Locale XY per semplificazione conti e migliorata la gestione della svuotature a trapezio.
2024-07-23 11:52:43 +02:00
Daniele Bariletti 0a8f26c993 EgtGeomKernel :
- correzioni alla triangolazione delle bezier.
2024-07-23 09:47:19 +02:00
Riccardo Elitropi cba9c253e1 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-07-22 11:46:43 +02:00
Riccardo Elitropi 71f3bf8809 EgtMachKernel :
- in calcPocketing, migliorata la gestione di superfici con isole sia aperte che chiuse, gestito caso di circonferenza tutta aperta e modifica del parametro MinSafe.
2024-07-22 11:46:39 +02:00
Daniele Bariletti d491536eb4 EgtGeomKernel :
- piccola aggiunta al CopyFrom delle Surf Bezier.
2024-07-22 11:18:32 +02:00
Daniele Bariletti e68465c80b EgtGeomKernel :
- piccola aggiunta al CopyFrom delle Surf Bezier.
2024-07-22 11:18:01 +02:00
Daniele Bariletti dfb8fd2160 EgtGeomKernel :
- correzione bug nella triangolazione bezier.
2024-07-22 10:27:24 +02:00
Daniele Bariletti 746fa61e08 EgtGeomKernel :
- aggiunta dell'uniformazione delle curve in preparazione ad una superficie skinned.
2024-07-22 10:26:51 +02:00
Daniele Bariletti d0e0c46e2c EgtGeomKernel :
- correzione bug nella triangolazione bezier.
2024-07-22 10:22:36 +02:00
Daniele Bariletti 19c7f63303 EgtGeomKernel :
- generalizzazione della skinned con bezier.
2024-07-19 16:59:47 +02:00
Daniele Bariletti 87f6a29db3 EgtGeomKernel :
- aggiunte le skinned con le Bezier.
2024-07-19 13:13:45 +02:00
Riccardo Elitropi b04d1ed7a9 EgtGeomKernel :
- migliorie nella gestione dei lati Aperti/Chiusi in CalcPocketing.
2024-07-19 12:01:58 +02:00
Dario Sassi 54dba7ab41 EgtGeomKernel 2.6g5 :
- aggiunta classe DistPointSurfFr (distanza punto regione)
. a SurfFlatRegion aggiunte funzioni EraseChunk, GetChunkArea, GetChunkPerimeter, ResetAllCurveTempProps e ResetAllCurveTempParams
- piccoli adattamenti in CalcPocketing.
2024-07-18 20:18:18 +02:00
Daniele Bariletti 146c06d27f Merge branch 'master' into MoreBezier 2024-07-17 16:22:19 +02:00
Daniele Bariletti 7c45c1e287 EgtGeomKernel :
- aggiustamenti alla Bezier By Contour.
2024-07-17 16:18:18 +02:00
Daniele Bariletti d6dc5b8428 Merge branch 'master' of https://gitlab.steamware.net/egalware-cadcam/libreriebase/EgtGeomKernel 2024-07-17 09:10:07 +02:00
Daniele Bariletti 28695f9138 EgtGeomKernel :
- piccola modifica alle funzioni per creare superfici di Bezier.
2024-07-17 09:10:03 +02:00
Dario Sassi 66cec4a872 EgtGeomKernel :
- ridotte tolleranze su tangenza in intersezione archi.
2024-07-17 09:00:33 +02:00
Dario Sassi 8d1d3f766a EgtGeomKernel :
- irrobustita funzione IsClosedAndFlat di PolyLine (facendo i conti rispetto al baricentro)
- per Regioni quando si aggiune il loop esterno, se risulta formato da più parti disgiunte (per autonitersezioni) si ignorano quelle molto piccole.
2024-07-16 08:38:40 +02:00
Dario Sassi befed079c8 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-07-15 18:51:13 +02:00
Daniele Bariletti b9138029db EgtGeomKernel 2.6g3 :
- aggionamento versione.
2024-07-15 17:34:11 +02:00
Daniele Bariletti 2246dbc284 Merge branch 'MoreBezier' 2024-07-15 17:30:17 +02:00
Dario Sassi 67180b3569 Merge commit '4748bd5ac888a0ae6b9381c40bad0aaf01df73aa' 2024-07-15 17:11:30 +02:00
Daniele Bariletti 3a2aa2c679 Merge branch 'master' into MoreBezier 2024-07-15 17:06:16 +02:00
Daniele Bariletti 9dd4e043d4 EgtGeomKernel :
- correzione bug nelle rigate con le Bezier.
2024-07-15 17:05:44 +02:00
Riccardo Elitropi 4748bd5ac8 EgtGeomKernel :
- In CalcPocketing corretta la gestione delle isole aperte mediante MaxOffset.
2024-07-15 13:28:14 +02:00
Daniele Bariletti 649f97e933 EgtGeomKernel :
- correzione bug di triangolazione bezier.
2024-07-15 10:04:48 +02:00
Dario Sassi 21feed172d EgtGeomKernel :
- in CollisionAvoid corretto assegnamento riferimento (da fare prima del calcolo di hashgrids)
- in CalcPocketing corretti i punti che lasciavano memory leaks e migliorie stilistiche varie.
2024-07-15 07:08:11 +02:00
Riccardo Elitropi e853ff7f13 Aggiunto parametro per evitare casi ottimizzati 2024-07-12 20:09:04 +02:00
Riccardo Elitropi 95ff8b21b9 EgtGeomKernel :
- In CalcPocketing aggiunta funzione per Chain delle curve singole di svuotatura
- Inversione dei percorsi per lavorazione utensile
- Migliorati i controlli per le entrate da fuori.
2024-07-12 16:29:53 +02:00
Dario Sassi a7be952e11 EgtGeomKernel :
- in Pocketing, alla fine di CalcSpiral aggiunto reset dei TempProp delle curve componenti i percorsi risultanti.
2024-07-12 13:49:20 +02:00
Daniele Bariletti 7a67ce9333 Merge branch 'master' into MoreBezier 2024-07-12 12:07:26 +02:00
Daniele Bariletti 695350d3f6 EgtGeomKernel :
- correzione per evitare errori di triangolazione in prossimità dei poli in sup di Bezier.
2024-07-12 12:04:41 +02:00
Dario Sassi aade1d19f1 EgtGeomKernel :
- correzioni alle HashGrids per evitare problemi con memoria
- ottimizzazione calcolo CollisionAvoid con TestSeries e TestPath fatti di seguito
- piccole milgiorie a Pocketing.
2024-07-12 08:46:00 +02:00
Dario Sassi fd4677d099 EgtGeomKernel :
- piccola modifica in svuotature (tolto controllo di offset negativo).
2024-07-11 09:00:21 +02:00
Daniele Bariletti f7a28447fb EgtGeomKernel :
- correzione alla triangolazione delle bezier.
2024-07-10 16:41:34 +02:00
Daniele Bariletti 79b470b18b EgtGeomKernel :
- correzione alle rigate con Bezier.
2024-07-10 16:41:07 +02:00
Riccardo Elitropi f6d3873ecb EgtGeomKernel :
- In CalcPocketing, aggiunta inversione dei percorsi.
2024-07-10 12:35:20 +02:00
Riccardo Elitropi 92a8cdad99 EgtGeomKernel :
- in CalcPocketing aggiunto calcolo della Feed per percorsi a curva singola.
2024-07-10 10:24:23 +02:00
Daniele Bariletti 0c346e2bc7 Merge branch 'master' into MoreBezier 2024-07-10 08:53:12 +02:00
Daniele Bariletti d54caf4ae3 EgtGeomKernel :
- pulizia codice.
2024-07-10 08:52:47 +02:00
Dario Sassi ff9ea34ae1 EgtGeomKernel :
- in TestPosition di CollisionAvoid possibilità di restituire normale alla superficie nell'ultimo punto di contatto.
2024-07-09 16:48:54 +02:00
Daniele Bariletti c7035305e2 EgtGeomKernel :
- correzione alle rigate Bezier nella modalità MinDist.
2024-07-09 15:47:47 +02:00
Daniele Bariletti bc3c1e377e EgtGeomKernel :
- corretta la ruled con bezier in modalità MinDistPlus.
2024-07-09 13:04:48 +02:00
Riccardo Elitropi 98eff1b0b9 EgtGeomKernel :
- in CalcPocketing pulizia del codice e migliorie varie.
2024-07-09 11:10:49 +02:00
SaraP 052cc9e841 EgtGeomKernel 2.6g2 :
- aggiornamento versione.
2024-07-09 10:30:51 +02:00
SaraP b6a7ce4eef EgtGeomKernel :
- aggiunte funzioni che restituiscono il valore di offset che fa sparire una curva chiusa, una flat region o un suo chunk.
2024-07-09 10:25:24 +02:00
Daniele Bariletti 7a66ad27d8 EgtGeomKernel :
- correzioni alle rigate con le bezier.
2024-07-08 15:20:09 +02:00
Daniele Bariletti b4878f1ac0 EgtGeomKernel :
- correzioni e migliorie alle rigate con le bezier MINDISTPLUS.
2024-07-05 17:12:08 +02:00
Riccardo Elitropi 447ebe11e5 EgtGeomKernel :
- in calcolo pocketing, semplificate le curve di Feed e migliorata la gestione della superficie limite.
2024-07-04 16:43:44 +02:00
Dario Sassi 8981057d29 EgtGeomKernel :
- in calcolo pocketing piccole sistemazioni a salvataggio coefficiente feed (sempre in CurveTempParam).
2024-07-03 17:07:35 +02:00
Riccardo Elitropi 3270b573a8 EgtGeomKernel :
- in CalcPocketing aggiunte funzioni di Feed e migliorati i controlli sui lati aperti.
2024-07-03 13:23:52 +02:00
Daniele Bariletti 6df0cf3203 Merge branch 'master' into MoreBezier 2024-07-03 11:15:39 +02:00
Daniele Bariletti d67cca385e EgtGeomKernel :
- correzioni alle rigate con le Bezier.
2024-07-03 11:15:10 +02:00
SaraP f9d67442d6 EgtGeomKernel 2.6g1 :
- correzione offset nel caso di archi molto piccoli.
2024-07-01 10:54:37 +02:00
Dario Sassi dea96ccbcc EgtGeomKernel :
- miglioramenti a calcolo silhouette con CollisionAvoid compresa parallelizzazione
- piccole migliorie a CollisionAvoid
- migliorie e correzioni a CalcPocketing.
2024-06-29 18:45:19 +02:00
Dario Sassi 0f4be10330 EgtGeomKernel :
- in SurfTrimesh i metodi RemoveShell e RemovePart ora annullano i dati su shell e part per ricalcolarli quando richiesti.
2024-06-26 17:41:23 +02:00
Dario Sassi 121abf5864 EgtGeomKernel 2.6f4 :
- miglioramenti alla gestione di shell e part nelle superfici Trimesh.
2024-06-26 08:41:57 +02:00
Dario Sassi 38e836de2b Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-06-25 19:13:49 +02:00
Riccardo Elitropi 376c4e3693 EgtGeomKernel :
- In calcPocketing migliorate e semplificate le gestioni dei lati aperti, sia di bordi che di isole, anche con la superficie limite.
2024-06-25 13:29:23 +02:00
Dario Sassi 48ffd52b16 Merge commit '3e924113d3cf8134e84c53cf3f6b1d88c6ed1a7a' 2024-06-24 16:28:05 +02:00
Daniele Bariletti 9a16259ff5 EgtGeomKernel :
- correzione al miglioramento sul tempo di triangolazione delle bezier.
2024-06-20 12:52:03 +02:00
Daniele Bariletti 10ae269882 Merge branch 'master' into MoreBezier 2024-06-19 10:16:14 +02:00
Daniele Bariletti 9d845179a4 EgtGeomKernel :
- migliormaneto della velocità di calcolo per la triangolazione di superfici di Bezier.
- irrobustimento della stessa triangolazione.
2024-06-19 10:07:03 +02:00
Riccardo Elitropi 88bf84cca1 EgtGeomKernel :
- Aggiunta possibilità di entrate da isole aperte per CalcPocketing ( SpiralIN).
2024-06-18 11:15:44 +02:00
Riccardo Elitropi 5ba8f1df36 EgtGeomKernel :
- aggiunta gestione isole aperte.
2024-06-17 11:51:01 +02:00
Dario Sassi c4a05bcb2f EgtGeomKernel :
- miglioramenti al calcolo silhouette con CollisionAvoid
- modifiche a CollisionAvoid per permettere accelerazione con HashGrid anche a TestPosition.
2024-06-17 07:10:27 +02:00
Riccardo Elitropi 5841c9cae0 EgtGeomKernel :
- migliorie a CalcPocketing.
2024-06-14 16:46:56 +02:00
Dario Sassi 4fd03a78de EgtGeomKernel :
- correzione a calcolo silhouette con CAv di superficie trimesh (Level va tenuto costante nelle diverse funzioni).
2024-06-14 12:07:37 +02:00
Dario Sassi 420c072670 EgtGeomKernel :
- migliorie e sistemazioni in calcolo silhouette con CollisionAvoid.
2024-06-14 08:13:03 +02:00
SaraP 36477623b8 EgtGeomKernel :
- nel calcolo degli offset con Voronoi viene sempre eseguito l'offset sia a destra sia a sinistra ( per evitare problemi classificazione di vroni nel caso di cruve chiuse con piccole autointersezioni).
2024-06-13 09:51:43 +02:00
Dario Sassi 84d859dfe2 EgtGeomKernel :
- aggiunte funzioni per impostare e leggere TempProp e tempParam sulle curve di contorno delle Regioni.
2024-06-13 07:58:23 +02:00
Daniele Bariletti 09220bfd68 EgtGeomKernel :
- correzione all'utlima modifica alla triangolazione delle bezier.
2024-06-12 15:18:27 +02:00
Dario Sassi 42aaf6f3eb Merge commit '619905d72006d93976eff22ad76dc261e59a2790' 2024-06-12 13:29:26 +02:00
Dario Sassi 3f1f365451 EgtGeomKernel 2.6f3 :
- migliorie e irrobustimenti a calcolo silhouette di trimesh con collisio avoid.
2024-06-12 13:28:41 +02:00
Daniele Bariletti 9a29ee0e27 EgtGeomKernel :
- pulizia codice.
2024-06-12 09:19:28 +02:00
Daniele Bariletti 619905d720 EgtGeomKernel :
- correzione alla conversione di nurbs periodiche.
2024-06-11 16:05:53 +02:00
Daniele Bariletti 36ce855ef3 EgtGeomKernel :
- correzione alla conversione di nurbs periodiche.
2024-06-11 15:55:56 +02:00
Dario Sassi 9b0f2c7f59 EgtGeomKernel :
- aggiunta funzione e classe per calcolo silhouette tramite campionamento con utensile cilindrico
- in CollisionAvoid aggiunta funzione per verifica di insieme di punti (senza verifiche su intermedi).
2024-06-11 09:28:59 +02:00
Daniele Bariletti c637ccec47 EgtGeomKernel :
- aggiunta commento per triangolazione bezier.
2024-06-10 14:57:58 +02:00
Daniele Bariletti 8f27154604 EgtGeomKernel :
- correzione alla conversione di nurbs periodiche in bezier.
2024-06-10 14:57:28 +02:00
Dario Sassi 5d02732db6 EgtGeomKernel :
- correzione a Collision Avoid per utensile cilindrico che tocca vertice triangolo sul bordo
- in CalcPocketing tolti riferimenti a SafeZ e assegnato valore default a OpenMinSafe e a bAboveHead .
2024-06-07 18:59:26 +02:00
Daniele Bariletti 36657e17c4 EgtGeomKernel :
- correzione alla funzione per tagliare una sup di bezier con un piano.
2024-06-07 17:42:19 +02:00
Daniele Bariletti e2008bd479 EgtGeomKernel :
- correzione ulteriore alla triangolazione delle superfici bezier con patch con lati collassati.
2024-06-07 17:41:39 +02:00
Daniele Bariletti e32b85bc2d EgtGeomKernel :
- correzione alla triangolazione di sup. di Bezier con patch con lati collassati in un polo.
2024-06-07 16:00:24 +02:00
Dario Sassi 6dfc50e630 EgtGeomKernel 2.6f2 :
- in CAvToolSurfTm tolleranza negativa in Path vuol dire non controllare punto intermedio.
2024-06-07 13:02:07 +02:00
Riccardo Elitropi b4820ff255 EgtGeomKernel :
- piccole modifiche e migliorie a CalcPocketing.
2024-06-07 10:21:01 +02:00
Dario Sassi 515247a394 EgtGeomKernel :
- modifica a DistPointSurfTm per controllo tolleranza più efficace.
2024-06-06 17:43:26 +02:00
Dario Sassi b5c649821f Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-06-06 16:55:08 +02:00
Dario Sassi 9ba0c6f4cc EgtGeomKernel :
- miglioria nel calcolo silhouette di Trimesh.
2024-06-06 16:49:19 +02:00
Daniele Bariletti 35fc94d8cb Merge branch 'master' into MoreBezier 2024-06-06 09:21:18 +02:00
Daniele Bariletti a0316e280c EgtGeomKernel :
- piccola correzione.
2024-06-06 09:20:56 +02:00
Daniele Bariletti 84bcc715a8 EgtGeomKernel :
- piccola correzione di una tolleranza.
2024-06-06 09:16:53 +02:00
Daniele Bariletti b34d31029b EgtGeomKernel :
- piccola correzione.
2024-06-06 09:13:57 +02:00
Daniele Bariletti f67865f9cc EgtGeomKernel :
- piccola correzione di una tolleranza.
2024-06-06 09:12:47 +02:00
SaraP f48053a541 EgtGeomKernel :
- nelle booleane delle trimesh piccola modifica a DecomposeLoop.
2024-06-05 16:14:39 +02:00
Daniele Bariletti 8e917aa6d2 Merge branch 'master' of https://gitlab.steamware.net/egalware-cadcam/libreriebase/EgtGeomKernel 2024-06-05 09:11:18 +02:00
Daniele Bariletti f08dee836b EgtGeomKernel :
- correzioni alla conversione da nurbs a bezier per curve e superfici.
2024-06-05 09:11:00 +02:00
Daniele Bariletti 261e9ac0c8 EgtGeomKernel :
- correzioni alla conversione da nurbs a bezier per curve e superfici.
2024-06-05 09:10:22 +02:00
Dario Sassi b51d0c3e64 EgtGeomKernel :
- miglioramento a GetArc3P (ora riconosciuto come retta anche quando il punto intermedio coincide con uno dei due estremi).
2024-06-04 19:07:58 +02:00
Daniele Bariletti ac23938dd0 Merge branch 'master' into MoreBezier 2024-06-04 09:57:54 +02:00
Daniele Bariletti b9bac347e8 EgtGeomKernel :
- correzione alla gestione della conversione di curve nurbs periodiche.
2024-06-03 17:34:41 +02:00
Daniele Bariletti 980a1f62df EgtGeomKernel :
- correzione alla gestione di curve nurbs periodiche da convertire in bezier.
2024-06-03 17:32:14 +02:00
Daniele Bariletti 10c5d0fffe EgtGeomKernel :
- correzione alla rigata minDist con superficie Bezier.
2024-06-03 17:31:33 +02:00
Daniele Bariletti d7d36b670a EgtGeomKernel :
- correzione alla triangolazione di span bilineari in superfici di grado superiore all'uno.
2024-06-03 17:30:05 +02:00
Riccardo Elitropi 581551ee3e Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtGeomKernel 2024-06-03 12:06:48 +02:00
Riccardo Elitropi 487ce0c84b EgtGeomKernel :
- correzione percorsi tra più Chunk per SpiralIn/Out.
2024-06-03 12:06:44 +02:00
SaraP 5679733028 EgtGeomKernel :
- nelle operazioni booleane delle trimesh rilassata tolleranza per calcolo catene coincidenti durante la ritriangolazione.
2024-06-03 11:49:10 +02:00
Dario Sassi cd0fc4e449 EgtGeomKernel :
- piccole modifiche a Pocketing.
2024-06-03 09:10:04 +02:00
Dario Sassi e20b4b5b78 EgtGeomKernel 2.6f1 :
- modifiche a pocketing.
2024-06-03 08:15:38 +02:00
Dario Sassi b931582120 Merge commit 'bf14ab1332d4e190a3c3c8d8d802fd07b889b98b' 2024-05-31 14:48:33 +02:00
Riccardo Elitropi bf14ab1332 EgtGeomKernel :
Modifiche a CalcPocketing
- rimozione variabili statiche
- aggiunti casi ottimizzati Spiral
- estensione superfici sui lati aperti.
2024-05-31 13:10:15 +02:00
Daniele Bariletti 3b81a6b92e EgtGeomKernel :
- aggiunta la ruled bezier che aggiunge punti alla curva con meno punti ( da migliorare con la parametrizzazione sulla curva totale).
2024-05-30 16:53:37 +02:00
Dario Sassi 01bf44cf1e EgtGeomKernel :
- correzione a chiusura composita formata da un solo arco (il nuovo angolo giro al centro deve avere lo steso segno del precedente).
2024-05-30 16:45:38 +02:00
Dario Sassi b5d879cd3d EgtGeomKernel :
- in creazione regioni aggiunta chiusura loops di sicurezza dopo aggiustamenti
- in curve composite corretta chiusura per caso di un solo arco.
2024-05-30 11:20:45 +02:00
Dario Sassi 2b3c285190 EgtGeomKernel :
- modifiche stilistiche.
2024-05-30 08:45:43 +02:00
Dario Sassi 99bb83211c EgtGeomKernel 2.6e6 :
- a TestPath di CAvToolSurfTm passato un parametro in più per indicare la frazione di progress al completamento dell'operazione.
2024-05-29 18:57:12 +02:00
Daniele Bariletti b854c9588b EgtGeomKernel :
- implementata la versione ruled Bezier con la modalità isoparametrica.
2024-05-29 17:22:09 +02:00
Daniele Bariletti 2361225321 EgtGeomKernel :
- aggiunte le chiamate per la creazione di una rigata come superficie di Bezier
- aggiunta la funzione per la creazione del cono come Bezier ( ancora da implementare).
2024-05-28 16:29:10 +02:00
Daniele Bariletti eaf1138624 EgtGeomKernel :
- aggiunte le funzioni per creare rigate come superfici di Bezier
- piccole modifiche.
2024-05-28 16:25:43 +02:00
Daniele Bariletti ef5c67a4d5 EgtGeomKernel :
- aggiunti commenti
- aggiunte modifiche da implementare ulteriormente per la trinagolazione delle sup bilineari.
2024-05-28 16:23:58 +02:00
Daniele Bariletti ffd714d069 EgtGeomKernel :
- cambiato il nome ad una funzione.
2024-05-24 12:13:25 +02:00
Daniele Bariletti dc082d495e EgtGeomKernel :
- aggiunta limitazione alla creazione di una surf bezier tramite revolve nel caso in cui la curva attraversi l'asse di rivoluzione.
2024-05-24 11:30:04 +02:00
Daniele Bariletti e8e57ff793 Merge remote-tracking branch 'origin/master' into MoreBezier 2024-05-23 13:14:07 +02:00
Daniele Bariletti 3e16c4b56c EgtGeomKernel :
- aggiunti dei commenti.
2024-05-23 11:11:14 +02:00
Daniele Bariletti 77d3fcc7af EgtGeomKernel :
- aggiunta la funzione per il revolve con superfici di Bezier.
2024-05-22 12:13:15 +02:00
Daniele Bariletti 7322bf5034 EgtGeomKernel :
- correzioni alle funzioni per cambiare di grado le curve bezier.
2024-05-22 12:12:29 +02:00
Daniele Bariletti d340505593 Merge branch 'master' into MoreBezier 2024-05-21 15:49:54 +02:00
Daniele Bariletti 247849d112 EgtGeomKernel :
- aggiunta la funzione per modificare un singolo peso ad una curva di Bezier.
- aggiunta la funzione per lo screwing con una superficie di Bezier.
- aggiunto un commento.
2024-05-21 15:42:57 +02:00
Daniele Bariletti 1d4bccac4b EgtGeomKernel :
- aggiunte le funzioni per creare superfici di Bezier da Region e da Screwing.
2024-05-13 11:34:36 +02:00
Daniele Bariletti cc7aa66904 EgtGeomKernel :
- spostata la funzione CalcRegionPolyLines.
2024-05-13 10:30:24 +02:00
Daniele Bariletti 303a270359 EgtGeomKernel :
- gestione grado e razionalità delle curve convertite in Bezier.
2024-05-13 10:27:45 +02:00
Daniele Bariletti 5f56152a8b EgtGeomKernel :
- aggiunte le funzioni per creare SurfBez da estrusione e da FlatContour.
2024-05-09 15:13:25 +02:00
Daniele Bariletti d6567e94c4 EgtGeomKernel :
- aggiunta funzione MakeRational per curve di Bezier
- aggiunta funzione per la conversione in Bezier di una ICurve.
2024-05-08 17:49:31 +02:00
Daniele Bariletti a3f05c41fe Merge branch 'master' into MoreBezier 2024-05-08 08:52:20 +02:00
Daniele Bariletti 3143c00729 EgtGeomKernel :
- aggiunte le funzioni ProjectCurveOnSurfBez e la sua versione estesa.
2024-05-07 14:50:23 +02:00
Daniele Bariletti 621bf93ee9 Merge branch 'master' into MoreBezier 2024-05-07 10:32:08 +02:00
61 changed files with 15192 additions and 3896 deletions
+2
View File
@@ -317,6 +317,8 @@ AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst, bool bNeedSameProp)
pCrvCo->RemoveSmallDefects( 2 * LIN_TOL_MIN, ANG_TOL_STD_DEG, true) ;
// unisco eventuali tratti allineati
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, bNeedSameProp) ;
// richiudo i loop per sicurezza
pCrvCo->Close() ;
}
}
+2 -1
View File
@@ -134,7 +134,8 @@ GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd,
// calcolo arco non riuscito, se i punti sono allineati nel giusto verso per essere una retta
// verifico se i punti sono allineati nel giusto verso
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO) {
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO ||
AreSamePointApprox( ptOther, ptStart) || AreSamePointApprox( ptEnd, ptOther)) {
// creo l'oggetto retta
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
if ( IsNull( pLine))
+8 -8
View File
@@ -133,22 +133,22 @@ Attribs::Load( NgeReader& ngeIn)
unsigned char ucLev ;
if ( ! ngeIn.ReadUchar( ucLev, ","))
return false ;
m_Data[LEVEL] = CLIP( ucLev, GDB_LV_USER, GDB_LV_TEMP) ;
m_Data[LEVEL] = Clamp( ucLev, GDB_LV_USER, GDB_LV_TEMP) ;
// modo
unsigned char ucMode ;
if ( ! ngeIn.ReadUchar( ucMode, ","))
return false ;
m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
m_Data[MODE] = Clamp( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
// stato (se SEL è convertito in ON)
unsigned char ucStat ;
if ( ! ngeIn.ReadUchar( ucStat, ","))
return false ;
m_Data[STATUS] = CLIP( ucStat, GDB_ST_OFF, GDB_ST_ON) ;
m_Data[STATUS] = Clamp( ucStat, GDB_ST_OFF, GDB_ST_ON) ;
// marcatura (sempre OFF)
unsigned char ucMark ;
if ( ! ngeIn.ReadUchar( ucMark, ";"))
return false ;
m_Data[MARK] = CLIP( ucMark, GDB_MK_OFF, GDB_MK_OFF) ;
m_Data[MARK] = Clamp( ucMark, GDB_MK_OFF, GDB_MK_OFF) ;
// materiale
if ( ! ngeIn.ReadInt( m_Material, ";"))
return false ;
@@ -185,22 +185,22 @@ Attribs::DataFromString( const string& sParam)
int nLev ;
if ( ! FromString( vsParams[0], nLev))
return false ;
m_Data[LEVEL] = CLIP( nLev, GDB_LV_USER, GDB_LV_TEMP) ;
m_Data[LEVEL] = Clamp( nLev, GDB_LV_USER, GDB_LV_TEMP) ;
// modo
int nMode ;
if ( ! FromString( vsParams[1], nMode))
return false ;
m_Data[MODE] = CLIP( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
m_Data[MODE] = Clamp( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
// stato (ammessi solo OFF e ON)
int nStat ;
if ( ! FromString( vsParams[2], nStat))
return false ;
m_Data[STATUS] = CLIP( nStat, GDB_ST_OFF, GDB_ST_ON) ;
m_Data[STATUS] = Clamp( nStat, GDB_ST_OFF, GDB_ST_ON) ;
// marcatura (ammesso solo OFF)
int nMark ;
if ( ! FromString( vsParams[3], nMark))
return false ;
m_Data[MARK] = CLIP( nMark, GDB_MK_OFF, GDB_MK_OFF) ;
m_Data[MARK] = Clamp( nMark, GDB_MK_OFF, GDB_MK_OFF) ;
return true ;
}
+6 -8
View File
@@ -16,14 +16,12 @@
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EgtStringBase.h"
#include "/EgtDev/Include/EgtNumUtils.h"
class NgeWriter ;
class NgeReader ;
class GeomDB ;
//----------------------------------------------------------------------------
#define CLIP( nV, nMIN, nMAX) (( nV < nMIN) ? nMIN : (( nV > nMAX) ? nMAX : nV))
//----------------------------------------------------------------------------
class Attribs
{
@@ -46,14 +44,14 @@ class Attribs
bool Load( NgeReader& ngeIn) ;
void SetLevel( int nLev)
{ m_OldData[LEVEL] = m_Data[LEVEL] ;
m_Data[LEVEL] = CLIP( nLev, GDB_LV_USER, GDB_LV_TEMP) ; }
m_Data[LEVEL] = Clamp( nLev, GDB_LV_USER, GDB_LV_TEMP) ; }
void RevertLevel( void)
{ std::swap( m_Data[LEVEL], m_OldData[LEVEL]) ; }
int GetLevel( void) const
{ return m_Data[LEVEL] ; }
void SetMode( int nMode)
{ m_OldData[MODE] = m_Data[MODE] ;
m_Data[MODE] = CLIP( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ; }
m_Data[MODE] = Clamp( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ; }
void RevertMode( void)
{ std::swap( m_Data[MODE], m_OldData[MODE]) ; }
int GetMode( void) const
@@ -61,13 +59,13 @@ class Attribs
void SetStatus( int nStat)
{ if ( m_Data[STATUS] != GDB_ST_SEL)
m_OldData[STATUS] = m_Data[STATUS] ;
m_Data[STATUS] = CLIP( nStat, GDB_ST_OFF, GDB_ST_SEL) ; }
m_Data[STATUS] = Clamp( nStat, GDB_ST_OFF, GDB_ST_SEL) ; }
void RevertStatus( void)
{ SetStatus( m_OldData[STATUS]) ; }
int GetStatus( void) const
{ return m_Data[STATUS] ; }
void SetMark( void)
{ m_Data[MARK] = GDB_MK_ON ; }
void SetMark( int nMark)
{ m_Data[MARK] = Clamp( nMark, GDB_MK_OFF, GDB_MK_ON_2) ; }
void ResetMark( void)
{ m_Data[MARK] = GDB_MK_OFF ; }
int GetMark( void) const
+9 -6
View File
@@ -83,7 +83,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
//----------------------------------------------------------------------------
ICurve*
GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
const PolyLine& PL, double& dDist)
const PolyLine& PL, double& dDist, double dTol)
{
// calcolo la curva dove giacciono i punti di giunzione tra i due archi del biarco
PtrOwner<ICurve> pJCrv( CalcJCurve( ptP0, dDir0Deg, ptP1, dDir1Deg)) ;
@@ -122,7 +122,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
}
}
}
// non c'è intersezione, assegno valore medio
// non c'è intersezione, assegno valore medio
if ( dU < -0.5)
dU = 0.5 ;
// elimino casi vicino agli estremi, danno solo problemi
@@ -142,7 +142,10 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
Point3d ptPrev = ptCurr ;
while ( bPnt) {
double dLen = Dist( ptCurr, ptPrev) ;
int nStep = ( dLen < STEP ? 2 : 1) * int( dLen / STEP) + 1 ;
int nStep = int( dLen / STEP) + 1 ;
int nMinStep = ( dLen > 50 * dTol ? 3 : ( dLen > 10 * dTol ? 2 : 1)) ;
int nMaxStep = 10 ;
nStep = Clamp( nStep, nMinStep, nMaxStep) ;
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCoeff = double( i) / nStep ;
Point3d ptP = Media( ptPrev, ptCurr, dCoeff) ;
@@ -163,7 +166,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
static ICurve*
CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg)
{
// se i due punti coincidono, non si può fare alcunché
// se i due punti coincidono, non si può fare alcunché
if ( AreSamePointApprox( ptP0, ptP1))
return nullptr ;
@@ -205,14 +208,14 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
double dDir0RelDeg = DiffAngle( dDir0Deg, dDirDiffDeg) ;
// direzione iniziale secondo arco limite rispetto a direzione P0->P1 (dalla finale simmetrico e invert)
double dDir1RelDeg = - DiffAngle( dDir1Deg, dDirDiffDeg) ;
// nel caso di direzioni a 180deg si sceglie la più compatta
// nel caso di direzioni a 180deg si sceglie la più compatta
if ( abs( abs( dDir1RelDeg) - ANG_STRAIGHT) < EPS_SMALL)
dDir1RelDeg = ( dDir0RelDeg > 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ;
else if ( abs( abs( dDir0RelDeg) - ANG_STRAIGHT) < EPS_SMALL)
dDir0RelDeg = ( dDir1RelDeg > 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ;
// intervallo angolare ammissibile a partire da direzione iniziale primo arco ammissibile ( == Dir0)
double dDeltaAngDeg = - dDir0RelDeg + dDir1RelDeg ;
// se non è nella regione, prendo l'altra parte di arco
// se non è nella regione, prendo l'altra parte di arco
if ( ! AngleInSpan( dDirStartRelDeg, dDir0RelDeg, dDeltaAngDeg))
pArc->ToExplementary() ;
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1
+1 -1
View File
@@ -17,5 +17,5 @@
//-----------------------------------------------------------------------------
ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
const PolyLine& PL, double& dDist) ;
const PolyLine& PL, double& dDist, double dTol) ;
+513
View File
@@ -0,0 +1,513 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : CAvSilhouetteSurfTm.cpp Data : 08.06.24 Versione : 2.6f2
// Contenuto : Implementazione della funzione CAvSilhouetteSurfTm.
//
//
//
// Modifiche : 08.06.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "CAvSilhouetteSurfTm.h"
#include "GeoConst.h"
#include "/EgtDev/Include/EGkChainCurves.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include <thread>
#include <future>
using namespace std ;
//----------------------------------------------------------------------------
// Funzioni locali per calcolo isolinee con metodo Marching Squares
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Quadrato (C=corner E=edge) :
//
// C3 - E2 - C2
// | |
// E3 E1
// | |
// C0 - E0 - C1
//
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
static Point3d
CalcPoint( const Point3d& ptS, const Point3d& ptE, double dLevel,
const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid)
{
// Distanza tra gli estremi iniziali
double dDist = max( abs( ptS.x - ptE.x), abs( ptS.y - ptE.y)) ;
// Ricerca con metodo di bisezione (si arresta quando il medio è allineato agli estremi)
const int MAX_ITER = 10 ;
int nCount = 0 ;
Point3d ptP1 = ptS ;
Point3d ptP2 = ptE ;
Point3d ptMid = Media( ptP1, ptP2) ;
while ( nCount < MAX_ITER) {
// verifica del punto medio
ptMid.z = 0 ;
Point3d ptTest = GetToGlob( ptMid + cavTstm.GetToolHeight() * Z_AX, frGrid) ;
double dMove ;
cavTstm.TestPosition( ptTest, frGrid.VersZ(), frGrid.VersZ(), dMove) ;
ptMid.z = dMove ;
// se sta sulla linea che unisce gli estremi, basta interpolazione lineare
if ( abs( ptMid.z - ( ptP1.z + ptP2.z) / 2) < EPS_SMALL / 2)
return Media( ptP1, ptP2, ( ptP1.z - dLevel) / ( ptP1.z - ptP2.z)) ;
// altrimenti nuova suddivisione della parte con estremi da parte opposta rispetto al livello
bool b1On = ( ptP1.z > dLevel) ;
bool bMidOn = ( ptMid.z > dLevel) ;
if ( b1On != bMidOn)
ptP2 = ptMid ;
else
ptP1 = ptMid ;
ptMid = Media( ptP1, ptP2) ;
++ nCount ;
}
ptMid.z = dLevel ;
return ptMid ;
}
//----------------------------------------------------------------------------
static int
ProcessSquare( int nFlag, int& nI1s, int& nI1e, int& nI2s, int& nI2e)
{
static int LineTable[16][5] = { { 0, -1, -1, -1, -1},
{ 1, 0, 3, -1, -1},
{ 1, 1, 0, -1, -1},
{ 1, 1, 3, -1, -1},
{ 1, 2, 1, -1, -1},
{ 2, 0, 1, 2, 3},
{ 1, 2, 0, -1, -1},
{ 1, 2, 3, -1, -1},
{ 1, 3, 2, -1, -1},
{ 1, 0, 2, -1, -1},
{ 2, 1, 2, 3, 0},
{ 1, 1, 2, -1, -1},
{ 1, 3, 1, -1, -1},
{ 1, 0, 1, -1, -1},
{ 1, 3, 0, -1, -1},
{ 0, -1, -1, -1, -1}} ;
// flag fuori dai limiti
if ( nFlag < 0 || nFlag > 15)
return -1 ;
// nessuna linea
if ( LineTable[nFlag][0] == 0)
return 0 ;
// una linea
else if ( LineTable[nFlag][0] == 1) {
nI1s = LineTable[nFlag][1] ;
nI1e = LineTable[nFlag][2] ;
return 1 ;
}
// due linee
else if ( LineTable[nFlag][0] == 2) {
nI1s = LineTable[nFlag][1] ;
nI1e = LineTable[nFlag][2] ;
nI2s = LineTable[nFlag][3] ;
nI2e = LineTable[nFlag][4] ;
return 2 ;
}
return -1 ;
}
//----------------------------------------------------------------------------
static bool
TestSubEdges( unordered_map<int, Point3d>& umEdgePnt, const INTVECTOR& vEdgeInd, int nFirst, int nLast,
const DBLVECTOR& vdGrid, int nStepX, double dStep,
double dLevel, const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid)
{
for ( int k = nFirst ; k <= nLast ; ++ k) {
// recupero i differenti indici
int nKey = vEdgeInd[k] ;
int nInd = nKey / 2 ;
bool bOnX = ( ( nKey % 2) == 0) ;
int j = nInd / ( nStepX + 1) ;
int i = nInd % ( nStepX + 1) ;
// determino i punti estremi dell'edge
Point3d ptS{ i * dStep, j * dStep, vdGrid[nInd]} ;
Point3d ptE{ ptS.x + ( bOnX ? dStep : 0), ptS.y + ( bOnX ? 0 : dStep), vdGrid[nInd + ( bOnX ? 1 : nStepX + 1)]} ;
// calcolo il punto
Point3d ptQ = CalcPoint( ptS, ptE, dLevel, cavTstm, frGrid) ;
umEdgePnt[ nKey] = ptQ ;
}
return true ;
}
//----------------------------------------------------------------------------
static bool
MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep, double dRad,
double dLevel, const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid, POLYLINEVECTOR& vPL)
{
// Analizzo gli edge da cui passano le curve cercate
unordered_map<int, Point3d> umEdgePnt( 4 * ( nStepX + nStepY)) ;
INTVECTOR vEdgeInd ;
vEdgeInd.reserve( 4 * ( nStepX + nStepY)) ;
for ( int j = 0 ; j < nStepY ; ++ j) {
for ( int i = 0 ; i < nStepX ; ++ i) {
// indici dei vertici nella griglia
int nInd0 = i + j * ( nStepX + 1) ;
int nInd1 = ( i + 1) + j * ( nStepX + 1) ;
int nInd2 = ( i + 1) + ( j + 1) * ( nStepX + 1) ;
int nInd3 = i + ( j + 1) * ( nStepX + 1) ;
// flag del quadrato
bool bUp0 = ( vdGrid[nInd0] > dLevel) ;
bool bUp1 = ( vdGrid[nInd1] > dLevel) ;
bool bUp2 = ( vdGrid[nInd2] > dLevel) ;
bool bUp3 = ( vdGrid[nInd3] > dLevel) ;
// se tutti uguali, passo al successivo
if ( bUp0 == bUp1 && bUp0 == bUp2 && bUp0 == bUp3)
continue ;
// verifico quali calcolare
if ( bUp0 != bUp1) {
int nKey = 2 * nInd0 ;
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
umEdgePnt[ nKey] = P_INVALID ;
vEdgeInd.emplace_back( nKey) ;
}
}
if ( bUp3 != bUp2) {
int nKey = 2 * nInd3 ;
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
umEdgePnt[ nKey] = P_INVALID ;
vEdgeInd.emplace_back( nKey) ;
}
}
if ( bUp0 != bUp3) {
int nKey = 2 * nInd0 + 1 ;
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
umEdgePnt[ nKey] = P_INVALID ;
vEdgeInd.emplace_back( nKey) ;
}
}
if ( bUp1 != bUp2) {
int nKey = 2 * nInd1 + 1 ;
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
umEdgePnt[ nKey] = P_INVALID ;
vEdgeInd.emplace_back( nKey) ;
}
}
}
}
// Numero di edge da valutare
int nEdgeCnt = int( vEdgeInd.size()) ;
// Recupero il numero massimo di thread concorrenti
int nThreadMax = thread::hardware_concurrency() ;
bool bOk = true ;
// Se un solo thread o pochi punti
if ( nThreadMax <= 1 || nEdgeCnt < 50) {
TestSubEdges( umEdgePnt, vEdgeInd, 0, nEdgeCnt - 1, vdGrid, nStepX, dStep, dLevel, cavTstm, frGrid) ;
}
// altrimenti
else {
const int MAX_PARTS = 32 ;
INTINTVECTOR vFstLst( MAX_PARTS) ;
// calcolo le parti del vettore
int nPartCnt = min( nThreadMax, MAX_PARTS) ;
int nPartDim = nEdgeCnt / nPartCnt + 1 ;
for ( int i = 0 ; i < nPartCnt ; ++ i) {
vFstLst[i].first = i * nPartDim ;
vFstLst[i].second = min( ( i + 1) * nPartDim, nEdgeCnt) - 1 ;
}
// processo le parti
future<bool> vRes[MAX_PARTS] ;
for ( int i = 0 ; i < nPartCnt ; ++ i)
vRes[i] = async( launch::async, &TestSubEdges, ref( umEdgePnt), cref( vEdgeInd), vFstLst[i].first, vFstLst[i].second,
cref( vdGrid), nStepX, dStep, dLevel, cref( cavTstm), cref( frGrid)) ;
// attendo i risultati
int nFin = 0 ;
while ( nFin < nPartCnt) {
for ( int i = 0 ; i < nPartCnt ; ++ i) {
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
bOk = vRes[i].get() && bOk ;
++ nFin ;
}
}
}
}
// Predispongo il concatenamento
BIPNTVECTOR vBiPnt ;
vBiPnt.reserve( 2 * ( nStepX + nStepY)) ;
ChainCurves chainC ;
chainC.Init( false, EPS_SMALL, 2 * ( nStepX + nStepY)) ;
// Ciclo sui quadrati da analizzare
for ( int j = 0 ; j < nStepY ; ++ j) {
for ( int i = 0 ; i < nStepX ; ++ i) {
// indici dei vertici nella griglia
int nInd0 = i + j * ( nStepX + 1) ;
int nInd1 = ( i + 1) + j * ( nStepX + 1) ;
int nInd2 = ( i + 1) + ( j + 1) * ( nStepX + 1) ;
int nInd3 = i + ( j + 1) * ( nStepX + 1) ;
// flag del quadrato
int nFlag = ( vdGrid[nInd0] > dLevel ? 1 : 0) +
( vdGrid[nInd1] > dLevel ? 2 : 0) +
( vdGrid[nInd2] > dLevel ? 4 : 0) +
( vdGrid[nInd3] > dLevel ? 8 : 0) ;
// se quadrato con vertici tutti dello stesso tipo, passo al successivo
if ( nFlag == 0 || nFlag == 15)
continue ;
// chiavi
int vKey[4] = { 2 * nInd0, 2 * nInd1 + 1, 2 * nInd3, 2 * nInd0 + 1} ;
// calcolo segmenti da inserire
int nI1s, nI1e, nI2s, nI2e ;
int nSegCnt = ProcessSquare( nFlag, nI1s, nI1e, nI2s, nI2e) ;
if ( nSegCnt == -1)
return false ;
else if ( nSegCnt == 1) {
Point3d ptL1s = umEdgePnt.find( vKey[nI1s])->second ;
Point3d ptL1e = umEdgePnt.find( vKey[nI1e])->second ;
vBiPnt.emplace_back( ptL1s, ptL1e) ;
Vector3d vtDir1 = ptL1e - ptL1s ; vtDir1.Normalize() ;
chainC.AddCurve( int( vBiPnt.size()), ptL1s, vtDir1, ptL1e, vtDir1) ;
}
else if ( nSegCnt == 2) {
Point3d ptL1s = umEdgePnt.find( vKey[nI1s])->second ;
Point3d ptL1e = umEdgePnt.find( vKey[nI1e])->second ;
vBiPnt.emplace_back( ptL1s, ptL1e) ;
Vector3d vtDir1 = ptL1e - ptL1s ; vtDir1.Normalize() ;
chainC.AddCurve( int( vBiPnt.size()), ptL1s, vtDir1, ptL1e, vtDir1) ;
Point3d ptL2s = umEdgePnt.find( vKey[nI2s])->second ;
Point3d ptL2e = umEdgePnt.find( vKey[nI2e])->second ;
vBiPnt.emplace_back( ptL2s, ptL2e) ;
Vector3d vtDir2 = ptL2e - ptL2s ; vtDir2.Normalize() ;
chainC.AddCurve( int( vBiPnt.size()), ptL2s, vtDir2, ptL2e, vtDir2) ;
}
}
}
// Recupero i contorni
INTVECTOR vnId ;
while ( chainC.GetChainFromNear( ORIG, false, vnId)) {
// creo una composita
CurveComposite crvCompo ;
crvCompo.AddPoint( vBiPnt[vnId[0]-1].first) ;
for ( int i = 0 ; i < int( vnId.size()) ; ++ i) {
Point3d ptCurr = vBiPnt[vnId[i]-1].second ;
crvCompo.AddLine( ptCurr) ;
}
// la chiudo
crvCompo.Close() ;
// elimino le parti allineate
crvCompo.MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG) ;
// salto i contorni orari con area inferiore al doppio del quadrato
double dCmpArea ;
if ( ! crvCompo.GetAreaXY( dCmpArea) || ( dCmpArea < 0 && abs( dCmpArea) < 2 * dStep * dStep))
continue ;
// per test mettere a 1
#if 0
vPL.emplace_back( PolyLine()) ;
crvCompo.ApproxWithLines( 0, 0, ICurve::APL_SPECIAL, vPL.back()) ;
#else
// eseguo offset a sinistra pari allo step
OffsetCurve offsCompo ;
offsCompo.Make( &crvCompo, -( dRad - 2 * EPS_SMALL), ICurve::OFF_CHAMFER) ;
PtrOwner<ICurve> pCrvOffset( offsCompo.GetLongerCurve()) ;
if ( ! IsNull( pCrvOffset)) {
vPL.emplace_back( PolyLine()) ;
pCrvOffset->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, vPL.back()) ;
}
#endif
}
return true ;
}
//----------------------------------------------------------------------------
// Silhouette rispetto ad una direzione e sopra una quota di una superficie TriMesh
// ( dTol è il passo della griglia di campionamento e il raggio del cilindro di prova)
//----------------------------------------------------------------------------
bool
CAvSilhouetteSurfTm( const ISurfTriMesh& Stm, const Plane3d& plPlane, double dTol, POLYLINEVECTOR& vPL)
{
// verifico superficie
if ( &Stm == nullptr || ! Stm.IsValid())
return false ;
// verifico piano
if ( &plPlane == nullptr || plPlane.GetVersN().IsSmall())
return false ;
// verifico tolleranza
dTol = max( dTol, 100 * EPS_SMALL) ;
// verifico parametri di ritorno
if ( &vPL == nullptr)
return false ;
vPL.clear() ;
// sistema di riferimento nel piano
Frame3d frGrid ;
if ( ! frGrid.Set( plPlane.GetPoint(), plPlane.GetVersN()))
return false ;
// bounding box della superficie nel riferimento del piano
BBox3d b3Surf ;
if ( ! Stm.GetBBox( GetInvert( frGrid), b3Surf, BBF_STANDARD))
return false ;
// calcolo dati della griglia
const double EXTRA_XY = 1.5 * dTol ;
const double EXTRA_Z = 10 * dTol ;
b3Surf.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
int nStepX = int( ceil( b3Surf.GetDimX() / dTol)) ;
int nStepY = int( ceil( b3Surf.GetDimY() / dTol)) ;
frGrid.ChangeOrig( GetToGlob( b3Surf.GetMin(), frGrid)) ;
double dDimZ = b3Surf.GetDimZ() ;
double dLevelOffs = - b3Surf.GetMin().z ;
// calcolo dei punti della griglia (sul top del cilindro)
PNTUVECTOR vPntM( ( nStepX + 1) * ( nStepY + 1)) ;
for ( int j = 0 ; j <= nStepY ; ++ j) {
for ( int i = 0 ; i <= nStepX ; ++ i) {
int nInd = i + j * ( nStepX + 1) ;
Point3d ptP = GetToGlob( Point3d( i * dTol, j * dTol, dDimZ), frGrid) ;
vPntM[nInd] = { ptP, 0.} ;
}
}
// esecuzione della verifica
double dRad = SQRT1_2 * dTol ;
CAvToolSurfTm cavTstm ;
cavTstm.SetStdTool( dDimZ, dRad, 0) ;
cavTstm.SetSurfTm( Stm) ;
if ( ! cavTstm.TestSeries( vPntM, frGrid.VersZ(), frGrid.VersZ(), -1))
return false ;
// griglia degli spostamenti
DBLVECTOR vdGrid( ( nStepX + 1) * ( nStepY + 1)) ;
for ( int j = 0 ; j <= nStepY ; ++ j) {
for ( int i = 0 ; i <= nStepX ; ++ i) {
int nInd = i + j * ( nStepX + 1) ;
vdGrid[nInd] = vPntM[nInd].second ;
}
}
// calcolo della silhouette con il metodo MarchingSquares
double dLevel = dLevelOffs ;
if ( ! MarchingSquares( vdGrid, nStepX, nStepY, dTol, dRad, dLevel, cavTstm, frGrid, vPL))
return false ;
// riporto nella corretta posizione le curve trovate
for ( auto& PL : vPL)
PL.ToGlob( frGrid) ;
return true ;
}
//----------------------------------------------------------------------------
// Silhouette rispetto ad una direzione e sopra diverse quote di una superficie TriMesh
//----------------------------------------------------------------------------
ICAvParSilhouettesSurfTm*
CreateCAvParSilhouettesSurfTm( void)
{
return static_cast<ICAvParSilhouettesSurfTm*> ( new(nothrow) CAvParSilhouettesSurfTm) ;
}
//----------------------------------------------------------------------------
CAvParSilhouettesSurfTm::CAvParSilhouettesSurfTm( void)
: m_dTol( 100 * EPS_SMALL), m_nStepX( 0), m_nStepY( 0), m_dRad( m_dTol), m_dLevelOffs( 0), m_bGridOk( false)
{
}
//----------------------------------------------------------------------------
bool
CAvParSilhouettesSurfTm::SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol)
{
m_vpStm = vpStm ;
m_frGrid = frPlanes ;
m_dTol = max( dTol, 100 * EPS_SMALL) ;
m_dRad = SQRT1_2 * m_dTol ;
m_nStepX = 0 ;
m_nStepY = 0 ;
m_dDimZ = 0 ;
m_dLevelOffs = 0 ;
m_bGridOk = false ;
return true ;
}
//----------------------------------------------------------------------------
bool
CAvParSilhouettesSurfTm::Prepare( void)
{
// ingombro delle superfici nel riferimento dei piani
BBox3d b3All ;
Frame3d frInv = GetInvert( m_frGrid) ;
for ( auto pStm : m_vpStm) {
BBox3d b3Surf ;
if ( ! pStm->GetBBox( frInv, b3Surf, BBF_STANDARD))
return false ;
b3All.Add( b3Surf) ;
}
// calcolo dati della griglia
const double EXTRA_XY = 1.5 * m_dTol ;
const double EXTRA_Z = 10 * m_dTol ;
b3All.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
m_nStepX = int( ceil( b3All.GetDimX() / m_dTol)) ;
m_nStepY = int( ceil( b3All.GetDimY() / m_dTol)) ;
m_frGrid.ChangeOrig( GetToGlob( b3All.GetMin(), m_frGrid)) ;
m_dDimZ = b3All.GetDimZ() ;
m_dLevelOffs = - b3All.GetMin().z ;
// calcolo dei punti della griglia (sul top del cilindro)
PNTUVECTOR vPntM( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
int nInd = i + j * ( m_nStepX + 1) ;
Point3d ptP = GetToGlob( Point3d( i * m_dTol, j * m_dTol, m_dDimZ), m_frGrid) ;
vPntM[nInd] = { ptP, 0.} ;
}
}
// esecuzione della verifica
if ( ! m_cavTstm.SetStdTool( m_dDimZ, m_dRad, 0))
return false ;
if ( m_vpStm.empty() || ! m_cavTstm.SetSurfTm( *( m_vpStm[0])))
return false ;
for ( int k = 1 ; k < int( m_vpStm.size()) ; ++ k)
m_cavTstm.AddSurfTm( *( m_vpStm[k])) ;
if ( ! m_cavTstm.TestSeries( vPntM, m_frGrid.VersZ(), m_frGrid.VersZ(), -1))
return false ;
// griglia degli spostamenti
m_vdGrid.clear() ;
m_vdGrid.resize( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
int nInd = i + j * ( m_nStepX + 1) ;
m_vdGrid[nInd] = vPntM[nInd].second ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
CAvParSilhouettesSurfTm::GetSilhouette( double dLevel, POLYLINEVECTOR& vPL)
{
// reset risultato
vPL.clear() ;
// se necessario eseguo i calcoli preparatori
if ( ! m_bGridOk && ! Prepare())
return false ;
m_bGridOk = true ;
// calcolo della silhouette con il metodo MarchingSquares
dLevel += m_dLevelOffs ;
double dCalcLevel = max( dLevel, 0.) ;
if ( ! MarchingSquares( m_vdGrid, m_nStepX, m_nStepY, m_dTol, m_dRad, dCalcLevel, m_cavTstm, m_frGrid, vPL))
return false ;
// riporto nella corretta posizione le curve trovate
for ( auto& PL : vPL) {
if ( dLevel < dCalcLevel - EPS_SMALL)
PL.Translate( Vector3d{ 0, 0, dLevel - dCalcLevel}) ;
PL.ToGlob( m_frGrid) ;
}
return true ;
}
+44
View File
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : CAvSilhouetteSurfTm.h Data : 16.06.24 Versione : 2.6f2
// Contenuto : Dichiarazione della classe calcolo multi-silhouette.
//
//
//
// Modifiche : 10.06.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "CAvToolSurfTm.h"
#include "/EgtDev/Include/EGkCAvSilhouetteSurfTm.h"
//-----------------------------------------------------------------------------
class CAvParSilhouettesSurfTm : public ICAvParSilhouettesSurfTm
{
public :
bool SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol) override ;
bool GetSilhouette( double dLevel, POLYLINEVECTOR& vPL) override ;
public :
CAvParSilhouettesSurfTm( void) ;
private :
bool Prepare( void) ;
private :
CISURFTMPVECTOR m_vpStm ;
CAvToolSurfTm m_cavTstm ;
Frame3d m_frGrid ;
double m_dTol ;
int m_nStepX ;
int m_nStepY ;
double m_dRad ;
double m_dDimZ ;
double m_dLevelOffs ;
bool m_bGridOk ;
DBLVECTOR m_vdGrid ;
} ;
+208 -41
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2018-2018
// EgalTech 2018-2024
//----------------------------------------------------------------------------
// File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
// File : CAvToolSurfTm.cpp Data : 07.06.24 Versione : 2.6f2
// Contenuto : Implementazione della classe CAvToolSurfTm.
//
//
//
// Modifiche : 27.04.18 DS Creazione modulo.
//
// 07.06.24 DS Con tolleranza lineare negativa non si controlla il punto medio.
//
//----------------------------------------------------------------------------
@@ -37,10 +37,29 @@ CreateCAvToolSurfTm( void)
// CAvToolSurfTm
//----------------------------------------------------------------------------
CAvToolSurfTm::CAvToolSurfTm( void)
: m_Tool( false)
: m_frMove( false), m_Tool( false)
{
}
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::Clear( void)
{
// pulisco la lista dei puntatori a Stm
m_vSTM.clear() ;
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
m_vBaseInd.clear() ;
m_vBaseInd.emplace_back( 0) ;
// pulisco HashGrid 2d
m_HGrids.Clear() ;
// reset utensile
m_Tool.Clear() ;
// reset riferimento
m_frMove.Reset( false) ;
return true ;
}
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
@@ -50,6 +69,9 @@ CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
m_vBaseInd.clear() ;
m_vBaseInd.emplace_back( 0) ;
// pulisco HashGrid 2d
m_HGrids.Clear() ;
// non tocco l'utensile
// aggiungo la superficie
return AddSurfTm( Stm) ;
}
@@ -99,7 +121,8 @@ CAvToolSurfTm::SetGenTool( const ICurveComposite* pToolOutline)
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist)
CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove,
double& dTotDist, Vector3d* pvtTriaN) const
{
// Se utensile non definito, errore
if ( m_Tool.GetType() == Tool::UNDEF)
@@ -107,20 +130,148 @@ CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Ve
// Se direzioni non definite, errore
if ( vtDir.IsSmall() || vtMove.IsSmall())
return false ;
// Imposto il riferimento di movimento
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
m_frMove.Set( ORIG, vtMove, vtDir) ;
else
m_frMove.Set( ORIG, vtMove) ;
// Eseguo controllo
// Se riferimento di movimento già presente
if ( m_frMove.IsValid()) {
// Calcolo nuovo riferimento di movimento
Frame3d frMove ;
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
frMove.Set( ORIG, vtMove, vtDir) ;
else
frMove.Set( ORIG, vtMove) ;
// Se riferimenti di movimento uguali, sfrutto HashGrid 2d
if ( AreSameFrame( frMove, m_frMove)) {
// Eseguo controllo
Point3d ptCurr = ptT ;
Vector3d vtTriaN ;
dTotDist = MyTestPositionHG( ptCurr, vtDir, vtTriaN) ;
if ( pvtTriaN != nullptr)
*pvtTriaN = vtTriaN ;
return ( dTotDist > - EPS_SMALL) ;
}
}
// Altrimenti eseguo controllo diretto
Point3d ptCurr = ptT ;
dTotDist = MyTestPosition( ptCurr, vtDir) ;
Vector3d vtTriaN ;
dTotDist = MyTestPosition( ptCurr, vtDir, vtMove, vtTriaN) ;
if ( pvtTriaN != nullptr)
*pvtTriaN = vtTriaN ;
return ( dTotDist > - EPS_SMALL) ;
}
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol)
CAvToolSurfTm::TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dProgCoeff)
{
// Se utensile non definito, errore
if ( m_Tool.GetType() == Tool::UNDEF)
return false ;
// Se direzioni non definite, errore
if ( vtDir.IsSmall() || vtMove.IsSmall())
return false ;
// Se vettore vuoto, non devo fare alcunché
if ( vPntM.empty())
return true ;
// Calcolo nuovo riferimento di movimento
Frame3d frMove ;
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
frMove.Set( ORIG, vtMove, vtDir) ;
else
frMove.Set( ORIG, vtMove) ;
// Se riferimento di movimento non presente o diverso dal calcolato
if ( ! m_frMove.IsValid() || ! AreSameFrame( frMove, m_frMove)) {
// Salvo nuovo riferimento
m_frMove = frMove ;
// Ricalcolo HashGrid
if ( ! PrepareHashGrid())
return false ;
}
// Determino il numero di punti dell'insieme
m_nTotPnt = int( vPntM.size()) ;
// Recupero il numero massimo di thread concorrenti
int nThreadMax = thread::hardware_concurrency() ;
bool bOk = true ;
// Se un solo thread o pochi punti
if ( nThreadMax <= 1 || m_nTotPnt < 500) {
m_nCurrPnt = 0 ;
bOk = TestSubSeries( -1, vPntM, vtDir, 0, m_nTotPnt - 1, dProgCoeff) ;
ProcessEvents( int( 100 * dProgCoeff), 0) ;
}
// altrimenti
else {
const int MAX_PARTS = 32 ;
INTINTVECTOR vFstLst( MAX_PARTS) ;
// calcolo le parti del vettore
int nPartCnt = min( nThreadMax, MAX_PARTS) ;
int nPartDim = m_nTotPnt / nPartCnt + 1 ;
for ( int i = 0 ; i < nPartCnt ; ++ i) {
vFstLst[i].first = i * nPartDim ;
vFstLst[i].second = min( ( i + 1) * nPartDim, m_nTotPnt) - 1 ;
}
// processo le parti
m_nCurrPnt = 0 ;
m_bBreak = false ;
future<bool> vRes[MAX_PARTS] ;
for ( int i = 0 ; i < nPartCnt ; ++ i)
vRes[i] = async( launch::async, &CAvToolSurfTm::TestSubSeries, this, i, ref( vPntM), cref( vtDir), vFstLst[i].first, vFstLst[i].second, dProgCoeff) ;
// attendo i risultati
int nFin = 0 ;
int nNextPE = 0 ;
while ( nFin < nPartCnt) {
for ( int i = 0 ; i < nPartCnt ; ++ i) {
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
bOk = vRes[i].get() && bOk ;
++ nFin ;
}
}
if ( m_nCurrPnt > nNextPE) {
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 10) ;
nNextPE += STEP_PE ;
if ( nRes == 1)
m_bBreak = true ;
}
}
ProcessEvents( int( 100 * dProgCoeff), 0) ;
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir, int nFirst, int nLast, double dProgCoeff)
{
// Se vettore vuoto, non devo fare alcunché
if ( vPntM.empty())
return true ;
// Ciclo sui punti da verificare
for ( int i = nFirst ; i <= nLast ; ++ i) {
// verifico il punto
Vector3d vtTriaN ;
double dMove = MyTestPositionHG( vPntM[i].first, vtDir, vtTriaN) ;
vPntM[i].second = dMove ;
if ( dMove < - EPS_SMALL)
return false ;
++ m_nCurrPnt ;
// se singolo thread
if ( nId == -1) {
// gestione eventi (ogni STEP_PE punti)
if (( m_nCurrPnt % STEP_PE) == 0) {
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 0) ;
if ( nRes == 1)
return false ;
}
}
// altrimenti multithread
else {
if ( m_bBreak)
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol, double dProgCoeff)
{
// Se utensile non definito, errore
if ( m_Tool.GetType() == Tool::UNDEF)
@@ -131,14 +282,25 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
// Se lista vuota, non devo fare alcunché
if ( lPntM.empty())
return true ;
// Imposto il riferimento di movimento
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
m_frMove.Set( ORIG, vtMove, vtDir) ;
// Controllo la tolleranza lineare (se negativa non vanno fatti controlli sui punti medi)
if ( dLinTol > -EPS_ZERO)
dLinTol = max( dLinTol, EPS_SMALL) ;
else
m_frMove.Set( ORIG, vtMove) ;
// Predispongo Hash Grid
if ( ! PrepareHashGrid())
return false ;
dLinTol = -1 ;
// Calcolo nuovo riferimento di movimento
Frame3d frMove ;
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
frMove.Set( ORIG, vtMove, vtDir) ;
else
frMove.Set( ORIG, vtMove) ;
// Se riferimento di movimento non presente o diverso dal calcolato
if ( ! m_frMove.IsValid() || ! AreSameFrame( frMove, m_frMove)) {
// Salvo nuovo riferimento
m_frMove = frMove ;
// Ricalcolo HashGrid
if ( ! PrepareHashGrid())
return false ;
}
// Determino il numero di punti del path
m_nTotPnt = int( lPntM.size()) ;
// Recupero il numero massimo di thread concorrenti
@@ -146,8 +308,9 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
bool bOk = true ;
// Se un solo thread o pochi punti
if ( nThreadMax <= 1 || m_nTotPnt < 500) {
bOk = TestSubPath( -1, lPntM, vtDir, dLinTol) ;
ProcessEvents( 100, 0) ;
m_nCurrPnt = 0 ;
bOk = TestSubPath( -1, lPntM, vtDir, dLinTol, dProgCoeff) ;
ProcessEvents( int( 100 * dProgCoeff), 0) ;
}
// altrimenti
else {
@@ -167,7 +330,7 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
m_bBreak = false ;
future<bool> vRes[MAX_PARTS] ;
for ( int i = 0 ; i < nPartCnt ; ++ i)
vRes[i] = async( launch::async, &CAvToolSurfTm::TestSubPath, this, i, ref( vlPntM[i]), cref( vtDir), dLinTol) ;
vRes[i] = async( launch::async, &CAvToolSurfTm::TestSubPath, this, i, ref( vlPntM[i]), cref( vtDir), dLinTol, dProgCoeff) ;
// attendo i risultati
int nFin = 0 ;
int nNextPE = 0 ;
@@ -179,7 +342,7 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
}
}
if ( m_nCurrPnt > nNextPE) {
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt), 10) ;
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 10) ;
nNextPE += STEP_PE ;
if ( nRes == 1)
m_bBreak = true ;
@@ -191,16 +354,14 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
lPntM.pop_back() ;
lPntM.splice( lPntM.end(), vlPntM[i]) ;
}
ProcessEvents( 100, 0) ;
ProcessEvents( int( 100 * dProgCoeff), 0) ;
}
// pulisco HashGrid 2d
m_HGrids.Clear() ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol)
CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol, double dProgCoeff)
{
// Se lista vuota, non devo fare alcunché
if ( lPntM.empty())
@@ -212,12 +373,13 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
while ( itPntMCurr != lPntM.end()) {
// verifico il punto
ptCurr = itPntMCurr->first ;
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir) ;
itPntMCurr->second = - dMove ;
Vector3d vtTriaN ;
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir, vtTriaN) ;
itPntMCurr->second = dMove ;
if ( dMove < - EPS_SMALL)
return false ;
// se esiste il punto precedente devo verificare il medio
if ( itPntMPrev != lPntM.end()) {
// se esiste il punto precedente e richiesto devo verificare il medio
if ( itPntMPrev != lPntM.end() && dLinTol > 0) {
MyTestMidPointHG( lPntM, itPntMPrev, itPntMCurr, ptPrev, ptCurr, vtDir, dLinTol, 1) ;
}
// passo al successivo
@@ -229,7 +391,7 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
if ( nId == -1) {
// gestione eventi (ogni STEP_PE punti)
if (( m_nCurrPnt % STEP_PE) == 0) {
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt), 0) ;
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 0) ;
if ( nRes == 1)
return false ;
}
@@ -246,7 +408,7 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev)
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) const
{
// se superato limite di ricursione, esco
const int MAX_LEV = 10 ;
@@ -256,7 +418,8 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
Point3d ptMid = Media( ptPrev, ptCurr, 0.5) ;
// ne effettuo la correzione per evitare la collisione
Point3d ptNewMid = ptMid ;
double dMidMove = MyTestPositionHG( ptNewMid, vtDir) ;
Vector3d vtTriaN ;
double dMidMove = MyTestPositionHG( ptNewMid, vtDir, vtTriaN) ;
if ( dMidMove < - EPS_SMALL)
return false ;
// massima distanza ammissibile
@@ -265,7 +428,7 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
if ( abs(( Media( itPntMPrev->first, itPntMCurr->first, 0.5) - ptNewMid) * m_frMove.VersZ()) > 0.5 * dLinTol ||
SqDist( itPntMPrev->first, itPntMCurr->first) > dMaxSqDist) {
// aggiungo
lPntM.emplace( itPntMCurr, ptNewMid, - dMidMove) ;
lPntM.emplace( itPntMCurr, ptNewMid, dMidMove) ;
auto itPntMMid = itPntMCurr ;
-- itPntMMid ;
// verifico intervallo precedente
@@ -278,20 +441,22 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
//----------------------------------------------------------------------------
double
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir)
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, Vector3d& vtTriaN) const
{
double dTotDist = 0 ;
vtTriaN = V_NULL ;
for ( auto pStm : m_vSTM) {
Triangle3d Tria ;
for ( int nTria = pStm->GetFirstTriangle( Tria) ;
nTria != SVT_NULL ;
nTria = pStm->GetNextTriangle( nTria, Tria)) {
double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, m_frMove.VersZ()) ;
double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, vtMove) ;
if ( dDist < - EPS_SMALL)
return -1 ;
if ( dDist > EPS_SMALL) {
dTotDist += dDist ;
ptT += dDist * m_frMove.VersZ() ;
ptT += dDist * vtMove ;
vtTriaN = Tria.GetN() ;
}
}
}
@@ -300,7 +465,7 @@ CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir)
//----------------------------------------------------------------------------
double
CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir)
CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d& vtTriaN) const
{
// calcolo box utensile nel riferimento di movimento
BBox3d b3Tool ;
@@ -322,6 +487,7 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir)
}
// ciclo sui triangoli che intersecano box in 2d
double dTotDist = 0 ;
vtTriaN = V_NULL ;
INTVECTOR vnIds ;
if ( m_HGrids.Find( b3Tool, vnIds)) {
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
@@ -337,6 +503,7 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir)
if ( dDist > EPS_SMALL) {
dTotDist += dDist ;
ptT += dDist * m_frMove.VersZ() ;
vtTriaN = Tria.GetN() ;
}
else if ( dDist < -EPS_SMALL)
return -1 ;
@@ -379,7 +546,7 @@ CAvToolSurfTm::PrepareHashGrid( void)
//----------------------------------------------------------------------------
int
CAvToolSurfTm::GetSurfInd( int nT)
CAvToolSurfTm::GetSurfInd( int nT) const
{
// verifico la presenza di almeno un intervallo
if ( m_vBaseInd.size() < 2)
+11 -7
View File
@@ -36,20 +36,24 @@ class CAvToolSurfTm : public ICAvToolSurfTm
{ return m_Tool.GetHeigth() ; }
const ICurveComposite& GetToolOutline( bool bApprox = false) const override
{ return ( bApprox ? m_Tool.GetApproxOutline() : m_Tool.GetOutline()) ;}
bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist) override ;
bool TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol) override ;
bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove,
double& dTotDist, Vector3d* pvtTriaN = nullptr) const override ;
bool TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dProgCoeff = 1) override ;
bool TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol, double dProgCoeff = 1) override ;
public :
CAvToolSurfTm( void) ;
bool Clear( void) ;
private :
bool TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) ;
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir) ;
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) ;
bool TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir, int nFirst, int nLast, double dProgCoeff) ;
bool TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol, double dProgCoeff) ;
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, Vector3d& vtTriaN) const ;
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d& vtTriaN) const ;
bool MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) ;
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) const ;
bool PrepareHashGrid( void) ;
int GetSurfInd( int nT) ;
int GetSurfInd( int nT) const ;
private :
typedef std::vector<const SurfTriMesh*> CSURFTMPVECTOR ; // vettore di puntatori a const SurfTriMesh
+1 -1
View File
@@ -2503,7 +2503,7 @@ DiskSegmentEscapeDistLongMot( const Point3d& ptDiskCen, double dDiskRad,
double dSegDist = 0. ;
for ( int nSol = 0 ; nSol < nRoot ; ++ nSol) {
// Soluzione interna al segmento
if ( vdRoots[nSol] > 0. && vdRoots[nSol] < dSegLen) {
if ( vdRoots[nSol] > 0. && vdRoots[nSol] < dSegLen + EPS_ZERO) {
Point3d ptC = ptSeg + vdRoots[nSol] * vtSeg ;
// Distanza del punto soluzione dal piano del disco nella posizione iniziale
double dCurDist = PointPlaneSignedDist( ptC, ptDiskCen, vtMove) ;
+6974 -1603
View File
File diff suppressed because it is too large Load Diff
+677 -88
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -33,4 +33,5 @@ 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) ;
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez) ;
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
+180 -5
View File
@@ -13,6 +13,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "CurveAux.h"
#include "CurveBezier.h"
#include "CurveComposite.h"
#include "DistPointCrvBezier.h"
@@ -141,6 +142,32 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
return true ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::SetControlWeight( int nInd, double dW)
{
// verifico validità, razionalità e indice
if ( m_nStatus != OK || ! m_bRat || nInd < 0 || nInd > m_nDeg)
return false ;
// verifico che il peso non sia nullo o negativo
if ( dW < EPS_SMALL)
return false ;
// assegno il valore e il peso
m_vWeCtrl[nInd] = dW ;
// annullo analisi presenza singolarità
m_dParSing = - 2 ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::FromArc( const ICurveArc& crArc)
@@ -1542,7 +1569,7 @@ CurveBezier::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAngTo
return false ;
vtDir.ToSpherical( nullptr, nullptr, &dDir1Deg) ;
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist)) ;
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist, dLinTol)) ;
if ( IsNull( pCrv))
return false ;
}
@@ -1779,12 +1806,24 @@ CurveBezier::TrimStartEndAtParam( double dUStartTrim, double dUEndTrim)
// verifico che i trim non cancellino interamente la curva
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
return false ;
// se razionale devo trovare il punto di trim iniziale per ricalcolare il parametro di trim
Point3d ptStart ;
if( m_bRat)
GetPointD1D2( dUStartTrim, ptStart) ;
// trim finale
if ( ! TrimEndAtParam( dUEndTrim))
return false ;
// trim iniziale con il parametro opportunamente ricalcolato
double dNewUStartTrim = dUStartTrim / dUEndTrim ;
return TrimStartAtParam( dNewUStartTrim) ;
double dNewUStartTrim ;
if( m_bRat)
GetParamAtPoint( ptStart, dNewUStartTrim) ;
else
dNewUStartTrim = dUStartTrim / dUEndTrim ;
//trim iniziale
if( ! TrimStartAtParam( dNewUStartTrim))
return false ;
return true ;
}
//----------------------------------------------------------------------------
@@ -1800,7 +1839,10 @@ CurveBezier::TrimStartAtLen( double dLenTrim)
return false ;
// utilizzo il trim sui parametri
return TrimStartAtParam( dUTrim) ;
if( ! TrimStartAtParam( dUTrim))
return false ;
return true ;
}
//----------------------------------------------------------------------------
@@ -1816,7 +1858,10 @@ CurveBezier::TrimEndAtLen( double dLenTrim)
return false ;
// utilizzo il trim sui parametri
return TrimEndAtParam( dUTrim) ;
if( ! TrimEndAtParam( dUTrim))
return false ;
return true ;
}
//----------------------------------------------------------------------------
@@ -2208,3 +2253,133 @@ CurveBezier::ResetVoronoiObject() const
delete m_pVoronoiObj ;
m_pVoronoiObj = nullptr ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::MakeRational( void)
{
if ( m_bRat)
return true ;
// creo il vettore dei pesi e li setto tutti a 1
m_vWeCtrl.assign( m_nDeg + 1, 1) ;
// aggiorno il flag rational
m_bRat = true ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::MakeRationalStandardForm( void)
{
if ( ! m_bRat)
return false ;
double dW0 = m_vWeCtrl[0] ;
double dWn = m_vWeCtrl.back() ;
if( dW0 > 1- EPS_ZERO && dWn > 1 - EPS_ZERO)
return true ;
if( dW0 < EPS_ZERO || dWn < EPS_ZERO)
return false ;
// formula del Farin
double dCoeff = pow( dW0 / dWn, 1. / m_nDeg) ;
for ( int i = 0 ; i < m_nDeg + 1 ; ++i)
m_vWeCtrl[i] *= pow( dCoeff, i) / dW0 ;
return true ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::MakeNonRational( double dTol)
{
if( ! m_bRat)
return true ;
// controllo se i pesi sono tutti == 1 allora è una finta razionale e mi basta fare una copia dei punti di controllo
bool bIsActualRat = false ;
for ( int i = 0 ; i < m_nDeg ; ++i) {
if ( abs(m_vWeCtrl[i] - 1) > EPS_SMALL) {
bIsActualRat = true ;
break ;
}
}
bool bOk = true ;
if ( ! bIsActualRat) {
PtrOwner<CurveBezier> pNewBez( CreateBasicCurveBezier()) ;
for ( int p = 0 ; p < m_nDeg ; ++p) {
Point3d pt = GetControlPoint( p) ;
pNewBez->SetControlPoint( p, pt) ;
}
}
else {
// provo ad approssimare la curva di bezier con una controparte non razionale
int nDeg = m_nDeg ;
// punto di rientro in caso fallisca il primo tentativo
retry :
nDeg += 2 ;
PtrOwner<CurveBezier> pNewBez( CreateBasicCurveBezier()) ;
pNewBez->Init( nDeg, false) ;
PNTVECTOR vPntCtrl ;
PNTVECTOR vPntSampling ;
for ( int p = 0 ; p < nDeg + 1; ++p) {
Point3d pt ; GetPointD1D2( double(p) / nDeg, pt) ;
pNewBez->SetControlPoint( p, pt) ;
vPntCtrl.push_back( pt) ;
}
vPntSampling = vPntCtrl ;
int c = 0 ;
double dErr = INFINITO ;
while ( dErr > dTol && c < 100) {
double dErrMax = 0 ;
// calcolo le differenze tra i punti di sampling sulla nuova curva e quelli sulla curva originale
for ( int p = 0 ; p < nDeg + 1; ++p) {
Point3d pt ; pNewBez->GetPointD1D2( double(p) / nDeg, pt) ;
Vector3d vDiff = vPntSampling[p] - pt ;
double dErrLoc = vDiff.Len() ;
if( dErrLoc > dErrMax)
dErrMax = dErrLoc ;
// aggiorno il vettore dei punti di controllo della nuova curva
vPntCtrl[p] += vDiff ;
}
dErr = dErrMax ;
// aggiorno i punti di controllo della nuova curva
for ( int i = 0 ; i < nDeg + 1 ; ++i)
pNewBez->SetControlPoint( i, vPntCtrl[i]) ;
++c ;
}
// calcolo l'errore di approssimazione sulla curva
CalcBezierApproxError( this, pNewBez, dErr) ;
bOk = dErr < dTol ;
if( bOk) {
// aggiorno la curva di bezier originale con quella approssimata
Init( nDeg, false) ;
for( int i = 0 ; i < nDeg + 1 ; ++i) {
SetControlPoint( i, pNewBez->GetControlPoint( i)) ;
SetControlWeight( i, pNewBez->GetControlWeight( i)) ;
}
}
else if( nDeg < m_nDeg + 4)
goto retry ;
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
CurveBezier::IsALine( void) const
{
Point3d ptStart ; GetStartPoint( ptStart) ;
Point3d ptEnd ; GetEndPoint( ptEnd) ;
for ( int i = 1 ; i < m_nDeg ; ++i) {
Point3d ptCtrl = GetControlPoint( i) ;
DistPointLine dpl( ptCtrl, ptStart, ptEnd) ;
double dDist = 0 ; dpl.GetDist( dDist) ;
if( dDist > EPS_SMALL)
return false ;
}
return true ;
}
+5
View File
@@ -137,6 +137,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
bool Init( int nDeg, bool bIsRational) override ;
bool SetControlPoint( int nInd, const Point3d& ptCtrl) override ;
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
bool SetControlWeight( int nInd, double dW) override ;
bool FromArc( const ICurveArc& crArc) override ;
bool FromLine( const ICurveLine& crLine) override ;
int GetDegree( void) const override
@@ -148,6 +149,10 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
double GetControlWeight( int nInd, bool* pbOk = NULL) const override ;
bool GetControlPolygonLength( double& dLen) const override ;
int GetSingularParam( double& dPar) const override ;
bool MakeRational( void) override ;
bool MakeRationalStandardForm( void) override ;
bool MakeNonRational( double dTol) override ;
bool IsALine( void) const override ;
public : // IGeoObjRW
int GetNgeId( void) const override ;
+8 -8
View File
@@ -439,12 +439,12 @@ CurveByApprox::CalcSplitPoints( double dLinTol, double dAngTolDeg, double dLinFe
m_vSplits.push_back(i) ;
continue ;
}
// verifico linearità del tratto precedente
// verifico linearità del tratto precedente
bool bPrevLin = vtPrev.SqLen() > dSqLinFea &&
( m_vNextDer[i-1] * m_vPrevDer[i]) > dAngTolCos &&
( vtPrev ^ m_vNextDer[i-1]).SqLen() < dSqLinTol &&
( vtPrev ^ m_vPrevDer[i]).SqLen() < dSqLinTol ;
// verifico linearità del tratto successivo
// verifico linearità del tratto successivo
bool bNextLin = vtNext.SqLen() > dSqLinFea &&
( m_vNextDer[i] * m_vPrevDer[i+1]) > dAngTolCos &&
( vtNext ^ m_vNextDer[i]).SqLen() < dSqLinTol &&
@@ -483,7 +483,7 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
PtrOwner<ICurve> pCrv ;
double dMaxDist ;
// se la polilinea ha più di 2 punti
// se la polilinea ha più di 2 punti
if ( PL.GetPointNbr() > 2) {
// calcolo punti e direzioni agli estremi della polilinea usando la curva di Bezier
int nI ;
@@ -501,11 +501,11 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
ptP1 = m_vPnt[nI] ;
m_vPrevDer[nI].ToSpherical( nullptr, nullptr, &dDir1Deg) ;
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist)) ;
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist, dLinTol)) ;
if ( IsNull( pCrv))
return false ;
}
// se la polilinea è formata da 2 punti
// se la polilinea è formata da 2 punti
else if ( PL.GetPointNbr() == 2) {
// se molto vicini, esco
double dLen ;
@@ -561,7 +561,7 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
return false ;
}
// spezzo l'intervallo in due parti a metà
// spezzo l'intervallo in due parti a metà
double dParStart, dParEnd ;
if ( ! PL.GetFirstU( dParStart) || ! PL.GetLastU( dParEnd))
return false ;
@@ -569,9 +569,9 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
PolyLine PL2 ;
if ( ! PL.Split( dParMid, PL2))
return false ;
// prima metà
// prima metà
if ( ! BiArcOrSplit( nLev + 1, PL, dLinTol, dAngTolDeg, PA))
return false ;
// seconda metà
// seconda metà
return BiArcOrSplit( nLev + 1, PL2, dLinTol, dAngTolDeg, PA) ;
}
+19 -5
View File
@@ -291,9 +291,15 @@ CurveComposite::Close( void)
return true ;
// se molto vicini li modifico
if ( AreSamePointEpsilon( ptStart, ptEnd, 10 * EPS_SMALL)) {
// se un solo arco
if ( m_CrvSmplS.size() == 1 && m_CrvSmplS.front()->GetType() == CRV_ARC) {
CurveArc* pArc = GetBasicCurveArc( m_CrvSmplS.front()) ;
return pArc->ChangeAngCenter( pArc->GetAngCenter() > 0 ? ANG_FULL : -ANG_FULL) ;
}
// caso generale
Point3d ptMid = Media( ptStart, ptEnd) ;
if ( ! ModifyStart( ptMid) ||
! ModifyEnd( ptMid))
if ( ! m_CrvSmplS.front()->ModifyStart( ptMid) ||
! m_CrvSmplS.back()->ModifyEnd( ptMid))
return false ;
}
// altrimenti aggiungo la linea di chiusura
@@ -598,6 +604,10 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc)
if ( ! AddCurve( *pCrv))
return false ;
}
if ( ccSrc.m_nStatus == IS_A_POINT) {
m_ptStart = ccSrc.m_ptStart ;
m_nStatus = IS_A_POINT ;
}
return true ;
}
@@ -656,7 +666,7 @@ CurveComposite::Dump( string& sOut, bool bMM, const char* szNewLine) const
while ( pCrvSmpl != nullptr && i < MAX_CRV) {
// assegno ed emetto nome e tipo della curva semplice
sOut += "#" + ToString( i) + " " + pCrvSmpl->GetTitle() + szNewLine ;
// salvataggio della curva semplice
// dati della curva semplice
if ( ! pCrvSmpl->Dump( sOut, bMM, szNewLine))
return false ;
// passo alla successiva
@@ -879,8 +889,10 @@ CurveComposite::TestClosure( void)
// se distanza superiore al limite ridotto forzo i punti a coincidere
if ( ! AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT)) {
// se un solo arco
if ( m_CrvSmplS.size() == 1 && m_CrvSmplS.front()->GetType() == CRV_ARC)
return GetBasicCurveArc( m_CrvSmplS.front())->ChangeAngCenter( ANG_FULL) ;
if ( m_CrvSmplS.size() == 1 && m_CrvSmplS.front()->GetType() == CRV_ARC) {
CurveArc* pArc = GetBasicCurveArc( m_CrvSmplS.front()) ;
return pArc->ChangeAngCenter( pArc->GetAngCenter() > 0 ? ANG_FULL : -ANG_FULL) ;
}
// caso generale
Point3d ptM = Media( ptStart, ptEnd) ;
return ( m_CrvSmplS.front()->ModifyStart( ptM) &&
@@ -940,6 +952,8 @@ CurveComposite::IsFlat( Plane3d& plPlane, bool bUseExtrusion, double dToler) con
return false ;
}
} break ;
default :
return false ;
}
}
// recupero dati sulla planarità della polilinea
+2 -2
View File
@@ -50,7 +50,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
}
// altrimenti, per curve successive
else {
// verifico se la distanza minima dal box è superiore al minimo già trovato
// verifico se la distanza minima dal box è superiore al minimo già trovato
BBox3d b3B ;
if ( pCrvSmpl->GetLocalBBox( b3B) &&
b3B.SqDistFromPoint( ptP) <= m_dDist * m_dDist) {
@@ -105,7 +105,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
++ i ;
}
}
// con minima distanza più bassa
// con minima distanza più bassa
else if ( dCurrDist < m_dDist) {
// aggiorno i minimi
m_dDist = dCurrDist ;
+2
View File
@@ -47,6 +47,8 @@ DistPointCurve::DistPointCurve( const Point3d& ptP, const ICurve& Curve, bool bI
case CRV_COMPO :
CrvCompositeCalculate( ptP, Curve) ;
break ;
default :
break ;
}
// salvo il punto
m_ptP = ptP ;
+156
View File
@@ -0,0 +1,156 @@
//----------------------------------------------------------------------------
// EgalTech 2018-2020
//----------------------------------------------------------------------------
// File : DistPointSurfTm.cpp Data : 19.12.20 Versione : 2.2l3
// Contenuto : Implementazione della classe distanza Punto da Trimesh.
//
//
//
// Modifiche : 07.12.18 LM Creazione modulo.
//
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "SurfFlatRegion.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkDistPointSurfFr.h"
using namespace std ;
//----------------------------------------------------------------------------
DistPointSurfFr::DistPointSurfFr( const Point3d& ptP, const ISurfFlatRegion& frSurf)
: m_dDist( -1)
{
// FlatRegion non valida
if ( &frSurf == nullptr || ! frSurf.IsValid())
return ;
// Calcolo la distanza
Calculate( ptP, frSurf) ;
}
//----------------------------------------------------------------------------
void
DistPointSurfFr::Calculate( const Point3d& ptP, const ISurfFlatRegion& frSurf)
{
// Inizializzo distanza non calcolata
m_dDist = -1 ;
// Converto regione in classe base
const SurfFlatRegion* pSfr = GetBasicSurfFlatRegion( &frSurf) ;
if ( pSfr == nullptr)
return ;
// ciclo sulle parti della regione
for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; nC ++) {
// ciclo sui loop della parte di regione
for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; nL ++) {
PtrOwner<ICurve> pLoop( pSfr->GetLoop( nC, nL)) ;
if ( IsNull( pLoop)) {
m_dDist = -1 ;
return ;
}
DistPointCurve DPL( ptP, *pLoop) ;
double dDist ;
if ( DPL.GetDist( dDist) && ( m_dDist < -EPS_SMALL || dDist < m_dDist)) {
m_dDist = dDist ;
int nFlag ;
m_nMinChunk = nC ;
m_nMinLoop = nL ;
DPL.GetParamAtMinDistPoint( 0, m_dMinPar, nFlag) ;
DPL.GetMinDistPoint( 0, m_ptMinDistPoint, nFlag) ;
DPL.GetSideAtMinDistPoint( 0, pSfr->GetNormVersor(), m_nSide) ;
}
}
}
// se trovata, aggiorno minima distanza sul piano
if ( m_dDist > - EPS_SMALL) {
Point3d ptOn = ptP - ( ptP - pSfr->GetPlanePoint()) * pSfr->GetNormVersor() * pSfr->GetNormVersor() ;
m_dDistOnPlane = min( Dist( ptOn, m_ptMinDistPoint), m_dDist) ;
}
}
//----------------------------------------------------------------------------
bool
DistPointSurfFr::GetDist( double& dDist) const
{
if ( m_dDist < 0)
return false ;
dDist = m_dDist ;
return true ;
}
//----------------------------------------------------------------------------
bool
DistPointSurfFr::GetDistOnRegionPlane( double& dDist) const
{
if ( m_dDist < 0)
return false ;
dDist = m_dDistOnPlane ;
return true ;
}
//----------------------------------------------------------------------------
bool
DistPointSurfFr::GetPointAtMinDist( Point3d& ptMinDist) const
{
if ( m_dDist < 0)
return false ;
ptMinDist = m_ptMinDistPoint ;
return true ;
}
//----------------------------------------------------------------------------
bool
DistPointSurfFr::GetParamAtMinDist( int& nMinChunk, int& nMinLoop, double& dMinPar) const
{
if ( m_dDist < 0)
return false ;
nMinChunk = m_nMinChunk ;
nMinLoop = m_nMinLoop ;
dMinPar = m_dMinPar ;
return true ;
}
//----------------------------------------------------------------------------
bool
DistPointSurfFr::GetSideAtMinDist( int& nSide) const
{
if ( m_dDist < 0)
return false ;
nSide = m_nSide ;
return true ;
}
//----------------------------------------------------------------------------
bool
IsPointInsideSurfFr( const Point3d& ptP, const ISurfFlatRegion* pSfr, double dMinDist, bool& bInside, int& nChunk)
{
// default non include
bInside = false ;
nChunk = -1 ;
// verifica regione
if ( pSfr == nullptr || ! pSfr->IsValid())
return false ;
// verifico se la proiezione del punto sul piano della regione sta nel suo box
Point3d ptOn = ptP - ( ptP - pSfr->GetPlanePoint()) * pSfr->GetNormVersor() * pSfr->GetNormVersor() ;
BBox3d b3Box ;
pSfr->GetLocalBBox( b3Box) ;
b3Box.Expand( dMinDist) ;
if ( ! b3Box.Encloses( ptOn))
return true ;
// determino dove sta il punto
DistPointSurfFr DPR( ptP, *pSfr) ;
double dDist ; int nMinCh, nMinL; double dMinPar ; int nSide ;
if ( DPR.GetDistOnRegionPlane( dDist) && DPR.GetParamAtMinDist( nMinCh, nMinL, dMinPar) && DPR.GetSideAtMinDist( nSide)) {
if ( abs( dMinDist) < EPS_SMALL)
bInside = ( nSide != PRS_OUT) ;
else if ( dMinDist < 0)
bInside = ( nSide == PRS_IN && dDist > abs( dMinDist) - EPS_SMALL) ;
else
bInside = ( nSide != PRS_OUT || dDist < dMinDist + EPS_SMALL) ;
if ( bInside)
nChunk = nMinCh ;
}
return true ;
}
+34 -32
View File
@@ -21,10 +21,10 @@ using namespace std ;
//----------------------------------------------------------------------------
// Calcola la differenza fra i bounding-box A e B.
// L'insieme differenza non è un bounding-box, ma è esprimibile come unione di al più sei bounding-box.
// L'insieme differenza non è un bounding-box, ma è esprimibile come unione di al più sei bounding-box.
// Se l'insieme differenza fra i box non ha misura nulla viene restituito true, false altrimenti.
// I casi in cui non vengono trovati box di misura positiva sono quelli in cui o il box A è contenuto
// nel box B; uno di questi si verifica se il box A è vuoto.
// I casi in cui non vengono trovati box di misura positiva sono quelli in cui o il box A è contenuto
// nel box B; uno di questi si verifica se il box A è vuoto.
// Nel vettore vBoxDiff vengono restituiti i box la cui unione costituisce la differenza fra A e B.
static bool
BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDiff)
@@ -34,7 +34,7 @@ BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDi
// Se box A vuoto, risultato vuoto
if ( boxA.IsEmpty())
return false ;
// Se box B vuoto o i box non si intersecano, risultato è ancora A
// Se box B vuoto o i box non si intersecano, risultato è ancora A
BBox3d boxInt ;
if ( boxB.IsSmall() || ! boxA.FindIntersection( boxB, boxInt)) {
vBoxDiff.emplace_back( boxA) ;
@@ -94,7 +94,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
{
// Inizializzo distanza non calcolata
m_dDist = - 1. ;
// Controllo se la superficie è chiusa
// Controllo se la superficie è chiusa
m_bIsSurfClosed = tmSurf.IsClosed() ;
// Lavoro con l'oggetto superficie trimesh di base
@@ -107,8 +107,8 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
if ( b3Stm.IsEmpty())
return ;
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
@@ -118,17 +118,17 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
BBox3d boxPPrev( ptP) ;
BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ;
// Variabili distanza minima, indice del triangolo di distanza minima, punto di distanza minima
double dMinSqDist = DBL_MAX ;
double dMinDist = DBL_MAX ;
int nMinDistTriaIndex = SVT_NULL ;
Point3d ptMinDistPoint ;
// Finché non si verifica la condizione di terminazione ingrandisco il box.
// Finché non si verifica la condizione di terminazione ingrandisco il box.
pStm->ResetTempInts() ;
bool bContinue = true ;
// creazione del vettore dei triangoli più vicini a ptP
// creazione del vettore dei triangoli più vicini a ptP
vector<pair<int, Triangle3d>> vTria ; // <indice triangolo, Triangolo>
while ( bContinue) {
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
BOXVECTOR vBox ;
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
// Ciclo sui box differenza
@@ -136,7 +136,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
for ( const auto& b3Box : vBox) {
// interseco il box con quello della superficie e ne verifico la distanza minima dal punto
BBox3d b3Int ;
if ( ! b3Box.FindIntersection( b3Stm, b3Int) || b3Int.SqDistFromPoint( ptP) > dMinSqDist)
if ( ! b3Box.FindIntersection( b3Stm, b3Int) || b3Int.DistFromPoint( ptP) > dMinDist)
continue ;
// ricerca sui triangoli nel box
bCollide = true ;
@@ -149,17 +149,22 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
if ( pStm->GetTempInt( nT, nTriaTemp) && nTriaTemp == 0 && pStm->GetTriangle( nT, trCurTria)) {
pStm->SetTempInt( nT, 1) ;
DistPointTriangle distPT( ptP, trCurTria) ;
double dCurSqDist ;
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno
if ( distPT.GetSqDist( dCurSqDist)) {
if ( abs( dCurSqDist - dMinSqDist) < EPS_SMALL) // se distanze uguali...
vTria.emplace_back( make_pair( nT, trCurTria)) ; // aggiungo il triangolo
else if ( dCurSqDist < dMinSqDist) { // se minore...
vTria.clear() ; // pulisco il vettore
dMinSqDist = dCurSqDist ;
double dCurrDist ;
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno
if ( distPT.GetDist( dCurrDist)) {
// se distanze uguali...
if ( abs( dCurrDist - dMinDist) < EPS_SMALL)
// aggiungo il triangolo
vTria.emplace_back( make_pair( nT, trCurTria)) ;
// se minore...
else if ( dCurrDist < dMinDist) {
// pulisco il vettore
vTria.clear() ;
dMinDist = dCurrDist ;
nMinDistTriaIndex = nT ;
distPT.GetMinDistPoint( ptMinDistPoint) ;
vTria.emplace_back( make_pair( nT, trCurTria)) ; // aggiungo il triangolo
// aggiungo il triangolo
vTria.emplace_back( make_pair( nT, trCurTria)) ;
}
}
}
@@ -167,7 +172,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
}
}
// Se si verifica la condizione di terminazione arresto il ciclo altrimenti aggiorno i box
if ( ! bCollide || dMinSqDist < SQ_EPS_SMALL)
if ( ! bCollide || dMinDist < EPS_SMALL)
bContinue = false ;
else {
boxPPrev = boxP ;
@@ -180,10 +185,10 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
return ;
// salvo la distanza minima
m_dDist = sqrt( max( dMinSqDist, 0.)) ;
m_dDist = dMinDist ;
// salvo il punto a distanza minima
m_ptMinDistPoint = ptMinDistPoint ;
// se il punto è sulla TriMesh...
// se il punto è sulla TriMesh...
if ( m_dDist < EPS_SMALL) {
m_nMinDistTriaIndex = nMinDistTriaIndex ;
m_bIsInside = false ;
@@ -215,7 +220,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
// 1) calcolo i centroidi dei triangoli in questione
// 2) ottengo il punto medio di questi centroidi
// 3) controllo quale triangolo interseca il segmento che parte da ptP e arriva a tale punto
// 4) userò questo triangolo per classificare ptP
// 4) userò questo triangolo per classificare ptP
if ( bOutside == bInside) {
// calcolo il baricentro complessivo
Point3d ptBar_tot ;
@@ -236,9 +241,6 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
}
else // se informazioni coerenti
m_bIsInside = bInside ;
return ;
}
//----------------------------------------------------------------------------
@@ -291,8 +293,8 @@ GetSurfTmNearestVertex( const Point3d& ptP, const ISurfTriMesh& tmSurf)
if ( b3Stm.IsEmpty())
return SVT_NULL ;
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
@@ -304,11 +306,11 @@ GetSurfTmNearestVertex( const Point3d& ptP, const ISurfTriMesh& tmSurf)
// Variabili distanza minima
int nVert = SVT_NULL ;
double dMinSqDist = DBL_MAX ;
// Finché non si verifica la condizione di terminazione ingrandisco il box.
// Finché non si verifica la condizione di terminazione ingrandisco il box.
pStm->ResetTempInts() ;
bool bContinue = true ;
while ( bContinue) {
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
BOXVECTOR vBox ;
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
// Ciclo sui box differenza
BIN
View File
Binary file not shown.
+5
View File
@@ -281,6 +281,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="BBox3d.cpp" />
<ClCompile Include="BiArcs.cpp" />
<ClCompile Include="CalcPocketing.cpp" />
<ClCompile Include="CAvSilhouetteSurfTm.cpp" />
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
<ClCompile Include="CAvToolSurfTm.cpp" />
<ClCompile Include="CAvToolTriangle.cpp" />
@@ -309,6 +310,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="CurveByApprox.cpp" />
<ClCompile Include="CurveByInterp.cpp" />
<ClCompile Include="CurveCompositeOffset.cpp" />
<ClCompile Include="DistPointSurfFr.cpp" />
<ClCompile Include="IntersCurveSurfTm.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
@@ -319,9 +321,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="IntersPlaneVolZmap.cpp" />
<ClCompile Include="IntersLineSurfBez.cpp" />
<ClCompile Include="PolygonElevation.cpp" />
<ClCompile Include="ProjectCurveSurfBez.cpp" />
<ClCompile Include="Quaternion.cpp" />
<ClCompile Include="RotationMinimizingFrame.cpp" />
<ClCompile Include="RotationXplaneFrame.cpp" />
<ClCompile Include="SbzFromCurves.cpp" />
<ClCompile Include="SbzStandard.cpp" />
<ClCompile Include="Voronoi.cpp" />
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
@@ -340,6 +344,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h" />
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
<ClInclude Include="CAvSilhouetteSurfTm.h" />
<ClInclude Include="CDeBoxTria.h" />
<ClInclude Include="CDeCapsTria.h" />
<ClInclude Include="CDeConeFrustumTria.h" />
+15
View File
@@ -537,6 +537,18 @@
<ClCompile Include="Quaternion.cpp">
<Filter>File di origine\Base</Filter>
</ClCompile>
<ClCompile Include="CAvSilhouetteSurfTm.cpp">
<Filter>File di origine\GeoCollisionAvoid</Filter>
</ClCompile>
<ClCompile Include="ProjectCurveSurfBez.cpp">
<Filter>File di origine\GeoProject</Filter>
</ClCompile>
<ClCompile Include="SbzFromCurves.cpp">
<Filter>File di origine\GeoCreate</Filter>
</ClCompile>
<ClCompile Include="DistPointSurfFr.cpp">
<Filter>File di origine\GeoDist</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -1214,6 +1226,9 @@
<ClInclude Include="..\Include\EGkDistPointLine.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="CAvSilhouetteSurfTm.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtGeomKernel.rc">
+2 -2
View File
@@ -1254,13 +1254,13 @@ GdbIterator::GetCalcStatus( int& nStat) const
//----------------------------------------------------------------------------
bool
GdbIterator::SetMark( void)
GdbIterator::SetMark( int nMark)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// imposto la marcatura
return m_pCurrObj->SetMark() ;
return m_pCurrObj->SetMark( nMark) ;
}
//----------------------------------------------------------------------------
+1 -1
View File
@@ -103,7 +103,7 @@ class GdbIterator : public IGdbIterator
bool RevertStatus( void) override ;
bool GetStatus( int& nStat) const override ;
bool GetCalcStatus( int& nStat) const override ;
bool SetMark( void) override ;
bool SetMark( int nMark = GDB_MK_ON) override ;
bool ResetMark( void) override ;
bool GetMark( int& nMark) const override ;
bool GetCalcMark( int& nMark) const override ;
+4 -4
View File
@@ -612,14 +612,14 @@ GdbObj::GetCalcStatus( int& nStat, int nLev) const
//----------------------------------------------------------------------------
bool
GdbObj::SetMark( void)
GdbObj::SetMark( int nMark)
{
// verifico esistenza (con eventuale creazione) degli attributi
if ( GetSafeAttribs() == nullptr)
return false ;
// assegno la marcatura
m_pAttribs->SetMark() ;
m_pAttribs->SetMark( nMark) ;
return true ;
}
@@ -659,8 +659,8 @@ GdbObj::GetCalcMark( int& nMark) const
nObjMark = m_pAttribs->GetMark() ;
// se la marcatura è ON, non ho bisogno di sapere altro
if ( nObjMark == GDB_MK_ON) {
nMark = GDB_MK_ON ;
if ( nObjMark == GDB_MK_ON || nObjMark == GDB_MK_ON_2) {
nMark = nObjMark ;
return true ;
}
+1 -1
View File
@@ -81,7 +81,7 @@ class GdbObj
bool IsSelected( void) const ;
bool GetStatus( int& nStat) const ;
bool GetCalcStatus( int& nStat, int nLev = 0) const ;
bool SetMark( void) ;
bool SetMark( int nMark) ;
bool ResetMark( void) ;
bool GetMark( int& nMark) const ;
bool GetCalcMark( int& nMark) const ;
+2 -2
View File
@@ -2310,7 +2310,7 @@ GeomDB::GetCalcStatus( int nId, int& nStat) const
//----------------------------------------------------------------------------
bool
GeomDB::SetMark( int nId)
GeomDB::SetMark( int nId, int nMark)
{
// recupero l'oggetto
GdbObj* pGdbObj = GetGdbObj( nId) ;
@@ -2318,7 +2318,7 @@ GeomDB::SetMark( int nId)
return false ;
// imposto la marcatura
return pGdbObj->SetMark() ;
return pGdbObj->SetMark( nMark) ;
}
//----------------------------------------------------------------------------
+1 -1
View File
@@ -136,7 +136,7 @@ class GeomDB : public IGeomDB
bool RevertStatus( int nId) override ;
bool GetStatus( int nId, int& nStat) const override ;
bool GetCalcStatus( int nId, int& nStat) const override ;
bool SetMark( int nId) override ;
bool SetMark( int nId, int nMark = GDB_MK_ON) override ;
bool ResetMark( int nId) override ;
bool GetMark( int nId, int& nMark) const override ;
bool GetCalcMark( int nId, int& nMark) const override ;
+11 -11
View File
@@ -116,7 +116,7 @@ HashGrid1d::~HashGrid1d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_CellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
@@ -396,8 +396,10 @@ HashGrid1d::Enlarge( void)
for ( auto pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
pCell->m_neighborOffset = nullptr ;
}
delete[] m_cell ;
m_cell = nullptr ;
// ... the number of cells is doubled in each coordinate direction, ...
m_CellCount *= 2 ;
@@ -641,17 +643,15 @@ HashGrids1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
void
HashGrids1d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_ObjsList.clear() ;
m_ObjsMap.clear() ;
m_objsToAdd.clear() ;
m_nonGridObjs.clear() ;
for ( auto pGrid : m_GridList)
delete pGrid ;
m_GridList.clear() ;
m_bActivate = true ;
m_bGridActive = false ;
m_b3Objs.Reset() ;
}
+11 -11
View File
@@ -125,7 +125,7 @@ HashGrid2d::~HashGrid2d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_xyCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
@@ -445,8 +445,10 @@ HashGrid2d::Enlarge( void)
for ( auto pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
pCell->m_neighborOffset = nullptr ;
}
delete[] m_cell ;
m_cell = nullptr ;
// ... the number of cells is doubled in each coordinate direction, ...
m_xCellCount *= 2 ;
@@ -695,17 +697,15 @@ HashGrids2d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
void
HashGrids2d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_ObjsList.clear() ;
m_ObjsMap.clear() ;
m_objsToAdd.clear() ;
m_nonGridObjs.clear() ;
for ( auto pGrid : m_GridList)
delete pGrid ;
m_GridList.clear() ;
m_bActivate = true ;
m_bGridActive = false ;
m_b3Objs.Reset() ;
}
+11 -11
View File
@@ -132,7 +132,7 @@ HashGrid3d::~HashGrid3d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_xyzCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
@@ -486,8 +486,10 @@ HashGrid3d::Enlarge( void)
for ( auto pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
pCell->m_neighborOffset = nullptr ;
}
delete[] m_cell ;
m_cell = nullptr ;
// ... the number of cells is doubled in each coordinate direction, ...
m_xCellCount *= 2 ;
@@ -739,17 +741,15 @@ HashGrids3d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
void
HashGrids3d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_ObjsList.clear() ;
m_ObjsMap.clear() ;
m_objsToAdd.clear() ;
m_nonGridObjs.clear() ;
for ( auto pGrid : m_GridList)
delete pGrid ;
m_GridList.clear() ;
m_bActivate = true ;
m_bGridActive = false ;
m_b3Objs.Reset() ;
}
+8 -5
View File
@@ -17,6 +17,9 @@
using namespace std ;
//----------------------------------------------------------------------------
static const double EPS_INTER_ARC = 0.1 * EPS_SMALL ;
//----------------------------------------------------------------------------
IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
{
@@ -60,15 +63,15 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
vtDir /= dDist ;
// cerchi esterni -> nessuna intersezione
if ( dDist > m_Arc1.GetRadius() + m_Arc2.GetRadius() + EPS_SMALL)
if ( dDist > m_Arc1.GetRadius() + m_Arc2.GetRadius() + EPS_INTER_ARC)
return ;
// cerchi interni -> nessuna intersezione
if ( dDist < abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) - EPS_SMALL)
if ( dDist < abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) - EPS_INTER_ARC)
return ;
// cerchi coincidenti -> sovrapposizioni e/o intersezioni agli estremi
if ( dDist < EPS_SMALL && abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) < EPS_SMALL) {
if ( dDist < EPS_SMALL && abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) < EPS_INTER_ARC) {
// coefficiente da parametro dell'arco 1 a lunghezza
double dU2L = abs( m_Arc1.GetAngCenter()) * DEGTORAD * m_Arc1.GetRadius() ;
// determino se sono equiversi o controversi
@@ -236,7 +239,7 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
double dSqH = m_Arc1.GetRadius() * m_Arc1.GetRadius() - dA * dA ;
// cerchi tangenti esterni -> una intersezione
if ( abs( dDist - ( m_Arc1.GetRadius() + m_Arc2.GetRadius())) < EPS_SMALL) {
if ( abs( dDist - ( m_Arc1.GetRadius() + m_Arc2.GetRadius())) < EPS_INTER_ARC) {
// tolleranza tangenziale sull'intersezione
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
// calcolo il punto di intersezione
@@ -358,7 +361,7 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
}
// cerchi tangenti interni -> una intersezione
if ( abs( dDist - abs( m_Arc1.GetRadius() - m_Arc2.GetRadius())) < EPS_SMALL) {
if ( abs( dDist - abs( m_Arc1.GetRadius() - m_Arc2.GetRadius())) < EPS_INTER_ARC) {
// tolleranza tangenziale sull'intersezione
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
// determino quale dei due contiene l'altro
+8
View File
@@ -78,6 +78,8 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB,
case CRV_COMPO :
LineCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
break ;
default :
break ;
}
break ;
case CRV_ARC :
@@ -91,6 +93,8 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB,
case CRV_COMPO :
ArcCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
break ;
default :
break ;
}
break ;
case CRV_COMPO :
@@ -104,8 +108,12 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB,
case CRV_COMPO :
CrvCompoCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
break ;
default :
break ;
}
break ;
default :
break ;
}
// per curve approssimate, sistemo...
AdjustIntersParams( ( pCalcCrv[0] != m_pCurve[0]), ( pCalcCrv[1] != m_pCurve[1])) ;
+6 -8
View File
@@ -2,7 +2,7 @@
// 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.
// Contenuto : Implementazione di alcune funzioni di utilità per gli offset delle curve.
//
//
//
@@ -25,11 +25,7 @@ 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))
if ( IsFillet( pCrvCo->GetCurve( i), dDist))
pCrvCo->SetCurveTempParam( i, 1.0) ;
else
pCrvCo->SetCurveTempParam( i, 0.0) ;
@@ -39,12 +35,14 @@ IdentifyFillets( ICurveComposite* pCrvCo, double dDist)
//----------------------------------------------------------------------------
bool
IsFillet( ICurve* pCrv, double dDist)
IsFillet( const ICurve* pCrv, double dDist)
{
if ( pCrv == nullptr)
return false ;
// deve essere un arco
if ( pCrv->GetType() != CRV_ARC)
return false ;
CurveArc* pArc = GetBasicCurveArc( pCrv) ;
const CurveArc* pArc = GetBasicCurveArc( pCrv) ;
// deve avere raggio uguale alla distanza di offset
if ( abs( pArc->GetRadius() - abs( dDist)) > EPS_SMALL)
return false ;
+2 -2
View File
@@ -2,7 +2,7 @@
// 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.
// Contenuto : Dichiarazione di alcune funzioni di utilità per gli offset delle curve.
//
//
//
@@ -16,6 +16,6 @@
//----------------------------------------------------------------------------
bool IdentifyFillets( ICurveComposite* pCrvCo, double dDist) ;
bool IsFillet( ICurve* pCrv, double dDist) ;
bool IsFillet( const ICurve* pCrv, double dDist) ;
bool AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType) ;
bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
+29 -23
View File
@@ -74,7 +74,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
// verifico che la curva esista
if ( pCrv == nullptr)
return false ;
// verifico se la curva è un segmento di retta
// verifico se la curva è un segmento di retta
bool bIsLine = false ;
const CurveLine* pLine = GetBasicCurveLine( pCrv) ;
if ( pLine != nullptr)
@@ -85,7 +85,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
if ( pCompo != nullptr && pCompo->IsALine( m_dLinTol, ptStart, ptEnd))
bIsLine = true ;
}
// verifico che la curva sia piana (per le linee è comunque sempre vero)
// verifico che la curva sia piana (per le linee è comunque sempre vero)
Plane3d plPlane ;
if ( ! pCrv->IsFlat( plPlane, bIsLine, 10 * EPS_SMALL) && ! bIsLine)
return false ;
@@ -167,7 +167,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
// -------------------- OFFSET STANDARD ---------------------------------
if ( ! USE_VORONOI) {
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+)
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+)
if ( ! ccCopy.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, ANG_TOL_STD_DEG))
return false ;
@@ -187,11 +187,11 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
if ( ! ccCopy.MergeCurves( m_dLinTol, ANG_TOL_STD_DEG, bClosed, true))
return false ;
// verifico se il punto iniziale è stato modificato
// verifico se il punto iniziale è stato modificato
Point3d ptNewStart ; ccCopy.GetStartPoint( ptNewStart) ;
bChangeStart = ( ! AreSamePointApprox( ptNewStart, ptStart)) ;
// calcolo le lunghezze delle diverse entità
// calcolo le lunghezze delle diverse entità
DBLVECTOR vLens ;
{
const ICurve* pCrv1 = ccCopy.GetFirstCurve() ;
@@ -203,7 +203,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
pCrv1 = ccCopy.GetNextCurve() ;
}
}
// calcolo gli angoli tra le diverse entità
// calcolo gli angoli tra le diverse entità
DBLVECTOR vAngs ;
{
vAngs.push_back( 0) ;
@@ -230,7 +230,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
vAngs.push_back( 0) ;
}
// primo passo : estraggo entità dalla copia, loro offset elementare e aggiunta raccordi esterni (sempre fillet)
// primo passo : estraggo entità dalla copia, loro offset elementare e aggiunta raccordi esterni (sempre fillet)
CurveComposite ccCopy2 ;
if ( ! ccCopy2.CopyFrom( &ccCopy))
return false ;
@@ -285,9 +285,9 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
// se originale chiuso, devo confrontare anche ultima e prima curva
if ( bClosed && m_CrvLst.size() >= 2) {
// la curva precedente è l'ultima dell'offset
// la curva precedente è l'ultima dell'offset
ICurve* pCrv1 = m_CrvLst.back() ;
// la curva successiva ora è la prima dell'offset
// la curva successiva ora è la prima dell'offset
ICurve* pCrv2 = m_CrvLst.front() ;
// verifico relazione con la curva precedente e aggiungo eventuali curve intermedie
CurveComposite ccTemp ;
@@ -334,7 +334,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
bool bNextInt = NextIsLine( iIter, m_CrvLst, bClosed) &&
NextIsLonger( nInd1, vLens, bClosed) &&
( ( dDist < 0 && vAngs[nInd1] > 0) || ( dDist > 0 && vAngs[nInd1] < 0)) ;
// calcolo la massima estensione di offset (Voronoi con entità adiacenti)
// calcolo la massima estensione di offset (Voronoi con entità adiacenti)
double dMaxDist = INFINITO ;
if ( bPrevInt && bNextInt) {
double dTgA = tan( 0.5 * ( ANG_STRAIGHT - abs( vAngs[nInd1-1])) * DEGTORAD) ;
@@ -502,7 +502,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
// sesto passo : se curva aperta, elimino i tratti che stanno nella circonferenza di offset dei punti estremi
if ( ! bClosed) {
// ciconferenza sull'estremità iniziale
// ciconferenza sull'estremità iniziale
Point3d ptStart ; ccCopy.GetStartPoint( ptStart) ;
PtrOwner<CurveArc> pCircS( CreateBasicCurveArc()) ;
if ( IsNull( pCircS) || ! pCircS->Set( ptStart, Z_AX, abs( dDist)))
@@ -551,7 +551,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
// passo alla successiva
++ iIter ;
}
// circonferenza sull'estremità finale
// circonferenza sull'estremità finale
Point3d ptEnd ; ccCopy.GetEndPoint( ptEnd) ;
PtrOwner<CurveArc> pCircE( CreateBasicCurveArc()) ;
if ( IsNull( pCircE) || ! pCircE->Set( ptEnd, Z_AX, abs( dDist)))
@@ -697,6 +697,12 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
// calcolo offset con Voronoi
ICURVEPOVECTOR vOffs ;
voronoiObj->CalcOffset( vOffs, dDist, nType) ;
if ( vOffs.size() == 0) {
// se non ho ottenuto offset ritento con valore leggermente diverso per le tolleranze di vroni
double dCorr = ( dDist > 0 ? - VRONI_OFFS_TOL : VRONI_OFFS_TOL) ;
voronoiObj->CalcOffset( vOffs, dDist + dCorr, nType) ;
}
for ( int i = 0 ; i < ( int)vOffs.size() ; i ++)
m_CrvLst.emplace_back( Release( vOffs[i])) ;
@@ -817,7 +823,7 @@ PreviousIsLine( ICURVEPLIST::const_iterator iIter, const ICURVEPLIST& CrvLst, bo
// se non esiste e curva chiusa prendo l'ultimo
if ( iPrev == CrvLst.end() && bClosed)
-- iPrev ;
// se non esiste o non è una linea, test fallito
// se non esiste o non è una linea, test fallito
if ( iPrev == CrvLst.end() || (*iPrev)->GetType() != CRV_LINE )
return false ;
// test superato
@@ -830,7 +836,7 @@ PreviousIsLonger( int nInd1, const DBLVECTOR& vLens, bool bClosed)
{
// massimo indice nel vettore
int nMax = int( vLens.size()) - 1 ;
// verifico validità indice (questo indice è incrementato di 1)
// verifico validità indice (questo indice è incrementato di 1)
if ( nInd1 < 1 || nInd1 > nMax + 1)
return false ;
// indice del precedente nel vettore di lunghezze
@@ -854,7 +860,7 @@ NextIsLine( ICURVEPLIST::const_iterator iIter, const ICURVEPLIST& CrvLst, bool b
// se non esiste e curva chiusa prendo il primo
if ( iNext == CrvLst.end() && bClosed)
iNext = CrvLst.begin() ;
// se non esiste o non è una linea, test fallito
// se non esiste o non è una linea, test fallito
if ( iNext == CrvLst.end() || (*iNext)->GetType() != CRV_LINE )
return false ;
// test superato
@@ -867,7 +873,7 @@ NextIsLonger( int nInd1, const DBLVECTOR& vLens, bool bClosed)
{
// massimo indice nel vettore
int nMax = int( vLens.size()) - 1 ;
// verifico validità indice (questo indice è incrementato di 1)
// verifico validità indice (questo indice è incrementato di 1)
if ( nInd1 < 1 || nInd1 > nMax + 1)
return false ;
// indice del successivo nel vettore di lunghezze
@@ -946,7 +952,7 @@ VerifyAndAdjustSamePoint( ICurve* pCrv1, ICurve* pCrv2, int& nRes)
nRes = 4 ;
return true ;
}
// se coincidono esattamente, va bene così
// se coincidono esattamente, va bene così
if ( AreSamePointExact( ptP1, ptP2)) {
nRes = 0 ;
return true ;
@@ -976,7 +982,7 @@ VerifyAndAdjustInternalAngle( ICurve* pCrv1, ICurve* pCrv2, int& nRes)
IntersCurveCurve intCC( *pCrv1, *pCrv2) ;
if ( intCC.GetIntersCount() == 0)
return false ;
// prendo l'intersezione più vicina al punto medio tra gli estremi delle curve
// prendo l'intersezione più vicina al punto medio tra gli estremi delle curve
Point3d ptP1, ptP2 ;
if ( ! pCrv1->GetEndPoint( ptP1) || ! pCrv2->GetStartPoint( ptP2))
return false ;
@@ -1024,7 +1030,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
vtDir2.Invert() ;
}
// verifico sia angolo esterno (accetto se entità quasi esattamente sovrapposte)
// verifico sia angolo esterno (accetto se entità quasi esattamente sovrapposte)
if ( abs( dAngDeg) < ( ANG_STRAIGHT - 10 * EPS_ANG_ZERO) &&
( ( dDist < 0 && dAngDeg > 0) ||
( dDist > 0 && dAngDeg < 0)))
@@ -1066,7 +1072,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
return false ;
ptP1a = ptP1 + vtDir1 * dLen ;
ptP2a = ptP2 - vtDir2 * dLen ;
// se prima c'è linea posso allungarla
// se prima c'è linea posso allungarla
if ( pCrv1->GetType() == CRV_LINE)
pCrv1->ModifyEnd( ptP1a) ;
// altrimenti, devo aggiungere una nuova linea
@@ -1085,7 +1091,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
if ( ! ccAux.AddCurve( Release( pCrv)))
return false ;
}
// se dopo c'è linea posso allungarla
// se dopo c'è linea posso allungarla
if ( pCrv2->GetType() == CRV_LINE)
pCrv2->ModifyStart( ptP2a) ;
// altrimenti, devo aggiungere una nuova linea
@@ -1108,7 +1114,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
if ( ! pCrv1->GetEndPoint( ptP1) || ! pCrv2->GetStartPoint( ptP2))
return false ;
ptPc = ptP1 + vtDir1 * dLen ;
// se prima c'è linea o angolo molto piccolo posso allungarla
// se prima c'è linea o angolo molto piccolo posso allungarla
if ( ( pCrv1->GetType() == CRV_LINE) || bAngSmall)
pCrv1->ModifyEnd( ptPc) ;
// altrimenti, devo aggiungere una nuova linea
@@ -1119,7 +1125,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
if ( ! ccAux.AddCurve( Release( pCrv)))
return false ;
}
// se dopo c'è linea o angolo molto piccolo posso allungarla
// se dopo c'è linea o angolo molto piccolo posso allungarla
if ( ( pCrv2->GetType() == CRV_LINE) || bAngSmall)
pCrv2->ModifyStart( ptPc) ;
// altrimenti, devo aggiungere una nuova linea
+16 -6
View File
@@ -587,18 +587,29 @@ PolyLine::IsClosedAndFlat( Plane3d& plPlane, double& dArea, double dToler) const
// Test if closed
if ( ! IsClosed())
return false ;
// Compute a representative plane for the polygon
Point3d ptP ;
// Calcolo il centro (per minimizzare gli errori nelle successive operazioni)
Point3d ptCen = ORIG ;
int nCount = 0 ;
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) {
ptCen += ptP ;
++ nCount ;
}
ptCen /= nCount ;
Vector3d vtMove = ptCen - ORIG ;
// Compute a representative plane for the polygon (faccio il calcolo nel centro e poi traslo al contrario il piano)
PolygonPlane PolyPlane ;
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP))
PolyPlane.AddPoint( ptP) ;
PolyPlane.AddPoint( ptP - vtMove) ;
if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea)) {
dArea = 0 ;
return IsFlat( plPlane, dToler) ;
}
plPlane.Translate( vtMove) ;
// Sistemo il piano per l'offset utilizzato
// Test each vertex to see if it is farther from plane than allowed max distance
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) {
double dDist = ( ( ptP - ORIG) * plPlane.GetVersN()) - plPlane.GetDist() ;
double dDist = DistPointPlane( ptP, plPlane) ;
if ( abs( dDist) > dToler)
return false ;
}
@@ -1597,7 +1608,7 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
// distanza del punto dal segmento della polilinea
DistPointLine PointLineDistCalc( vPnt1[i].first, vPnt2[j-1].first, vPnt2[j].first) ;
double dPlDist ;
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist) {
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist - EPS_SMALL) {
dDist = dPlDist ;
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
dMinDistPar += j - 1 ;
@@ -1628,8 +1639,7 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
// distanza del punto dal segmento della polilinea
DistPointLine PointLineDistCalc( vPnt2[j].first, vPnt1[i-1].first, vPnt1[i].first) ;
double dPlDist ;
PointLineDistCalc.GetDist( dPlDist) ;
if ( dPlDist < dDist) {
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist - EPS_SMALL) {
dDist = dPlDist ;
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
dMinDistPar += i - 1 ;
+55
View File
@@ -0,0 +1,55 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : ProjectCurveSurfBez.cpp Data : 07.05.24 Versione : 2.6e3
// Contenuto : Implementazione funzioni proiezione curve su superficie Bezier.
//
//
//
// Modifiche : 07.05.24 DB Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "/EgtDev/Include/EGkProjectCurveSurfTm.h"
#include "/EgtDev/Include/EGkSurfBezier.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const Vector3d& vtDir, double dLinTol, double dMaxSegmLen,
PNT5AXVECTOR& vPt5ax)
{
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, vtDir, dLinTol, dMaxSegmLen, vPt5ax) ;
}
//----------------------------------------------------------------------------
bool
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const IGeoPoint3d& gpRef,
double dLinTol, double dMaxSegmLen, PNT5AXVECTOR& vPt5ax)
{
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, gpRef, dLinTol, dMaxSegmLen, vPt5ax) ;
}
//----------------------------------------------------------------------------
bool
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const ICurve& crRef,
double dLinTol, double dMaxSegmLen, PNT5AXVECTOR& vPt5ax)
{
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, crRef, dLinTol, dMaxSegmLen, vPt5ax) ;
}
//----------------------------------------------------------------------------
bool
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const ISurfTriMesh& tmRef,
double dLinTol, double dMaxSegmLen, PNT5AXVECTOR& vPt5ax)
{
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, tmRef, dLinTol, dMaxSegmLen, vPt5ax) ;
}
+1407
View File
File diff suppressed because it is too large Load Diff
+34 -1
View File
@@ -17,12 +17,13 @@
#include "SurfTriMesh.h"
#include "SurfBezier.h"
#include "/EgtDev/Include/EGkSbzStandard.h"
#include "/EgtDev/Include/EGkSbzFromCurves.h"
using namespace std ;
//-------------------------------------------------------------------------------
ISurfBezier*
CreateBezierSphere( const Point3d& ptCenter, double dR)
GetSurfBezierSphere( const Point3d& ptCenter, double dR)
{
// creo una superficie di Bezier di grado 2 con 45 punti di controllo
PtrOwner<ISurfBezier> pSrfBez( CreateSurfBezier()) ;
@@ -78,3 +79,35 @@ CreateBezierSphere( const Point3d& ptCenter, double dR)
return Release( pSrfBez) ;
}
////-------------------------------------------------------------------------------
//ISurfBezier*
//GetSurfBezierCone( const Point3d& ptCenter, double dRadius, const Vector3d& dHeight)
//{
// // le dimensioni devono essere significative
// if ( dRadius < EPS_SMALL || abs( dHeight) < EPS_SMALL)
// return nullptr ;
// // creo la circonferenza di base
// CurveArc cArc ;
// cArc.Set( ORIG, Z_AX, dRadius) ;
// if ( dHeight < 0)
// cArc.Invert() ;
// // punto di vertice
// Point3d ptTip( 0, 0, dHeight) ;
// // creo la superficie laterale del cono
// PtrOwner<ISurfBezier> pSbz( GetSurfBezierRuled( ptTip, &cArc)) ;
// if ( IsNull( pSbz))
// return nullptr ;
//
// //// creo la superficie di base e la inverto
// //PtrOwner<ISurfTriMesh> pSTM1( GetSurfTriMeshByFlatContour( &cArc, dLinTol)) ;
// //if ( IsNull( pSTM1))
// // return nullptr ;
// //pSTM1->Invert() ;
// //// la unisco alla superficie del fianco
// //if ( ! pSTM->DoSewing( *pSTM1))
// // return nullptr ;
//
// // restituisco la superficie
// return Release( pSbz) ;
//}
+2
View File
@@ -88,6 +88,8 @@ SelfIntersCurve::SelfIntersCurve( const ICurve& Curve)
}
}
break ;
default :
break ;
}
// per curva approssimata, sistemo...
AdjustIntersParams( ( pCalcCrv != m_pCurve), pCalcCrv, vTmpPar) ;
+143 -30
View File
@@ -367,25 +367,14 @@ GetSurfFlatRegionFromTriangle( const Triangle3d& Tria)
ISurfFlatRegion*
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
{
// Creo la regione.
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr))
return nullptr ;
// Creo curva composita.
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
if ( IsNull( pLoop))
if ( IsNull( pLoop) || ! pLoop->FromPolyLine( ContourPolyLine))
return nullptr ;
// Creo la regione.
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr) || ! pSfr->AddExtLoop( Release( pLoop)))
return nullptr ;
Point3d ptSt, ptEn ;
bool bContinue = ContourPolyLine.GetFirstPoint( ptSt) &&
ContourPolyLine.GetNextPoint( ptEn) ;
while ( bContinue) {
CurveLine cvLine ;
cvLine.Set( ptSt, ptEn) ;
pLoop->AddCurve( cvLine) ;
ptSt = ptEn ;
bContinue = ContourPolyLine.GetNextPoint( ptEn) ;
}
pSfr->AddExtLoop( Release( pLoop)) ;
return Release( pSfr) ;
}
@@ -401,25 +390,17 @@ GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) {
// Creo curva composita.
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
if ( IsNull( pLoop))
if ( IsNull( pLoop) || ! pLoop->FromPolyLine( vContoursPolyLineVec[nL]))
return nullptr ;
Point3d ptSt, ptEn ;
bool bContinue = vContoursPolyLineVec[nL].GetFirstPoint( ptSt) &&
vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
while ( bContinue) {
CurveLine cvLine ;
cvLine.Set( ptSt, ptEn) ;
pLoop->AddCurve( cvLine) ;
ptSt = ptEn ;
bContinue = vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
}
// Loop esterno
if ( nL == 0) {
pSfr->AddExtLoop( Release( pLoop)) ;
if ( ! pSfr->AddExtLoop( Release( pLoop)))
return nullptr ;
}
// Loop interno
else {
pSfr->AddIntLoop( Release( pLoop)) ;
if ( ! pSfr->AddIntLoop( Release( pLoop)))
return nullptr ;
}
}
return Release( pSfr) ;
@@ -590,4 +571,136 @@ SurfFlatRegionByContours::GetUnusedCurveTempProps( INTVECTOR& vId)
vId.push_back( pCrv->GetTempProp()) ;
}
return ( ! vId.empty()) ;
}
}
//-------------------------------------------------------------------------------
bool
CalcRegionPolyLines( const POLYLINEVECTOR& vPL, Vector3d& vtN, INTMATRIX& vnPLIndMat, BOOLVECTOR& vbInvert)
{
// 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 bool : riferito al vettore originale delle polyline, riporta true se la polyline è stata invertita
// 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()) ;
VCT3DVECTOR vvtN ;
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
// calcolo piano medio e area
Plane3d plPlane ;
double dArea ;
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea))
return false ;
// verifico che le normali siano molto vicine
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN))
return false ;
// salvo la normale
vvtN.push_back( plPlane.GetVersN()) ;
// assegno il segno all'area secondo il verso della normale
if ( ( plPlane.GetVersN() * vtN) > 0)
m_vArea.emplace_back( i, dArea) ;
else
m_vArea.emplace_back( i, - dArea) ;
}
// 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)) ; }) ;
// 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 del loop più grande
bool bInvertAll = vvtN[m_vArea[0].first] * vtN < 0 ;
vtN = vvtN[m_vArea[0].first] ;
//// 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. ;
vbInvert.resize( vPL.size()) ;
fill( vbInvert.begin(), vbInvert.end(), false) ;
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) {
vCrvCompo[j]->Invert() ;
dAreaExtLoop *= -1 ;
vbInvert[j] = true ;
}
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.) {
vCrvCompo[j]->Invert() ;
vbInvert[j] = true ;
}
}
}
}
} while ( ! bFirstCrv) ;
if ( bInvertAll) {
for ( int i = 0 ; i < int( vPL.size()) ; ++i)
vbInvert[i] = ! vbInvert[i] ;
}
return true ;
}
+33 -145
View File
@@ -31,10 +31,6 @@
using namespace std ;
//-------------------------------------------------------------------------------
static bool CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
POLYLINEVECTOR& vPL, Vector3d& vtN) ;
//-------------------------------------------------------------------------------
ISurfTriMesh*
GetSurfTriMeshByFlatContour( const ICurve* pCurve, double dLinTol)
@@ -65,12 +61,25 @@ GetSurfTriMeshByRegion( const CICURVEPVECTOR& vpCurve, double dLinTol)
return nullptr ;
// calcolo le polilinee che approssimano le curve della regione
POLYLINEVECTOR vPL ;
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, vPL[i]))
return nullptr ;
}
Vector3d vtN ;
if ( ! CalcRegionPolyLines( vpCurve, dLinTol, vPL, vtN))
INTMATRIX vnPLIndMat ;
BOOLVECTOR vbInvert ;
if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert))
return nullptr ;
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) {
for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){
if( vbInvert[vnPLIndMat[i][j]])
vPL[vnPLIndMat[i][j]].Invert() ;
}
}
// creo e setto la superficie trimesh
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL))
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL, vnPLIndMat))
return nullptr ;
// salvo tolleranza lineare usata
pSTM->SetLinearTolerance( dLinTol) ;
@@ -145,9 +154,20 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d&
return GetSurfTriMeshByExtrusion( vpCurve[0], vtExtr, true, dLinTol) ;
// calcolo le polilinee che approssimano le curve della regione
POLYLINEVECTOR vPL ;
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, vPL[i]))
return nullptr ;
}
Vector3d vtN ;
if ( ! CalcRegionPolyLines( vpCurve, dLinTol, vPL, vtN))
INTMATRIX vnPLIndMat ;
BOOLVECTOR vbInvert ;
if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert))
return nullptr ;
for ( int i = 0 ; i < int( vPL.size()) ; ++i) {
if( vbInvert[i])
vPL[i].Invert() ;
}
// verifico la direzione di estrusione
double dOrthoExtr = vtN * vtExtr ;
if ( ( abs( dOrthoExtr) < EPS_SMALL))
@@ -159,7 +179,8 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d&
}
// creo la prima superficie di estremità
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL))
// alla funzione CreateByRegion passo anche la matrice che contiene la struttura dei chunk. Le polyline hanno già il verso giusto
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL, vnPLIndMat))
return nullptr ;
// creo la seconda superficie e la unisco alla prima
{ // copio la prima superficie
@@ -1280,7 +1301,8 @@ GetSurfTriMeshSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, cons
}
// creo il cap sull'inizio e lo attacco alla swept ( è già in posizione giusta)
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
if ( ! pSci->CreateByRegion( vPLi))
INTMATRIX vnPLIndMat ;
if ( ! pSci->CreateByRegion( vPLi, vnPLIndMat))
return nullptr ;
pStmSwept->DoSewing( *pSci) ;
// recupero i loops alla fine
@@ -1289,7 +1311,8 @@ GetSurfTriMeshSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, cons
return nullptr ;
// creo la superficie alla fine e la attacco
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
if ( ! pSce->CreateByRegion( vPLe))
vnPLIndMat.clear() ;
if ( ! pSce->CreateByRegion( vPLe, vnPLIndMat))
return nullptr ;
// attacco la superficie finale alla swept
pSce->Invert() ;
@@ -1433,138 +1456,3 @@ GetSurfTriMeshRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, do
// restituisco la superficie
return Release( pSTM) ;
}
//-------------------------------------------------------------------------------
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
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, vPL[i]))
return false ;
}
// 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 ( ! vPL[i].IsClosedAndFlat( plPlane, dArea))
return false ;
// verifico che le normali siano molto vicine
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN))
return false ;
// assegno il segno all'area secondo il verso della normale
if ( ( plPlane.GetVersN() * vtN) > 0)
m_vArea.emplace_back( i, dArea) ;
else
m_vArea.emplace_back( i, - dArea) ;
}
// 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)) ; }) ;
// 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) ;
}
// 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 ;
}
+27 -2
View File
@@ -45,6 +45,7 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
for( int j = 0 ; j < snData.nCPV ; ++j) {
CNurbsData nuCurve ;
nuCurve.bPeriodic = true ;
nuCurve.bRat = snData.bRat ;
nuCurve.nDeg = snData.nDegU ;
nuCurve.vU = vU ;
// vettore dei punti di controllo
@@ -63,13 +64,23 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
nuCurve.vW = vWeCtrl ;
// i punti dell' oggetto nuCurve devono essere in forma non omogenea
if ( NurbsCurveCanonicalize( nuCurve)) { // se NurbsCurveCanonicalize ha restituito false (la curva potrebbe esserre un punto di polo) allora non modifico i punti e il vettore dei nodi della superficie
if ( snData.mCP.size() != nuCurve.vCP.size() ) {
snData.mCP.resize( nuCurve.vCP.size()) ;
if( snData.bRat)
snData.mW.resize( nuCurve.vW.size()) ;
}
for ( int i = 0 ; i < snData.nCPU ; ++i) {
snData.mCP[i][j] = nuCurve.vCP[i] ;
if( snData.bRat) {
snData.mW[i][j] = nuCurve.vW[i] ;
snData.mCP[i][j] *= nuCurve.vW[i] ;
}
}
snData.vU = nuCurve.vU ;
}
}
snData.bPeriodicU = false ;
snData.nCPU = int( snData.mCP.size()) ;
}
if ( snData.bPeriodicV || ! snData.bClampedV) {
bool bIsRational = snData.bRat ;
@@ -83,6 +94,7 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
for( int i = 0 ; i < snData.nCPU ; ++i) {
CNurbsData nuCurve ;
nuCurve.bPeriodic = true ;
nuCurve.bRat = snData.bRat ;
nuCurve.nDeg = snData.nDegV ;
nuCurve.vU = vV ;
// vettore dei punti di controllo
@@ -101,15 +113,28 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
nuCurve.vW = vWeCtrl ;
// i punti dell' oggetto nuCurve devono essere in forma non omogenea
if ( NurbsCurveCanonicalize( nuCurve)) { // se NurbsCurveCanonicalize ha restituito false (la curva potrebbe esserre un punto di polo) allora non modifico i punti e il vettore dei nodi della superficie
for ( int j = 0 ; j < snData.nCPV ; ++j ) {
if ( snData.mCP[i].size() != nuCurve.vCP.size()){
snData.mCP[i].clear() ;
snData.mCP[i].resize( nuCurve.vCP.size()) ;
if ( snData.bRat ) {
snData.mW[i].clear() ;
snData.mW[i].resize( nuCurve.vW.size()) ;
}
}
for ( int j = 0 ; j < int( nuCurve.vCP.size()) ; ++j ) {
snData.mCP[i][j] = nuCurve.vCP[j] ;
if ( snData.bRat ) {
snData.mW[i][j] = nuCurve.vW[j] ;
snData.mCP[i][j] *= nuCurve.vW[j] ;
}
}
snData.vV = nuCurve.vU ;
}
}
snData.bPeriodicV = false ;
snData.nCPV = int( snData.mCP[0].size()) ;
}
return true;
return true ;
}
//----------------------------------------------------------------------------
+2083 -224
View File
File diff suppressed because it is too large Load Diff
+18 -2
View File
@@ -75,7 +75,11 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
bool GetVolume( double& dVolume) const override
{ if ( &dVolume == nullptr)
return false ;
if( m_pSTM == nullptr)
GetAuxSurf() ;
dVolume = 0 ;
if( m_pSTM != nullptr)
m_pSTM->GetVolume( dVolume) ;
return true ; }
bool GetCentroid( Point3d& ptCen) const override ;
bool Invert( void) override ;
@@ -135,8 +139,15 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
bool IncreaseUV( Point3d& ptUV, Vector3d vtH , Point3d* ptUVCopy, bool bModifyOrig) const override ;
// funzione che restituisce gli edge della superficie o in forma di linea spezzata o in forma di curva di Bezier
// se la superficie è trimmata restituisce i loop dello spazio parametrico in forma di linee spezzate
bool GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge = -1) const override ;
bool GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge = -1) const override ; // se la superficie non è trimmata restituisce un vettore di 4 elementi. Se la superficie è chiusa lungo un parametro i lati algi estremi di quel parametro saranno null.
bool IsPlanar( void) const override ;
bool CreateByFlatContour( const PolyLine& PL) override ;
bool CreateByRegion( const POLYLINEVECTOR& vPL) override ;
bool CreateByExtrusion( const ICurve* pCurve, const Vector3d& vtExtr, bool bDeg3OrDeg2 = false) override ;
bool CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, double dMove) override ;
bool CreateByPointCurve( const Point3d& pt, const ICurve* pCurve) override ;
bool CreateByTwoCurves( const ICurve* pCurve1, const ICurve* pCurve2, int nType) override ;
bool CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez, bool bReduceToDeg3) override ;
public : // IGeoObjRW
int GetNgeId( void) const override ;
@@ -189,11 +200,15 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
double GetCurveOnVApproxLen( double dU) const ;
// funzione che proietta nello spazio parametrico un trim derivante da un taglio con un piano, categorizzandolo come aperto o chiuso ( nel parametrico)
bool AddCurveCompoToCuts( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCCOpen, ICRVCOMPOPOVECTOR& vpCCClosed, double dToler = EPS_SMALL, const Plane3d* pPlCut = nullptr) const ;
ISurfFlatRegion* CreateTrimRegionFromCuts( ICRVCOMPOPOVECTOR& vpCCOpen, ICRVCOMPOPOVECTOR& vpCCClosed) const ;
// restituisce il singolo edge della superficie non trimmata
ICurveComposite* GetSingleEdge3D( bool bLineOrBezier, int nEdge) const ;
bool UpdateEdgesFromTree( Tree& tr) const ;
// funzione che calcola se gli edge sono collassati in poli
bool CalcPoles( void) ;
bool CalcPoles( void) const ;
bool FindMatchByParam( const PolyLine& pl0, const PolyLine& pl1, INTVECTOR& vMatch, int& nLong) const ;
bool ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ;
bool ReorderPntEnhancedVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ;
private :
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
@@ -215,6 +230,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
double m_dTempParam[2] ; // vettore parametri temporanei
mutable vector<ICRVCOMPOPOVECTOR> m_mCCEdge ;// vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
mutable ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
} ;
//-----------------------------------------------------------------------------
+290 -24
View File
@@ -109,18 +109,25 @@ SurfFlatRegion::AddExtLoop( ICurve* pCrv)
if ( ! AdjustLoops( Release( pMyCrv), CrvLst, true))
return false ;
// aggiungo le singole curve
int nExtAdded = 0 ;
bool bOk = true ;
for ( auto& pSingCrv : CrvLst) {
if ( ! AddSimpleExtLoop( pSingCrv))
bool bAdded = false ;
if ( AddSimpleExtLoop( pSingCrv, bAdded))
++ nExtAdded ;
else
bOk = false ;
}
return bOk ;
return ( bOk && nExtAdded > 0) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv, bool& bAdded)
{
// default
bAdded = false ;
// acquisisco la curva
PtrOwner<ICurve> pMyCrv( pCrv) ;
if ( IsNull( pMyCrv))
@@ -133,6 +140,8 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
Plane3d plPlane ;
if ( ! pMyCrv->GetArea( plPlane, dArea))
return false ;
if ( dArea < SQ_EPS_SMALL)
return true ;
// se sto costruendo il primo chunk
if ( m_vExtInd.size() == 0) {
// assegno il riferimento intrinseco
@@ -198,6 +207,7 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
m_OGrMgr.Reset() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
bAdded = true ;
return true ;
}
@@ -912,9 +922,6 @@ SurfFlatRegion::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
bool
SurfFlatRegion::GetArea( double& dArea) const
{
// controllo parametro di ritorno
if ( &dArea == nullptr)
return false ;
// inizio con area nulla
dArea = 0 ;
// la regione deve essere validata
@@ -937,9 +944,6 @@ SurfFlatRegion::GetArea( double& dArea) const
bool
SurfFlatRegion::GetGrossArea( double& dArea) const
{
// controllo parametro di ritorno
if ( &dArea == nullptr)
return false ;
// inizio con area nulla
dArea = 0 ;
// la regione deve essere validata
@@ -963,9 +967,6 @@ SurfFlatRegion::GetGrossArea( double& dArea) const
bool
SurfFlatRegion::GetCentroid( Point3d& ptCen) const
{
// controllo parametro di ritorno
if ( &ptCen == nullptr)
return false ;
// la regione deve essere validata
if ( m_nStatus != OK || m_vpLoop.empty())
return false ;
@@ -991,13 +992,20 @@ SurfFlatRegion::GetCentroid( Point3d& ptCen) const
return true ;
}
//----------------------------------------------------------------------------
int
SurfFlatRegion::GetChunkCount( void) const
{
// la regione deve essere validata
if ( m_nStatus != OK)
return 0 ;
return int( m_vExtInd.size()) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::GetChunkCentroid( int nChunk, Point3d& ptCen) const
{
// controllo parametro di ritorno
if ( &ptCen == nullptr)
return false ;
// la regione deve essere validata
if ( m_nStatus != OK || m_vpLoop.empty())
return false ;
@@ -1011,13 +1019,53 @@ SurfFlatRegion::GetChunkCentroid( int nChunk, Point3d& ptCen) const
}
//----------------------------------------------------------------------------
int
SurfFlatRegion::GetChunkCount( void) const
bool
SurfFlatRegion::GetChunkArea( int nChunk, double& dArea) const
{
// default, area nulla
dArea = 0 ;
// la regione deve essere validata
if ( m_nStatus != OK)
return 0 ;
return int( m_vExtInd.size()) ;
if ( m_nStatus != OK || m_vpLoop.empty())
return false ;
// il chunk deve esistere
if ( nChunk < 0 || nChunk >= GetChunkCount())
return false ;
// calcolo l'area
bool bOk = true ;
for ( int nL = 0 ; nL < GetLoopCount( nChunk) ; ++ nL) {
const ICurve* pLoop = GetMyLoop( nChunk, nL) ;
double dLoopArea ;
if ( pLoop != nullptr && pLoop->GetAreaXY( dLoopArea))
dArea += dLoopArea ;
else
bOk = false ;
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::GetChunkPerimeter( int nChunk, double& dLen) const
{
// default, perimetro nullo
dLen = 0 ;
// la regione deve essere validata
if ( m_nStatus != OK || m_vpLoop.empty())
return false ;
// il chunk deve esistere
if ( nChunk < 0 || nChunk >= GetChunkCount())
return false ;
// calcolo il perimetro
bool bOk = true ;
for ( int nL = 0 ; nL < GetLoopCount( nChunk) ; ++ nL) {
const ICurve* pLoop = GetMyLoop( nChunk, nL) ;
double dLoopLen ;
if ( pLoop != nullptr && pLoop->GetLength( dLoopLen))
dLen += dLoopLen ;
else
bOk = false ;
}
return bOk ;
}
//----------------------------------------------------------------------------
@@ -1118,6 +1166,19 @@ SurfFlatRegion::GetLoop( int nChunk, int nLoop) const
return pCrv ;
}
//----------------------------------------------------------------------------
int
SurfFlatRegion::GetLoopCurveCount( int nChunk, int nLoop) const
{
// recupero il loop nel riferimento intrinseco
const ICurve* pMyCrv = GetMyLoop( nChunk, nLoop) ;
if ( pMyCrv == nullptr)
return 0 ;
// restituisco il numero di curve di cui è composto
const ICurveComposite* pMyCompo = GetCurveComposite( pMyCrv) ;
return ( pMyCompo == nullptr ? 1 : pMyCompo->GetCurveCount()) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const
@@ -1151,7 +1212,7 @@ SurfFlatRegion::CalcAuxSurf( double dLinTol, double dAngTolDeg) const
POLYLINEVECTOR vPL ;
vPL.resize( GetLoopCount( i)) ;
int j = 0 ;
ICurve* pLoop = GetMyLoop( i, j) ;
ICurve* pLoop = GetMyLoop( i, j) ;
while ( pLoop != nullptr) {
// approssimo con linee a destra per non avere problemi in punti di contatto tra esterni e interni
if ( ! pLoop->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_RIGHT, vPL[j]))
@@ -1160,10 +1221,11 @@ SurfFlatRegion::CalcAuxSurf( double dLinTol, double dAngTolDeg) const
}
// se chunk abbastanza grande, creo la superficie trimesh relativa
double dArea ;
if ( vPL[0].GetAreaXY( dArea) && dArea > 100 * SQ_EPS_SMALL) {
if ( vPL[0].GetAreaXY( dArea) && dArea > 25 * SQ_EPS_SMALL) {
// creo, setto la superficie trimesh ed elimino punti ripetuti
PtrOwner<SurfTriMesh> pChSTM( CreateBasicSurfTriMesh()) ;
if ( IsNull( pChSTM) || ! pChSTM->CreateByRegion( vPL) || ! pChSTM->DoCompacting())
INTMATRIX vnPLIndMat ;
if ( IsNull( pChSTM) || ! pChSTM->CreateByRegion( vPL, vnPLIndMat) || ! pChSTM->DoCompacting())
return nullptr ;
// porto la trimesh in globale al riferimento intrinseco
pChSTM->ToGlob( m_frF) ;
@@ -1171,7 +1233,10 @@ SurfFlatRegion::CalcAuxSurf( double dLinTol, double dAngTolDeg) const
pSTM->DoSewing( *pChSTM) ;
}
}
// la restituisco
// se vuota
if ( pSTM->IsEmpty())
pSTM->AdjustTopology() ;
// la restituisco
return Release( pSTM) ;
}
@@ -1226,6 +1291,56 @@ SurfFlatRegion::CloneChunk( int nChunk) const
return Release( pSfr) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::EraseChunk(int nChunk)
{
// la regione deve essere validata
if ( m_nStatus != OK || m_vpLoop.empty())
return false ;
// il chunk deve esistere
if ( nChunk < 0 || nChunk >= GetChunkCount())
return false ;
// se un solo chunk, resetto la regione
if ( GetChunkCount() == 1) {
Clear() ;
return true ;
}
// se ultimo chunk
if ( nChunk == m_vExtInd.size() - 1) {
// elimino i loop
for ( int i = m_vExtInd[nChunk] ; i < int( m_vpLoop.size()) ; ++ i) {
delete m_vpLoop[i] ;
m_vpLoop[i] = nullptr ;
}
m_vpLoop.erase( m_vpLoop.begin() + m_vExtInd[nChunk], m_vpLoop.end()) ;
// elimino indice di loop esterno
m_vExtInd.pop_back() ;
}
// altrimenti
else {
// numero di loop da eliminare
int nLoopCnt = m_vExtInd[nChunk+1] - m_vExtInd[nChunk] ;
// elimino i loop
for ( int i = m_vExtInd[nChunk] ; i < m_vExtInd[nChunk+1] ; ++ i) {
delete m_vpLoop[i] ;
m_vpLoop[i] = nullptr ;
}
m_vpLoop.erase( m_vpLoop.begin() + m_vExtInd[nChunk], m_vpLoop.begin() + m_vExtInd[nChunk+1]) ;
// elimino indice di loop esterno
m_vExtInd.erase( m_vExtInd.begin() + nChunk) ;
// aggiorno indice inizio chunk successivi
for ( int i = nChunk ; i < int( m_vExtInd.size()) ; ++i)
m_vExtInd[i] -= nLoopCnt ;
}
// imposto ricalcolo della grafica
m_OGrMgr.Reset() ;
ResetAuxSurf() ;
// imposto ricalcolo Voronoi
ResetVoronoiObject() ;
return true ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const
@@ -1480,3 +1595,154 @@ SurfFlatRegion::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const
return m_pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::GetChunkMaxOffset( int nChunk, double& dOffs) const
{
// verifico se è stato calcolato Voronoi
if ( m_pVoronoiObj == nullptr)
if ( ! CalcVoronoiObject())
return false ;
// il massimo offset per il chunk è il massimo offset del suo loop esterno
// ( il diagramma di Voronoi tiene già conto della limitazione con i loop interni)
int nInd = GetIndFromChunkLoop( nChunk, 0) ;
return m_pVoronoiObj->CalcLimitOffset( nInd, true, dOffs) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::GetMaxOffset( double& dOffs) const
{
int nChunks = GetChunkCount() ;
if ( nChunks == 0)
return false ;
// calcolo il massimo fra gli offset limite di tutti i suoi chunks
if ( ! GetChunkMaxOffset( 0, dOffs))
return false ;
for ( int i = 1 ; i < nChunks ; i++) {
double dCurrOffs ;
if ( ! GetChunkMaxOffset( i, dCurrOffs))
return false ;
if ( dCurrOffs > dOffs)
dOffs = dCurrOffs ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::SetCurveTempProp( int nChunk, int nLoop, int nCrv, int nProp, int nPropInd)
{
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
if ( pLoop == nullptr)
return false ;
if ( pLoop->GetType() != CRV_COMPO) {
if ( nCrv != 0)
return false ;
pLoop->SetTempProp( nProp, nPropInd) ;
return true ;
}
return GetBasicCurveComposite( pLoop)->SetCurveTempProp( nCrv, nProp, nPropInd) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::GetCurveTempProp( int nChunk, int nLoop, int nCrv, int& nProp, int nPropInd) const
{
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
if ( pLoop == nullptr)
return false ;
if ( pLoop->GetType() != CRV_COMPO) {
if ( nCrv != 0)
return false ;
nProp = pLoop->GetTempProp( nPropInd) ;
return true ;
}
return GetBasicCurveComposite( pLoop)->GetCurveTempProp( nCrv, nProp, nPropInd) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::ResetAllCurveTempProps( void)
{
for ( int nC = 0 ; nC < GetChunkCount() ; ++ nC) {
for ( int nL = 0 ; nL < GetLoopCount( nC) ; ++ nL) {
ICurve* pLoop = GetMyLoop( nC, nL) ;
if ( pLoop != nullptr) {
if ( pLoop->GetType() != CRV_COMPO) {
pLoop->SetTempProp( 0, 0) ;
pLoop->SetTempProp( 0, 1) ;
}
else {
CurveComposite* pCompoLoop = GetBasicCurveComposite( pLoop) ;
for ( int nI = 0 ; nI < pCompoLoop->GetCurveCount() ; ++ nI) {
pCompoLoop->SetCurveTempProp( nI, 0, 0) ;
pCompoLoop->SetCurveTempProp( nI, 0, 1) ;
}
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::SetCurveTempParam( int nChunk, int nLoop, int nCrv, double dParam, int nParamInd)
{
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
if ( pLoop == nullptr)
return false ;
if ( pLoop->GetType() != CRV_COMPO) {
if ( nCrv != 0)
return false ;
pLoop->SetTempParam( dParam, nParamInd) ;
return true ;
}
return GetBasicCurveComposite( pLoop)->SetCurveTempParam( nCrv, dParam, nParamInd) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::GetCurveTempParam( int nChunk, int nLoop, int nCrv, double& dParam, int nParamInd) const
{
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
if ( pLoop == nullptr)
return false ;
if ( pLoop->GetType() != CRV_COMPO) {
if ( nCrv != 0)
return false ;
dParam = pLoop->GetTempParam( nParamInd) ;
return true ;
}
return GetBasicCurveComposite( pLoop)->GetCurveTempParam( nCrv, dParam, nParamInd) ;
}
//----------------------------------------------------------------------------
bool
SurfFlatRegion::ResetAllCurveTempParams( void)
{
for ( int nC = 0 ; nC < GetChunkCount() ; ++ nC) {
for ( int nL = 0 ; nL < GetLoopCount( nC) ; ++ nL) {
ICurve* pLoop = GetMyLoop( nC, nL) ;
if ( pLoop != nullptr) {
if ( pLoop->GetType() != CRV_COMPO) {
pLoop->SetTempParam( 0, 0) ;
pLoop->SetTempParam( 0, 1) ;
}
else {
CurveComposite* pCompoLoop = GetBasicCurveComposite( pLoop) ;
for ( int nI = 0 ; nI < pCompoLoop->GetCurveCount() ; ++ nI) {
pCompoLoop->SetCurveTempParam( nI, 0, 0) ;
pCompoLoop->SetCurveTempParam( nI, 0, 1) ;
}
}
}
}
}
return true ;
}
+21 -9
View File
@@ -94,18 +94,30 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
{ return m_frF.Orig() ; }
const Vector3d& GetNormVersor( void) const override
{ return m_frF.VersZ() ; }
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
void ResetVoronoiObject( void) const override ;
bool GetMaxOffset( double& dOffs) const override ;
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
const SurfTriMesh* GetAuxSurf( void) const override ;
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
int GetChunkCount( void) const override ;
SurfFlatRegion* CloneChunk( int nChunk) const override ;
bool EraseChunk(int nChunk) override ;
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
bool GetChunkArea( int nChunk, double& dArea) const override ;
bool GetChunkPerimeter( int nChunk, double& dLen) const override ;
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
bool GetChunkMaxOffset( int nChunk, double& dOffs) const override ;
int GetLoopCount( int nChunk) const override ;
int GetLoopCurveCount( int nChunk, int nLoop) const override ;
ICurve* GetLoop( int nChunk, int nLoop) const override ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni)
bool ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const override ;
const SurfTriMesh* GetAuxSurf( void) const override ;
SurfFlatRegion* CloneChunk( int nChunk) const override ;
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 CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
void ResetVoronoiObject( void) const override ;
bool SetCurveTempProp( int nChunk, int nLoop, int nCrv, int nProp, int nPropInd = 0) override ;
bool GetCurveTempProp( int nChunk, int nLoop, int nCrv, int& nProp, int nPropInd = 0) const override ;
bool ResetAllCurveTempProps( void) override ;
bool SetCurveTempParam( int nChunk, int nLoop, int nCrv, double dParam, int nParamInd = 0) override ;
bool GetCurveTempParam( int nChunk, int nLoop, int nCrv, double& dParam, int nParamInd = 0) const override ;
bool ResetAllCurveTempParams( void) override ;
public : // IGeoObjRW
int GetNgeId( void) const override ;
@@ -136,7 +148,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
private :
bool CopyFrom( const SurfFlatRegion& clSrc) ;
bool AddSimpleExtLoop( ICurve* pCrv) ;
bool AddSimpleExtLoop( ICurve* pCrv, bool& bAdded) ;
bool MyAddExtLoop( ICurve* pCrv) ;
bool AddSimpleIntLoop( ICurve* pCrv) ;
bool MyAddIntLoop( ICurve* pCrv, int nChunk) ;
+384 -235
View File
@@ -33,8 +33,8 @@
#include "/EgtDev/Include/EGkUiUnits.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <new>
#include <set>
#include <tuple>
using namespace std ;
@@ -46,7 +46,7 @@ SurfTriMesh::SurfTriMesh( void)
: m_nStatus( TO_VERIFY), m_dLinTol( STM_STD_LIN_TOL), m_dBoundaryAng( STM_STD_BOUNDARY_ANG),
m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bShowEdges( false), m_bOriented( false), m_bClosed( false),
m_bFaceted( false), m_bFacEdged( false), m_nTimeStamp( 0), m_nTempProp{0,0}, m_dTempParam{0,0},
m_nMaxTFlag( 0), m_nParts( -1), m_nShells( -1), m_pHGrd3d( nullptr)
m_nMaxTFlag( 0), m_nShells( -1), m_pHGrd3d( nullptr)
{
m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ;
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
@@ -85,8 +85,8 @@ SurfTriMesh::Init( int nNumVert, int nNumTria, int nNumFacet)
m_nStatus = OK ;
m_bClosed = false ;
m_nMaxTFlag = 0 ;
m_nParts = -1 ;
m_nShells = -1 ;
m_vPart.clear() ;
return true ;
}
@@ -117,8 +117,8 @@ SurfTriMesh::Clear( void)
m_dTempParam[0] = 0 ;
m_dTempParam[1] = 0 ;
m_nMaxTFlag = 0 ;
m_nParts = -1 ;
m_nShells = -1 ;
m_vPart.clear() ;
return true ;
}
@@ -128,8 +128,8 @@ SurfTriMesh::AddVertex( const Point3d& ptVert, double dU, double dV)
{
// imposto ricalcolo
m_nStatus = TO_VERIFY ;
m_nParts = - 1 ;
m_nShells = -1 ;
m_vPart.clear() ;
m_OGrMgr.Reset() ;
ResetHashGrids3d() ;
// inserisco il vertice
@@ -160,8 +160,8 @@ SurfTriMesh::MoveVertex( int nInd, const Point3d& ptNewVert)
m_vVert[nInd].ptP = ptNewVert ;
// imposto ricalcolo
m_nStatus = TO_VERIFY ;
m_nParts = - 1 ;
m_nShells = - 1 ;
m_vPart.clear() ;
m_bFaceted = false ;
m_bFacEdged = false ;
m_OGrMgr.Reset() ;
@@ -230,8 +230,8 @@ SurfTriMesh::AddTriangle( const int nIdVert[3], int nTFlag)
return SVT_DEL ;
// imposto ricalcolo
m_nStatus = TO_VERIFY ;
m_nParts = - 1 ;
m_nShells = -1 ;
m_vPart.clear() ;
m_OGrMgr.Reset() ;
ResetHashGrids3d() ;
// inserisco il triangolo
@@ -322,8 +322,8 @@ SurfTriMesh::RemoveTriangle( int nId)
m_bFaceted = false ;
m_bFacEdged = false ;
// invalido calcolo connettività
m_nParts = - 1 ;
m_nShells = -1 ;
m_vPart.clear() ;
return true ;
}
@@ -912,8 +912,6 @@ SurfTriMesh::CloneTriangle( int nT) const
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
pSurfTM->m_nParts = 1 ;
pSurfTM->m_nShells = 1 ;
// Copio il triangolo
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[nT].nIdVert[0]].ptP),
@@ -1156,7 +1154,7 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
if ( ! IsNull( pSfrTria)) {
if ( bAllTria && Tria.GetN() * vtVers < 0)
pSfrTria->Invert() ;
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
pSfrTria->Offset( dTol, ICurve::OFF_CHAMFER) ;
if ( IsNull( pSfr))
pSfr.Set( pSfrTria) ;
else
@@ -1172,7 +1170,7 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
return false ;
// Effettuo contro-offset
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
pSfr->Offset( -dTol, ICurve::OFF_CHAMFER) ;
// Recupero i contorni della regione
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
@@ -1227,7 +1225,7 @@ SurfTriMesh::GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR&
if ( ! IsNull( pSfrTria)) {
if ( bAllTria && Tria.GetN() * vtVers < 0)
pSfrTria->Invert() ;
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
pSfrTria->Offset( dTol, ICurve::OFF_CHAMFER) ;
if ( IsNull( pSfr))
pSfr.Set( pSfrTria) ;
else
@@ -1241,10 +1239,10 @@ SurfTriMesh::GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR&
// Se non esiste la regione
if ( IsNull( pSfr))
return false ;
return true ;
// Effettuo contro-offset
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
pSfr->Offset( -dTol, ICurve::OFF_CHAMFER) ;
// Recupero i contorni della regione
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
@@ -1311,8 +1309,8 @@ SurfTriMesh::CopyFrom( const SurfTriMesh& stmSrc)
m_nTempProp[0] = stmSrc.m_nTempProp[0] ;
m_nTempProp[1] = stmSrc.m_nTempProp[1] ;
m_nMaxTFlag = stmSrc.m_nMaxTFlag ;
m_nParts = stmSrc.m_nParts ;
m_nShells = stmSrc.m_nShells ;
m_vPart = stmSrc.m_vPart ;
m_dTempParam[0] = stmSrc.m_dTempParam[0] ;
m_dTempParam[1] = stmSrc.m_dTempParam[1] ;
return true ;
@@ -1350,12 +1348,10 @@ SurfTriMesh::Dump( string& sOut, bool bMM, const char* szNewLine) const
// segnalo eventuale incongruenza di orientamento
if ( ! m_bOriented)
sOut += string( "Inconsistent Orientation") + szNewLine ;
// segnalo numero di parti
// segnalo numero di parti e di gusci
int nParts = GetPartCount() ;
sOut += string( "Parts=") + ToString( nParts) + szNewLine ;
// segnalo numero di gusci
int nShells = GetShellCount() ;
sOut += string( "Shells=") + ToString( nShells) + szNewLine ;
sOut += string( "Parts=") + ToString( nParts) + string( " Shells=") + ToString( nShells) + szNewLine ;
// numero di vertici
sOut += "Vert : Nbr=" + ToString( GetVertexCount()) +
" Size=" + ToString( GetVertexSize()) + szNewLine ;
@@ -1465,8 +1461,8 @@ SurfTriMesh::Load( NgeReader& ngeIn)
// imposto ricalcolo della grafica, della connessione e di hashgrids3d
m_OGrMgr.Clear() ;
m_nMaxTFlag = 0 ;
m_nParts = -1 ;
m_nShells = -1 ;
m_vPart.clear() ;
ResetHashGrids3d() ;
// leggo la prossima linea ( 2 parametri : dLinTol e dSmoothAng)
// tolleranza lineare di costruzione
@@ -1626,8 +1622,8 @@ SurfTriMesh::Validate( bool bCorrect)
}
// invalido calcolo connessione
m_nParts = - 1 ;
m_nShells = -1 ;
m_vPart.clear() ;
return ( m_nStatus == OK) ;
}
@@ -1902,8 +1898,8 @@ SurfTriMesh::AdjustTopology( void)
m_bFaceted = false ;
m_bFacEdged = false ;
// invalido calcolo connessione
m_nParts = - 1 ;
m_nShells = - 1 ;
m_vPart.clear() ;
// verifica indici
if ( ! Validate( true))
return false ;
@@ -2097,13 +2093,13 @@ SurfTriMesh::CreateByFlatContour( const PolyLine& PL)
//----------------------------------------------------------------------------
bool
SurfTriMesh::CreateByRegion( const POLYLINEVECTOR& vPL)
SurfTriMesh::CreateByRegion( const POLYLINEVECTOR& vPL, const INTMATRIX& vnPLIndMat)
{
// eseguo la triangolazione, dopo aver verificato che l'insieme di contorni costituisca una regione
PNTVECTOR vPnt ;
INTVECTOR vTria ;
Triangulate Tri ;
if ( ! Tri.MakeAdvanced( vPL, vPnt, vTria))
if ( ! Tri.MakeAdvanced( vPL, vPnt, vTria, vnPLIndMat))
return false ;
// inizializzo la superficie
@@ -2719,6 +2715,8 @@ VeryfyPolylineForRevolution( const PolyLine& PL, const Point3d& ptAx, const Vect
ptPc.z = 0 ;
++ nSeg ;
// verifico distanza
// se la curva è chiusa oppure è vicina all'asse ( entro EPS_SMALL), ma non ho che sono start o end ad essere sull'asse
// allora dovrò rimaneggiare la polyline
if ( DistPointLine( ORIG, ptPp, ptPc).IsSmall()) {
if ( bClosed ||
( ! ( nSeg == 1 && AreSamePointApprox( ORIG, ptPp)) &&
@@ -3572,7 +3570,10 @@ SurfTriMesh::Invert( void)
if ( m_nStatus != OK)
return false ;
// imposto ricalcolo della grafica e di hashgrids3d
// imposto ricalcolo numero delle parti (le shell non cambiano)
m_vPart.clear() ;
// imposto ricalcolo della grafica e di hashgrids3d
m_OGrMgr.Reset() ;
ResetHashGrids3d() ;
@@ -3645,14 +3646,187 @@ SurfTriMesh::GetAllTriaBox( void) const
}
//----------------------------------------------------------------------------
int
SurfTriMesh::GetPartCount( void) const
bool
SurfTriMesh::VerifyConnection( bool bShellsAndParts) const
{
if ( ! IsValid())
return 0 ;
if ( m_nParts == - 1 && ! VerifyConnection())
return 0 ;
return m_nParts ;
return false ;
// se non sono già note le shell
if ( m_nShells == -1) {
// reset connessione
for ( auto& Tria : m_vTria)
Tria.nShell = SVT_NULL ;
// ciclo sui triangoli per determinare le shells
m_nShells = 0 ;
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
// salto triangoli cancellati o già assegnati
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
m_vTria[i].nShell != SVT_NULL)
continue ;
// assegno indice di shell connessa al triangolo
m_vTria[i].nShell = m_nShells ;
++ m_nShells ;
// set di triangoli da aggiornare
set<int> stTria ;
stTria.insert( i) ;
while ( ! stTria.empty()) {
// tolgo un triangolo dal set
const auto iIt = stTria.begin() ;
int nT = *iIt ;
stTria.erase( iIt) ;
// aggiorno i triangoli adiacenti
for ( int j = 0 ; j < 3 ; ++ j) {
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nShell == SVT_NULL) {
m_vTria[nAdjT].nShell = m_vTria[nT].nShell ;
stTria.insert( nAdjT) ;
}
}
}
}
}
// reset delle parti
m_vPart.clear() ;
// se richiesta solo la determinazione delle shell, esco
if ( ! bShellsAndParts)
return true ;
// Se superficie vuota, allora non ho parti
if ( m_nShells == 0)
return true ;
// Se ho solo una shell, allora ho una sola parte
if ( m_nShells == 1) {
m_vPart.emplace_back( m_bClosed, INTVECTOR{ 0}) ;
return true ;
}
// Ho più shell devo controllare la loro posizione relativa
struct SHELLINFO {
SHELLINFO( int nI, double dVol, const BBox3d& b3B, ISurfTriMesh* pStm)
: nInd( nI), dVolume( dVol), b3Box( b3B), pStmShell( pStm) {}
int nInd ;
double dVolume ;
BBox3d b3Box ;
PtrOwner<ISurfTriMesh> pStmShell ;
} ;
vector<SHELLINFO> vOuterShells ;
vector<SHELLINFO> vInnerShells ;
INTVECTOR vOpenShells ;
for ( int nSh = 0 ; nSh < m_nShells ; ++ nSh) {
// se la shell è chiusa
if ( IsShellClosed( nSh)) {
// creo una superficie clonata dalla shell
PtrOwner<ISurfTriMesh> pStmShell( CloneShell( nSh)) ;
if ( IsNull( pStmShell) || ! pStmShell->IsValid())
return false ;
// ne calcolo il volume (con segno)
double dVol = 0. ;
pStmShell->GetVolume( dVol) ;
// ne calcolo il bounding box
BBox3d b3Box ;
pStmShell->GetLocalBBox( b3Box, BBF_STANDARD) ;
// la inserisco nel vettore opportuno
if ( dVol > 0)
vOuterShells.emplace_back( nSh, dVol, b3Box, Release( pStmShell)) ;
else
vInnerShells.emplace_back( nSh, dVol, b3Box, Release( pStmShell)) ;
}
// altrimenti aperta
else {
// la inserisco nel vettore delle shell aperte
vOpenShells.push_back( nSh) ;
}
}
// ordino il vettore delle shell esterne in senso crescente di volume (crescenti anche in valore assoluto)
sort( vOuterShells.begin(), vOuterShells.end(),
[]( const SHELLINFO& a, const SHELLINFO& b) {
return ( a.dVolume < b.dVolume) ;
}) ;
// ordino il vettore delle shell interne in senso crescente di volume (decrescenti in valore assoluto)
sort( vInnerShells.begin(), vInnerShells.end(),
[]( const SHELLINFO& a, const SHELLINFO& b) {
return ( a.dVolume < b.dVolume) ;
}) ;
// classifico le shell esterne
for ( int i = 0 ; i < int( vOuterShells.size()) ; ++ i) {
// inserisco nel vettore delle parti
m_vPart.emplace_back( true, INTVECTOR{ vOuterShells[i].nInd}) ;
// cerco eventuali interne che vi appartengono
CISURFTMPVECTOR vStmTest{ vOuterShells[i].pStmShell} ;
for ( int j = 0 ; j < int( vInnerShells.size()) ; ++ j) {
// se libera e il box è incluso, verifico se realmente interna
if ( vInnerShells[j].nInd >= 0 && vOuterShells[i].b3Box.Encloses( vInnerShells[j].b3Box)) {
Point3d ptCheck ;
vInnerShells[j].pStmShell->GetFirstVertex( ptCheck) ;
bool bIsInside = true ;
for ( const auto& pStmTest : vStmTest) {
BBox3d b3Test = pStmTest->GetAllTriaBox() ;
if ( b3Test.Overlaps( vInnerShells[j].b3Box)) {
DistPointSurfTm distCalculator( ptCheck, *pStmTest) ;
if ( ! distCalculator.IsPointInside()) {
bIsInside = false ;
break ;
}
}
}
if ( bIsInside) {
m_vPart.back().vShell.push_back( vInnerShells[j].nInd) ;
vInnerShells[j].nInd = -1 ;
vStmTest.push_back( vInnerShells[j].pStmShell) ;
}
}
}
}
// classifico le shell interne rimaste libere
bool bNewInner = true ;
CISURFTMPVECTOR vStmTest ;
for ( int i = 0 ; i < int( vInnerShells.size()) ; ++ i) {
if ( vInnerShells[i].nInd >= 0) {
// se non è nuova interna verifico sia interna alle altre correnti
if ( ! bNewInner) {
bool bIsInside = true ;
Point3d ptCheck ;
vInnerShells[i].pStmShell->GetFirstVertex( ptCheck) ;
// se il box interferisce con altri, verifico se realmente interna
for ( const auto& pStmTest : vStmTest) {
BBox3d b3Test = pStmTest->GetAllTriaBox() ;
if ( b3Test.Overlaps( vInnerShells[i].b3Box)) {
DistPointSurfTm distCalculator( ptCheck, *pStmTest) ;
if ( ! distCalculator.IsPointInside()) {
bIsInside = false ;
break ;
}
}
}
if ( bIsInside)
m_vPart.back().vShell.push_back( vInnerShells[i].nInd) ;
else
bNewInner = true ;
}
// se nuova interna
if ( bNewInner) {
bNewInner = false ;
m_vPart.emplace_back( true, INTVECTOR{ -1, vInnerShells[i].nInd}) ;
vStmTest.clear() ;
}
vInnerShells[i].nInd = -1 ;
vStmTest.push_back( vInnerShells[i].pStmShell) ;
}
}
// aggiungo all'elenco delle parti le shell aperte
for ( int i = 0 ; i < int( vOpenShells.size()) ; ++ i) {
m_vPart.emplace_back( false, INTVECTOR{ vOpenShells[i]}) ;
}
return true ;
}
//----------------------------------------------------------------------------
@@ -3661,209 +3835,67 @@ SurfTriMesh::GetShellCount( void) const
{
if ( ! IsValid())
return 0 ;
if ( m_nShells == - 1 && ! VerifyConnection())
if ( m_nShells == -1 && ! VerifyConnection())
return 0 ;
return m_nShells ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::VerifyConnection( void) const
SurfTriMesh::GetShellArea( int nShell, double& dArea) const
{
// Controllo parametro di ritorno
if ( &dArea == nullptr)
return false ;
// Imposto area nulla
dArea = 0 ;
// Verifiche sull'oggetto
if ( ! IsValid())
return false ;
// reset connessione
for ( auto& Tria : m_vTria) {
Tria.nPart = SVT_NULL ;
Tria.nShell = SVT_NULL ;
if ( m_nShells == -1 && ! VerifyConnection())
return false ;
// Se la componente non esiste, errore
if ( nShell < 0 || nShell >= m_nShells)
return false ;
// sommo l'area di tutti i triangoli della shell
Triangle3d Tria ;
int nId = GetFirstTriangle( Tria) ;
while ( nId != SVT_NULL) {
if ( m_vTria[nId].nShell == nShell)
dArea += Tria.GetArea() ;
nId = GetNextTriangle( nId, Tria) ;
}
// ciclo sui triangoli per determinare le shells
m_nShells = 0 ;
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
// salto triangoli cancellati o già assegnati
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
m_vTria[i].nShell != SVT_NULL)
continue ;
// assegno indice di parte connessa al triangolo
m_vTria[i].nShell = m_nShells ;
++ m_nShells ;
// set di triangoli da aggiornare
set<int> stTria ;
stTria.insert( i) ;
while ( ! stTria.empty()) {
// tolgo un triangolo dal set
const auto iIt = stTria.begin() ;
int nT = *iIt ;
stTria.erase( iIt) ;
// aggiorno i triangoli adiacenti
for ( int j = 0 ; j < 3 ; ++ j) {
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nShell == SVT_NULL) {
m_vTria[nAdjT].nShell = m_vTria[nT].nShell ;
stTria.insert( nAdjT) ;
}
}
}
}
// identifico le parti
m_nParts = 0 ;
if ( m_nShells == 1) { // se ho solo una shell allora ho una sola parte
m_nParts = 1 ;
for ( auto& Tria : m_vTria)
Tria.nPart = Tria.nShell ;
}
else { // se ho più shells devo controllare la loro posizione
// salvo solo le Shells chiuse e per ognuna di esse il loro volume e l'indice della shell
// < stmShell, ( nShellInd, dVol) >
// NB. I Volumi sono sempre finiti, il segno del volume mi dice solo se sto considerando
// la parte interna o esterna della superficie
typedef pair<PtrOwner<ISurfTriMesh>, pair<int, double>> SHELLINFO ;
vector<SHELLINFO> vClosedShells ;
vClosedShells.reserve( m_nShells) ;
INTVECTOR vOpenShells ; // vettore di indici di Shell aperte
for ( int s = 0 ; s < GetShellCount() ; ++ s) {
// recupero la Shell
PtrOwner<ISurfTriMesh> pStmShell( CloneShell( s)) ;
if ( IsNull( pStmShell) || ! pStmShell->IsValid())
return false ;
double dVol = 0. ;
// se chiusa calcolo il suo volume con segno
if ( pStmShell->IsClosed()) {
pStmShell->GetVolume( dVol) ;
vClosedShells.emplace_back( make_pair( Release( pStmShell), make_pair( s, dVol))) ;
}
// se aperta, non rientra nella classficazione ( sarà coincidente ad una Part)
else
vOpenShells.push_back( s) ;
}
// ordino il vettore in senso decrescente per volume, in valore assoluto
// NB. tutte le shell con volume negativo sono state invertite !
sort( vClosedShells.begin(), vClosedShells.end(),
[]( const SHELLINFO& a, const SHELLINFO& b) {
return abs( a.second.second) > abs( b.second.second) ;
}) ;
// se la superficie in prima posizione è negativa, allora le inverto tutte; il numero di
// Parts non cambia nel conto
if ( ! vClosedShells.empty() && vClosedShells.front().second.second < - EPS_SMALL)
for ( auto& Shell : vClosedShells)
Shell.first->Invert() ;
// creo una matrice di interi ; ogni riga corrisponde ad una Parte, dove in posizione 0 c'è
// la shell esterna e nelle successive le rispettiva shells interne
INTMATRIX vnShellIndMat ;
bool bFirstShell ; // flag per indicare se la shell corrente è esterna
int nIndExtShell = -1 ; // indice del vettore di shell chiuse della shell esterna
INTVECTOR vIndIntShells ; // vettore di indici di shell chiuse interne alla shell esterna corrente
do {
bFirstShell = true ;
for ( int i = 0 ; i < int( vClosedShells.size()) ; ++ i) {
// recupero l'indice della shell e verifico che sia valido
int j = vClosedShells[i].second.first ;
if ( j < 0)
continue ;
// lo inserisco come esterno...
if ( bFirstShell) {
vnShellIndMat.push_back({ j}) ;
vClosedShells[i].second.first = -1 ;
bFirstShell = false ;
nIndExtShell = i ;
vIndIntShells.clear() ;
}
// altrimento verifico se la shell è interna o no
else {
// la shell è interna se è sia interna alla shell esterna corrente ( della riga di
// vnShellIndMat ) e allo stesso tempo esterna a tutte le shell già inserite nella riga
// attuale.
Point3d ptCheck ;
vClosedShells[i].first->GetFirstVertex( ptCheck) ;
// 1) verifica rispetto alla shell esterna
DistPointSurfTm distCalculator( ptCheck, *vClosedShells[nIndExtShell].first) ;
if ( ! distCalculator.IsPointInside())
continue ;
// 2) verifica rispetto a tutte la shell già trovate interne
bool bOk = true ;
for ( int k = 1 ; k < int( vIndIntShells.size()) ; ++ k) {
DistPointSurfTm distCalculator( ptCheck, *vClosedShells[vIndIntShells[k]].first) ;
// NB. tutte le shell hanno volume negativo !
if ( ! distCalculator.IsPointInside()) {
bOk = false ;
break ;
}
}
if ( bOk) {
// inserisco nella matrice
vnShellIndMat.back().push_back( j) ;
vClosedShells[i].second.first = - 1 ;
vIndIntShells.push_back( i) ;
}
}
}
} while ( ! bFirstShell) ;
// scorro le righe della matrice e assegno la Part ( ovvero la riga )
int nPart = 0 ;
for ( nPart = 0 ; nPart < int( vnShellIndMat.size()) ; ++ nPart) {
++ m_nParts ;
for ( int j = 0 ; j < int( vnShellIndMat[nPart].size()) ; ++ j) {
for ( auto& Tria : m_vTria) {
if ( Tria.nShell == j)
Tria.nPart = nPart ;
}
}
}
// per tutte le superfici aperte, assegno loro una Parte
for ( int i = 0 ; i < int( vOpenShells.size()) ; ++ i) {
++ m_nParts ;
for ( auto& Tria : m_vTria) {
if ( Tria.nShell == i)
Tria.nPart = i + ( nPart ++ ) ;
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::RemovePart( int nPart)
bool
SurfTriMesh::IsShellClosed( int nShell) const
{
// Verifiche sull'oggetto
if ( ! IsValid())
return false ;
// Il numero delle componenti deve essere maggiore di zero o calcolabile
if ( m_nParts == -1 && ! VerifyConnection())
if ( m_nShells == -1 && ! VerifyConnection( false))
return false ;
// Se la componente non esiste, errore
if ( m_nParts <= 0 || nPart < 0 || nPart >= m_nParts)
if ( nShell < 0 || nShell >= m_nShells)
return false ;
int nPartsOld = m_nParts ;
// Rimuovo i triangoli della componente nPart
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
if ( m_vTria[i].nPart == nPart)
RemoveTriangle( i) ;
// ciclo sui triangoli della shell
bool bClosed = true ;
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
// se triangolo non cancellato e della shell
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nShell == nShell) {
// verifico le adiacenze
if ( m_vTria[i].nIdAdjac[0] == SVT_NULL ||
m_vTria[i].nIdAdjac[1] == SVT_NULL ||
m_vTria[i].nIdAdjac[2] == SVT_NULL) {
bClosed = false ;
break ;
}
}
}
// Aggiorno il numero di componenti
m_nParts = nPartsOld - 1 ;
// imposto ricalcolo della grafica e di hashgrids3d
m_OGrMgr.Reset() ;
ResetHashGrids3d() ;
return true ;
// restituisco il risultato
return bClosed ;
}
//----------------------------------------------------------------------------
@@ -3878,18 +3910,16 @@ SurfTriMesh::RemoveShell( int nShell)
return false ;
// Se la componente non esiste, errore
if ( m_nShells <= 0 || nShell < 0 || nShell >= m_nShells)
if ( nShell < 0 || nShell >= m_nShells)
return false ;
int nShellsOld = m_nShells ;
// Rimuovo i triangoli della componente nPart
// Rimuovo i triangoli della componente nShell
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
if ( m_vTria[i].nShell == nShell)
RemoveTriangle( i) ;
}
// Aggiorno il numero di componenti
m_nShells = nShellsOld - 1 ;
// I dati di Shells e Parts sono stati resettati da RemoveTriangle
// imposto ricalcolo della grafica e di hashgrids3d
m_OGrMgr.Reset() ;
@@ -3899,18 +3929,18 @@ SurfTriMesh::RemoveShell( int nShell)
}
//----------------------------------------------------------------------------
SurfTriMesh*
SurfTriMesh::ClonePart( int nPart) const
SurfTriMesh*
SurfTriMesh::CloneShell( int nShell) const
{
if ( ! IsValid())
return nullptr ;
// Il numero delle componenti deve essere maggiore di zero o calcolabile
if ( m_nParts == -1 && ! VerifyConnection())
if ( m_nShells == -1 && ! VerifyConnection())
return nullptr ;
// Se la componente non esiste, errore
if ( m_nParts <= 0 || nPart < 0 || nPart >= m_nParts)
if ( nShell < 0 || nShell >= m_nShells)
return nullptr ;
// Creo nuovo oggetto SurfTriMesh
@@ -3924,12 +3954,10 @@ SurfTriMesh::ClonePart( int nPart) const
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
pSurfTM->m_nParts = 1 ;
pSurfTM->m_nShells = 1 ;
// Copio i triangoli
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nPart == nPart) {
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nShell == nShell) {
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[0]].ptP),
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[1]].ptP),
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[2]].ptP)} ;
@@ -3946,18 +3974,139 @@ SurfTriMesh::ClonePart( int nPart) const
}
//----------------------------------------------------------------------------
SurfTriMesh*
SurfTriMesh::CloneShell( int nShell) const
int
SurfTriMesh::GetPartCount( void) const
{
if ( ! IsValid())
return 0 ;
if ( m_vPart.empty() && ! VerifyConnection())
return 0 ;
return int( m_vPart.size()) ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::GetPartArea( int nPart, double& dArea) const
{
// Controllo parametro di ritorno
if ( &dArea == nullptr)
return false ;
// Imposto area nulla
dArea = 0 ;
// Verifiche sull'oggetto
if ( ! IsValid())
return false ;
if ( m_vPart.empty() && ! VerifyConnection())
return false ;
// Se la componente non esiste, errore
if ( nPart < 0 || nPart >= int( m_vPart.size()))
return false ;
// sommo l'area di tutti i triangoli della parte
Triangle3d Tria ;
int nId = GetFirstTriangle( Tria) ;
while ( nId != SVT_NULL) {
const auto& vShell = m_vPart[nPart].vShell ;
if ( find( vShell.begin(), vShell.end(), m_vTria[nId].nShell) != vShell.end())
dArea += Tria.GetArea() ;
nId = GetNextTriangle( nId, Tria) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::IsPartClosed( int nPart) const
{
// Verifiche sull'oggetto
if ( ! IsValid())
return false ;
if ( m_vPart.empty() && ! VerifyConnection())
return false ;
// Se la componente non esiste, errore
if ( nPart < 0 || nPart >= int( m_vPart.size()))
return false ;
return m_vPart[nPart].bClosed ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::GetPartVolume( int nPart, double& dVolume) const
{
// Controllo parametro di ritorno
if ( &dVolume == nullptr)
return false ;
// Imposto volume nullo
dVolume = 0 ;
// Verifiche sull'oggetto
if ( ! IsValid())
return false ;
if ( m_vPart.empty() && ! VerifyConnection())
return false ;
// Se la componente non esiste, errore
if ( nPart < 0 || nPart >= int( m_vPart.size()))
return false ;
// la parte deve essere chiusa
if ( ! m_vPart[nPart].bClosed)
return true ;
// sommo il volume con segno di tutte le piramidi della parte dall'origine ad ogni faccia
Triangle3d Tria ;
int nId = GetFirstTriangle( Tria) ;
while ( nId != SVT_NULL) {
const auto& vShell = m_vPart[nPart].vShell ;
if ( find( vShell.begin(), vShell.end(), m_vTria[nId].nShell) != vShell.end()) {
Vector3d vtA = ( Tria.GetP( 1) - Tria.GetP( 0)) ^ ( Tria.GetP( 2) - Tria.GetP( 0)) ;
dVolume += ( Tria.GetP( 0) - ORIG) * vtA ;
}
nId = GetNextTriangle( nId, Tria) ;
}
dVolume /= 6 ;
return true ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::RemovePart( int nPart)
{
if ( ! IsValid())
return false ;
// Il numero delle componenti deve essere maggiore di zero o calcolabile
if ( m_vPart.empty() && ! VerifyConnection())
return false ;
// Se la componente non esiste, errore
if ( nPart < 0 || nPart >= int( m_vPart.size()))
return false ;
// Rimuovo i triangoli della componente nPart (ovvero delle sue shell)
const auto vShell = m_vPart[nPart].vShell ;
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
if ( find( vShell.begin(), vShell.end(), m_vTria[i].nShell) != vShell.end())
RemoveTriangle( i) ;
}
// I dati di Shells e Parts sono stati resettati da RemoveTriangle
// imposto ricalcolo della grafica e di hashgrids3d
m_OGrMgr.Reset() ;
ResetHashGrids3d() ;
return true ;
}
//----------------------------------------------------------------------------
SurfTriMesh*
SurfTriMesh::ClonePart( int nPart) const
{
if ( ! IsValid())
return nullptr ;
// Il numero delle componenti deve essere maggiore di zero o calcolabile
if ( m_nShells == -1 && ! VerifyConnection())
// Il numero delle parti deve essere maggiore di zero o calcolabile
if ( m_vPart.empty() && ! VerifyConnection())
return nullptr ;
// Se la componente non esiste, errore
if ( m_nShells <= 0 || nShell < 0 || nShell >= m_nShells)
// Se la parte non esiste, errore
if ( nPart < 0 || nPart >= int( m_vPart.size()))
return nullptr ;
// Creo nuovo oggetto SurfTriMesh
@@ -3971,12 +4120,12 @@ SurfTriMesh::CloneShell( int nShell) const
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
pSurfTM->m_nParts = 1 ;
pSurfTM->m_nShells = 1 ;
// Copio i triangoli
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nShell == nShell) {
const auto& vShell = m_vPart[nPart].vShell ;
if ( m_vTria[i].nIdVert[0] != SVT_DEL &&
find( vShell.begin(), vShell.end(), m_vTria[i].nShell) != vShell.end()) {
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[0]].ptP),
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[1]].ptP),
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[2]].ptP)} ;
+32 -14
View File
@@ -52,16 +52,16 @@ class StmTria
public :
StmTria( void)
: nIdVert{ SVT_NULL, SVT_NULL, SVT_NULL}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nShell( SVT_NULL), nPart( SVT_NULL), nTemp( 0), nTempShell{ 0}, nTempPart{ 0} {}
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
StmTria( const int nIdV[3])
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nShell( SVT_NULL), nPart( SVT_NULL), nTemp( 0), nTempShell{ 0}, nTempPart{ 0} {}
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
StmTria( const int nIdV[3], int nTF)
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nShell( SVT_NULL), nPart( SVT_NULL), nTemp( 0), nTempShell{ 0}, nTempPart{ 0} {}
vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
StmTria( const int nIdV[3], const int nIdA[3], const Vector3d& vtV, int nTF, int nEF)
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ nIdA[0], nIdA[1], nIdA[2]}, nETempFlag{ 0, 0, 0},
vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nShell( SVT_NULL), nPart( SVT_NULL), nTemp( 0), nTempShell{ 0}, nTempPart{ 0} {}
vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
public :
int nIdVert[3] ;
int nIdAdjac[3] ;
@@ -71,11 +71,24 @@ class StmTria
int nTFlag ;
int nEFlag ;
mutable int nShell ;
mutable int nPart ;
mutable int nTemp ;
mutable int nTempShell ;
mutable int nTempPart ;
} ;
//----------------------------------------------------------------------------
// Classe Part
class StmPart
{
public :
StmPart( void)
: bClosed( false) {}
StmPart( bool bClo, const INTVECTOR& vSh)
: bClosed( bClo), vShell( vSh) {}
int GetShellCount( void)
{ return ( vShell.empty() ? 0 : int( vShell.size()) - ( vShell[0] == -1 ? 1 : 0)) ; }
public :
bool bClosed ;
INTVECTOR vShell ;
} ;
//----------------------------------------------------------------------------
@@ -238,7 +251,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
bool RemoveTriangle( int nId) override ;
bool AdjustTopology( void) override ;
bool CreateByFlatContour( const PolyLine& PL) override ;
bool CreateByRegion( const POLYLINEVECTOR& vPL) override ;
bool CreateByRegion( const POLYLINEVECTOR& vPL, const INTMATRIX& vnPLIndMat) override ;
bool CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) override ;
bool CreateByPointCurve( const Point3d& ptP, const PolyLine& PL) override ;
bool CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nRuledType) override ;
@@ -319,12 +332,15 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
bool Repair( double dMaxEdgeLen = MAX_EDGE_LEN_STD) override ;
bool GetAllTriaOverlapBox( const BBox3d& b3Box, INTVECTOR& vT) const override ;
const BBox3d& GetAllTriaBox( void) const override ;
int GetPartCount( void) const override ;
int GetShellCount( void) const override ;
bool RemovePart( int nPart) override ;
int GetShellCount( void) const override ;
bool GetShellArea( int nShell, double& dArea) const override ;
bool RemoveShell( int nShell) override ;
SurfTriMesh* ClonePart( int nPart) const override ;
SurfTriMesh* CloneShell( int nShell) const override ;
int GetPartCount( void) const override ;
bool RemovePart( int nPart) override ;
bool GetPartArea( int nPart, double& dArea) const override ;
bool GetPartVolume( int nPart, double& dVolume) const override ;
SurfTriMesh* ClonePart( int nPart) const override ;
bool SetTFlag( int nId, int nTFlag) override ;
bool GetTFlag( int nId, int& nFlag) const override ;
int GetMaxTFlag( void) const override
@@ -359,6 +375,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
private :
typedef std::vector<StmVert> VERTVECTOR ;
typedef std::vector<StmTria> TRIAVECTOR ;
typedef std::vector<StmPart> PARTVECTOR ;
typedef std::vector<StmFacEdge> FACEDGEVECTOR ;
typedef std::deque<Stm3Int> TRINTDEQUE ;
@@ -403,14 +420,15 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
bool UpdateFacetEdging( void) ;
void ResetHashGrids3d( void) const ;
bool VerifyHashGrids3d( void) const ;
bool VerifyConnection( void) const ;
bool VerifyConnection( bool bShellsAndParts = true) const ;
bool IsShellClosed( int nShell) const ;
bool IsPartClosed( int nPart) const ;
bool CutTriangleByPlane( int nTriaId, const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
bool CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
bool DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMATRIX& cvBoundClosedLoopVec, BOOLVECTOR& vbInOut) ;
bool RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf, bool& bModif) ;
bool AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf) ;
bool IntersectTriMeshTriangle( SurfTriMesh& Other) ;
bool IdentifyParts( void) const ;
bool IdentifyShells( void) const ;
bool RemoveDoubleTriangles( bool& bModified) ;
bool RemoveTJunctions( bool& bModified) ;
@@ -442,8 +460,8 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
int m_nTempProp[2] ; // vettore proprietà temporanee
double m_dTempParam[2] ; // vettore parametri temporanei
int m_nMaxTFlag ; // massimo valore dei TFlag dei triangoli
mutable int m_nParts ; // numero di parti intese come volumi (-1 se da calcolare)
mutable int m_nShells ; // numero di gusci connessi (-1 se da calcolare)
mutable PARTVECTOR m_vPart ; // vettore delle parti (flag chiusura e elenco shell, prima sempre esterna o infinita)
mutable HashGrids3d* m_pHGrd3d ; // Hash Grid 3d nel suo riferimento
mutable BBox3d m_b3HGrd3d ; // Box3d collegato a Hash Grid 3d
} ;
+4 -38
View File
@@ -73,8 +73,7 @@ SurfTriMesh::DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMA
bool bChangedStart = ChangeStart( ptOpenLoopStP, cvBoundClosedLoopVec[nLoop]) ;
// splitto
bool bSplitted = SplitAtPoint( ptOpenLoopEnP, cvBoundClosedLoopVec[nLoop], Loop1, Loop2) ;
if ( ! ( bChangedStart && bSplitted) ||
( nLastOpenLoopPoint == 0 && ( Loop1.size() == 2 || Loop2.size() == 2)))
if ( ! ( bChangedStart && bSplitted))
continue ; // la catena aperta non è interna al loop chiuso attuale
// il loop 2 segue sempre la direzione della catena, il loop 1 ha dentro la catena invertita
@@ -433,9 +432,9 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
int nSameSeg = 0 ;
for ( int nSeg1 = 0 ; nSeg1 < nChainSize1 ; ++ nSeg1) {
for ( int nSeg2 = 0 ; nSeg2 < nChainSize2 ; ++ nSeg2) {
if ( AreSamePointExact( cvOpenChain[nCh1][nSeg1].ptSt, cvOpenChain[nCh2][nSeg2].ptSt) &&
AreSamePointExact( cvOpenChain[nCh1][nSeg1].ptEn, cvOpenChain[nCh2][nSeg2].ptEn) &&
AreSameVectorExact( cvOpenChain[nCh1][nSeg1].vtOuter, cvOpenChain[nCh2][nSeg2].vtOuter)) {
if ( AreSamePointEpsilon( cvOpenChain[nCh1][nSeg1].ptSt, cvOpenChain[nCh2][nSeg2].ptSt, 100 * EPS_ZERO) &&
AreSamePointEpsilon( cvOpenChain[nCh1][nSeg1].ptEn, cvOpenChain[nCh2][nSeg2].ptEn, 100 * EPS_ZERO) &&
AreSameVectorEpsilon( cvOpenChain[nCh1][nSeg1].vtOuter, cvOpenChain[nCh2][nSeg2].vtOuter, 100 * EPS_ZERO)) {
++ nSameSeg ;
}
}
@@ -1404,39 +1403,6 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
return true ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::IdentifyParts( void) const
{
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
// salto triangoli cancellati o già assegnati
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
abs( m_vTria[i].nTempPart) != 1)
continue ;
// set di triangoli da aggiornare
set<int> stTria ;
stTria.insert( i) ;
while ( ! stTria.empty()) {
// tolgo un triangolo dal set
const auto iIt = stTria.begin() ;
int nT = *iIt ;
stTria.erase( iIt) ;
// aggiorno i triangoli adiacenti
for ( int j = 0 ; j < 3 ; ++ j) {
if ( m_vTria[nT].nETempFlag[j] != 0)
continue ;
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nTempPart == 0) {
m_vTria[nAdjT].nTempPart = m_vTria[nT].nTempPart ;
stTria.insert( nAdjT) ;
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::IdentifyShells( void) const
+1416 -916
View File
File diff suppressed because it is too large Load Diff
+32 -20
View File
@@ -155,7 +155,7 @@ class Cell
~Cell( void) {}
Cell( void)
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false),
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), m_nVertToErase( -1),
m_ptPbl( ORIG), m_ptPtr( SBZ_TREG_COEFF, SBZ_TREG_COEFF, 0), m_bProcessed( false), m_bSplitVert( true)
{
Point3d ptTr ( 1 * SBZ_TREG_COEFF, 1 * SBZ_TREG_COEFF) ;
@@ -163,7 +163,7 @@ class Cell
}
Cell( const Point3d& ptBL, const Point3d& ptTR)
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false),
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), m_nVertToErase( -1),
m_ptPbl( ptBL), m_ptPtr( ptTR), m_bProcessed( false), m_bSplitVert( true) {}
bool IsSame( const Cell& cOtherCell) const
{ return ( m_nId == cOtherCell.m_nId) ; }
@@ -185,9 +185,9 @@ class Cell
{ return Point3d( m_ptPtr.x, m_ptPbl.y); }
double GetSplitValue( void) const
{ return m_dSplit ; }
bool IsSplitVert( void) const // se true la cella verrebbe splittata verticalmente, senn orizzontalmente
bool IsSplitVert( void) const // se true la cella verrebbe splittata verticalmente, sennò orizzontalmente
{ return m_bSplitVert ; }
bool IsLeaf( void) const // flag che indica se la cella ha figli o se una foglia
bool IsLeaf( void) const // flag che indica se la cella ha figli o se è una foglia
{ return ( m_nChild1 == -2 && m_nChild2 == -2) ; }
bool IsProcessed( void) const // flag che indica se tutti i figli della cella, se ce ne sono, sono stati processati
{ return m_bProcessed ; }
@@ -197,7 +197,7 @@ class Cell
{ return c1.m_ptPbl.x < c2.m_ptPbl.x ; }
static bool minorY( const Cell& c1, const Cell& c2)
{ return c1.m_ptPbl.y < c2.m_ptPbl.y ; }
public :
int m_nId ; // Id della cella
int m_nTop ; // cella adiacente al lato top
@@ -217,6 +217,8 @@ class Cell
bool m_bOnTopEdge ; // flag che indica se la cella è sul lato top ( per superfici chiuse sul parametro V)
std::vector<Inters> m_vInters ; // vettore delle intersezioni della cella con i loop di trim
// ogni elemento del vettore è l'insieme dei punti che caratterizza un attraversamento della cella
int m_nVertToErase ; // vertice da eliminare dal poligono della cella, in caso di lato sovrapposto ad un lato di polo
// contati in senso CCW a partire dal bottom left
private :
Point3d m_ptPbl ; // punto bottom left
@@ -235,12 +237,17 @@ class Tree
Tree( const Point3d ptBl, const Point3d ptTr) ; // creatore da usare solo nel caso in cui si voglia aggiungere tagli ad un'unica cella e del risultato ottenere il contorno
bool SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ;
bool GetIndependentTrees( BIPNTVECTOR& vTrees) ; // calcolo la suddivisione della superficie solo sulle singole bbox dei loop di trim ( unendo quelli vicini)
bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax il massimo per la dimensione maggiore di un triangolo della trimesh
// dSideMin lunghezza minima del lato di una cella nello spazio reale
bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax è il massimo per la dimensione maggiore di un triangolo della trimesh
// dSideMin è lunghezza minima del lato di una cella nello spazio reale
bool BuildTree_test( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ;
bool GetPolygons( POLYLINEMATRIX& vPolygons) ;
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, INTVECTOR vCells = {}) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
// ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
bool GetPolygons( POLYLINEMATRIX& vvPolygons) ;
bool GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d) ;
bool GetPolygons( POLYLINEMATRIX& vPolygons, bool bForTriangulation, POLYLINEMATRIX& vvPolygons3d) ;
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, POLYLINEVECTOR& vPolygonsCorrected, // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
bool bForTriangulation, POLYLINEVECTOR& vPolygons3d, INTVECTOR vCells = {}) ; // ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
// se richiesti per la triangolazione ad alcuni poligoni potrebbero venire tolti dei punti per evitare errori dovuti ad eventuali poli sui bordi del parametrico
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, POLYLINEVECTOR& vPolygonsCorrected, POLYLINEVECTOR& vPolygons3d) ;
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, INTVECTOR vCells = {}) ;
bool GetLeaves ( std::vector<Cell>& vLeaves) const ; // restituisce gli indici delle foglie nell'albero
bool GetEdges3D ( POLYLINEMATRIX& mPLEdges) ; // restituisce gli edge 3D come polyline
bool GetSplitLoops( POLYLINEVECTOR& vPl) const // funzione che restituisce i loop splitatti ai confini delle celle
@@ -256,8 +263,8 @@ class Tree
private :
bool LimitLoop( PolyLine& pl, POLYLINEVECTOR& vPl, BOOLVECTOR& vbOrientation) const ; // funzione che limita i loop di trim allo spazio parametrico
bool Split( int nId, double dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert
bool Split( int nId) ; // funzione di split di una cella dell'albero a met nella direzione data da bVert
void Balance( void) ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profondit di +- 1
bool Split( int nId) ; // funzione di split di una cella dell'albero a metà nella direzione data da bVert
void Balance( void) ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profondità di +- 1
int GetHeightLeaves( int nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId
int GetDepth( int nId, int nRef) const ; // livello del nodo nId
void GetTopNeigh( int nId, INTVECTOR& vTopNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato top
@@ -268,17 +275,20 @@ class Tree
void ResetTree( void) ; // resetto m_bProcessed a false per tutti i nodi dell'albero
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle
bool FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim
bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle
bool FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim
// resituisce l'id della cella verso cui la curva di trim esce e il vettore delle intersezioni per la cella successiva con il primo punto
bool CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) ; // crea i poligoni della cella passata. richiede anche la funzione CreateIslandAndHoles per completare i poligoni.
bool CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) ; // ai poligoni generati da CreatePolygonsCell aggiunge i loop che creano isole o buchi all'interno della singola cella
bool CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX& vPolygons3d, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell, const PolyLine& plCell3d) ; // crea i poligoni della cella passata. richiede anche la funzione CreateIslandAndHoles per completare i poligoni.
bool CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX& vvPolygons3d, int& nPoly, INTVECTOR& vnParentChunk, bool bForTriangulation,
const PolyLine& plPolygonsBasic, const PolyLine& plPolygonsBasic3d) ; // ai poligoni generati da CreatePolygonsCell aggiunge i loop che creano isole o buchi all'interno della singola cella
bool CheckIfBefore( const PolyLine& pl, int nEdge) const ; // controllo se ptEnd è prima di ptStart sul lato nEdge rispetto al senso antiorario
bool CheckIfBefore( const Inters& inA) const ; // controlla se l'ingresso è prima dell'uscita in senso antiorario a partire da ptTR.
bool CheckIfBefore( int nEdge1, const Point3d& ptP1, int nEdge2, const Point3d& ptP2) const ; // verifico quale punto viene prima tra pt1 e pt2 a partire da ptTR girando in senso CCW (punto 1 su edge 1 e punto 2 su edge 2, rispetto al lato 3)
bool CheckIfBefore( int nEdge, const Point3d& ptP1, const Point3d& ptP2, int nEdge2 = -1) const ; // sul lato nEdge controllo se ptP1 viene prima di ptP2.
bool AreSameEdge( int nEdge1, int nEdge2) const ; // indica se i due edge sono lo stesso. Un vertice adiacente ad un edge viene considerato uguale a questo edge
bool AddVertex( int nId, const PNTMATRIX& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const ; // aggiunge un punto ad un poligono in una cella, premurandosi di aggiungere eventualmente vertici o punti di celle vicine di cui tenere conto
bool CheckIfBefore( int nEdgeA, int nEdgeB) const ; // per due edge uguali per la funzione AreSameEdge chiedo se EdgeA viene prima di EdgeB
bool AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVertex3d, PolyLine& plTrimmedPoly, int& c,
const Point3d& ptToAdd, PolyLine& plTrimmedPoly3d, bool ForTriangulation, Point3d& ptLast) const ; // aggiunge un punto ad un poligono in una cella, premurandosi di aggiungere eventualmente vertici o punti di celle vicine di cui tenere conto
bool SetRightEdgeIn( int nId) ; // categorizza la cella in base all'edge destro per poter poi definire m_nFlag
bool CategorizeCell( int nId) ; // categorizza la cella in base al flag m_nFlag (dentro, fuori, intersecata)
bool CheckIfBetween( const Inters& inA, const Inters& inB) const ; // / controllo se inB è compreso tra l'end e lo start di inA (in senso CCW)
@@ -296,7 +306,7 @@ class Tree
DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00
bool m_bTrimmed ; // superficie trimmata
//INTMATRIX m_vChunk ; // elenco dei loop divisi per chunk
std::map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
std::unordered_map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
//ICURVEPOVECTOR m_vLoop ; // curve di loop
std::vector<std::tuple<PolyLine,bool>> m_vPlApprox ; // vettore contenente le approssimazioni dei loop // il bool indica se la curva è CCW
bool m_bBilinear ; // superficie bilineare
@@ -310,8 +320,10 @@ class Tree
int m_nSpanU ; // numero di span lungo il parametro U
int m_nSpanV ; // numero di span lungo il parametro V
POLYLINEMATRIX m_vPolygons ; // matrice dei poligoni del tree
std::map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 puntatore Null e -1 root
std::map<int,PNTVECTOR> m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id lo stesso che la cella ha in m_mTree
POLYLINEMATRIX m_vPolygonsCorr ; // matrice dei poligoni del tree, corretti per i punti che sono nei poli
POLYLINEMATRIX m_vPolygons3d ; // matrice dei poligoni3d del tree
std::unordered_map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root
std::unordered_map<int,PNTVECTOR> m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id è lo stesso che la cella ha in m_mTree. I punti sono nell'ordine P00, P10, P11, P01
INTVECTOR m_vnLeaves ; // vettore delle foglie
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
bool m_bTestMode ; // bool che indica se la test mode è attiva
+37 -113
View File
@@ -17,6 +17,7 @@
#include "Triangulate.h"
#include "ProjPlane.h"
#include "earcut.hpp"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkPolyLine.h"
#include "/EgtDev/Include/EGkPlane3d.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
@@ -223,6 +224,14 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
//---------------------------------------------------------------------------
bool
Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVECTOR& vTr)
{
INTMATRIX vnPLIndMat ;
return MakeAdvanced( vPLORIG, vPt, vTr, vnPLIndMat) ;
}
//---------------------------------------------------------------------------
bool
Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVECTOR& vTr, const INTMATRIX& vnPLIndMatPre)
{
vPt.clear() ;
vTr.clear() ;
@@ -230,113 +239,28 @@ Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVEC
if ( int( vPLORIG.size()) == 0)
return true ;
// copio il vettore di PolyLine
POLYLINEVECTOR vPL ;
for ( int i = 0 ; i < int( vPLORIG.size()) ; ++ i)
vPL.push_back( vPLORIG[i]) ;
typedef std::pair<int,double> INDAREA ;
std::vector<INDAREA> m_vArea ;
// calcolo piano medio e area delle curve
m_vArea.reserve( vPL.size()) ;
Vector3d vtN0 ;
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
// calcolo piano medio e area
Plane3d plPlane ;
double dArea ;
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))
return false ;
// assegno il segno all'area secondo il verso della normale
if ( ( plPlane.GetVersN() * vtN0) > 0)
m_vArea.emplace_back( i, dArea) ;
else
m_vArea.emplace_back( i, - dArea) ;
}
// 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)) ; }) ;
// dalle PolyLine passo alle curve nel piano XY ( prendo la prima come riferimento, trascuro le Z delle successive)
Frame3d frRef ; frRef.Set( ORIG, vtN0) ;
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) ;
}
// 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
Vector3d vtN ;
// se non sono stati passate le info per ordinare le polyline allora le ordino
INTMATRIX vnPLIndMat ;
// 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() ;
}
}
BOOLVECTOR vbInvert ;
if( vnPLIndMatPre.size() == 0){
if ( ! CalcRegionPolyLines( vPLORIG, vtN, vnPLIndMat, vbInvert))
return false ;
vPL = vPLORIG ;
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) {
for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){
if( vbInvert[vnPLIndMat[i][j]])
vPL.back().Invert() ;
}
}
} while ( ! bFirstCrv) ;
}
else {
// ho già calcolato e riordinato tutto, devo solo fare una copia delle polyline
// non serve fare le eventuali inversioni delle polyline, perché se è già stata calcolata la matrice dei chunck allora sono GIà state invertire
vPL = vPLORIG ;
vnPLIndMat = vnPLIndMatPre ;
}
// chiamo la Triangolazione per ogni riga della matrice ( quindi su ogni "Chunk")
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++ i) {
@@ -525,7 +449,7 @@ Triangulate::MakeByEC( const PNTVECTOR& vPt, INTVECTOR& vTr)
vTr.push_back( vPol[i]) ;
vTr.push_back( vPol[vNext[i]]) ;
}
// Delete vertex v[i] by redirecting next and previous links
// Delete vertex v[i] by redirecting next and previous links
// of neighboring verts past it. Decrement vertex count
vNext[vPrev[i]] = vNext[i] ;
vPrev[vNext[i]] = vPrev[i] ;
@@ -654,7 +578,7 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, INTVECTOR& vTr, double& dMinMinAng
// Reset earity of diagonal endpoints
vEar[vPrev[i]] = EAS_NULL ;
vEar[vNext[i]] = EAS_NULL ;
// Delete vertex v[i] by redirecting next and previous links
// Delete vertex v[i] by redirecting next and previous links
// of neighboring verts past it. Decrement vertex count
vNext[vPrev[i]] = vNext[i] ;
vPrev[vNext[i]] = vPrev[i] ;
@@ -792,7 +716,7 @@ Triangulate::MakeByEC3( const PNTVECTOR& vPt, INTVECTOR& vTr, double& dMinMinAng
// Reset earity of diagonal endpoints
vEar[vPrev[i]] = EAS_NULL ;
vEar[vNext[i]] = EAS_NULL ;
// Delete vertex v[i] by redirecting next and previous links
// Delete vertex v[i] by redirecting next and previous links
// of neighboring verts past it. Decrement vertex count
vNext[vPrev[i]] = vNext[i] ;
vPrev[vNext[i]] = vPrev[i] ;
@@ -886,7 +810,7 @@ Triangulate::TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol,
}
}
else {
// The ear triangle is clockwise so v[i] is not an ear
// The ear triangle is clockwise so v[i] is not an ear
bIsEar = false ;
}
@@ -1231,14 +1155,14 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
break ;
}
}
// non ho trovato alcunché, errore
// non ho trovato alcunch, errore
if ( nI == - 1)
return false ;
// se ho trovato un punto esatto del contorno, non devo fare altri controlli
if ( AreSamePointApprox( ptInt, vPt[nI]))
return true ;
// devo ora verificare che il segmento che unisce i punti non intersechi altri lati del contorno esterno
// altrimenti tengo il punto con raggio più vicino a X_AX o Y_AX o Z_AX secondo m_nPlane
// altrimenti tengo il punto con raggio pi vicino a X_AX o Y_AX o Z_AX secondo m_nPlane
int nJ = nI ;
Point3d ptPa = ptP ;
Point3d ptPb = vPt[nI] ;
@@ -1254,7 +1178,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
double dMinTan = INFINITO ;
double dMinSqDist = SQ_INFINITO ;
for ( int i = 0 ; i < nNumPt ; ++ i) {
// salto il punto già trovato
// salto il punto gi trovato
if ( i == nJ)
continue ;
// verifico se sta nel triangolo
@@ -1290,7 +1214,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
bool
Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const Point3d& ptCorn, const Point3d& ptNext)
{
// la parte valida del settore è a sinistra dei segmenti ptPrev --> ptCorn --> ptNext
// la parte valida del settore a sinistra dei segmenti ptPrev --> ptCorn --> ptNext
// se corner convesso
if ( TriangleIsCCW( ptPrev, ptCorn, ptNext, 0))
return ( TriangleIsCCW( ptPrev, ptCorn, ptTest) &&
@@ -1305,10 +1229,10 @@ Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const
bool
ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi)
{
// se il nuovo inizio coincide col vecchio, non devo fare alcunché
// se il nuovo inizio coincide col vecchio, non devo fare alcunch
if ( nNewStart == 0)
return true ;
// se il nuovo indice è oltre la dimensione del vettore, errore
// se il nuovo indice oltre la dimensione del vettore, errore
if ( nNewStart >= int( vPi.size()))
return false ;
// ciclo di aggiustamento
+1
View File
@@ -23,6 +23,7 @@ class Triangulate
bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
bool MakeAdvanced( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
bool MakeAdvanced( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, const INTMATRIX& vnPLIndMat) ;
private :
bool MakeByEC_HPP( const PolyLine& PL, bool bCCW, PNTVECTOR& vPt, INTVECTOR& vTr) ;
+1 -1
View File
@@ -5090,7 +5090,7 @@ VolZmap::CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ,
// ---------- SFERA ----------------------------------------------------------
//---------------------------------------------------------------------------- pizza
//----------------------------------------------------------------------------
bool
VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dRad, int nToolNum)
{
+168 -213
View File
@@ -371,6 +371,16 @@ Voronoi::GetCurve( int nId) const
return pCrv ;
}
//----------------------------------------------------------------------------
bool
Voronoi::GetVroniPlane( Plane3d& plPlane) const
{
if ( ! IsValid())
return false ;
plPlane.Set( m_Frame.Orig(), m_Frame.VersZ()) ;
return plPlane.IsValid() ;
}
//----------------------------------------------------------------------------
bool
Voronoi::CalcVoronoi( int nBound)
@@ -512,12 +522,12 @@ Voronoi::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound)
// verifico se necessario calcolo Voronoi
if ( ! m_bVDComputed || nBound != m_nBound)
CalcVoronoi( nBound) ;
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
// recupero la curva del bisettore
PtrOwner<ICurve> pCrv( GetBisectorCurve( i)) ;
if ( ! IsNull( pCrv) && pCrv->IsValid())
vCrvs.emplace_back( Release( pCrv)) ;
vCrvs.emplace_back( Release( pCrv)) ;
}
// libero la memoria di vroni utilizzata per calcolare bisettore
@@ -584,65 +594,48 @@ Voronoi::CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType)
if ( ! IsValid())
return false ;
// verifico se curve sono coerenti per calcolo dell'offset
if ( ! VerifyCurvesValidityForOffset())
return false ;
// se offset nullo restituisco direttamente le curve
if ( abs( dOffs) < EPS_SMALL) {
for ( auto pCrv : m_vpCrvs)
vOffs.emplace_back( pCrv->Clone()) ;
}
bool bClosed = m_vpCrvs[0]->IsClosed() ;
// stabilisco lato offset
bool bRightOffs = true ;
bool bLeftOffs = true ;
if ( bClosed) {
bRightOffs = ( dOffs > EPS_SMALL ? true : false) ;
bLeftOffs = ( dOffs < - EPS_SMALL ? true : false) ;
}
// calcolo offset
ICRVCOMPOPLIST OffsList ;
if ( ! CalcVroniOffset( OffsList, abs( dOffs), bRightOffs, bLeftOffs))
if ( ! CalcVroniOffset( OffsList, abs( dOffs)))
return false ;
// sistemo le curve di offset calcolate con vroni
for ( auto pCrv : OffsList) {
// aggiustamento per curva aperta
if ( ! bClosed)
AdjustOpenOffsetCurve( *pCrv, dOffs) ;
if ( pCrv->IsValid()) {
// seleziono le porzioni dell'offset che si trovano dal lato richiesto
ICRVCOMPOPOVECTOR vResult = AdjustOffsetCurves( pCrv, dOffs) ;
for ( int i = 0 ; i < int( vResult.size()) ; ++ i) {
// eventuale inversione
if ( dOffs > EPS_SMALL)
pCrv->Invert() ;
vResult[i]->Invert() ;
// sistemo il punto di inizio
if ( vResult[i]->IsClosed())
AdjustOffsetStart( vResult[i]) ;
// sistemo i raccordi
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0) {
IdentifyFillets( pCrv, dOffs) ;
AdjustCurveFillets( pCrv, dOffs, nType) ;
}
if ( bClosed) {
// forzo chiusura della curva per evitare piccole imprecisioni
pCrv->Close() ;
// sistemo il punto di inizio
AdjustOffsetStart( *pCrv) ;
IdentifyFillets( vResult[i], dOffs) ;
AdjustCurveFillets( vResult[i], dOffs, nType) ;
}
// porto nel frame globale
pCrv->ToGlob( m_Frame) ;
vResult[i]->ToGlob( m_Frame) ;
// unisco le parti allineate
pCrv->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
vResult[i]->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
// aggiungo al vettore finale
vOffs.emplace_back( pCrv) ;
vOffs.emplace_back( Release( vResult[i])) ;
}
else
delete pCrv ;
// dealloco curva
delete( pCrv) ;
}
return true ;
@@ -662,7 +655,7 @@ Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bo
return false ;
ICRVCOMPOPLIST OffsList ;
if ( ! CalcVroniOffset( OffsList, abs( dOffs), true, true))
if ( ! CalcVroniOffset( OffsList, abs( dOffs)))
return false ;
// sistemo le curve di offset calcolate con vroni
@@ -706,21 +699,13 @@ Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bo
//----------------------------------------------------------------------------
bool
Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs, bool bRightOffs, bool bLeftOffs)
Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
{
OffsList.clear() ;
if ( ! IsValid())
return false ;
int nOrigCrvCnt = 1 ;
if ( m_vpCrvs[0]->GetType() == CRV_COMPO) {
const CurveComposite * pOrigCompo = GetBasicCurveComposite( m_vpCrvs[0]) ;
if ( pOrigCompo == nullptr)
return false ;
nOrigCrvCnt = pOrigCompo->GetCurveCount() ;
}
try {
// reset di eventuali offset precedenti
m_vroni->apiResetOffsetData() ;
@@ -729,16 +714,12 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs, bool bRightOff
UpdateVoronoi( dOffs) ;
string sTmp = "" ;
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs, 0.0, false, bLeftOffs, bRightOffs) ;
int nOffsCnt = m_vroni->GetOffsetCount() ;
if ( nOffsCnt == 0) {
// se non ho ottenuto offset ritento con valore leggermente diverso per le tolleranze di vroni
m_vroni->apiResetOffsetData() ;
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs - VRONI_OFFS_TOL, 0.0, false, bLeftOffs, bRightOffs) ;
nOffsCnt = m_vroni->GetOffsetCount() ;
}
// viene sempre calcolato sia right_offset sia left_offset anche nel caso di curve chiuse per evitare problemi di identificazione
// di vroni nel caso di piccole autointersezioni
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs, 0.0, false, true, true) ;
// recupero le curve di offset da vroni
int nOffsCnt = m_vroni->GetOffsetCount() ;
for ( int i = 0 ; i < nOffsCnt ; i++) {
PtrOwner<CurveComposite> pCrvOffs ( CreateBasicCurveComposite()) ;
int nCrvCnt = m_vroni->GetOffsetCurveCount( i) ; // numero di sottocurve
@@ -756,7 +737,10 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs, bool bRightOff
bool bOk = false ;
if ( nType == t_site::SEG)
bOk = pCrvOffs->AddLine( ptE) ;
else {
else {
// se estremi coincidenti passo alla curva successiva ( da vroni non possono arrivare circonferenze)
if ( AreSamePointApprox( ptS, ptE))
continue ;
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
pArc->Set2PRS( ptS, ptE, Dist( ptC, ptS), nType == CCW) ;
bOk = pCrvOffs->AddCurve( Release( pArc)) ;
@@ -768,9 +752,17 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs, bool bRightOff
int nCurrCrvId = pCrvOffs->GetCurveCount() - 1 ;
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigCrv + 1, 0) ;
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigLoop, 1) ;
// verifico se è raccordo relativo agli estremi della curva
if ( nOrigCrv == -1 && ( nOrigPnt == 0 || nOrigPnt == nOrigCrvCnt))
pCrvOffs->SetCurveTempParam( nCurrCrvId, 1.0, 0) ;
// verifico se è una giunzione, ovvero un raccordo relativo agli estremi di una curva ( con distinzione fra curva
// aperta e chiusa)
if ( nOrigCrv == -1) {
int nOrigCrvCnt = 1 ;
if ( m_vpCrvs[nOrigLoop]->GetType() == CRV_COMPO)
nOrigCrvCnt = GetBasicCurveComposite( m_vpCrvs[nOrigLoop])->GetCurveCount() ;
if ( nOrigPnt == 0 || nOrigPnt == nOrigCrvCnt) {
double dParam = m_vpCrvs[nOrigLoop]->IsClosed() ? VRONI_JUNCTION_CLOSED : VRONI_JUNCTION_OPEN ;
pCrvOffs->SetCurveTempParam( nCurrCrvId, dParam, 0) ;
}
}
}
}
@@ -810,160 +802,81 @@ Voronoi::UpdateVoronoi( double dOffs)
}
//----------------------------------------------------------------------------
bool
Voronoi::VerifyCurvesValidityForOffset()
{
if ( m_vpCrvs.size() == 1)
return true ;
// se ho più curve, devono essere tutte chiuse
for ( auto pCrv : m_vpCrvs) {
if ( ! pCrv->IsClosed())
return false ;
}
// verifico se gli orientamenti delle curve sono coerenti
DBLVECTOR vArea( m_vpCrvs.size()) ;
double dRefArea = 0.0 ;
for ( int i = 0 ; i < ( int)m_vpCrvs.size() ; i ++) {
m_vpCrvs[i]->GetAreaXY( vArea[i]) ;
if ( abs( vArea[i]) > abs( dRefArea))
dRefArea = vArea[i] ;
}
bool bRefCCW = ( dRefArea > EPS_SMALL) ;
for ( int i = 0 ; i < ( int)vArea.size() ; i++) {
// se curva con orientamento principale verifico sia esterna a tutte le altre curve con orientamento principale
if ( vArea[i] * dRefArea > EPS_SMALL) {
for ( int j = 0 ; j < ( int)vArea.size() ; j++) {
if ( j != i && vArea[i] * vArea[j] > EPS_SMALL) {
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[j]) ;
int nRes = ccInt.GetRegionCurveClassification() ;
if ( nRes == CCREGC_NULL || nRes == CCREGC_SAME || nRes == CCREGC_INTERS)
return false ;
if ( ( bRefCCW && nRes == CCREGC_IN1) || ( ! bRefCCW && nRes == CCREGC_IN2)) {
// se è interna ad una curva con orientamento principale, verifico sia esterna ad almeno una curva con orientamento
// diverso dal principale
bool bFound = false ;
for ( int k = 0 ; k < ( int)vArea.size() ; k++) {
if ( k != i && vArea[i] * vArea[k] < EPS_SMALL) {
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[k]) ;
int nRes = ccInt.GetRegionCurveClassification() ;
if ( ( bRefCCW && nRes == CCREGC_OUT) || ( ! bRefCCW && nRes == CCREGC_IN1)) {
bFound = true ;
break ;
}
}
}
if ( ! bFound)
return false ;
}
}
}
}
// se curva con orientamento diverso dal principale verifico sia contenuta in una curva con orientamento principale
else if ( vArea[i] * dRefArea < - EPS_SMALL) {
bool bInside = false ;
for ( int j = 0 ; j < ( int)vArea.size() ; j++) {
if ( j != i && vArea[j] * dRefArea > EPS_SMALL) {
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[j]) ;
int nRes = ccInt.GetRegionCurveClassification() ;
if ( ( bRefCCW && nRes == CCREGC_IN1) || ( ! bRefCCW && nRes == CCREGC_OUT)) {
bInside = true ;
break ;
}
}
}
if ( ! bInside)
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Voronoi::AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs)
ICRVCOMPOPOVECTOR
Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
{
ICRVCOMPOPOVECTOR vResult ;
int nSideRef = dOffs < EPS_SMALL ? MDS_LEFT : MDS_RIGHT ;
// recupero i raccordi relativi agli estremi della curva aperta
INTVECTOR vJunctions ;
for ( int i = 0 ; i < pCompo.GetCurveCount() ; i++) {
double dParTmp ;
pCompo.GetCurveTempParam( i, dParTmp) ;
if ( dParTmp > EPS_SMALL)
vJunctions.push_back( i) ;
// verifico se presenti giunzioni
bool bJunctions = false ;
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i ++) {
double dParam ; pCompo->GetCurveTempParam( i, dParam) ;
if ( abs( dParam - VRONI_JUNCTION_OPEN) < EPS_SMALL) {
bJunctions = true ;
break ;
}
}
if ( vJunctions.size() == 0) {
// verifico se si trova dal lato corretto
if ( ! bJunctions) {
// controllo la curva complessiva
int nSide = GetOffsetCurveSide( pCompo, 0) ;
if ( nSide != nSideRef)
// se lato errato, tutta la curva va cancellata
pCompo.Clear() ;
if ( nSide == nSideRef)
vResult.emplace_back( pCompo->Clone()) ;
}
else if ( vJunctions.size() == 2) {
// recupero i due tratti di curva
PtrOwner<CurveComposite> pCompo1( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[0] + 1, vJunctions[1]))) ;
PtrOwner<CurveComposite> pCompo2( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[1] + 1, vJunctions[0]))) ;
pCompo.Clear() ;
if ( ! IsNull( pCompo1) && pCompo1->IsValid()) {
int nSide = GetOffsetCurveSide( *pCompo1, 0) ;
if ( nSide == nSideRef)
pCompo.CopyFrom( pCompo1) ;
else if ( ! IsNull( pCompo2) && pCompo2->IsValid())
pCompo.CopyFrom( pCompo2) ;
}
else if ( ! IsNull( pCompo2) && pCompo2->IsValid()) {
int nSide = GetOffsetCurveSide( *pCompo2, 0) ;
if ( nSide == nSideRef)
pCompo.CopyFrom( pCompo2) ;
}
}
else {
// mi posiziono dopo la junction
pCompo.ChangeStartPoint( vJunctions[0] + 1) ;
delete( pCompo.RemoveFirstOrLastCurve()) ;
// verifico validità della curva
int nSide = GetOffsetCurveSide( pCompo, 0) ;
if ( nSide == nSideRef) {
// scorro fino alla prima curva non valida ed elimino la curva da quel punto fino alla fine
for ( int i = 1 ; i < pCompo.GetCurveCount() ; i++) {
else {
// scorro la curva eliminando le giunzioni relative a curve aperte e le sottocurve che si trovano dal lato sbagliato
PtrOwner<CurveComposite> pCompoCurr( CreateBasicCurveComposite()) ;
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i ++) {
bool bKeep = true ;
double dParTmp ; pCompo->GetCurveTempParam( i, dParTmp) ;
if ( abs( dParTmp - VRONI_JUNCTION_OPEN) < EPS_SMALL)
bKeep = false ;
else {
int nSide = GetOffsetCurveSide( pCompo, i) ;
if ( nSide != nSideRef)
pCompo.TrimEndAtParam( i) ;
}
}
else {
// elimino finchè non trovo una curva valida
while( nSide != nSideRef && pCompo.IsValid()) {
delete( pCompo.RemoveFirstOrLastCurve( false)) ;
if ( pCompo.IsValid())
nSide = GetOffsetCurveSide( pCompo, 0) ;
}
}
}
bKeep = ( nSide == nSideRef) ;
}
return true ;
if ( bKeep)
pCompoCurr->AddCurve( pCompo->GetCurve( i)->Clone()) ;
else {
// salvo la curva ottenuta fino ad ora e resetto per i prossimi tratti validi
if ( pCompoCurr->IsValid()) {
vResult.emplace_back( Release( pCompoCurr)) ;
pCompoCurr.Set( CreateBasicCurveComposite()) ;
}
}
}
// salvo eventuale ultima curva
if ( pCompoCurr->IsValid())
vResult.emplace_back( Release( pCompoCurr)) ;
// verifico se posso concatenare prima e ultima curva
if ( vResult.size() > 1) {
Point3d ptStart ; vResult.front()->GetStartPoint( ptStart) ;
Point3d ptEnd ; vResult.back()->GetEndPoint( ptEnd) ;
if ( AreSamePointApprox( ptStart, ptEnd) && vResult.front()->AddCurve( vResult.back()->Clone(), false))
vResult.pop_back() ;
}
}
return vResult ;
}
//---------------------------------------------------------------------------
int
Voronoi::GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv)
Voronoi::GetOffsetCurveSide( const ICurveComposite* pOffs, int nCrv) const
{
Point3d ptM ; pOffs.GetCurve( nCrv)->GetMidPoint(ptM) ;
int nOrigCrv ; pOffs.GetCurveTempProp( nCrv, nOrigCrv) ;
Point3d ptM ; pOffs->GetCurve( nCrv)->GetMidPoint( ptM) ;
const ICurve* pCrvRef = m_vpCrvs[0] ;
// se ha una sottocurva di riferimento
if ( nOrigCrv != 0 && m_vpCrvs[0]->GetType() == CRV_COMPO) {
const CurveComposite* pCompoOrig = GetBasicCurveComposite( m_vpCrvs[0]) ;
// recupero curva e sottocurva di riferimento
int nOrigSubCrv ; pOffs->GetCurveTempProp( nCrv, nOrigSubCrv) ;
int nOrigCrv ; pOffs->GetCurveTempProp( nCrv, nOrigCrv, 1) ;
const ICurve* pCrvRef = m_vpCrvs[nOrigCrv] ;
if ( nOrigSubCrv != 0 && m_vpCrvs[nOrigCrv]->GetType() == CRV_COMPO) {
const CurveComposite* pCompoOrig = GetBasicCurveComposite( m_vpCrvs[nOrigCrv]) ;
if ( pCompoOrig != nullptr)
pCrvRef = pCompoOrig->GetCurve( nOrigCrv - 1) ;
pCrvRef = pCompoOrig->GetCurve( nOrigSubCrv - 1) ;
}
DistPointCurve distPC( ptM, *pCrvRef) ;
@@ -974,19 +887,19 @@ Voronoi::GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv)
//---------------------------------------------------------------------------
bool
Voronoi::AdjustOffsetStart( ICurveComposite& pCrv)
Voronoi::AdjustOffsetStart( ICurveComposite* pCrv) const
{
for ( int i = 0 ; i < pCrv.GetCurveCount() ; i++) {
// cerco il tratto associato alla prima curva originale
int nProp ; pCrv.GetCurveTempProp( i, nProp) ;
if ( nProp == 1) {
pCrv.ChangeStartPoint( i) ;
for ( int i = 0 ; i < pCrv->GetCurveCount() ; i++) {
// cerco il tratto associato alla prima sottocurva originale
int nOrigCrv ; pCrv->GetCurveTempProp( i, nOrigCrv) ;
if ( nOrigCrv == 1) {
pCrv->ChangeStartPoint( i) ;
break ;
}
// oppure un raccordo di junction
double dParam ; pCrv.GetCurveTempParam( i, dParam) ;
if ( abs( dParam - 1) < EPS_SMALL) {
pCrv.ChangeStartPoint( i + 1) ;
// oppure associato ad una giunzione
double dParam ; pCrv->GetCurveTempParam( i, dParam) ;
if ( abs( dParam - VRONI_JUNCTION_CLOSED) < EPS_SMALL) {
pCrv->ChangeStartPoint( i + 1) ;
break ;
}
}
@@ -1003,7 +916,8 @@ Voronoi::Translate( const Vector3d & vtMove)
}
//---------------------------------------------------------------------------
bool Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
bool
Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{
if ( ! IsValid())
return false ;
@@ -1011,7 +925,8 @@ bool Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
}
//---------------------------------------------------------------------------
bool Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
bool
Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
if ( ! IsValid())
return false ;
@@ -1019,7 +934,8 @@ bool Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
}
//---------------------------------------------------------------------------
bool Voronoi::ToGlob( const Frame3d& frRef)
bool
Voronoi::ToGlob( const Frame3d& frRef)
{
if ( ! IsValid())
return false ;
@@ -1027,7 +943,8 @@ bool Voronoi::ToGlob( const Frame3d& frRef)
}
//---------------------------------------------------------------------------
bool Voronoi::ToLoc( const Frame3d& frRef)
bool
Voronoi::ToLoc( const Frame3d& frRef)
{
if ( ! IsValid())
return false ;
@@ -1035,9 +952,47 @@ bool Voronoi::ToLoc( const Frame3d& frRef)
}
//---------------------------------------------------------------------------
bool Voronoi::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
bool
Voronoi::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
{
if ( ! IsValid())
return false ;
return m_Frame.LocToLoc( frOri, frDest) ;
}
//---------------------------------------------------------------------------
bool
Voronoi::CalcLimitOffset( int nCrv, bool bLeft, double& dOffs)
{
if ( nCrv < 0 || nCrv > int( m_vpCrvs.size()) - 1)
return false ;
// se curva aperta errore
if ( ! m_vpCrvs[nCrv]->IsClosed())
return false ;
dOffs = - INFINITO ;
try {
// verifico se necessario calcolo Voronoi
if ( ! m_bVDComputed)
CalcVoronoi() ;
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
// verifico se è un bisettore relativo alla curva richiesta e dal lato opportuno
if ( m_vroni->IsRelatedEdge( i, nCrv, bLeft)) {
// calcolo i parametri del bisettore
double dParS, dParE ;
m_vroni->GetBisectorParams( i, dParS, dParE) ;
dOffs = max( { dParS, dParE, dOffs}) ;
}
}
// libero la memoria di vroni dedicata agli offset
m_vroni->apiFreeOffsetData() ;
}
catch (...) {
LOG_ERROR( GetEGkLogger(), m_vroni->GetExceptionMessage()) ;
return false ;
}
return true ;
}
+8 -5
View File
@@ -25,6 +25,8 @@
static const bool USE_VORONOI = true ;
static const int VORONOI_STD_BOUND = 3 ;
static const double VRONI_OFFS_TOL = 1e-9 ;
static const double VRONI_JUNCTION_OPEN = 1.0 ;
static const double VRONI_JUNCTION_CLOSED = 2.0 ;
//-------------------------- Forward Definitions -------------------------------
class ISurfFlatRegion ;
@@ -50,10 +52,12 @@ class Voronoi
ICurve* GetCurve( int nId) const ;
int GetCurveCount( void) const
{ return m_vpCrvs.size() ; } ;
bool GetVroniPlane( Plane3d& plPlane) const ;
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = VORONOI_STD_BOUND) ;
bool CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType) ;
bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids) ;
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) ;
bool CalcLimitOffset( int nCrv, bool bLeft, double& dOffs) ;
bool Translate( const Vector3d& vtMove) ;
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) ;
@@ -73,12 +77,11 @@ class Voronoi
bool AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoopId) ;
bool CalcVoronoi( int nBound = VORONOI_STD_BOUND) ;
bool CalcVroniOffset( ICRVCOMPOPLIST& vOffs, double dOffs, bool bRightOffs, bool bLeftOffs) ;
bool CalcVroniOffset( ICRVCOMPOPLIST& vOffs, double dOffs) ;
bool UpdateVoronoi( double dOffs) ;
bool VerifyCurvesValidityForOffset( void) ;
bool AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs) ;
bool AdjustOffsetStart( ICurveComposite& pCompo) ;
int GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv) ;
ICRVCOMPOPOVECTOR AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const ;
bool AdjustOffsetStart( ICurveComposite* pCompo) const ;
int GetOffsetCurveSide( const ICurveComposite* pOffs, int nCrv) const ;
ICurve* GetBisectorCurve( int i) ;
private :