mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-07-13 15:08:59 +08:00
- BRepMesh converted to nocdlpack, - Collections are defined in namespace BRepMesh, - Doxygen comments corrected to use @ instead of \.
149 lines
4.8 KiB
C++
149 lines
4.8 KiB
C++
// Created on: 2011-06-02
|
|
// Created by: Oleg AGASHIN
|
|
// Copyright (c) 2011-2014 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 <BRepMesh_VertexTool.hxx>
|
|
#include <gp_XY.hxx>
|
|
#include <gp_XYZ.hxx>
|
|
#include <Precision.hxx>
|
|
#include <BRepMesh_Vertex.hxx>
|
|
#include <BRepMesh_VertexInspector.hxx>
|
|
|
|
//=======================================================================
|
|
//function : Inspect
|
|
//purpose :
|
|
//=======================================================================
|
|
NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect(
|
|
const Standard_Integer theTarget)
|
|
{
|
|
const BRepMesh_Vertex& aVertex = myVertices(theTarget - 1);
|
|
if(aVertex.Movability() == BRepMesh_Deleted)
|
|
{
|
|
myDelNodes.Append(theTarget);
|
|
return CellFilter_Purge;
|
|
}
|
|
|
|
gp_XY aVec = (myPoint - aVertex.Coord());
|
|
Standard_Boolean inTol;
|
|
if (Abs(myTolerance[1]) < Precision::Confusion())
|
|
{
|
|
inTol = aVec.SquareModulus() < myTolerance[0];
|
|
}
|
|
else
|
|
{
|
|
inTol = ((aVec.X() * aVec.X()) < myTolerance[0]) &&
|
|
((aVec.Y() * aVec.Y()) < myTolerance[1]);
|
|
}
|
|
if (inTol)
|
|
myResIndices.Append(theTarget);
|
|
|
|
return CellFilter_Keep;
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : BRepMesh_VertexTool
|
|
//purpose :
|
|
//=======================================================================
|
|
BRepMesh_VertexTool::BRepMesh_VertexTool(
|
|
const Standard_Integer theReservedSize,
|
|
const Handle(NCollection_IncAllocator)& theAllocator)
|
|
: myAllocator (theAllocator),
|
|
myCellFilter(0., myAllocator),
|
|
mySelector (Max(theReservedSize, 64),myAllocator)
|
|
{
|
|
const Standard_Real aTol = Precision::Confusion();
|
|
SetCellSize ( aTol + 0.05 * aTol );
|
|
SetTolerance( aTol, aTol );
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Add
|
|
//purpose :
|
|
//=======================================================================
|
|
Standard_Integer BRepMesh_VertexTool::Add(const BRepMesh_Vertex& theVertex)
|
|
{
|
|
Standard_Integer aIndex = FindIndex(theVertex);
|
|
if (aIndex == 0)
|
|
{
|
|
BRepMesh::ListOfInteger aParams(myAllocator);
|
|
aIndex = Add(theVertex, aParams);
|
|
}
|
|
return aIndex;
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Add
|
|
//purpose :
|
|
//=======================================================================
|
|
Standard_Integer BRepMesh_VertexTool::Add(
|
|
const BRepMesh_Vertex& theVertex,
|
|
const BRepMesh::ListOfInteger& theParams)
|
|
{
|
|
Standard_Integer aIndex = mySelector.Add(theVertex);
|
|
myLinksMap.Bind(aIndex, theParams);
|
|
|
|
gp_XY aMinPnt, aMaxPnt;
|
|
expandPoint(theVertex.Coord(), aMinPnt, aMaxPnt);
|
|
myCellFilter.Add(aIndex, aMinPnt, aMaxPnt);
|
|
|
|
return aIndex;
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Delete
|
|
//purpose :
|
|
//=======================================================================
|
|
void BRepMesh_VertexTool::Delete(const Standard_Integer theIndex)
|
|
{
|
|
BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
|
|
|
|
gp_XY aMinPnt, aMaxPnt;
|
|
expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
|
|
|
|
myCellFilter.Remove(theIndex, aMinPnt, aMaxPnt);
|
|
mySelector.Delete(theIndex);
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Substitute
|
|
//purpose :
|
|
//=======================================================================
|
|
void BRepMesh_VertexTool::Substitute(
|
|
const Standard_Integer theIndex,
|
|
const BRepMesh_Vertex& theVertex,
|
|
const BRepMesh::ListOfInteger& theData)
|
|
{
|
|
BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
|
|
|
|
gp_XY aMinPnt, aMaxPnt;
|
|
expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
|
|
|
|
myCellFilter.Remove(theIndex, aMinPnt, aMaxPnt);
|
|
|
|
aV = theVertex;
|
|
expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
|
|
myCellFilter.Add(theIndex, aMinPnt, aMaxPnt);
|
|
FindFromIndex(theIndex) = theData;
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Statistics
|
|
//purpose :
|
|
//=======================================================================
|
|
void BRepMesh_VertexTool::Statistics(Standard_OStream& theStream) const
|
|
{
|
|
theStream << "\nStructure Statistics\n---------------\n\n";
|
|
theStream << "This structure has " << mySelector.NbVertices() << " Nodes\n\n";
|
|
}
|