iMSTK
Interactive Medical Simulation Toolkit
imstkConnectiveStrandGenerator.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkGeometryAlgorithm.h"
10 #include "imstkDataArray.h"
11 
12 #include <random>
13 namespace imstk
14 {
15 class PointSet;
16 class SurfaceMesh;
17 class LineMesh;
18 
31 {
32 public:
34  ~ConnectiveStrandGenerator() override = default;
35 
36  void setInputMeshes(
37  std::shared_ptr<SurfaceMesh> inputMeshA,
38  std::shared_ptr<SurfaceMesh> inputMeshB);
39 
40  std::shared_ptr<LineMesh> getOutputMesh() const;
41 
46  void setSegmentsPerStrand(int numSegs) { m_segmentsPerStrand = numSegs; }
47  int getSegmentsPerStrand() { return m_segmentsPerStrand; }
49 
54  void setStrandsPerFace(double density) { m_strandsPerFace = density; }
55  double getStrandsPerFace() { return m_strandsPerFace; }
57 
58  void setAllowedAngleDeviation(double angle) { m_allowedAngleDeviation = angle; }
59  double getAllowedAgnleDeviation() const { return m_allowedAngleDeviation; }
60 
61 protected:
62  void requestUpdate() override;
63 
66  std::vector<int> filterCells(SurfaceMesh* meshA, SurfaceMesh* meshB) const;
67 
75  std::shared_ptr<LineMesh> createStrands(
76  SurfaceMesh* meshA,
77  const std::vector<int>& faces,
78  SurfaceMesh* meshB) const;
79 
81  const Vec3d generateRandomPointOnFace(SurfaceMesh* mesh, int face) const;
82 
83  int m_segmentsPerStrand = 3;
84  double m_strandsPerFace = 1;
85  double m_allowedAngleDeviation = PI;
86 };
87 } // namespace imstk
This filter takes in two surface meshes and generates a LineMesh that connectes the faces of the two ...
void setSegmentsPerStrand(int numSegs)
Get/Set the number of segments each connective strand is made of. Defaults to 3.
Compound Geometry.
void requestUpdate() override
Users can implement this for the logic to be run.
std::vector< int > filterCells(SurfaceMesh *meshA, SurfaceMesh *meshB) const
Filter faces on meshA to remove those facing away from meshB Checks nearest faces, if nearest face normal points in same general direction then ignore.
Abstract base class for geometry algorithms. GeometryAlgorithms take N input geometries and produce N...
Represents a set of triangles & vertices via an array of Vec3d double vertices & Vec3i integer indice...
void setStrandsPerFace(double density)
Get/Set the number of of connective strands attached to each face Defaults to 1.
const Vec3d generateRandomPointOnFace(SurfaceMesh *mesh, int face) const
std::shared_ptr< LineMesh > createStrands(SurfaceMesh *meshA, const std::vector< int > &faces, SurfaceMesh *meshB) const
Creates a line mesh by connecting points of the given faces of meshA with with random points on rando...