00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef  _MO_MESHANNOTATEDISOLINE_
00024 #define  _MO_MESHANNOTATEDISOLINE_
00025 
00026 #include <MeshVizXLM/MbVec3.h>
00027 #include <MeshVizXLM/extractors/MiExtractorCallback.h>
00028 
00029 #include <MeshVizXLM/mapping/nodes/MoMeshIsoline.h>
00030 
00031 #include <Inventor/STL/vector>
00032 
00033 #ifdef _WIN32
00034 #pragma warning(push)
00035 #pragma warning(disable:4251)
00036 #endif
00037 
00038 class MeXLineMeshUnstructured;
00039 class MeXLineTopologyExplicitI;
00040 class MiGeometryI;
00041 class SoAnnoText3;
00042 class SoText2;
00043 class SoGroup;
00044 class SoGetBoundingBoxAction;
00045 class SoTextProperty;
00046 
00047 class MxExtractorCallback;
00048 
00097 class MESHVIZXLM_DMAP_API MoMeshAnnotatedIsoline : public MoMeshIsoline {
00098 
00099   SO_NODE_HEADER(MoMeshAnnotatedIsoline) ;
00100 
00101  public:
00102 
00106   MoMeshAnnotatedIsoline() ;
00107 
00112   SoSFBool    isVisible ;
00113 
00120   SoSFBool    isText2D ;
00121 
00125   enum AnnotPath {
00126     TANGENTIAL_PATH, 
00127     HORIZONTAL_PATH, 
00128     VERTICAL_PATH    
00130   } ;
00131 
00140   SoSFEnum    path ;
00141 
00146   SoSFVec3f    upVector ;
00147 
00152   SoSFFloat   gap ;
00153 
00160   SoSFFloat   fontSize ;
00161 
00166   SoSFColor   color ;
00167   
00172   SoSFBool    isBackground ;
00173 
00178   SoSFColor   backgroundColor ;
00179 
00184   SoSFColor   borderColor ;
00185 
00189   void setExtractorCallback(MiExtractorCallback* extractorCallback);
00190 
00191   
00192  private:
00193   static void initClass() ;
00194     static void exitClass() ;
00195 
00196  private:
00197   virtual void doExtract(SoAction * action);
00198 
00199  private:
00200   virtual ~MoMeshAnnotatedIsoline() ;  
00201   void annotateLines(SoAction * action,const std::vector<const MeXLineMeshUnstructured*>& lines, const MiMesh* inputMesh);
00202 
00203   MxExtractorCallback* m_redrawCallback;
00204 
00205   class ChordalDistance
00206   {
00207   public:
00208     std::vector< double > m_distances;
00209     SbBox3f m_bbox;
00210     size_t m_startCellIndex;
00211   };
00212 
00213   void computeChordalDistances(const MeXLineTopologyExplicitI& topo,const MiGeometryI& geom, std::vector< ChordalDistance >& chordalDistancesArray);
00214   void addAnnot(MbVec3d& pos, std::string& str, MbVec3d& baseVector, float width, float height);
00215   void getStringSize(SoAction * action, const std::string& str, float &width, float &height, SbBox3f& bbox);
00216   std::string computeString(SoAction * action,float isovalue,float& width,float& height,SbBox3f& annotBbox);
00217   std::vector<double>::iterator computeAnnotPos(ChordalDistance& chordalDistances, const std::vector<double>::iterator& beg, const std::vector<double>::iterator& end,
00218     double value,const MeXLineTopologyExplicitI& topo,const MiGeometryI& geom,MbVec3d& pos,MbVec3d& baseVector);
00219   void initSceneGraph(double diag);
00220 
00221   void clear();
00222 
00223   SoSeparator* m_sepAnnot;
00224   SoGroup* m_bboxGroup;
00225   SoAnnoText3* m_bboxText;
00226   SoText2* m_bboxText2;
00227   SoFont* m_font;
00228   SoGetBoundingBoxAction* m_bboxAction;
00229   SoTextProperty* m_textProp;
00230 } ;
00231 
00232 #ifdef _WIN32
00233 #pragma warning(pop)
00234 #endif
00235 
00236 #endif 
00237 
00238 
00239 
00240