5#include "ColorMapping.h"
10 template<
typename TDataType>
16 auto colorMapper = std::make_shared<ColorMapping<DataType3f>>();
17 colorMapper->varMin()->setValue(-0.5);
18 colorMapper->varMax()->setValue(0.5);
19 this->stateField()->connect(colorMapper->inScalar());
23 auto surfaceVisualizer = std::make_shared<GLSurfaceVisualModule>();
24 surfaceVisualizer->varColorMode()->getDataPtr()->setCurrentKey(1);
25 colorMapper->outColor()->connect(surfaceVisualizer->inColor());
26 this->stateTriangleSet()->connect(surfaceVisualizer->inTriangleSet());
30 template<
typename TDataType>
35 template<
typename TDataType>
38 auto center = this->varTranslation()->getValue();
39 auto eulerAngles = this->varRotation()->getValue();
41 eulerAngles /= 180.0f;
44 auto levelSet = this->inLevelSet()->getDataPtr()->getSDF();
46 Coord lo = levelSet.lowerBound();
47 Coord hi = levelSet.upperBound();
51 int nx = levelSet.nx() - 1;
52 int ny = levelSet.ny() - 1;
53 int nz = levelSet.nz() - 1;
57 Coord shifted_center = center + 0.5 * (lo + hi);
62 int totalVNum = reduce.
accumulate(voxelVertNum.begin(), voxelVertNum.size());
65 scan.
exclusive(voxelVertNum.begin(), voxelVertNum.size());
67 this->stateField()->resize(totalVNum);
74 this->stateField()->getData(),
81 auto triSet = this->stateTriangleSet()->getDataPtr();
82 triSet->setPoints(vertices);
83 triSet->setTriangles(triangles);
#define DEFINE_CLASS(name)
static void constructTrianglesForClipper(DArray< Real > &field, DArray< Coord > &vertices, DArray< TopologyModule::Triangle > &triangles, DArray< int > &vertNum, DistanceField3D< TDataType > &sdf, TPlane3D< Real > plane)
static void countVerticeNumberForClipper(DArray< int > &num, DistanceField3D< TDataType > &sdf, TPlane3D< Real > plane)
std::shared_ptr< GraphicsPipeline > graphicsPipeline()
static DYN_FUNC Quat< Real > fromEulerAngles(const Real &yaw, const Real &pitch, const Real &roll)
DYN_FUNC Vector< Real, 3 > rotate(const Vector< Real, 3 > &v) const
Rotate a vector by the quaternion, guarantee the quaternion is normalized before rotating the vector.
T accumulate(const T *val, const uint num)
void exclusive(T *output, const T *input, size_t length, bool bcao=true)
2D geometric primitives in three-dimensional space
~VolumeClipper() override
void resetStates() override
This is an implementation of AdditiveCCD based on peridyno.
Array< T, DeviceType::GPU > DArray