Evaluation.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 Imetric 3D GmbH                                    *
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_EVALUATION_H
00025 #define MESH_EVALUATION_H
00026 
00027 #include <list>
00028 #include <math.h>
00029 
00030 #include "MeshKernel.h"
00031 #include "Visitor.h"
00032 
00033 namespace MeshCore {
00034 
00044 class MeshExport MeshEvaluation
00045 {
00046 public:
00047   MeshEvaluation (const MeshKernel &rclB) : _rclMesh(rclB) {}
00048   virtual ~MeshEvaluation () {}
00049 
00055   virtual bool Evaluate () = 0;
00056 
00057 protected:
00058   const MeshKernel& _rclMesh; 
00059 };
00060 
00061 // ----------------------------------------------------
00062 
00070 class MeshExport MeshValidation
00071 {
00072 public:
00073   MeshValidation (MeshKernel &rclB) : _rclMesh(rclB) {}
00074   virtual ~MeshValidation () {}
00075 
00080   virtual bool Fixup() = 0;
00081 
00082 protected:
00083   MeshKernel& _rclMesh; 
00084 };
00085 
00086 // ----------------------------------------------------
00087 
00092 class MeshExport MeshOrientationVisitor : public MeshFacetVisitor
00093 {
00094 public:
00095     MeshOrientationVisitor();
00096 
00098     bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long );
00099     bool HasNonUnifomOrientedFacets() const;
00100 
00101 private:
00102     bool _nonuniformOrientation;
00103 };
00104 
00110 class MeshExport MeshOrientationCollector : public MeshOrientationVisitor
00111 {
00112 public:
00113     MeshOrientationCollector(std::vector<unsigned long>& aulIndices,
00114                              std::vector<unsigned long>& aulComplement);
00115 
00117     bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long);
00118 
00119 private:
00120     std::vector<unsigned long>& _aulIndices;
00121     std::vector<unsigned long>& _aulComplement;
00122 };
00123 
00127 class MeshExport MeshSameOrientationCollector : public MeshOrientationVisitor
00128 {
00129 public:
00130     MeshSameOrientationCollector(std::vector<unsigned long>& aulIndices);
00132     bool Visit (const MeshFacet &, const MeshFacet &, unsigned long , unsigned long);
00133 
00134 private:
00135     std::vector<unsigned long>& _aulIndices;
00136 };
00137 
00142 class MeshExport MeshEvalOrientation : public MeshEvaluation
00143 {
00144 public:
00145     MeshEvalOrientation (const MeshKernel& rclM);
00146     ~MeshEvalOrientation();
00147     bool Evaluate ();
00148     std::vector<unsigned long> GetIndices() const;
00149 
00150 private:
00151     unsigned long HasFalsePositives(const std::vector<unsigned long>&) const;
00152 };
00153 
00158 class MeshExport MeshFixOrientation : public MeshValidation
00159 {
00160 public:
00161     MeshFixOrientation (MeshKernel& rclM);
00162     ~MeshFixOrientation();
00163     bool Fixup();
00164 };
00165 
00166 // ----------------------------------------------------
00167 
00172 class MeshExport MeshEvalSolid : public MeshEvaluation
00173 {
00174 public:
00175   MeshEvalSolid (const MeshKernel& rclM);
00176   ~MeshEvalSolid();
00177   bool Evaluate ();
00178 };
00179 
00180 // ----------------------------------------------------
00181 
00188 class MeshExport MeshEvalTopology : public MeshEvaluation
00189 {
00190 public:
00191     MeshEvalTopology (const MeshKernel &rclB) : MeshEvaluation(rclB) {}
00192     virtual ~MeshEvalTopology () {}
00193     virtual bool Evaluate ();
00194 
00195     void GetFacetManifolds (std::vector<unsigned long> &raclFacetIndList) const;
00196     unsigned long CountManifolds() const;
00197     const std::vector<std::pair<unsigned long, unsigned long> >& GetIndices() const { return nonManifoldList; }
00198     const std::list<std::vector<unsigned long> >& GetFacets() const { return nonManifoldFacets; }
00199 
00200 protected:
00201     std::vector<std::pair<unsigned long, unsigned long> > nonManifoldList;
00202     std::list<std::vector<unsigned long> > nonManifoldFacets;
00203 };
00204 
00209 class MeshExport MeshFixTopology : public MeshValidation
00210 {
00211 public:
00212     MeshFixTopology (MeshKernel &rclB, const std::list<std::vector<unsigned long> >& mf)
00213       : MeshValidation(rclB), nonManifoldList(mf) {}
00214     virtual ~MeshFixTopology () {}
00215     bool Fixup();
00216 
00217 protected:
00218     const std::list<std::vector<unsigned long> >& nonManifoldList;
00219 };
00220 
00221 // ----------------------------------------------------
00222 
00230 class MeshExport MeshEvalSingleFacet : public MeshEvalTopology
00231 {
00232 public:
00233   MeshEvalSingleFacet (const MeshKernel &rclB) : MeshEvalTopology(rclB) {}
00234   virtual ~MeshEvalSingleFacet () {}
00235   bool Evaluate ();
00236 };
00237 
00242 class MeshExport MeshFixSingleFacet : public MeshValidation
00243 {
00244 public:
00245   MeshFixSingleFacet (MeshKernel &rclB, const std::vector<std::list<unsigned long> >& mf)
00246     : MeshValidation(rclB), _raclManifoldList(mf) {}
00247   virtual ~MeshFixSingleFacet () {}
00248   bool Fixup();
00249 
00250 protected:
00251   const std::vector<std::list<unsigned long> >& _raclManifoldList;
00252 };
00253 
00254 // ----------------------------------------------------
00255 
00260 class MeshExport MeshEvalSelfIntersection : public MeshEvaluation
00261 {
00262 public:
00263     MeshEvalSelfIntersection (const MeshKernel &rclB) : MeshEvaluation(rclB) {}
00264     virtual ~MeshEvalSelfIntersection () {}
00266     bool Evaluate ();
00268     void GetIntersections(const std::vector<std::pair<unsigned long, unsigned long> >&,
00269         std::vector<std::pair<Base::Vector3f, Base::Vector3f> >&) const;
00271     void GetIntersections(std::vector<std::pair<unsigned long, unsigned long> >&) const;
00272 };
00273 
00278 class MeshExport MeshFixSelfIntersection : public MeshValidation
00279 {
00280 public:
00281     MeshFixSelfIntersection (MeshKernel &rclB, const std::vector<std::pair<unsigned long, unsigned long> >& si)
00282         : MeshValidation(rclB), selfIntersectons(si) {}
00283     virtual ~MeshFixSelfIntersection () {}
00284     bool Fixup();
00285 
00286 private:
00287     const std::vector<std::pair<unsigned long, unsigned long> >& selfIntersectons;
00288 };
00289 
00290 // ----------------------------------------------------
00291 
00297 class MeshExport MeshEvalNeighbourhood : public MeshEvaluation
00298 {
00299 public:
00300   MeshEvalNeighbourhood (const MeshKernel &rclB) : MeshEvaluation(rclB) {}
00301   ~MeshEvalNeighbourhood () {}
00302   bool Evaluate ();
00303   std::vector<unsigned long> GetIndices() const;
00304 };
00305 
00310 class MeshExport MeshFixNeighbourhood : public MeshValidation
00311 {
00312 public:
00313   MeshFixNeighbourhood (MeshKernel &rclB) : MeshValidation(rclB) {}
00314   ~MeshFixNeighbourhood () {}
00315   bool Fixup();
00316 };
00317 
00318 // ----------------------------------------------------
00319 
00328 class MeshExport MeshEigensystem : public MeshEvaluation
00329 {
00330 public:
00331   MeshEigensystem (const MeshKernel &rclB);
00332   virtual ~MeshEigensystem () {}
00333 
00335   Base::Matrix4D Transform() const;
00339   Base::Vector3f GetBoundings() const;
00340 
00341   bool Evaluate();
00346 protected:
00347   void CalculateLocalSystem();
00348 
00349 private:
00350   Base::Vector3f _cU, _cV, _cW, _cC; 
00351   float _fU, _fV, _fW; 
00352 };
00353 
00354 } // namespace MeshCore
00355 
00356 #endif // MESH_EVALUATION_H

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