HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Solidify.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU Library (C++)
7  *
8  * COMMENTS: Determines which tetrahedra should be considered part of a solid
9  * object and which should not
10  */
11 
12 #ifndef __GU_Solidify_h__
13 #define __GU_Solidify_h__
14 
15 #include <GEO/GEO_PrimPoly.h>
17 #include <UT/UT_Interrupt.h>
18 #include <UT/UT_UniquePtr.h>
19 #include <UT/UT_SparseMatrix.h>
20 #include <UT/UT_Vector.h>
21 #include <UT/UT_MatrixSolver.h>
22 #include <vector>
23 #include "GU_TetConnectivity.h"
24 
25 //#define USE_EIGEN
26 
27 #ifdef USE_EIGEN
28 #include <Eigen/Sparse>
29 #include <Eigen/IterativeLinearSolvers>
30 #endif
31 
33 {
34 private:
35 #ifdef USE_EIGEN
36  typedef Eigen::SparseMatrix<double> MatrixType;
37  typedef Eigen::SparseLU<MatrixType> SolverType;
38  //typedef Eigen::ConjugateGradient<MatrixType, Eigen::Lower|Eigen::Upper> SolverType;
39  typedef Eigen::VectorXd VectorType;
40  typedef Eigen::Triplet<double> TripletType;
41 #else
46 #endif
47 
48  // fills given interiorgrp with tets not on the boundary of the tetrahedralization
49  void findInteriorTets(
50  const GU_TetrahedronAdjacency& adjacency,
51  const GA_PrimitiveGroup *search_grp,
52  GA_PrimitiveGroup* interiorgrp);
53 
54 public:
55 
57  : mySrc(nullptr)
58  { }
60 
61  enum Status
62  {
63  SUCCESS = 0,
67  };
68 
69  Status solidify(const GU_Detail *gdp,
70  const GA_PrimitiveGroup *tet_grp,
71  const GA_PrimitiveGroup *poly_grp);
72 
74  {
75  if ( !mySrc ) return false;
76  return myTetSolidityIndex[mySrc->primitiveIndex(tet)] != -1;
77  }
78 
80  {
81  if ( !mySrc )
82  return -1.0;
83  auto idx = myTetSolidityIndex[mySrc->primitiveIndex(tet)];
84  if ( idx == -1 )
85  return -1.0; // not solid by default
86 #ifdef USE_EIGEN
87  return mySolidity[idx];
88 #else
89  return mySolidity(idx);
90 #endif
91  }
92  const GU_Detail* getSrc() { return mySrc; }
93  const GA_PrimitiveGroup* getTetGrp() { return myTetGrp; }
94  const GA_PrimitiveGroup* getPolyGrp() { return myPolyGrp; }
95 
96 private:
97  const GU_Detail *mySrc;
98  const GA_PrimitiveGroup *myTetGrp;
99  const GA_PrimitiveGroup *myPolyGrp;
100  UT_ExintArray myTetSolidityIndex; // GA_Index -> system index map
101  VectorType mySolidity;
102 };
103 
104 #endif // __GU_Solidify_h__
const GU_Detail * getSrc()
Definition: GU_Solidify.h:92
fpreal getSolidity(GA_Offset tet)
Definition: GU_Solidify.h:79
GA_Size GA_Offset
Definition: GA_Types.h:617
const GA_PrimitiveGroup * getPolyGrp()
Definition: GU_Solidify.h:94
const GA_PrimitiveGroup * getTetGrp()
Definition: GU_Solidify.h:93
#define GU_API
Definition: GU_API.h:12
double fpreal
Definition: SYS_Types.h:270
bool hasValidSolidity(GA_Offset tet)
Definition: GU_Solidify.h:73