preliminary tool to import from BRL-CAD
[engrid.git] / src / libengrid / createcadtesselation.h
blob2160c485da604e7168e42b4100aad6d15c6cbdb5
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008-2012 enGits GmbH +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef CREATECADTESSELATION_H
24 #define CREATECADTESSELATION_H
26 #include "operation.h"
28 class CreateCadTesselation : public Operation
31 protected: // attributes
33 vec3_t m_X1;
34 vec3_t m_X2;
35 vec3_t m_XScan1;
36 vec3_t m_XScan2;
37 int m_Ni;
38 int m_Nj;
39 int m_Nk;
40 double m_Dx;
41 double m_Dy;
42 double m_Dz;
43 double m_ScanMemory;
44 bool m_GeometryFound;
45 int m_NumIterations;
46 int m_PreservationType;
47 double m_SmallestFeatureSize;
49 protected: // methods
51 virtual bool shootRay(vec3_t x, vec3_t v, vec3_t &x_in, vec3_t &x_out, vec3_t &n_in, vec3_t &n_out) = 0;
52 virtual void operate();
54 void scan(bool create_grid, int interlaces = 0);
56 double getx(int i) { return m_X1[0] + i*m_Dx; }
57 double gety(int j) { return m_X1[1] + j*m_Dy; }
58 double getz(int k) { return m_X1[2] + k*m_Dz; }
59 vec3_t getX(int i, int j, int k) { return vec3_t(getx(i), gety(j), getz(k)); }
60 int getIdx(int i, int j, int k) { return i + j*m_Ni + k*m_Ni*m_Nj; }
62 public: // methods
64 CreateCadTesselation();
66 void setScanMemory(double mem) { m_ScanMemory = mem; }
67 void setPreservationOff() { m_PreservationType = 0; }
68 void setSolidPreservation() { m_PreservationType = 1; }
69 void setFluidPreservation() { m_PreservationType = 2; }
70 void setPreservationType(int t) { m_PreservationType = t; }
71 void setSmoothingIterations(int n) { m_NumIterations = n; }
72 bool preserveSolid() { return m_PreservationType == 1; }
73 bool preserveFluid() { return m_PreservationType == 2; }
74 void setSmallestFeatureSize(double sfs) { m_SmallestFeatureSize = sfs; }
78 #endif // CREATECADTESSELATION_H