MeshProperties.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Juergen Riegel         <juergen.riegel@web.de>          *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef MESH_MESHPROPERTIES_H
00025 #define MESH_MESHPROPERTIES_H
00026 
00027 #include <vector>
00028 #include <list>
00029 #include <set>
00030 #include <string>
00031 #include <map>
00032 
00033 #include <Base/Handle.h>
00034 #include <Base/Matrix.h>
00035 #include <Base/Vector3D.h>
00036 
00037 #include <App/PropertyStandard.h>
00038 #include <App/PropertyGeo.h>
00039 
00040 #include "Core/MeshKernel.h"
00041 #include "Mesh.h"
00042 
00043 
00044 namespace Mesh
00045 {
00046 
00047 class MeshPy;
00048 
00053 class MeshExport PropertyNormalList : public App::PropertyVectorList
00054 {
00055     TYPESYSTEM_HEADER();
00056 
00057 public:
00058     PropertyNormalList()
00059     {
00060     }
00061     virtual ~PropertyNormalList()
00062     {
00063     }
00064     void transform(const Base::Matrix4D &rclMat);
00065 };
00066 
00068 struct MeshExport CurvatureInfo
00069 {
00070     float fMaxCurvature, fMinCurvature;
00071     Base::Vector3f cMaxCurvDir, cMinCurvDir;
00072 };
00073 
00077 class MeshExport PropertyCurvatureList: public App::PropertyLists
00078 {
00079     TYPESYSTEM_HEADER();
00080 
00081 public:
00082     enum { 
00083         MeanCurvature  = 0,  
00084         GaussCurvature = 1,  
00085         MaxCurvature   = 2,  
00086         MinCurvature   = 3,  
00087         AbsCurvature   = 4   
00088     };
00089 
00090 public:
00091     PropertyCurvatureList();
00092     ~PropertyCurvatureList();
00093 
00094     void setSize(int newSize){_lValueList.resize(newSize);}   
00095     int getSize(void) const {return _lValueList.size();}   
00096     std::vector<float> getCurvature( int tMode) const;
00097     void setValue(const CurvatureInfo&);
00098     void setValues(const std::vector<CurvatureInfo>&);
00099 
00101     const CurvatureInfo& operator[] (const int idx) const {return _lValueList.operator[] (idx);} 
00102     void  set1Value (const int idx, const CurvatureInfo& value){_lValueList.operator[] (idx) = value;}
00103     const std::vector<CurvatureInfo> &getValues(void) const{return _lValueList;}
00104     void transform(const Base::Matrix4D &rclMat);
00105 
00106     void Save (Base::Writer &writer) const;
00107     void Restore(Base::XMLReader &reader);
00108 
00109     void SaveDocFile (Base::Writer &writer) const;
00110     void RestoreDocFile(Base::Reader &reader);
00111 
00114     PyObject* getPyObject(void);
00115     void setPyObject(PyObject *value);
00117 
00118     App::Property *Copy(void) const;
00119     void Paste(const App::Property &from);
00120 
00121     virtual unsigned int getMemSize (void) const{return _lValueList.size() * sizeof(CurvatureInfo);}
00122 
00123 private:
00124     std::vector<CurvatureInfo> _lValueList;
00125 };
00126 
00130 class MeshExport PropertyMeshKernel : public App::PropertyComplexGeoData
00131 {
00132     TYPESYSTEM_HEADER();
00133 
00134 public:
00135     PropertyMeshKernel();
00136     ~PropertyMeshKernel();
00137 
00148     void setValuePtr(MeshObject* m);
00150     void setValue(const MeshObject& m);
00152     void setValue(const MeshCore::MeshKernel& m);
00154     void swapMesh(MeshObject&);
00156     void swapMesh(MeshCore::MeshKernel&);
00160     const MeshObject &getValue(void) const;
00161     const MeshObject *getValuePtr(void) const;
00162     virtual unsigned int getMemSize (void) const;
00164 
00167     const Data::ComplexGeoData* getComplexData() const;
00169     Base::BoundBox3d getBoundingBox() const;
00171     virtual void getFaces(std::vector<Base::Vector3d> &Points,
00172         std::vector<Data::ComplexGeoData::Facet> &Topo,
00173         float Accuracy, uint16_t flags=0) const;
00175 
00178     MeshObject* startEditing();
00179     void finishEditing();
00181     void transformGeometry(const Base::Matrix4D &rclMat);
00182     void deletePointIndices ( const std::vector<unsigned long>& );
00183     void deleteFacetIndices ( const std::vector<unsigned long>& );
00184     void setPointIndices( const std::vector<std::pair<unsigned long, Base::Vector3f> >& );
00185     void append(const std::vector<MeshCore::MeshFacet>& rFaces,
00186                 const std::vector<Base::Vector3f>& rPoints);
00187     void createSegment(const std::vector<unsigned long>& segm);
00188     void smooth(int iter, float d_max);
00189     void clear();
00191 
00194     void harmonizeNormals();
00195     void validateIndices();
00196     void validateDeformations(float fMaxAngle);
00197     void validateDegenerations();
00198     void removeDuplicatedPoints();
00199     void removeDuplicatedFacets();
00200     void removeNonManifolds();
00201     void removeSelfIntersections();
00202     void removeFoldsOnSurface();
00204 
00211     PyObject* getPyObject(void);
00217     void setPyObject(PyObject *value);
00219 
00220     const char* getEditorName(void) const { return "MeshGui::PropertyMeshKernelItem"; }
00221 
00224     void Save (Base::Writer &writer) const;
00225     void Restore(Base::XMLReader &reader);
00226 
00227     void SaveDocFile (Base::Writer &writer) const;
00228     void RestoreDocFile(Base::Reader &reader);
00229 
00230     App::Property *Copy(void) const;
00231     void Paste(const App::Property &from);
00233 
00234 private:
00235     Base::Reference<MeshObject> _meshObject;
00236     MeshPy* meshPyObject;
00237 };
00238 
00239 } // namespace Mesh
00240 
00241 #endif // MESH_MESHPROPERTIES_H
00242 

Generated on Wed Nov 23 19:00:23 2011 for FreeCAD by  doxygen 1.6.1