8 std::string filename = file_path + vtk_file;
30 bool reading_points =
false;
31 bool reading_tets =
false;
35 size_t indices_count = 0;
36 while (std::getline(fs, line))
38 std::stringstream ss(line);
39 if (line.size() == (
size_t)(0))
42 else if (line.substr(0, 6) ==
"POINTS")
44 reading_points =
true;
50 else if (line.substr(0, 5) ==
"CELLS")
52 reading_points =
false;
58 else if (line.substr(0, 10) ==
"CELL_TYPES")
60 reading_points =
false;
63 else if (reading_points)
73 X[x_count++] = position;
75 else if (reading_tets)
81 printf(
"Load deformable failed: Only Tetrahedra are supported in VTK file.\n");
88 for (
size_t i = 0; i < 4; i++)
94 indices[indices_count++] = tet;
99 for (
int i = 0; i < n_tets; ++i)
101 const Index& ni = indices[i];
130 std::string eigenvalues_file = std::string(file_path) +
"eigenvalues.bin";
133 std::string Kr_file = std::string(file_path) +
"K_r_diag_mat.bin";
139 std::string modes_file = std::string(file_path) +
"modes.bin";
143 std::string M_file = std::string(file_path) +
"M_diag_mat.bin";
157 const unsigned int n_size,
160 std::ifstream f_in(file, std::ios::in | std::ios::binary);
163 f_in.read((
char*)&
size, 4);
169 for (
unsigned int i = 0; i < n_size; ++i)
171 f_in.read((
char*)&temp,
sizeof(
double));
179 const unsigned int n_modes,
180 const unsigned int n_full,
183 std::ifstream f_in(file, std::ios::in | std::ios::binary);
185 unsigned int v_size=0;
186 f_in.read((
char*)&v_size, 4);
187 btAssert(v_size >= n_modes * n_full);
191 for (
int i = 0; i < n_modes; ++i)
193 for (
int j = 0; j < n_full; ++j)
196 f_in.read((
char*)&temp,
sizeof(
double));
198 if (mat[i].
size() != n_modes)
213 mass / (
btScalar(12.0)) * (lx * lx + lz * lz),
214 mass / (
btScalar(12.0)) * (lx * lx + ly * ly));
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void setReducedModes(int num_modes, int full_size)
void disableReducedModes(const bool rigid_only)
void setMassProps(const tDenseArray &mass_array)
tDenseArray m_eigenvalues
void internalInitialization()
btAlignedObjectArray< TetraScratch > m_tetraScratchesTn
void appendTetra(int model, Material *mat)
btAlignedObjectArray< TetraScratch > m_tetraScratches
void appendLink(int model=-1, Material *mat=0)
void initializeDmInverse()
btVector3 can be used to represent 3D points and vectors.
void setZ(btScalar _z)
Set the z value.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
void setY(btScalar _y)
Set the y value.
void setX(btScalar _x)
Set the x value.
static void readBinaryMat(btReducedDeformableBody::tDenseMatrix &mat, const unsigned int n_modes, const unsigned int n_full, const char *file)
static void readBinaryVec(btReducedDeformableBody::tDenseArray &vec, const unsigned int n_size, const char *file)
static btReducedDeformableBody * createFromVtkFile(btSoftBodyWorldInfo &worldInfo, const char *vtk_file)
static btReducedDeformableBody * createReducedDeformableObject(btSoftBodyWorldInfo &worldInfo, const std::string &file_path, const std::string &vtk_file, const int num_modes, bool rigid_only)
static void calculateLocalInertia(btVector3 &inertia, const btScalar mass, const btVector3 &half_extents, const btVector3 &margin)
static void readReducedDeformableInfoFromFiles(btReducedDeformableBody *rsb, const char *file_path)
static void generateBoundaryFaces(btSoftBody *psb)