/[ff3d]/ff3d/solver/SurfaceMeshGenerator.cpp
ViewVC logotype

Diff of /ff3d/solver/SurfaceMeshGenerator.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by delpinux, Mon Feb 17 16:32:50 2003 UTC revision 1.2 by delpinux, Sat Feb 22 13:55:16 2003 UTC
# Line 272  setBoundaryType(const Boundary& B, Line 272  setBoundaryType(const Boundary& B,
272  }  }
273    
274    
275  TinyVector<3>  TinyVector<3, real_t>
276  SurfaceMeshGenerator::  SurfaceMeshGenerator::
277  __splitEdge(const Edge& e,  __splitEdge(const Edge& e,
278              const Reference::Representation& ref,              const Reference::Representation& ref,
# Line 337  generateSurfacicMesh(const Shape& S, Line 337  generateSurfacicMesh(const Shape& S,
337    //! list of cut edges and intersection vertex.    //! list of cut edges and intersection vertex.
338    std::map<Edge::Pair, Vertex*> verticesList;    std::map<Edge::Pair, Vertex*> verticesList;
339    
340      //! list of cut edges and intersection vertex.
341      std::map<Edge::Pair, size_t> edgesRef;
342    
343    /**    /**
344     *  This contains the generate triangles     *  This contains the generate triangles
345     *  They just point on verticesList elements     *  They just point on verticesList elements
# Line 344  generateSurfacicMesh(const Shape& S, Line 347  generateSurfacicMesh(const Shape& S,
347    typedef std::list<TinyVector<3,Edge::Pair> > EdgePairList;    typedef std::list<TinyVector<3,Edge::Pair> > EdgePairList;
348    typedef std::list<const Cell*> MotherCellList;    typedef std::list<const Cell*> MotherCellList;
349    EdgePairList triangleList;    EdgePairList triangleList;
350      EdgePairList localTriangleList;
351    MotherCellList cellList;    MotherCellList cellList;
352    
353    for (size_t i = 0; i<SMesh.nbEdges(); i++) {    for (size_t i = 0; i<SMesh.nbEdges(); i++) {
# Line 352  generateSurfacicMesh(const Shape& S, Line 356  generateSurfacicMesh(const Shape& S,
356      if((e(0).Ref().insideDomain() xor e(1).Ref().insideDomain())      if((e(0).Ref().insideDomain() xor e(1).Ref().insideDomain())
357         and ((e(0).Ref().isSet(ref)) xor (e(1).Ref().isSet(ref))))         and ((e(0).Ref().isSet(ref)) xor (e(1).Ref().isSet(ref))))
358        {        {
         e.Ref() = 1;  
359          verticesList[e] = new Vertex(__splitEdge(e, ref, S));          verticesList[e] = new Vertex(__splitEdge(e, ref, S));
360            edgesRef[e] = 1;
361        }        }
362    }    }
363    
# Line 455  generateSurfacicMesh(const Shape& S, Line 459  generateSurfacicMesh(const Shape& S,
459                for (size_t i2=i1; i2<3; ++i2) {                for (size_t i2=i1; i2<3; ++i2) {
460                  *(currentAddedEdge) = Edge(currentCell(TverticesList[i1]),                  *(currentAddedEdge) = Edge(currentCell(TverticesList[i1]),
461                                             currentCell(TverticesList[i2+1]));                                             currentCell(TverticesList[i2+1]));
462                    Edge& e = (*currentAddedEdge);
463                    if (((e(0).Ref().isSet(ref)) xor (e(1).Ref().isSet(ref)))
464                        and (e(0).Ref().insideDomain() xor e(1).Ref().insideDomain())) {
465                      e.Ref() = 1;
466                      edgesRef[e] = 1;
467                    }
468                  currentAddedEdge++;                  currentAddedEdge++;
469                }                }
470              }              }
# Line 546  generateSurfacicMesh(const Shape& S, Line 555  generateSurfacicMesh(const Shape& S,
555    
556              for(size_t ie=0; ie<6; ++ie) {              for(size_t ie=0; ie<6; ++ie) {
557                const Edge& e = currentT->edge(ie);                const Edge& e = currentT->edge(ie);
558                if (((e(0).Ref().isSet(ref)) xor (e(1).Ref().isSet(ref)))                if (edgesRef.find(e) != edgesRef.end())
                   and (e(0).Ref().insideDomain() xor e(1).Ref().insideDomain())) {  
559                  cutEdges.push_back(&e);                  cutEdges.push_back(&e);
               }  
560              }              }
561    
562              switch (cutEdges.size()) {              switch (cutEdges.size()) {
563              case 3: {              case 3: {
564                //! Addes a triangle to the list.                //! Addes a triangle to the list.
565                triangleList.push_front(TinyVector<3,Edge::Pair>());                localTriangleList.push_front(TinyVector<3,Edge::Pair>());
566                cellList.push_front(&currentCell);                cellList.push_front(&currentCell);
567    
568                std::vector<TinyVector<3> > V(cutEdges.size());                std::vector<TinyVector<3> > V(cutEdges.size());
# Line 571  generateSurfacicMesh(const Shape& S, Line 578  generateSurfacicMesh(const Shape& S,
578                  std::swap(cutEdges[1], cutEdges[2]);                  std::swap(cutEdges[1], cutEdges[2]);
579    
580                //! Sets the triangle vertices (actually just store the edge where it lives).                //! Sets the triangle vertices (actually just store the edge where it lives).
581                EdgePairList::iterator currentTriangle = triangleList.begin();                EdgePairList::iterator currentTriangle = localTriangleList.begin();
582                for(size_t i=0; i<cutEdges.size(); ++i)                for(size_t i=0; i<cutEdges.size(); ++i)
583                  (*currentTriangle)[i] = (Edge::Pair)(*cutEdges[i]);                  (*currentTriangle)[i] = (Edge::Pair)(*cutEdges[i]);
584    
585                //! Stores the Edges on which the vertex will be computed.                //! Stores the Edges on which the vertex will be computed.
586                for (size_t i=0; i<cutEdges.size(); ++i)                for (size_t i=0; i<cutEdges.size(); ++i) {
587                  verticesList[*cutEdges[i]] =  new Vertex(__splitEdge(*cutEdges[i], ref, S));                  verticesList[*cutEdges[i]] =  new Vertex(__splitEdge(*cutEdges[i], ref, S));
588                    edgesRef[*cutEdges[i]] = 1;
589                  }
590                break;                break;
591              }              }
592              case 4: {              case 4: {
# Line 587  generateSurfacicMesh(const Shape& S, Line 596  generateSurfacicMesh(const Shape& S,
596                  cutEdgesMap[(Edge::Pair)*(cutEdges[ie])] = (cutEdges[ie]);                  cutEdgesMap[(Edge::Pair)*(cutEdges[ie])] = (cutEdges[ie]);
597    
598                //! Addes a triangle to the list.                //! Addes a triangle to the list.
599                triangleList.push_front(TinyVector<3,Edge::Pair>());                localTriangleList.push_front(TinyVector<3,Edge::Pair>());
600                cellList.push_front(&currentCell);                cellList.push_front(&currentCell);
601    
602                std::vector<TinyVector<3> > V(cutEdges.size());                std::vector<TinyVector<3> > V(cutEdges.size());
# Line 604  generateSurfacicMesh(const Shape& S, Line 613  generateSurfacicMesh(const Shape& S,
613                bool swapEdge = ((V[0]^V[1])*V[2] > 0);                bool swapEdge = ((V[0]^V[1])*V[2] > 0);
614    
615                //! Sets the triangle vertices (actually just store the edge where it lives).                //! Sets the triangle vertices (actually just store the edge where it lives).
616                EdgePairList::iterator currentTriangle = triangleList.begin();                EdgePairList::iterator currentTriangle = localTriangleList.begin();
617    
618                currentCutEdge = cutEdgesMap.begin();                currentCutEdge = cutEdgesMap.begin();
619                if (!swapEdge)                if (!swapEdge)
# Line 620  generateSurfacicMesh(const Shape& S, Line 629  generateSurfacicMesh(const Shape& S,
629    
630                for (size_t i=0; i<4; ++i) {                for (size_t i=0; i<4; ++i) {
631                  verticesList[*cutEdges[i]] =  new Vertex(__splitEdge(*cutEdges[i], ref, S));                  verticesList[*cutEdges[i]] =  new Vertex(__splitEdge(*cutEdges[i], ref, S));
632                    edgesRef[*cutEdges[i]] = 1;
633                }                }
634    
635                //! Addes a triangle to the list.                //! Addes a triangle to the list.
636                triangleList.push_front(TinyVector<3,Edge::Pair>());                localTriangleList.push_front(TinyVector<3,Edge::Pair>());
637                cellList.push_front(&currentCell);                cellList.push_front(&currentCell);
638    
639                currentTriangle = triangleList.begin();                currentTriangle = localTriangleList.begin();
640    
641                //! Sets the triangle vertices (actually just store the edge where it lives).                //! Sets the triangle vertices (actually just store the edge where it lives).
642                currentCutEdge = cutEdgesMap.begin();                currentCutEdge = cutEdgesMap.begin();
# Line 652  generateSurfacicMesh(const Shape& S, Line 662  generateSurfacicMesh(const Shape& S,
662    
663            if(jobDone) {            if(jobDone) {
664              meshedHexahedra.insert(&currentCell);              meshedHexahedra.insert(&currentCell);
665                for (EdgePairList::iterator t = localTriangleList.begin();
666                     t != localTriangleList.end(); ++t) {
667                  triangleList.push_front(*t);
668                }
669            } else {            } else {
670              hexaTetraAssociation[&currentCell]              hexaTetraAssociation[&currentCell]
671                = std::pair<ReferenceCounting<std::vector<TetrahedronByEdges> >,                = std::pair<ReferenceCounting<std::vector<TetrahedronByEdges> >,
672                            ReferenceCounting<std::vector<Edge> > >                            ReferenceCounting<std::vector<Edge> > >
673                (pT,pAddedEdges);                (pT,pAddedEdges);
674            }            }
675    
676              localTriangleList.clear();
677          }          }
678        }        }
679    
   
680  //   triangleList.clear();  //   triangleList.clear();
681  //   verticesList.clear();  //   verticesList.clear();
682    
# Line 699  generateSurfacicMesh(const Shape& S, Line 714  generateSurfacicMesh(const Shape& S,
714  //        std::swap(cutEdges[1], cutEdges[2]);  //        std::swap(cutEdges[1], cutEdges[2]);
715    
716  //      //! Addes a triangle to the list.  //      //! Addes a triangle to the list.
717  //      triangleList.push_front(TinyVector<3,Edge::Pair>());  //      localTriangleList.push_front(TinyVector<3,Edge::Pair>());
718  //      cellList.push_front(&currentCell);  //      cellList.push_front(&currentCell);
719    
720  //      //! Sets the triangle vertices (actually just store the edge where it lives).  //      //! Sets the triangle vertices (actually just store the edge where it lives).
721  //      EdgePairList::iterator currentTriangle = triangleList.begin();  //      EdgePairList::iterator currentTriangle = localTriangleList.begin();
722  //      for(size_t i=0; i<cutEdges.size(); ++i)  //      for(size_t i=0; i<cutEdges.size(); ++i)
723  //        (*currentTriangle)[i] = (Edge::Pair)(*cutEdges[i]);  //        (*currentTriangle)[i] = (Edge::Pair)(*cutEdges[i]);
724    
# Line 719  generateSurfacicMesh(const Shape& S, Line 734  generateSurfacicMesh(const Shape& S,
734  //        cutEdgesMap[(Edge::Pair)*(cutEdges[ie])] = (cutEdges[ie]);  //        cutEdgesMap[(Edge::Pair)*(cutEdges[ie])] = (cutEdges[ie]);
735    
736  //      //! Addes a triangle to the list.  //      //! Addes a triangle to the list.
737  //      triangleList.push_front(TinyVector<3,Edge::Pair>());  //      localTriangleList.push_front(TinyVector<3,Edge::Pair>());
738  //      cellList.push_front(&currentCell);  //      cellList.push_front(&currentCell);
739    
740  //      std::vector<TinyVector<3> > V(cutEdges.size());  //      std::vector<TinyVector<3> > V(cutEdges.size());
# Line 736  generateSurfacicMesh(const Shape& S, Line 751  generateSurfacicMesh(const Shape& S,
751  //      bool swapEdge = ((V[0]^V[1])*V[2] > 0);  //      bool swapEdge = ((V[0]^V[1])*V[2] > 0);
752    
753  //      //! Sets the triangle vertices (actually just store the edge where it lives).  //      //! Sets the triangle vertices (actually just store the edge where it lives).
754  //      EdgePairList::iterator currentTriangle = triangleList.begin();  //      EdgePairList::iterator currentTriangle = localTriangleList.begin();
755    
756  //      currentCutEdge = cutEdgesMap.begin();  //      currentCutEdge = cutEdgesMap.begin();
757  //      if (!swapEdge)  //      if (!swapEdge)
# Line 755  generateSurfacicMesh(const Shape& S, Line 770  generateSurfacicMesh(const Shape& S,
770  //      }  //      }
771    
772  //      //! Addes a triangle to the list.  //      //! Addes a triangle to the list.
773  //      triangleList.push_front(TinyVector<3,Edge::Pair>());  //      localTriangleList.push_front(TinyVector<3,Edge::Pair>());
774  //      cellList.push_front(&currentCell);  //      cellList.push_front(&currentCell);
775    
776  //      currentTriangle = triangleList.begin();  //      currentTriangle = localTriangleList.begin();
777    
778  //      //! Sets the triangle vertices (actually just store the edge where it lives).  //      //! Sets the triangle vertices (actually just store the edge where it lives).
779  //      currentCutEdge = cutEdgesMap.begin();  //      currentCutEdge = cutEdgesMap.begin();
# Line 781  generateSurfacicMesh(const Shape& S, Line 796  generateSurfacicMesh(const Shape& S,
796  //       }  //       }
797  //       }  //       }
798  //     }  //     }
799    
800    
801    //     for (EdgePairList::iterator t = localTriangleList.begin();
802    //       t != localTriangleList.end(); ++t) {
803    //       size_t nbInside = 0;
804    //       for (size_t k =0; k<3; ++k) {
805    //      std::map<Edge::Pair, size_t>::iterator eRef
806    //        = edgesRef.find((*t)[k]);
807    //      if ((*eRef).second == 1)
808    //        nbInside ++;
809    //       }
810    //       if (nbInside == 3) {
811    //      ffout(3) << "yaduboulo\n";
812    //      triangleList.push_front(*t);
813    //       } else {
814    //      ffout(3) << "cava " << nbInside  << '\n';
815    //       }
816    //     }
817    
818    //     for (EdgePairList::iterator t = localTriangleList.begin();
819    //       t != localTriangleList.end(); ++t) {
820    //       triangleList.push_front(*t);
821    //     }
822    
823    //     localTriangleList.clear();
824  //   }  //   }
825    
826    
# Line 816  generateSurfacicMesh(const Shape& S, Line 856  generateSurfacicMesh(const Shape& S,
856    
857      s_mesh.cell(i) = Triangle(V0,V1,V2);      s_mesh.cell(i) = Triangle(V0,V1,V2);
858  #warning SHOULD USE BC NUMBER (ie OBJECT NUMBER IN SCENE INSTEAD)  #warning SHOULD USE BC NUMBER (ie OBJECT NUMBER IN SCENE INSTEAD)
859    
860    
861      s_mesh.cell(i).reference() = 1;      s_mesh.cell(i).reference() = 1;
862      s_mesh.cell(i).setMother(*motherCell);      s_mesh.cell(i).setMother(*motherCell);
863    
# Line 823  generateSurfacicMesh(const Shape& S, Line 865  generateSurfacicMesh(const Shape& S,
865      motherCell++;      motherCell++;
866    }    }
867    
868  //   for (std::set<const Cell*>::iterator i = toTreatHexahedra.begin();  //    plot2(s_mesh, toTreatHexahedra, SMesh);
 //        i != toTreatHexahedra.end(); ++i) {  
 //     ffout(3) << (*i) << '\n';  
 //   }  
   
 //   plot2(s_mesh, toTreatHexahedra, SMesh);  
869  }  }
870    
871    
872    
873  // #include <vtkPolyDataMapper.h>  // #include <vtkPolyDataMapper.h>
874  // #include <vtkRenderWindow.h>  // #include <vtkRenderWindow.h>
875  // #include <vtkRenderWindowInteractor.h>  // #include <vtkRenderWindowInteractor.h>
# Line 995  generateSurfacicMesh(const Shape& S, Line 1033  generateSurfacicMesh(const Shape& S,
1033  // //   coneActor->Delete();  // //   coneActor->Delete();
1034  // //   ren1->Delete();  // //   ren1->Delete();
1035  // }  // }
1036    

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26