00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef COREFINE_3D_HH
00025 #define COREFINE_3D_HH
00026
00027 #include "inline-macro.hh"
00028 #include "corefine.hh"
00029 #include "attribute-bounding-box.hh"
00030 #include "corefine-3d-tools.hh"
00031 #include "edge-intersection.hh"
00032 #include "grid-3d.hh"
00033 #include "grid-tree-3d.hh"
00034 #include "time.hh"
00035
00036 namespace GMap3d {
00037
00038 typedef CGridTree3d<std::list<CDart*>*> TFaceGrid;
00039 typedef CGridTree3dIterator<std::list<CDart*>*> TFaceGridIter;
00040
00041 class DLL_COREFINEMENT CCorefine3d : public CCorefine
00042 {
00043 public:
00044
00045 CCorefine3d(CGMapVertex * AMap, bool ACalculateOrientation = true,
00046 TCoordinate AEpsilon = 1E-4, int AVertexDI = -1);
00047 ~CCorefine3d();
00048
00049 void computeOnlyFirstIntersection(bool ABoolean);
00050 void setGridResolution(int ARes);
00051
00052 virtual int corefine(CDart *& AMesh1, CDart *& AMesh2,
00053 std::bitset<NB_MARKS> ACopyMarks = 0);
00054
00055 const CTime & getInitialisationTime() const { return FInitialisationTime; }
00056 const CTime & getGridCreationTime() const { return FGridCreationTime; }
00057 const CTime & getResearchTime() const { return FResearchTime; }
00058 const CTime & getLineCreationTime() const { return FLineCreationTime; }
00059 const CTime & getUpdateTime() const { return FUpdateTime; }
00060
00061 protected:
00062
00063 virtual unsigned long initMesh(CDart * AMesh);
00064 virtual void cleanMesh(CDart * AMesh);
00065
00066 void createGrid(CDart * AMesh, unsigned long ANbFaces);
00067 void destroyGrid();
00068
00069 unsigned int getMaxVerticesDegree(std::list<CDart*> * AList);
00070 CVertex normalizeGridSize(const CVertex & AGridSize);
00071 void getGridResolution(const CVertex & AGridSize,
00072 unsigned int AMinRes,
00073 unsigned int AMaxRes,
00074 unsigned int * AResX,
00075 unsigned int * AResY,
00076 unsigned int * AResZ);
00077 void computeGridResolution(const CVertex & AGridSize,
00078 unsigned long ANbFaces,
00079 TCoordinate ANbFacesPerCell,
00080 unsigned int * AResX,
00081 unsigned int * AResY,
00082 unsigned int * AResZ,
00083 unsigned int AMinRes = 1,
00084 unsigned int AMaxRes = 512);
00085 unsigned int refineGrid(unsigned int AMaxSubDiv,
00086 unsigned int AMaxNumberOfFaces);
00087
00088 void addFaceToGrid(TFaceGrid * AGrid, CDart * AFace);
00089 void removeFaceFromGrid(TFaceGrid * AGrid, CDart * AFace);
00090
00091 void updateVertexLinks(CDart * ADart, CAttributeVertex * AVertex);
00092 void updateVertexLinks(CDart * ADart);
00093 CVertex * getVertex(CDart * ADart);
00094
00095 void updateFaceLinks(CDart * AFace);
00096 CDart * getFace(CDart * ADart);
00097
00098 CDart * createEdge();
00099
00100 virtual CDart * insertVertexInFace(CDart * AFace, const CVertex & APoint);
00101 virtual CDart * insertEdgeInFace(CDart * AVertex1, const CVertex & AVertex2);
00102 virtual CDart * splitFace(CDart * AVertex1, CDart * AVertex2);
00103 virtual CDart * splitEdge(CDart * AVertex, const CVertex & APoint);
00104 virtual CDart * removeEdge(CDart * AEdge, int ADeleteMark = -1);
00105 CVertex getProjectionOnPlane(CDart * AVertex, const CPlane & APlane);
00106
00107 bool isSameEdge_Naive(CDart * AEdge1, CDart * AEdge2);
00108 bool isSameEdge_Optimized(CDart * AEdge1, CDart * AEdge2);
00109 bool areFacesLinked(CDart * AFace1, CDart * AFace2);
00110
00111 CEdgeIntersection findNearestIntersectionInGrid(const CVertex & AVertex1,
00112 const CVertex & AVertex2);
00113
00114 CDart * findFirstIntersectionInGrid(const CVertex & AVertex, int * ADim);
00115
00116 void followIntersection(CDart * AVertex1, CDart * AVertex2, int AMark);
00117
00118 bool manageFacesIntersection(CDart * AFace1, const CPlane & APlane1,
00119 CDart * AFace2, const CPlane & APlane2,
00120 int AMark, std::list<CDart*> * AList);
00121
00122 void createIntersectionEdge(CDart * AFace1, CDart * AFace2,
00123 const CPlane & APlane1,
00124 const CPlane & APlane2,
00125 const CEdgeIntersection & AInter1,
00126 const CEdgeIntersection & AInter2,
00127 int AMark, std::list<CDart*> * AList);
00128
00129 void applyModifications(CDart * AMesh);
00130
00131 void extractIntersectionLines(CDart * AMesh);
00132
00133 private:
00134
00135 int FVertexDI;
00136 int FFaceDI;
00137
00138 int FAlpha2DI;
00139
00140 int FOrientMark;
00141 int FFictiveMark;
00142 int FIntersectionMark;
00143
00144 int FNumberOfIntersectionLines;
00145 int FNumberOfIntersectionEdges;
00146
00147 bool FLocalVertexDirectInfo;
00148 bool FCalculateOrientation;
00149 bool FComputeOnlyFirstIntersection;
00150 int FGridResolution;
00151
00152 CTime FInitialisationTime;
00153 CTime FGridCreationTime;
00154 CTime FResearchTime;
00155 CTime FLineCreationTime;
00156 CTime FUpdateTime;
00157
00158 CCorefine3dTools FTools;
00159
00160 TFaceGrid * FGrid;
00161 };
00162
00163 }
00164
00165 #include INCLUDE_INLINE("corefine-3d.icc")
00166
00167 #endif