NDEVR
API Documentation
BlockModel.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: BlockModel
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include "Design/Headers/Model.h"
35#include "Design/Headers/Material.h"
36#include "Design/Headers/GriddedMesh.h"
37namespace NDEVR
38{
42 class BLOCK_MODEL_API BlockGeometry : public GridMesh<3>
43 {
44 public:
45 BlockGeometry()
46 {}
47 explicit BlockGeometry(const Geometry& model)
48 : GridMesh<3>(model)
49 {}
50
51 inline uint04 convertToIndex(uint04 x, uint04 y, uint04 z) const
52 {
53 return GridMesh<3>::convertToIndex(Vector<3, uint04>(x, y, z));
54 }
55 inline uint04 convertToIndex(Vector<3, uint04> vec) const
56 {
57 return GridMesh<3>::convertToIndex(vec);
58 }
59 bool isBlockVisible(uint04 x, uint04 y, uint04 z);
60
61 bool processSelection(SelectionInfo& info) const;
62
63 template<class t_type>
64 void setBlockVertex(VertexProperty property, uint04 x, uint04 y, uint04 z, const t_type& vector)
65 {
66 m_geo.setVertex(property, convertToIndex(x, y, z), vector);
67 }
68 template<class t_type>
69 t_type blockVertex(VertexProperty property, uint04 x, uint04 y, uint04 z) const
70 {
71 return m_geo.vertex<t_type>(property, convertToIndex(x, y, z));
72 }
73
74 template<class t_type>
75 void setVertexProperty(uint04 extra_property_index, uint04 x, uint04 y, uint04 z, const t_type& vector)
76 {
77 m_geo.setVertexProperty(extra_property_index, convertToIndex(x, y, z), vector);
78 }
79 template<class t_type>
80 t_type vertexProperty(uint04 extra_property_index, uint04 x, uint04 y, uint04 z) const
81 {
82 return m_geo.vertexProperty<t_type>(extra_property_index, convertToIndex(x, y, z));
83 }
84 void pointKriging(const Matrix<fltp08>& mat, Geometry sample_data, LogPtr log = LogPtr());
85 void lineKriging(const Matrix<fltp08>& mat, Geometry sample_data, LogPtr log = LogPtr());
86 void triangulate(const Matrix<fltp08>& matrix, LogPtr log = LogPtr());
87 void calculateTangentSpace(bool calc_tan, bool calc_bitan);
88 void calculatePrimitiveIndices();
89 static constexpr StringView TypeName() { return "block_model"; }
90 static void KrigeModel(Geometry& block_model, const Geometry& model, Vector<3, fltp08> block_size, LogPtr log = LogPtr());
91
92 };
93
98 class NDEVR_DESIGN_API BlockModel : public Model
99 {
100 public:
101 explicit BlockModel(const Model& model)
102 : Model(model)
103 , m_geometry(getGeometry())
104 {
105 if (!m_geometry.isValid())
106 m_geometry = BlockGeometry(createChildGeometry());
107 if (!is<NDPN::type>(TypeName()))
108 {
109 set<NDPN::type>(TypeName());
110
113 mat.set<NDPM::grid_line_spacing>(Vector<4, fltp04>(1, 1, 1, Constant<fltp04>::Invalid));
114 mat.set<NDPM::two_sided>(true);
116 mat.set<NDPM::pixel_thickness>(3.0);
118 mat.setUVColor(UVType::e_KD, RGBColor(128, 128, 128));
119 }
120 }
121
122 static const char* TypeName() { return "block_model"; }
123 const BlockGeometry& blockGeometry() const { return m_geometry; }
124 BlockGeometry& blockGeometry() { return m_geometry; }
125 protected:
126 BlockGeometry m_geometry;
127 };
128};
129
130
131
void set(t_property_type property, const t_type &value)
Sets a property value in the database.
bool is(t_property_type property, const StringView &value) const
Checks whether a string property matches the given StringView value.
Stores a uniform grid of data in N dimensions into a Geometry object.
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
void setUVColor(const t_type &type)
Sets the color for all UV channels to the same value.
Definition Material.h:382
@ e_no_shading
No shading applied. Constant light influence of 1.0.
Definition Material.h:171
@ e_modelspace_linework
Gridlines rendered in model-local coordinate space.
Definition Material.h:206
@ e_solid_color
A single solid color is used.
Definition Material.h:187
void setUVMode(UVType uv_index, const UVMode &type)
Sets the UV mapping mode for the specified UV channel.
Geometry getGeometry() const
Returns the geometry attached to this model.
Geometry createChildGeometry()
Creates a new child geometry for this model.
Model()
Default constructor. Creates an uninitialized Model.
Definition Model.h:365
Material createChildMaterial(bool copy_child=false)
Creates a new child material for this model.
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
@ pixel_thickness
Thickness in pixels for line and point rendering.
Definition Material.h:62
@ shading_model
The shading model index used for rendering (see Material::ShadingModel).
Definition Material.h:55
@ gridline_spacing_mode
Mode controlling how gridline spacing is interpreted.
Definition Material.h:64
@ grid_line_spacing
Spacing values for gridline rendering (4-component vector).
Definition Material.h:63
@ two_sided
Whether the material is rendered on both sides of a face.
Definition Material.h:54
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ e_KD
Diffuse texture/color channel.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408