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

Merge branch 'feature/entity-networks' into 'master'

Feature/entity networks

See merge request DennisGlaeser/frackit!14
parents 2bfeea03 385c28bb
install(FILES
constraints.hh
containedentitynetwork.hh
containedentitynetworkinterface.hh
entitynetwork.hh
entitynetworkinterface.hh
impl_admissibledimension.hh
impl_admissiblemagnitude.hh
impl_distancetoboundary.hh
networkbuilder.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/frackit/entitynetwork)
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Class representing a network of entities, contained
* in (possibly multiple) sub-domains. Sub-networks might
* be defined on each sub-domain.
*/
#ifndef FRACKIT_CONTAINED_ENTITY_NETWORK_HH
#define FRACKIT_CONTAINED_ENTITY_NETWORK_HH
#include <vector>
#include <unordered_map>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include "containedentitynetworkinterface.hh"
namespace Frackit {
/*!
* \relates ContainedEntityNetworkBuilder
* \brief Class representing a network of entities, contained
* in (possibly multiple) sub-domains. Sub-networks might
* be defined on each sub-domain.
* \note Use the class ContainedEntityNetworkBuilder for construction.
*/
class ContainedEntityNetwork
: public ContainedEntityNetworkInterface
{
public:
/*!
* \brief Constructor.
* \param entityDim Dimension of the network entities
* \param fragmentList List containing all entity fragments
* \param fragmentIndexMap Map containing the fragments
* of a network, where each fragment
* is mapped to the index of the primary
* entity of the network.
*/
ContainedEntityNetwork(int entityDim,
int domainDim,
std::unordered_map<std::size_t, TopTools_ListOfShape>&& sdFragments,
std::unordered_map<std::size_t, TopTools_ListOfShape>&& entityFragments,
std::unordered_map<std::size_t, TopTools_DataMapOfShapeInteger>&& entityFragmentMaps)
: ContainedEntityNetworkInterface(entityDim, domainDim)
, subDomainFragments_(std::move(sdFragments))
, subDomainEntityFragments_(std::move(entityFragments))
, subDomainEntityFragmentIndexMap_(std::move(entityFragmentMaps))
{
subDomainIndices_.reserve(subDomainFragments_.size());
for (const auto& sdDataPair : subDomainFragments_)
subDomainIndices_.push_back(sdDataPair.first);
}
/*!
* \brief Returns the indices of defined the sub-domains
*/
const std::vector<std::size_t>& subDomainIndices() const override
{ return subDomainIndices_; }
/*!
* \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); }
/*!
* \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); }
/*!
* \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); }
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_;
};
} // end namespace Frackit
#endif // FRACKIT_CONTAINED_ENTITY_NETWORK_HH
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Interface defining networks of entities contained
* in (possibly multiple) sub-domains.
*/
#ifndef FRACKIT_CONTAINED_ENTITY_NETWORK_INTERFACE_HH
#define FRACKIT_CONTAINED_ENTITY_NETWORK_INTERFACE_HH
#include <vector>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
namespace Frackit {
/*!
* \brief Interface defining networks of entities contained
* in (possibly multiple) sub-domains.
*/
class ContainedEntityNetworkInterface
{
public:
/*!
* \brief Constructor.
* \param entityDim Dimension of the network entities
* \param domainDim Dimension of the domain in
* which entities are embedded
*/
ContainedEntityNetworkInterface(int entityDim, int domainDim)
: entityDimension_(entityDim)
, domainDimension_(domainDim)
{}
/*!
* \brief Returns the dimension of the network entities.
*/
int entityDimension() const
{ return entityDimension_; }
/*!
* \brief Returns the dimension of the (sub-)domains.
*/
int domainDimension() const
{ return domainDimension_; }
/*!
* \brief Returns the indices of defined the sub-domains
*/
virtual const std::vector<std::size_t>& subDomainIndices() 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;
/*!
* \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;
/*!
* \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;
private:
int entityDimension_;
int domainDimension_;
};
} // end namespace Frackit
#endif // FRACKIT_CONTAINED_ENTITY_NETWORK_INTERFACE_HH
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Class representing a network of entities,
* consisting of fragments of primary entities.
*/
#ifndef FRACKIT_ENTITY_NETWORK_HH
#define FRACKIT_ENTITY_NETWORK_HH
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include "entitynetworkinterface.hh"
namespace Frackit {
/*!
* \relates EntityNetworkBuilder
* \brief Class representing a network of entities,
* consisting of fragments of primary entities.
* In addition to the fragments, it contains a
* map which maps an index, the index of the primary
* entity, to each fragment.
* \note Use the class EntityNetworkBuilder for construction.
*/
class EntityNetwork
: public EntityNetworkInterface
{
public:
/*!
* \brief Constructor.
* \param entityDim Dimension of the network entities
* \param fragmentList List containing all entity fragments
* \param fragmentIndexMap Map containing the fragments
* of a network, where each fragment
* is mapped to the index of the primary
* entity of the network (before fragmentation).
*/
EntityNetwork(int entityDim,
TopTools_ListOfShape&& fragmentList,
TopTools_DataMapOfShapeInteger&& fragmentIndexMap)
: EntityNetworkInterface(entityDim)
, entityFragments_(std::move(fragmentList))
, entityFragmentIndexMap_(std::move(fragmentIndexMap))
{}
/*!
* \brief Returns the fragments of the network entities.
*/
const TopTools_ListOfShape& entityFragments() const override
{ return entityFragments_; }
/*!
* \brief Returns the map which maps each fragment to its primary entity index.
*/
const TopTools_DataMapOfShapeInteger& entityFragmentsIndexMap() const override
{ return entityFragmentIndexMap_; }
private:
TopTools_ListOfShape entityFragments_;
TopTools_DataMapOfShapeInteger entityFragmentIndexMap_;
};
} // end namespace Frackit
#endif // FRACKIT_ENTITY_NETWORK_HH
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Interface defining networks of entities.
*/
#ifndef FRACKIT_ENTITY_NETWORK_INTERFACE_HH
#define FRACKIT_ENTITY_NETWORK_INTERFACE_HH
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
namespace Frackit {
/*!
* \brief Interface defining networks of entities.
*/
class EntityNetworkInterface
{
public:
/*!
* \brief Constructor.
* \param entityDim Dimension of the network entities
*/
EntityNetworkInterface(int entityDim)
: entityDimension_(entityDim)
{}
/*!
* \brief Returns the dimension of the network entities.
*/
int entityDimension() const
{ return entityDimension_; }
/*!
* \brief Returns the fragments of the network entities.
*/
virtual const TopTools_ListOfShape& entityFragments() const = 0;
/*!
* \brief Returns the map which maps each fragment to its primary entity index.
*/
virtual const TopTools_DataMapOfShapeInteger& entityFragmentsIndexMap() const = 0;
private:
int entityDimension_;
};
} // end namespace Frackit
#endif // FRACKIT_ENTITY_NETWORK_INTERFACE_HH
This diff is collapsed.
......@@ -55,6 +55,7 @@
// Algorithm for boolean operations on shapes
#include <BRepAlgoAPI_BuilderAlgo.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Cut.hxx>
......@@ -365,11 +366,31 @@ namespace OCCUtilities {
fragments.SetFuzzyValue(eps);
fragments.Build();
if (!fragments.IsDone())
throw std::runtime_error(std::string("Could not perform segment fragmentation"));
throw std::runtime_error(std::string("Could not perform fragmentation"));
return fragments.Shape();
}
//! Convenience function to get the shape resulting from the union of a set of objects
template<class ctype>
TopoDS_Shape fuse(const std::vector<TopoDS_Shape>& objects, ctype eps)
{
TopTools_ListOfShape shapes;
for (const auto& shape : objects)
shapes.Append(shape);
BRepAlgoAPI_Fuse fuse;
fuse.SetRunParallel(false);
fuse.SetArguments(shapes);
fuse.SetTools(shapes);
fuse.SetFuzzyValue(eps);
fuse.Build();
if (!fuse.IsDone())
throw std::runtime_error(std::string("Could not perform union"));
return fuse.Shape();
}
/*!
* \brief Determines the overlap edges between two sets of edges.
* \param edges1 the first set of edges
......
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