OpenLexocad  27.1
ComplexGeoData.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
3  * *
4  * This file is part of the FreeCAD CAx development system. *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Library General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Library General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Library General Public *
17  * License along with this library; see the file COPYING.LIB. If not, *
18  * write to the Free Software Foundation, Inc., 59 Temple Place, *
19  * Suite 330, Boston, MA 02111-1307, USA *
20  * *
21  ***************************************************************************/
22 
23 
24 #ifndef _AppComplexGeoData_h_
25 #define _AppComplexGeoData_h_
26 
27 #include <Base/Placement.h>
28 #include <Base/Persistence.h>
29 #include <Base/Handle.h>
30 #include <Base/Matrix.h>
31 #include <Base/BoundBox.h>
32 #include <Base/Rotation.h>
33 
34 #ifdef __GNUC__
35 # include <stdint.h>
36 #endif
37 
38 
39 namespace Data
40 {
41 
46 class LX_CORE_EXPORT Segment: public Base::BaseClass
47 {
49 
50 public:
51  virtual ~Segment(){}
52  virtual std::string getName() const=0;
53 };
54 
55 
58 class LX_CORE_EXPORT ComplexGeoData: public Base::Persistence, public Base::Handled
59 {
61 
62 public:
63  struct Line {uint32_t I1; uint32_t I2;};
64  struct Facet {uint32_t I1; uint32_t I2; uint32_t I3;};
65  struct Domain {
66  std::vector<Base::Vector3d> points;
67  std::vector<Facet> facets;
68  };
69 
71  ComplexGeoData(void);
73  virtual ~ComplexGeoData();
74 
81  virtual std::vector<const char*> getElementTypes(void) const=0;
82  virtual unsigned long countSubElements(const char* Type) const=0;
84  virtual Segment* getSubElement(const char* Type, unsigned long) const=0;
86  virtual Segment* getSubElementByName(const char* Name) const;
88  virtual void getLinesFromSubelement(
89  const Segment*,
90  std::vector<Base::Vector3d> &Points,
91  std::vector<Line> &lines) const;
93  virtual void getFacesFromSubelement(
94  const Segment*,
95  std::vector<Base::Vector3d> &Points,
96  std::vector<Base::Vector3d> &PointNormals,
97  std::vector<Facet> &faces) const;
99 
103  void applyTransform(const Base::Matrix4D& rclTrf);
105  void applyTranslation(const Base::Vector3d&);
107  void applyRotation(const Base::Rotation&);
111  void setPlacement(const Base::Placement& rclPlacement);
115  Base::Placement getPlacement() const;
120  virtual void setTransform(const Base::Matrix4D& rclTrf)=0;
125  virtual Base::Matrix4D getTransform(void) const = 0;
127 
130  virtual void transformGeometry(const Base::Matrix4D &rclMat) = 0;
133 
136  virtual Base::BoundBox3d getBoundBox(void)const=0;
139  virtual Base::Vector3d getPointFromLineIntersection(
140  const Base::Vector3f& base,
141  const Base::Vector3f& dir) const;
143  virtual void getPoints(std::vector<Base::Vector3d> &Points,
144  std::vector<Base::Vector3d> &Normals,
145  float Accuracy, uint16_t flags=0) const;
147  virtual void getLines(std::vector<Base::Vector3d> &Points,std::vector<Line> &lines,
148  float Accuracy, uint16_t flags=0) const;
150  virtual void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &faces,
151  float Accuracy, uint16_t flags=0) const;
156  virtual bool getCenterOfGravity(Base::Vector3d& center) const;
158 
161  static const std::string &elementMapPrefix();
164  static const std::string &tagPostfix();
166  static const std::string &indexPostfix();
168  static const std::string &missingPrefix();
170  static bool hasMissingElement(const char *subname);
177  static const char *isMappedElement(const char *name);
178 
180  static std::string newElementName(const char *name);
182  static std::string oldElementName(const char *name);
184  static std::string noElementName(const char *name);
185 
187  static const char *findElementName(const char *subname);
188 
189  static inline const char *hasMappedElementName(const char *subname) {
190  return isMappedElement(findElementName(subname));
191  }
193 
194 protected:
195 
198  {
199  return getTransform() * Base::Vector3d(vec.x,vec.y,vec.z);
200  }
203  {
204  Base::Matrix4D tmpM(getTransform());
205  tmpM.inverse();
206  Base::Vector3d tmp = tmpM * vec;
207  return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z);
208  }
209 public:
210  mutable long Tag;
211 };
212 
213 } //namespace App
214 
215 
216 #endif
_Precision z
Definition: Vector3D.h:89
virtual ~Segment()
Definition: ComplexGeoData.h:51
_Precision y
Definition: Vector3D.h:88
std::vector< Base::Vector3d > points
Definition: ComplexGeoData.h:66
Definition: ComplexGeoData.h:58
Definition: ComplexGeoData.h:39
Core::PropertyText name
Definition: CoreDocument.h:167
Base::Vector3d transformToOutside(const Base::Vector3f &vec) const
from local to outside
Definition: ComplexGeoData.h:197
Vector3< double > Vector3d
Definition: Vector3D.h:248
_Precision x
Definition: Vector3D.h:87
Persistence class and root of the type system.
Definition: Persistence.h:23
long Tag
Definition: ComplexGeoData.h:210
Vector3< float > Vector3f
Definition: Vector3D.h:247
void inverse(void)
Matrix is expected to have a 3x3 rotation submatrix.
BaseClass class and root of the type system.
Definition: Base.h:85
Definition: Handle.h:161
static const char * hasMappedElementName(const char *subname)
Definition: ComplexGeoData.h:189
Base::Vector3f transformToInside(const Base::Vector3d &vec) const
from local to inside
Definition: ComplexGeoData.h:202
Definition: Matrix.h:38
Definition: ComplexGeoData.h:46
Definition: ComplexGeoData.h:64
uint32_t I2
Definition: ComplexGeoData.h:63
Definition: ComplexGeoData.h:65
std::vector< Facet > facets
Definition: ComplexGeoData.h:67
Definition: Placement.h:38
TYPESYSTEM_HEADER()
Definition: BoundBox.h:39
Definition: Rotation.h:34
Definition: ComplexGeoData.h:63
uint32_t I3
Definition: ComplexGeoData.h:64