611 |
PIntersection listVertexIntersectionNew; |
PIntersection listVertexIntersectionNew; |
612 |
std::vector<Triangle> triangleListIntersectionNew; |
std::vector<Triangle> triangleListIntersectionNew; |
613 |
|
|
614 |
|
// CALCUL DES INTERSECTIONS |
615 |
__calculatePointsIntersection(O1, O2, toTreatHexahedra, listVertexIntersectionNew); |
__calculatePointsIntersection(O1, O2, toTreatHexahedra, listVertexIntersectionNew); |
616 |
|
|
617 |
//create mesh intersection for the object 0 and 1 |
//create mesh intersection for the object 0 and 1 |
618 |
|
// GENERATION DES MAILLAGES |
619 |
__createTrianglesIntersection<booleanTest>(0, O1, O2, toTreatHexahedra, |
__createTrianglesIntersection<booleanTest>(0, O1, O2, toTreatHexahedra, |
620 |
triangleListIntersectionNew, listVertexIntersectionNew); |
triangleListIntersectionNew, listVertexIntersectionNew); |
621 |
ffout(4)<<"nb triangles in intersection 0 "<<triangleListIntersectionNew.size()<<"\n"<<std::flush; |
ffout(4)<<"nb triangles in intersection 0 "<<triangleListIntersectionNew.size()<<"\n"<<std::flush; |
809 |
PIntersection& listVertexIntersectionNew) |
PIntersection& listVertexIntersectionNew) |
810 |
{ |
{ |
811 |
// calculate points intersection between object O1 and O2 |
// calculate points intersection between object O1 and O2 |
812 |
MapCellTriangle hexaToTriangle0=*(O1.hexalist); |
const MapCellTriangle& hexaToTriangle0=*(O1.hexalist); |
813 |
MapCellTriangle hexaToTriangle1=*(O2.hexalist); |
const MapCellTriangle& hexaToTriangle1=*(O2.hexalist); |
814 |
|
|
815 |
for(std::set<const Cell*>::iterator i=toTreatHexahedra.begin(); |
for(std::set<const Cell*>::const_iterator i=toTreatHexahedra.begin(); |
816 |
i!=toTreatHexahedra.end(); ++i) { |
i!=toTreatHexahedra.end(); ++i) { |
817 |
MapCellTriangle::iterator it0=hexaToTriangle0.find(*i); |
MapCellTriangle::const_iterator it0=hexaToTriangle0.find(*i); |
818 |
MapCellTriangle::iterator it1=hexaToTriangle1.find(*i); |
MapCellTriangle::const_iterator it1=hexaToTriangle1.find(*i); |
819 |
if(it0!=hexaToTriangle0.end() and it1!=hexaToTriangle1.end()) { |
|
820 |
std::list<Triangle*> listTriangle0=(*it0).second; |
assert(it0!=hexaToTriangle0.end() and it1!=hexaToTriangle1.end()); |
821 |
std::list<Triangle*> listTriangle1=(*it1).second; |
|
822 |
for(std::list<Triangle*>::iterator jt0=listTriangle0.begin() ; |
std::list<Triangle*> listTriangle0=(*it0).second; |
823 |
jt0!=listTriangle0.end() ; ++jt0) { |
std::list<Triangle*> listTriangle1=(*it1).second; |
824 |
for(std::list<Triangle*>::iterator jt1=listTriangle1.begin() ; |
|
825 |
jt1!=listTriangle1.end() ; ++jt1) { |
for(std::list<Triangle*>::iterator jt0=listTriangle0.begin() ; |
826 |
__createPointIntersection(jt0,jt1,listVertexIntersectionNew); |
jt0!=listTriangle0.end() ; ++jt0) { |
827 |
} |
for(std::list<Triangle*>::iterator jt1=listTriangle1.begin() ; |
828 |
|
jt1!=listTriangle1.end() ; ++jt1) { |
829 |
|
__createPointIntersection(jt0,jt1,listVertexIntersectionNew); |
830 |
} |
} |
|
} else { |
|
|
//ffout(4)<<"pas d'intersection dans l'hexa\n"; |
|
831 |
} |
} |
832 |
} |
} |
833 |
} |
} |
1030 |
if(!(norm3>epsilon)) { |
if(!(norm3>epsilon)) { |
1031 |
//point confondus avec l'autre sommet |
//point confondus avec l'autre sommet |
1032 |
Pinter.addPoint(Vo1); |
Pinter.addPoint(Vo1); |
1033 |
} else |
} else { |
1034 |
|
// CONSIDÈRE QU'IL PEUT Y AVOIR DEUX POINTS D'INTERSECTION SUR L'ARÊTE, MAIS PAS PLUS |
1035 |
if(listVertexIntersectionNew.find(pV)==listVertexIntersectionNew.end() |
if(listVertexIntersectionNew.find(pV)==listVertexIntersectionNew.end() |
1036 |
and listVertexIntersectionNew.find(pV2)==listVertexIntersectionNew.end()) { |
and listVertexIntersectionNew.find(pV2)==listVertexIntersectionNew.end()) { |
1037 |
listVertexIntersectionNew[pV][0]=new Vertex (P); |
listVertexIntersectionNew[pV][0]=new Vertex (P); |
1061 |
} |
} |
1062 |
} |
} |
1063 |
} |
} |
1064 |
|
} |
1065 |
Pinter.cutTriangle1()[ncase]=Pinter.size(); |
Pinter.cutTriangle1()[ncase]=Pinter.size(); |
1066 |
} |
} |
1067 |
} else { |
} else { |
1132 |
{ |
{ |
1133 |
// calculate points intersection between triangle "currentTriangle" and "currentTriangle1" |
// calculate points intersection between triangle "currentTriangle" and "currentTriangle1" |
1134 |
// this points are in "Pinter" |
// this points are in "Pinter" |
1135 |
|
|
1136 |
|
// NECESSITE DE V012 et Vo012 ? |
1137 |
|
|
1138 |
TinyVector<3,const Vertex * > V012; |
TinyVector<3,const Vertex * > V012; |
1139 |
const Triangle& T0=*(*currentTriangle1); |
const Triangle& T0=*(*currentTriangle1); |
1140 |
V012[0] = &T0(0); |
V012[0] = &T0(0); |
1192 |
pTriangle.second=(*currentTriangle); |
pTriangle.second=(*currentTriangle); |
1193 |
|
|
1194 |
IntersectionPoints Pinter; |
IntersectionPoints Pinter; |
1195 |
|
// CALCUL DU POINT D'INTERSECTION |
1196 |
__CalculPoint(currentTriangle, currentTriangle1, Pinter, listVertexIntersectionNew); |
__CalculPoint(currentTriangle, currentTriangle1, Pinter, listVertexIntersectionNew); |
1197 |
|
|
1198 |
const TinyVector<3,size_t >& pintercut=Pinter.cutTriangle1(); |
const TinyVector<3,size_t >& pintercut=Pinter.cutTriangle1(); |
1199 |
|
|
1200 |
if(pintercut[0]+pintercut[1]+pintercut[2]!=0) { |
if(Pinter.size()!=0) { |
1201 |
//ffout(4)<<"le tr est cut\n"; |
//ffout(4)<<"rajout2 \n"; |
|
assert(pairTriangleToIntersectionPoints.find(pTriangle)==pairTriangleToIntersectionPoints.end()); |
|
1202 |
pairTriangleToIntersectionPoints[pTriangle] = Pinter; |
pairTriangleToIntersectionPoints[pTriangle] = Pinter; |
|
} else { |
|
|
if(Pinter.size()!=0) { |
|
|
//ffout(4)<<"rajout2 \n"; |
|
|
pairTriangleToIntersectionPoints[pTriangle] = Pinter; |
|
|
} |
|
1203 |
} |
} |
1204 |
|
|
1205 |
if(pairTriangleToIntersectionPoints.find(pTriangle)!= pairTriangleToIntersectionPoints.end()) { |
if(pairTriangleToIntersectionPoints.find(pTriangle)!= pairTriangleToIntersectionPoints.end()) { |
1212 |
const Vertex& Vo1 = To(1); |
const Vertex& Vo1 = To(1); |
1213 |
const Vertex& Vo2 = To(2); |
const Vertex& Vo2 = To(2); |
1214 |
const Vertex& P=*(pairTriangleToIntersectionPoints[pTriangle][i]); |
const Vertex& P=*(pairTriangleToIntersectionPoints[pTriangle][i]); |
1215 |
|
|
1216 |
|
// TESTE SI LE POINT EST SUR UNE DES ARETES EN TESTANT TROIS "EGALITÉ" TRIANGULAIRE |
1217 |
|
|
1218 |
real_t Vo01=Norm(Vo1-Vo0); |
real_t Vo01=Norm(Vo1-Vo0); |
1219 |
real_t Vo12=Norm(Vo2-Vo1); |
real_t Vo12=Norm(Vo2-Vo1); |
1581 |
|
|
1582 |
int numberPointsInterior=pointsInterior.size(); |
int numberPointsInterior=pointsInterior.size(); |
1583 |
const size_t& numobject=K.numobject; |
const size_t& numobject=K.numobject; |
1584 |
MapCellTriangle hexaToTriangle1=*(O2.hexalist); |
const MapCellTriangle& hexaToTriangle1=*(O2.hexalist); |
1585 |
|
|
1586 |
MapCellTriangle::iterator it1=hexaToTriangle1.find(cell); |
MapCellTriangle::const_iterator it1=hexaToTriangle1.find(cell); |
1587 |
if(it1!=hexaToTriangle1.end()) { |
if(it1!=hexaToTriangle1.end()) { |
1588 |
std::list<Triangle*> listTriangle1=(*it1).second; |
std::list<Triangle*> listTriangle1=(*it1).second; |
1589 |
for(std::list<Triangle*>::iterator jt0=listTriangle1.begin() ; |
for(std::list<Triangle*>::iterator jt0=listTriangle1.begin() ; |
1734 |
size_t objectNumber=0; |
size_t objectNumber=0; |
1735 |
if(numobject==0) |
if(numobject==0) |
1736 |
objectNumber=1; |
objectNumber=1; |
1737 |
MapCellTriangle hexaToTriangle1=*(O2.hexalist); |
const MapCellTriangle& hexaToTriangle1=*(O2.hexalist); |
1738 |
|
|
1739 |
MapCellTriangle::iterator it1=hexaToTriangle1.find(cell); |
MapCellTriangle::const_iterator it1=hexaToTriangle1.find(cell); |
1740 |
|
|
1741 |
if(it1!=hexaToTriangle1.end()) { |
if(it1!=hexaToTriangle1.end()) { |
1742 |
std::list<Triangle*> listTriangle1=(*it1).second; |
std::list<Triangle*> listTriangle1=(*it1).second; |
1751 |
pairTriangle.second=(currentTriangle); |
pairTriangle.second=(currentTriangle); |
1752 |
pairTriangle.first=(*jt0); |
pairTriangle.first=(*jt0); |
1753 |
} |
} |
1754 |
if(pairTriangleToIntersectionPoints.find(pairTriangle)!= |
|
1755 |
pairTriangleToIntersectionPoints.end()) { |
std::map< PairTriangleNew , IntersectionPoints>::iterator i = pairTriangleToIntersectionPoints.find(pairTriangle); |
1756 |
|
if(i != pairTriangleToIntersectionPoints.end()) { |
1757 |
TinyVector<3,size_t> cutTriangle; |
TinyVector<3,size_t> cutTriangle; |
1758 |
if(numobject<objectNumber) { |
if(numobject<objectNumber) { |
1759 |
cutTriangle=(pairTriangleToIntersectionPoints[pairTriangle]).cutTriangle1(); |
cutTriangle=(*i).second.cutTriangle1(); |
1760 |
} else { |
} else { |
1761 |
cutTriangle=(pairTriangleToIntersectionPoints[pairTriangle]).cutTriangle2(); |
cutTriangle=(*i).second.cutTriangle2(); |
1762 |
} |
} |
1763 |
|
|
1764 |
for (size_t n=0; n<3; ++n) { |
for (size_t n=0; n<3; ++n) { |
1784 |
const std::set<const Cell*>& toTreatHexahedra) { |
const std::set<const Cell*>& toTreatHexahedra) { |
1785 |
//to put the reference by front |
//to put the reference by front |
1786 |
std::list<const Triangle*> front; |
std::list<const Triangle*> front; |
1787 |
|
int frontSize = 0; |
1788 |
|
|
1789 |
size_t objectNumber=0; |
size_t objectNumber=0; |
1790 |
if(numobject==0) |
if(numobject==0) |
1801 |
or (*edgesRefVertex[numobject])[&(*T)(1)]==2 |
or (*edgesRefVertex[numobject])[&(*T)(1)]==2 |
1802 |
or (*edgesRefVertex[numobject])[&(*T)(2)]==2)) { |
or (*edgesRefVertex[numobject])[&(*T)(2)]==2)) { |
1803 |
front.push_front(T); |
front.push_front(T); |
1804 |
|
frontSize++; |
1805 |
const Triangle*& TT=(*listOfTriangleMeshFront.find(T)).second; |
const Triangle*& TT=(*listOfTriangleMeshFront.find(T)).second; |
1806 |
// on traite le triangle du front |
// on traite le triangle du front |
1807 |
__putEdgeRef(T,TT,numobject,O1,O2); |
__putEdgeRef(T,TT,numobject,O1,O2); |
1810 |
} |
} |
1811 |
|
|
1812 |
size_t iter=0; |
size_t iter=0; |
1813 |
ffout(0)<<"taille initial du front ="<<front.size()<<"\n"; |
ffout(4)<<"taille initial du front ="<< frontSize <<"\n"; |
1814 |
//if(front.size()==0) |
//if(front.size()==0) |
1815 |
ffout(0)<<"ref de surfmesh = "<<surfmesh.cell(0).reference()<<"\n"; |
ffout(4)<<"ref de surfmesh = "<<surfmesh.cell(0).reference()<<"\n"; |
1816 |
//put reference by front |
//put reference by front |
1817 |
size_t erase=0; |
size_t erase=0; |
1818 |
while(front.size()!=0 and iter<nbcell) { |
while(frontSize !=0 and iter<nbcell) { |
1819 |
std::list<const Triangle*>::iterator er=front.begin() ; |
std::list<const Triangle*>::iterator er=front.begin() ; |
1820 |
for(std::list<const Triangle*>::iterator jt0=front.begin() ; |
for(std::list<const Triangle*>::iterator jt0=front.begin() ; |
1821 |
jt0!=front.end() ; ++jt0) { |
jt0!=front.end() ; ++jt0) { |
1822 |
if(jt0!=front.begin() and erase==1) |
if(jt0!=front.begin() and erase==1) { |
1823 |
er=front.erase(er); |
er=front.erase(er); |
1824 |
|
frontSize--; |
1825 |
|
} |
1826 |
er=jt0; |
er=jt0; |
1827 |
erase=0; |
erase=0; |
1828 |
const Triangle* T=*jt0; |
const Triangle* T=*jt0; |
1854 |
} else { |
} else { |
1855 |
erase=1; |
erase=1; |
1856 |
} |
} |
1857 |
TinyVector<3,const Triangle*> V=connect(surfmesh.cellNumber(*T)); |
const TinyVector<3,const Triangle*>& V=connect(surfmesh.cellNumber(*T)); |
1858 |
|
|
1859 |
for(size_t j=0 ; j<3 ; ++j) { |
for(size_t j=0 ; j<3 ; ++j) { |
1860 |
//check the neighbours exist |
//check the neighbours exist |
1881 |
size_t sum=edge0[0]+edge1[0]+edge2[0]; |
size_t sum=edge0[0]+edge1[0]+edge2[0]; |
1882 |
if((ref0==2 or ref1==2 or ref2==2) and |
if((ref0==2 or ref1==2 or ref2==2) and |
1883 |
(ref0!=1 and ref1!=1 and ref2!=1) and sum==0) { |
(ref0!=1 and ref1!=1 and ref2!=1) and sum==0) { |
1884 |
ffout(0)<<"ref 2 partout\n"; |
ffout(4)<<"ref 2 partout\n"; |
1885 |
test=1; |
test=1; |
1886 |
ref0=2; |
ref0=2; |
1887 |
ref1=2; |
ref1=2; |
1926 |
} |
} |
1927 |
if(test==1/*ref0+ref1+ref2==6 *//*or edge0[0]+edge1[0]+edge2[0]==1*/) { |
if(test==1/*ref0+ref1+ref2==6 *//*or edge0[0]+edge1[0]+edge2[0]==1*/) { |
1928 |
front.push_front(triangle); |
front.push_front(triangle); |
1929 |
|
frontSize++; |
1930 |
} |
} |
1931 |
//ffout(0)<<ref0<<" "<<ref1<<" "<<ref2<<"\n"; |
//ffout(0)<<ref0<<" "<<ref1<<" "<<ref2<<"\n"; |
1932 |
} |
} |
1933 |
} |
} |
1934 |
} |
} |
1935 |
} |
} |
1936 |
if(erase==1 and front.size()==1) |
if(erase==1 and frontSize==1) { |
1937 |
er=front.erase(er); |
er=front.erase(er); |
1938 |
|
frontSize--; |
1939 |
|
} |
1940 |
++iter; |
++iter; |
1941 |
ffout(0)<<"taille du front = "<<front.size()<<" "<<iter<<" "<<nbcell<<"\n"; |
ffout(0)<<"taille du front = "<<front.size()<<" "<<iter<<" "<<nbcell<<"\n"; |
1942 |
} |
} |
2388 |
{ |
{ |
2389 |
//build mesh of object O1 (which is intersected with O2) |
//build mesh of object O1 (which is intersected with O2) |
2390 |
|
|
2391 |
size_t nbcell=(*O1.trianglelist).size(); |
size_t nbcell=(*O1.trianglelist).size(); |
2392 |
SurfaceMeshOfTriangles surfmesh(nbcell); |
SurfaceMeshOfTriangles surfmesh(nbcell); |
2393 |
__constructionFinalMesh(O1,surfmesh); |
__constructionFinalMesh(O1,surfmesh); |
2394 |
Connectivity<Triangle> connect(nbcell); |
Connectivity<Triangle> connect(nbcell); |
2395 |
ConnectivityBuilder<SurfaceMeshOfTriangles> C(surfmesh,connect); |
ConnectivityBuilder<SurfaceMeshOfTriangles> C(surfmesh,connect); |
2396 |
//ffout(4)<<"numero "<<numobject<<" "<<objectNumber<<"\n"<<std::flush; |
//ffout(4)<<"numero "<<numobject<<" "<<objectNumber<<"\n"<<std::flush; |
2397 |
size_t objectNumber=0; |
size_t objectNumber=0; |
2398 |
if(numobject==0) |
if(numobject==0) |
2399 |
objectNumber=1; |
objectNumber=1; |
2400 |
// (*edgesRefVertex[numobject]).clear(); |
// (*edgesRefVertex[numobject]).clear(); |
2401 |
MapCellTriangle hexaToTriangle0=*(O1.hexalist); |
const MapCellTriangle& hexaToTriangle0=*(O1.hexalist); |
2402 |
|
|
2403 |
|
|
2404 |
std::set<const Cell*> hexaList1; |
std::set<const Cell*> hexaList1; |
2415 |
ffout(4)<<"taille hexalistIn "<<hexaListIn.size()<<"\n"; |
ffout(4)<<"taille hexalistIn "<<hexaListIn.size()<<"\n"; |
2416 |
for (std::set<const Cell*>::iterator icell = hexaListIn.begin(); icell != hexaListIn.end(); ++icell) { |
for (std::set<const Cell*>::iterator icell = hexaListIn.begin(); icell != hexaListIn.end(); ++icell) { |
2417 |
|
|
2418 |
MapCellTriangle::iterator it0=hexaToTriangle0.find(*icell); |
MapCellTriangle::const_iterator it0=hexaToTriangle0.find(*icell); |
2419 |
|
|
2420 |
if(it0!=hexaToTriangle0.end()) { |
if(it0!=hexaToTriangle0.end()) { |
2421 |
//ffout(4)<<"ici\n"; |
//ffout(4)<<"ici\n"; |
2455 |
} |
} |
2456 |
} |
} |
2457 |
|
|
2458 |
|
ffout(0) << "putRefByFront\n"; |
2459 |
//put the reference of points |
//put the reference of points |
2460 |
__putRefByFront(numobject,O1,O2,surfmesh,connect,toTreatHexahedra); |
__putRefByFront(numobject,O1,O2,surfmesh,connect,toTreatHexahedra); |
2461 |
|
ffout(0) << "putRefByFront Fait\n"; |
2462 |
|
|
2463 |
size_t nbinters=listVertexIntersectionNew.size(); |
size_t nbinters=listVertexIntersectionNew.size(); |
2464 |
ffout(4)<<"size listVertexIntersectionNew "<<nbinters<<"\n"<<std::flush; |
ffout(4)<<"size listVertexIntersectionNew "<<nbinters<<"\n"<<std::flush; |
2465 |
|
|
2466 |
for(std::set<const Cell*>::iterator i=toTreatHexahedra.begin(); |
for(std::set<const Cell*>::iterator i=toTreatHexahedra.begin(); |
2467 |
i!=toTreatHexahedra.end() ; ++i) { |
i!=toTreatHexahedra.end() ; ++i) { |
2468 |
MapCellTriangle::iterator it0=hexaToTriangle0.find(*i); |
MapCellTriangle::const_iterator it0=hexaToTriangle0.find(*i); |
2469 |
|
|
2470 |
if(it0!=hexaToTriangle0.end()) { |
if(it0!=hexaToTriangle0.end()) { |
2471 |
std::list<Triangle*> listTriangle0=(*it0).second; |
std::list<Triangle*> listTriangle0=(*it0).second; |
3359 |
ObjectToTreat& O, |
ObjectToTreat& O, |
3360 |
size_t nobject) |
size_t nobject) |
3361 |
{ |
{ |
3362 |
|
ffout(3) << "Marching cube ..." << std::flush; |
3363 |
EdgePairList triangleListes; |
EdgePairList triangleListes; |
3364 |
EdgePairList localTriangleListesEdges; |
EdgePairList localTriangleListesEdges; |
3365 |
VerticesList verticesListes; |
VerticesList verticesListes; |
3372 |
verticesListes, edgesRef, cellListObject); |
verticesListes, edgesRef, cellListObject); |
3373 |
|
|
3374 |
__dataStructureConvertion(O, triangleListes, verticesListes, cellListObject); |
__dataStructureConvertion(O, triangleListes, verticesListes, cellListObject); |
3375 |
|
ffout(3) << " done\n"; |
3376 |
return 0; |
return 0; |
3377 |
} |
} |
3378 |
|
|