Commit 61775850 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[entitynetwork] use id class

parent bc92fe73
......@@ -32,6 +32,7 @@
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <frackit/common/id.hh>
#include "containedentitynetworkinterface.hh"
namespace Frackit {
......@@ -67,43 +68,43 @@ public:
, subDomainEntityFragments_(std::move(entityFragments))
, subDomainEntityFragmentIndexMap_(std::move(entityFragmentMaps))
{
subDomainIndices_.reserve(subDomainFragments_.size());
subDomainIds_.reserve(subDomainFragments_.size());
for (const auto& sdDataPair : subDomainFragments_)
subDomainIndices_.push_back(sdDataPair.first);
subDomainIds_.emplace_back(sdDataPair.first);
}
/*!
* \brief Returns the indices of defined the sub-domains
* \brief Returns the ids of defined the sub-domains
*/
const std::vector<std::size_t>& subDomainIndices() const override
{ return subDomainIndices_; }
const std::vector<Id>& subDomainIds() const override
{ return subDomainIds_; }
/*!
* \brief Returns the fragments of a sub-domain
* \param subDomainIdx The index of the sub-domain
*/
const TopTools_ListOfShape& subDomainFragments(std::size_t subDomainIdx) const override
{ return subDomainFragments_.at(subDomainIdx); }
const TopTools_ListOfShape& subDomainFragments(Id subDomainId) const override
{ return subDomainFragments_.at(subDomainId.get()); }
/*!
* \brief Returns the entity fragments of the network defined for a sub-domain
* \param subDomainIdx The index of the sub-domain
*/
const TopTools_ListOfShape& subDomainEntityFragments(std::size_t subDomainIdx) const override
{ return subDomainEntityFragments_.at(subDomainIdx); }
const TopTools_ListOfShape& subDomainEntityFragments(Id subDomainId) const override
{ return subDomainEntityFragments_.at(subDomainId.get()); }
/*!
* \brief Returns the map which maps each fragment the network of a sub-domain to its primary entity index.
* \param subDomainIdx The index of the sub-domain
*/
const TopTools_DataMapOfShapeInteger& subDomainEntityFragmentsIndexMap(std::size_t subDomainIdx) const override
{ return subDomainEntityFragmentIndexMap_.at(subDomainIdx); }
const TopTools_DataMapOfShapeInteger& subDomainEntityFragmentsIndexMap(Id subDomainId) const override
{ return subDomainEntityFragmentIndexMap_.at(subDomainId.get()); }
private:
std::unordered_map<std::size_t, TopTools_ListOfShape> subDomainFragments_;
std::unordered_map<std::size_t, TopTools_ListOfShape> subDomainEntityFragments_;
std::unordered_map<std::size_t, TopTools_DataMapOfShapeInteger> subDomainEntityFragmentIndexMap_;
std::vector<std::size_t> subDomainIndices_;
std::vector<Id> subDomainIds_;
};
} // end namespace Frackit
......
......@@ -30,6 +30,8 @@
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <frackit/common/id.hh>
namespace Frackit {
/*!
......@@ -65,27 +67,27 @@ public:
{ return domainDimension_; }
/*!
* \brief Returns the indices of defined the sub-domains
* \brief Returns the ids of defined the sub-domains
*/
virtual const std::vector<std::size_t>& subDomainIndices() const = 0;
virtual const std::vector<Id>& subDomainIds() const = 0;
/*!
* \brief Returns the fragments of a sub-domain
* \param subDomainIdx The index of the sub-domain
*/
virtual const TopTools_ListOfShape& subDomainFragments(std::size_t subDomainIdx) const = 0;
virtual const TopTools_ListOfShape& subDomainFragments(Id subDomainId) const = 0;
/*!
* \brief Returns the entity fragments of the network defined for a sub-domain
* \param subDomainIdx The index of the sub-domain
*/
virtual const TopTools_ListOfShape& subDomainEntityFragments(std::size_t subDomainIdx) const = 0;
virtual const TopTools_ListOfShape& subDomainEntityFragments(Id subDomainId) const = 0;
/*!
* \brief Returns the map which maps each fragment the network of a sub-domain to its primary entity index.
* \param subDomainIdx The index of the sub-domain
*/
virtual const TopTools_DataMapOfShapeInteger& subDomainEntityFragmentsIndexMap(std::size_t subDomainIdx) const = 0;
virtual const TopTools_DataMapOfShapeInteger& subDomainEntityFragmentsIndexMap(Id subDomainId) const = 0;
private:
int entityDimension_;
......
......@@ -127,12 +127,12 @@ private:
void makeEntityMap_(const ContainedEntityNetwork& network)
{
std::size_t subNetworkOffset = 0;
for (auto idx : network.subDomainIndices())
for (const auto& id : network.subDomainIds())
{
// the map maps to the entity index within the sub-domain network
// Therefore, we add the offset in order to ensure that we don't add
// entities from another network to the same primary entity index
const auto& map = network.subDomainEntityFragmentsIndexMap(idx);
const auto& map = network.subDomainEntityFragmentsIndexMap(id);
for (TopTools_DataMapIteratorOfDataMapOfShapeInteger it(map); it.More(); it.Next())
{
allEntities_.Append(it.Key());
......@@ -198,16 +198,16 @@ private:
*/
void makeSubShapeMaps_(const ContainedEntityNetwork& network)
{
for (auto idx : network.subDomainIndices())
for (auto id : network.subDomainIds())
{
const auto& sdFragments = network.subDomainFragments(idx);
const auto& sdFragments = network.subDomainFragments(id);
for (TopTools_ListIteratorOfListOfShape it(sdFragments); it.More(); it.Next())
addSolids_(it.Value(), idx);
addSolids_(it.Value(), id.get());
}
for (auto idx : network.subDomainIndices())
for (auto id : network.subDomainIds())
{
const auto& sdEntityFragments = network.subDomainEntityFragments(idx);
const auto& sdEntityFragments = network.subDomainEntityFragments(id);
for (TopTools_ListIteratorOfListOfShape it(sdEntityFragments); it.More(); it.Next())
addFaces_(it.Value());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment