12 #ifndef smtk_mesh_core_Interface_h
13 #define smtk_mesh_core_Interface_h
15 #include "smtk/CoreExports.h"
18 #include "smtk/mesh/core/CellTraits.h"
19 #include "smtk/mesh/core/CellTypes.h"
20 #include "smtk/mesh/core/DimensionTypes.h"
21 #include "smtk/mesh/core/FieldTypes.h"
22 #include "smtk/mesh/core/Handle.h"
23 #include "smtk/mesh/core/TypeSet.h"
34 class ContainsFunctor;
35 class PointConnectivity;
42 virtual bool allocatePoints(
43 std::size_t numPointsToAlloc,
44 smtk::mesh::Handle& firstVertexHandle,
45 std::vector<double*>& coordinateMemory) = 0;
47 virtual bool allocateCells(
49 std::size_t numCellsToAlloc,
51 smtk::mesh::HandleRange& createdCellIds,
52 smtk::mesh::Handle*& connectivityArray) = 0;
54 template<
int CellType>
56 std::size_t numCellsToAlloc,
57 smtk::mesh::HandleRange& createdCellIds,
58 smtk::mesh::Handle*& connectivityArray)
63 return this->allocateCells(
64 cellType, numCellsToAlloc, Traits::NUM_VERTICES, createdCellIds, connectivityArray);
67 virtual bool connectivityModified(
68 const smtk::mesh::HandleRange& cellsToUpdate,
70 const smtk::mesh::Handle* connectivityArray) = 0;
84 virtual bool reserveNumberOfCoordinates(std::size_t nCoordinates) = 0;
85 virtual bool setCoordinate(std::size_t coord,
double* xyz) = 0;
91 virtual bool addCell(
smtk::mesh::CellType ctype,
int* pointIds, std::size_t nCoordinates = 0) = 0;
93 virtual bool flush() = 0;
95 virtual smtk::mesh::HandleRange cells() = 0;
97 bool setCoordinate(std::size_t coord,
double x,
double y,
double z)
99 double xyz[3] = { x, y, z };
100 return this->setCoordinate(coord, xyz);
102 bool setCoordinate(std::size_t coord,
float* xyz)
104 return this->setCoordinate(coord, xyz[0], xyz[1], xyz[2]);
106 bool setCoordinate(std::size_t coord,
float x,
float y,
float z)
108 double xyz[3] = { x, y, z };
109 return this->setCoordinate(coord, xyz);
112 bool isValid()
const {
return m_validState; }
115 bool m_validState{
false };
129 virtual std::size_t addCoordinate(
double* xyz) = 0;
130 virtual bool setCoordinate(std::size_t coord,
double* xyz) = 0;
136 virtual bool addCell(
smtk::mesh::CellType ctype,
int* pointIds, std::size_t nCoordinates = 0) = 0;
138 virtual bool flush() = 0;
140 virtual smtk::mesh::HandleRange cells() = 0;
142 std::size_t addCoordinate(
double x,
double y,
double z)
144 double xyz[3] = { x, y, z };
145 return this->addCoordinate(xyz);
147 std::size_t addCoordinate(
float* xyz) {
return this->addCoordinate(xyz[0], xyz[1], xyz[2]); }
148 std::size_t addCoordinate(
float x,
float y,
float z)
150 double xyz[3] = { x, y, z };
151 return this->addCoordinate(xyz);
154 bool setCoordinate(std::size_t coord,
double x,
double y,
double z)
156 double xyz[3] = { x, y, z };
157 return this->setCoordinate(coord, xyz);
159 bool setCoordinate(std::size_t coord,
float* xyz)
161 return this->setCoordinate(coord, xyz[0], xyz[1], xyz[2]);
163 bool setCoordinate(std::size_t coord,
float x,
float y,
float z)
165 double xyz[3] = { x, y, z };
166 return this->setCoordinate(coord, xyz);
169 virtual bool isValid()
const = 0;
182 std::size_t whichConnectivityVector{ 0 };
183 std::size_t ptrOffsetInVector{ 0 };
188 virtual bool fetchNextCell(
192 const smtk::mesh::Handle*& points) = 0;
196 virtual std::size_t cellSize()
const = 0;
198 virtual std::size_t vertSize()
const = 0;
209 std::vector<std::size_t> pointIds;
210 std::vector<double> sqDistances;
211 std::vector<double> x_s, y_s, z_s;
212 bool want_sqDistances{
false };
213 bool want_Coordinates{
false };
219 virtual smtk::mesh::HandleRange range()
const = 0;
222 locatePointsWithinRadius(
double x,
double y,
double z,
double radius,
Results& results) = 0;
235 virtual std::string name()
const = 0;
241 virtual bool isModified()
const = 0;
283 const smtk::mesh::HandleRange& cells) = 0;
289 std::size_t numPoints,
290 const std::function<std::array<double, 3>(std::size_t)>& coordinates) = 0;
292 virtual smtk::mesh::Handle getRoot()
const = 0;
301 virtual bool createMesh(
const smtk::mesh::HandleRange& cells, smtk::mesh::Handle& meshHandle) = 0;
304 virtual std::size_t numMeshes(smtk::mesh::Handle handle)
const = 0;
306 virtual smtk::mesh::HandleRange getMeshsets(smtk::mesh::Handle handle)
const = 0;
308 virtual smtk::mesh::HandleRange getMeshsets(smtk::mesh::Handle handle,
int dimension)
const = 0;
311 virtual smtk::mesh::HandleRange getMeshsets(smtk::mesh::Handle handle,
const std::string& name)
315 virtual smtk::mesh::HandleRange getMeshsets(
316 smtk::mesh::Handle handle,
320 virtual smtk::mesh::HandleRange getMeshsets(
321 smtk::mesh::Handle handle,
325 virtual smtk::mesh::HandleRange getMeshsets(
326 smtk::mesh::Handle handle,
330 virtual smtk::mesh::HandleRange getCells(
const smtk::mesh::HandleRange& meshsets)
const = 0;
333 virtual smtk::mesh::HandleRange getCells(
334 const smtk::mesh::HandleRange& meshsets,
338 virtual smtk::mesh::HandleRange getCells(
339 const smtk::mesh::HandleRange& meshsets,
340 const smtk::mesh::CellTypes& cellTypes)
const = 0;
343 virtual smtk::mesh::HandleRange getCells(
344 const smtk::mesh::HandleRange& meshsets,
345 smtk::mesh::DimensionType dim)
const = 0;
350 virtual smtk::mesh::HandleRange getPoints(
351 const smtk::mesh::HandleRange& cells,
352 bool boundary_only =
false)
const = 0;
356 virtual bool getCoordinates(
const smtk::mesh::HandleRange& points,
double* xyz)
const = 0;
363 virtual bool getCoordinates(
const smtk::mesh::HandleRange& points,
float* xyz)
const = 0;
367 virtual bool setCoordinates(
const smtk::mesh::HandleRange& points,
const double* xyz) = 0;
371 virtual bool setCoordinates(
const smtk::mesh::HandleRange& points,
const float* xyz) = 0;
373 virtual std::string name(
const smtk::mesh::Handle& meshset)
const = 0;
374 virtual bool setName(
const smtk::mesh::Handle& meshset,
const std::string& name) = 0;
376 virtual std::vector<std::string> computeNames(
const smtk::mesh::HandleRange& meshsets)
const = 0;
378 virtual std::vector<smtk::mesh::Domain> computeDomainValues(
379 const smtk::mesh::HandleRange& meshsets)
const = 0;
381 virtual std::vector<smtk::mesh::Dirichlet> computeDirichletValues(
382 const smtk::mesh::HandleRange& meshsets)
const = 0;
384 virtual std::vector<smtk::mesh::Neumann> computeNeumannValues(
385 const smtk::mesh::HandleRange& meshsets)
const = 0;
388 const smtk::mesh::HandleRange& meshsets)
const = 0;
393 virtual bool computeShell(
const smtk::mesh::HandleRange& meshes, smtk::mesh::HandleRange& shell)
397 virtual bool computeAdjacenciesOfDimension(
398 const smtk::mesh::HandleRange& meshes,
400 smtk::mesh::HandleRange& adj)
const = 0;
404 canonicalIndex(
const smtk::mesh::Handle& cell, smtk::mesh::Handle& parent,
int& index)
const = 0;
408 virtual bool mergeCoincidentContactPoints(
409 const smtk::mesh::HandleRange& meshes,
410 double tolerance) = 0;
413 virtual smtk::mesh::HandleRange neighbors(
const smtk::mesh::Handle& cell)
const = 0;
416 virtual bool setDomain(
const smtk::mesh::HandleRange& meshsets,
const smtk::mesh::Domain& domain)
420 virtual bool setDirichlet(
421 const smtk::mesh::HandleRange& meshsets,
425 virtual bool setNeumann(
426 const smtk::mesh::HandleRange& meshsets,
429 virtual bool setId(
const smtk::mesh::Handle& meshset,
const smtk::common::UUID&
id)
const = 0;
433 virtual bool findById(
434 const smtk::mesh::Handle& root,
436 smtk::mesh::Handle& meshset)
const = 0;
444 virtual bool setAssociation(
446 const smtk::mesh::HandleRange& meshsets)
const = 0;
450 virtual smtk::mesh::HandleRange findAssociations(
451 const smtk::mesh::Handle& root,
462 virtual bool createCellField(
463 const smtk::mesh::HandleRange& meshsets,
464 const std::string& name,
465 std::size_t dimension,
466 const smtk::mesh::FieldType& type,
467 const void* data) = 0;
473 virtual smtk::mesh::HandleRange getMeshsets(
474 smtk::mesh::Handle handle,
477 virtual bool hasCellField(
478 const smtk::mesh::HandleRange& meshsets,
481 virtual bool getCellField(
482 const smtk::mesh::HandleRange& meshsets,
484 void* data)
const = 0;
486 virtual bool setCellField(
487 const smtk::mesh::HandleRange& meshsets,
489 const void* data) = 0;
491 virtual bool getField(
492 const smtk::mesh::HandleRange& cells,
494 void* data)
const = 0;
496 virtual bool setField(
497 const smtk::mesh::HandleRange& cells,
499 const void* data) = 0;
501 virtual std::set<smtk::mesh::CellFieldTag> computeCellFieldTags(
502 const smtk::mesh::Handle& handle)
const = 0;
504 virtual bool deleteCellField(
506 const smtk::mesh::HandleRange& meshsets) = 0;
508 virtual bool createPointField(
509 const smtk::mesh::HandleRange& meshsets,
510 const std::string& name,
511 std::size_t dimension,
512 const smtk::mesh::FieldType& type,
513 const void* data) = 0;
519 virtual smtk::mesh::HandleRange getMeshsets(
520 smtk::mesh::Handle handle,
523 virtual bool hasPointField(
524 const smtk::mesh::HandleRange& meshsets,
527 virtual bool getPointField(
528 const smtk::mesh::HandleRange& meshsets,
530 void* data)
const = 0;
532 virtual bool setPointField(
533 const smtk::mesh::HandleRange& meshsets,
535 const void* data) = 0;
537 virtual bool getField(
538 const smtk::mesh::HandleRange& points,
540 void* data)
const = 0;
542 virtual bool setField(
543 const smtk::mesh::HandleRange& points,
545 const void* data) = 0;
547 virtual std::set<smtk::mesh::PointFieldTag> computePointFieldTags(
548 const smtk::mesh::Handle& handle)
const = 0;
550 virtual bool deletePointField(
552 const smtk::mesh::HandleRange& meshsets) = 0;
554 virtual smtk::mesh::HandleRange pointIntersect(
555 const smtk::mesh::HandleRange& a,
556 const smtk::mesh::HandleRange& b,
558 smtk::mesh::ContainmentType containmentType)
const = 0;
560 virtual smtk::mesh::HandleRange pointDifference(
561 const smtk::mesh::HandleRange& a,
562 const smtk::mesh::HandleRange& b,
564 smtk::mesh::ContainmentType containmentType)
const = 0;
568 virtual void cellForEach(
569 const HandleRange& cells,
581 virtual bool deleteHandles(
const smtk::mesh::HandleRange& toDel) = 0;
585 virtual void setModifiedState(
bool state) = 0;