/[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.20 by dobj, Tue Jul 22 17:07:56 2003 UTC revision 1.21 by delpinux, Wed Jul 23 17:54:32 2003 UTC
# Line 33  Line 33 
33    
34  #include <Union.hpp>  #include <Union.hpp>
35  #include <Intersection.hpp>  #include <Intersection.hpp>
36    #include <Not.hpp>
37    
38  #include <Problem.hpp>  #include <Problem.hpp>
39    
# Line 51  Line 52 
52    
53  #include <set>  #include <set>
54  #include <iostream>  #include <iostream>
55    #include <stack>
56    
57  class SurfaceMeshGenerator::Internals  class SurfaceMeshGenerator::Internals
58  {  {
# Line 316  public : Line 317  public :
317    ReferenceCounting<Vector<Vertex*> > verticeslist;    ReferenceCounting<Vector<Vertex*> > verticeslist;
318    ReferenceCounting< MapCellTriangle > hexalist;    ReferenceCounting< MapCellTriangle > hexalist;
319        
320      const ObjectToTreat& operator=(const ObjectToTreat& O)
321      {
322        Object::operator=(O);
323        trianglelist = O.trianglelist;
324        verticeslist = O.verticeslist;
325        hexalist = O.hexalist;
326    
327        return *this;
328      }
329    
330    //constructor    //constructor
331    ObjectToTreat(const Object & O)    ObjectToTreat(const Object & O)
332      : Object(O)      : Object(O)
333    {    {
334      ;      ;
335    }    }
336    /*ObjectToTreat(ObjectToTreat& O)  
337      : Object(O.__shape,O.__reference)    ObjectToTreat(ObjectToTreat& O)
338      {      : Object(O),
339      trianglelist=O.trianglelist;        trianglelist(O.trianglelist),
340      verticeslist=O.verticeslist;        verticeslist(O.verticeslist),
341      }*/        hexalist(O.hexalist)
342      {
343        ;
344      }
345    
346    ObjectToTreat(ReferenceCounting<Vector<Triangle> > tr,    ObjectToTreat(ReferenceCounting<Vector<Triangle> > tr,
347                  ReferenceCounting<Vector<Vertex*> > ver,                  ReferenceCounting<Vector<Vertex*> > ver,
348                  ReferenceCounting< MapCellTriangle > hex,                  ReferenceCounting< MapCellTriangle > hex,
349                  Object & O)                  Object & O)
350      : Object(O){      : Object(O),
351      trianglelist=tr;        trianglelist(tr),
352      verticeslist=ver;        verticeslist(ver),
353      hexalist=hex;        hexalist(hex)
354      {
355        ;
356      }
357    
358      ~ObjectToTreat()
359      {
360        ;
361    }    }
362  };  };
363    
# Line 485  __operationBoolean(size_t num, Line 507  __operationBoolean(size_t num,
507      }      }
508    }    }
509        
510    toTreatHexahedra=cuttedHexahedra;    //  toTreatHexahedra=cuttedHexahedra;
511    __dataStructureConvertion(num);    __dataStructureConvertion(num);
512    
513      std::set<const Cell*> hexaList1;
514      std::set<const Cell*> hexaList2;
515    
516      for (MapCellTriangle::iterator i=(*O1.hexalist).begin(); i!= (*O1.hexalist).end(); ++i) {
517        hexaList1.insert((*i).first);
518      }
519      for (MapCellTriangle::iterator i=(*O2.hexalist).begin(); i!= (*O2.hexalist).end(); ++i) {
520        hexaList2.insert((*i).first);
521      }
522    
523      std::set_intersection (hexaList1.begin(), hexaList1.end(),
524                             hexaList2.begin(), hexaList2.end(),
525                             inserter(toTreatHexahedra, toTreatHexahedra.begin()));
526    
527    
528    ffout(0)<<"nb hexa to treat "<<toTreatHexahedra.size()<<"\n";    ffout(0)<<"nb hexa to treat "<<toTreatHexahedra.size()<<"\n";
529        
530    O0=__calculateIntersection(O1,O2,Omega);    O0=__calculateIntersection(O1,O2,Omega);
531        return O0;
532  }  }
533    
534  SurfaceMeshGenerator::Internals::ObjectToTreat SurfaceMeshGenerator::Internals::  SurfaceMeshGenerator::Internals::ObjectToTreat SurfaceMeshGenerator::Internals::
# Line 499  __calculateIntersection(ObjectToTreat& O Line 537  __calculateIntersection(ObjectToTreat& O
537                          const Domain& Omega)                          const Domain& Omega)
538  {  {
539    const Scene& scene = Omega.scene();    const Scene& scene = Omega.scene();
540    SurfaceMeshGenerator::Internals::ObjectToTreat O0=O1;    SurfaceMeshGenerator::Internals::ObjectToTreat O0(O1);
541        
542    __calculatePointsIntersection(scene,O1,O2);    __calculatePointsIntersection(scene,O1,O2);
543    //create mesh intersection for the object 0 and 1    //create mesh intersection for the object 0 and 1
# Line 2108  __createTrianglesIntersection(const size Line 2146  __createTrianglesIntersection(const size
2146      } else {      } else {
2147        (*edgesRefVertex[numobject])[&(T(2))]=0;        (*edgesRefVertex[numobject])[&(T(2))]=0;
2148      }      }
2149      /* if(numobject>objectNumber and (*edgesRefVertex[numobject])[&T(0)]==2       if((*edgesRefVertex[numobject])[&T(0)]==2
2150         and (*edgesRefVertex[numobject])[&T(1)]==2          and (*edgesRefVertex[numobject])[&T(1)]==2
2151         and (*edgesRefVertex[numobject])[&T(2)]==2) {          and (*edgesRefVertex[numobject])[&T(2)]==2) {
2152         __addTriangle(T(0),T(1),T(2),&T.mother());         __addTriangle(T(0),T(1),T(2),&T.mother());
2153         }*/       }
2154    }    }
2155        
2156    size_t nbinters=listVertexIntersectionNew.size();    size_t nbinters=listVertexIntersectionNew.size();
# Line 2958  void plotmedit(const size_t& nobject, Line 2996  void plotmedit(const size_t& nobject,
2996  void plothexa(size_t ncase,std::set<const Cell*>& cuttedHexahedra);  void plothexa(size_t ncase,std::set<const Cell*>& cuttedHexahedra);
2997    
2998    
2999    void showObject(const Object& object, const size_t& level,
3000                    std::stack<int> objectStack, const size_t& numero)
3001    {
3002      for (size_t i=0; i<level; ++i)
3003        std::cout << "==";
3004      switch(object.shapeType()) {
3005      case Shape::union_: {
3006        const Union& U = static_cast<const Union&>(*(object.shape()));
3007        std::cout << "Union:\n";
3008        size_t j=0;
3009        for(Union::const_iterator i = U.begin();
3010            i != U.end(); ++i, ++j) {
3011          if (j>1) {
3012            for (size_t l=0; l<level; ++l)
3013              std::cout << "==";
3014            std::cout << "Calcule l'union\n";
3015          }
3016          showObject((*(*i)), level+1, objectStack, numero+1);
3017        }
3018        for (size_t l=0; l<level; ++l)
3019          std::cout << "==";
3020        std::cout << "Calcule l'union\n";
3021        break;
3022      }  case Shape::intersection: {
3023        const Intersection& I = static_cast<const Intersection&>(*(object.shape()));
3024        std::cout << "Intersection:\n";
3025        size_t j=0;
3026        for(Intersection::const_iterator i = I.begin();
3027            i != I.end(); ++i,++j) {
3028          if (j>1) {
3029            for (size_t l=0; l<level; ++l)
3030              std::cout << "==";
3031            std::cout << "Calcule l'intersection\n";
3032          }
3033          showObject((*(*i)), level+1, objectStack, numero+1);
3034        }
3035        for (size_t l=0; l<level; ++l)
3036          std::cout << "==";
3037        std::cout << "Calcule l'intersection\n";
3038        break;
3039      } case Shape::difference: {
3040        fferr(0) << __FILE__ << ':' << __LINE__ << ": Not implemented\n";
3041        break;
3042      } case Shape::not_: {
3043        const Not& N = static_cast<const Not&>(*(object.shape()));
3044        std::cout << "Not:\n";
3045        showObject((*N.object()), level+1, objectStack, numero+1);
3046        break;
3047      } default: {
3048        std::cout << "Nouvel Objet à traiter: " << numero << '\n';
3049      }
3050      }
3051    }
3052    
3053  /*! Generates a surfacic mesh using only characteristic function of an object  /*! Generates a surfacic mesh using only characteristic function of an object
3054    and the Structured 3D Mesh.    and the Structured 3D Mesh.
3055    
# Line 2969  generateSurfacicMesh(const Object& O, Line 3061  generateSurfacicMesh(const Object& O,
3061                       SurfaceMeshOfTriangles& s_mesh,                       SurfaceMeshOfTriangles& s_mesh,
3062                       Structured3DMesh& SMesh,                       Structured3DMesh& SMesh,
3063                       const Reference::Representation& ref,                       const Reference::Representation& ref,
3064                       const std::set<Reference::Representation>& referencesList) {                       const std::set<Reference::Representation>& referencesList)
3065     {
3066    const Shape& S = *(O.shape());    const Shape& S = *(O.shape());
3067            
3068    typedef std::map<TinyVector<3>, Object*,    typedef std::map<TinyVector<3>, Object*,
# Line 2981  generateSurfacicMesh(const Object& O, Line 3073  generateSurfacicMesh(const Object& O,
3073    const Object& object = Omega.object();    const Object& object = Omega.object();
3074    const Scene& scene = Omega.scene();    const Scene& scene = Omega.scene();
3075    
3076      std::stack<int> objectStack;
3077      showObject(object, 0, objectStack, 0);
3078      std::exit(1);
3079    
3080    switch (object.shapeType()) {    switch (object.shapeType()) {
3081    case Shape::union_: {    case Shape::union_: {
3082      const Union& U = static_cast<const Union&>(*(object.shape()));      const Union& U = static_cast<const Union&>(*(object.shape()));
# Line 3164  generateSurfacicMesh(const Object& O, Line 3260  generateSurfacicMesh(const Object& O,
3260        SurfaceMeshGenerator::Internals::ObjectToTreat& O1=O0;        SurfaceMeshGenerator::Internals::ObjectToTreat& O1=O0;
3261        SurfaceMeshGenerator::Internals::ObjectToTreat& O2=(*(*__internals).listOfObjectToTreat[num]);        SurfaceMeshGenerator::Internals::ObjectToTreat& O2=(*(*__internals).listOfObjectToTreat[num]);
3262    
3263        //O0=(*__internals).__operationBoolean(num,O1,O2,Omega,SMesh,cuttedHexahedra, meshedHexahedra);        O0=(*__internals).__operationBoolean(num,O1,O2,Omega,SMesh,cuttedHexahedra, meshedHexahedra);
       for(size_t n = 0; n<scene.nbObjects(); ++n) {  
           Reference::Representation otherRef;  
           otherRef.resize(scene.nbObjects());  
           if (scene.object(n).reference() == (O2.reference())) {  
               otherRef[n] = true;  
               //create surface objects  
               (*__internals).__createSurface(SMesh,  
                        *(scene.object(n).shape()),otherRef,num,  
                        cuttedHexahedra,meshedHexahedra);  
           }  
       }  
3264    
       (*__internals).toTreatHexahedra=cuttedHexahedra;  
       (*__internals).__dataStructureConvertion(num);  
       ffout(0)<<"nb hexa to treat "<<(*__internals).toTreatHexahedra.size()<<"\n";  
   
       O0=(*__internals).__calculateIntersection(O1,O2,Omega);  
3265        num++;        num++;
3266      }      }
3267    }    }
# Line 3192  generateSurfacicMesh(const Object& O, Line 3272  generateSurfacicMesh(const Object& O,
3272        
3273    //construction of s_mesh    //construction of s_mesh
3274    (*__internals).__constructionFinalMesh(O0,s_mesh);    (*__internals).__constructionFinalMesh(O0,s_mesh);
3275          
3276  //   //  plot2(s_mesh, (*__internals).toTreatHexahedra, SMesh);    //  plot2(s_mesh, (*__internals).toTreatHexahedra, SMesh);
3277    plotmedit(nobject,s_mesh, (*__internals).toTreatHexahedra,cuttedHexahedra,    plotmedit(nobject,s_mesh, (*__internals).toTreatHexahedra,cuttedHexahedra,
3278              n0,n1);              n0,n1);
3279  }  }

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

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