Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mzernova committed Jan 16, 2025
1 parent fe88bed commit b0b47e7
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 215 deletions.
25 changes: 12 additions & 13 deletions src/RWMesh/RWMesh_EdgeIterator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
// function : RWMesh_EdgeIterator
// purpose :
// =======================================================================
RWMesh_EdgeIterator::RWMesh_EdgeIterator (const TDF_Label& theLabel,
const TopLoc_Location& theLocation,
const Standard_Boolean theToMapColors,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator (theLabel, theLocation, TopAbs_EDGE, theToMapColors, theStyle)
RWMesh_EdgeIterator::RWMesh_EdgeIterator(const TDF_Label& theLabel,
const TopLoc_Location& theLocation,
const Standard_Boolean theToMapColors,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator(theLabel, theLocation, TopAbs_EDGE, theToMapColors, theStyle)
{
Next();
}
Expand All @@ -36,9 +36,9 @@ RWMesh_EdgeIterator::RWMesh_EdgeIterator (const TDF_Label& theLabel,
// function : RWMesh_EdgeIterator
// purpose :
// =======================================================================
RWMesh_EdgeIterator::RWMesh_EdgeIterator (const TopoDS_Shape& theShape,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator (theShape, TopAbs_EDGE, theStyle)
RWMesh_EdgeIterator::RWMesh_EdgeIterator(const TopoDS_Shape& theShape,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator(theShape, TopAbs_EDGE, theStyle)
{
Next();
}
Expand All @@ -51,11 +51,10 @@ void RWMesh_EdgeIterator::Next()
{
for (; myIter.More(); myIter.Next())
{
myEdge = TopoDS::Edge (myIter.Current());
myPolygon3D = BRep_Tool::Polygon3D (myEdge, myLocation);
myTrsf = myLocation.Transformation();
if (myPolygon3D.IsNull()
|| myPolygon3D->NbNodes() == 0)
myEdge = TopoDS::Edge(myIter.Current());
myPolygon3D = BRep_Tool::Polygon3D(myEdge, myLocation);
myTrsf = myLocation.Transformation();
if (myPolygon3D.IsNull() || myPolygon3D->NbNodes() == 0)
{
resetEdge();
continue;
Expand Down
39 changes: 19 additions & 20 deletions src/RWMesh/RWMesh_EdgeIterator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#ifndef _RWMesh_EdgeIterator_HeaderFile
#define _RWMesh_EdgeIterator_HeaderFile

#include <gp_Trsf.hxx>
#include <NCollection_DataMap.hxx>
#include <Poly_Polygon3D.hxx>
#include <RWMesh_ShapeIterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Edge.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopoDS_Edge.hxx>
#include <XCAFPrs_Style.hxx>
#include <RWMesh_ShapeIterator.hxx>
#include <gp_Trsf.hxx>

#include <algorithm>

Expand All @@ -34,22 +34,21 @@ class TDF_Label;
class RWMesh_EdgeIterator : public RWMesh_ShapeIterator
{
public:

//! Main constructor.
//! @param[in] theLabel The label of the shape.
//! @param[in] theLocation The location of the shape.
//! @param[in] theToMapColors Flag to indicate if colors should be mapped.
//! @param[in] theStyle The style of the shape.
Standard_EXPORT RWMesh_EdgeIterator (const TDF_Label& theLabel,
const TopLoc_Location& theLocation,
const Standard_Boolean theToMapColors = false,
const XCAFPrs_Style& theStyle = XCAFPrs_Style());
Standard_EXPORT RWMesh_EdgeIterator(const TDF_Label& theLabel,
const TopLoc_Location& theLocation,
const Standard_Boolean theToMapColors = false,
const XCAFPrs_Style& theStyle = XCAFPrs_Style());

//! Auxiliary constructor.
//! @param[in] theShape The shape to iterate.
//! @param[in] theStyle The style of the shape.
Standard_EXPORT RWMesh_EdgeIterator (const TopoDS_Shape& theShape,
const XCAFPrs_Style& theStyle = XCAFPrs_Style());
Standard_EXPORT RWMesh_EdgeIterator(const TopoDS_Shape& theShape,
const XCAFPrs_Style& theStyle = XCAFPrs_Style());

//! Return true if iterator points to the valid triangulation.
bool More() const Standard_OVERRIDE { return !myPolygon3D.IsNull(); }
Expand All @@ -73,17 +72,18 @@ public:
}

public:

//! Lower element index in current triangulation.
Standard_Integer ElemLower() const Standard_OVERRIDE { return 1; }

//! Upper element index in current triangulation.
Standard_Integer ElemUpper() const Standard_OVERRIDE { return myPolygon3D->NbNodes(); }

public:

//! Return number of nodes for the current edge.
Standard_Integer NbNodes() const Standard_OVERRIDE { return !myPolygon3D.IsNull() ? myPolygon3D->NbNodes() : 0; }
Standard_Integer NbNodes() const Standard_OVERRIDE
{
return !myPolygon3D.IsNull() ? myPolygon3D->NbNodes() : 0;
}

//! Lower node index in current triangulation.
Standard_Integer NodeLower() const Standard_OVERRIDE { return 1; }
Expand All @@ -92,12 +92,13 @@ public:
Standard_Integer NodeUpper() const Standard_OVERRIDE { return myPolygon3D->NbNodes(); }

public:

//! Return the node with specified index with applied transformation.
gp_Pnt node (const Standard_Integer theNode) const Standard_OVERRIDE { return myPolygon3D->Nodes().Value (theNode); }
gp_Pnt node(const Standard_Integer theNode) const Standard_OVERRIDE
{
return myPolygon3D->Nodes().Value(theNode);
}

private:

//! Reset information for current edge.
void resetEdge()
{
Expand All @@ -110,10 +111,8 @@ private:
void initEdge();

private:

TopoDS_Edge myEdge; //!< current edge
Handle(Poly_Polygon3D) myPolygon3D; //!< geometry of current edge

TopoDS_Edge myEdge; //!< current edge
Handle(Poly_Polygon3D) myPolygon3D; //!< geometry of current edge
};

#endif // _RWMesh_EdgeIterator_HeaderFile
64 changes: 31 additions & 33 deletions src/RWMesh/RWMesh_FaceIterator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,52 @@
// function : RWMesh_FaceIterator
// purpose :
// =======================================================================
RWMesh_FaceIterator::RWMesh_FaceIterator (const TDF_Label& theLabel,
const TopLoc_Location& theLocation,
const Standard_Boolean theToMapColors,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator (theLabel, theLocation, TopAbs_FACE, theToMapColors, theStyle),
mySLTool (1, 1e-12),
myHasNormals (false),
myIsMirrored (false)
{
RWMesh_FaceIterator::RWMesh_FaceIterator(const TDF_Label& theLabel,
const TopLoc_Location& theLocation,
const Standard_Boolean theToMapColors,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator(theLabel, theLocation, TopAbs_FACE, theToMapColors, theStyle),
mySLTool(1, 1e-12),
myHasNormals(false),
myIsMirrored(false)
{
Next();
}

// =======================================================================
// function : RWMesh_FaceIterator
// purpose :
// =======================================================================
RWMesh_FaceIterator::RWMesh_FaceIterator (const TopoDS_Shape& theShape,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator (theShape, TopAbs_FACE, theStyle),
mySLTool (1, 1e-12),
myHasNormals (false),
myIsMirrored (false)
{
RWMesh_FaceIterator::RWMesh_FaceIterator(const TopoDS_Shape& theShape,
const XCAFPrs_Style& theStyle)
: RWMesh_ShapeIterator(theShape, TopAbs_FACE, theStyle),
mySLTool(1, 1e-12),
myHasNormals(false),
myIsMirrored(false)
{
Next();
}

// =======================================================================
// function : normal
// purpose :
// =======================================================================
gp_Dir RWMesh_FaceIterator::normal (Standard_Integer theNode) const
gp_Dir RWMesh_FaceIterator::normal(Standard_Integer theNode) const
{
gp_Dir aNormal (gp::DZ());
gp_Dir aNormal(gp::DZ());
if (myPolyTriang->HasNormals())
{
Graphic3d_Vec3 aNormVec3;
myPolyTriang->Normal (theNode, aNormVec3);
myPolyTriang->Normal(theNode, aNormVec3);
if (aNormVec3.Modulus() != 0.0f)
{
aNormal.SetCoord (aNormVec3.x(), aNormVec3.y(), aNormVec3.z());
aNormal.SetCoord(aNormVec3.x(), aNormVec3.y(), aNormVec3.z());
}
}
else if (myHasNormals
&& myPolyTriang->HasUVNodes())
else if (myHasNormals && myPolyTriang->HasUVNodes())
{
const gp_XY anUV = myPolyTriang->UVNode (theNode).XY();
mySLTool.SetParameters (anUV.X(), anUV.Y());
const gp_XY anUV = myPolyTriang->UVNode(theNode).XY();
mySLTool.SetParameters(anUV.X(), anUV.Y());
if (mySLTool.IsNormalDefined())
{
aNormal = mySLTool.Normal();
Expand All @@ -87,11 +86,10 @@ void RWMesh_FaceIterator::Next()
{
for (; myIter.More(); myIter.Next())
{
myFace = TopoDS::Face (myIter.Current());
myPolyTriang = BRep_Tool::Triangulation (myFace, myLocation);
myFace = TopoDS::Face(myIter.Current());
myPolyTriang = BRep_Tool::Triangulation(myFace, myLocation);
myTrsf = myLocation.Transformation();
if (myPolyTriang.IsNull()
|| myPolyTriang->NbTriangles() == 0)
if (myPolyTriang.IsNull() || myPolyTriang->NbTriangles() == 0)
{
resetFace();
continue;
Expand Down Expand Up @@ -119,13 +117,13 @@ void RWMesh_FaceIterator::initFace()
}
if (myPolyTriang->HasUVNodes() && !myHasNormals)
{
TopoDS_Face aFaceFwd = TopoDS::Face (myFace.Oriented (TopAbs_FORWARD));
aFaceFwd.Location (TopLoc_Location());
TopoDS_Face aFaceFwd = TopoDS::Face(myFace.Oriented(TopAbs_FORWARD));
aFaceFwd.Location(TopLoc_Location());
TopLoc_Location aLoc;
if (!BRep_Tool::Surface (aFaceFwd, aLoc).IsNull())
if (!BRep_Tool::Surface(aFaceFwd, aLoc).IsNull())
{
myFaceAdaptor.Initialize (aFaceFwd, false);
mySLTool.SetSurface (myFaceAdaptor);
myFaceAdaptor.Initialize(aFaceFwd, false);
mySLTool.SetSurface(myFaceAdaptor);
myHasNormals = true;
}
}
Expand Down
Loading

0 comments on commit b0b47e7

Please sign in to comment.