mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0029692: Add functionality to make the group of touching same-dimensional shapes connected
Implementation of the new class *BOPAlgo_MakeConnected* for making the group of touching same-dimensional shapes connected. Provide the material association for the first sub-elements of the input shapes. Provide possibility to make the connected shape periodic. Draw commands for new algorithm: * makeconnected - make the input shapes connected or glued, performs material associations; * cmaterialson - returns the materials located on the requested side of a shape; * cmakeperiodic - makes the connected shape periodic in requested directions; * crepeatshape - repeats the periodic connected shape in requested directions requested number of times; * cperiodictwins - returns all periodic twins for the shape; * cclearrepetitions - clears all previous repetitions of the periodic shape, keeping the shape periodic. Documentation & test cases for the new algorithm.
This commit is contained in:
@@ -112,3 +112,15 @@ Unable to make the shape to look identical on opposite sides (Splitter fails)
|
||||
|
||||
.BOPAlgo_AlertUnableToRepeat
|
||||
Unable to repeat the shape (Gluer fails)
|
||||
|
||||
.BOPAlgo_AlertMultiDimensionalArguments
|
||||
Multi-dimensional arguments
|
||||
|
||||
.BOPAlgo_AlertUnableToMakePeriodic
|
||||
Unable to make the shape periodic
|
||||
|
||||
.BOPAlgo_AlertUnableToGlue
|
||||
Unable to glue the shapes
|
||||
|
||||
.BOPAlgo_AlertShapeIsNotPeriodic
|
||||
The shape is not periodic
|
||||
|
@@ -126,4 +126,16 @@ DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToMakeIdentical)
|
||||
//! Unable to repeat the shape (Gluer fails)
|
||||
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToRepeat)
|
||||
|
||||
//! Multi-dimensional arguments
|
||||
DEFINE_SIMPLE_ALERT(BOPAlgo_AlertMultiDimensionalArguments)
|
||||
|
||||
//! Unable to make the shape periodic
|
||||
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToMakePeriodic)
|
||||
|
||||
//! Unable to glue the shapes
|
||||
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertUnableToGlue)
|
||||
|
||||
//! The shape is not periodic
|
||||
DEFINE_ALERT_WITH_SHAPE(BOPAlgo_AlertShapeIsNotPeriodic)
|
||||
|
||||
#endif // _BOPAlgo_Alerts_HeaderFile
|
||||
|
@@ -114,4 +114,16 @@ static const char BOPAlgo_BOPAlgo_msg[] =
|
||||
"Unable to make the shape to look identical on opposite sides (Splitter fails)\n"
|
||||
"\n"
|
||||
".BOPAlgo_AlertUnableToRepeat\n"
|
||||
"Unable to repeat the shape (Gluer fails)\n";
|
||||
"Unable to repeat the shape (Gluer fails)\n"
|
||||
"\n"
|
||||
".BOPAlgo_AlertMultiDimensionalArguments\n"
|
||||
"Multi-dimensional arguments\n"
|
||||
"\n"
|
||||
".BOPAlgo_AlertUnableToMakePeriodic\n"
|
||||
"Unable to make the shape periodic\n"
|
||||
"\n"
|
||||
".BOPAlgo_AlertUnableToGlue\n"
|
||||
"Unable to glue the shapes\n"
|
||||
"\n"
|
||||
".BOPAlgo_AlertShapeIsNotPeriodic\n"
|
||||
"The shape is not periodic\n";
|
||||
|
333
src/BOPAlgo/BOPAlgo_MakeConnected.cxx
Normal file
333
src/BOPAlgo/BOPAlgo_MakeConnected.cxx
Normal file
@@ -0,0 +1,333 @@
|
||||
// Created on: 2018-03-29
|
||||
// Created by: Eugeny MALTCHIKOV
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BOPAlgo_MakeConnected.hxx>
|
||||
|
||||
#include <BOPAlgo_Alerts.hxx>
|
||||
#include <BOPAlgo_Builder.hxx>
|
||||
#include <BOPAlgo_Tools.hxx>
|
||||
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose : Makes the shapes connected
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::Perform()
|
||||
{
|
||||
// Check the input data
|
||||
CheckData();
|
||||
if (HasErrors())
|
||||
return;
|
||||
|
||||
if (myHistory.IsNull())
|
||||
myHistory = new BRepTools_History;
|
||||
|
||||
// Glue the arguments
|
||||
MakeConnected();
|
||||
if (HasErrors())
|
||||
return;
|
||||
|
||||
// Perform material associations for the faces
|
||||
AssociateMaterials();
|
||||
if (HasErrors())
|
||||
return;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckData
|
||||
//purpose : Check the validity of input data
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::CheckData()
|
||||
{
|
||||
// Check the number of arguments
|
||||
if (myArguments.IsEmpty())
|
||||
{
|
||||
// Not enough arguments
|
||||
AddError(new BOPAlgo_AlertTooFewArguments());
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that all shapes in arguments are of the same type
|
||||
|
||||
// Extract the shapes from the compound arguments
|
||||
TopTools_ListOfShape aLA;
|
||||
// Fence map
|
||||
TopTools_MapOfShape aMFence;
|
||||
|
||||
TopTools_ListIteratorOfListOfShape itLA(myArguments);
|
||||
for (; itLA.More(); itLA.Next())
|
||||
BOPAlgo_Tools::TreatCompound(itLA.Value(), aMFence, aLA);
|
||||
|
||||
if (aLA.IsEmpty())
|
||||
{
|
||||
// It seems that all argument shapes are empty compounds
|
||||
AddError(new BOPAlgo_AlertTooFewArguments());
|
||||
return;
|
||||
}
|
||||
|
||||
// Check dimensions of the extracted non-compound shapes
|
||||
itLA.Initialize(aLA);
|
||||
Standard_Integer iDim = BOPTools_AlgoTools::Dimension(itLA.Value());
|
||||
for (itLA.Next(); itLA.More(); itLA.Next())
|
||||
{
|
||||
if (iDim != BOPTools_AlgoTools::Dimension(itLA.Value()))
|
||||
{
|
||||
// The arguments are of different type
|
||||
AddError(new BOPAlgo_AlertMultiDimensionalArguments());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeConnected
|
||||
//purpose : Glues the argument shapes
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::MakeConnected()
|
||||
{
|
||||
// Initialize the history
|
||||
if (myGlueHistory.IsNull())
|
||||
myGlueHistory = new BRepTools_History;
|
||||
|
||||
if (myArguments.Extent() == 1)
|
||||
{
|
||||
// No need to glue the single shape
|
||||
myShape = myArguments.First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Glue the shapes
|
||||
BOPAlgo_Builder aGluer;
|
||||
aGluer.SetArguments(myArguments);
|
||||
aGluer.SetGlue(BOPAlgo_GlueShift);
|
||||
aGluer.SetRunParallel(myRunParallel);
|
||||
aGluer.SetNonDestructive(Standard_True);
|
||||
aGluer.Perform();
|
||||
if (aGluer.HasErrors())
|
||||
{
|
||||
// Unable to glue the shapes
|
||||
TopoDS_Compound aCW;
|
||||
BRep_Builder().MakeCompound(aCW);
|
||||
for (TopTools_ListIteratorOfListOfShape it(myArguments); it.More(); it.Next())
|
||||
BRep_Builder().Add(aCW, it.Value());
|
||||
AddError(new BOPAlgo_AlertUnableToGlue(aCW));
|
||||
return;
|
||||
}
|
||||
myShape = aGluer.Shape();
|
||||
// Save the gluing history
|
||||
myGlueHistory->Merge(aGluer.Arguments(), aGluer);
|
||||
myHistory->Merge(myGlueHistory);
|
||||
}
|
||||
|
||||
// Keep the glued shape
|
||||
myGlued = myShape;
|
||||
|
||||
// Fill the map of origins
|
||||
FillOrigins();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FillOrigins
|
||||
//purpose : Fills the map of origins
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::FillOrigins()
|
||||
{
|
||||
myOrigins.Clear();
|
||||
|
||||
// Map the history shapes of the arguments
|
||||
if (myAllInputsMap.IsEmpty())
|
||||
{
|
||||
TopTools_ListIteratorOfListOfShape itLA(myArguments);
|
||||
for (; itLA.More(); itLA.Next())
|
||||
TopExp::MapShapes(itLA.Value(), myAllInputsMap);
|
||||
}
|
||||
|
||||
const Standard_Integer aNbS = myAllInputsMap.Extent();
|
||||
for (Standard_Integer i = 1; i <= aNbS; ++i)
|
||||
{
|
||||
const TopoDS_Shape& aS = myAllInputsMap(i);
|
||||
if (!BRepTools_History::IsSupportedType(aS))
|
||||
continue;
|
||||
|
||||
// Get Modified & Generated shapes
|
||||
for (Standard_Integer j = 0; j < 2; ++j)
|
||||
{
|
||||
const TopTools_ListOfShape& aLH = !j ? myHistory->Modified(aS) : myHistory->Generated(aS);
|
||||
TopTools_ListIteratorOfListOfShape itLH(aLH);
|
||||
for (; itLH.More(); itLH.Next())
|
||||
{
|
||||
const TopoDS_Shape& aHS = itLH.Value();
|
||||
TopTools_ListOfShape* pLOr = myOrigins.ChangeSeek(aHS);
|
||||
if (!pLOr)
|
||||
pLOr = myOrigins.Bound(aHS, TopTools_ListOfShape());
|
||||
if (!pLOr->Contains(aS))
|
||||
pLOr->Append(aS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AssociateMaterials
|
||||
//purpose : Associates the materials for the border elements
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::AssociateMaterials()
|
||||
{
|
||||
myMaterials.Clear();
|
||||
|
||||
// Extract all non-compound shapes from the result
|
||||
TopTools_ListOfShape aLShapes;
|
||||
TopTools_MapOfShape aMFence;
|
||||
BOPAlgo_Tools::TreatCompound(myShape, aMFence, aLShapes);
|
||||
|
||||
if (aLShapes.IsEmpty())
|
||||
return;
|
||||
|
||||
// Define the element type and the material type
|
||||
TopAbs_ShapeEnum anElemType;
|
||||
const TopAbs_ShapeEnum aMaterialType = aLShapes.First().ShapeType();
|
||||
if (aMaterialType == TopAbs_SOLID || aMaterialType == TopAbs_COMPSOLID)
|
||||
anElemType = TopAbs_FACE;
|
||||
else if (aMaterialType == TopAbs_FACE || aMaterialType == TopAbs_SHELL)
|
||||
anElemType = TopAbs_EDGE;
|
||||
else if (aMaterialType == TopAbs_EDGE || aMaterialType == TopAbs_WIRE)
|
||||
anElemType = TopAbs_VERTEX;
|
||||
else
|
||||
return;
|
||||
|
||||
TopTools_ListIteratorOfListOfShape itLS(aLShapes);
|
||||
for (; itLS.More(); itLS.Next())
|
||||
{
|
||||
const TopoDS_Shape& aS = itLS.Value();
|
||||
const TopTools_ListOfShape& aLOr = GetOrigins(aS);
|
||||
const TopoDS_Shape& aSOr = aLOr.IsEmpty() ? aS : aLOr.First();
|
||||
|
||||
TopExp_Explorer anExp(aS, anElemType);
|
||||
for (; anExp.More(); anExp.Next())
|
||||
{
|
||||
const TopoDS_Shape& anElement = anExp.Current();
|
||||
TopTools_ListOfShape* pLM = myMaterials.ChangeSeek(anElement);
|
||||
if (!pLM)
|
||||
pLM = myMaterials.Bound(anElement, TopTools_ListOfShape());
|
||||
pLM->Append(aSOr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Update
|
||||
//purpose : Updates the history, material associations and origins map
|
||||
// after periodicity operations
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::Update()
|
||||
{
|
||||
// Update history
|
||||
myHistory->Clear();
|
||||
if (!myGlueHistory.IsNull())
|
||||
myHistory->Merge(myGlueHistory);
|
||||
if (!myPeriodicityMaker.History().IsNull())
|
||||
myHistory->Merge(myPeriodicityMaker.History());
|
||||
|
||||
// Fill the map of origins
|
||||
FillOrigins();
|
||||
|
||||
// Update the material associations after making the shape periodic
|
||||
AssociateMaterials();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakePeriodic
|
||||
//purpose : Makes the shape periodic according to the given parameters
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams)
|
||||
{
|
||||
if (HasErrors())
|
||||
return;
|
||||
|
||||
// Make the shape periodic
|
||||
myPeriodicityMaker.Clear();
|
||||
myPeriodicityMaker.SetShape(myGlued);
|
||||
myPeriodicityMaker.SetPeriodicityParameters(theParams);
|
||||
myPeriodicityMaker.SetRunParallel(myRunParallel);
|
||||
myPeriodicityMaker.Perform();
|
||||
if (myPeriodicityMaker.HasErrors())
|
||||
{
|
||||
// Add warning informing the user that periodicity with
|
||||
// given parameters is not possible
|
||||
AddWarning(new BOPAlgo_AlertUnableToMakePeriodic(myShape));
|
||||
return;
|
||||
}
|
||||
|
||||
myShape = myPeriodicityMaker.Shape();
|
||||
|
||||
// Update history, materials, origins
|
||||
Update();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RepeatShape
|
||||
//purpose : Repeats the shape in the given direction given number of times
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::RepeatShape(const Standard_Integer theDirectionID,
|
||||
const Standard_Integer theTimes)
|
||||
{
|
||||
if (HasErrors())
|
||||
return;
|
||||
|
||||
if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors())
|
||||
{
|
||||
// The shape has not been made periodic yet
|
||||
AddWarning(new BOPAlgo_AlertShapeIsNotPeriodic(myShape));
|
||||
return;
|
||||
}
|
||||
|
||||
// Repeat the shape
|
||||
myShape = myPeriodicityMaker.RepeatShape(theDirectionID, theTimes);
|
||||
|
||||
// Update history, materials, origins
|
||||
Update();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearRepetitions
|
||||
//purpose : Clears the repetitions performed on the periodic shape
|
||||
// keeping the shape periodic
|
||||
//=======================================================================
|
||||
void BOPAlgo_MakeConnected::ClearRepetitions()
|
||||
{
|
||||
if (HasErrors())
|
||||
return;
|
||||
|
||||
if (myPeriodicityMaker.Shape().IsNull() || myPeriodicityMaker.HasErrors())
|
||||
{
|
||||
// The shape has not been made periodic yet
|
||||
AddWarning(new BOPAlgo_AlertShapeIsNotPeriodic(myShape));
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear repetitions
|
||||
myPeriodicityMaker.ClearRepetitions();
|
||||
myShape = myPeriodicityMaker.Shape();
|
||||
|
||||
// Update history, materials, origins
|
||||
Update();
|
||||
}
|
338
src/BOPAlgo/BOPAlgo_MakeConnected.hxx
Normal file
338
src/BOPAlgo/BOPAlgo_MakeConnected.hxx
Normal file
@@ -0,0 +1,338 @@
|
||||
// Created on: 2018-03-29
|
||||
// Created by: Eugeny MALTCHIKOV
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BOPAlgo_MakeConnected_HeaderFile
|
||||
#define _BOPAlgo_MakeConnected_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <BOPAlgo_Options.hxx>
|
||||
#include <BOPAlgo_MakePeriodic.hxx>
|
||||
|
||||
#include <BRepTools_History.hxx>
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
#include <TopTools_OrientedShapeMapHasher.hxx>
|
||||
|
||||
//! BOPAlgo_MakeConnected is the algorithm for making the touching
|
||||
//! shapes connected or glued, i.e. for making the coinciding geometries
|
||||
//! be topologically shared among the shapes.
|
||||
//!
|
||||
//! The input shapes should be of the same dimension, otherwise
|
||||
//! the gluing will not make any sense.
|
||||
//!
|
||||
//! After the shapes are made connected, the border elements of input shapes
|
||||
//! are associated with the shapes to which they belong. At that, the orientation of
|
||||
//! the border element in the shape is taken into account.
|
||||
//! The associations are made for the following types:
|
||||
//! - For input SOLIDS, the resulting FACES are associated with the input solids;
|
||||
//! - For input FACES, the resulting EDGES are associated with the input faces;
|
||||
//! - For input EDGES, the resulting VERTICES are associated with the input edges.
|
||||
//!
|
||||
//! In frames of this algorithm the input shapes are called materials,
|
||||
//! and the association process is called the material association.
|
||||
//! The material association allows finding the coinciding elements for the opposite
|
||||
//! input shapes. These elements will be associated to at least two materials.
|
||||
//!
|
||||
//! After making the shapes connected, it is possible to make the connected
|
||||
//! shape periodic using the *BOPAlgo_MakePeriodic* tool.
|
||||
//! After making the shape periodic, the material associations will be updated
|
||||
//! to correspond to the actual state of the result shape.
|
||||
//! Repetition of the periodic shape is also possible here. Material associations
|
||||
//! are not going to be lost.
|
||||
//!
|
||||
//! The algorithm supports history of shapes modification, thus it is possible
|
||||
//! to track the modification of the input shapes during the operations.
|
||||
//! Additionally to standard history methods, the algorithm provides the
|
||||
//! the method *GetOrigins()* which allows obtaining the input shapes from which
|
||||
//! the resulting shape has been created.
|
||||
//!
|
||||
//! The algorithm supports the parallel processing mode, which allows faster
|
||||
//! completion of the operations.
|
||||
//!
|
||||
//! The algorithm returns the following Error/Warning messages:
|
||||
//! - *BOPAlgo_AlertTooFewArguments* - error alert is given on the attempt to run
|
||||
//! the algorithm without the arguments;
|
||||
//! - *BOPAlgo_AlertMultiDimensionalArguments* - error alert is given on the attempt
|
||||
//! to run the algorithm on multi-dimensional arguments;
|
||||
//! - *BOPAlgo_AlertUnableToGlue* - error alert is given if the gluer algorithm
|
||||
//! is unable to glue the given arguments;
|
||||
//! - *BOPAlgo_AlertUnableToMakePeriodic* - warning alert is given if the periodicity
|
||||
//! maker is unable to make the connected shape periodic with given options;
|
||||
//! - *BOPAlgo_AlertShapeIsNotPeriodic* - warning alert is given on the attempt to
|
||||
//! repeat the shape before making it periodic.
|
||||
//!
|
||||
//! Here is the example of usage of the algorithm:
|
||||
//! ~~~~
|
||||
//! TopTools_ListOfShape anArguments = ...; // Shapes to make connected
|
||||
//! Standard_Boolean bRunParallel = ...; // Parallel processing mode
|
||||
//!
|
||||
//! BOPAlgo_MakeConnected aMC; // Tool for making the shapes connected
|
||||
//! aMC.SetArguments(anArguments); // Set the shapes
|
||||
//! aMC.SetRunParallel(bRunParallel); // Set parallel processing mode
|
||||
//! aMC.Perform(); // Perform the operation
|
||||
//!
|
||||
//! if (aMC.HasErrors()) // Check for the errors
|
||||
//! {
|
||||
//! // errors treatment
|
||||
//! Standard_SStream aSStream;
|
||||
//! aMC.DumpErrors(aSStream);
|
||||
//! return;
|
||||
//! }
|
||||
//! if (aMC.HasWarnings()) // Check for the warnings
|
||||
//! {
|
||||
//! // warnings treatment
|
||||
//! Standard_SStream aSStream;
|
||||
//! aMC.DumpWarnings(aSStream);
|
||||
//! }
|
||||
//!
|
||||
//! const TopoDS_Shape& aGluedShape = aMC.Shape(); // Connected shape
|
||||
//!
|
||||
//! // Checking material associations
|
||||
//! TopAbs_ShapeEnum anElemType = ...; // Type of border element
|
||||
//! TopExp_Explorer anExp(anArguments.First(), anElemType);
|
||||
//! for (; anExp.More(); anExp.Next())
|
||||
//! {
|
||||
//! const TopoDS_Shape& anElement = anExp.Current();
|
||||
//! const TopTools_ListOfShape& aNegativeM = aMC.MaterialsOnNegativeSide(anElement);
|
||||
//! const TopTools_ListOfShape& aPositiveM = aMC.MaterialsOnPositiveSide(anElement);
|
||||
//! }
|
||||
//!
|
||||
//! // Making the connected shape periodic
|
||||
//! BOPAlgo_MakePeriodic::PeriodicityParams aParams = ...; // Options for periodicity of the connected shape
|
||||
//! aMC.MakePeriodic(aParams);
|
||||
//!
|
||||
//! // Shape repetition after making it periodic
|
||||
//! // Check if the shape has been made periodic successfully
|
||||
//! if (aMC.PeriodicityTool().HasErrors())
|
||||
//! {
|
||||
//! // Periodicity maker error treatment
|
||||
//! }
|
||||
//!
|
||||
//! // Shape repetition in periodic directions
|
||||
//! aMC.RepeatShape(0, 2);
|
||||
//!
|
||||
//! const TopoDS_Shape& aShape = aMC.PeriodicShape(); // Periodic and repeated shape
|
||||
//! ~~~~
|
||||
//!
|
||||
class BOPAlgo_MakeConnected : public BOPAlgo_Options
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
public: //! @name Constructor
|
||||
|
||||
//! Empty constructor
|
||||
BOPAlgo_MakeConnected() : BOPAlgo_Options()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public: //! @name Setters for the shapes to make connected
|
||||
|
||||
//! Sets the shape for making them connected.
|
||||
//! @param theArgs [in] The arguments for the operation.
|
||||
void SetArguments(const TopTools_ListOfShape& theArgs)
|
||||
{
|
||||
myArguments = theArgs;
|
||||
}
|
||||
|
||||
//! Adds the shape to the arguments.
|
||||
//! @param theS [in] One of the argument shapes.
|
||||
void AddArgument(const TopoDS_Shape& theS)
|
||||
{
|
||||
myArguments.Append(theS);
|
||||
}
|
||||
|
||||
//! Returns the list of arguments of the operation.
|
||||
const TopTools_ListOfShape& Arguments() const
|
||||
{
|
||||
return myArguments;
|
||||
}
|
||||
|
||||
public: //! @name Performing the operations
|
||||
|
||||
//! Performs the operation, i.e. makes the input shapes connected.
|
||||
Standard_EXPORT void Perform();
|
||||
|
||||
|
||||
public: //! @name Shape periodicity & repetition
|
||||
|
||||
//! Makes the connected shape periodic.
|
||||
//! Repeated calls of this method overwrite the previous calls
|
||||
//! working with the basis connected shape.
|
||||
//! @param theParams [in] Periodic options.
|
||||
Standard_EXPORT void MakePeriodic(const BOPAlgo_MakePeriodic::PeriodicityParams& theParams);
|
||||
|
||||
//! Performs repetition of the periodic shape in specified direction
|
||||
//! required number of times.
|
||||
//! @param theDirectionID [in] The direction's ID (0 for X, 1 for Y, 2 for Z);
|
||||
//! @param theTimes [in] Requested number of repetitions (sign of the value defines
|
||||
//! the side of the repetition direction (positive or negative)).
|
||||
Standard_EXPORT void RepeatShape(const Standard_Integer theDirectionID,
|
||||
const Standard_Integer theTimes);
|
||||
|
||||
//! Clears the repetitions performed on the periodic shape,
|
||||
//! keeping the shape periodic.
|
||||
Standard_EXPORT void ClearRepetitions();
|
||||
|
||||
//! Returns the periodicity tool.
|
||||
const BOPAlgo_MakePeriodic& PeriodicityTool() const
|
||||
{
|
||||
return myPeriodicityMaker;
|
||||
}
|
||||
|
||||
|
||||
public: //! @name Material transitions
|
||||
|
||||
//! Returns the original shapes which images contain the
|
||||
//! the given shape with FORWARD orientation.
|
||||
//! @param theS [in] The shape for which the materials are necessary.
|
||||
const TopTools_ListOfShape& MaterialsOnPositiveSide(const TopoDS_Shape& theS)
|
||||
{
|
||||
const TopTools_ListOfShape* pLM = myMaterials.Seek(theS.Oriented(TopAbs_FORWARD));
|
||||
return (pLM ? *pLM : EmptyList());
|
||||
}
|
||||
|
||||
//! Returns the original shapes which images contain the
|
||||
//! the given shape with REVERSED orientation.
|
||||
//! @param theS [in] The shape for which the materials are necessary.
|
||||
const TopTools_ListOfShape& MaterialsOnNegativeSide(const TopoDS_Shape& theS)
|
||||
{
|
||||
const TopTools_ListOfShape* pLM = myMaterials.Seek(theS.Oriented(TopAbs_REVERSED));
|
||||
return (pLM ? *pLM : EmptyList());
|
||||
}
|
||||
|
||||
|
||||
public: //! @name History methods
|
||||
|
||||
//! Returns the history of operations
|
||||
const Handle(BRepTools_History)& History() const
|
||||
{
|
||||
return myHistory;
|
||||
}
|
||||
|
||||
//! Returns the list of shapes modified from the given shape.
|
||||
//! @param theS [in] The shape for which the modified shapes are necessary.
|
||||
const TopTools_ListOfShape& GetModified(const TopoDS_Shape& theS)
|
||||
{
|
||||
return (myHistory.IsNull() ? EmptyList() : myHistory->Modified(theS));
|
||||
}
|
||||
|
||||
//! Returns the list of original shapes from which the current shape has been created.
|
||||
//! @param theS [in] The shape for which the origins are necessary.
|
||||
const TopTools_ListOfShape& GetOrigins(const TopoDS_Shape& theS)
|
||||
{
|
||||
const TopTools_ListOfShape* pLOr = myOrigins.Seek(theS);
|
||||
return (pLOr ? *pLOr : EmptyList());
|
||||
}
|
||||
|
||||
|
||||
public: //! @name Getting the result shapes
|
||||
|
||||
//! Returns the resulting connected shape
|
||||
const TopoDS_Shape& Shape() const
|
||||
{
|
||||
return myGlued;
|
||||
}
|
||||
|
||||
//! Returns the resulting periodic & repeated shape
|
||||
const TopoDS_Shape& PeriodicShape() const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
|
||||
|
||||
public: //! @name Clearing the contents of the algorithm from previous runs
|
||||
|
||||
//! Clears the contents of the algorithm.
|
||||
void Clear()
|
||||
{
|
||||
BOPAlgo_Options::Clear();
|
||||
myArguments.Clear();
|
||||
myAllInputsMap.Clear();
|
||||
myPeriodicityMaker.Clear();
|
||||
myOrigins.Clear();
|
||||
myMaterials.Clear();
|
||||
if (!myGlueHistory.IsNull())
|
||||
myGlueHistory->Clear();
|
||||
if (!myHistory.IsNull())
|
||||
myHistory->Clear();
|
||||
myGlued.Nullify();
|
||||
myShape.Nullify();
|
||||
}
|
||||
|
||||
|
||||
protected: //! @name Protected methods performing the operation
|
||||
|
||||
//! Checks the validity of input data.
|
||||
Standard_EXPORT void CheckData();
|
||||
|
||||
//! Makes the argument shapes connected (or glued).
|
||||
Standard_EXPORT void MakeConnected();
|
||||
|
||||
//! Associates the materials transitions for the border elements:
|
||||
//! - For input Solids, associates the Faces to Solids;
|
||||
//! - For input Faces, associates the Edges to Faces;
|
||||
//! - For input Edges, associates the Vertices to Edges.
|
||||
Standard_EXPORT void AssociateMaterials();
|
||||
|
||||
//! Fills the map of origins
|
||||
Standard_EXPORT void FillOrigins();
|
||||
|
||||
//! Updates the history, material associations, origins map
|
||||
//! after periodicity operations.
|
||||
Standard_EXPORT void Update();
|
||||
|
||||
private:
|
||||
|
||||
//! Returns an empty list.
|
||||
const TopTools_ListOfShape& EmptyList()
|
||||
{
|
||||
static const TopTools_ListOfShape anEmptyList;
|
||||
return anEmptyList;
|
||||
}
|
||||
|
||||
protected: //! @name Fields
|
||||
|
||||
// Inputs
|
||||
TopTools_ListOfShape myArguments; //!< Input shapes for making them connected
|
||||
TopTools_IndexedMapOfShape myAllInputsMap; //!< Map of all BRep sub-elements of the input shapes
|
||||
|
||||
// Tools
|
||||
BOPAlgo_MakePeriodic myPeriodicityMaker; //!< Tool for making the shape periodic
|
||||
|
||||
// Results
|
||||
NCollection_DataMap
|
||||
<TopoDS_Shape,
|
||||
TopTools_ListOfShape,
|
||||
TopTools_OrientedShapeMapHasher> myMaterials; //!< Map of the materials associations
|
||||
//! for the border elements
|
||||
TopTools_DataMapOfShapeListOfShape myOrigins; //!< Map of origins
|
||||
//! (allows tracking the shape's ancestors)
|
||||
|
||||
Handle(BRepTools_History) myGlueHistory; //!< Gluing History
|
||||
Handle(BRepTools_History) myHistory; //!< Final History of shapes modifications
|
||||
//! (including making the shape periodic and repetitions)
|
||||
|
||||
TopoDS_Shape myGlued; //!< The resulting connected (glued) shape
|
||||
TopoDS_Shape myShape; //!< The resulting shape
|
||||
};
|
||||
|
||||
#endif // _BOPAlgo_MakeConnected_HeaderFile
|
@@ -27,6 +27,8 @@ BOPAlgo_CheckResult.cxx
|
||||
BOPAlgo_CheckResult.hxx
|
||||
BOPAlgo_CheckStatus.hxx
|
||||
BOPAlgo_ListOfCheckResult.hxx
|
||||
BOPAlgo_MakeConnected.cxx
|
||||
BOPAlgo_MakeConnected.hxx
|
||||
BOPAlgo_MakePeriodic.cxx
|
||||
BOPAlgo_MakePeriodic.hxx
|
||||
BOPAlgo_MakerVolume.cxx
|
||||
|
Reference in New Issue
Block a user