84 |
|
|
85 |
typedef std::map<Edge::Pair, Vertex*> VerticesList; |
typedef std::map<Edge::Pair, Vertex*> VerticesList; |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
//! list of cut edges and intersection vertex. |
//! list of cut edges and intersection vertex. |
90 |
std::map<Edge::Pair, size_t> edgesRef; |
std::map<Edge::Pair, size_t> edgesRef; |
91 |
|
std::vector<ReferenceCounting<EdgePairList> > triangleListes; |
|
std::vector<ReferenceCounting<EdgePairList> > triangleListes; |
|
92 |
|
|
93 |
EdgePairList localTriangleList; |
EdgePairList localTriangleList; |
94 |
|
|
96 |
std::list<TinyVector<3> > InsideVertexList; |
std::list<TinyVector<3> > InsideVertexList; |
97 |
|
|
98 |
//! list of cut edges and intersection vertex. |
//! list of cut edges and intersection vertex. |
99 |
std::vector<ReferenceCounting<VerticesList> > verticesListes; |
//VerticesList verticesList; |
100 |
|
std::vector<ReferenceCounting<VerticesList> > verticesListes; |
101 |
|
|
102 |
HexaTetraAssociation hexaTetraAssociation; |
HexaTetraAssociation hexaTetraAssociation; |
103 |
|
|
192 |
__createTriangles(const Shape& S, |
__createTriangles(const Shape& S, |
193 |
const Reference::Representation& ref,const int objectNumber) |
const Reference::Representation& ref,const int objectNumber) |
194 |
{ |
{ |
195 |
|
|
196 |
for(SurfaceMeshGenerator::Internals::HexaTetraAssociation::iterator i |
for(SurfaceMeshGenerator::Internals::HexaTetraAssociation::iterator i |
197 |
= hexaTetraAssociation.begin(); |
= hexaTetraAssociation.begin(); |
198 |
i != hexaTetraAssociation.end(); ++i) { |
i != hexaTetraAssociation.end(); ++i) { |
237 |
|
|
238 |
//! Stores the Edges on which the vertex will be computed. |
//! Stores the Edges on which the vertex will be computed. |
239 |
for (size_t i=0; i<cutEdges.size(); ++i) |
for (size_t i=0; i<cutEdges.size(); ++i) |
240 |
(*verticesListes[objectNumber])[*cutEdges[i]] = new Vertex(Internals::__splitEdge(*cutEdges[i], ref, S)); |
// verticesList[*cutEdges[i]] = new Vertex(Internals::__splitEdge(*cutEdges[i], ref, S)); |
241 |
|
(*verticesListes[objectNumber])[*cutEdges[i]] = new Vertex(Internals::__splitEdge(*cutEdges[i], ref, S)); |
242 |
|
|
243 |
break; |
break; |
244 |
} |
} |
245 |
case 4: { |
case 4: { |
281 |
} |
} |
282 |
|
|
283 |
for (size_t i=0; i<4; ++i) { |
for (size_t i=0; i<4; ++i) { |
284 |
(*verticesListes[objectNumber])[*cutEdges[i]] = new Vertex(__splitEdge(*cutEdges[i], ref, S)); |
// verticesList[*cutEdges[i]] = new Vertex(__splitEdge(*cutEdges[i], ref, S)); |
285 |
|
(*verticesListes[objectNumber])[*cutEdges[i]] = new Vertex(__splitEdge(*cutEdges[i], ref, S)); |
286 |
|
|
287 |
} |
} |
288 |
|
|
289 |
//! Addes a triangle to the list. |
//! Addes a triangle to the list. |
318 |
t != localTriangleList.end(); ++t) { |
t != localTriangleList.end(); ++t) { |
319 |
(*triangleListes[objectNumber]).push_front(*t); |
(*triangleListes[objectNumber]).push_front(*t); |
320 |
} |
} |
|
|
|
321 |
localTriangleList.clear(); |
localTriangleList.clear(); |
322 |
} |
} |
323 |
} |
} |
540 |
void plot2(const SurfaceMeshOfTriangles& s, |
void plot2(const SurfaceMeshOfTriangles& s, |
541 |
std::set<const Cell*>& hlist, |
std::set<const Cell*>& hlist, |
542 |
Structured3DMesh& SMesh); |
Structured3DMesh& SMesh); |
|
void plotmedit(const SurfaceMeshOfTriangles& s_mesh,std::set<const Cell*>& toTreatHexahedra,size_t nobj,size_t nobjother); |
|
|
void Bary(Vertex& P,TinyVector<3>& P0,TinyVector<3>& V12,TinyVector<3>& V02,size_t& ncompt); |
|
543 |
|
|
544 |
|
void plotmedit(const SurfaceMeshOfTriangles& s_mesh, |
545 |
|
std::set<const Cell*>& toTreatHexahedra,size_t nobj); |
546 |
|
void Bary(const Vertex& P,TinyVector<3>& P0,TinyVector<3>& V12,TinyVector<3>& V02,size_t& ncompt); |
547 |
|
|
548 |
|
|
549 |
/*! Generates a surfacic mesh using only characteristic function of an object |
/*! Generates a surfacic mesh using only characteristic function of an object |
594 |
|
|
595 |
otherReferences.erase(O.reference()); |
otherReferences.erase(O.reference()); |
596 |
size_t nobject = scene.nbObjects(); |
size_t nobject = scene.nbObjects(); |
|
std::cout<<"nb object "<<nobject<<"\n"; |
|
|
(*__internals).verticesListes.resize(nobject+1); |
|
|
(*__internals).triangleListes.resize(nobject+1); |
|
597 |
|
|
598 |
for(int no=0 ; no<nobject+1 ; ++no) |
(*__internals).verticesListes.resize(nobject); |
599 |
|
(*__internals).triangleListes.resize(nobject); |
600 |
|
|
601 |
|
|
602 |
|
for(int no=0 ; no<nobject ; ++no) |
603 |
{ |
{ |
604 |
(*__internals).triangleListes[no]= new SurfaceMeshGenerator::Internals::EdgePairList; |
(*__internals).triangleListes[no]= new SurfaceMeshGenerator::Internals::EdgePairList; |
605 |
(*__internals).verticesListes[no]= new SurfaceMeshGenerator::Internals::VerticesList; |
(*__internals).verticesListes[no]= new SurfaceMeshGenerator::Internals::VerticesList; |
606 |
} |
|
607 |
|
|
608 |
|
} |
609 |
|
|
|
|
|
610 |
for (size_t i = 0; i<SMesh.nbEdges(); i++) { |
for (size_t i = 0; i<SMesh.nbEdges(); i++) { |
611 |
Edge& e = SMesh.edge(i); |
Edge& e = SMesh.edge(i); |
612 |
#warning THIS TEST IS NOT ENOUGH! THINK TO THE BORDER! |
#warning THIS TEST IS NOT ENOUGH! THINK TO THE BORDER! |
614 |
and ((e(0).Ref().isSet(ref)) xor (e(1).Ref().isSet(ref)))) |
and ((e(0).Ref().isSet(ref)) xor (e(1).Ref().isSet(ref)))) |
615 |
{ |
{ |
616 |
(*(*__internals).verticesListes[0])[e] = new Vertex((*__internals).__splitEdge(e, ref, S)); |
(*(*__internals).verticesListes[0])[e] = new Vertex((*__internals).__splitEdge(e, ref, S)); |
617 |
|
//(*__internals).verticesList[e] = new Vertex((*__internals).__splitEdge(e, ref, S)); |
618 |
(*__internals).edgesRef[e] = 1; |
(*__internals).edgesRef[e] = 1; |
619 |
} |
} |
620 |
} |
} |
625 |
/// a triangulation has been generated inside the hexahedron |
/// a triangulation has been generated inside the hexahedron |
626 |
std::set<const Cell*> meshedHexahedra; |
std::set<const Cell*> meshedHexahedra; |
627 |
|
|
628 |
if ((*(*__internals).verticesListes[0]).size()==0) { |
// if ((*__internals).verticesList.size()==0) { |
629 |
fferr(2) << __FILE__ << ':' << __LINE__ << ": " |
if ((*(*__internals).verticesListes[0]).size()==0) { |
630 |
|
|
631 |
|
fferr(2) << __FILE__ << ':' << __LINE__ << ": " |
632 |
<< "meshing object " << S << " a problem occured ...\n" |
<< "meshing object " << S << " a problem occured ...\n" |
633 |
<< "Check that:\n" |
<< "Check that:\n" |
634 |
<< "- the object is not to small compare to the background mesh\n" |
<< "- the object is not to small compare to the background mesh\n" |
670 |
|
|
671 |
for (size_t l=0; l<H.numberOfEdges(); l++) { |
for (size_t l=0; l<H.numberOfEdges(); l++) { |
672 |
Edge& e = H.edge(l); |
Edge& e = H.edge(l); |
673 |
if ((*(*__internals).verticesListes[0]).count(e) > 0) { |
// if ((*__internals).verticesList.count(e) > 0) { |
674 |
|
if ((*(*__internals).verticesListes[0]).count(e) > 0) { |
675 |
intersected = true; |
intersected = true; |
676 |
cuttedHexahedra.insert(¤tCell); |
cuttedHexahedra.insert(¤tCell); |
677 |
break; |
break; |
840 |
|
|
841 |
//! Stores the Edges on which the vertex will be computed. |
//! Stores the Edges on which the vertex will be computed. |
842 |
for (size_t i=0; i<cutEdges.size(); ++i) { |
for (size_t i=0; i<cutEdges.size(); ++i) { |
843 |
(*(*__internals).verticesListes[0])[*cutEdges[i]] |
//(*__internals).verticesList[*cutEdges[i]] |
844 |
|
(*(*__internals).verticesListes[0])[*cutEdges[i]] |
845 |
= new Vertex((*__internals).__splitEdge(*cutEdges[i], ref, S)); |
= new Vertex((*__internals).__splitEdge(*cutEdges[i], ref, S)); |
846 |
(*__internals).edgesRef[*cutEdges[i]] = 1; |
(*__internals).edgesRef[*cutEdges[i]] = 1; |
847 |
} |
} |
887 |
} |
} |
888 |
|
|
889 |
for (size_t i=0; i<4; ++i) { |
for (size_t i=0; i<4; ++i) { |
890 |
(*(*__internals).verticesListes[0])[*cutEdges[i]] |
//(*__internals).verticesList[*cutEdges[i]] |
891 |
|
(*(*__internals).verticesListes[0])[*cutEdges[i]] |
892 |
= new Vertex((*__internals).__splitEdge(*cutEdges[i], ref, S)); |
= new Vertex((*__internals).__splitEdge(*cutEdges[i], ref, S)); |
893 |
(*__internals).edgesRef[*cutEdges[i]] = 1; |
(*__internals).edgesRef[*cutEdges[i]] = 1; |
894 |
} |
} |
926 |
for (SurfaceMeshGenerator::Internals::EdgePairList::iterator t |
for (SurfaceMeshGenerator::Internals::EdgePairList::iterator t |
927 |
= (*__internals).localTriangleList.begin(); |
= (*__internals).localTriangleList.begin(); |
928 |
t != (*__internals).localTriangleList.end(); ++t) { |
t != (*__internals).localTriangleList.end(); ++t) { |
929 |
(*(*__internals).triangleListes[0]).push_front(*t); |
(*(*__internals).triangleListes[0]).push_front(*t); |
930 |
} |
} |
931 |
} else { |
} else { |
932 |
(*__internals).hexaTetraAssociation[¤tCell] |
(*__internals).hexaTetraAssociation[¤tCell] |
939 |
} |
} |
940 |
} |
} |
941 |
|
|
942 |
// (*(*__internals).triangleListes[0]).clear(); |
//(*(*__internals).triangleListes[0]).clear(); |
943 |
// (*(*__internals).verticesListes[0]).clear(); |
//(*(*__internals).verticesListes[0]).clear(); |
944 |
|
|
945 |
|
// (*__internals).verticesList.clear(); |
946 |
|
|
947 |
|
|
948 |
|
// (*__internals).__createTriangles(S,ref,0); |
949 |
|
|
950 |
// (*__internals).__createTriangles(S, ref,0); |
//size_t nobj= (*(*__internals).triangleListes[0]).size(); |
|
|
|
|
// size_t nobj= (*(*__internals).triangleListes[0]).size(); |
|
951 |
//std::cout<<"nb tr objet1 "<<nobj<<" \n"; |
//std::cout<<"nb tr objet1 "<<nobj<<" \n"; |
|
//std::cout<<(*(*__internals).verticesListes[0]).size()<<"\n"; |
|
952 |
|
|
953 |
// size_t num=0; |
//int num=0; |
954 |
// for(ObjectReferences::iterator i = otherReferences.begin(); |
// for(ObjectReferences::iterator i = otherReferences.begin(); |
955 |
// i != otherReferences.end(); ++i) { |
// i != otherReferences.end(); ++i) { |
956 |
// num+=1; |
// num++; |
957 |
// for(size_t n = 0; n<scene.nbObjects(); ++n) { |
// for(size_t n = 0; n<scene.nbObjects(); ++n) { |
958 |
// Reference::Representation otherRef; |
// Reference::Representation otherRef; |
959 |
// otherRef.resize(scene.nbObjects()); |
// otherRef.resize(scene.nbObjects()); |
960 |
// |
// |
961 |
// if (scene.object(n).reference() == ((*i).first)) { |
// if (scene.object(n).reference() == ((*i).first)) { |
962 |
// otherRef[n] = true; |
// otherRef[n] = true; |
963 |
// (*__internals).__createTriangles(*(scene.object(n).shape()), |
// (*__internals).__createTriangles(*(scene.object(n).shape()), |
964 |
// otherRef,num); |
// otherRef,num); |
965 |
// } |
// } |
966 |
// } |
// } |
967 |
// } |
// } |
968 |
|
//size_t nobjother=(*(*__internals).triangleListes[1]).size(); |
|
// size_t nobjother=(*(*__internals).triangleListes[1]).size(); |
|
969 |
//std::cout<<"nb tr objet2 "<<nobjother<<" \n"; |
//std::cout<<"nb tr objet2 "<<nobjother<<" \n"; |
970 |
//std::cout<<(*(*__internals).verticesListes[1]).size()<<"\n"; |
size_t ntr=0; |
971 |
|
for(size_t n = 0; n<scene.nbObjects(); ++n) |
972 |
|
ntr+=(*(*__internals).verticesListes[n]).size(); |
973 |
|
|
974 |
|
s_mesh.setNumberOfVertices(ntr); |
975 |
|
|
976 |
// std::set<const Cell*> toTreatHexahedra; |
// s_mesh.setNumberOfVertices((*__internals).verticesList.size()); |
|
// std::set_difference (cuttedHexahedra.begin(), cuttedHexahedra.end(), |
|
|
// meshedHexahedra.begin(), meshedHexahedra.end(), |
|
|
// inserter(toTreatHexahedra, toTreatHexahedra.begin())); |
|
977 |
|
|
978 |
//******************************************************************************* |
//std::cout<<"nb tot "<<s_mesh.numberOfVertices()<<"\n"; |
|
/* std::vector<Vertex*> vertexintersectionList; |
|
|
std::list<int> numberOfIntersectionPerTriangle; |
|
|
|
|
|
for(SurfaceMeshGenerator::Internals::EdgePairList::iterator currentTriangle |
|
|
= (*(*__internals).triangleListes[0]).begin(); |
|
|
currentTriangle != (*(*__internals).triangleListes[0]).end(); |
|
|
++currentTriangle) |
|
|
{ |
|
|
size_t numInter=0; |
|
|
Vertex& V0 = *((*(*__internals).verticesListes[0])[(*currentTriangle)[0]]); |
|
|
Vertex& V1 = *((*(*__internals).verticesListes[0])[(*currentTriangle)[1]]); |
|
|
Vertex& V2 = *((*(*__internals).verticesListes[0])[(*currentTriangle)[2]]); |
|
|
|
|
|
//equation of the plan |
|
|
TinyVector<3> V01,V12,V02; |
|
|
V01=V1.Vector3()-V0.Vector3(); |
|
|
V12=V2.Vector3()-V1.Vector3(); |
|
|
V02=V2.Vector3()-V0.Vector3(); |
|
|
TinyVector<3> coeff; |
|
|
coeff=V01^V02; |
|
|
|
|
|
real_t d=-(coeff[0]*V0[0]+coeff[1]*V0[1]+coeff[2]*V0[2]); |
|
|
// std::cout<<"--------------------------------------------------------------\n"; |
|
|
for(SurfaceMeshGenerator::Internals::EdgePairList::iterator currentTriangle |
|
|
= (*(*__internals).triangleListes[1]).begin(); |
|
|
currentTriangle != (*(*__internals).triangleListes[1]).end(); |
|
|
++currentTriangle) |
|
|
{ |
|
|
// std::cout<<"*************************\n"; |
|
|
Vertex& Vo0 = *((*(*__internals).verticesListes[1])[(*currentTriangle)[0]]); |
|
|
Vertex& Vo1 = *((*(*__internals).verticesListes[1])[(*currentTriangle)[1]]); |
|
|
Vertex& Vo2 = *((*(*__internals).verticesListes[1])[(*currentTriangle)[2]]); |
|
|
|
|
|
|
|
|
real_t pscalar,k; |
|
|
size_t num; |
|
|
{ |
|
|
Vertex P; |
|
|
TinyVector<3> Vo01; |
|
|
Vo01=Vo1.Vector3()-Vo0.Vector3(); |
|
|
pscalar=coeff*Vo01; |
|
|
if(pscalar>1e-8) |
|
|
{ |
|
|
k=-(coeff[0]*Vo0[0]+coeff[1]*Vo0[1]+coeff[2]*Vo0[2]+d)/pscalar; |
|
|
P=Vo0+k*Vo01; |
|
|
TinyVector<3> P0=P.Vector3()-V2.Vector3(); |
|
|
//std::cout<<"verif "<<coeff[0]*P.Vector3()[0]+coeff[1]*P.Vector3()[1]+coeff[2]*P.Vector3()[2]+d<<"\n"; |
|
|
Bary(P,P0,V12,V02,num); |
|
|
if(num==3) |
|
|
{ |
|
|
std::cout<<P.Vector3()[0]<<" "<<P.Vector3()[1]<<" "<<P.Vector3()[2]<<" 3 point intersection \n"; |
|
|
vertexintersectionList.push_back(&P); |
|
|
|
|
|
numInter+=1; |
|
|
} |
|
|
} |
|
|
} |
|
|
{ |
|
|
Vertex P; |
|
|
TinyVector<3> Vo02; |
|
|
Vo02=Vo2.Vector3()-Vo0.Vector3(); |
|
|
pscalar=coeff*Vo02; |
|
|
|
|
|
if(pscalar>1e-8) |
|
|
{ |
|
|
k=-(coeff[0]*Vo0[0]+coeff[1]*Vo0[1]+coeff[2]*Vo0[2]+d)/pscalar; |
|
|
P=Vo0+k*Vo02; |
|
|
TinyVector<3> P0=P.Vector3()-V2.Vector3(); |
|
|
Bary(P,P0,V12,V02,num); |
|
|
if(num==3) |
|
|
{std::cout<<P.Vector3()[0]<<" "<<P.Vector3()[1]<<" "<<P.Vector3()[2]<<" 3 point intersection \n"; |
|
|
vertexintersectionList.push_back(&P); |
|
|
numInter+=1; |
|
|
} |
|
|
} |
|
|
} |
|
|
{ |
|
|
Vertex P; |
|
|
TinyVector<3> Vo12; |
|
|
Vo12=Vo2.Vector3()-Vo1.Vector3(); |
|
|
pscalar=coeff*Vo12; |
|
|
if(pscalar>1e-8) |
|
|
{ |
|
|
k=-(coeff[0]*Vo1[0]+coeff[1]*Vo1[1]+coeff[2]*Vo1[2]+d)/pscalar; |
|
|
Vertex P; |
|
|
P=Vo1+k*Vo12; |
|
|
TinyVector<3> P0=P.Vector3()-V2.Vector3(); |
|
|
Bary(P,P0,V12,V02,num); |
|
|
if(num==3) |
|
|
{std::cout<<P.Vector3()[0]<<" "<<P.Vector3()[1]<<" "<<P.Vector3()[2]<<" 3 point intersection \n"; |
|
|
vertexintersectionList.push_back(&P); |
|
|
numInter+=1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
numberOfIntersectionPerTriangle.push_back(numInter); |
|
|
//std::cout<<"nb inter "<<numInter<<"\n"; |
|
|
} |
|
|
// create triangles |
|
|
int mark = 0; |
|
|
std::list<int>::iterator nbInter=numberOfIntersectionPerTriangle.begin(); |
|
|
size_t nbVertexInter=vertexintersectionList.size(); |
|
|
std::vector<Vertex*> vertexplot; |
|
|
|
|
|
for(SurfaceMeshGenerator::Internals::EdgePairList::const_iterator currentTriangle |
|
|
= (*(*__internals).triangleListes[0]).begin(); |
|
|
currentTriangle != (*(*__internals).triangleListes[0]).end(); |
|
|
++currentTriangle) |
|
|
{ |
|
|
//if the triangle is intersected |
|
|
if(*nbInter!=0) |
|
|
{ |
|
|
Vertex& V0 = *((*(*__internals).verticesListes[0])[(*currentTriangle)[0]]); |
|
|
Vertex& V1 = *((*(*__internals).verticesListes[0])[(*currentTriangle)[1]]); |
|
|
Vertex& V2 = *((*(*__internals).verticesListes[0])[(*currentTriangle)[2]]); |
|
|
if(V0.Ref().insideDomain() or V1.Ref().insideDomain() or V2.Ref().insideDomain()) |
|
|
{ |
|
|
Vertex& A=V0; |
|
|
if(V1.Ref().insideDomain()) |
|
|
A=V1; |
|
|
else |
|
|
if(V2.Ref().insideDomain()) |
|
|
A=V2; |
|
|
for(int k=0 ; k<*nbInter ; ++k) |
|
|
{ |
|
|
Vertex& B=(*(vertexintersectionList[k+mark])); |
|
|
Vertex& C=(*(vertexintersectionList[k+1+mark])); |
|
|
if(k==*nbInter-1 and k+mark==nbVertexInter) |
|
|
C=(*(vertexintersectionList[0])); |
|
|
// Edge e0=Edge(A,B),e1=Edge(A,C),e2=Edge(B,C); |
|
|
// (*(*__internals).triangleListes[2]).push_front(TinyVector<3,Edge::Pair>()); |
|
|
// SurfaceMeshGenerator::Internals::EdgePairList::iterator current |
|
|
// = (*(*__internals).triangleListes[2]).begin(); |
|
|
// (*current)[0]=(Edge::Pair)(e0); |
|
|
//(*current)[1]=(Edge::Pair)(e1); |
|
|
//(*current)[2]=(Edge::Pair)(e2); |
|
|
//(*(*__internals).verticesListes[2])[e0]=new Vertex(e0(0)); |
|
|
//(*(*__internals).verticesListes[2])[e1]=new Vertex(e1(0)); |
|
|
//(*(*__internals).verticesListes[2])[e2]=new Vertex(e2(0)); |
|
|
vertexplot.push_back(&A); |
|
|
vertexplot.push_back(&B); |
|
|
vertexplot.push_back(&C); |
|
|
//std::cout<<"1 "<<C.Vector3()[0]<<" "<<C.Vector3()[1]<<" "<<C.Vector3()[2]<<"\n"; |
|
|
|
|
|
} |
|
|
} |
|
979 |
|
|
980 |
else |
//! copies vertices into the s_mesh. |
981 |
{ |
int i = 0; |
982 |
Vertex& A=V0; |
// for(SurfaceMeshGenerator::Internals::VerticesList::iterator splitVertex |
983 |
Vertex& B=V1; |
// = (*__internals).verticesList.begin(); |
984 |
if(!(V1.Ref().insideDomain())) |
// splitVertex != (*__internals).verticesList.end(); ++splitVertex) { |
985 |
B=V2; |
// |
986 |
else |
// s_mesh.vertex(i) = (*(*splitVertex).second); |
987 |
if(!(V0.Ref().insideDomain())) |
//delete (*splitVertex).second; |
988 |
A=V2; |
//(*splitVertex).second = &s_mesh.vertex(i); |
989 |
for(int k=0 ; k<*nbInter ; ++k) |
//i++; |
990 |
{ |
//} |
991 |
Vertex& C=(*(vertexintersectionList[k+mark])); |
for(size_t n = 0; n<scene.nbObjects(); ++n) |
992 |
//Edge e0=Edge(A,B),e1=Edge(A,C),e2=Edge(B,C); |
{ |
993 |
//(*(*__internals).triangleListes[2]).push_front(TinyVector<3,Edge::Pair>()); |
for(SurfaceMeshGenerator::Internals::VerticesList::iterator splitVertex |
994 |
//SurfaceMeshGenerator::Internals::EdgePairList::iterator current |
= (*(*__internals).verticesListes[n]).begin(); |
995 |
//= (*(*__internals).triangleListes[2]).begin(); |
splitVertex != (*(*__internals).verticesListes[n]).end(); ++splitVertex) |
996 |
//(*current)[0]=(Edge::Pair)(e0); |
{ |
997 |
//(*current)[1]=(Edge::Pair)(e1); |
s_mesh.vertex(i) = (*(*splitVertex).second); |
998 |
//(*current)[2]=(Edge::Pair)(e2); |
delete (*splitVertex).second; |
999 |
//(*(*__internals).verticesListes[2])[e0]=new Vertex(e0(0)); |
(*splitVertex).second = &s_mesh.vertex(i); |
1000 |
//(*(*__internals).verticesListes[2])[e1]=new Vertex(e1(0)); |
i++; |
1001 |
//(*(*__internals).verticesListes[2])[e2]=new Vertex(e2(0)); |
} |
1002 |
vertexplot.push_back(&A); |
} |
|
vertexplot.push_back(&B); |
|
|
vertexplot.push_back(&C); |
|
|
//std::cout<<"2 "<<k<<" "<<mark<<" "<<C.Vector3()[0]<<" "<<C.Vector3()[1]<<" "<<C.Vector3()[2]<<"\n"; |
|
1003 |
|
|
|
} |
|
|
} |
|
|
} |
|
|
mark+=*nbInter; |
|
|
++nbInter; |
|
|
|
|
|
} |
|
1004 |
|
|
|
std::cout<<(*(*__internals).verticesListes[2]).size()<<"\n"; |
|
|
std::cout<<(*(*__internals).triangleListes[2]).size()<<"\n"; |
|
|
std::cout<<(*(*__internals).verticesListes[0]).size()<<"\n"; |
|
|
std::cout<<(*(*__internals).triangleListes[0]).size()<<"\n"; |
|
|
*/ |
|
|
size_t ntr=0; |
|
|
for(size_t n = 0; n<scene.nbObjects()+1; ++n) |
|
|
ntr+=(*(*__internals).verticesListes[n]).size(); |
|
1005 |
|
|
1006 |
s_mesh.setNumberOfVertices(ntr); |
// std::set<const Cell*> toTreatHexahedra; |
1007 |
|
// std::set_difference (cuttedHexahedra.begin(), cuttedHexahedra.end(), |
1008 |
//! copies vertices into the s_mesh. |
// meshedHexahedra.begin(), meshedHexahedra.end(), |
1009 |
int i = 0; |
// inserter(toTreatHexahedra, toTreatHexahedra.begin())); |
|
for(size_t n = 0; n<scene.nbObjects()+1; ++n) |
|
|
{ |
|
|
for(SurfaceMeshGenerator::Internals::VerticesList::iterator splitVertex |
|
|
= (*(*__internals).verticesListes[n]).begin(); |
|
|
splitVertex != (*(*__internals).verticesListes[n]).end(); ++splitVertex) |
|
|
{ |
|
|
s_mesh.vertex(i) = (*(*splitVertex).second); |
|
|
delete (*splitVertex).second; |
|
|
(*splitVertex).second = &s_mesh.vertex(i); |
|
|
i++; |
|
|
} |
|
|
} |
|
|
|
|
1010 |
|
|
1011 |
i = 0; |
i = 0; |
1012 |
size_t ncell=0; |
size_t ncell=0; |
|
for(size_t n = 0; n<scene.nbObjects()+1; ++n) |
|
|
ncell+=(*(*__internals).triangleListes[n]).size(); |
|
1013 |
|
|
1014 |
s_mesh.setNumberOfCells(ncell); |
for(size_t n = 0; n<scene.nbObjects(); ++n) |
1015 |
|
ncell+=(*(*__internals).triangleListes[n]).size(); |
1016 |
SurfaceMeshGenerator::Internals::MotherCellList::iterator motherCell |
|
1017 |
= (*__internals).cellList.begin(); |
s_mesh.setNumberOfCells(ncell); |
1018 |
|
//std::cout<<"nb tot "<<s_mesh.numberOfCells()<<" \n"; |
1019 |
|
|
|
for(size_t n = 0; n<scene.nbObjects()+1; ++n) |
|
|
{ |
|
|
for(SurfaceMeshGenerator::Internals::EdgePairList::iterator currentTriangle |
|
|
= (*(*__internals).triangleListes[n]).begin(); |
|
|
currentTriangle != (*(*__internals).triangleListes[n]).end(); |
|
|
++currentTriangle) |
|
|
{ |
|
|
Vertex& V0 = *((*(*__internals).verticesListes[n])[(*currentTriangle)[0]]); |
|
|
Vertex& V1 = *((*(*__internals).verticesListes[n])[(*currentTriangle)[1]]); |
|
|
Vertex& V2 = *((*(*__internals).verticesListes[n])[(*currentTriangle)[2]]); |
|
1020 |
|
|
1021 |
s_mesh.cell(i) = Triangle(V0,V1,V2); |
SurfaceMeshGenerator::Internals::MotherCellList::iterator motherCell |
1022 |
|
= (*__internals).cellList.begin(); |
1023 |
|
|
1024 |
|
|
1025 |
|
for(size_t n = 0; n<scene.nbObjects(); ++n) |
1026 |
|
{ |
1027 |
|
|
1028 |
|
for(SurfaceMeshGenerator::Internals::EdgePairList::iterator currentTriangle |
1029 |
|
= (*(*__internals).triangleListes[n]).begin(); |
1030 |
|
currentTriangle != (*(*__internals).triangleListes[n]).end(); |
1031 |
|
++currentTriangle) |
1032 |
|
{ |
1033 |
|
//Vertex& V0 = *((*__internals).verticesList[(*currentTriangle)[0]]); |
1034 |
|
//Vertex& V1 = *((*__internals).verticesList[(*currentTriangle)[1]]); |
1035 |
|
//Vertex& V2 = *((*__internals).verticesList[(*currentTriangle)[2]]); |
1036 |
|
Vertex& V0 = *((*(*__internals).verticesListes[n])[(*currentTriangle)[0]]); |
1037 |
|
Vertex& V1 = *((*(*__internals).verticesListes[n])[(*currentTriangle)[1]]); |
1038 |
|
Vertex& V2 = *((*(*__internals).verticesListes[n])[(*currentTriangle)[2]]); |
1039 |
|
|
1040 |
|
s_mesh.cell(i) = Triangle(V0,V1,V2); |
1041 |
#warning SHOULD USE BC NUMBER (ie OBJECT NUMBER IN SCENE INSTEAD) |
#warning SHOULD USE BC NUMBER (ie OBJECT NUMBER IN SCENE INSTEAD) |
|
s_mesh.cell(i).reference() = 1; |
|
|
s_mesh.cell(i).setMother(*motherCell); |
|
|
i++; |
|
|
motherCell++; |
|
|
} |
|
|
} |
|
|
/*std::cout<<nobjother<<" plot medit\n"; |
|
1042 |
|
|
1043 |
{ |
s_mesh.cell(i).reference() = 1; |
1044 |
std::ofstream sortie("plot.mesh"); |
s_mesh.cell(i).setMother(*motherCell); |
1045 |
|
|
1046 |
sortie<<"MeshVersionFormatted 1"<<" \n"; |
i++; |
1047 |
sortie<<" \n"; |
motherCell++; |
1048 |
sortie<<"Dimension"<<" \n"; |
} |
1049 |
sortie<<"3"<<" \n"; |
} |
|
sortie<<" \n"; |
|
|
sortie<<"Vertices"<<" \n"; |
|
|
sortie<<vertexplot.size()<<"\n"; |
|
|
for(int i=0;i<vertexplot.size();++i) |
|
|
{ |
|
|
sortie<<(*vertexplot[i]).Vector3()[0]<<" "<<(*vertexplot[i]).Vector3()[1]<<" "<<(*vertexplot[i]).Vector3()[2]<<" 0"<<" \n"; |
|
|
} |
|
1050 |
|
|
1051 |
sortie<<" \n"; |
// plot2(s_mesh, toTreatHexahedra, SMesh); |
1052 |
sortie<<"Triangles"<<"\n"; |
// plotmedit(s_mesh, toTreatHexahedra,nobj); |
|
sortie<<vertexplot.size()/3<<"\n"; |
|
1053 |
|
|
|
for (size_t i=0; i<vertexplot.size()/3; ++i) |
|
|
{ |
|
|
sortie<<3*i+1<<" "<<3*i+2<<" "<<3*i+3<<" "<<1<<"\n"; |
|
|
} |
|
|
sortie<<" \n"; |
|
|
sortie<<"End"<<"\n"; |
|
|
}*/ |
|
|
|
|
|
// plotmedit(s_mesh,toTreatHexahedra,nobj,nobjother); |
|
|
// plot2(s_mesh, toTreatHexahedra, SMesh); |
|
1054 |
} |
} |
1055 |
|
|
1056 |
|
|
1067 |
} |
} |
1068 |
|
|
1069 |
|
|
1070 |
void Bary(Vertex& P,TinyVector<3>& P0,TinyVector<3>& V12,TinyVector<3>& V02,size_t& compt) |
void plotmedit(const SurfaceMeshOfTriangles& s_mesh,std::set<const Cell*>& toTreatHexahedra,size_t nobj) |
|
{ |
|
|
TinyMatrix<2,2> mat; |
|
|
real_t det=V02[0]*V12[1]-V02[1]*V12[0]; |
|
|
compt=0; |
|
|
real_t eps=-1e-10; |
|
|
if(det!=0.) |
|
|
{ |
|
|
det=1./det; |
|
|
mat(0,0)=-det*V12[1]; |
|
|
mat(1,0)=det*V02[1]; |
|
|
mat(1,1)=-det*V02[0]; |
|
|
mat(0,1)=det*V12[0]; |
|
|
TinyVector<2> bary,secondmb; |
|
|
secondmb[0]=P0[0]; |
|
|
secondmb[1]=P0[1]; |
|
|
bary=mat*secondmb; |
|
|
if(bary[0]>=eps && bary[1]>=eps && (1.-bary[0]-bary[1])>=eps) |
|
|
compt+=1; |
|
|
} |
|
|
else |
|
|
compt+=1; |
|
|
{ |
|
|
det=V02[1]*V12[2]-V02[2]*V12[1]; |
|
|
if(det!=0.) |
|
|
{ |
|
|
det=1./det; |
|
|
mat(0,0)=-det*V12[2]; |
|
|
mat(1,0)=det*V02[2]; |
|
|
mat(1,1)=-det*V02[1]; |
|
|
mat(0,1)=det*V12[1]; |
|
|
TinyVector<2> bary,secondmb; |
|
|
secondmb[0]=P0[1]; |
|
|
secondmb[1]=P0[2]; |
|
|
bary=mat*secondmb; |
|
|
if(bary[0]>=eps && bary[1]>=eps && (1-bary[0]-bary[1])>=eps) |
|
|
compt+=1; |
|
|
} |
|
|
else |
|
|
compt+=1; |
|
|
{ |
|
|
det=V02[0]*V12[2]-V02[2]*V12[0]; |
|
|
if(det!=0.) |
|
|
{ |
|
|
det=1./det; |
|
|
mat(0,0)=-V12[2]*det; |
|
|
mat(1,0)=V02[2]*det; |
|
|
mat(1,1)=-V02[0]*det; |
|
|
mat(0,1)=V12[0]*det; |
|
|
TinyVector<2> bary,secondmb; |
|
|
secondmb[0]=P0[0]; |
|
|
secondmb[1]=P0[2]; |
|
|
bary=mat*secondmb; |
|
|
|
|
|
if(bary[0]>=eps && bary[1]>=eps && (1-bary[0]-bary[1])>=eps) |
|
|
{ |
|
|
compt+=1; |
|
|
} |
|
|
} |
|
|
else |
|
|
compt+=1; |
|
|
} |
|
|
} |
|
|
// if(compt==3) |
|
|
// { |
|
|
//std::cout<<P.Vector3()[0]<<" "<<P.Vector3()[1]<<" "<<P.Vector3()[2]<<" 3 point intersection \n"; |
|
|
// } |
|
|
} |
|
|
|
|
|
|
|
|
void plotmedit(const SurfaceMeshOfTriangles& s_mesh,std::set<const Cell*>& toTreatHexahedra,size_t nobj,size_t nobjother) |
|
1071 |
{ |
{ |
1072 |
|
|
1073 |
//********************************************************************** |
//********************************************************************** |
1113 |
sortie<<s_mesh.vertexNumber(T(0))+8*toTreatHexahedra.size()+1<<" "<<s_mesh.vertexNumber(T(1))+8*toTreatHexahedra.size()+1<<" "<<s_mesh.vertexNumber(T(2))+8*toTreatHexahedra.size()+1; |
sortie<<s_mesh.vertexNumber(T(0))+8*toTreatHexahedra.size()+1<<" "<<s_mesh.vertexNumber(T(1))+8*toTreatHexahedra.size()+1<<" "<<s_mesh.vertexNumber(T(2))+8*toTreatHexahedra.size()+1; |
1114 |
// sortie<<3*i+1+8*toTreatHexahedra.size()<<" "<<3*i+2+8*toTreatHexahedra.size()<<" //"<<3*i+3+8*toTreatHexahedra.size()<<" "<<1<<"\n"; |
// sortie<<3*i+1+8*toTreatHexahedra.size()<<" "<<3*i+2+8*toTreatHexahedra.size()<<" //"<<3*i+3+8*toTreatHexahedra.size()<<" "<<1<<"\n"; |
1115 |
if(i<(nobj)) |
if(i<(nobj)) |
1116 |
sortie<<" 1"<<"\n"; |
sortie<<" 1"<<"\n"; |
|
else |
|
|
if(i<(nobj+nobjother)) |
|
|
sortie<<" 2"<<"\n"; |
|
1117 |
else |
else |
1118 |
sortie<<" 3"<<"\n"; |
sortie<<" 2"<<"\n"; |
1119 |
} |
} |
1120 |
sortie<<" \n"; |
sortie<<" \n"; |
1121 |
sortie<<"Hexahedra"<<"\n"; |
sortie<<"Hexahedra"<<"\n"; |
1134 |
|
|
1135 |
} |
} |
1136 |
|
|
|
|
|
1137 |
/* #include <vtkPolyDataMapper.h> |
/* #include <vtkPolyDataMapper.h> |
1138 |
#include <vtkRenderWindow.h> |
#include <vtkRenderWindow.h> |
1139 |
#include <vtkRenderWindowInteractor.h> |
#include <vtkRenderWindowInteractor.h> |