Miglioratagestione dellefacce complanari

This commit is contained in:
LorenzoM
2021-04-23 17:54:58 +02:00
parent b0be7306a9
commit 8db33f941b
+110 -84
View File
@@ -4544,24 +4544,30 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex;
}
}
else if ( nResPP == IPPT_YES && abs(plPlaneA.GetDist() - plPlaneB.GetDist()) < EPS_SMALL && AreSameVectorApprox( plPlaneA.GetVersN(), plPlaneB.GetVersN())) {
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) ;
// 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;
else if (nResPP == IPPT_YES) {
Point3d ptCentroidA, ptCentroidB ;
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
if ( AreSameVectorApprox( 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);
// 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;
}
}
}
}
@@ -4597,27 +4603,33 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
SurfB.m_vTria[nTB].nTempPart = nPartIndex ;
}
}
else if ( nResPP == IPPT_YES && abs(plPlaneA.GetDist() - plPlaneB.GetDist()) < EPS_SMALL && AreSameVectorApprox( plPlaneA.GetVersN(), plPlaneB.GetVersN())) {
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) ;
// 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 ;
else if ( nResPP == IPPT_YES) {
Point3d ptCentroidA, ptCentroidB ;
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
if (AreSameVectorApprox(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);
// 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;
}
}
}
}
@@ -4685,27 +4697,33 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex ;
}
}
else if ( nResPP == IPPT_YES && abs(plPlaneA.GetDist() - plPlaneB.GetDist()) < EPS_SMALL && AreSameVectorApprox( plPlaneA.GetVersN(), plPlaneB.GetVersN())) {
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) ;
// Assegno indice di parte ai triangoli di A e ai pezzi di 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 ;
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex ;
else if ( nResPP == IPPT_YES) {
Point3d ptCentroidA, ptCentroidB ;
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
if ( AreSameVectorApprox( 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) ;
// Assegno indice di parte ai triangoli di A e ai pezzi di 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 ;
itFacetB->second[nPieceNumB].nPiecePart = nPartIndex ;
}
}
}
}
@@ -4744,30 +4762,38 @@ SurfTriMesh::ItersectTriMeshFacets( SurfTriMesh& Other)
SurfB.m_vTria[nTB].nTempPart = nPartIndex ;
}
}
else if ( nResPP == IPPT_YES && abs(plPlaneA.GetDist() - plPlaneB.GetDist()) < EPS_SMALL && AreSameVectorApprox( plPlaneA.GetVersN(), plPlaneB.GetVersN())) {
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) ;
// 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 ;
else if (nResPP == IPPT_YES) {
Point3d ptCentroidA, ptCentroidB ;
RegionA.GetCentroid( ptCentroidA) ;
RegionB.GetCentroid( ptCentroidB) ;
bool bVecOk = AreSameVectorApprox(plPlaneA.GetVersN(), plPlaneB.GetVersN());
double dOk = abs((ptCentroidB - ptCentroidA) * plPlaneA.GetVersN());
if ( AreSameVectorApprox( 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);
// 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;
}
}
}
}