Miglioramento gestione facce complanari

This commit is contained in:
LorenzoM
2021-04-28 13:07:26 +02:00
parent c56e573ae3
commit 2d6804215d
+88 -64
View File
@@ -4532,41 +4532,47 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
Point3d ptL ; Vector3d vtL ;
int nResPP = IntersPlanePlane( plPlaneA, plPlaneB, ptL, vtL) ;
if ( /*nResPP == IPPT_NO ||*/ nResPP == IPPT_OVERLAPS) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
frIntersRegion.GetArea( dIntersRegArea) ;
// Assegno indice di parte ai pezzi.
if ( dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0;
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0 ;
int nPartIndex = bCodirectedNorm ? 2 : - 2 ;
itFacetA->second[nPieceNumA].nPiecePart = nPartIndex;
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex;
itFacetA->second[nPieceNumA].nPiecePart = nPartIndex ;
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex ;
}
}
else if (nResPP == IPPT_YES) {
else if ( nResPP == IPPT_YES) {
Point3d ptCentroidA, ptCentroidB ;
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
if ( AreSameOrOppositeVectorApprox( plPlaneA.GetVersN(), plPlaneB.GetVersN()) &&
abs( ( ptCentroidB - ptCentroidA) * plPlaneA.GetVersN()) < EPS_SMALL) {
BBox3d b3Box, b3BoxB;
RegionA.GetLocalBBox(b3Box);
RegionB.GetLocalBBox(b3BoxB);
b3Box.Add(b3BoxB);
b3Box.Expand(10);
INTDBLVECTOR vInters;
if (!IntersLineBox(ptL, vtL, 100., b3Box, vInters, false) || int(vInters.size()) < 2) {
SurfFlatRegion frIntersRegion = RegionA;
frIntersRegion.Intersect(RegionB);
double dIntersRegArea;
frIntersRegion.GetArea(dIntersRegArea);
BBox3d b3Box, b3BoxB ;
RegionA.GetLocalBBox( b3Box) ;
RegionB.GetLocalBBox( b3BoxB) ;
b3Box.Add( b3BoxB) ;
b3Box.Expand( 10) ;
INTDBLVECTOR vInters ;
if ( ! IntersLineBox( ptL, vtL, 100., b3Box, vInters, false) || int( vInters.size()) < 2) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
frIntersRegion.GetArea( dIntersRegArea) ;
// Assegno indice di parte ai pezzi.
if (dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0;
int nPartIndex = bCodirectedNorm ? 2 : -2;
itFacetA->second[nPieceNumA].nPiecePart = nPartIndex;
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex;
if ( dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0 ;
int nPartIndex = bCodirectedNorm ? 2 : - 2 ;
itFacetA->second[nPieceNumA].nPiecePart = nPartIndex ;
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex ;
}
}
}
@@ -4588,6 +4594,9 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
Point3d ptL ; Vector3d vtL ;
int nResPP = IntersPlanePlane( plPlaneA, plPlaneB, ptL, vtL) ;
if ( /*nResPP == IPPT_NO ||*/ nResPP == IPPT_OVERLAPS) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
@@ -4608,27 +4617,30 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
if ( AreSameOrOppositeVectorApprox(plPlaneA.GetVersN(), plPlaneB.GetVersN()) &&
abs((ptCentroidB - ptCentroidA) * plPlaneA.GetVersN()) < EPS_SMALL) {
BBox3d b3Box, b3BoxB;
RegionA.GetLocalBBox(b3Box);
RegionB.GetLocalBBox(b3BoxB);
b3Box.Add(b3BoxB);
b3Box.Expand(10);
INTDBLVECTOR vInters;
if (!IntersLineBox(ptL, vtL, 100., b3Box, vInters, false) || int(vInters.size()) < 2) {
SurfFlatRegion frIntersRegion = RegionA;
frIntersRegion.Intersect(RegionB);
double dIntersRegArea;
frIntersRegion.GetArea(dIntersRegArea);
abs( ( ptCentroidB - ptCentroidA) * plPlaneA.GetVersN()) < EPS_SMALL) {
BBox3d b3Box, b3BoxB ;
RegionA.GetLocalBBox( b3Box) ;
RegionB.GetLocalBBox( b3BoxB) ;
b3Box.Add( b3BoxB) ;
b3Box.Expand( 10) ;
INTDBLVECTOR vInters ;
if ( ! IntersLineBox( ptL, vtL, 100., b3Box, vInters, false) || int( vInters.size()) < 2) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
frIntersRegion.GetArea( dIntersRegArea) ;
// Assegno indice di parte al pezzo di faccia A e ai triangoli della faccia B.
if (dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0;
int nPartIndex = bCodirectedNorm ? 2 : -2;
itFacetA->second[nPieceNumA].nPiecePart = nPartIndex;
INTVECTOR vTB;
SurfB.GetAllTriaInFacet(nFB, vTB);
for (int& nTB : vTB)
SurfB.m_vTria[nTB].nTempPart = nPartIndex;
if ( dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0 ;
int nPartIndex = bCodirectedNorm ? 2 : - 2 ;
itFacetA->second[nPieceNumA].nPiecePart = nPartIndex ;
INTVECTOR vTB ;
SurfB.GetAllTriaInFacet( nFB, vTB) ;
for ( int& nTB : vTB)
SurfB.m_vTria[nTB].nTempPart = nPartIndex ;
}
}
}
@@ -4686,6 +4698,9 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
Point3d ptL ; Vector3d vtL ;
int nResPP = IntersPlanePlane( plPlaneA, plPlaneB, ptL, vtL) ;
if ( /*nResPP == IPPT_NO ||*/ nResPP == IPPT_OVERLAPS) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
@@ -4714,6 +4729,9 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
b3Box.Expand( 10) ;
INTDBLVECTOR vInters;
if ( ! IntersLineBox( ptL, vtL, 100., b3Box, vInters, false) || int( vInters.size()) < 2) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
@@ -4748,6 +4766,9 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
Point3d ptL ; Vector3d vtL ;
int nResPP = IntersPlanePlane( plPlaneA, plPlaneB, ptL, vtL) ;
if ( /*nResPP == IPPT_NO ||*/ nResPP == IPPT_OVERLAPS) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
@@ -4766,35 +4787,38 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
SurfB.m_vTria[nTB].nTempPart = nPartIndex ;
}
}
else if (nResPP == IPPT_YES) {
else if ( nResPP == IPPT_YES) {
Point3d ptCentroidA, ptCentroidB ;
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
if ( AreSameOrOppositeVectorApprox( plPlaneA.GetVersN(), plPlaneB.GetVersN()) &&
abs( ( ptCentroidB - ptCentroidA) * plPlaneA.GetVersN()) < EPS_SMALL) {
BBox3d b3Box, b3BoxB;
RegionA.GetLocalBBox(b3Box);
RegionB.GetLocalBBox(b3BoxB);
b3Box.Add(b3BoxB);
b3Box.Expand(10);
INTDBLVECTOR vInters;
if (!IntersLineBox(ptL, vtL, 100., b3Box, vInters, false) || int(vInters.size()) < 2) {
SurfFlatRegion frIntersRegion = RegionA;
frIntersRegion.Intersect(RegionB);
double dIntersRegArea;
frIntersRegion.GetArea(dIntersRegArea);
abs( ( ptCentroidB - ptCentroidA) * plPlaneA.GetVersN()) < EPS_SMALL) {
BBox3d b3Box, b3BoxB ;
RegionA.GetLocalBBox( b3Box) ;
RegionB.GetLocalBBox( b3BoxB) ;
b3Box.Add( b3BoxB) ;
b3Box.Expand( 10) ;
INTDBLVECTOR vInters ;
if ( ! IntersLineBox( ptL, vtL, 100., b3Box, vInters, false) || int( vInters.size()) < 2) {
// Se necessario inverto la regione B per eseguire l'intersezione.
if ( plPlaneA.GetVersN() * plPlaneB.GetVersN() < - EPS_SMALL)
RegionB.Invert() ;
SurfFlatRegion frIntersRegion = RegionA ;
frIntersRegion.Intersect( RegionB) ;
double dIntersRegArea ;
frIntersRegion.GetArea( dIntersRegArea) ;
// Assegno indice di parte al pezzo di faccia A e ai triangoli della faccia B.
if (dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0;
int nPartIndex = bCodirectedNorm ? 2 : -2;
INTVECTOR vTA;
GetAllTriaInFacet(nFA, vTA);
for (int& nTA : vTA)
m_vTria[nTA].nTempPart = nPartIndex;
INTVECTOR vTB;
SurfB.GetAllTriaInFacet(nFB, vTB);
for (int& nTB : vTB)
SurfB.m_vTria[nTB].nTempPart = nPartIndex;
if ( dIntersRegArea > EPS_SMALL) {
bool bCodirectedNorm = RegionA.GetNormVersor() * RegionB.GetNormVersor() > 0 ;
int nPartIndex = bCodirectedNorm ? 2 : - 2 ;
INTVECTOR vTA ;
GetAllTriaInFacet( nFA, vTA) ;
for ( int& nTA : vTA)
m_vTria[nTA].nTempPart = nPartIndex ;
INTVECTOR vTB ;
SurfB.GetAllTriaInFacet( nFB, vTB) ;
for ( int& nTB : vTB)
SurfB.m_vTria[nTB].nTempPart = nPartIndex ;
}
}
}