00001 /*************************************************************************** 00002 * Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> * 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 INSPECTION_FEATURE_H 00025 #define INSPECTION_FEATURE_H 00026 00027 #include <App/DocumentObject.h> 00028 #include <App/PropertyLinks.h> 00029 #include <App/DocumentObjectGroup.h> 00030 00031 #include <Mod/Mesh/App/Core/Iterator.h> 00032 #include <Mod/Points/App/Points.h> 00033 00034 class TopoDS_Shape; 00035 class BRepExtrema_DistShapeShape; 00036 00037 namespace MeshCore { 00038 class MeshKernel; 00039 class MeshGrid; 00040 } 00041 00042 namespace Mesh { class MeshObject; } 00043 namespace Points { class PointsGrid; } 00044 namespace Part { class TopoShape; } 00045 00046 namespace Inspection 00047 { 00048 00050 class InspectionExport InspectActualGeometry 00051 { 00052 public: 00053 InspectActualGeometry() {} 00054 virtual ~InspectActualGeometry() {} 00056 virtual unsigned long countPoints() const = 0; 00057 virtual Base::Vector3f getPoint(unsigned long) = 0; 00058 }; 00059 00060 class InspectionExport InspectActualMesh : public InspectActualGeometry 00061 { 00062 public: 00063 InspectActualMesh(const Mesh::MeshObject& rMesh); 00064 ~InspectActualMesh(); 00065 virtual unsigned long countPoints() const; 00066 virtual Base::Vector3f getPoint(unsigned long); 00067 00068 private: 00069 MeshCore::MeshPointIterator _iter; 00070 unsigned long _count; 00071 }; 00072 00073 class InspectionExport InspectActualPoints : public InspectActualGeometry 00074 { 00075 public: 00076 InspectActualPoints(const Points::PointKernel&); 00077 virtual unsigned long countPoints() const; 00078 virtual Base::Vector3f getPoint(unsigned long); 00079 00080 private: 00081 const Points::PointKernel& _rKernel; 00082 }; 00083 00084 class InspectionExport InspectActualShape : public InspectActualGeometry 00085 { 00086 public: 00087 InspectActualShape(const Part::TopoShape&); 00088 virtual unsigned long countPoints() const; 00089 virtual Base::Vector3f getPoint(unsigned long); 00090 00091 private: 00092 const Part::TopoShape& _rShape; 00093 std::vector<Base::Vector3d> points; 00094 }; 00095 00097 class InspectionExport InspectNominalGeometry 00098 { 00099 public: 00100 InspectNominalGeometry() {} 00101 virtual ~InspectNominalGeometry() {} 00102 virtual float getDistance(const Base::Vector3f&) = 0; 00103 }; 00104 00105 class InspectionExport InspectNominalMesh : public InspectNominalGeometry 00106 { 00107 public: 00108 InspectNominalMesh(const Mesh::MeshObject& rMesh, float offset); 00109 ~InspectNominalMesh(); 00110 virtual float getDistance(const Base::Vector3f&); 00111 00112 private: 00113 MeshCore::MeshFacetIterator _iter; 00114 MeshCore::MeshGrid* _pGrid; 00115 Base::BoundBox3f _box; 00116 }; 00117 00118 class InspectionExport InspectNominalFastMesh : public InspectNominalGeometry 00119 { 00120 public: 00121 InspectNominalFastMesh(const Mesh::MeshObject& rMesh, float offset); 00122 ~InspectNominalFastMesh(); 00123 virtual float getDistance(const Base::Vector3f&); 00124 00125 protected: 00126 MeshCore::MeshFacetIterator _iter; 00127 MeshCore::MeshGrid* _pGrid; 00128 Base::BoundBox3f _box; 00129 unsigned long max_level; 00130 }; 00131 00132 class InspectionExport InspectNominalPoints : public InspectNominalGeometry 00133 { 00134 public: 00135 InspectNominalPoints(const Points::PointKernel&, float offset); 00136 ~InspectNominalPoints(); 00137 virtual float getDistance(const Base::Vector3f&); 00138 00139 private: 00140 const Points::PointKernel& _rKernel; 00141 Points::PointsGrid* _pGrid; 00142 }; 00143 00144 class InspectionExport InspectNominalShape : public InspectNominalGeometry 00145 { 00146 public: 00147 InspectNominalShape(const TopoDS_Shape&, float offset); 00148 ~InspectNominalShape(); 00149 virtual float getDistance(const Base::Vector3f&); 00150 00151 private: 00152 BRepExtrema_DistShapeShape* distss; 00153 const TopoDS_Shape& _rShape; 00154 }; 00155 00156 // ---------------------------------------------------------------- 00157 00161 class InspectionExport Feature : public App::DocumentObject 00162 { 00163 PROPERTY_HEADER(Inspection::Feature); 00164 00165 public: 00167 Feature(void); 00168 virtual ~Feature(); 00169 00172 App::PropertyFloat SearchRadius; 00173 App::PropertyFloat Thickness; 00174 App::PropertyLink Actual; 00175 App::PropertyLinkList Nominals; 00176 App::PropertyFloatList Distances; 00178 00181 short mustExecute() const; 00183 App::DocumentObjectExecReturn* execute(void); 00185 00187 const char* getViewProviderName(void) const 00188 { return "InspectionGui::ViewProviderInspection"; } 00189 }; 00190 00191 class InspectionExport Group : public App::DocumentObjectGroup 00192 { 00193 PROPERTY_HEADER(Inspection::Group); 00194 00195 public: 00197 Group(void); 00198 virtual ~Group(); 00199 00201 const char* getViewProviderName(void) const 00202 { return "InspectionGui::ViewProviderInspectionGroup"; } 00203 }; 00204 00205 } //namespace Inspection 00206 00207 00208 #endif // INSPECTION_FEATURE_H