OpenLexocad  28.0
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 #pragma once
25 
26 #include <Base/Placement.h>
27 #include <Base/Persistence.h>
28 #include <Base/Handle.h>
29 #include <Base/BoundBox.h>
30 namespace Core { class CoreDocument; }
31 
32 
33 
34 namespace Data
35 {
36 
41 class LX_CORE_EXPORT Segment: public Base::BaseClass
42 {
44 
45 public:
46  virtual ~Segment(){}
47  virtual std::string getName() const=0;
48 };
49 
50 
53 class LX_CORE_EXPORT ComplexGeoData: public Base::Persistence, public Base::Handled
54 {
56 
57 public:
58  struct Line {uint32_t I1; uint32_t I2;};
59  struct Facet {uint32_t I1; uint32_t I2; uint32_t I3;};
60  struct Domain {
61  std::vector<Base::Vector3d> points;
62  std::vector<Facet> facets;
63  };
64 
67 
74  virtual std::vector<const char*> getElementTypes(void) const=0;
75  virtual unsigned long countSubElements(const char* Type) const=0;
77  virtual Segment* getSubElement(const char* Type, unsigned long) const=0;
79  virtual Segment* getSubElementByName(const char* Name) const;
81  virtual void getLinesFromSubelement(
82  const Segment*,
83  std::vector<Base::Vector3d> &Points,
84  std::vector<Line> &lines) const;
86  virtual void getFacesFromSubelement(
87  const Segment*,
88  std::vector<Base::Vector3d> &Points,
89  std::vector<Base::Vector3d> &PointNormals,
90  std::vector<Facet> &faces) const;
92 
96  void applyTransform(const Base::Matrix4D& rclTrf);
104  void setPlacement(const Base::Placement& rclPlacement);
113  virtual void setTransform(const Base::Matrix4D& rclTrf)=0;
118  virtual Base::Matrix4D getTransform(void) const = 0;
120 
123  virtual void transformGeometry(const Base::Matrix4D &rclMat) = 0;
126 
129  virtual Base::BoundBox3d getBoundBox(void)const=0;
133  const Base::Vector3f& base,
134  const Base::Vector3f& dir) const;
136  virtual void getPoints(std::vector<Base::Vector3d> &Points,
137  std::vector<Base::Vector3d> &Normals,
138  float Accuracy, uint16_t flags=0) const;
140  virtual void getLines(std::vector<Base::Vector3d> &Points,std::vector<Line> &lines,
141  float Accuracy, uint16_t flags=0) const;
143  virtual void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &faces,
144  float Accuracy, uint16_t flags=0) const;
149  virtual bool getCenterOfGravity(Base::Vector3d& center) const;
151 
154  static const std::string &elementMapPrefix();
157  static const std::string &tagPostfix();
159  static const std::string &indexPostfix();
161  static const std::string &missingPrefix();
163  static bool hasMissingElement(const char *subname);
170  static const char *isMappedElement(const char *name);
171 
173  static std::string newElementName(const char *name);
175  static std::string oldElementName(const char *name);
177  static std::string noElementName(const char *name);
178 
180  static const char *findElementName(const char *subname);
181 
182  static inline const char *hasMappedElementName(const char *subname) {
183  return isMappedElement(findElementName(subname));
184  }
186 
187 protected:
188 
191  {
192  return getTransform() * Base::Vector3d(vec.x,vec.y,vec.z);
193  }
196  {
197  Base::Matrix4D tmpM(getTransform());
198  tmpM.inverse();
199  Base::Vector3d tmp = tmpM * vec;
200  return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z);
201  }
202 public:
203  mutable long Tag;
204 };
205 
206 } //namespace App
207 
Data::ComplexGeoData::Domain::points
std::vector< Base::Vector3d > points
Definition: ComplexGeoData.h:61
Base::BaseClass
BaseClass class and root of the type system.
Definition: Base.h:78
Data::ComplexGeoData::Domain::facets
std::vector< Facet > facets
Definition: ComplexGeoData.h:62
Data::ComplexGeoData::applyTransform
void applyTransform(const Base::Matrix4D &rclTrf)
Data::ComplexGeoData::getCenterOfGravity
virtual bool getCenterOfGravity(Base::Vector3d &center) const
Data::ComplexGeoData::getFacesFromSubelement
virtual void getFacesFromSubelement(const Segment *, std::vector< Base::Vector3d > &Points, std::vector< Base::Vector3d > &PointNormals, std::vector< Facet > &faces) const
Data::ComplexGeoData::findElementName
static const char * findElementName(const char *subname)
Find the start of an element name in a subname.
Base::Vector3::y
_Precision y
Definition: Vector3D.h:86
Data::ComplexGeoData::indexPostfix
static const std::string & indexPostfix()
Special postfix to mark the index of an array element.
Base::Placement
Definition: Placement.h:56
Base::Vector3::z
_Precision z
Definition: Vector3D.h:87
Base::Handled
Definition: Handle.h:159
Base::Persistence
Persistence class and root of the type system.
Definition: Persistence.h:22
Data
Definition: ComplexGeoData.h:35
Data::ComplexGeoData::getLines
virtual void getLines(std::vector< Base::Vector3d > &Points, std::vector< Line > &lines, float Accuracy, uint16_t flags=0) const
Data::ComplexGeoData::Line
Definition: ComplexGeoData.h:58
Data::ComplexGeoData::Facet::I3
uint32_t I3
Definition: ComplexGeoData.h:59
Data::ComplexGeoData::getPointFromLineIntersection
virtual Base::Vector3d getPointFromLineIntersection(const Base::Vector3f &base, const Base::Vector3f &dir) const
Data::ComplexGeoData::countSubElements
virtual unsigned long countSubElements(const char *Type) const =0
Data::ComplexGeoData::Facet
Definition: ComplexGeoData.h:59
Base::Vector3::x
_Precision x
Definition: Vector3D.h:85
Data::ComplexGeoData::getSubElement
virtual Segment * getSubElement(const char *Type, unsigned long) const =0
get the subelement by type and number
Data::ComplexGeoData::setPlacement
void setPlacement(const Base::Placement &rclPlacement)
Base::BoundBox3
Definition: BoundBox.h:56
Data::ComplexGeoData::isMappedElement
static const char * isMappedElement(const char *name)
Data::ComplexGeoData::Tag
long Tag
Definition: ComplexGeoData.h:203
Persistence.h
Core
Definition: Base.h:5
Data::ComplexGeoData::tagPostfix
static const std::string & tagPostfix()
Special postfix to mark the following tag.
Handle.h
Base::Vector3< double >
Placement.h
Base::Vector3d
Vector3< double > Vector3d
Definition: Vector3D.h:246
Data::ComplexGeoData::setTransform
virtual void setTransform(const Base::Matrix4D &rclTrf)=0
Data::ComplexGeoData::oldElementName
static std::string oldElementName(const char *name)
Strip out the mapped element name if there is one.
Data::ComplexGeoData::getLinesFromSubelement
virtual void getLinesFromSubelement(const Segment *, std::vector< Base::Vector3d > &Points, std::vector< Line > &lines) const
Data::ComplexGeoData::getPoints
virtual void getPoints(std::vector< Base::Vector3d > &Points, std::vector< Base::Vector3d > &Normals, float Accuracy, uint16_t flags=0) const
Data::ComplexGeoData::newElementName
static std::string newElementName(const char *name)
Strip out the trailing element name if there is mapped element name precedes it.
BoundBox.h
Data::ComplexGeoData
Definition: ComplexGeoData.h:54
Data::ComplexGeoData::getPlacement
Base::Placement getPlacement() const
Data::ComplexGeoData::applyRotation
void applyRotation(const Base::Rotation &)
Base::Rotation
Definition: Rotation.h:53
Data::ComplexGeoData::transformToInside
Base::Vector3f transformToInside(const Base::Vector3d &vec) const
from local to inside
Definition: ComplexGeoData.h:195
Data::ComplexGeoData::Domain
Definition: ComplexGeoData.h:60
Data::ComplexGeoData::noElementName
static std::string noElementName(const char *name)
Strip out the old and new element name if there is one.
Data::ComplexGeoData::ComplexGeoData
ComplexGeoData(void)
Constructor.
Data::ComplexGeoData::hasMappedElementName
static const char * hasMappedElementName(const char *subname)
Definition: ComplexGeoData.h:182
Data::ComplexGeoData::applyTranslation
void applyTranslation(const Base::Vector3d &)
Base::Matrix4D
Definition: Matrix.h:55
Data::ComplexGeoData::getFaces
virtual void getFaces(std::vector< Base::Vector3d > &Points, std::vector< Facet > &faces, float Accuracy, uint16_t flags=0) const
Data::Segment::~Segment
virtual ~Segment()
Definition: ComplexGeoData.h:46
Data::ComplexGeoData::transformToOutside
Base::Vector3d transformToOutside(const Base::Vector3f &vec) const
from local to outside
Definition: ComplexGeoData.h:190
TYPESYSTEM_HEADER
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
Data::ComplexGeoData::getTransform
virtual Base::Matrix4D getTransform(void) const =0
Base::Vector3f
Vector3< float > Vector3f
Definition: Vector3D.h:245
Base::Matrix4D::inverse
void inverse(void)
Matrix is expected to have a 3x3 rotation submatrix.
Data::ComplexGeoData::Line::I2
uint32_t I2
Definition: ComplexGeoData.h:58
Data::Segment
Definition: ComplexGeoData.h:42
Data::Segment::getName
virtual std::string getName() const =0
Data::ComplexGeoData::hasMissingElement
static bool hasMissingElement(const char *subname)
Check if a subname contains missing element.
Data::ComplexGeoData::getSubElementByName
virtual Segment * getSubElementByName(const char *Name) const
get subelement by combined name
Data::ComplexGeoData::getElementTypes
virtual std::vector< const char * > getElementTypes(void) const =0
Data::ComplexGeoData::missingPrefix
static const std::string & missingPrefix()
Special prefix to mark a missing element.