1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Configuration - Reorganize repository structure #450

Reorganizing structure to have Module/TK/Package/FILES structure.
New structure reflect the structure inside IDE.
Migrate FILES, PACKAGES, EXTRLIB to CMake version to handle changes on updates.
No changes were done to installation layout, all installation result keep as before.
The migration was done using python script, see PR, which refactor automatically the structure.
Updated doc generation to have valid path to modules, toolkits and packages.
In case of PR into new version, IR-790 can be used as a target for the previous version.
This commit is contained in:
Pasukhin Dmitry
2025-03-20 00:39:26 +00:00
committed by GitHub
parent 606d652b41
commit 5647b46a34
15528 changed files with 18633 additions and 15727 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,378 @@
// Created on: 1991-07-01
// Created by: Remi LEQUETTE
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_Builder_HeaderFile
#define _BRep_Builder_HeaderFile
#include <GeomAbs_Shape.hxx>
#include <Poly_ListOfTriangulation.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopoDS_Builder.hxx>
class TopoDS_Face;
class Geom_Surface;
class TopLoc_Location;
class Poly_Triangulation;
class TopoDS_Edge;
class Geom_Curve;
class Poly_Polygon3D;
class Poly_PolygonOnTriangulation;
class Geom2d_Curve;
class gp_Pnt2d;
class Poly_Polygon2D;
class TopoDS_Vertex;
class gp_Pnt;
//! A framework providing advanced tolerance control.
//! It is used to build Shapes.
//! If tolerance control is required, you are advised to:
//! 1. build a default precision for topology, using the
//! classes provided in the BRepAPI package
//! 2. update the tolerance of the resulting shape.
//! Note that only vertices, edges and faces have
//! meaningful tolerance control. The tolerance value
//! must always comply with the condition that face
//! tolerances are more restrictive than edge tolerances
//! which are more restrictive than vertex tolerances. In
//! other words: Tol(Vertex) >= Tol(Edge) >= Tol(Face).
//! Other rules in setting tolerance include:
//! - you can open up tolerance but should never restrict it
//! - an edge cannot be included within the fusion of the
//! tolerance spheres of two vertices
class BRep_Builder : public TopoDS_Builder
{
public:
DEFINE_STANDARD_ALLOC
//! Makes an undefined Face.
void MakeFace(TopoDS_Face& F) const;
//! Makes a Face with a surface.
Standard_EXPORT void MakeFace(TopoDS_Face& F,
const Handle(Geom_Surface)& S,
const Standard_Real Tol) const;
//! Makes a Face with a surface and a location.
Standard_EXPORT void MakeFace(TopoDS_Face& F,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Makes a theFace with a single triangulation. The triangulation
//! is in the same reference system than the TFace.
Standard_EXPORT void MakeFace(TopoDS_Face& theFace,
const Handle(Poly_Triangulation)& theTriangulation) const;
//! Makes a Face with a list of triangulations and active one.
//! Use NULL active triangulation to set the first triangulation in list as active.
//! The triangulations is in the same reference system than the TFace.
Standard_EXPORT void MakeFace(
TopoDS_Face& theFace,
const Poly_ListOfTriangulation& theTriangulations,
const Handle(Poly_Triangulation)& theActiveTriangulation = Handle(Poly_Triangulation)()) const;
//! Updates the face F using the tolerance value Tol,
//! surface S and location Location.
Standard_EXPORT void UpdateFace(const TopoDS_Face& F,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Changes a face triangulation.
//! A NULL theTriangulation removes face triangulations.
//! If theToReset is TRUE face triangulations will be reset to new list with only one input
//! triangulation that will be active. Else if theTriangulation is contained in internal
//! triangulations list it will be made active,
//! else the active triangulation will be replaced to theTriangulation one.
Standard_EXPORT void UpdateFace(const TopoDS_Face& theFace,
const Handle(Poly_Triangulation)& theTriangulation,
const Standard_Boolean theToReset = true) const;
//! Updates the face Tolerance.
Standard_EXPORT void UpdateFace(const TopoDS_Face& F, const Standard_Real Tol) const;
//! Sets the NaturalRestriction flag of the face.
Standard_EXPORT void NaturalRestriction(const TopoDS_Face& F, const Standard_Boolean N) const;
//! Makes an undefined Edge (no geometry).
Standard_EXPORT void MakeEdge(TopoDS_Edge& E) const;
//! Makes an Edge with a curve.
void MakeEdge(TopoDS_Edge& E, const Handle(Geom_Curve)& C, const Standard_Real Tol) const;
//! Makes an Edge with a curve and a location.
void MakeEdge(TopoDS_Edge& E,
const Handle(Geom_Curve)& C,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Makes an Edge with a polygon 3d.
void MakeEdge(TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P) const;
//! makes an Edge polygon on Triangulation.
void MakeEdge(TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& N,
const Handle(Poly_Triangulation)& T) const;
//! makes an Edge polygon on Triangulation.
void MakeEdge(TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& N,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const;
//! Sets a 3D curve for the edge.
//! If <C> is a null handle, remove any existing 3d curve.
void UpdateEdge(const TopoDS_Edge& E, const Handle(Geom_Curve)& C, const Standard_Real Tol) const;
//! Sets a 3D curve for the edge.
//! If <C> is a null handle, remove any existing 3d curve.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom_Curve)& C,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Sets a pcurve for the edge on the face.
//! If <C> is a null handle, remove any existing pcurve.
void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C,
const TopoDS_Face& F,
const Standard_Real Tol) const;
//! Sets pcurves for the edge on the closed face. If
//! <C1> or <C2> is a null handle, remove any existing
//! pcurve.
void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const TopoDS_Face& F,
const Standard_Real Tol) const;
//! Sets a pcurve for the edge on the face.
//! If <C> is a null handle, remove any existing pcurve.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Sets a pcurve for the edge on the face.
//! If <C> is a null handle, remove any existing pcurve.
//! Sets UV bounds for curve repsentation
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol,
const gp_Pnt2d& Pf,
const gp_Pnt2d& Pl) const;
//! Sets pcurves for the edge on the closed surface.
//! <C1> or <C2> is a null handle, remove any existing
//! pcurve.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Sets pcurves for the edge on the closed surface.
//! <C1> or <C2> is a null handle, remove any existing
//! pcurve.
//! Sets UV bounds for curve repsentation
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol,
const gp_Pnt2d& Pf,
const gp_Pnt2d& Pl) const;
//! Changes an Edge 3D polygon.
//! A null Polygon removes the 3d Polygon.
void UpdateEdge(const TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P) const;
//! Changes an Edge 3D polygon.
//! A null Polygon removes the 3d Polygon.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_Polygon3D)& P,
const TopLoc_Location& L) const;
//! Changes an Edge polygon on Triangulation.
void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& N,
const Handle(Poly_Triangulation)& T) const;
//! Changes an Edge polygon on Triangulation.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& N,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const;
//! Changes an Edge polygon on Triangulation.
void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& N1,
const Handle(Poly_PolygonOnTriangulation)& N2,
const Handle(Poly_Triangulation)& T) const;
//! Changes an Edge polygon on Triangulation.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& N1,
const Handle(Poly_PolygonOnTriangulation)& N2,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const;
//! Changes Edge polygon on a face.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_Polygon2D)& P,
const TopoDS_Face& S) const;
//! Changes Edge polygon on a face.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_Polygon2D)& P,
const Handle(Geom_Surface)& S,
const TopLoc_Location& T) const;
//! Changes Edge polygons on a face.
//!
//! A null Polygon removes the 2d Polygon.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_Polygon2D)& P1,
const Handle(Poly_Polygon2D)& P2,
const TopoDS_Face& S) const;
//! Changes Edge polygons on a face.
//!
//! A null Polygon removes the 2d Polygon.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_Polygon2D)& P1,
const Handle(Poly_Polygon2D)& P2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const;
//! Updates the edge tolerance.
Standard_EXPORT void UpdateEdge(const TopoDS_Edge& E, const Standard_Real Tol) const;
//! Sets the geometric continuity on the edge.
Standard_EXPORT void Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const GeomAbs_Shape C) const;
//! Sets the geometric continuity on the edge.
Standard_EXPORT void Continuity(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2,
const GeomAbs_Shape C) const;
//! Sets the same parameter flag for the edge <E>.
Standard_EXPORT void SameParameter(const TopoDS_Edge& E, const Standard_Boolean S) const;
//! Sets the same range flag for the edge <E>.
Standard_EXPORT void SameRange(const TopoDS_Edge& E, const Standard_Boolean S) const;
//! Sets the degenerated flag for the edge <E>.
Standard_EXPORT void Degenerated(const TopoDS_Edge& E, const Standard_Boolean D) const;
//! Sets the range of the 3d curve if Only3d=TRUE,
//! otherwise sets the range to all the representations
Standard_EXPORT void Range(const TopoDS_Edge& E,
const Standard_Real First,
const Standard_Real Last,
const Standard_Boolean Only3d = Standard_False) const;
//! Sets the range of the edge on the pcurve on the
//! surface.
Standard_EXPORT void Range(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real First,
const Standard_Real Last) const;
//! Sets the range of the edge on the pcurve on the face.
void Range(const TopoDS_Edge& E,
const TopoDS_Face& F,
const Standard_Real First,
const Standard_Real Last) const;
//! Add to <Eout> the geometric representations of
//! <Ein>.
Standard_EXPORT void Transfert(const TopoDS_Edge& Ein, const TopoDS_Edge& Eout) const;
//! Makes an udefined vertex without geometry.
void MakeVertex(TopoDS_Vertex& V) const;
//! Makes a vertex from a 3D point.
void MakeVertex(TopoDS_Vertex& V, const gp_Pnt& P, const Standard_Real Tol) const;
//! Sets a 3D point on the vertex.
Standard_EXPORT void UpdateVertex(const TopoDS_Vertex& V,
const gp_Pnt& P,
const Standard_Real Tol) const;
//! Sets the parameter for the vertex on the edge
//! curves.
Standard_EXPORT void UpdateVertex(const TopoDS_Vertex& V,
const Standard_Real P,
const TopoDS_Edge& E,
const Standard_Real Tol) const;
//! Sets the parameter for the vertex on the edge
//! pcurve on the face.
void UpdateVertex(const TopoDS_Vertex& V,
const Standard_Real P,
const TopoDS_Edge& E,
const TopoDS_Face& F,
const Standard_Real Tol) const;
//! Sets the parameter for the vertex on the edge
//! pcurve on the surface.
Standard_EXPORT void UpdateVertex(const TopoDS_Vertex& V,
const Standard_Real P,
const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const Standard_Real Tol) const;
//! Sets the parameters for the vertex on the face.
Standard_EXPORT void UpdateVertex(const TopoDS_Vertex& Ve,
const Standard_Real U,
const Standard_Real V,
const TopoDS_Face& F,
const Standard_Real Tol) const;
//! Updates the vertex tolerance.
Standard_EXPORT void UpdateVertex(const TopoDS_Vertex& V, const Standard_Real Tol) const;
//! Transfert the parameters of Vin on Ein as the
//! parameter of Vout on Eout.
Standard_EXPORT void Transfert(const TopoDS_Edge& Ein,
const TopoDS_Edge& Eout,
const TopoDS_Vertex& Vin,
const TopoDS_Vertex& Vout) const;
protected:
private:
};
#include <BRep_Builder.lxx>
#endif // _BRep_Builder_HeaderFile

View File

@@ -0,0 +1,226 @@
// Created on: 1991-07-02
// Created by: Remi LEQUETTE
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-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 <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_TFace.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_Tool.hxx>
//=======================================================================
// function : MakeFace
// purpose :
//=======================================================================
inline void BRep_Builder::MakeFace(TopoDS_Face& F) const
{
Handle(BRep_TFace) TF = new BRep_TFace();
MakeShape(F, TF);
}
//=======================================================================
// function : MakeEdge
// purpose : make edge from curve
//=======================================================================
inline void BRep_Builder::MakeEdge(TopoDS_Edge& E,
const Handle(Geom_Curve)& C,
const Standard_Real Tol) const
{
MakeEdge(E);
UpdateEdge(E, C, TopLoc_Location(), Tol);
}
//=======================================================================
// function : MakeEdge
// purpose : make edge from curve
//=======================================================================
inline void BRep_Builder::MakeEdge(TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P) const
{
MakeEdge(E);
UpdateEdge(E, P);
}
//=======================================================================
// function : MakeEdge
// purpose : make edge from triangulation
//=======================================================================
inline void BRep_Builder::MakeEdge(TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& P,
const Handle(Poly_Triangulation)& T) const
{
MakeEdge(E);
UpdateEdge(E, P, T, TopLoc_Location());
}
//=======================================================================
// function : MakeEdge
// purpose : make edge from triangulation
//=======================================================================
inline void BRep_Builder::MakeEdge(TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& P,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const
{
MakeEdge(E);
UpdateEdge(E, P, T, L);
}
//=======================================================================
// function : MakeEdge
// purpose : make edge from curve
//=======================================================================
inline void BRep_Builder::MakeEdge(TopoDS_Edge& E,
const Handle(Geom_Curve)& C,
const TopLoc_Location& L,
const Standard_Real Tol) const
{
MakeEdge(E);
UpdateEdge(E, C, L, Tol);
}
//=======================================================================
// function : UpdateEdge
// purpose :
//=======================================================================
inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom_Curve)& C,
const Standard_Real Tol) const
{
UpdateEdge(E, C, TopLoc_Location(), Tol);
}
//=======================================================================
// function : UpdateEdge
// purpose :
//=======================================================================
inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C,
const TopoDS_Face& F,
const Standard_Real Tol) const
{
TopLoc_Location l;
UpdateEdge(E, C, BRep_Tool::Surface(F, l), l, Tol);
}
//=======================================================================
// function : UpdateEdge
// purpose :
//=======================================================================
inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const TopoDS_Face& F,
const Standard_Real Tol) const
{
TopLoc_Location l;
UpdateEdge(E, C1, C2, BRep_Tool::Surface(F, l), l, Tol);
}
//=======================================================================
// function : UpdateEdge
// purpose :
//=======================================================================
inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, const Handle(Poly_Polygon3D)& P) const
{
UpdateEdge(E, P, TopLoc_Location());
}
//=======================================================================
// function : UpdateEdge
// purpose :
//=======================================================================
inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& P,
const Handle(Poly_Triangulation)& T) const
{
UpdateEdge(E, P, T, TopLoc_Location());
}
//=======================================================================
// function : UpdateEdge
// purpose :
//=======================================================================
inline void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Handle(Poly_PolygonOnTriangulation)& P1,
const Handle(Poly_PolygonOnTriangulation)& P2,
const Handle(Poly_Triangulation)& T) const
{
UpdateEdge(E, P1, P2, T, TopLoc_Location());
}
//=======================================================================
// function : Range
// purpose :
//=======================================================================
inline void BRep_Builder::Range(const TopoDS_Edge& E,
const TopoDS_Face& F,
const Standard_Real First,
const Standard_Real Last) const
{
TopLoc_Location l;
Range(E, BRep_Tool::Surface(F, l), l, First, Last);
}
//=======================================================================
// function : MakeVertex
// purpose : undefined vertex
//=======================================================================
inline void BRep_Builder::MakeVertex(TopoDS_Vertex& V) const
{
Handle(BRep_TVertex) TV = new BRep_TVertex();
MakeShape(V, TV);
}
//=======================================================================
// function : MakeVertex
// purpose : vertex from 3d point
//=======================================================================
inline void BRep_Builder::MakeVertex(TopoDS_Vertex& V,
const gp_Pnt& P,
const Standard_Real Tol) const
{
MakeVertex(V);
UpdateVertex(V, P, Tol);
}
//=======================================================================
// function : UpdateVertex
// purpose : update vertex with parameter on edge on face
//=======================================================================
inline void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V,
const Standard_Real Par,
const TopoDS_Edge& E,
const TopoDS_Face& F,
const Standard_Real Tol) const
{
TopLoc_Location l;
UpdateVertex(V, Par, E, BRep_Tool::Surface(F, l), l, Tol);
}

View File

@@ -0,0 +1,84 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_Curve3D.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <Geom_Curve.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_Curve3D, BRep_GCurve)
//=================================================================================================
BRep_Curve3D::BRep_Curve3D(const Handle(Geom_Curve)& C, const TopLoc_Location& L)
: BRep_GCurve(L,
C.IsNull() ? RealFirst() : C->FirstParameter(),
C.IsNull() ? RealLast() : C->LastParameter()),
myCurve(C)
{
}
//=================================================================================================
void BRep_Curve3D::D0(const Standard_Real U, gp_Pnt& P) const
{
// should be D0 NYI
P = myCurve->Value(U);
}
//=================================================================================================
Standard_Boolean BRep_Curve3D::IsCurve3D() const
{
return Standard_True;
}
//=================================================================================================
const Handle(Geom_Curve)& BRep_Curve3D::Curve3D() const
{
return myCurve;
}
//=================================================================================================
void BRep_Curve3D::Curve3D(const Handle(Geom_Curve)& C)
{
myCurve = C;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_Curve3D::Copy() const
{
Handle(BRep_Curve3D) C = new BRep_Curve3D(myCurve, Location());
C->SetRange(First(), Last());
return C;
}
//=================================================================================================
void BRep_Curve3D::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_GCurve)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myCurve.get())
}

View File

@@ -0,0 +1,63 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_Curve3D_HeaderFile
#define _BRep_Curve3D_HeaderFile
#include <Standard.hxx>
#include <BRep_GCurve.hxx>
#include <Standard_Real.hxx>
class Geom_Curve;
class TopLoc_Location;
class gp_Pnt;
class BRep_CurveRepresentation;
class BRep_Curve3D;
DEFINE_STANDARD_HANDLE(BRep_Curve3D, BRep_GCurve)
//! Representation of a curve by a 3D curve.
class BRep_Curve3D : public BRep_GCurve
{
public:
Standard_EXPORT BRep_Curve3D(const Handle(Geom_Curve)& C, const TopLoc_Location& L);
//! Computes the point at parameter U.
Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
//! Returns True.
Standard_EXPORT virtual Standard_Boolean IsCurve3D() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom_Curve)& Curve3D() const Standard_OVERRIDE;
Standard_EXPORT virtual void Curve3D(const Handle(Geom_Curve)& C) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_Curve3D, BRep_GCurve)
protected:
private:
Handle(Geom_Curve) myCurve;
};
#endif // _BRep_Curve3D_HeaderFile

View File

@@ -0,0 +1,124 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveOn2Surfaces.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_CurveOn2Surfaces, BRep_CurveRepresentation)
//=================================================================================================
BRep_CurveOn2Surfaces::BRep_CurveOn2Surfaces(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2,
const GeomAbs_Shape C)
: BRep_CurveRepresentation(L1),
mySurface(S1),
mySurface2(S2),
myLocation2(L2),
myContinuity(C)
{
}
//=================================================================================================
void BRep_CurveOn2Surfaces::D0(const Standard_Real, gp_Pnt&) const
{
throw Standard_NullObject("BRep_CurveOn2Surfaces::D0");
}
//=================================================================================================
Standard_Boolean BRep_CurveOn2Surfaces::IsRegularity() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_CurveOn2Surfaces::IsRegularity(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2) const
{
return ((mySurface == S1 && mySurface2 == S2 && myLocation == L1 && myLocation2 == L2)
|| (mySurface == S2 && mySurface2 == S1 && myLocation == L2 && myLocation2 == L1));
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_CurveOn2Surfaces::Surface() const
{
return mySurface;
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_CurveOn2Surfaces::Surface2() const
{
return mySurface2;
}
//=================================================================================================
const TopLoc_Location& BRep_CurveOn2Surfaces::Location2() const
{
return myLocation2;
}
//=================================================================================================
const GeomAbs_Shape& BRep_CurveOn2Surfaces::Continuity() const
{
return myContinuity;
}
//=================================================================================================
void BRep_CurveOn2Surfaces::Continuity(const GeomAbs_Shape C)
{
myContinuity = C;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_CurveOn2Surfaces::Copy() const
{
Handle(BRep_CurveOn2Surfaces) C =
new BRep_CurveOn2Surfaces(Surface(), Surface2(), Location(), Location2(), myContinuity);
return C;
}
//=================================================================================================
void BRep_CurveOn2Surfaces::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_CurveRepresentation)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySurface.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySurface2.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myLocation2)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myContinuity)
}

View File

@@ -0,0 +1,81 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_CurveOn2Surfaces_HeaderFile
#define _BRep_CurveOn2Surfaces_HeaderFile
#include <Standard.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <Standard_Real.hxx>
class Geom_Surface;
class gp_Pnt;
class BRep_CurveOn2Surfaces;
DEFINE_STANDARD_HANDLE(BRep_CurveOn2Surfaces, BRep_CurveRepresentation)
//! Defines a continuity between two surfaces.
class BRep_CurveOn2Surfaces : public BRep_CurveRepresentation
{
public:
Standard_EXPORT BRep_CurveOn2Surfaces(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2,
const GeomAbs_Shape C);
//! Returns True.
Standard_EXPORT virtual Standard_Boolean IsRegularity() const Standard_OVERRIDE;
//! A curve on two surfaces (continuity).
Standard_EXPORT virtual Standard_Boolean IsRegularity(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2) const
Standard_OVERRIDE;
//! Raises an error.
Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const;
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface2() const Standard_OVERRIDE;
Standard_EXPORT virtual const TopLoc_Location& Location2() const Standard_OVERRIDE;
Standard_EXPORT virtual const GeomAbs_Shape& Continuity() const Standard_OVERRIDE;
Standard_EXPORT virtual void Continuity(const GeomAbs_Shape C) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_CurveOn2Surfaces, BRep_CurveRepresentation)
protected:
private:
Handle(Geom_Surface) mySurface;
Handle(Geom_Surface) mySurface2;
TopLoc_Location myLocation2;
GeomAbs_Shape myContinuity;
};
#endif // _BRep_CurveOn2Surfaces_HeaderFile

View File

@@ -0,0 +1,146 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveOnClosedSurface.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_CurveOnClosedSurface, BRep_CurveOnSurface)
//=================================================================================================
BRep_CurveOnClosedSurface::BRep_CurveOnClosedSurface(const Handle(Geom2d_Curve)& PC1,
const Handle(Geom2d_Curve)& PC2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const GeomAbs_Shape C)
: BRep_CurveOnSurface(PC1, S, L),
myPCurve2(PC2),
myContinuity(C)
{
}
//=================================================================================================
Standard_Boolean BRep_CurveOnClosedSurface::IsCurveOnClosedSurface() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_CurveOnClosedSurface::IsRegularity() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_CurveOnClosedSurface::IsRegularity(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2) const
{
return ((Surface() == S1) && (Surface() == S2) && (Location() == L1) && (Location() == L2));
}
//=================================================================================================
const Handle(Geom2d_Curve)& BRep_CurveOnClosedSurface::PCurve2() const
{
return myPCurve2;
}
//=================================================================================================
const GeomAbs_Shape& BRep_CurveOnClosedSurface::Continuity() const
{
return myContinuity;
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_CurveOnClosedSurface::Surface2() const
{
return Surface();
}
//=================================================================================================
const TopLoc_Location& BRep_CurveOnClosedSurface::Location2() const
{
return Location();
}
//=================================================================================================
void BRep_CurveOnClosedSurface::PCurve2(const Handle(Geom2d_Curve)& C)
{
myPCurve2 = C;
}
//=================================================================================================
void BRep_CurveOnClosedSurface::Continuity(const GeomAbs_Shape C)
{
myContinuity = C;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_CurveOnClosedSurface::Copy() const
{
Handle(BRep_CurveOnClosedSurface) C =
new BRep_CurveOnClosedSurface(PCurve(), PCurve2(), Surface(), Location(), myContinuity);
C->SetRange(First(), Last());
C->SetUVPoints(myUV1, myUV2);
C->SetUVPoints2(myUV21, myUV22);
return C;
}
//=================================================================================================
void BRep_CurveOnClosedSurface::Update()
{
if (!Precision::IsNegativeInfinite(First()))
myPCurve2->D0(First(), myUV21);
if (!Precision::IsPositiveInfinite(Last()))
myPCurve2->D0(Last(), myUV22);
BRep_CurveOnSurface::Update();
}
//=================================================================================================
void BRep_CurveOnClosedSurface::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_CurveOnSurface)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPCurve2.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myContinuity)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myUV21)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myUV22)
}

View File

@@ -0,0 +1,97 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_CurveOnClosedSurface_HeaderFile
#define _BRep_CurveOnClosedSurface_HeaderFile
#include <Standard.hxx>
#include <BRep_CurveOnSurface.hxx>
class Geom2d_Curve;
class Geom_Surface;
class TopLoc_Location;
class BRep_CurveRepresentation;
class BRep_CurveOnClosedSurface;
DEFINE_STANDARD_HANDLE(BRep_CurveOnClosedSurface, BRep_CurveOnSurface)
//! Representation of a curve by two pcurves on
//! a closed surface.
class BRep_CurveOnClosedSurface : public BRep_CurveOnSurface
{
public:
Standard_EXPORT BRep_CurveOnClosedSurface(const Handle(Geom2d_Curve)& PC1,
const Handle(Geom2d_Curve)& PC2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const GeomAbs_Shape C);
void SetUVPoints2(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
void UVPoints2(gp_Pnt2d& P1, gp_Pnt2d& P2) const;
//! Returns True.
Standard_EXPORT virtual Standard_Boolean IsCurveOnClosedSurface() const Standard_OVERRIDE;
//! Returns True
Standard_EXPORT virtual Standard_Boolean IsRegularity() const Standard_OVERRIDE;
//! A curve on two surfaces (continuity).
Standard_EXPORT virtual Standard_Boolean IsRegularity(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2) const
Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom2d_Curve)& PCurve2() const Standard_OVERRIDE;
//! Returns Surface()
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface2() const Standard_OVERRIDE;
//! Returns Location()
Standard_EXPORT virtual const TopLoc_Location& Location2() const Standard_OVERRIDE;
Standard_EXPORT virtual const GeomAbs_Shape& Continuity() const Standard_OVERRIDE;
Standard_EXPORT virtual void Continuity(const GeomAbs_Shape C) Standard_OVERRIDE;
Standard_EXPORT virtual void PCurve2(const Handle(Geom2d_Curve)& C) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Recomputes any derived data after a modification.
//! This is called when the range is modified.
Standard_EXPORT virtual void Update() Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_CurveOnClosedSurface, BRep_CurveOnSurface)
protected:
private:
Handle(Geom2d_Curve) myPCurve2;
GeomAbs_Shape myContinuity;
gp_Pnt2d myUV21;
gp_Pnt2d myUV22;
};
#include <BRep_CurveOnClosedSurface.lxx>
#endif // _BRep_CurveOnClosedSurface_HeaderFile

View File

@@ -0,0 +1,37 @@
// Created on: 1993-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : SetUVPoints2
// purpose :
//=======================================================================
inline void BRep_CurveOnClosedSurface::SetUVPoints2(const gp_Pnt2d& P1, const gp_Pnt2d& P2)
{
myUV21 = P1;
myUV22 = P2;
}
//=======================================================================
// function : UVPoints2
// purpose :
//=======================================================================
inline void BRep_CurveOnClosedSurface::UVPoints2(gp_Pnt2d& P1, gp_Pnt2d& P2) const
{
P1 = myUV21;
P2 = myUV22;
}

View File

@@ -0,0 +1,129 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveOnSurface.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_CurveOnSurface, BRep_GCurve)
//=================================================================================================
BRep_CurveOnSurface::BRep_CurveOnSurface(const Handle(Geom2d_Curve)& PC,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L)
: BRep_GCurve(L, PC->FirstParameter(), PC->LastParameter()),
myPCurve(PC),
mySurface(S)
{
}
//=================================================================================================
void BRep_CurveOnSurface::D0(const Standard_Real U, gp_Pnt& P) const
{
// should be D0 NYI
gp_Pnt2d P2d = myPCurve->Value(U);
P = mySurface->Value(P2d.X(), P2d.Y());
P.Transform(myLocation.Transformation());
}
//=================================================================================================
Standard_Boolean BRep_CurveOnSurface::IsCurveOnSurface() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_CurveOnSurface::IsCurveOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
{
return (S == mySurface) && (L == myLocation);
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_CurveOnSurface::Surface() const
{
return mySurface;
}
//=================================================================================================
const Handle(Geom2d_Curve)& BRep_CurveOnSurface::PCurve() const
{
return myPCurve;
}
//=================================================================================================
void BRep_CurveOnSurface::PCurve(const Handle(Geom2d_Curve)& C)
{
myPCurve = C;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_CurveOnSurface::Copy() const
{
Handle(BRep_CurveOnSurface) C = new BRep_CurveOnSurface(myPCurve, mySurface, Location());
C->SetRange(First(), Last());
C->SetUVPoints(myUV1, myUV2);
return C;
}
//=================================================================================================
void BRep_CurveOnSurface::Update()
{
Standard_Real f = First();
Standard_Real l = Last();
Standard_Boolean isneg = Precision::IsNegativeInfinite(f);
Standard_Boolean ispos = Precision::IsPositiveInfinite(l);
if (!isneg)
{
myPCurve->D0(f, myUV1);
}
if (!ispos)
{
myPCurve->D0(l, myUV2);
}
}
//=================================================================================================
void BRep_CurveOnSurface::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_GCurve)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myUV1)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myUV2)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPCurve.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySurface.get())
}

View File

@@ -0,0 +1,89 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_CurveOnSurface_HeaderFile
#define _BRep_CurveOnSurface_HeaderFile
#include <Standard.hxx>
#include <gp_Pnt2d.hxx>
#include <BRep_GCurve.hxx>
#include <Standard_Real.hxx>
class Geom2d_Curve;
class Geom_Surface;
class TopLoc_Location;
class gp_Pnt;
class BRep_CurveRepresentation;
class BRep_CurveOnSurface;
DEFINE_STANDARD_HANDLE(BRep_CurveOnSurface, BRep_GCurve)
//! Representation of a curve by a curve in the
//! parametric space of a surface.
class BRep_CurveOnSurface : public BRep_GCurve
{
public:
Standard_EXPORT BRep_CurveOnSurface(const Handle(Geom2d_Curve)& PC,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
void SetUVPoints(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
void UVPoints(gp_Pnt2d& P1, gp_Pnt2d& P2) const;
//! Computes the point at parameter U.
Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
//! Returns True.
Standard_EXPORT virtual Standard_Boolean IsCurveOnSurface() const Standard_OVERRIDE;
//! A curve in the parametric space of a surface.
Standard_EXPORT virtual Standard_Boolean IsCurveOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom2d_Curve)& PCurve() const Standard_OVERRIDE;
Standard_EXPORT virtual void PCurve(const Handle(Geom2d_Curve)& C) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Recomputes any derived data after a modification.
//! This is called when the range is modified.
Standard_EXPORT virtual void Update() Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_CurveOnSurface, BRep_GCurve)
protected:
gp_Pnt2d myUV1;
gp_Pnt2d myUV2;
private:
Handle(Geom2d_Curve) myPCurve;
Handle(Geom_Surface) mySurface;
};
#include <BRep_CurveOnSurface.lxx>
#endif // _BRep_CurveOnSurface_HeaderFile

View File

@@ -0,0 +1,37 @@
// Created on: 1993-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : SetUVPoints
// purpose :
//=======================================================================
inline void BRep_CurveOnSurface::SetUVPoints(const gp_Pnt2d& P1, const gp_Pnt2d& P2)
{
myUV1 = P1;
myUV2 = P2;
}
//=======================================================================
// function : UVPoints
// purpose :
//=======================================================================
inline void BRep_CurveOnSurface::UVPoints(gp_Pnt2d& P1, gp_Pnt2d& P2) const
{
P1 = myUV1;
P2 = myUV2;
}

View File

@@ -0,0 +1,297 @@
// Created on: 1993-07-06
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveRepresentation.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Poly_Polygon2D.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_CurveRepresentation, Standard_Transient)
//=================================================================================================
BRep_CurveRepresentation::BRep_CurveRepresentation(const TopLoc_Location& L)
: myLocation(L)
{
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsCurve3D() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsCurveOnSurface() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsCurveOnClosedSurface() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsRegularity() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsCurveOnSurface(const Handle(Geom_Surface)&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsRegularity(const Handle(Geom_Surface)&,
const Handle(Geom_Surface)&,
const TopLoc_Location&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygon3D() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygonOnTriangulation() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygonOnTriangulation(
const Handle(Poly_Triangulation)&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygonOnClosedTriangulation() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygonOnClosedSurface() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygonOnSurface() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_CurveRepresentation::IsPolygonOnSurface(const Handle(Geom_Surface)&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
const Handle(Geom_Curve)& BRep_CurveRepresentation::Curve3D() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::Curve3D(const Handle(Geom_Curve)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_CurveRepresentation::Surface() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Geom2d_Curve)& BRep_CurveRepresentation::PCurve() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Geom2d_Curve)& BRep_CurveRepresentation::PCurve2() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::PCurve(const Handle(Geom2d_Curve)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::PCurve2(const Handle(Geom2d_Curve)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const GeomAbs_Shape& BRep_CurveRepresentation::Continuity() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::Continuity(const GeomAbs_Shape)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_CurveRepresentation::Surface2() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const TopLoc_Location& BRep_CurveRepresentation::Location2() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Poly_Polygon3D)& BRep_CurveRepresentation::Polygon3D() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::Polygon3D(const Handle(Poly_Polygon3D)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Poly_Polygon2D)& BRep_CurveRepresentation::Polygon() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::Polygon(const Handle(Poly_Polygon2D)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Poly_PolygonOnTriangulation)& BRep_CurveRepresentation::PolygonOnTriangulation2() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::PolygonOnTriangulation2(const Handle(Poly_PolygonOnTriangulation)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::PolygonOnTriangulation(const Handle(Poly_PolygonOnTriangulation)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Poly_PolygonOnTriangulation)& BRep_CurveRepresentation::PolygonOnTriangulation() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Poly_Triangulation)& BRep_CurveRepresentation::Triangulation() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
const Handle(Poly_Polygon2D)& BRep_CurveRepresentation::Polygon2() const
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::Polygon2(const Handle(Poly_Polygon2D)&)
{
throw Standard_DomainError("BRep_CurveRepresentation");
}
//=================================================================================================
void BRep_CurveRepresentation::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myLocation)
}

View File

@@ -0,0 +1,165 @@
// Created on: 1993-07-05
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_CurveRepresentation_HeaderFile
#define _BRep_CurveRepresentation_HeaderFile
#include <Standard.hxx>
#include <TopLoc_Location.hxx>
#include <Standard_Transient.hxx>
#include <GeomAbs_Shape.hxx>
class Geom_Surface;
class Poly_Triangulation;
class Geom_Curve;
class Geom2d_Curve;
class Poly_Polygon3D;
class Poly_Polygon2D;
class Poly_PolygonOnTriangulation;
class BRep_CurveRepresentation;
DEFINE_STANDARD_HANDLE(BRep_CurveRepresentation, Standard_Transient)
//! Root class for the curve representations. Contains
//! a location.
class BRep_CurveRepresentation : public Standard_Transient
{
public:
//! A 3D curve representation.
Standard_EXPORT virtual Standard_Boolean IsCurve3D() const;
//! A curve in the parametric space of a surface.
Standard_EXPORT virtual Standard_Boolean IsCurveOnSurface() const;
//! A continuity between two surfaces.
Standard_EXPORT virtual Standard_Boolean IsRegularity() const;
//! A curve with two parametric curves on the same
//! surface.
Standard_EXPORT virtual Standard_Boolean IsCurveOnClosedSurface() const;
//! Is it a curve in the parametric space of <S> with
//! location <L>.
Standard_EXPORT virtual Standard_Boolean IsCurveOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const;
//! Is it a regularity between <S1> and <S2> with
//! location <L1> and <L2>.
Standard_EXPORT virtual Standard_Boolean IsRegularity(const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2) const;
//! A 3D polygon representation.
Standard_EXPORT virtual Standard_Boolean IsPolygon3D() const;
//! A representation by an array of nodes on a
//! triangulation.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnTriangulation() const;
//! Is it a polygon in the definition of <T> with
//! location <L>.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnTriangulation(
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const;
//! A representation by two arrays of nodes on a
//! triangulation.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnClosedTriangulation() const;
//! A polygon in the parametric space of a surface.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnSurface() const;
//! Is it a polygon in the parametric space of <S> with
//! location <L>.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const;
//! Two 2D polygon representations in the parametric
//! space of a surface.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnClosedSurface() const;
const TopLoc_Location& Location() const;
void Location(const TopLoc_Location& L);
Standard_EXPORT virtual const Handle(Geom_Curve)& Curve3D() const;
Standard_EXPORT virtual void Curve3D(const Handle(Geom_Curve)& C);
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface() const;
Standard_EXPORT virtual const Handle(Geom2d_Curve)& PCurve() const;
Standard_EXPORT virtual void PCurve(const Handle(Geom2d_Curve)& C);
Standard_EXPORT virtual const Handle(Geom2d_Curve)& PCurve2() const;
Standard_EXPORT virtual void PCurve2(const Handle(Geom2d_Curve)& C);
Standard_EXPORT virtual const Handle(Poly_Polygon3D)& Polygon3D() const;
Standard_EXPORT virtual void Polygon3D(const Handle(Poly_Polygon3D)& P);
Standard_EXPORT virtual const Handle(Poly_Polygon2D)& Polygon() const;
Standard_EXPORT virtual void Polygon(const Handle(Poly_Polygon2D)& P);
Standard_EXPORT virtual const Handle(Poly_Polygon2D)& Polygon2() const;
Standard_EXPORT virtual void Polygon2(const Handle(Poly_Polygon2D)& P);
Standard_EXPORT virtual const Handle(Poly_Triangulation)& Triangulation() const;
Standard_EXPORT virtual const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation() const;
Standard_EXPORT virtual void PolygonOnTriangulation(const Handle(Poly_PolygonOnTriangulation)& P);
Standard_EXPORT virtual const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation2()
const;
Standard_EXPORT virtual void PolygonOnTriangulation2(
const Handle(Poly_PolygonOnTriangulation)& P2);
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface2() const;
Standard_EXPORT virtual const TopLoc_Location& Location2() const;
Standard_EXPORT virtual const GeomAbs_Shape& Continuity() const;
Standard_EXPORT virtual void Continuity(const GeomAbs_Shape C);
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const = 0;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const;
DEFINE_STANDARD_RTTIEXT(BRep_CurveRepresentation, Standard_Transient)
protected:
Standard_EXPORT BRep_CurveRepresentation(const TopLoc_Location& L);
TopLoc_Location myLocation;
private:
};
#include <BRep_CurveRepresentation.lxx>
#endif // _BRep_CurveRepresentation_HeaderFile

View File

@@ -0,0 +1,35 @@
// Created on: 1993-07-09
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : Location
// purpose :
//=======================================================================
inline const TopLoc_Location& BRep_CurveRepresentation::Location() const
{
return myLocation;
}
//=======================================================================
// function : Location
// purpose :
//=======================================================================
inline void BRep_CurveRepresentation::Location(const TopLoc_Location& L)
{
myLocation = L;
}

View File

@@ -0,0 +1,49 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_GCurve.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_GCurve, BRep_CurveRepresentation)
//=================================================================================================
BRep_GCurve::BRep_GCurve(const TopLoc_Location& L,
const Standard_Real First,
const Standard_Real Last)
: BRep_CurveRepresentation(L),
myFirst(First),
myLast(Last)
{
}
//=================================================================================================
void BRep_GCurve::Update() {}
//=================================================================================================
void BRep_GCurve::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_CurveRepresentation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myFirst)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myLast)
}

View File

@@ -0,0 +1,74 @@
// Created on: 1995-03-09
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_GCurve_HeaderFile
#define _BRep_GCurve_HeaderFile
#include <Standard.hxx>
#include <Standard_Real.hxx>
#include <BRep_CurveRepresentation.hxx>
class TopLoc_Location;
class gp_Pnt;
class BRep_GCurve;
DEFINE_STANDARD_HANDLE(BRep_GCurve, BRep_CurveRepresentation)
//! Root class for the geometric curves
//! representation. Contains a range.
//! Contains a first and a last parameter.
class BRep_GCurve : public BRep_CurveRepresentation
{
public:
void SetRange(const Standard_Real First, const Standard_Real Last);
void Range(Standard_Real& First, Standard_Real& Last) const;
Standard_Real First() const;
Standard_Real Last() const;
void First(const Standard_Real F);
void Last(const Standard_Real L);
//! Computes the point at parameter U.
Standard_EXPORT virtual void D0(const Standard_Real U, gp_Pnt& P) const = 0;
//! Recomputes any derived data after a modification.
//! This is called when the range is modified.
Standard_EXPORT virtual void Update();
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_GCurve, BRep_CurveRepresentation)
protected:
Standard_EXPORT BRep_GCurve(const TopLoc_Location& L,
const Standard_Real First,
const Standard_Real Last);
private:
Standard_Real myFirst;
Standard_Real myLast;
};
#include <BRep_GCurve.lxx>
#endif // _BRep_GCurve_HeaderFile

View File

@@ -0,0 +1,80 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : SetRange
// purpose :
//=======================================================================
inline void BRep_GCurve::SetRange(const Standard_Real First, const Standard_Real Last)
{
myFirst = First;
myLast = Last;
Update();
}
//=======================================================================
// function : Range
// purpose :
//=======================================================================
inline void BRep_GCurve::Range(Standard_Real& First, Standard_Real& Last) const
{
First = myFirst;
Last = myLast;
}
//=======================================================================
// function : First
// purpose :
//=======================================================================
inline Standard_Real BRep_GCurve::First() const
{
return myFirst;
}
//=======================================================================
// function : Last
// purpose :
//=======================================================================
inline Standard_Real BRep_GCurve::Last() const
{
return myLast;
}
//=======================================================================
// function : First
// purpose :
//=======================================================================
inline void BRep_GCurve::First(const Standard_Real F)
{
myFirst = F;
Update();
}
//=======================================================================
// function : Last
// purpose :
//=======================================================================
inline void BRep_GCurve::Last(const Standard_Real L)
{
myLast = L;
Update();
}

View File

@@ -0,0 +1,19 @@
// Copyright (c) 2015 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 BRep_ListIteratorOfListOfCurveRepresentation_HeaderFile
#define BRep_ListIteratorOfListOfCurveRepresentation_HeaderFile
#include <BRep_ListOfCurveRepresentation.hxx>
#endif

View File

@@ -0,0 +1,19 @@
// Copyright (c) 2015 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 BRep_ListIteratorOfListOfPointRepresentation_HeaderFile
#define BRep_ListIteratorOfListOfPointRepresentation_HeaderFile
#include <BRep_ListOfPointRepresentation.hxx>
#endif

View File

@@ -0,0 +1,27 @@
// Created on: 1991-06-27
// Created by: Remi LEQUETTE
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef BRep_ListOfCurveRepresentation_HeaderFile
#define BRep_ListOfCurveRepresentation_HeaderFile
#include <BRep_CurveRepresentation.hxx>
#include <NCollection_List.hxx>
typedef NCollection_List<Handle(BRep_CurveRepresentation)> BRep_ListOfCurveRepresentation;
typedef NCollection_List<Handle(BRep_CurveRepresentation)>::Iterator
BRep_ListIteratorOfListOfCurveRepresentation;
#endif

View File

@@ -0,0 +1,27 @@
// Created on: 1991-06-27
// Created by: Remi LEQUETTE
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef BRep_ListOfPointRepresentation_HeaderFile
#define BRep_ListOfPointRepresentation_HeaderFile
#include <BRep_PointRepresentation.hxx>
#include <NCollection_List.hxx>
typedef NCollection_List<Handle(BRep_PointRepresentation)> BRep_ListOfPointRepresentation;
typedef NCollection_List<Handle(BRep_PointRepresentation)>::Iterator
BRep_ListIteratorOfListOfPointRepresentation;
#endif

View File

@@ -0,0 +1,72 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_PointOnCurve.hxx>
#include <Geom_Curve.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PointOnCurve, BRep_PointRepresentation)
//=================================================================================================
BRep_PointOnCurve::BRep_PointOnCurve(const Standard_Real P,
const Handle(Geom_Curve)& C,
const TopLoc_Location& L)
: BRep_PointRepresentation(P, L),
myCurve(C)
{
}
//=================================================================================================
Standard_Boolean BRep_PointOnCurve::IsPointOnCurve() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_PointOnCurve::IsPointOnCurve(const Handle(Geom_Curve)& C,
const TopLoc_Location& L) const
{
return (myCurve == C) && (Location() == L);
}
//=================================================================================================
const Handle(Geom_Curve)& BRep_PointOnCurve::Curve() const
{
return myCurve;
}
//=================================================================================================
void BRep_PointOnCurve::Curve(const Handle(Geom_Curve)& C)
{
myCurve = C;
}
//=================================================================================================
void BRep_PointOnCurve::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_PointRepresentation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myCurve.get())
}

View File

@@ -0,0 +1,61 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PointOnCurve_HeaderFile
#define _BRep_PointOnCurve_HeaderFile
#include <Standard.hxx>
#include <BRep_PointRepresentation.hxx>
#include <Standard_Real.hxx>
class Geom_Curve;
class TopLoc_Location;
class BRep_PointOnCurve;
DEFINE_STANDARD_HANDLE(BRep_PointOnCurve, BRep_PointRepresentation)
//! Representation by a parameter on a 3D curve.
class BRep_PointOnCurve : public BRep_PointRepresentation
{
public:
Standard_EXPORT BRep_PointOnCurve(const Standard_Real P,
const Handle(Geom_Curve)& C,
const TopLoc_Location& L);
//! Returns True
Standard_EXPORT virtual Standard_Boolean IsPointOnCurve() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsPointOnCurve(const Handle(Geom_Curve)& C,
const TopLoc_Location& L) const
Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom_Curve)& Curve() const Standard_OVERRIDE;
Standard_EXPORT virtual void Curve(const Handle(Geom_Curve)& C) Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PointOnCurve, BRep_PointRepresentation)
protected:
private:
Handle(Geom_Curve) myCurve;
};
#endif // _BRep_PointOnCurve_HeaderFile

View File

@@ -0,0 +1,76 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_PointOnCurveOnSurface.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PointOnCurveOnSurface, BRep_PointsOnSurface)
//=================================================================================================
BRep_PointOnCurveOnSurface::BRep_PointOnCurveOnSurface(const Standard_Real P,
const Handle(Geom2d_Curve)& C,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L)
: BRep_PointsOnSurface(P, S, L),
myPCurve(C)
{
}
//=================================================================================================
Standard_Boolean BRep_PointOnCurveOnSurface::IsPointOnCurveOnSurface() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_PointOnCurveOnSurface::IsPointOnCurveOnSurface(const Handle(Geom2d_Curve)& PC,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
{
return (myPCurve == PC) && (Surface() == S) && (Location() == L);
}
//=================================================================================================
const Handle(Geom2d_Curve)& BRep_PointOnCurveOnSurface::PCurve() const
{
return myPCurve;
}
//=================================================================================================
void BRep_PointOnCurveOnSurface::PCurve(const Handle(Geom2d_Curve)& C)
{
myPCurve = C;
}
//=================================================================================================
void BRep_PointOnCurveOnSurface::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_PointRepresentation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myPCurve.get())
}

View File

@@ -0,0 +1,65 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PointOnCurveOnSurface_HeaderFile
#define _BRep_PointOnCurveOnSurface_HeaderFile
#include <Standard.hxx>
#include <BRep_PointsOnSurface.hxx>
#include <Standard_Real.hxx>
class Geom2d_Curve;
class Geom_Surface;
class TopLoc_Location;
class BRep_PointOnCurveOnSurface;
DEFINE_STANDARD_HANDLE(BRep_PointOnCurveOnSurface, BRep_PointsOnSurface)
//! Representation by a parameter on a curve on a
//! surface.
class BRep_PointOnCurveOnSurface : public BRep_PointsOnSurface
{
public:
Standard_EXPORT BRep_PointOnCurveOnSurface(const Standard_Real P,
const Handle(Geom2d_Curve)& C,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
//! Returns True
Standard_EXPORT virtual Standard_Boolean IsPointOnCurveOnSurface() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsPointOnCurveOnSurface(const Handle(Geom2d_Curve)& PC,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom2d_Curve)& PCurve() const Standard_OVERRIDE;
Standard_EXPORT virtual void PCurve(const Handle(Geom2d_Curve)& C) Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PointOnCurveOnSurface, BRep_PointsOnSurface)
protected:
private:
Handle(Geom2d_Curve) myPCurve;
};
#endif // _BRep_PointOnCurveOnSurface_HeaderFile

View File

@@ -0,0 +1,62 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_PointOnSurface.hxx>
#include <Geom_Surface.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PointOnSurface, BRep_PointsOnSurface)
//=================================================================================================
BRep_PointOnSurface::BRep_PointOnSurface(const Standard_Real P1,
const Standard_Real P2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L)
: BRep_PointsOnSurface(P1, S, L),
myParameter2(P2)
{
}
//=================================================================================================
Standard_Boolean BRep_PointOnSurface::IsPointOnSurface() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_PointOnSurface::IsPointOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
{
return (Surface() == S) && (Location() == L);
}
//=================================================================================================
Standard_Real BRep_PointOnSurface::Parameter2() const
{
return myParameter2;
}
//=================================================================================================
void BRep_PointOnSurface::Parameter2(const Standard_Real P)
{
myParameter2 = P;
}

View File

@@ -0,0 +1,57 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PointOnSurface_HeaderFile
#define _BRep_PointOnSurface_HeaderFile
#include <Standard.hxx>
#include <Standard_Real.hxx>
#include <BRep_PointsOnSurface.hxx>
class Geom_Surface;
class TopLoc_Location;
class BRep_PointOnSurface;
DEFINE_STANDARD_HANDLE(BRep_PointOnSurface, BRep_PointsOnSurface)
//! Representation by two parameters on a surface.
class BRep_PointOnSurface : public BRep_PointsOnSurface
{
public:
Standard_EXPORT BRep_PointOnSurface(const Standard_Real P1,
const Standard_Real P2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
Standard_EXPORT virtual Standard_Boolean IsPointOnSurface() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsPointOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Real Parameter2() const Standard_OVERRIDE;
Standard_EXPORT virtual void Parameter2(const Standard_Real P) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PointOnSurface, BRep_PointsOnSurface)
protected:
private:
Standard_Real myParameter2;
};
#endif // _BRep_PointOnSurface_HeaderFile

View File

@@ -0,0 +1,145 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_PointRepresentation.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PointRepresentation, Standard_Transient)
//=================================================================================================
BRep_PointRepresentation::BRep_PointRepresentation(const Standard_Real P, const TopLoc_Location& L)
: myLocation(L),
myParameter(P)
{
}
//=================================================================================================
Standard_Boolean BRep_PointRepresentation::IsPointOnCurve() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_PointRepresentation::IsPointOnCurveOnSurface() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_PointRepresentation::IsPointOnSurface() const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_PointRepresentation::IsPointOnCurve(const Handle(Geom_Curve)&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_PointRepresentation::IsPointOnCurveOnSurface(const Handle(Geom2d_Curve)&,
const Handle(Geom_Surface)&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
Standard_Boolean BRep_PointRepresentation::IsPointOnSurface(const Handle(Geom_Surface)&,
const TopLoc_Location&) const
{
return Standard_False;
}
//=================================================================================================
Standard_Real BRep_PointRepresentation::Parameter2() const
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
void BRep_PointRepresentation::Parameter2(const Standard_Real)
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
const Handle(Geom_Curve)& BRep_PointRepresentation::Curve() const
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
void BRep_PointRepresentation::Curve(const Handle(Geom_Curve)&)
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
const Handle(Geom2d_Curve)& BRep_PointRepresentation::PCurve() const
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
void BRep_PointRepresentation::PCurve(const Handle(Geom2d_Curve)&)
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_PointRepresentation::Surface() const
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
void BRep_PointRepresentation::Surface(const Handle(Geom_Surface)&)
{
throw Standard_DomainError("BRep_PointRepresentation");
}
//=================================================================================================
void BRep_PointRepresentation::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myLocation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myParameter)
}

View File

@@ -0,0 +1,100 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PointRepresentation_HeaderFile
#define _BRep_PointRepresentation_HeaderFile
#include <Standard.hxx>
#include <TopLoc_Location.hxx>
#include <Standard_Real.hxx>
#include <Standard_Transient.hxx>
class Geom_Curve;
class Geom2d_Curve;
class Geom_Surface;
class BRep_PointRepresentation;
DEFINE_STANDARD_HANDLE(BRep_PointRepresentation, Standard_Transient)
//! Root class for the points representations.
//! Contains a location and a parameter.
class BRep_PointRepresentation : public Standard_Transient
{
public:
//! A point on a 3d curve.
Standard_EXPORT virtual Standard_Boolean IsPointOnCurve() const;
//! A point on a 2d curve on a surface.
Standard_EXPORT virtual Standard_Boolean IsPointOnCurveOnSurface() const;
//! A point on a surface.
Standard_EXPORT virtual Standard_Boolean IsPointOnSurface() const;
//! A point on the curve <C>.
Standard_EXPORT virtual Standard_Boolean IsPointOnCurve(const Handle(Geom_Curve)& C,
const TopLoc_Location& L) const;
//! A point on the 2d curve <PC> on the surface <S>.
Standard_EXPORT virtual Standard_Boolean IsPointOnCurveOnSurface(const Handle(Geom2d_Curve)& PC,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const;
//! A point on the surface <S>.
Standard_EXPORT virtual Standard_Boolean IsPointOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const;
const TopLoc_Location& Location() const;
void Location(const TopLoc_Location& L);
Standard_Real Parameter() const;
void Parameter(const Standard_Real P);
Standard_EXPORT virtual Standard_Real Parameter2() const;
Standard_EXPORT virtual void Parameter2(const Standard_Real P);
Standard_EXPORT virtual const Handle(Geom_Curve)& Curve() const;
Standard_EXPORT virtual void Curve(const Handle(Geom_Curve)& C);
Standard_EXPORT virtual const Handle(Geom2d_Curve)& PCurve() const;
Standard_EXPORT virtual void PCurve(const Handle(Geom2d_Curve)& C);
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface() const;
Standard_EXPORT virtual void Surface(const Handle(Geom_Surface)& S);
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const;
DEFINE_STANDARD_RTTIEXT(BRep_PointRepresentation, Standard_Transient)
protected:
Standard_EXPORT BRep_PointRepresentation(const Standard_Real P, const TopLoc_Location& L);
private:
TopLoc_Location myLocation;
Standard_Real myParameter;
};
#include <BRep_PointRepresentation.lxx>
#endif // _BRep_PointRepresentation_HeaderFile

View File

@@ -0,0 +1,55 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : Location
// purpose :
//=======================================================================
inline const TopLoc_Location& BRep_PointRepresentation::Location() const
{
return myLocation;
}
//=======================================================================
// function : Location
// purpose :
//=======================================================================
inline void BRep_PointRepresentation::Location(const TopLoc_Location& L)
{
myLocation = L;
}
//=======================================================================
// function : Parameter
// purpose :
//=======================================================================
inline Standard_Real BRep_PointRepresentation::Parameter() const
{
return myParameter;
}
//=======================================================================
// function : Parameter
// purpose :
//=======================================================================
inline void BRep_PointRepresentation::Parameter(const Standard_Real P)
{
myParameter = P;
}

View File

@@ -0,0 +1,57 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_PointsOnSurface.hxx>
#include <Geom_Surface.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PointsOnSurface, BRep_PointRepresentation)
//=================================================================================================
BRep_PointsOnSurface::BRep_PointsOnSurface(const Standard_Real P,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L)
: BRep_PointRepresentation(P, L),
mySurface(S)
{
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_PointsOnSurface::Surface() const
{
return mySurface;
}
//=================================================================================================
void BRep_PointsOnSurface::Surface(const Handle(Geom_Surface)& S)
{
mySurface = S;
}
//=================================================================================================
void BRep_PointsOnSurface::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_PointRepresentation)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySurface.get())
}

View File

@@ -0,0 +1,54 @@
// Created on: 1993-08-10
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PointsOnSurface_HeaderFile
#define _BRep_PointsOnSurface_HeaderFile
#include <Standard.hxx>
#include <BRep_PointRepresentation.hxx>
#include <Standard_Real.hxx>
class Geom_Surface;
class TopLoc_Location;
class BRep_PointsOnSurface;
DEFINE_STANDARD_HANDLE(BRep_PointsOnSurface, BRep_PointRepresentation)
//! Root for points on surface.
class BRep_PointsOnSurface : public BRep_PointRepresentation
{
public:
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface() const Standard_OVERRIDE;
Standard_EXPORT virtual void Surface(const Handle(Geom_Surface)& S) Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PointsOnSurface, BRep_PointRepresentation)
protected:
Standard_EXPORT BRep_PointsOnSurface(const Standard_Real P,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
private:
Handle(Geom_Surface) mySurface;
};
#endif // _BRep_PointsOnSurface_HeaderFile

View File

@@ -0,0 +1,72 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveRepresentation.hxx>
#include <BRep_Polygon3D.hxx>
#include <Poly_Polygon3D.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_Polygon3D, BRep_CurveRepresentation)
//=================================================================================================
BRep_Polygon3D::BRep_Polygon3D(const Handle(Poly_Polygon3D)& P, const TopLoc_Location& L)
: BRep_CurveRepresentation(L),
myPolygon3D(P)
{
}
//=================================================================================================
Standard_Boolean BRep_Polygon3D::IsPolygon3D() const
{
return Standard_True;
}
//=================================================================================================
const Handle(Poly_Polygon3D)& BRep_Polygon3D::Polygon3D() const
{
return myPolygon3D;
}
//=================================================================================================
void BRep_Polygon3D::Polygon3D(const Handle(Poly_Polygon3D)& P)
{
myPolygon3D = P;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_Polygon3D::Copy() const
{
Handle(BRep_Polygon3D) P = new BRep_Polygon3D(myPolygon3D, Location());
return P;
}
//=================================================================================================
void BRep_Polygon3D::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_CurveRepresentation)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPolygon3D.get())
}

View File

@@ -0,0 +1,58 @@
// Created on: 1995-03-09
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_Polygon3D_HeaderFile
#define _BRep_Polygon3D_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BRep_CurveRepresentation.hxx>
class Poly_Polygon3D;
class TopLoc_Location;
class BRep_Polygon3D;
DEFINE_STANDARD_HANDLE(BRep_Polygon3D, BRep_CurveRepresentation)
//! Representation by a 3D polygon.
class BRep_Polygon3D : public BRep_CurveRepresentation
{
public:
Standard_EXPORT BRep_Polygon3D(const Handle(Poly_Polygon3D)& P, const TopLoc_Location& L);
//! Returns True.
Standard_EXPORT virtual Standard_Boolean IsPolygon3D() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Poly_Polygon3D)& Polygon3D() const Standard_OVERRIDE;
Standard_EXPORT virtual void Polygon3D(const Handle(Poly_Polygon3D)& P) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_Polygon3D, BRep_CurveRepresentation)
protected:
private:
Handle(Poly_Polygon3D) myPolygon3D;
};
#endif // _BRep_Polygon3D_HeaderFile

View File

@@ -0,0 +1,77 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveRepresentation.hxx>
#include <BRep_PolygonOnClosedSurface.hxx>
#include <Geom_Surface.hxx>
#include <Poly_Polygon2D.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PolygonOnClosedSurface, BRep_PolygonOnSurface)
//=================================================================================================
BRep_PolygonOnClosedSurface::BRep_PolygonOnClosedSurface(const Handle(Poly_Polygon2D)& P1,
const Handle(Poly_Polygon2D)& P2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L)
: BRep_PolygonOnSurface(P1, S, L),
myPolygon2(P2)
{
}
//=================================================================================================
Standard_Boolean BRep_PolygonOnClosedSurface::IsPolygonOnClosedSurface() const
{
return Standard_True;
}
//=================================================================================================
const Handle(Poly_Polygon2D)& BRep_PolygonOnClosedSurface::Polygon2() const
{
return myPolygon2;
}
//=================================================================================================
void BRep_PolygonOnClosedSurface::Polygon2(const Handle(Poly_Polygon2D)& P)
{
myPolygon2 = P;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_PolygonOnClosedSurface::Copy() const
{
Handle(BRep_PolygonOnClosedSurface) P =
new BRep_PolygonOnClosedSurface(Polygon(), myPolygon2, Surface(), Location());
return P;
}
//=================================================================================================
void BRep_PolygonOnClosedSurface::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_PolygonOnSurface)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPolygon2.get())
}

View File

@@ -0,0 +1,64 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PolygonOnClosedSurface_HeaderFile
#define _BRep_PolygonOnClosedSurface_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BRep_PolygonOnSurface.hxx>
class Poly_Polygon2D;
class Geom_Surface;
class TopLoc_Location;
class BRep_CurveRepresentation;
class BRep_PolygonOnClosedSurface;
DEFINE_STANDARD_HANDLE(BRep_PolygonOnClosedSurface, BRep_PolygonOnSurface)
//! Representation by two 2d polygons in the parametric
//! space of a surface.
class BRep_PolygonOnClosedSurface : public BRep_PolygonOnSurface
{
public:
Standard_EXPORT BRep_PolygonOnClosedSurface(const Handle(Poly_Polygon2D)& P1,
const Handle(Poly_Polygon2D)& P2,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
//! returns True.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnClosedSurface() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Poly_Polygon2D)& Polygon2() const Standard_OVERRIDE;
Standard_EXPORT virtual void Polygon2(const Handle(Poly_Polygon2D)& P) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PolygonOnClosedSurface, BRep_PolygonOnSurface)
protected:
private:
Handle(Poly_Polygon2D) myPolygon2;
};
#endif // _BRep_PolygonOnClosedSurface_HeaderFile

View File

@@ -0,0 +1,84 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveRepresentation.hxx>
#include <BRep_PolygonOnClosedTriangulation.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PolygonOnClosedTriangulation, BRep_PolygonOnTriangulation)
//=================================================================================================
BRep_PolygonOnClosedTriangulation::BRep_PolygonOnClosedTriangulation(
const Handle(Poly_PolygonOnTriangulation)& P1,
const Handle(Poly_PolygonOnTriangulation)& P2,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L)
: BRep_PolygonOnTriangulation(P1, T, L),
myPolygon2(P2)
{
}
//=================================================================================================
Standard_Boolean BRep_PolygonOnClosedTriangulation::IsPolygonOnClosedTriangulation() const
{
return Standard_True;
}
//=================================================================================================
void BRep_PolygonOnClosedTriangulation::PolygonOnTriangulation2(
const Handle(Poly_PolygonOnTriangulation)& P2)
{
myPolygon2 = P2;
}
//=================================================================================================
const Handle(Poly_PolygonOnTriangulation)& BRep_PolygonOnClosedTriangulation::
PolygonOnTriangulation2() const
{
return myPolygon2;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_PolygonOnClosedTriangulation::Copy() const
{
Handle(BRep_PolygonOnClosedTriangulation) P;
P = new BRep_PolygonOnClosedTriangulation(PolygonOnTriangulation(),
myPolygon2,
Triangulation(),
Location());
return P;
}
//=================================================================================================
void BRep_PolygonOnClosedTriangulation::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_PolygonOnTriangulation)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPolygon2.get())
}

View File

@@ -0,0 +1,66 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PolygonOnClosedTriangulation_HeaderFile
#define _BRep_PolygonOnClosedTriangulation_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BRep_PolygonOnTriangulation.hxx>
class Poly_PolygonOnTriangulation;
class Poly_Triangulation;
class TopLoc_Location;
class BRep_CurveRepresentation;
class BRep_PolygonOnClosedTriangulation;
DEFINE_STANDARD_HANDLE(BRep_PolygonOnClosedTriangulation, BRep_PolygonOnTriangulation)
//! A representation by two arrays of nodes on a
//! triangulation.
class BRep_PolygonOnClosedTriangulation : public BRep_PolygonOnTriangulation
{
public:
Standard_EXPORT BRep_PolygonOnClosedTriangulation(const Handle(Poly_PolygonOnTriangulation)& P1,
const Handle(Poly_PolygonOnTriangulation)& P2,
const Handle(Poly_Triangulation)& Tr,
const TopLoc_Location& L);
//! Returns True.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnClosedTriangulation() const Standard_OVERRIDE;
Standard_EXPORT virtual void PolygonOnTriangulation2(
const Handle(Poly_PolygonOnTriangulation)& P2) Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation2() const
Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PolygonOnClosedTriangulation, BRep_PolygonOnTriangulation)
protected:
private:
Handle(Poly_PolygonOnTriangulation) myPolygon2;
};
#endif // _BRep_PolygonOnClosedTriangulation_HeaderFile

View File

@@ -0,0 +1,92 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveRepresentation.hxx>
#include <BRep_PolygonOnSurface.hxx>
#include <Geom_Surface.hxx>
#include <Poly_Polygon2D.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PolygonOnSurface, BRep_CurveRepresentation)
//=================================================================================================
BRep_PolygonOnSurface::BRep_PolygonOnSurface(const Handle(Poly_Polygon2D)& P,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L)
: BRep_CurveRepresentation(L),
myPolygon2D(P),
mySurface(S)
{
}
//=================================================================================================
Standard_Boolean BRep_PolygonOnSurface::IsPolygonOnSurface() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_PolygonOnSurface::IsPolygonOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
{
return (S == mySurface) && (L == myLocation);
}
//=================================================================================================
const Handle(Geom_Surface)& BRep_PolygonOnSurface::Surface() const
{
return mySurface;
}
//=================================================================================================
const Handle(Poly_Polygon2D)& BRep_PolygonOnSurface::Polygon() const
{
return myPolygon2D;
}
//=================================================================================================
void BRep_PolygonOnSurface::Polygon(const Handle(Poly_Polygon2D)& P)
{
myPolygon2D = P;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_PolygonOnSurface::Copy() const
{
Handle(BRep_PolygonOnSurface) P = new BRep_PolygonOnSurface(myPolygon2D, mySurface, Location());
return P;
}
//=================================================================================================
void BRep_PolygonOnSurface::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_CurveRepresentation)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPolygon2D.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySurface.get())
}

View File

@@ -0,0 +1,72 @@
// Created on: 1995-03-14
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PolygonOnSurface_HeaderFile
#define _BRep_PolygonOnSurface_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BRep_CurveRepresentation.hxx>
class Poly_Polygon2D;
class Geom_Surface;
class TopLoc_Location;
class BRep_PolygonOnSurface;
DEFINE_STANDARD_HANDLE(BRep_PolygonOnSurface, BRep_CurveRepresentation)
//! Representation of a 2D polygon in the parametric
//! space of a surface.
class BRep_PolygonOnSurface : public BRep_CurveRepresentation
{
public:
Standard_EXPORT BRep_PolygonOnSurface(const Handle(Poly_Polygon2D)& P,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
//! A 2D polygon representation in the parametric
//! space of a surface.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnSurface() const Standard_OVERRIDE;
//! A 2D polygon representation in the parametric
//! space of a surface.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnSurface(const Handle(Geom_Surface)& S,
const TopLoc_Location& L) const
Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Geom_Surface)& Surface() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Poly_Polygon2D)& Polygon() const Standard_OVERRIDE;
Standard_EXPORT virtual void Polygon(const Handle(Poly_Polygon2D)& P) Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PolygonOnSurface, BRep_CurveRepresentation)
protected:
private:
Handle(Poly_Polygon2D) myPolygon2D;
Handle(Geom_Surface) mySurface;
};
#endif // _BRep_PolygonOnSurface_HeaderFile

View File

@@ -0,0 +1,98 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveRepresentation.hxx>
#include <BRep_PolygonOnTriangulation.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_PolygonOnTriangulation, BRep_CurveRepresentation)
//=================================================================================================
BRep_PolygonOnTriangulation::BRep_PolygonOnTriangulation(
const Handle(Poly_PolygonOnTriangulation)& P,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L)
: BRep_CurveRepresentation(L),
myPolygon(P),
myTriangulation(T)
{
}
//=================================================================================================
Standard_Boolean BRep_PolygonOnTriangulation::IsPolygonOnTriangulation() const
{
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRep_PolygonOnTriangulation::IsPolygonOnTriangulation(
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const
{
return (T == myTriangulation) && (L == myLocation);
}
//=================================================================================================
void BRep_PolygonOnTriangulation::PolygonOnTriangulation(
const Handle(Poly_PolygonOnTriangulation)& P)
{
myPolygon = P;
}
//=================================================================================================
const Handle(Poly_PolygonOnTriangulation)& BRep_PolygonOnTriangulation::PolygonOnTriangulation()
const
{
return myPolygon;
}
//=================================================================================================
const Handle(Poly_Triangulation)& BRep_PolygonOnTriangulation::Triangulation() const
{
return myTriangulation;
}
//=================================================================================================
Handle(BRep_CurveRepresentation) BRep_PolygonOnTriangulation::Copy() const
{
Handle(BRep_PolygonOnTriangulation) P =
new BRep_PolygonOnTriangulation(myPolygon, myTriangulation, Location());
return P;
}
//=================================================================================================
void BRep_PolygonOnTriangulation::DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, BRep_CurveRepresentation)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myPolygon.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myTriangulation.get())
}

View File

@@ -0,0 +1,74 @@
// Created on: 1995-03-15
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_PolygonOnTriangulation_HeaderFile
#define _BRep_PolygonOnTriangulation_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BRep_CurveRepresentation.hxx>
class Poly_PolygonOnTriangulation;
class Poly_Triangulation;
class TopLoc_Location;
class BRep_PolygonOnTriangulation;
DEFINE_STANDARD_HANDLE(BRep_PolygonOnTriangulation, BRep_CurveRepresentation)
//! A representation by an array of nodes on a
//! triangulation.
class BRep_PolygonOnTriangulation : public BRep_CurveRepresentation
{
public:
Standard_EXPORT BRep_PolygonOnTriangulation(const Handle(Poly_PolygonOnTriangulation)& P,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L);
//! returns True.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnTriangulation() const Standard_OVERRIDE;
//! Is it a polygon in the definition of <T> with
//! location <L>.
Standard_EXPORT virtual Standard_Boolean IsPolygonOnTriangulation(
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L) const Standard_OVERRIDE;
//! returns True.
Standard_EXPORT virtual void PolygonOnTriangulation(const Handle(Poly_PolygonOnTriangulation)& P)
Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Poly_Triangulation)& Triangulation() const Standard_OVERRIDE;
Standard_EXPORT virtual const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation() const
Standard_OVERRIDE;
//! Return a copy of this representation.
Standard_EXPORT virtual Handle(BRep_CurveRepresentation) Copy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_PolygonOnTriangulation, BRep_CurveRepresentation)
protected:
private:
Handle(Poly_PolygonOnTriangulation) myPolygon;
Handle(Poly_Triangulation) myTriangulation;
};
#endif // _BRep_PolygonOnTriangulation_HeaderFile

View File

@@ -0,0 +1,136 @@
// Created on: 1992-08-25
// Created by: Modelistation
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_CurveOn2Surfaces.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_TEdge.hxx>
#include <Standard_Type.hxx>
#include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_TEdge, TopoDS_TEdge)
static const Standard_Integer ParameterMask = 1;
static const Standard_Integer RangeMask = 2;
static const Standard_Integer DegeneratedMask = 4;
//=================================================================================================
BRep_TEdge::BRep_TEdge()
: TopoDS_TEdge(),
myTolerance(RealEpsilon()),
myFlags(0)
{
SameParameter(Standard_True);
SameRange(Standard_True);
}
//=================================================================================================
Standard_Boolean BRep_TEdge::SameParameter() const
{
return (myFlags & ParameterMask) != 0;
}
//=================================================================================================
void BRep_TEdge::SameParameter(const Standard_Boolean S)
{
if (S)
myFlags |= ParameterMask;
else
myFlags &= ~ParameterMask;
}
//=================================================================================================
Standard_Boolean BRep_TEdge::SameRange() const
{
return (myFlags & RangeMask) != 0;
}
//=================================================================================================
void BRep_TEdge::SameRange(const Standard_Boolean S)
{
if (S)
myFlags |= RangeMask;
else
myFlags &= ~RangeMask;
}
//=================================================================================================
Standard_Boolean BRep_TEdge::Degenerated() const
{
return (myFlags & DegeneratedMask) != 0;
}
//=================================================================================================
void BRep_TEdge::Degenerated(const Standard_Boolean S)
{
if (S)
myFlags |= DegeneratedMask;
else
myFlags &= ~DegeneratedMask;
}
//=================================================================================================
Handle(TopoDS_TShape) BRep_TEdge::EmptyCopy() const
{
Handle(BRep_TEdge) TE = new BRep_TEdge();
TE->Tolerance(myTolerance);
// copy the curves representations
BRep_ListOfCurveRepresentation& l = TE->ChangeCurves();
BRep_ListIteratorOfListOfCurveRepresentation itr(myCurves);
while (itr.More())
{
// on ne recopie PAS les polygones
if (itr.Value()->IsKind(STANDARD_TYPE(BRep_GCurve))
|| itr.Value()->IsKind(STANDARD_TYPE(BRep_CurveOn2Surfaces)))
{
l.Append(itr.Value()->Copy());
}
itr.Next();
}
TE->Degenerated(Degenerated());
TE->SameParameter(SameParameter());
TE->SameRange(SameRange());
return TE;
}
//=================================================================================================
void BRep_TEdge::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, TopoDS_TEdge)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myTolerance)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myFlags)
for (BRep_ListIteratorOfListOfCurveRepresentation itr(myCurves); itr.More(); itr.Next())
{
const Handle(BRep_CurveRepresentation)& aCurveRepresentation = itr.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, aCurveRepresentation.get())
}
}

View File

@@ -0,0 +1,94 @@
// Created on: 1992-05-27
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_TEdge_HeaderFile
#define _BRep_TEdge_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_Integer.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <TopoDS_TEdge.hxx>
class TopoDS_TShape;
class BRep_TEdge;
DEFINE_STANDARD_HANDLE(BRep_TEdge, TopoDS_TEdge)
//! The TEdge from BRep is inherited from the TEdge
//! from TopoDS. It contains the geometric data.
//!
//! The TEdge contains :
//!
//! * A tolerance.
//!
//! * A same parameter flag.
//!
//! * A same range flag.
//!
//! * A Degenerated flag.
//!
//! * A list of curve representation.
class BRep_TEdge : public TopoDS_TEdge
{
public:
//! Creates an empty TEdge.
Standard_EXPORT BRep_TEdge();
Standard_Real Tolerance() const;
void Tolerance(const Standard_Real T);
//! Sets the tolerance to the max of <T> and the
//! current tolerance.
void UpdateTolerance(const Standard_Real T);
Standard_EXPORT Standard_Boolean SameParameter() const;
Standard_EXPORT void SameParameter(const Standard_Boolean S);
Standard_EXPORT Standard_Boolean SameRange() const;
Standard_EXPORT void SameRange(const Standard_Boolean S);
Standard_EXPORT Standard_Boolean Degenerated() const;
Standard_EXPORT void Degenerated(const Standard_Boolean S);
const BRep_ListOfCurveRepresentation& Curves() const;
BRep_ListOfCurveRepresentation& ChangeCurves();
//! Returns a copy of the TShape with no sub-shapes.
Standard_EXPORT Handle(TopoDS_TShape) EmptyCopy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_TEdge, TopoDS_TEdge)
protected:
private:
Standard_Real myTolerance;
Standard_Integer myFlags;
BRep_ListOfCurveRepresentation myCurves;
};
#include <BRep_TEdge.lxx>
#endif // _BRep_TEdge_HeaderFile

View File

@@ -0,0 +1,66 @@
// Created on: 1992-08-25
// Created by: Modelistation
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : Tolerance
// purpose :
//=======================================================================
inline Standard_Real BRep_TEdge::Tolerance() const
{
return myTolerance;
}
//=======================================================================
// function : Tolerance
// purpose :
//=======================================================================
inline void BRep_TEdge::Tolerance(const Standard_Real T)
{
myTolerance = T;
}
//=======================================================================
// function : UpdateTolerance
// purpose :
//=======================================================================
inline void BRep_TEdge::UpdateTolerance(const Standard_Real T)
{
if (T > myTolerance)
myTolerance = T;
}
//=======================================================================
// function : Curves
// purpose :
//=======================================================================
inline const BRep_ListOfCurveRepresentation& BRep_TEdge::Curves() const
{
return myCurves;
}
//=======================================================================
// function : ChangeCurves
// purpose :
//=======================================================================
inline BRep_ListOfCurveRepresentation& BRep_TEdge::ChangeCurves()
{
return myCurves;
}

View File

@@ -0,0 +1,191 @@
// Created on: 1992-08-25
// Created by: Remi Lequette
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_TFace.hxx>
#include <Geom_Surface.hxx>
#include <Poly_Triangulation.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_TFace, TopoDS_TFace)
//=================================================================================================
BRep_TFace::BRep_TFace()
: TopoDS_TFace(),
myTolerance(RealEpsilon()),
myNaturalRestriction(Standard_False)
{
}
//=================================================================================================
Handle(TopoDS_TShape) BRep_TFace::EmptyCopy() const
{
Handle(BRep_TFace) TF = new BRep_TFace();
TF->Surface(mySurface);
TF->Location(myLocation);
TF->Tolerance(myTolerance);
return TF;
}
//=================================================================================================
const Handle(Poly_Triangulation)& BRep_TFace::Triangulation(const Poly_MeshPurpose thePurpose) const
{
if (thePurpose == Poly_MeshPurpose_NONE)
{
return ActiveTriangulation();
}
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = anIter.Value();
if ((aTriangulation->MeshPurpose() & thePurpose) != 0)
{
return aTriangulation;
}
}
if ((thePurpose & Poly_MeshPurpose_AnyFallback) != 0 && !myTriangulations.IsEmpty())
{
// if none matching other criteria was found return the first defined triangulation
return myTriangulations.First();
}
static const Handle(Poly_Triangulation) anEmptyTriangulation;
return anEmptyTriangulation;
}
//=================================================================================================
void BRep_TFace::Triangulation(const Handle(Poly_Triangulation)& theTriangulation,
const Standard_Boolean theToReset)
{
if (theToReset || theTriangulation.IsNull())
{
if (!myActiveTriangulation.IsNull())
{
// Reset Active bit
myActiveTriangulation->SetMeshPurpose(myActiveTriangulation->MeshPurpose()
& ~Poly_MeshPurpose_Active);
myActiveTriangulation.Nullify();
}
myTriangulations.Clear();
if (!theTriangulation.IsNull())
{
// Reset list of triangulations to new list with only one input triangulation that will be
// active
myTriangulations.Append(theTriangulation);
myActiveTriangulation = theTriangulation;
// Set Active bit
theTriangulation->SetMeshPurpose(theTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
}
return;
}
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
// Make input triangulation active if it is already contained in list of triangulations
if (anIter.Value() == theTriangulation)
{
if (!myActiveTriangulation.IsNull())
{
// Reset Active bit
myActiveTriangulation->SetMeshPurpose(myActiveTriangulation->MeshPurpose()
& ~Poly_MeshPurpose_Active);
}
myActiveTriangulation = theTriangulation;
// Set Active bit
theTriangulation->SetMeshPurpose(theTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
return;
}
}
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
// Replace active triangulation to input one
if (anIter.Value() == myActiveTriangulation)
{
// Reset Active bit
myActiveTriangulation->SetMeshPurpose(myActiveTriangulation->MeshPurpose()
& ~Poly_MeshPurpose_Active);
anIter.ChangeValue() = theTriangulation;
myActiveTriangulation = theTriangulation;
// Set Active bit
theTriangulation->SetMeshPurpose(theTriangulation->MeshPurpose() | Poly_MeshPurpose_Active);
return;
}
}
}
//=================================================================================================
void BRep_TFace::Triangulations(const Poly_ListOfTriangulation& theTriangulations,
const Handle(Poly_Triangulation)& theActiveTriangulation)
{
if (theTriangulations.IsEmpty())
{
myActiveTriangulation.Nullify();
myTriangulations.Clear();
return;
}
Standard_Boolean anActiveInList = false;
for (Poly_ListOfTriangulation::Iterator anIter(theTriangulations); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = anIter.Value();
Standard_ASSERT_RAISE(!aTriangulation.IsNull(),
"Try to set list with NULL triangulation to the face");
if (aTriangulation == theActiveTriangulation)
{
anActiveInList = true;
}
// Reset Active bit
aTriangulation->SetMeshPurpose(aTriangulation->MeshPurpose() & ~Poly_MeshPurpose_Active);
}
Standard_ASSERT_RAISE(theActiveTriangulation.IsNull() || anActiveInList,
"Active triangulation isn't part of triangulations list");
myTriangulations = theTriangulations;
if (theActiveTriangulation.IsNull())
{
// Save the first one as active
myActiveTriangulation = myTriangulations.First();
}
else
{
myActiveTriangulation = theActiveTriangulation;
}
myActiveTriangulation->SetMeshPurpose(myActiveTriangulation->MeshPurpose()
| Poly_MeshPurpose_Active);
}
//=================================================================================================
void BRep_TFace::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, TopoDS_TFace)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, myActiveTriangulation.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, mySurface.get())
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myLocation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myTolerance)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myNaturalRestriction)
for (Poly_ListOfTriangulation::Iterator anIter(myTriangulations); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTriangulation = anIter.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, aTriangulation.get())
}
}

View File

@@ -0,0 +1,147 @@
// Created on: 1992-05-27
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_TFace_HeaderFile
#define _BRep_TFace_HeaderFile
#include <Standard.hxx>
#include <Poly_ListOfTriangulation.hxx>
#include <TopLoc_Location.hxx>
#include <Standard_Real.hxx>
#include <TopoDS_TFace.hxx>
class Geom_Surface;
class TopoDS_TShape;
class BRep_TFace;
DEFINE_STANDARD_HANDLE(BRep_TFace, TopoDS_TFace)
//! The Tface from BRep is based on the TFace from
//! TopoDS. The TFace contains :
//!
//! * A surface, a tolerance and a Location.
//!
//! * A NaturalRestriction flag, when this flag is
//! True the boundary of the face is known to be the
//! parametric space (Umin, UMax, VMin, VMax).
//!
//! * An optional list of triangulations. If there are any
//! triangulations the surface can be absent.
//!
//! The Location is used for the Surface.
//!
//! The triangulation is in the same reference system
//! than the TFace. A point on mySurface must be
//! transformed with myLocation, but not a point on
//! the triangulation.
//!
//! The Surface may be shared by different TFaces but
//! not the Triangulation, because the Triangulation
//! may be modified by the edges.
class BRep_TFace : public TopoDS_TFace
{
public:
//! Creates an empty TFace.
Standard_EXPORT BRep_TFace();
//! Returns face surface.
const Handle(Geom_Surface)& Surface() const { return mySurface; }
//! Sets surface for this face.
void Surface(const Handle(Geom_Surface)& theSurface) { mySurface = theSurface; }
//! Returns the face location.
const TopLoc_Location& Location() const { return myLocation; }
//! Sets the location for this face.
void Location(const TopLoc_Location& theLocation) { myLocation = theLocation; }
//! Returns the face tolerance.
Standard_Real Tolerance() const { return myTolerance; }
//! Sets the tolerance for this face.
void Tolerance(const Standard_Real theTolerance) { myTolerance = theTolerance; }
//! Returns TRUE if the boundary of this face is known to be the parametric space (Umin, UMax,
//! VMin, VMax).
Standard_Boolean NaturalRestriction() const { return myNaturalRestriction; }
//! Sets the flag that is TRUE if the boundary of this face is known to be the parametric space.
void NaturalRestriction(const Standard_Boolean theRestriction)
{
myNaturalRestriction = theRestriction;
}
//! Returns the triangulation of this face according to the mesh purpose.
//! @param[in] thePurpose a mesh purpose to find appropriate triangulation (NONE by default).
//! @return an active triangulation in case of NONE purpose,
//! the first triangulation appropriate for the input purpose,
//! just the first triangulation if none matching other criteria and input purpose is
//! AnyFallback or null handle if there is no any suitable triangulation.
Standard_EXPORT const Handle(Poly_Triangulation)& Triangulation(
const Poly_MeshPurpose thePurpose = Poly_MeshPurpose_NONE) const;
//! Sets input triangulation for this face.
//! @param[in] theTriangulation triangulation to be set
//! @param[in] theToReset flag to reset triangulations list to new list with only one input
//! triangulation. If theTriangulation is NULL internal list of triangulations will be cleared and
//! active triangulation will be nullified. If theToReset is TRUE internal list of triangulations
//! will be reset to new list with only one input triangulation that will be active. Else if input
//! triangulation is contained in internal triangulations list it will be made active,
//! else the active triangulation will be replaced to input one.
Standard_EXPORT void Triangulation(const Handle(Poly_Triangulation)& theTriangulation,
const Standard_Boolean theToReset = true);
//! Returns a copy of the TShape with no sub-shapes.
//! The new Face has no triangulation.
Standard_EXPORT virtual Handle(TopoDS_TShape) EmptyCopy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
public:
//! Returns the list of available face triangulations.
const Poly_ListOfTriangulation& Triangulations() const { return myTriangulations; }
//! Sets input list of triangulations and currently active triangulation for this face.
//! If list is empty internal list of triangulations will be cleared and active triangulation will
//! be nullified. Else this list will be saved and the input active triangulation be saved as
//! active. Use NULL active triangulation to set the first triangulation in list as active. Note:
//! the method throws exception if there is any NULL triangulation in input list or
//! if this list doesn't contain input active triangulation.
Standard_EXPORT void Triangulations(const Poly_ListOfTriangulation& theTriangulations,
const Handle(Poly_Triangulation)& theActiveTriangulation);
//! Returns number of available face triangulations.
Standard_Integer NbTriangulations() const { return myTriangulations.Size(); }
//! Returns current active triangulation.
const Handle(Poly_Triangulation)& ActiveTriangulation() const { return myActiveTriangulation; }
DEFINE_STANDARD_RTTIEXT(BRep_TFace, TopoDS_TFace)
private:
Poly_ListOfTriangulation myTriangulations;
Handle(Poly_Triangulation) myActiveTriangulation;
Handle(Geom_Surface) mySurface;
TopLoc_Location myLocation;
Standard_Real myTolerance;
Standard_Boolean myNaturalRestriction;
};
#endif // _BRep_TFace_HeaderFile

View File

@@ -0,0 +1,57 @@
// Created on: 1992-08-25
// Created by: Modelistation
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_TVertex.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Type.hxx>
#include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRep_TVertex, TopoDS_TVertex)
//=================================================================================================
BRep_TVertex::BRep_TVertex()
: TopoDS_TVertex(),
myTolerance(RealEpsilon())
{
}
//=================================================================================================
Handle(TopoDS_TShape) BRep_TVertex::EmptyCopy() const
{
Handle(BRep_TVertex) TV = new BRep_TVertex();
TV->Pnt(myPnt);
TV->Tolerance(myTolerance);
return TV;
}
//=================================================================================================
void BRep_TVertex::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, TopoDS_TVertex)
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &myPnt)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myTolerance)
for (BRep_ListIteratorOfListOfPointRepresentation itr(myPoints); itr.More(); itr.Next())
{
const Handle(BRep_PointRepresentation)& aPointRepresentation = itr.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, aPointRepresentation.get())
}
}

View File

@@ -0,0 +1,75 @@
// Created on: 1992-05-27
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_TVertex_HeaderFile
#define _BRep_TVertex_HeaderFile
#include <Standard.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Real.hxx>
#include <BRep_ListOfPointRepresentation.hxx>
#include <TopoDS_TVertex.hxx>
class TopoDS_TShape;
class BRep_TVertex;
DEFINE_STANDARD_HANDLE(BRep_TVertex, TopoDS_TVertex)
//! The TVertex from BRep inherits from the TVertex
//! from TopoDS. It contains the geometric data.
//!
//! The TVertex contains a 3d point, location and a tolerance.
class BRep_TVertex : public TopoDS_TVertex
{
public:
Standard_EXPORT BRep_TVertex();
Standard_Real Tolerance() const;
void Tolerance(const Standard_Real T);
//! Sets the tolerance to the max of <T> and the
//! current tolerance.
void UpdateTolerance(const Standard_Real T);
const gp_Pnt& Pnt() const;
void Pnt(const gp_Pnt& P);
const BRep_ListOfPointRepresentation& Points() const;
BRep_ListOfPointRepresentation& ChangePoints();
//! Returns a copy of the TShape with no sub-shapes.
Standard_EXPORT Handle(TopoDS_TShape) EmptyCopy() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRep_TVertex, TopoDS_TVertex)
protected:
private:
gp_Pnt myPnt;
Standard_Real myTolerance;
BRep_ListOfPointRepresentation myPoints;
};
#include <BRep_TVertex.lxx>
#endif // _BRep_TVertex_HeaderFile

View File

@@ -0,0 +1,86 @@
// Created on: 1992-08-25
// Created by: Modelistation
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
//=======================================================================
// function : Tolerance
// purpose :
//=======================================================================
inline Standard_Real BRep_TVertex::Tolerance() const
{
return myTolerance;
}
//=======================================================================
// function : Tolerance
// purpose :
//=======================================================================
inline void BRep_TVertex::Tolerance(const Standard_Real T)
{
myTolerance = T;
}
//=======================================================================
// function : UpdateTolerance
// purpose :
//=======================================================================
inline void BRep_TVertex::UpdateTolerance(const Standard_Real T)
{
if (T > myTolerance)
myTolerance = T;
}
//=======================================================================
// function : Pnt
// purpose :
//=======================================================================
inline const gp_Pnt& BRep_TVertex::Pnt() const
{
return myPnt;
}
//=======================================================================
// function : Pnt
// purpose :
//=======================================================================
inline void BRep_TVertex::Pnt(const gp_Pnt& P)
{
myPnt = P;
}
//=======================================================================
// function : Points
// purpose :
//=======================================================================
inline const BRep_ListOfPointRepresentation& BRep_TVertex::Points() const
{
return myPoints;
}
//=======================================================================
// function : ChangePoints
// purpose :
//=======================================================================
inline BRep_ListOfPointRepresentation& BRep_TVertex::ChangePoints()
{
return myPoints;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,386 @@
// Created on: 1993-07-07
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRep_Tool_HeaderFile
#define _BRep_Tool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <GeomAbs_Shape.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <Poly_ListOfTriangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_Polygon2D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <TopAbs_ShapeEnum.hxx>
class TopoDS_Shape;
class TopoDS_Face;
class TopLoc_Location;
class TopoDS_Edge;
class TopoDS_Vertex;
//! Provides class methods to access to the geometry
//! of BRep shapes.
class BRep_Tool
{
public:
DEFINE_STANDARD_ALLOC
//! If S is Shell, returns True if it has no free boundaries (edges).
//! If S is Wire, returns True if it has no free ends (vertices).
//! (Internal and External sub-shepes are ignored in these checks)
//! If S is Edge, returns True if its vertices are the same.
//! For other shape types returns S.Closed().
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Shape& S);
//! Returns the geometric surface of the face. Returns
//! in <L> the location for the surface.
Standard_EXPORT static const Handle(Geom_Surface)& Surface(const TopoDS_Face& F,
TopLoc_Location& L);
//! Returns the geometric surface of the face. It can
//! be a copy if there is a Location.
Standard_EXPORT static Handle(Geom_Surface) Surface(const TopoDS_Face& F);
//! Returns the triangulation of the face according to the mesh purpose.
//! @param[in] theFace the input face to find triangulation.
//! @param[out] theLocation the face location.
//! @param[in] theMeshPurpose a mesh purpose to find appropriate triangulation (NONE by default).
//! @return an active triangulation in case of NONE purpose,
//! the first triangulation appropriate for the input purpose,
//! just the first triangulation if none matching other criteria and input purpose is
//! AnyFallback or null handle if there is no any suitable triangulation.
Standard_EXPORT static const Handle(Poly_Triangulation)& Triangulation(
const TopoDS_Face& theFace,
TopLoc_Location& theLocation,
const Poly_MeshPurpose theMeshPurpose = Poly_MeshPurpose_NONE);
//! Returns all triangulations of the face.
//! @param[in] theFace the input face.
//! @param[out] theLocation the face location.
//! @return list of all available face triangulations.
Standard_EXPORT static const Poly_ListOfTriangulation& Triangulations(
const TopoDS_Face& theFace,
TopLoc_Location& theLocation);
//! Returns the tolerance of the face.
Standard_EXPORT static Standard_Real Tolerance(const TopoDS_Face& F);
//! Returns the NaturalRestriction flag of the face.
Standard_EXPORT static Standard_Boolean NaturalRestriction(const TopoDS_Face& F);
//! Returns True if <F> has a surface, false otherwise.
Standard_EXPORT static Standard_Boolean IsGeometric(const TopoDS_Face& F);
//! Returns True if <E> is a 3d curve or a curve on
//! surface.
Standard_EXPORT static Standard_Boolean IsGeometric(const TopoDS_Edge& E);
//! Returns the 3D curve of the edge. May be a Null
//! handle. Returns in <L> the location for the curve.
//! In <First> and <Last> the parameter range.
Standard_EXPORT static const Handle(Geom_Curve)& Curve(const TopoDS_Edge& E,
TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last);
//! Returns the 3D curve of the edge. May be a Null handle.
//! In <First> and <Last> the parameter range.
//! It can be a copy if there is a Location.
Standard_EXPORT static Handle(Geom_Curve) Curve(const TopoDS_Edge& E,
Standard_Real& First,
Standard_Real& Last);
//! Returns the 3D polygon of the edge. May be a Null
//! handle. Returns in <L> the location for the polygon.
Standard_EXPORT static const Handle(Poly_Polygon3D)& Polygon3D(const TopoDS_Edge& E,
TopLoc_Location& L);
//! Returns the curve associated to the edge in the
//! parametric space of the face. Returns a NULL
//! handle if this curve does not exist. Returns in
//! <First> and <Last> the parameter range.
//! If the surface is a plane the curve can be not stored but created a new
//! each time. The flag pointed by <theIsStored> serves to indicate storage status.
//! It is valued if the pointer is non-null.
Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
const TopoDS_Face& F,
Standard_Real& First,
Standard_Real& Last,
Standard_Boolean* theIsStored = NULL);
//! Returns the curve associated to the edge in the
//! parametric space of the surface. Returns a NULL
//! handle if this curve does not exist. Returns in
//! <First> and <Last> the parameter range.
//! If the surface is a plane the curve can be not stored but created a new
//! each time. The flag pointed by <theIsStored> serves to indicate storage status.
//! It is valued if the pointer is non-null.
Standard_EXPORT static Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last,
Standard_Boolean* theIsStored = NULL);
//! For the planar surface builds the 2d curve for the edge
//! by projection of the edge on plane.
//! Returns a NULL handle if the surface is not planar or
//! the projection failed.
Standard_EXPORT static Handle(Geom2d_Curve) CurveOnPlane(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last);
//! Returns in <C>, <S>, <L> a 2d curve, a surface and
//! a location for the edge <E>. <C> and <S> are null
//! if the edge has no curve on surface. Returns in
//! <First> and <Last> the parameter range.
Standard_EXPORT static void CurveOnSurface(const TopoDS_Edge& E,
Handle(Geom2d_Curve)& C,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last);
//! Returns in <C>, <S>, <L> the 2d curve, the surface
//! and the location for the edge <E> of rank <Index>.
//! <C> and <S> are null if the index is out of range.
//! Returns in <First> and <Last> the parameter range.
Standard_EXPORT static void CurveOnSurface(const TopoDS_Edge& E,
Handle(Geom2d_Curve)& C,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last,
const Standard_Integer Index);
//! Returns the polygon associated to the edge in the
//! parametric space of the face. Returns a NULL
//! handle if this polygon does not exist.
Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface(const TopoDS_Edge& E,
const TopoDS_Face& F);
//! Returns the polygon associated to the edge in the
//! parametric space of the surface. Returns a NULL
//! handle if this polygon does not exist.
Standard_EXPORT static Handle(Poly_Polygon2D) PolygonOnSurface(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
//! Returns in <C>, <S>, <L> a 2d curve, a surface and
//! a location for the edge <E>. <C> and <S> are null
//! if the edge has no polygon on surface.
Standard_EXPORT static void PolygonOnSurface(const TopoDS_Edge& E,
Handle(Poly_Polygon2D)& C,
Handle(Geom_Surface)& S,
TopLoc_Location& L);
//! Returns in <C>, <S>, <L> the 2d curve, the surface
//! and the location for the edge <E> of rank <Index>.
//! <C> and <S> are null if the index is out of range.
Standard_EXPORT static void PolygonOnSurface(const TopoDS_Edge& E,
Handle(Poly_Polygon2D)& C,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
const Standard_Integer Index);
//! Returns the polygon associated to the edge in the
//! parametric space of the face. Returns a NULL
//! handle if this polygon does not exist.
Standard_EXPORT static const Handle(Poly_PolygonOnTriangulation)& PolygonOnTriangulation(
const TopoDS_Edge& E,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L);
//! Returns in <P>, <T>, <L> a polygon on triangulation, a
//! triangulation and a location for the edge <E>.
//! <P> and <T> are null if the edge has no
//! polygon on triangulation.
Standard_EXPORT static void PolygonOnTriangulation(const TopoDS_Edge& E,
Handle(Poly_PolygonOnTriangulation)& P,
Handle(Poly_Triangulation)& T,
TopLoc_Location& L);
//! Returns in <P>, <T>, <L> a polygon on
//! triangulation, a triangulation and a location for
//! the edge <E> for the range index. <C> and <S> are
//! null if the edge has no polygon on triangulation.
Standard_EXPORT static void PolygonOnTriangulation(const TopoDS_Edge& E,
Handle(Poly_PolygonOnTriangulation)& P,
Handle(Poly_Triangulation)& T,
TopLoc_Location& L,
const Standard_Integer Index);
//! Returns True if <E> has two PCurves in the
//! parametric space of <F>. i.e. <F> is on a closed
//! surface and <E> is on the closing curve.
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Edge& E, const TopoDS_Face& F);
//! Returns True if <E> has two PCurves in the
//! parametric space of <S>. i.e. <S> is a closed
//! surface and <E> is on the closing curve.
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
//! Returns True if <E> has two arrays of indices in
//! the triangulation <T>.
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Edge& E,
const Handle(Poly_Triangulation)& T,
const TopLoc_Location& L);
//! Returns the tolerance for <E>.
Standard_EXPORT static Standard_Real Tolerance(const TopoDS_Edge& E);
//! Returns the SameParameter flag for the edge.
Standard_EXPORT static Standard_Boolean SameParameter(const TopoDS_Edge& E);
//! Returns the SameRange flag for the edge.
Standard_EXPORT static Standard_Boolean SameRange(const TopoDS_Edge& E);
//! Returns True if the edge is degenerated.
Standard_EXPORT static Standard_Boolean Degenerated(const TopoDS_Edge& E);
//! Gets the range of the 3d curve.
Standard_EXPORT static void Range(const TopoDS_Edge& E,
Standard_Real& First,
Standard_Real& Last);
//! Gets the range of the edge on the pcurve on the
//! surface.
Standard_EXPORT static void Range(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last);
//! Gets the range of the edge on the pcurve on the face.
Standard_EXPORT static void Range(const TopoDS_Edge& E,
const TopoDS_Face& F,
Standard_Real& First,
Standard_Real& Last);
//! Gets the UV locations of the extremities of the edge.
Standard_EXPORT static void UVPoints(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
gp_Pnt2d& PFirst,
gp_Pnt2d& PLast);
//! Gets the UV locations of the extremities of the edge.
Standard_EXPORT static void UVPoints(const TopoDS_Edge& E,
const TopoDS_Face& F,
gp_Pnt2d& PFirst,
gp_Pnt2d& PLast);
//! Sets the UV locations of the extremities of the edge.
Standard_EXPORT static void SetUVPoints(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
const gp_Pnt2d& PFirst,
const gp_Pnt2d& PLast);
//! Sets the UV locations of the extremities of the edge.
Standard_EXPORT static void SetUVPoints(const TopoDS_Edge& E,
const TopoDS_Face& F,
const gp_Pnt2d& PFirst,
const gp_Pnt2d& PLast);
//! Returns True if the edge is on the surfaces of the
//! two faces.
Standard_EXPORT static Standard_Boolean HasContinuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2);
//! Returns the continuity.
Standard_EXPORT static GeomAbs_Shape Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2);
//! Returns True if the edge is on the surfaces.
Standard_EXPORT static Standard_Boolean HasContinuity(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2);
//! Returns the continuity.
Standard_EXPORT static GeomAbs_Shape Continuity(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S1,
const Handle(Geom_Surface)& S2,
const TopLoc_Location& L1,
const TopLoc_Location& L2);
//! Returns True if the edge has regularity on some
//! two surfaces
Standard_EXPORT static Standard_Boolean HasContinuity(const TopoDS_Edge& E);
//! Returns the max continuity of edge between some surfaces or GeomAbs_C0 if there no such
//! surfaces.
Standard_EXPORT static GeomAbs_Shape MaxContinuity(const TopoDS_Edge& theEdge);
//! Returns the 3d point.
Standard_EXPORT static gp_Pnt Pnt(const TopoDS_Vertex& V);
//! Returns the tolerance.
Standard_EXPORT static Standard_Real Tolerance(const TopoDS_Vertex& V);
//! Finds the parameter of <theV> on <theE>.
//! @param[in] theV input vertex
//! @param[in] theE input edge
//! @param[out] theParam calculated parameter on the curve
//! @return TRUE if done
Standard_EXPORT static Standard_Boolean Parameter(const TopoDS_Vertex& theV,
const TopoDS_Edge& theE,
Standard_Real& theParam);
//! Returns the parameter of <V> on <E>.
//! Throws Standard_NoSuchObject if no parameter on edge
Standard_EXPORT static Standard_Real Parameter(const TopoDS_Vertex& V, const TopoDS_Edge& E);
//! Returns the parameters of the vertex on the
//! pcurve of the edge on the face.
Standard_EXPORT static Standard_Real Parameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
const TopoDS_Face& F);
//! Returns the parameters of the vertex on the
//! pcurve of the edge on the surface.
Standard_EXPORT static Standard_Real Parameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L);
//! Returns the parameters of the vertex on the face.
Standard_EXPORT static gp_Pnt2d Parameters(const TopoDS_Vertex& V, const TopoDS_Face& F);
//! Returns the maximum tolerance of input shape subshapes.
//@param theShape - Shape to search tolerance.
//@param theSubShape - Search subshape, only Face, Edge or Vertex are supported.
Standard_EXPORT static Standard_Real MaxTolerance(const TopoDS_Shape& theShape,
const TopAbs_ShapeEnum theSubShape);
};
#endif // _BRep_Tool_HeaderFile

View File

@@ -0,0 +1,59 @@
# Source files for BRep package
set(OCCT_BRep_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_BRep_FILES
BRep_Builder.cxx
BRep_Builder.hxx
BRep_Builder.lxx
BRep_Curve3D.cxx
BRep_Curve3D.hxx
BRep_CurveOn2Surfaces.cxx
BRep_CurveOn2Surfaces.hxx
BRep_CurveOnClosedSurface.cxx
BRep_CurveOnClosedSurface.hxx
BRep_CurveOnClosedSurface.lxx
BRep_CurveOnSurface.cxx
BRep_CurveOnSurface.hxx
BRep_CurveOnSurface.lxx
BRep_CurveRepresentation.cxx
BRep_CurveRepresentation.hxx
BRep_CurveRepresentation.lxx
BRep_GCurve.cxx
BRep_GCurve.hxx
BRep_GCurve.lxx
BRep_ListIteratorOfListOfCurveRepresentation.hxx
BRep_ListIteratorOfListOfPointRepresentation.hxx
BRep_ListOfCurveRepresentation.hxx
BRep_ListOfPointRepresentation.hxx
BRep_PointOnCurve.cxx
BRep_PointOnCurve.hxx
BRep_PointOnCurveOnSurface.cxx
BRep_PointOnCurveOnSurface.hxx
BRep_PointOnSurface.cxx
BRep_PointOnSurface.hxx
BRep_PointRepresentation.cxx
BRep_PointRepresentation.hxx
BRep_PointRepresentation.lxx
BRep_PointsOnSurface.cxx
BRep_PointsOnSurface.hxx
BRep_Polygon3D.cxx
BRep_Polygon3D.hxx
BRep_PolygonOnClosedSurface.cxx
BRep_PolygonOnClosedSurface.hxx
BRep_PolygonOnClosedTriangulation.cxx
BRep_PolygonOnClosedTriangulation.hxx
BRep_PolygonOnSurface.cxx
BRep_PolygonOnSurface.hxx
BRep_PolygonOnTriangulation.cxx
BRep_PolygonOnTriangulation.hxx
BRep_TEdge.cxx
BRep_TEdge.hxx
BRep_TEdge.lxx
BRep_TFace.cxx
BRep_TFace.hxx
BRep_Tool.cxx
BRep_Tool.hxx
BRep_TVertex.cxx
BRep_TVertex.hxx
BRep_TVertex.lxx
)

View File

@@ -0,0 +1,25 @@
// Created on: 1993-02-19
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef BRepAdaptor_Array1OfCurve_HeaderFile
#define BRepAdaptor_Array1OfCurve_HeaderFile
#include <BRepAdaptor_Curve.hxx>
#include <NCollection_Array1.hxx>
typedef NCollection_Array1<BRepAdaptor_Curve> BRepAdaptor_Array1OfCurve;
#endif

View File

@@ -0,0 +1,559 @@
// Created on: 1998-08-20
// Created by: Philippe MANGIN
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepAdaptor_CompCurve.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Lin.hxx>
#include <gp_Parab.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopExp.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepAdaptor_CompCurve, Adaptor3d_Curve)
BRepAdaptor_CompCurve::BRepAdaptor_CompCurve()
: TFirst(0.0),
TLast(0.0),
PTol(0.0),
CurIndex(-1),
Forward(Standard_False),
IsbyAC(Standard_False)
{
}
BRepAdaptor_CompCurve::BRepAdaptor_CompCurve(const TopoDS_Wire& theWire,
const Standard_Boolean theIsAC)
: myWire(theWire),
TFirst(0.0),
TLast(0.0),
PTol(0.0),
CurIndex(-1),
Forward(Standard_False),
IsbyAC(theIsAC)
{
Initialize(theWire, theIsAC);
}
BRepAdaptor_CompCurve::BRepAdaptor_CompCurve(const TopoDS_Wire& theWire,
const Standard_Boolean theIsAC,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTolerance)
: myWire(theWire),
TFirst(theFirst),
TLast(theLast),
PTol(theTolerance),
CurIndex(-1),
Forward(Standard_False),
IsbyAC(theIsAC)
{
Initialize(theWire, theIsAC, theFirst, theLast, theTolerance);
}
//=================================================================================================
Handle(Adaptor3d_Curve) BRepAdaptor_CompCurve::ShallowCopy() const
{
Handle(BRepAdaptor_CompCurve) aCopy = new BRepAdaptor_CompCurve();
aCopy->myWire = myWire;
aCopy->TFirst = TFirst;
aCopy->TLast = TLast;
aCopy->PTol = PTol;
aCopy->myCurves = new (BRepAdaptor_HArray1OfCurve)(1, myCurves->Size());
for (Standard_Integer anI = 1; anI <= myCurves->Size(); ++anI)
{
const Handle(Adaptor3d_Curve) aCurve = myCurves->Value(anI).ShallowCopy();
const BRepAdaptor_Curve& aBrepCurve = *(Handle(BRepAdaptor_Curve)::DownCast(aCurve));
aCopy->myCurves->SetValue(anI, aBrepCurve);
}
aCopy->myKnots = myKnots;
aCopy->CurIndex = CurIndex;
aCopy->Forward = Forward;
aCopy->IsbyAC = IsbyAC;
return aCopy;
}
void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, const Standard_Boolean AC)
{
Standard_Integer ii, NbEdge;
BRepTools_WireExplorer wexp;
TopoDS_Edge E;
myWire = W;
PTol = 0.0;
IsbyAC = AC;
for (NbEdge = 0, wexp.Init(myWire); wexp.More(); wexp.Next())
if (!BRep_Tool::Degenerated(wexp.Current()))
NbEdge++;
if (NbEdge == 0)
return;
CurIndex = (NbEdge + 1) / 2;
myCurves = new (BRepAdaptor_HArray1OfCurve)(1, NbEdge);
myKnots = new (TColStd_HArray1OfReal)(1, NbEdge + 1);
myKnots->SetValue(1, 0.);
for (ii = 0, wexp.Init(myWire); wexp.More(); wexp.Next())
{
E = wexp.Current();
if (!BRep_Tool::Degenerated(E))
{
ii++;
myCurves->ChangeValue(ii).Initialize(E);
if (AC)
{
myKnots->SetValue(ii + 1, myKnots->Value(ii));
myKnots->ChangeValue(ii + 1) += GCPnts_AbscissaPoint::Length(myCurves->ChangeValue(ii));
}
else
myKnots->SetValue(ii + 1, (Standard_Real)ii);
}
}
Forward = Standard_True; // Default ; The Reverse Edges are parsed.
if ((NbEdge > 2) || ((NbEdge == 2) && (!myWire.Closed())))
{
TopAbs_Orientation Or = myCurves->Value(1).Edge().Orientation();
TopoDS_Vertex VI, VL;
TopExp::CommonVertex(myCurves->Value(1).Edge(), myCurves->Value(2).Edge(), VI);
VL = TopExp::LastVertex(myCurves->Value(1).Edge());
if (VI.IsSame(VL))
{ // The direction of parsing is always preserved
if (Or == TopAbs_REVERSED)
Forward = Standard_False;
}
else
{ // The direction of parsing is always reversed
if (Or != TopAbs_REVERSED)
Forward = Standard_False;
}
}
TFirst = 0;
TLast = myKnots->Value(myKnots->Length());
}
void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W,
const Standard_Boolean AC,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol)
{
Initialize(W, AC);
TFirst = First;
TLast = Last;
PTol = Tol;
// Trim the extremal curves.
Handle(BRepAdaptor_Curve) HC;
Standard_Integer i1, i2;
Standard_Real f = TFirst, l = TLast, d;
i1 = i2 = CurIndex;
Prepare(f, d, i1);
Prepare(l, d, i2);
CurIndex = (i1 + i2) / 2; // Small optimization
if (i1 == i2)
{
if (l > f)
HC = Handle(BRepAdaptor_Curve)::DownCast(myCurves->Value(i1).Trim(f, l, PTol));
else
HC = Handle(BRepAdaptor_Curve)::DownCast(myCurves->Value(i1).Trim(l, f, PTol));
myCurves->SetValue(i1, *HC);
}
else
{
const BRepAdaptor_Curve& c1 = myCurves->Value(i1);
const BRepAdaptor_Curve& c2 = myCurves->Value(i2);
Standard_Real k;
k = c1.LastParameter();
if (k > f)
HC = Handle(BRepAdaptor_Curve)::DownCast(c1.Trim(f, k, PTol));
else
HC = Handle(BRepAdaptor_Curve)::DownCast(c1.Trim(k, f, PTol));
myCurves->SetValue(i1, *HC);
k = c2.FirstParameter();
if (k <= l)
HC = Handle(BRepAdaptor_Curve)::DownCast(c2.Trim(k, l, PTol));
else
HC = Handle(BRepAdaptor_Curve)::DownCast(c2.Trim(l, k, PTol));
myCurves->SetValue(i2, *HC);
}
}
const TopoDS_Wire& BRepAdaptor_CompCurve::Wire() const
{
return myWire;
}
void BRepAdaptor_CompCurve::Edge(const Standard_Real U, TopoDS_Edge& E, Standard_Real& UonE) const
{
Standard_Real d;
Standard_Integer index = CurIndex;
UonE = U;
Prepare(UonE, d, index);
E = myCurves->Value(index).Edge();
}
Standard_Real BRepAdaptor_CompCurve::FirstParameter() const
{
return TFirst;
}
Standard_Real BRepAdaptor_CompCurve::LastParameter() const
{
return TLast;
}
GeomAbs_Shape BRepAdaptor_CompCurve::Continuity() const
{
if (myCurves->Length() > 1)
return GeomAbs_C0;
return myCurves->Value(1).Continuity();
}
Standard_Integer BRepAdaptor_CompCurve::NbIntervals(const GeomAbs_Shape S) const
{
Standard_Integer NbInt, ii;
for (ii = 1, NbInt = 0; ii <= myCurves->Length(); ii++)
NbInt += myCurves->ChangeValue(ii).NbIntervals(S);
return NbInt;
}
void BRepAdaptor_CompCurve::Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const
{
Standard_Integer ii, jj, kk, n;
Standard_Real f, F, delta;
// First curve (direction of parsing of the edge)
n = myCurves->ChangeValue(1).NbIntervals(S);
Handle(TColStd_HArray1OfReal) Ti = new (TColStd_HArray1OfReal)(1, n + 1);
myCurves->ChangeValue(1).Intervals(Ti->ChangeArray1(), S);
InvPrepare(1, f, delta);
F = myKnots->Value(1);
if (delta < 0)
{
// invert the direction of parsing
for (kk = 1, jj = Ti->Length(); jj > 0; kk++, jj--)
T(kk) = F + (Ti->Value(jj) - f) * delta;
}
else
{
for (kk = 1; kk <= Ti->Length(); kk++)
T(kk) = F + (Ti->Value(kk) - f) * delta;
}
// and the next
for (ii = 2; ii <= myCurves->Length(); ii++)
{
n = myCurves->ChangeValue(ii).NbIntervals(S);
if (n != Ti->Length() - 1)
Ti = new (TColStd_HArray1OfReal)(1, n + 1);
myCurves->ChangeValue(ii).Intervals(Ti->ChangeArray1(), S);
InvPrepare(ii, f, delta);
F = myKnots->Value(ii);
if (delta < 0)
{
// invert the direction of parcing
for (jj = Ti->Length() - 1; jj > 0; kk++, jj--)
T(kk) = F + (Ti->Value(jj) - f) * delta;
}
else
{
for (jj = 2; jj <= Ti->Length(); kk++, jj++)
T(kk) = F + (Ti->Value(jj) - f) * delta;
}
}
}
Handle(Adaptor3d_Curve) BRepAdaptor_CompCurve::Trim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const
{
BRepAdaptor_CompCurve C(myWire, IsbyAC, First, Last, Tol);
Handle(BRepAdaptor_CompCurve) HC = new (BRepAdaptor_CompCurve)(C);
return HC;
}
Standard_Boolean BRepAdaptor_CompCurve::IsClosed() const
{
return myWire.Closed();
}
Standard_Boolean BRepAdaptor_CompCurve::IsPeriodic() const
{
return Standard_False;
}
Standard_Real BRepAdaptor_CompCurve::Period() const
{
return (TLast - TFirst);
}
gp_Pnt BRepAdaptor_CompCurve::Value(const Standard_Real U) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
return myCurves->Value(index).Value(u);
}
void BRepAdaptor_CompCurve::D0(const Standard_Real U, gp_Pnt& P) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D0(u, P);
}
void BRepAdaptor_CompCurve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D1(u, P, V);
V *= d;
}
void BRepAdaptor_CompCurve::D2(const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D2(u, P, V1, V2);
V1 *= d;
V2 *= d * d;
}
void BRepAdaptor_CompCurve::D3(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D3(u, P, V1, V2, V3);
V1 *= d;
V2 *= d * d;
V3 *= d * d * d;
}
gp_Vec BRepAdaptor_CompCurve::DN(const Standard_Real U, const Standard_Integer N) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
return (myCurves->Value(index).DN(u, N) * Pow(d, N));
}
Standard_Real BRepAdaptor_CompCurve::Resolution(const Standard_Real R3d) const
{
Standard_Real Res = 1.e200, r;
Standard_Integer ii, L = myCurves->Length();
for (ii = 1; ii <= L; ii++)
{
r = myCurves->Value(ii).Resolution(R3d);
if (r < Res)
Res = r;
}
return Res;
}
GeomAbs_CurveType BRepAdaptor_CompCurve::GetType() const
{
return GeomAbs_OtherCurve; // temporary
// if ( myCurves->Length() > 1) return GeomAbs_OtherCurve;
// return myCurves->Value(1).GetType();
}
gp_Lin BRepAdaptor_CompCurve::Line() const
{
return myCurves->Value(1).Line();
}
gp_Circ BRepAdaptor_CompCurve::Circle() const
{
return myCurves->Value(1).Circle();
}
gp_Elips BRepAdaptor_CompCurve::Ellipse() const
{
return myCurves->Value(1).Ellipse();
}
gp_Hypr BRepAdaptor_CompCurve::Hyperbola() const
{
return myCurves->Value(1).Hyperbola();
}
gp_Parab BRepAdaptor_CompCurve::Parabola() const
{
return myCurves->Value(1).Parabola();
}
Standard_Integer BRepAdaptor_CompCurve::Degree() const
{
return myCurves->Value(1).Degree();
}
Standard_Boolean BRepAdaptor_CompCurve::IsRational() const
{
return myCurves->Value(1).IsRational();
}
Standard_Integer BRepAdaptor_CompCurve::NbPoles() const
{
return myCurves->Value(1).NbPoles();
}
Standard_Integer BRepAdaptor_CompCurve::NbKnots() const
{
return myCurves->Value(1).NbKnots();
}
Handle(Geom_BezierCurve) BRepAdaptor_CompCurve::Bezier() const
{
return myCurves->Value(1).Bezier();
}
Handle(Geom_BSplineCurve) BRepAdaptor_CompCurve::BSpline() const
{
return myCurves->Value(1).BSpline();
}
//=======================================================================
// function : Prepare
// purpose :
// When the parameter is close to "node" the rule is determined
// depending on the sign of tol:
// - negative -> Rule preceding to the node.
// - positive -> Rule following after the node.
//=======================================================================
void BRepAdaptor_CompCurve::Prepare(Standard_Real& W,
Standard_Real& Delta,
Standard_Integer& theCurIndex) const
{
Standard_Real f, l, Wtest, Eps;
Standard_Integer ii;
if (W - TFirst < TLast - W)
{
Eps = PTol;
}
else
{
Eps = -PTol;
}
Wtest = W + Eps; // Offset to discriminate the nodes
// Find the index
Standard_Boolean Trouve = Standard_False;
if (myKnots->Value(theCurIndex) > Wtest)
{
for (ii = theCurIndex - 1; ii > 0 && !Trouve; ii--)
if (myKnots->Value(ii) <= Wtest)
{
theCurIndex = ii;
Trouve = Standard_True;
}
if (!Trouve)
theCurIndex = 1; // Out of limits...
}
else if (myKnots->Value(theCurIndex + 1) <= Wtest)
{
for (ii = theCurIndex + 1; ii <= myCurves->Length() && !Trouve; ii++)
if (myKnots->Value(ii + 1) > Wtest)
{
theCurIndex = ii;
Trouve = Standard_True;
}
if (!Trouve)
theCurIndex = myCurves->Length(); // Out of limits...
}
// Invert ?
const TopoDS_Edge& E = myCurves->Value(theCurIndex).Edge();
TopAbs_Orientation Or = E.Orientation();
Standard_Boolean Reverse;
Reverse = (Forward && (Or == TopAbs_REVERSED)) || (!Forward && (Or != TopAbs_REVERSED));
// Calculate the local parameter
BRep_Tool::Range(E, f, l);
Delta = myKnots->Value(theCurIndex + 1) - myKnots->Value(theCurIndex);
if (Delta > PTol * 1.e-9)
Delta = (l - f) / Delta;
if (Reverse)
{
Delta *= -1;
W = l + (W - myKnots->Value(theCurIndex)) * Delta;
}
else
{
W = f + (W - myKnots->Value(theCurIndex)) * Delta;
}
}
void BRepAdaptor_CompCurve::InvPrepare(const Standard_Integer index,
Standard_Real& First,
Standard_Real& Delta) const
{
// Invert?
const TopoDS_Edge& E = myCurves->Value(index).Edge();
TopAbs_Orientation Or = E.Orientation();
Standard_Boolean Reverse;
Reverse = (Forward && (Or == TopAbs_REVERSED)) || (!Forward && (Or != TopAbs_REVERSED));
// Calculate the parameters of reparametrisation
// such as : T = Ti + (t-First)*Delta
Standard_Real f, l;
BRep_Tool::Range(E, f, l);
Delta = myKnots->Value(index + 1) - myKnots->Value(index);
if (l - f > PTol * 1.e-9)
Delta /= (l - f);
if (Reverse)
{
Delta *= -1;
First = l;
}
else
{
First = f;
}
}

View File

@@ -0,0 +1,215 @@
// Created on: 1998-08-20
// Created by: Philippe MANGIN
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepAdaptor_CompCurve_HeaderFile
#define _BRepAdaptor_CompCurve_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopoDS_Wire.hxx>
#include <Standard_Real.hxx>
#include <BRepAdaptor_HArray1OfCurve.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <Adaptor3d_Curve.hxx>
#include <GeomAbs_Shape.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <GeomAbs_CurveType.hxx>
class TopoDS_Edge;
class gp_Pnt;
class gp_Vec;
class gp_Lin;
class gp_Circ;
class gp_Elips;
class gp_Hypr;
class gp_Parab;
class Geom_BezierCurve;
class Geom_BSplineCurve;
DEFINE_STANDARD_HANDLE(BRepAdaptor_CompCurve, Adaptor3d_Curve)
//! The Curve from BRepAdaptor allows to use a Wire
//! of the BRep topology like a 3D curve.
//! Warning: With this class of curve, C0 and C1 continuities
//! are not assumed. So be careful with some algorithm!
//! Please note that BRepAdaptor_CompCurve cannot be
//! periodic curve at all (even if it contains single
//! periodic edge).
//!
//! BRepAdaptor_CompCurve can only work on valid wires where all edges are
//! connected to each other to make a chain.
class BRepAdaptor_CompCurve : public Adaptor3d_Curve
{
DEFINE_STANDARD_RTTIEXT(BRepAdaptor_CompCurve, Adaptor3d_Curve)
public:
//! Creates an undefined Curve with no Wire loaded.
Standard_EXPORT BRepAdaptor_CompCurve();
Standard_EXPORT BRepAdaptor_CompCurve(
const TopoDS_Wire& W,
const Standard_Boolean KnotByCurvilinearAbcissa = Standard_False);
//! Creates a Curve to access the geometry of edge
//! <W>.
Standard_EXPORT BRepAdaptor_CompCurve(const TopoDS_Wire& W,
const Standard_Boolean KnotByCurvilinearAbcissa,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol);
//! Shallow copy of adaptor
Standard_EXPORT virtual Handle(Adaptor3d_Curve) ShallowCopy() const Standard_OVERRIDE;
//! Sets the wire <W>.
Standard_EXPORT void Initialize(const TopoDS_Wire& W,
const Standard_Boolean KnotByCurvilinearAbcissa);
//! Sets wire <W> and trimmed parameter.
Standard_EXPORT void Initialize(const TopoDS_Wire& W,
const Standard_Boolean KnotByCurvilinearAbcissa,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol);
//! Returns the wire.
Standard_EXPORT const TopoDS_Wire& Wire() const;
//! returns an edge and one parameter on them
//! corresponding to the parameter U.
Standard_EXPORT void Edge(const Standard_Real U, TopoDS_Edge& E, Standard_Real& UonE) const;
Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
//! Returns the number of intervals for continuity
//! <S>. May be one if Continuity(me) >= <S>
Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) const Standard_OVERRIDE;
//! Stores in <T> the parameters bounding the intervals
//! of continuity <S>.
//!
//! The array must provide enough room to accommodate
//! for the parameters. i.e. T.Length() > NbIntervals()
Standard_EXPORT void Intervals(TColStd_Array1OfReal& T,
const GeomAbs_Shape S) const Standard_OVERRIDE;
//! Returns a curve equivalent of <me> between
//! parameters <First> and <Last>. <Tol> is used to
//! test for 3d points confusion.
//! If <First> >= <Last>
Standard_EXPORT Handle(Adaptor3d_Curve) Trim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
//! Computes the point of parameter U on the curve
Standard_EXPORT gp_Pnt Value(const Standard_Real U) const Standard_OVERRIDE;
//! Computes the point of parameter U.
Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
//! Computes the point of parameter U on the curve
//! with its first derivative.
//! Raised if the continuity of the current interval
//! is not C1.
Standard_EXPORT void D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE;
//! Returns the point P of parameter U, the first and second
//! derivatives V1 and V2.
//! Raised if the continuity of the current interval
//! is not C2.
Standard_EXPORT void D2(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2) const Standard_OVERRIDE;
//! Returns the point P of parameter U, the first, the second
//! and the third derivative.
//! Raised if the continuity of the current interval
//! is not C3.
Standard_EXPORT void D3(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const Standard_OVERRIDE;
//! The returned vector gives the value of the derivative for the
//! order of derivation N.
//! Raised if the continuity of the current interval
//! is not CN.
//! Raised if N < 1.
Standard_EXPORT gp_Vec DN(const Standard_Real U,
const Standard_Integer N) const Standard_OVERRIDE;
//! returns the parametric resolution
Standard_EXPORT Standard_Real Resolution(const Standard_Real R3d) const Standard_OVERRIDE;
Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE;
Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE;
Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE;
Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE;
Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE;
Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE;
Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE;
Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
protected:
private:
Standard_EXPORT void Prepare(Standard_Real& W, Standard_Real& D, Standard_Integer& ind) const;
Standard_EXPORT void InvPrepare(const Standard_Integer ind,
Standard_Real& F,
Standard_Real& D) const;
TopoDS_Wire myWire;
Standard_Real TFirst;
Standard_Real TLast;
Standard_Real PTol;
Handle(BRepAdaptor_HArray1OfCurve) myCurves;
Handle(TColStd_HArray1OfReal) myKnots;
Standard_Integer CurIndex;
Standard_Boolean Forward;
Standard_Boolean IsbyAC;
};
#endif // _BRepAdaptor_CompCurve_HeaderFile

View File

@@ -0,0 +1,599 @@
// Created on: 1993-02-19
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepAdaptor_Curve.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <BRep_Tool.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Lin.hxx>
#include <gp_Parab.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_NullObject.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <Geom_OffsetCurve.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepAdaptor_Curve, Adaptor3d_Curve)
//=================================================================================================
BRepAdaptor_Curve::BRepAdaptor_Curve() {}
//=================================================================================================
BRepAdaptor_Curve::BRepAdaptor_Curve(const TopoDS_Edge& E)
{
Initialize(E);
}
//=================================================================================================
BRepAdaptor_Curve::BRepAdaptor_Curve(const TopoDS_Edge& E, const TopoDS_Face& F)
{
Initialize(E, F);
}
//=================================================================================================
Handle(Adaptor3d_Curve) BRepAdaptor_Curve::ShallowCopy() const
{
Handle(BRepAdaptor_Curve) aCopy = new BRepAdaptor_Curve();
aCopy->myTrsf = myTrsf;
const Handle(Adaptor3d_Curve) aCurve = myCurve.ShallowCopy();
const GeomAdaptor_Curve& aGeomCurve = *(Handle(GeomAdaptor_Curve)::DownCast(aCurve));
aCopy->myCurve = aGeomCurve;
if (!myConSurf.IsNull())
{
aCopy->myConSurf = Handle(Adaptor3d_CurveOnSurface)::DownCast(myConSurf->ShallowCopy());
}
aCopy->myEdge = myEdge;
return aCopy;
}
//=================================================================================================
void BRepAdaptor_Curve::Reset()
{
myCurve.Reset();
myConSurf.Nullify();
myEdge.Nullify();
myTrsf = gp_Trsf();
}
//=================================================================================================
void BRepAdaptor_Curve::Initialize(const TopoDS_Edge& E)
{
myConSurf.Nullify();
myEdge = E;
Standard_Real pf, pl;
TopLoc_Location L;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, pf, pl);
if (!C.IsNull())
{
myCurve.Load(C, pf, pl);
}
else
{
Handle(Geom2d_Curve) PC;
Handle(Geom_Surface) S;
BRep_Tool::CurveOnSurface(E, PC, S, L, pf, pl);
if (!PC.IsNull())
{
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(S);
Handle(Geom2dAdaptor_Curve) HC = new Geom2dAdaptor_Curve();
HC->Load(PC, pf, pl);
myConSurf = new Adaptor3d_CurveOnSurface();
myConSurf->Load(HC, HS);
}
else
{
throw Standard_NullObject("BRepAdaptor_Curve::No geometry");
}
}
myTrsf = L.Transformation();
}
//=================================================================================================
void BRepAdaptor_Curve::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F)
{
myConSurf.Nullify();
myEdge = E;
TopLoc_Location L;
Standard_Real pf, pl;
Handle(Geom_Surface) S = BRep_Tool::Surface(F, L);
Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(E, F, pf, pl);
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(S);
Handle(Geom2dAdaptor_Curve) HC = new Geom2dAdaptor_Curve();
HC->Load(PC, pf, pl);
myConSurf = new Adaptor3d_CurveOnSurface();
myConSurf->Load(HC, HS);
myTrsf = L.Transformation();
}
//=================================================================================================
const gp_Trsf& BRepAdaptor_Curve::Trsf() const
{
return myTrsf;
}
//=================================================================================================
Standard_Boolean BRepAdaptor_Curve::Is3DCurve() const
{
return myConSurf.IsNull();
}
//=================================================================================================
Standard_Boolean BRepAdaptor_Curve::IsCurveOnSurface() const
{
return !myConSurf.IsNull();
}
//=================================================================================================
const GeomAdaptor_Curve& BRepAdaptor_Curve::Curve() const
{
return myCurve;
}
//=================================================================================================
const Adaptor3d_CurveOnSurface& BRepAdaptor_Curve::CurveOnSurface() const
{
return *myConSurf;
}
//=================================================================================================
const TopoDS_Edge& BRepAdaptor_Curve::Edge() const
{
return myEdge;
}
//=================================================================================================
Standard_Real BRepAdaptor_Curve::Tolerance() const
{
return BRep_Tool::Tolerance(myEdge);
}
//=================================================================================================
Standard_Real BRepAdaptor_Curve::FirstParameter() const
{
if (myConSurf.IsNull())
{
return myCurve.FirstParameter();
}
else
{
return myConSurf->FirstParameter();
}
}
//=================================================================================================
Standard_Real BRepAdaptor_Curve::LastParameter() const
{
if (myConSurf.IsNull())
{
return myCurve.LastParameter();
}
else
{
return myConSurf->LastParameter();
}
}
//=================================================================================================
GeomAbs_Shape BRepAdaptor_Curve::Continuity() const
{
if (myConSurf.IsNull())
{
return myCurve.Continuity();
}
else
{
return myConSurf->Continuity();
}
}
//=================================================================================================
Standard_Integer BRepAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
{
if (myConSurf.IsNull())
{
return myCurve.NbIntervals(S);
}
else
{
return myConSurf->NbIntervals(S);
}
}
//=================================================================================================
void BRepAdaptor_Curve::Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const
{
if (myConSurf.IsNull())
{
myCurve.Intervals(T, S);
}
else
{
myConSurf->Intervals(T, S);
}
}
//=================================================================================================
Handle(Adaptor3d_Curve) BRepAdaptor_Curve::Trim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const
{
// On fait une copie de this pour garder la trsf.
Handle(BRepAdaptor_Curve) res;
if (myConSurf.IsNull())
{
Standard_Real pf = FirstParameter(), pl = LastParameter();
Handle(Geom_Curve) C = myCurve.Curve();
const_cast<GeomAdaptor_Curve*>(&myCurve)->Load(C, First, Last);
res = new BRepAdaptor_Curve(*this);
const_cast<GeomAdaptor_Curve*>(&myCurve)->Load(C, pf, pl);
}
else
{
Handle(Adaptor3d_CurveOnSurface) sav = myConSurf;
const_cast<Handle(Adaptor3d_CurveOnSurface)&>(myConSurf) =
Handle(Adaptor3d_CurveOnSurface)::DownCast(myConSurf->Trim(First, Last, Tol));
res = new BRepAdaptor_Curve(*this);
const_cast<Handle(Adaptor3d_CurveOnSurface)&>(myConSurf) = sav;
}
return res;
}
//=================================================================================================
Standard_Boolean BRepAdaptor_Curve::IsClosed() const
{
if (myConSurf.IsNull())
{
return myCurve.IsClosed();
}
else
{
return myConSurf->IsClosed();
}
}
//=================================================================================================
Standard_Boolean BRepAdaptor_Curve::IsPeriodic() const
{
if (myConSurf.IsNull())
{
return myCurve.IsPeriodic();
}
else
{
return myConSurf->IsPeriodic();
}
}
//=================================================================================================
Standard_Real BRepAdaptor_Curve::Period() const
{
if (myConSurf.IsNull())
{
return myCurve.Period();
}
else
{
return myConSurf->Period();
}
}
//=================================================================================================
gp_Pnt BRepAdaptor_Curve::Value(const Standard_Real U) const
{
gp_Pnt P;
if (myConSurf.IsNull())
P = myCurve.Value(U);
else
P = myConSurf->Value(U);
P.Transform(myTrsf);
return P;
}
//=================================================================================================
void BRepAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
{
if (myConSurf.IsNull())
myCurve.D0(U, P);
else
myConSurf->D0(U, P);
P.Transform(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
{
if (myConSurf.IsNull())
myCurve.D1(U, P, V);
else
myConSurf->D1(U, P, V);
P.Transform(myTrsf);
V.Transform(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Curve::D2(const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
{
if (myConSurf.IsNull())
myCurve.D2(U, P, V1, V2);
else
myConSurf->D2(U, P, V1, V2);
P.Transform(myTrsf);
V1.Transform(myTrsf);
V2.Transform(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Curve::D3(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const
{
if (myConSurf.IsNull())
myCurve.D3(U, P, V1, V2, V3);
else
myConSurf->D3(U, P, V1, V2, V3);
P.Transform(myTrsf);
V1.Transform(myTrsf);
V2.Transform(myTrsf);
V3.Transform(myTrsf);
}
//=================================================================================================
gp_Vec BRepAdaptor_Curve::DN(const Standard_Real U, const Standard_Integer N) const
{
gp_Vec V;
if (myConSurf.IsNull())
V = myCurve.DN(U, N);
else
V = myConSurf->DN(U, N);
V.Transform(myTrsf);
return V;
}
//=================================================================================================
Standard_Real BRepAdaptor_Curve::Resolution(const Standard_Real R) const
{
if (myConSurf.IsNull())
{
return myCurve.Resolution(R);
}
else
{
return myConSurf->Resolution(R);
}
}
//=================================================================================================
GeomAbs_CurveType BRepAdaptor_Curve::GetType() const
{
if (myConSurf.IsNull())
{
return myCurve.GetType();
}
else
{
return myConSurf->GetType();
}
}
//=================================================================================================
gp_Lin BRepAdaptor_Curve::Line() const
{
gp_Lin L;
if (myConSurf.IsNull())
L = myCurve.Line();
else
L = myConSurf->Line();
L.Transform(myTrsf);
return L;
}
//=================================================================================================
gp_Circ BRepAdaptor_Curve::Circle() const
{
gp_Circ C;
if (myConSurf.IsNull())
C = myCurve.Circle();
else
C = myConSurf->Circle();
C.Transform(myTrsf);
return C;
}
//=================================================================================================
gp_Elips BRepAdaptor_Curve::Ellipse() const
{
gp_Elips E;
if (myConSurf.IsNull())
E = myCurve.Ellipse();
else
E = myConSurf->Ellipse();
E.Transform(myTrsf);
return E;
}
//=================================================================================================
gp_Hypr BRepAdaptor_Curve::Hyperbola() const
{
gp_Hypr H;
if (myConSurf.IsNull())
H = myCurve.Hyperbola();
else
H = myConSurf->Hyperbola();
H.Transform(myTrsf);
return H;
}
//=================================================================================================
gp_Parab BRepAdaptor_Curve::Parabola() const
{
gp_Parab P;
if (myConSurf.IsNull())
P = myCurve.Parabola();
else
P = myConSurf->Parabola();
P.Transform(myTrsf);
return P;
}
//=================================================================================================
Standard_Integer BRepAdaptor_Curve::Degree() const
{
if (myConSurf.IsNull())
return myCurve.Degree();
else
return myConSurf->Degree();
}
//=================================================================================================
Standard_Boolean BRepAdaptor_Curve::IsRational() const
{
if (myConSurf.IsNull())
return myCurve.IsRational();
else
return myConSurf->IsRational();
}
//=================================================================================================
Standard_Integer BRepAdaptor_Curve::NbPoles() const
{
if (myConSurf.IsNull())
return myCurve.NbPoles();
else
return myConSurf->NbPoles();
}
//=================================================================================================
Standard_Integer BRepAdaptor_Curve::NbKnots() const
{
if (myConSurf.IsNull())
return myCurve.NbKnots();
else
return myConSurf->NbKnots();
}
//=================================================================================================
Handle(Geom_BezierCurve) BRepAdaptor_Curve::Bezier() const
{
Handle(Geom_BezierCurve) BC;
if (myConSurf.IsNull())
{
BC = myCurve.Bezier();
}
else
{
BC = myConSurf->Bezier();
}
return myTrsf.Form() == gp_Identity ? BC
: Handle(Geom_BezierCurve)::DownCast(BC->Transformed(myTrsf));
}
//=================================================================================================
Handle(Geom_BSplineCurve) BRepAdaptor_Curve::BSpline() const
{
Handle(Geom_BSplineCurve) BS;
if (myConSurf.IsNull())
{
BS = myCurve.BSpline();
}
else
{
BS = myConSurf->BSpline();
}
return myTrsf.Form() == gp_Identity
? BS
: Handle(Geom_BSplineCurve)::DownCast(BS->Transformed(myTrsf));
}
//=================================================================================================
Handle(Geom_OffsetCurve) BRepAdaptor_Curve::OffsetCurve() const
{
if (!Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve)
throw Standard_NoSuchObject("BRepAdaptor_Curve::OffsetCurve");
Handle(Geom_OffsetCurve) anOffC = myCurve.OffsetCurve();
return myTrsf.Form() == gp_Identity
? anOffC
: Handle(Geom_OffsetCurve)::DownCast(anOffC->Transformed(myTrsf));
}

View File

@@ -0,0 +1,229 @@
// Created on: 1993-02-19
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepAdaptor_Curve_HeaderFile
#define _BRepAdaptor_Curve_HeaderFile
#include <Adaptor3d_CurveOnSurface.hxx>
#include <gp_Trsf.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <TopoDS_Edge.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Standard_Real.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <GeomAbs_CurveType.hxx>
class TopoDS_Face;
class Adaptor3d_CurveOnSurface;
class gp_Pnt;
class gp_Vec;
class gp_Lin;
class gp_Circ;
class gp_Elips;
class gp_Hypr;
class gp_Parab;
class Geom_BezierCurve;
class Geom_BSplineCurve;
class Geom_OffsetCurve;
DEFINE_STANDARD_HANDLE(BRepAdaptor_Curve, Adaptor3d_Curve)
//! The Curve from BRepAdaptor allows to use an Edge
//! of the BRep topology like a 3D curve.
//!
//! It has the methods the class Curve from Adaptor3d.
//!
//! It is created or Initialized with an Edge. It
//! takes into account local coordinate systems. If
//! the Edge has a 3D curve it is use with priority.
//! If the edge has no 3D curve one of the curves on
//! surface is used. It is possible to enforce using a
//! curve on surface by creating or initialising with
//! an Edge and a Face.
class BRepAdaptor_Curve : public Adaptor3d_Curve
{
DEFINE_STANDARD_RTTIEXT(BRepAdaptor_Curve, Adaptor3d_Curve)
public:
//! Creates an undefined Curve with no Edge loaded.
Standard_EXPORT BRepAdaptor_Curve();
//! Creates a Curve to access the geometry of edge
//! <E>.
Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E);
//! Creates a Curve to access the geometry of edge
//! <E>. The geometry will be computed using the
//! parametric curve of <E> on the face <F>. An Error
//! is raised if the edge does not have a pcurve on
//! the face.
Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E, const TopoDS_Face& F);
//! Shallow copy of adaptor
Standard_EXPORT virtual Handle(Adaptor3d_Curve) ShallowCopy() const Standard_OVERRIDE;
//! Reset currently loaded curve (undone Load()).
Standard_EXPORT void Reset();
//! Sets the Curve <me> to access the geometry of
//! edge <E>.
Standard_EXPORT void Initialize(const TopoDS_Edge& E);
//! Sets the Curve <me> to access the geometry of
//! edge <E>. The geometry will be computed using the
//! parametric curve of <E> on the face <F>. An Error
//! is raised if the edge does not have a pcurve on
//! the face.
Standard_EXPORT void Initialize(const TopoDS_Edge& E, const TopoDS_Face& F);
//! Returns the coordinate system of the curve.
Standard_EXPORT const gp_Trsf& Trsf() const;
//! Returns True if the edge geometry is computed from
//! a 3D curve.
Standard_EXPORT Standard_Boolean Is3DCurve() const;
//! Returns True if the edge geometry is computed from
//! a pcurve on a surface.
Standard_EXPORT Standard_Boolean IsCurveOnSurface() const;
//! Returns the Curve of the edge.
Standard_EXPORT const GeomAdaptor_Curve& Curve() const;
//! Returns the CurveOnSurface of the edge.
Standard_EXPORT const Adaptor3d_CurveOnSurface& CurveOnSurface() const;
//! Returns the edge.
Standard_EXPORT const TopoDS_Edge& Edge() const;
//! Returns the edge tolerance.
Standard_EXPORT Standard_Real Tolerance() const;
Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
//! Returns the number of intervals for continuity
//! <S>. May be one if Continuity(me) >= <S>
Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) const Standard_OVERRIDE;
//! Stores in <T> the parameters bounding the intervals
//! of continuity <S>.
//!
//! The array must provide enough room to accommodate
//! for the parameters. i.e. T.Length() > NbIntervals()
Standard_EXPORT void Intervals(TColStd_Array1OfReal& T,
const GeomAbs_Shape S) const Standard_OVERRIDE;
//! Returns a curve equivalent of <me> between
//! parameters <First> and <Last>. <Tol> is used to
//! test for 3d points confusion.
//! If <First> >= <Last>
Standard_EXPORT Handle(Adaptor3d_Curve) Trim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
//! Computes the point of parameter U on the curve
Standard_EXPORT gp_Pnt Value(const Standard_Real U) const Standard_OVERRIDE;
//! Computes the point of parameter U.
Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
//! Computes the point of parameter U on the curve
//! with its first derivative.
//! Raised if the continuity of the current interval
//! is not C1.
Standard_EXPORT void D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE;
//! Returns the point P of parameter U, the first and second
//! derivatives V1 and V2.
//! Raised if the continuity of the current interval
//! is not C2.
Standard_EXPORT void D2(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2) const Standard_OVERRIDE;
//! Returns the point P of parameter U, the first, the second
//! and the third derivative.
//! Raised if the continuity of the current interval
//! is not C3.
Standard_EXPORT void D3(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const Standard_OVERRIDE;
//! The returned vector gives the value of the derivative for the
//! order of derivation N.
//! Raised if the continuity of the current interval
//! is not CN.
//! Raised if N < 1.
Standard_EXPORT gp_Vec DN(const Standard_Real U,
const Standard_Integer N) const Standard_OVERRIDE;
//! returns the parametric resolution
Standard_EXPORT Standard_Real Resolution(const Standard_Real R3d) const Standard_OVERRIDE;
Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE;
Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE;
Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE;
Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE;
Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE;
Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE;
Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
//! Warning:
//! This will make a copy of the Bezier Curve since it applies to it myTsrf.
//! Be careful when using this method.
Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE;
//! Warning:
//! This will make a copy of the BSpline Curve since it applies to it myTsrf.
//! Be careful when using this method.
Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
Standard_EXPORT Handle(Geom_OffsetCurve) OffsetCurve() const Standard_OVERRIDE;
private:
gp_Trsf myTrsf;
GeomAdaptor_Curve myCurve;
Handle(Adaptor3d_CurveOnSurface) myConSurf;
TopoDS_Edge myEdge;
};
#endif // _BRepAdaptor_Curve_HeaderFile

View File

@@ -0,0 +1,80 @@
// Created on: 1993-07-13
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_Tool.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepAdaptor_Curve2d, Geom2dAdaptor_Curve)
//=================================================================================================
BRepAdaptor_Curve2d::BRepAdaptor_Curve2d() {}
//=================================================================================================
BRepAdaptor_Curve2d::BRepAdaptor_Curve2d(const TopoDS_Edge& E, const TopoDS_Face& F)
{
Initialize(E, F);
}
//=================================================================================================
Handle(Adaptor2d_Curve2d) BRepAdaptor_Curve2d::ShallowCopy() const
{
Handle(BRepAdaptor_Curve2d) aCopy = new BRepAdaptor_Curve2d();
aCopy->myCurve = myCurve;
aCopy->myTypeCurve = myTypeCurve;
aCopy->myFirst = myFirst;
aCopy->myLast = myLast;
aCopy->myBSplineCurve = myBSplineCurve;
if (!myNestedEvaluator.IsNull())
{
aCopy->myNestedEvaluator = myNestedEvaluator->ShallowCopy();
}
return aCopy;
}
//=================================================================================================
void BRepAdaptor_Curve2d::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F)
{
myEdge = E;
myFace = F;
Standard_Real aFirs, aLast;
const Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(E, F, aFirs, aLast);
if (!aPCurve.IsNull())
{
Geom2dAdaptor_Curve::Load(aPCurve, aFirs, aLast);
}
}
//=================================================================================================
const TopoDS_Edge& BRepAdaptor_Curve2d::Edge() const
{
return myEdge;
}
//=================================================================================================
const TopoDS_Face& BRepAdaptor_Curve2d::Face() const
{
return myFace;
}

View File

@@ -0,0 +1,67 @@
// Created on: 1993-07-13
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepAdaptor_Curve2d_HeaderFile
#define _BRepAdaptor_Curve2d_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <Geom2dAdaptor_Curve.hxx>
//! The Curve2d from BRepAdaptor allows to use an Edge
//! on a Face like a 2d curve. (curve in the
//! parametric space).
//!
//! It has the methods of the class Curve2d from
//! Adpator.
//!
//! It is created or initialized with a Face and an
//! Edge. The methods are inherited from Curve from
//! Geom2dAdaptor.
class BRepAdaptor_Curve2d : public Geom2dAdaptor_Curve
{
DEFINE_STANDARD_RTTIEXT(BRepAdaptor_Curve2d, Geom2dAdaptor_Curve)
public:
//! Creates an uninitialized curve2d.
Standard_EXPORT BRepAdaptor_Curve2d();
//! Creates with the pcurve of <E> on <F>.
Standard_EXPORT BRepAdaptor_Curve2d(const TopoDS_Edge& E, const TopoDS_Face& F);
//! Shallow copy of adaptor
Standard_EXPORT virtual Handle(Adaptor2d_Curve2d) ShallowCopy() const Standard_OVERRIDE;
//! Initialize with the pcurve of <E> on <F>.
Standard_EXPORT void Initialize(const TopoDS_Edge& E, const TopoDS_Face& F);
//! Returns the Edge.
Standard_EXPORT const TopoDS_Edge& Edge() const;
//! Returns the Face.
Standard_EXPORT const TopoDS_Face& Face() const;
private:
TopoDS_Edge myEdge;
TopoDS_Face myFace;
};
DEFINE_STANDARD_HANDLE(BRepAdaptor_Curve2d, Geom2dAdaptor_Curve)
#endif // _BRepAdaptor_Curve2d_HeaderFile

View File

@@ -0,0 +1,25 @@
// Created on: 1993-02-19
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef BRepAdaptor_HArray1OfCurve_HeaderFile
#define BRepAdaptor_HArray1OfCurve_HeaderFile
#include <BRepAdaptor_Array1OfCurve.hxx>
#include <NCollection_DefineHArray1.hxx>
DEFINE_HARRAY1(BRepAdaptor_HArray1OfCurve, BRepAdaptor_Array1OfCurve)
#endif

View File

@@ -0,0 +1,335 @@
// Created on: 1993-02-19
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepAdaptor_Surface.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_Surface.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <gp_Ax1.hxx>
#include <gp_Cone.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Dir.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Sphere.hxx>
#include <gp_Torus.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <TopoDS_Face.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepAdaptor_Surface, Adaptor3d_Surface)
//=================================================================================================
BRepAdaptor_Surface::BRepAdaptor_Surface() {}
//=================================================================================================
BRepAdaptor_Surface::BRepAdaptor_Surface(const TopoDS_Face& F, const Standard_Boolean R)
{
Initialize(F, R);
}
//=================================================================================================
Handle(Adaptor3d_Surface) BRepAdaptor_Surface::ShallowCopy() const
{
Handle(BRepAdaptor_Surface) aCopy = new BRepAdaptor_Surface();
const Handle(Adaptor3d_Surface) aSurface = mySurf.ShallowCopy();
const GeomAdaptor_Surface& aGeomSurface = *(Handle(GeomAdaptor_Surface)::DownCast(aSurface));
aCopy->mySurf = aGeomSurface;
aCopy->myTrsf = myTrsf;
aCopy->myFace = myFace;
return aCopy;
}
//=================================================================================================
void BRepAdaptor_Surface::Initialize(const TopoDS_Face& F, const Standard_Boolean Restriction)
{
myFace = F;
TopLoc_Location L;
const Handle(Geom_Surface)& aSurface = BRep_Tool::Surface(F, L);
if (aSurface.IsNull())
return;
if (Restriction)
{
Standard_Real umin, umax, vmin, vmax;
BRepTools::UVBounds(F, umin, umax, vmin, vmax);
mySurf.Load(aSurface, umin, umax, vmin, vmax);
}
else
mySurf.Load(aSurface);
myTrsf = L.Transformation();
}
//=================================================================================================
const GeomAdaptor_Surface& BRepAdaptor_Surface::Surface() const
{
return mySurf;
}
//=================================================================================================
GeomAdaptor_Surface& BRepAdaptor_Surface::ChangeSurface()
{
return mySurf;
}
//=================================================================================================
const gp_Trsf& BRepAdaptor_Surface::Trsf() const
{
return myTrsf;
}
//=================================================================================================
const TopoDS_Face& BRepAdaptor_Surface::Face() const
{
return myFace;
}
//=================================================================================================
Standard_Real BRepAdaptor_Surface::Tolerance() const
{
return BRep_Tool::Tolerance(myFace);
}
//=================================================================================================
void BRepAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const
{
mySurf.UIntervals(T, S);
}
//=================================================================================================
void BRepAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const
{
mySurf.VIntervals(T, S);
}
//=================================================================================================
Handle(Adaptor3d_Surface) BRepAdaptor_Surface::UTrim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const
{
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
return HS->UTrim(First, Last, Tol);
}
//=================================================================================================
Handle(Adaptor3d_Surface) BRepAdaptor_Surface::VTrim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const
{
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
return HS->VTrim(First, Last, Tol);
}
//=================================================================================================
gp_Pnt BRepAdaptor_Surface::Value(const Standard_Real U, const Standard_Real V) const
{
return mySurf.Value(U, V).Transformed(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Surface::D0(const Standard_Real U, const Standard_Real V, gp_Pnt& P) const
{
mySurf.D0(U, V, P);
P.Transform(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Surface::D1(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V) const
{
mySurf.D1(U, V, P, D1U, D1V);
P.Transform(myTrsf);
D1U.Transform(myTrsf);
D1V.Transform(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Surface::D2(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& D2UV) const
{
mySurf.D2(U, V, P, D1U, D1V, D2U, D2V, D2UV);
P.Transform(myTrsf);
D1U.Transform(myTrsf);
D1V.Transform(myTrsf);
D2U.Transform(myTrsf);
D2V.Transform(myTrsf);
D2UV.Transform(myTrsf);
}
//=================================================================================================
void BRepAdaptor_Surface::D3(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& D2UV,
gp_Vec& D3U,
gp_Vec& D3V,
gp_Vec& D3UUV,
gp_Vec& D3UVV) const
{
mySurf.D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV);
P.Transform(myTrsf);
D1U.Transform(myTrsf);
D1V.Transform(myTrsf);
D2U.Transform(myTrsf);
D2V.Transform(myTrsf);
D2UV.Transform(myTrsf);
D3U.Transform(myTrsf);
D3V.Transform(myTrsf);
D3UUV.Transform(myTrsf);
D3UVV.Transform(myTrsf);
}
//=================================================================================================
gp_Vec BRepAdaptor_Surface::DN(const Standard_Real U,
const Standard_Real V,
const Standard_Integer Nu,
const Standard_Integer Nv) const
{
return mySurf.DN(U, V, Nu, Nv).Transformed(myTrsf);
}
//=================================================================================================
gp_Pln BRepAdaptor_Surface::Plane() const
{
return mySurf.Plane().Transformed(myTrsf);
}
//=================================================================================================
gp_Cylinder BRepAdaptor_Surface::Cylinder() const
{
return mySurf.Cylinder().Transformed(myTrsf);
}
//=================================================================================================
gp_Sphere BRepAdaptor_Surface::Sphere() const
{
return mySurf.Sphere().Transformed(myTrsf);
}
//=================================================================================================
gp_Cone BRepAdaptor_Surface::Cone() const
{
return mySurf.Cone().Transformed(myTrsf);
}
//=================================================================================================
gp_Torus BRepAdaptor_Surface::Torus() const
{
return mySurf.Torus().Transformed(myTrsf);
}
//=================================================================================================
Handle(Geom_BezierSurface) BRepAdaptor_Surface::Bezier() const
{
return Handle(Geom_BezierSurface)::DownCast(mySurf.Bezier()->Transformed(myTrsf));
}
//=================================================================================================
Handle(Geom_BSplineSurface) BRepAdaptor_Surface::BSpline() const
{
return Handle(Geom_BSplineSurface)::DownCast(mySurf.BSpline()->Transformed(myTrsf));
}
//=================================================================================================
gp_Ax1 BRepAdaptor_Surface::AxeOfRevolution() const
{
return mySurf.AxeOfRevolution().Transformed(myTrsf);
}
//=================================================================================================
gp_Dir BRepAdaptor_Surface::Direction() const
{
return mySurf.Direction().Transformed(myTrsf);
}
//=================================================================================================
Handle(Adaptor3d_Curve) BRepAdaptor_Surface::BasisCurve() const
{
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
return HS->BasisCurve();
}
//=================================================================================================
Handle(Adaptor3d_Surface) BRepAdaptor_Surface::BasisSurface() const
{
Handle(GeomAdaptor_Surface) HS = new GeomAdaptor_Surface();
HS->Load(Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf)));
return HS->BasisSurface();
}
//=================================================================================================
Standard_Real BRepAdaptor_Surface::OffsetValue() const
{
return mySurf.OffsetValue();
}

View File

@@ -0,0 +1,296 @@
// Created on: 1993-02-22
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepAdaptor_Surface_HeaderFile
#define _BRepAdaptor_Surface_HeaderFile
#include <GeomAdaptor_Surface.hxx>
#include <GeomAbs_Shape.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <gp_Trsf.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopoDS_Face.hxx>
class gp_Pnt;
class gp_Vec;
class gp_Pln;
class gp_Cylinder;
class gp_Cone;
class gp_Sphere;
class gp_Torus;
class Geom_BezierSurface;
class Geom_BSplineSurface;
class gp_Ax1;
class gp_Dir;
DEFINE_STANDARD_HANDLE(BRepAdaptor_Surface, Adaptor3d_Surface)
//! The Surface from BRepAdaptor allows to use a Face
//! of the BRep topology look like a 3D surface.
//!
//! It has the methods of the class Surface from
//! Adaptor3d.
//!
//! It is created or initialized with a Face. It takes
//! into account the local coordinates system.
//!
//! The u,v parameter range is the minmax value for
//! the restriction, unless the flag restriction is
//! set to false.
class BRepAdaptor_Surface : public Adaptor3d_Surface
{
DEFINE_STANDARD_RTTIEXT(BRepAdaptor_Surface, Adaptor3d_Surface)
public:
//! Creates an undefined surface with no face loaded.
Standard_EXPORT BRepAdaptor_Surface();
//! Creates a surface to access the geometry of <F>.
//! If <Restriction> is true the parameter range is
//! the parameter range in the UV space of the
//! restriction.
Standard_EXPORT BRepAdaptor_Surface(const TopoDS_Face& F,
const Standard_Boolean R = Standard_True);
//! Shallow copy of adaptor
Standard_EXPORT virtual Handle(Adaptor3d_Surface) ShallowCopy() const Standard_OVERRIDE;
//! Sets the surface to the geometry of <F>.
Standard_EXPORT void Initialize(const TopoDS_Face& F,
const Standard_Boolean Restriction = Standard_True);
//! Returns the surface.
Standard_EXPORT const GeomAdaptor_Surface& Surface() const;
//! Returns the surface.
Standard_EXPORT GeomAdaptor_Surface& ChangeSurface();
//! Returns the surface coordinate system.
Standard_EXPORT const gp_Trsf& Trsf() const;
//! Returns the face.
Standard_EXPORT const TopoDS_Face& Face() const;
//! Returns the face tolerance.
Standard_EXPORT Standard_Real Tolerance() const;
virtual Standard_Real FirstUParameter() const Standard_OVERRIDE
{
return mySurf.FirstUParameter();
}
virtual Standard_Real LastUParameter() const Standard_OVERRIDE { return mySurf.LastUParameter(); }
virtual Standard_Real FirstVParameter() const Standard_OVERRIDE
{
return mySurf.FirstVParameter();
}
virtual Standard_Real LastVParameter() const Standard_OVERRIDE { return mySurf.LastVParameter(); }
virtual GeomAbs_Shape UContinuity() const Standard_OVERRIDE { return mySurf.UContinuity(); }
virtual GeomAbs_Shape VContinuity() const Standard_OVERRIDE { return mySurf.VContinuity(); }
//! If necessary, breaks the surface in U intervals of
//! continuity <S>. And returns the number of
//! intervals.
virtual Standard_Integer NbUIntervals(const GeomAbs_Shape theSh) const Standard_OVERRIDE
{
return mySurf.NbUIntervals(theSh);
}
//! If necessary, breaks the surface in V intervals of
//! continuity <S>. And returns the number of
//! intervals.
virtual Standard_Integer NbVIntervals(const GeomAbs_Shape theSh) const Standard_OVERRIDE
{
return mySurf.NbVIntervals(theSh);
}
//! Returns the intervals with the requested continuity
//! in the U direction.
Standard_EXPORT void UIntervals(TColStd_Array1OfReal& T,
const GeomAbs_Shape S) const Standard_OVERRIDE;
//! Returns the intervals with the requested continuity
//! in the V direction.
Standard_EXPORT void VIntervals(TColStd_Array1OfReal& T,
const GeomAbs_Shape S) const Standard_OVERRIDE;
//! Returns a surface trimmed in the U direction
//! equivalent of <me> between
//! parameters <First> and <Last>. <Tol> is used to
//! test for 3d points confusion.
//! If <First> >= <Last>
Standard_EXPORT Handle(Adaptor3d_Surface) UTrim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const Standard_OVERRIDE;
//! Returns a surface trimmed in the V direction between
//! parameters <First> and <Last>. <Tol> is used to
//! test for 3d points confusion.
//! If <First> >= <Last>
Standard_EXPORT Handle(Adaptor3d_Surface) VTrim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol) const Standard_OVERRIDE;
virtual Standard_Boolean IsUClosed() const Standard_OVERRIDE { return mySurf.IsUClosed(); }
virtual Standard_Boolean IsVClosed() const Standard_OVERRIDE { return mySurf.IsVClosed(); }
virtual Standard_Boolean IsUPeriodic() const Standard_OVERRIDE { return mySurf.IsUPeriodic(); }
virtual Standard_Real UPeriod() const Standard_OVERRIDE { return mySurf.UPeriod(); }
virtual Standard_Boolean IsVPeriodic() const Standard_OVERRIDE { return mySurf.IsVPeriodic(); }
virtual Standard_Real VPeriod() const Standard_OVERRIDE { return mySurf.VPeriod(); }
//! Computes the point of parameters U,V on the surface.
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
Standard_EXPORT gp_Pnt Value(const Standard_Real U,
const Standard_Real V) const Standard_OVERRIDE;
//! Computes the point of parameters U,V on the surface.
Standard_EXPORT void D0(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P) const Standard_OVERRIDE;
//! Computes the point and the first derivatives on the surface.
//! Raised if the continuity of the current intervals is not C1.
//!
//! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point.
Standard_EXPORT void D1(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V) const Standard_OVERRIDE;
//! Computes the point, the first and second
//! derivatives on the surface.
//! Raised if the continuity of the current
//! intervals is not C2.
Standard_EXPORT void D2(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& D2UV) const Standard_OVERRIDE;
//! Computes the point, the first, second and third
//! derivatives on the surface.
//! Raised if the continuity of the current
//! intervals is not C3.
Standard_EXPORT void D3(const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& D2UV,
gp_Vec& D3U,
gp_Vec& D3V,
gp_Vec& D3UUV,
gp_Vec& D3UVV) const Standard_OVERRIDE;
//! Computes the derivative of order Nu in the direction
//! U and Nv in the direction V at the point P(U, V).
//! Raised if the current U interval is not not CNu
//! and the current V interval is not CNv.
//! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
Standard_EXPORT gp_Vec DN(const Standard_Real U,
const Standard_Real V,
const Standard_Integer Nu,
const Standard_Integer Nv) const Standard_OVERRIDE;
//! Returns the parametric U resolution corresponding
//! to the real space resolution <R3d>.
virtual Standard_Real UResolution(const Standard_Real theR3d) const Standard_OVERRIDE
{
return mySurf.UResolution(theR3d);
}
//! Returns the parametric V resolution corresponding
//! to the real space resolution <R3d>.
virtual Standard_Real VResolution(const Standard_Real theR3d) const Standard_OVERRIDE
{
return mySurf.VResolution(theR3d);
}
//! Returns the type of the surface : Plane, Cylinder,
//! Cone, Sphere, Torus, BezierSurface,
//! BSplineSurface, SurfaceOfRevolution,
//! SurfaceOfExtrusion, OtherSurface
virtual GeomAbs_SurfaceType GetType() const Standard_OVERRIDE { return mySurf.GetType(); }
Standard_EXPORT gp_Pln Plane() const Standard_OVERRIDE;
Standard_EXPORT gp_Cylinder Cylinder() const Standard_OVERRIDE;
Standard_EXPORT gp_Cone Cone() const Standard_OVERRIDE;
Standard_EXPORT gp_Sphere Sphere() const Standard_OVERRIDE;
Standard_EXPORT gp_Torus Torus() const Standard_OVERRIDE;
virtual Standard_Integer UDegree() const Standard_OVERRIDE { return mySurf.UDegree(); }
virtual Standard_Integer NbUPoles() const Standard_OVERRIDE { return mySurf.NbUPoles(); }
virtual Standard_Integer VDegree() const Standard_OVERRIDE { return mySurf.VDegree(); }
virtual Standard_Integer NbVPoles() const Standard_OVERRIDE { return mySurf.NbVPoles(); }
virtual Standard_Integer NbUKnots() const Standard_OVERRIDE { return mySurf.NbUKnots(); }
virtual Standard_Integer NbVKnots() const Standard_OVERRIDE { return mySurf.NbVKnots(); }
virtual Standard_Boolean IsURational() const Standard_OVERRIDE { return mySurf.IsURational(); }
virtual Standard_Boolean IsVRational() const Standard_OVERRIDE { return mySurf.IsVRational(); }
Standard_EXPORT Handle(Geom_BezierSurface) Bezier() const Standard_OVERRIDE;
//! Warning : this will make a copy of the
//! BSpline Surface since it applies
//! to it the myTsrf transformation
//! Be Careful when using this method
Standard_EXPORT Handle(Geom_BSplineSurface) BSpline() const Standard_OVERRIDE;
Standard_EXPORT gp_Ax1 AxeOfRevolution() const Standard_OVERRIDE;
Standard_EXPORT gp_Dir Direction() const Standard_OVERRIDE;
//! only for SurfaceOfExtrusion and SurfaceOfRevolution
//! Warning: this will make a copy of the underlying curve
//! since it applies to it the transformation
//! myTrsf. Be careful when using this method.
Standard_EXPORT Handle(Adaptor3d_Curve) BasisCurve() const Standard_OVERRIDE;
Standard_EXPORT Handle(Adaptor3d_Surface) BasisSurface() const Standard_OVERRIDE;
Standard_EXPORT Standard_Real OffsetValue() const Standard_OVERRIDE;
private:
GeomAdaptor_Surface mySurf;
gp_Trsf myTrsf;
TopoDS_Face myFace;
};
#endif // _BRepAdaptor_Surface_HeaderFile

View File

@@ -0,0 +1,15 @@
# Source files for BRepAdaptor package
set(OCCT_BRepAdaptor_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_BRepAdaptor_FILES
BRepAdaptor_Array1OfCurve.hxx
BRepAdaptor_CompCurve.cxx
BRepAdaptor_CompCurve.hxx
BRepAdaptor_Curve.cxx
BRepAdaptor_Curve.hxx
BRepAdaptor_Curve2d.cxx
BRepAdaptor_Curve2d.hxx
BRepAdaptor_HArray1OfCurve.hxx
BRepAdaptor_Surface.cxx
BRepAdaptor_Surface.hxx
)

View File

@@ -0,0 +1,115 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepLProp.hxx>
#include <BRepLProp_CLProps.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopoDS_Edge.hxx>
//=================================================================================================
GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1,
const BRepAdaptor_Curve& C2,
const Standard_Real u1,
const Standard_Real u2,
const Standard_Real tl,
const Standard_Real ta)
{
GeomAbs_Shape cont = GeomAbs_C0;
Standard_Boolean fini = Standard_False;
gp_Vec d1, d2;
gp_Dir dir1, dir2;
GeomAbs_Shape cont1 = C1.Continuity(), cont2 = C2.Continuity();
Standard_Integer n1 = 0, n2 = 0;
if (cont1 >= 5)
n1 = 3;
else if (cont1 == 4)
n1 = 2;
else if (cont1 == 2)
n1 = 1;
if (cont2 >= 5)
n2 = 3;
else if (cont2 == 4)
n2 = 2;
else if (cont2 == 2)
n2 = 1;
BRepLProp_CLProps clp1(C1, u1, n1, tl);
BRepLProp_CLProps clp2(C2, u2, n2, tl);
if (!(clp1.Value().IsEqual(clp2.Value(), tl)))
{
throw Standard_Failure("Courbes non jointives");
}
Standard_Integer min = Min(n1, n2);
if (min >= 1)
{
d1 = clp1.D1();
d2 = clp2.D1();
if (C1.Edge().Orientation() == TopAbs_REVERSED)
d1.Reverse();
if (C2.Edge().Orientation() == TopAbs_REVERSED)
d2.Reverse();
if (d1.IsEqual(d2, tl, ta))
{
cont = GeomAbs_C1;
}
else if (clp1.IsTangentDefined() && clp2.IsTangentDefined())
{
clp1.Tangent(dir1);
clp2.Tangent(dir2);
if (C1.Edge().Orientation() == TopAbs_REVERSED)
dir1.Reverse();
if (C2.Edge().Orientation() == TopAbs_REVERSED)
dir2.Reverse();
if (dir1.IsEqual(dir2, ta))
{
cont = GeomAbs_G1;
}
fini = Standard_True;
}
else
{
fini = Standard_True;
}
}
if (min >= 2 && !fini)
{
d1 = clp1.D2();
d2 = clp2.D2();
if (d1.IsEqual(d2, tl, ta))
{
cont = GeomAbs_C2;
}
}
const TopoDS_Edge& E1 = C1.Edge();
const TopoDS_Edge& E2 = C2.Edge();
if (E1.IsSame(E2) && C1.IsPeriodic() && cont >= GeomAbs_G1)
cont = GeomAbs_CN;
return cont;
}
//=================================================================================================
GeomAbs_Shape BRepLProp::Continuity(const BRepAdaptor_Curve& C1,
const BRepAdaptor_Curve& C2,
const Standard_Real u1,
const Standard_Real u2)
{
return Continuity(C1, C2, u1, u2, Precision::Confusion(), Precision::Angular());
}

View File

@@ -0,0 +1,54 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepLProp_HeaderFile
#define _BRepLProp_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Real.hxx>
class BRepAdaptor_Curve;
//! These global functions compute the degree of
//! continuity of a curve built by concatenation of two
//! edges at their junction point.
class BRepLProp
{
public:
DEFINE_STANDARD_ALLOC
//! Computes the regularity at the junction between C1 and
//! C2. The point u1 on C1 and the point u2 on C2 must be
//! confused. tl and ta are the linear and angular
//! tolerance used two compare the derivative.
Standard_EXPORT static GeomAbs_Shape Continuity(const BRepAdaptor_Curve& C1,
const BRepAdaptor_Curve& C2,
const Standard_Real u1,
const Standard_Real u2,
const Standard_Real tl,
const Standard_Real ta);
//! The same as preceding but using the standard tolerances from package Precision.
Standard_EXPORT static GeomAbs_Shape Continuity(const BRepAdaptor_Curve& C1,
const BRepAdaptor_Curve& C2,
const Standard_Real u1,
const Standard_Real u2);
};
#endif // _BRepLProp_HeaderFile

View File

@@ -0,0 +1,127 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepLProp_CLProps_HeaderFile
#define _BRepLProp_CLProps_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <LProp_Status.hxx>
class LProp_BadContinuity;
class Standard_DomainError;
class Standard_OutOfRange;
class LProp_NotDefined;
class BRepAdaptor_Curve;
class gp_Vec;
class gp_Pnt;
class gp_Dir;
class BRepLProp_CurveTool;
class BRepLProp_CLProps
{
public:
DEFINE_STANDARD_ALLOC
//! Initializes the local properties of the curve <C>
//! The current point and the derivatives are
//! computed at the same time, which allows an
//! optimization of the computation time.
//! <N> indicates the maximum number of derivations to
//! be done (0, 1, 2 or 3). For example, to compute
//! only the tangent, N should be equal to 1.
//! <Resolution> is the linear tolerance (it is used to test
//! if a vector is null).
Standard_EXPORT BRepLProp_CLProps(const BRepAdaptor_Curve& C,
const Standard_Integer N,
const Standard_Real Resolution);
//! Same as previous constructor but here the parameter is
//! set to the value <U>.
//! All the computations done will be related to <C> and <U>.
Standard_EXPORT BRepLProp_CLProps(const BRepAdaptor_Curve& C,
const Standard_Real U,
const Standard_Integer N,
const Standard_Real Resolution);
//! Same as previous constructor but here the parameter is
//! set to the value <U> and the curve is set
//! with SetCurve.
//! the curve can have a empty constructor
//! All the computations done will be related to <C> and <U>
//! when the functions "set" will be done.
Standard_EXPORT BRepLProp_CLProps(const Standard_Integer N, const Standard_Real Resolution);
//! Initializes the local properties of the curve
//! for the parameter value <U>.
Standard_EXPORT void SetParameter(const Standard_Real U);
//! Initializes the local properties of the curve
//! for the new curve.
Standard_EXPORT void SetCurve(const BRepAdaptor_Curve& C);
//! Returns the Point.
Standard_EXPORT const gp_Pnt& Value() const;
//! Returns the first derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1();
//! Returns the second derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2();
//! Returns the third derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D3();
//! Returns True if the tangent is defined.
//! For example, the tangent is not defined if the
//! three first derivatives are all null.
Standard_EXPORT Standard_Boolean IsTangentDefined();
//! output the tangent direction <D>
Standard_EXPORT void Tangent(gp_Dir& D);
//! Returns the curvature.
Standard_EXPORT Standard_Real Curvature();
//! Returns the normal direction <N>.
Standard_EXPORT void Normal(gp_Dir& N);
//! Returns the centre of curvature <P>.
Standard_EXPORT void CentreOfCurvature(gp_Pnt& P);
protected:
private:
BRepAdaptor_Curve myCurve;
Standard_Real myU;
Standard_Integer myDerOrder;
Standard_Real myCN;
Standard_Real myLinTol;
gp_Pnt myPnt;
gp_Vec myDerivArr[3];
gp_Dir myTangent;
Standard_Real myCurvature;
LProp_Status myTangentStatus;
Standard_Integer mySignificantFirstDerivativeOrder;
};
#endif // _BRepLProp_CLProps_HeaderFile

View File

@@ -0,0 +1,41 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepLProp_CLProps.hxx>
#include <LProp_BadContinuity.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_OutOfRange.hxx>
#include <LProp_NotDefined.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <BRepLProp_CurveTool.hxx>
#define Curve BRepAdaptor_Curve
#define Curve_hxx <BRepAdaptor_Curve.hxx>
#define Vec gp_Vec
#define Vec_hxx <gp_Vec.hxx>
#define Pnt gp_Pnt
#define Pnt_hxx <gp_Pnt.hxx>
#define Dir gp_Dir
#define Dir_hxx <gp_Dir.hxx>
#define Tool BRepLProp_CurveTool
#define Tool_hxx <BRepLProp_CurveTool.hxx>
#define LProp_CLProps BRepLProp_CLProps
#define LProp_CLProps_hxx <BRepLProp_CLProps.hxx>
#include <LProp_CLProps.gxx>

View File

@@ -0,0 +1,99 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepAdaptor_Curve.hxx>
#include <BRepLProp_CurveTool.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
//=================================================================================================
void BRepLProp_CurveTool::Value(const BRepAdaptor_Curve& C, const Standard_Real U, gp_Pnt& P)
{
P = C.Value(U);
}
//=================================================================================================
void BRepLProp_CurveTool::D1(const BRepAdaptor_Curve& C,
const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1)
{
C.D1(U, P, V1);
}
//=================================================================================================
void BRepLProp_CurveTool::D2(const BRepAdaptor_Curve& C,
const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2)
{
C.D2(U, P, V1, V2);
}
//=================================================================================================
void BRepLProp_CurveTool::D3(const BRepAdaptor_Curve& C,
const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3)
{
C.D3(U, P, V1, V2, V3);
}
//=================================================================================================
Standard_Integer BRepLProp_CurveTool::Continuity(const BRepAdaptor_Curve& C)
{
GeomAbs_Shape s = C.Continuity();
switch (s)
{
case GeomAbs_C0:
return 0;
case GeomAbs_C1:
return 1;
case GeomAbs_C2:
return 2;
case GeomAbs_C3:
return 3;
case GeomAbs_G1:
return 0;
case GeomAbs_G2:
return 0;
case GeomAbs_CN:
return 3;
};
return 0;
}
//=================================================================================================
Standard_Real BRepLProp_CurveTool::FirstParameter(const BRepAdaptor_Curve& C)
{
return C.FirstParameter();
}
//=================================================================================================
Standard_Real BRepLProp_CurveTool::LastParameter(const BRepAdaptor_Curve& C)
{
return C.LastParameter();
}

View File

@@ -0,0 +1,78 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepLProp_CurveTool_HeaderFile
#define _BRepLProp_CurveTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
class BRepAdaptor_Curve;
class gp_Pnt;
class gp_Vec;
class BRepLProp_CurveTool
{
public:
DEFINE_STANDARD_ALLOC
//! Computes the point <P> of parameter <U> on the curve <C>.
Standard_EXPORT static void Value(const BRepAdaptor_Curve& C, const Standard_Real U, gp_Pnt& P);
//! Computes the point <P> and first derivative <V1> of
//! parameter <U> on the curve <C>.
Standard_EXPORT static void D1(const BRepAdaptor_Curve& C,
const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1);
//! Computes the point <P>, the first derivative <V1> and second
//! derivative <V2> of parameter <U> on the curve <C>.
Standard_EXPORT static void D2(const BRepAdaptor_Curve& C,
const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2);
//! Computes the point <P>, the first derivative <V1>, the
//! second derivative <V2> and third derivative <V3> of
//! parameter <U> on the curve <C>.
Standard_EXPORT static void D3(const BRepAdaptor_Curve& C,
const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3);
//! returns the order of continuity of the curve <C>.
//! returns 1 : first derivative only is computable
//! returns 2 : first and second derivative only are computable.
//! returns 3 : first, second and third are computable.
Standard_EXPORT static Standard_Integer Continuity(const BRepAdaptor_Curve& C);
//! returns the first parameter bound of the curve.
Standard_EXPORT static Standard_Real FirstParameter(const BRepAdaptor_Curve& C);
//! returns the last parameter bound of the curve.
//! FirstParameter must be less than LastParamenter.
Standard_EXPORT static Standard_Real LastParameter(const BRepAdaptor_Curve& C);
protected:
private:
};
#endif // _BRepLProp_CurveTool_HeaderFile

View File

@@ -0,0 +1,176 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepLProp_SLProps_HeaderFile
#define _BRepLProp_SLProps_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Standard_Integer.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <LProp_Status.hxx>
class LProp_BadContinuity;
class Standard_DomainError;
class Standard_OutOfRange;
class LProp_NotDefined;
class BRepAdaptor_Surface;
class BRepLProp_SurfaceTool;
class gp_Pnt;
class gp_Vec;
class gp_Dir;
class BRepLProp_SLProps
{
public:
DEFINE_STANDARD_ALLOC
//! Initializes the local properties of the surface <S>
//! for the parameter values (<U>, <V>).
//! The current point and the derivatives are
//! computed at the same time, which allows an
//! optimization of the computation time.
//! <N> indicates the maximum number of derivations to
//! be done (0, 1, or 2). For example, to compute
//! only the tangent, N should be equal to 1.
//! <Resolution> is the linear tolerance (it is used to test
//! if a vector is null).
Standard_EXPORT BRepLProp_SLProps(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
const Standard_Integer N,
const Standard_Real Resolution);
//! idem as previous constructor but without setting the value
//! of parameters <U> and <V>.
Standard_EXPORT BRepLProp_SLProps(const BRepAdaptor_Surface& S,
const Standard_Integer N,
const Standard_Real Resolution);
//! idem as previous constructor but without setting the value
//! of parameters <U> and <V> and the surface.
//! the surface can have an empty constructor.
Standard_EXPORT BRepLProp_SLProps(const Standard_Integer N, const Standard_Real Resolution);
//! Initializes the local properties of the surface S
//! for the new surface.
Standard_EXPORT void SetSurface(const BRepAdaptor_Surface& S);
//! Initializes the local properties of the surface S
//! for the new parameter values (<U>, <V>).
Standard_EXPORT void SetParameters(const Standard_Real U, const Standard_Real V);
//! Returns the point.
Standard_EXPORT const gp_Pnt& Value() const;
//! Returns the first U derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1U();
//! Returns the first V derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1V();
//! Returns the second U derivatives
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2U();
//! Returns the second V derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2V();
//! Returns the second UV cross-derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& DUV();
//! returns True if the U tangent is defined.
//! For example, the tangent is not defined if the
//! two first U derivatives are null.
Standard_EXPORT Standard_Boolean IsTangentUDefined();
//! Returns the tangent direction <D> on the iso-V.
Standard_EXPORT void TangentU(gp_Dir& D);
//! returns if the V tangent is defined.
//! For example, the tangent is not defined if the
//! two first V derivatives are null.
Standard_EXPORT Standard_Boolean IsTangentVDefined();
//! Returns the tangent direction <D> on the iso-V.
Standard_EXPORT void TangentV(gp_Dir& D);
//! Tells if the normal is defined.
Standard_EXPORT Standard_Boolean IsNormalDefined();
//! Returns the normal direction.
Standard_EXPORT const gp_Dir& Normal();
//! returns True if the curvature is defined.
Standard_EXPORT Standard_Boolean IsCurvatureDefined();
//! returns True if the point is umbilic (i.e. if the
//! curvature is constant).
Standard_EXPORT Standard_Boolean IsUmbilic();
//! Returns the maximum curvature
Standard_EXPORT Standard_Real MaxCurvature();
//! Returns the minimum curvature
Standard_EXPORT Standard_Real MinCurvature();
//! Returns the direction of the maximum and minimum curvature
//! <MaxD> and <MinD>
Standard_EXPORT void CurvatureDirections(gp_Dir& MaxD, gp_Dir& MinD);
//! Returns the mean curvature.
Standard_EXPORT Standard_Real MeanCurvature();
//! Returns the Gaussian curvature
Standard_EXPORT Standard_Real GaussianCurvature();
protected:
private:
BRepAdaptor_Surface mySurf;
Standard_Real myU;
Standard_Real myV;
Standard_Integer myDerOrder;
Standard_Integer myCN;
Standard_Real myLinTol;
gp_Pnt myPnt;
gp_Vec myD1u;
gp_Vec myD1v;
gp_Vec myD2u;
gp_Vec myD2v;
gp_Vec myDuv;
gp_Dir myNormal;
Standard_Real myMinCurv;
Standard_Real myMaxCurv;
gp_Dir myDirMinCurv;
gp_Dir myDirMaxCurv;
Standard_Real myMeanCurv;
Standard_Real myGausCurv;
Standard_Integer mySignificantFirstDerivativeOrderU;
Standard_Integer mySignificantFirstDerivativeOrderV;
LProp_Status myUTangentStatus;
LProp_Status myVTangentStatus;
LProp_Status myNormalStatus;
LProp_Status myCurvatureStatus;
};
#endif // _BRepLProp_SLProps_HeaderFile

View File

@@ -0,0 +1,35 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepLProp_SLProps.hxx>
#include <LProp_BadContinuity.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_OutOfRange.hxx>
#include <LProp_NotDefined.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepLProp_SurfaceTool.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#define Surface BRepAdaptor_Surface
#define Surface_hxx <BRepAdaptor_Surface.hxx>
#define Tool BRepLProp_SurfaceTool
#define Tool_hxx <BRepLProp_SurfaceTool.hxx>
#define LProp_SLProps BRepLProp_SLProps
#define LProp_SLProps_hxx <BRepLProp_SLProps.hxx>
#include <LProp_SLProps.gxx>

View File

@@ -0,0 +1,107 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepAdaptor_Surface.hxx>
#include <BRepLProp_SurfaceTool.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
//=================================================================================================
void BRepLProp_SurfaceTool::Value(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P)
{
P = S.Value(U, V);
}
//=================================================================================================
void BRepLProp_SurfaceTool::D1(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V)
{
S.D1(U, V, P, D1U, D1V);
}
//=================================================================================================
void BRepLProp_SurfaceTool::D2(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& DUV)
{
S.D2(U, V, P, D1U, D1V, D2U, D2V, DUV);
}
//=================================================================================================
gp_Vec BRepLProp_SurfaceTool::DN(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
const Standard_Integer IU,
const Standard_Integer IV)
{
return S.DN(U, V, IU, IV);
}
//=================================================================================================
Standard_Integer BRepLProp_SurfaceTool::Continuity(const BRepAdaptor_Surface& S)
{
GeomAbs_Shape s = (GeomAbs_Shape)Min(S.UContinuity(), S.VContinuity());
switch (s)
{
case GeomAbs_C0:
return 0;
case GeomAbs_C1:
return 1;
case GeomAbs_C2:
return 2;
case GeomAbs_C3:
return 3;
case GeomAbs_G1:
return 0;
case GeomAbs_G2:
return 0;
case GeomAbs_CN:
return 3;
};
return 0;
}
//=================================================================================================
void BRepLProp_SurfaceTool::Bounds(const BRepAdaptor_Surface& S,
Standard_Real& U1,
Standard_Real& V1,
Standard_Real& U2,
Standard_Real& V2)
{
U1 = S.FirstUParameter();
V1 = S.FirstVParameter();
U2 = S.LastUParameter();
V2 = S.LastVParameter();
}

View File

@@ -0,0 +1,83 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepLProp_SurfaceTool_HeaderFile
#define _BRepLProp_SurfaceTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
class BRepAdaptor_Surface;
class gp_Pnt;
class gp_Vec;
class BRepLProp_SurfaceTool
{
public:
DEFINE_STANDARD_ALLOC
//! Computes the point <P> of parameter <U> and <V> on the
//! Surface <S>.
Standard_EXPORT static void Value(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P);
//! Computes the point <P> and first derivative <D1*> of
//! parameter <U> and <V> on the Surface <S>.
Standard_EXPORT static void D1(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V);
//! Computes the point <P>, the first derivative <D1*> and second
//! derivative <D2*> of parameter <U> and <V> on the Surface <S>.
Standard_EXPORT static void D2(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& DUV);
Standard_EXPORT static gp_Vec DN(const BRepAdaptor_Surface& S,
const Standard_Real U,
const Standard_Real V,
const Standard_Integer IU,
const Standard_Integer IV);
//! returns the order of continuity of the Surface <S>.
//! returns 1 : first derivative only is computable
//! returns 2 : first and second derivative only are computable.
Standard_EXPORT static Standard_Integer Continuity(const BRepAdaptor_Surface& S);
//! returns the bounds of the Surface.
Standard_EXPORT static void Bounds(const BRepAdaptor_Surface& S,
Standard_Real& U1,
Standard_Real& V1,
Standard_Real& U2,
Standard_Real& V2);
protected:
private:
};
#endif // _BRepLProp_SurfaceTool_HeaderFile

View File

@@ -0,0 +1,15 @@
# Source files for BRepLProp package
set(OCCT_BRepLProp_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_BRepLProp_FILES
BRepLProp.cxx
BRepLProp.hxx
BRepLProp_CLProps.hxx
BRepLProp_CLProps_0.cxx
BRepLProp_CurveTool.cxx
BRepLProp_CurveTool.hxx
BRepLProp_SLProps.hxx
BRepLProp_SLProps_0.cxx
BRepLProp_SurfaceTool.cxx
BRepLProp_SurfaceTool.hxx
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,403 @@
// Created on: 1992-08-28
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepTools_HeaderFile
#define _BRepTools_HeaderFile
#include <TopTools_FormatVersion.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
#include <Message_ProgressRange.hxx>
#include <TopTools_ListOfShape.hxx>
class TopoDS_Face;
class TopoDS_Wire;
class TopoDS_Edge;
class Bnd_Box2d;
class TopoDS_Vertex;
class TopoDS_Shell;
class TopoDS_Solid;
class TopoDS_CompSolid;
class TopoDS_Compound;
class TopoDS_Shape;
class BRep_Builder;
class Geom_Curve;
class Geom2d_Curve;
class Geom_Surface;
class OSD_FileSystem;
//! The BRepTools package provides utilities for BRep
//! data structures.
//!
//! * WireExplorer : A tool to explore the topology of
//! a wire in the order of the edges.
//!
//! * ShapeSet : Tools used for dumping, writing and
//! reading.
//!
//! * UVBounds : Methods to compute the limits of the
//! boundary of a face, a wire or an edge in the
//! parametric space of a face.
//!
//! * Update : Methods to call when a topology has
//! been created to compute all missing data.
//!
//! * UpdateFaceUVPoints: Method to update the UV points
//! stored with the edges on a face.
//!
//! * Compare : Method to compare two vertices.
//!
//! * Compare : Method to compare two edges.
//!
//! * OuterWire : A method to find the outer wire of a
//! face.
//!
//! * Map3DEdges : A method to map all the 3D Edges of
//! a Shape.
//!
//! * Dump : A method to dump a BRep object.
class BRepTools
{
public:
DEFINE_STANDARD_ALLOC
//! Returns in UMin, UMax, VMin, VMax the bounding
//! values in the parametric space of F.
Standard_EXPORT static void UVBounds(const TopoDS_Face& F,
Standard_Real& UMin,
Standard_Real& UMax,
Standard_Real& VMin,
Standard_Real& VMax);
//! Returns in UMin, UMax, VMin, VMax the bounding
//! values of the wire in the parametric space of F.
Standard_EXPORT static void UVBounds(const TopoDS_Face& F,
const TopoDS_Wire& W,
Standard_Real& UMin,
Standard_Real& UMax,
Standard_Real& VMin,
Standard_Real& VMax);
//! Returns in UMin, UMax, VMin, VMax the bounding
//! values of the edge in the parametric space of F.
Standard_EXPORT static void UVBounds(const TopoDS_Face& F,
const TopoDS_Edge& E,
Standard_Real& UMin,
Standard_Real& UMax,
Standard_Real& VMin,
Standard_Real& VMax);
//! Adds to the box <B> the bounding values in the
//! parametric space of F.
Standard_EXPORT static void AddUVBounds(const TopoDS_Face& F, Bnd_Box2d& B);
//! Adds to the box <B> the bounding values of the
//! wire in the parametric space of F.
Standard_EXPORT static void AddUVBounds(const TopoDS_Face& F, const TopoDS_Wire& W, Bnd_Box2d& B);
//! Adds to the box <B> the bounding values of the
//! edge in the parametric space of F.
Standard_EXPORT static void AddUVBounds(const TopoDS_Face& F, const TopoDS_Edge& E, Bnd_Box2d& B);
//! Update a vertex (nothing is done)
Standard_EXPORT static void Update(const TopoDS_Vertex& V);
//! Update an edge, compute 2d bounding boxes.
Standard_EXPORT static void Update(const TopoDS_Edge& E);
//! Update a wire (nothing is done)
Standard_EXPORT static void Update(const TopoDS_Wire& W);
//! Update a Face, update UV points.
Standard_EXPORT static void Update(const TopoDS_Face& F);
//! Update a shell (nothing is done)
Standard_EXPORT static void Update(const TopoDS_Shell& S);
//! Update a solid (nothing is done)
Standard_EXPORT static void Update(const TopoDS_Solid& S);
//! Update a composite solid (nothing is done)
Standard_EXPORT static void Update(const TopoDS_CompSolid& C);
//! Update a compound (nothing is done)
Standard_EXPORT static void Update(const TopoDS_Compound& C);
//! Update a shape, call the correct update.
Standard_EXPORT static void Update(const TopoDS_Shape& S);
//! For each edge of the face <F> reset the UV points
//! to the bounding points of the parametric curve of the
//! edge on the face.
Standard_EXPORT static void UpdateFaceUVPoints(const TopoDS_Face& theF);
//! Removes all cached polygonal representation of the shape,
//! i.e. the triangulations of the faces of <S> and polygons on
//! triangulations and polygons 3d of the edges.
//! In case polygonal representation is the only available representation
//! for the shape (shape does not have geometry) it is not removed.
//! @param[in] theShape the shape to clean
//! @param[in] theForce allows removing all polygonal representations from the shape,
//! including polygons on triangulations irrelevant for the faces of the
//! given shape.
Standard_EXPORT static void Clean(const TopoDS_Shape& theShape,
const Standard_Boolean theForce = Standard_False);
//! Removes geometry (curves and surfaces) from all edges and faces of the shape
Standard_EXPORT static void CleanGeometry(const TopoDS_Shape& theShape);
//! Removes all the pcurves of the edges of <S> that
//! refer to surfaces not belonging to any face of <S>
Standard_EXPORT static void RemoveUnusedPCurves(const TopoDS_Shape& S);
public:
//! Verifies that each Face from the shape has got a triangulation with a deflection smaller or
//! equal to specified one and the Edges a discretization on this triangulation.
//! @param[in] theShape shape to verify
//! @param[in] theLinDefl maximum allowed linear deflection
//! @param[in] theToCheckFreeEdges if TRUE, then free Edges are required to have 3D polygon
//! @return FALSE if input Shape contains Faces without triangulation,
//! or that triangulation has worse (greater) deflection than specified one,
//! or Edges in Shape lack polygons on triangulation
//! or free Edges in Shape lack 3D polygons
Standard_EXPORT static Standard_Boolean Triangulation(
const TopoDS_Shape& theShape,
const Standard_Real theLinDefl,
const Standard_Boolean theToCheckFreeEdges = Standard_False);
//! Loads triangulation data for each face of the shape
//! from some deferred storage using specified shared input file system
//! @param[in] theShape shape to load triangulations
//! @param[in] theTriangulationIdx index defining what triangulation should be loaded. Starts
//! from 0.
//! -1 is used in specific case to load currently already active triangulation.
//! If some face doesn't contain triangulation with this index, nothing will be loaded for
//! it. Exception will be thrown in case of invalid negative index
//! @param[in] theToSetAsActive flag to activate triangulation after its loading
//! @param[in] theFileSystem shared file system
//! @return TRUE if at least one triangulation is loaded.
Standard_EXPORT static Standard_Boolean LoadTriangulation(
const TopoDS_Shape& theShape,
const Standard_Integer theTriangulationIdx = -1,
const Standard_Boolean theToSetAsActive = Standard_False,
const Handle(OSD_FileSystem)& theFileSystem = Handle(OSD_FileSystem)());
//! Releases triangulation data for each face of the shape if there is deferred storage to load it
//! later
//! @param[in] theShape shape to unload triangulations
//! @param[in] theTriangulationIdx index defining what triangulation should be unloaded. Starts
//! from 0.
//! -1 is used in specific case to unload currently already active triangulation.
//! If some face doesn't contain triangulation with this index, nothing will be unloaded
//! for it. Exception will be thrown in case of invalid negative index
//! @return TRUE if at least one triangulation is unloaded.
Standard_EXPORT static Standard_Boolean UnloadTriangulation(
const TopoDS_Shape& theShape,
const Standard_Integer theTriangulationIdx = -1);
//! Activates triangulation data for each face of the shape
//! from some deferred storage using specified shared input file system
//! @param[in] theShape shape to activate triangulations
//! @param[in] theTriangulationIdx index defining what triangulation should be activated.
//! Starts from 0.
//! Exception will be thrown in case of invalid negative index
//! @param[in] theToActivateStrictly flag to activate exactly triangulation with defined
//! theTriangulationIdx index.
//! In TRUE case if some face doesn't contain triangulation with this index, active
//! triangulation will not be changed for it. Else the last available triangulation will be
//! activated.
//! @return TRUE if at least one active triangulation was changed.
Standard_EXPORT static Standard_Boolean ActivateTriangulation(
const TopoDS_Shape& theShape,
const Standard_Integer theTriangulationIdx,
const Standard_Boolean theToActivateStrictly = false);
//! Loads all available triangulations for each face of the shape
//! from some deferred storage using specified shared input file system
//! @param[in] theShape shape to load triangulations
//! @param[in] theFileSystem shared file system
//! @return TRUE if at least one triangulation is loaded.
Standard_EXPORT static Standard_Boolean LoadAllTriangulations(
const TopoDS_Shape& theShape,
const Handle(OSD_FileSystem)& theFileSystem = Handle(OSD_FileSystem)());
//! Releases all available triangulations for each face of the shape if there is deferred storage
//! to load them later
//! @param[in] theShape shape to unload triangulations
//! @return TRUE if at least one triangulation is unloaded.
Standard_EXPORT static Standard_Boolean UnloadAllTriangulations(const TopoDS_Shape& theShape);
public:
//! Returns True if the distance between the two
//! vertices is lower than their tolerance.
Standard_EXPORT static Standard_Boolean Compare(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
//! Returns True if the distance between the two
//! edges is lower than their tolerance.
Standard_EXPORT static Standard_Boolean Compare(const TopoDS_Edge& E1, const TopoDS_Edge& E2);
//! Returns the outer most wire of <F>. Returns a Null
//! wire if <F> has no wires.
Standard_EXPORT static TopoDS_Wire OuterWire(const TopoDS_Face& F);
//! Stores in the map <M> all the 3D topology edges
//! of <S>.
Standard_EXPORT static void Map3DEdges(const TopoDS_Shape& S, TopTools_IndexedMapOfShape& M);
//! Verifies that the edge <E> is found two times on
//! the face <F> before calling BRep_Tool::IsClosed.
Standard_EXPORT static Standard_Boolean IsReallyClosed(const TopoDS_Edge& E,
const TopoDS_Face& F);
//! Detect closedness of face in U and V directions
Standard_EXPORT static void DetectClosedness(const TopoDS_Face& theFace,
Standard_Boolean& theUclosed,
Standard_Boolean& theVclosed);
//! Dumps the topological structure and the geometry
//! of <Sh> on the stream <S>.
Standard_EXPORT static void Dump(const TopoDS_Shape& Sh, Standard_OStream& S);
//! Writes the shape to the stream in an ASCII format TopTools_FormatVersion_VERSION_1.
//! This alias writes shape with triangulation data.
//! @param[in] theShape the shape to write
//! @param[in][out] theStream the stream to output shape into
//! @param theRange the range of progress indicator to fill in
static void Write(const TopoDS_Shape& theShape,
Standard_OStream& theStream,
const Message_ProgressRange& theProgress = Message_ProgressRange())
{
Write(theShape,
theStream,
Standard_True,
Standard_False,
TopTools_FormatVersion_CURRENT,
theProgress);
}
//! Writes the shape to the stream in an ASCII format of specified version.
//! @param[in] theShape the shape to write
//! @param[in][out] theStream the stream to output shape into
//! @param[in] theWithTriangles flag which specifies whether to save shape with (TRUE) or without
//! (FALSE) triangles;
//! has no effect on triangulation-only geometry
//! @param[in] theWithNormals flag which specifies whether to save triangulation with (TRUE) or
//! without (FALSE) normals;
//! has no effect on triangulation-only geometry
//! @param[in] theVersion the TopTools format version
//! @param theProgress the range of progress indicator to fill in
Standard_EXPORT static void Write(
const TopoDS_Shape& theShape,
Standard_OStream& theStream,
const Standard_Boolean theWithTriangles,
const Standard_Boolean theWithNormals,
const TopTools_FormatVersion theVersion,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a Shape from <S> in returns it in <Sh>.
//! <B> is used to build the shape.
Standard_EXPORT static void Read(
TopoDS_Shape& Sh,
Standard_IStream& S,
const BRep_Builder& B,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes the shape to the file in an ASCII format TopTools_FormatVersion_VERSION_1.
//! This alias writes shape with triangulation data.
//! @param[in] theShape the shape to write
//! @param[in] theFile the path to file to output shape into
//! @param theProgress the range of progress indicator to fill in
static Standard_Boolean Write(const TopoDS_Shape& theShape,
const Standard_CString theFile,
const Message_ProgressRange& theProgress = Message_ProgressRange())
{
return Write(theShape,
theFile,
Standard_True,
Standard_False,
TopTools_FormatVersion_CURRENT,
theProgress);
}
//! Writes the shape to the file in an ASCII format of specified version.
//! @param[in] theShape the shape to write
//! @param[in] theFile the path to file to output shape into
//! @param[in] theWithTriangles flag which specifies whether to save shape with (TRUE) or without
//! (FALSE) triangles;
//! has no effect on triangulation-only geometry
//! @param[in] theWithNormals flag which specifies whether to save triangulation with (TRUE) or
//! without (FALSE) normals;
//! has no effect on triangulation-only geometry
//! @param[in] theVersion the TopTools format version
//! @param theProgress the range of progress indicator to fill in
Standard_EXPORT static Standard_Boolean Write(
const TopoDS_Shape& theShape,
const Standard_CString theFile,
const Standard_Boolean theWithTriangles,
const Standard_Boolean theWithNormals,
const TopTools_FormatVersion theVersion,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a Shape from <File>, returns it in <Sh>.
//! <B> is used to build the shape.
Standard_EXPORT static Standard_Boolean Read(
TopoDS_Shape& Sh,
const Standard_CString File,
const BRep_Builder& B,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Evals real tolerance of edge <theE>.
//! <theC3d>, <theC2d>, <theS>, <theF>, <theL> are
//! correspondently 3d curve of edge, 2d curve on surface <theS> and
//! rang of edge
//! If calculated tolerance is more then current edge tolerance, edge is updated.
//! Method returns actual tolerance of edge
Standard_EXPORT static Standard_Real EvalAndUpdateTol(const TopoDS_Edge& theE,
const Handle(Geom_Curve)& theC3d,
const Handle(Geom2d_Curve)& theC2d,
const Handle(Geom_Surface)& theS,
const Standard_Real theF,
const Standard_Real theL);
//! returns the cumul of the orientation of <Edge>
//! and thc containing wire in <Face>
Standard_EXPORT static TopAbs_Orientation OriEdgeInFace(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace);
//! Removes internal sub-shapes from the shape.
//! The check on internal status is based on orientation of sub-shapes,
//! classification is not performed.
//! Before removal of internal sub-shapes the algorithm checks if such
//! removal is not going to break topological connectivity between sub-shapes.
//! The flag <theForce> if set to true disables the connectivity check and clears
//! the given shape from all sub-shapes with internal orientation.
Standard_EXPORT static void RemoveInternals(TopoDS_Shape& theS,
const Standard_Boolean theForce = Standard_False);
//! Check all locations of shape according criterium:
//! aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec())
//! All sub-shapes having such locations are put in list theProblemShapes
Standard_EXPORT static void CheckLocations(const TopoDS_Shape& theS,
TopTools_ListOfShape& theProblemShapes);
};
#endif // _BRepTools_HeaderFile

View File

@@ -0,0 +1,192 @@
// Copyright (c) 1999-2022 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 <BRepTools_CopyModification.hxx>
#include <BRep_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Vertex.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
//=================================================================================================
BRepTools_CopyModification::BRepTools_CopyModification(const Standard_Boolean copyGeom,
const Standard_Boolean copyMesh)
: myCopyGeom(copyGeom),
myCopyMesh(copyMesh)
{
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewSurface(const TopoDS_Face& theFace,
Handle(Geom_Surface)& theSurf,
TopLoc_Location& theLoc,
Standard_Real& theTol,
Standard_Boolean& theRevWires,
Standard_Boolean& theRevFace)
{
theSurf = BRep_Tool::Surface(theFace, theLoc);
theTol = BRep_Tool::Tolerance(theFace);
theRevWires = theRevFace = Standard_False;
if (!theSurf.IsNull() && myCopyGeom)
theSurf = Handle(Geom_Surface)::DownCast(theSurf->Copy());
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri)
{
if (!myCopyMesh && BRep_Tool::IsGeometric(theFace))
{
return Standard_False;
}
TopLoc_Location aLoc;
theTri = BRep_Tool::Triangulation(theFace, aLoc);
if (theTri.IsNull())
return Standard_False;
// mesh is copied if and only if the geometry need to be copied too
if (myCopyGeom)
theTri = theTri->Copy();
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewCurve(const TopoDS_Edge& theEdge,
Handle(Geom_Curve)& theCurve,
TopLoc_Location& theLoc,
Standard_Real& theTol)
{
Standard_Real aFirst, aLast;
theCurve = BRep_Tool::Curve(theEdge, theLoc, aFirst, aLast);
theTol = BRep_Tool::Tolerance(theEdge);
if (!theCurve.IsNull() && myCopyGeom)
theCurve = Handle(Geom_Curve)::DownCast(theCurve->Copy());
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly)
{
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
{
return Standard_False;
}
TopLoc_Location aLoc;
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
if (thePoly.IsNull())
return Standard_False;
// polygon is copied if and only if the geometry need to be copied too
if (myCopyGeom)
thePoly = thePoly->Copy();
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewPolygonOnTriangulation(
const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly)
{
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
{
return Standard_False;
}
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(theFace, aLoc);
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aTria, aLoc);
if (thePoly.IsNull())
return Standard_False;
// polygon is copied if and only if the geometry need to be copied too
if (myCopyGeom)
thePoly = thePoly->Copy();
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewPoint(const TopoDS_Vertex& theVertex,
gp_Pnt& thePnt,
Standard_Real& theTol)
{
thePnt = BRep_Tool::Pnt(theVertex);
theTol = BRep_Tool::Tolerance(theVertex);
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewCurve2d(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
const TopoDS_Edge&,
const TopoDS_Face&,
Handle(Geom2d_Curve)& theCurve,
Standard_Real& theTol)
{
theTol = BRep_Tool::Tolerance(theEdge);
Standard_Real aFirst, aLast;
theCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
if (!theCurve.IsNull() && myCopyGeom)
theCurve = Handle(Geom2d_Curve)::DownCast(theCurve->Copy());
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_CopyModification::NewParameter(const TopoDS_Vertex& theVertex,
const TopoDS_Edge& theEdge,
Standard_Real& thePnt,
Standard_Real& theTol)
{
if (theVertex.IsNull())
return Standard_False; // infinite edge may have Null vertex
theTol = BRep_Tool::Tolerance(theVertex);
thePnt = BRep_Tool::Parameter(theVertex, theEdge);
return Standard_True;
}
//=================================================================================================
GeomAbs_Shape BRepTools_CopyModification::Continuity(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const TopoDS_Edge&,
const TopoDS_Face&,
const TopoDS_Face&)
{
return BRep_Tool::Continuity(theEdge, theFace1, theFace2);
}

View File

@@ -0,0 +1,131 @@
// Copyright (c) 1999-2022 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 _BRepTools_CopyModification_HeaderFile
#define _BRepTools_CopyModification_HeaderFile
#include <BRepTools_Modification.hxx>
class BRepTools_CopyModification;
DEFINE_STANDARD_HANDLE(BRepTools_CopyModification, BRepTools_Modification)
//! Tool class implementing necessary functionality for copying geometry and triangulation.
class BRepTools_CopyModification : public BRepTools_Modification
{
public:
//! Constructor.
//! \param[in] theCopyGeom indicates that the geometry (surfaces and curves) should be copied
//! \param[in] theCopyMesh indicates that the triangulation should be copied
Standard_EXPORT explicit BRepTools_CopyModification(
const Standard_Boolean theCopyGeom = Standard_True,
const Standard_Boolean theCopyMesh = Standard_True);
//! Returns true if theFace has been modified.
//! If the face has been modified:
//! - theSurf is the new geometry of the face,
//! - theLoc is its new location, and
//! - theTol is the new tolerance.
//! theRevWires, theRevFace are always set to false, because the orientation is not changed.
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& theFace,
Handle(Geom_Surface)& theSurf,
TopLoc_Location& theLoc,
Standard_Real& theTol,
Standard_Boolean& theRevWires,
Standard_Boolean& theRevFace) Standard_OVERRIDE;
//! Returns true if theEdge has been modified.
//! If the edge has been modified:
//! - theCurve is the new geometric support of the edge,
//! - theLoc is the new location, and
//! - theTol is the new tolerance.
//! If the edge has not been modified, this function
//! returns false, and the values of theCurve, theLoc and theTol are not significant.
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& theEdge,
Handle(Geom_Curve)& theCurve,
TopLoc_Location& theLoc,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns true if theVertex has been modified.
//! If the vertex has been modified:
//! - thePnt is the new geometry of the vertex, and
//! - theTol is the new tolerance.
//! If the vertex has not been modified this function
//! returns false, and the values of thePnt and theTol are not significant.
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& theVertex,
gp_Pnt& thePnt,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns true if theEdge has a new curve on surface on theFace.
//! If a new curve exists:
//! - theCurve is the new geometric support of the edge,
//! - theTol the new tolerance.
//! If no new curve exists, this function returns false, and
//! the values of theCurve and theTol are not significant.
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
const TopoDS_Edge& theNewEdge,
const TopoDS_Face& theNewFace,
Handle(Geom2d_Curve)& theCurve,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns true if theVertex has a new parameter on theEdge.
//! If a new parameter exists:
//! - thePnt is the parameter, and
//! - theTol is the new tolerance.
//! If no new parameter exists, this function returns false,
//! and the values of thePnt and theTol are not significant.
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& theVertex,
const TopoDS_Edge& theEdge,
Standard_Real& thePnt,
Standard_Real& theTol) Standard_OVERRIDE;
//! Returns the continuity of theNewEdge between theNewFace1 and theNewFace2.
//!
//! theNewEdge is the new edge created from theEdge. theNewFace1
//! (resp. theNewFace2) is the new face created from theFace1 (resp. theFace2).
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const TopoDS_Edge& theNewEdge,
const TopoDS_Face& theNewFace1,
const TopoDS_Face& theNewFace2) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - theTri is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri)
Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - thePoly is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - thePoly is a new polygon on triangulation
Standard_EXPORT Standard_Boolean
NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
private:
Standard_Boolean myCopyGeom;
Standard_Boolean myCopyMesh;
};
#endif // _BRepTools_CopyModification_HeaderFile

View File

@@ -0,0 +1,19 @@
// Copyright (c) 2015 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 BRepTools_DataMapIteratorOfMapOfVertexPnt2d_HeaderFile
#define BRepTools_DataMapIteratorOfMapOfVertexPnt2d_HeaderFile
#include <BRepTools_MapOfVertexPnt2d.hxx>
#endif

View File

@@ -0,0 +1,115 @@
// Created on: 1994-07-25
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepTools.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <TopTools_LocationSet.hxx>
// This file defines global functions not declared in any public header,
// intended for use from debugger prompt (Command Window in Visual Studio)
//! Save shape to file
const char* BRepTools_Write(const char* theFileStr, void* theShapePtr)
{
if (theFileStr == 0 || theShapePtr == 0)
{
return "Error: name or shape is null";
}
try
{
OCC_CATCH_SIGNALS
if (BRepTools::Write(*(TopoDS_Shape*)theShapePtr, theFileStr))
return theFileStr;
else
return "Error: write failed";
}
catch (Standard_Failure const& anException)
{
return anException.GetMessageString();
}
}
//! Dump shape to cout
const char* BRepTools_Dump(void* theShapePtr)
{
if (theShapePtr == 0)
{
return "Error: name or shape is null";
}
try
{
OCC_CATCH_SIGNALS
std::cout << "\n\n";
BRepTools::Dump(*(TopoDS_Shape*)theShapePtr, std::cout);
std::cout << std::endl;
return "Shape dumped to std::cout";
}
catch (Standard_Failure const& anException)
{
return anException.GetMessageString();
}
}
//! Dump shape location to cout
const char* BRepTools_DumpLoc(void* theLocationPtr)
{
if (theLocationPtr == 0)
{
return "Error: name or shape is null";
}
try
{
OCC_CATCH_SIGNALS
std::cout << "\n\n";
TopTools_LocationSet LS;
LS.Add(*(TopLoc_Location*)theLocationPtr);
LS.Dump(std::cout);
std::cout << std::endl;
return "Location dumped to std::cout";
}
catch (Standard_Failure const& anException)
{
return anException.GetMessageString();
}
}
// MSVC debugger cannot deal correctly with functions whose argunments
// have non-standard types. Here we define alternative to the above functions
// with good types with the hope that GDB on Linux or other debugger could
// work with them (DBX could, on SUN Solaris).
#ifndef _MSC_VER
const char* BRepTools_Write(const char* theFileNameStr, const TopoDS_Shape& theShape)
{
return BRepTools_Write(theFileNameStr, (void*)&theShape);
}
const char* BRepTools_Dump(const TopoDS_Shape& theShape)
{
return BRepTools_Dump((void*)&theShape);
}
const char* BRepTools_DumpLoc(const TopoDS_Shape& theShape)
{
return BRepTools_DumpLoc((void*)&theShape);
}
#endif

View File

@@ -0,0 +1,349 @@
// Created on: 1996-12-30
// Created by: Stagiaire Mary FABIEN
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_Tool.hxx>
#include <BRepTools_GTrsfModification.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomLib.hxx>
#include <gp_GTrsf.hxx>
#include <gp_Pnt.hxx>
#include <gp_Quaternion.hxx>
#include <gp_XYZ.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_Type.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_GTrsfModification, BRepTools_Modification)
//=================================================================================================
BRepTools_GTrsfModification::BRepTools_GTrsfModification(const gp_GTrsf& T)
: myGTrsf(T)
{
// on prend comme dilatation maximale pour la tolerance la norme sup
Standard_Real loc1, loc2, loc3, loc4;
loc1 = Max(Abs(T.Value(1, 1)), Abs(T.Value(1, 2)));
loc2 = Max(Abs(T.Value(2, 1)), Abs(T.Value(2, 2)));
loc3 = Max(Abs(T.Value(3, 1)), Abs(T.Value(3, 2)));
loc4 = Max(Abs(T.Value(1, 3)), Abs(T.Value(2, 3)));
loc1 = Max(loc1, loc2);
loc2 = Max(loc3, loc4);
loc1 = Max(loc1, loc2);
myGScale = Max(loc1, Abs(T.Value(3, 3)));
}
//=================================================================================================
gp_GTrsf& BRepTools_GTrsfModification::GTrsf()
{
return myGTrsf;
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewSurface(const TopoDS_Face& F,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& Tol,
Standard_Boolean& RevWires,
Standard_Boolean& RevFace)
{
gp_GTrsf gtrsf;
gtrsf.SetVectorialPart(myGTrsf.VectorialPart());
gtrsf.SetTranslationPart(myGTrsf.TranslationPart());
S = BRep_Tool::Surface(F, L);
if (S.IsNull())
{
// processing the case when there is no geometry
return Standard_False;
}
S = Handle(Geom_Surface)::DownCast(S->Copy());
Tol = BRep_Tool::Tolerance(F);
Tol *= myGScale;
RevWires = Standard_False;
RevFace = myGTrsf.IsNegative();
S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
Handle(Standard_Type) TheTypeS = S->DynamicType();
if (TheTypeS == STANDARD_TYPE(Geom_BSplineSurface))
{
Handle(Geom_BSplineSurface) S2 = Handle(Geom_BSplineSurface)::DownCast(S);
for (Standard_Integer i = 1; i <= S2->NbUPoles(); i++)
for (Standard_Integer j = 1; j <= S2->NbVPoles(); j++)
{
gp_XYZ coor(S2->Pole(i, j).Coord());
gtrsf.Transforms(coor);
gp_Pnt P(coor);
S2->SetPole(i, j, P);
}
}
else if (TheTypeS == STANDARD_TYPE(Geom_BezierSurface))
{
Handle(Geom_BezierSurface) S2 = Handle(Geom_BezierSurface)::DownCast(S);
for (Standard_Integer i = 1; i <= S2->NbUPoles(); i++)
for (Standard_Integer j = 1; j <= S2->NbVPoles(); j++)
{
gp_XYZ coor(S2->Pole(i, j).Coord());
gtrsf.Transforms(coor);
gp_Pnt P(coor);
S2->SetPole(i, j, P);
}
}
else
{
throw Standard_NoSuchObject("BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Surface");
}
L.Identity();
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewCurve(const TopoDS_Edge& E,
Handle(Geom_Curve)& C,
TopLoc_Location& L,
Standard_Real& Tol)
{
Standard_Real f, l;
gp_GTrsf gtrsf;
gtrsf.SetVectorialPart(myGTrsf.VectorialPart());
gtrsf.SetTranslationPart(myGTrsf.TranslationPart());
Tol = BRep_Tool::Tolerance(E) * myGScale;
C = BRep_Tool::Curve(E, L, f, l);
if (!C.IsNull())
{
C = Handle(Geom_Curve)::DownCast(C->Copy()->Transformed(L.Transformation()));
Handle(Standard_Type) TheTypeC = C->DynamicType();
if (TheTypeC == STANDARD_TYPE(Geom_BSplineCurve))
{
Handle(Geom_BSplineCurve) C2 = Handle(Geom_BSplineCurve)::DownCast(C);
for (Standard_Integer i = 1; i <= C2->NbPoles(); i++)
{
gp_XYZ coor(C2->Pole(i).Coord());
gtrsf.Transforms(coor);
gp_Pnt P(coor);
C2->SetPole(i, P);
}
}
else if (TheTypeC == STANDARD_TYPE(Geom_BezierCurve))
{
Handle(Geom_BezierCurve) C2 = Handle(Geom_BezierCurve)::DownCast(C);
for (Standard_Integer i = 1; i <= C2->NbPoles(); i++)
{
gp_XYZ coor(C2->Pole(i).Coord());
gtrsf.Transforms(coor);
gp_Pnt P(coor);
C2->SetPole(i, P);
}
}
else
{
throw Standard_NoSuchObject("BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Curve");
}
C = new Geom_TrimmedCurve(C, f, l);
}
L.Identity();
return !C.IsNull();
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewPoint(const TopoDS_Vertex& V,
gp_Pnt& P,
Standard_Real& Tol)
{
gp_Pnt Pnt = BRep_Tool::Pnt(V);
Tol = BRep_Tool::Tolerance(V);
Tol *= myGScale;
gp_XYZ coor(Pnt.Coord());
myGTrsf.Transforms(coor);
P.SetXYZ(coor);
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewCurve2d(const TopoDS_Edge& E,
const TopoDS_Face& F,
const TopoDS_Edge&,
const TopoDS_Face&,
Handle(Geom2d_Curve)& C,
Standard_Real& Tol)
{
TopLoc_Location loc;
Tol = BRep_Tool::Tolerance(E);
Tol *= myGScale;
Standard_Real f, l;
C = BRep_Tool::CurveOnSurface(E, F, f, l);
if (C.IsNull())
{
// processing the case when there is no geometry
return Standard_False;
}
C = new Geom2d_TrimmedCurve(C, f, l);
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewParameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
Standard_Real& P,
Standard_Real& Tol)
{
Tol = BRep_Tool::Tolerance(V);
Tol *= myGScale;
P = BRep_Tool::Parameter(V, E);
return Standard_True;
}
//=================================================================================================
GeomAbs_Shape BRepTools_GTrsfModification::Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopoDS_Edge&,
const TopoDS_Face&,
const TopoDS_Face&)
{
return BRep_Tool::Continuity(E, F1, F2);
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewTriangulation(
const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTriangulation)
{
TopLoc_Location aLoc;
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
if (theTriangulation.IsNull())
{
return Standard_False;
}
gp_GTrsf aGTrsf;
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
aGTrsf.Multiply(aLoc.Transformation());
theTriangulation = theTriangulation->Copy();
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myGScale));
// apply transformation to 3D nodes
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
{
gp_Pnt aP = theTriangulation->Node(anInd);
aGTrsf.Transforms(aP.ChangeCoord());
theTriangulation->SetNode(anInd, aP);
}
// modify triangles orientation in case of mirror transformation
if (myGScale < 0.0)
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
{
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
Standard_Integer aN1, aN2, aN3;
aTria.Get(aN1, aN2, aN3);
aTria.Set(aN1, aN3, aN2);
theTriangulation->SetTriangle(anInd, aTria);
}
}
// modify normals
if (theTriangulation->HasNormals())
{
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
{
gp_Dir aNormal = theTriangulation->Normal(anInd);
gp_Mat aMat = aGTrsf.VectorialPart();
aMat.SetDiagonal(1., 1., 1.);
gp_Trsf aTrsf;
aTrsf.SetForm(gp_Rotation);
(gp_Mat&)aTrsf.HVectorialPart() = aMat;
aNormal.Transform(aTrsf);
theTriangulation->SetNormal(anInd, aNormal);
}
}
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly)
{
TopLoc_Location aLoc;
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
if (thePoly.IsNull())
{
return Standard_False;
}
gp_GTrsf aGTrsf;
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
aGTrsf.Multiply(aLoc.Transformation());
thePoly = thePoly->Copy();
thePoly->Deflection(thePoly->Deflection() * Abs(myGScale));
// transform nodes
TColgp_Array1OfPnt& aNodesArray = thePoly->ChangeNodes();
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
{
gp_Pnt& aP = aNodesArray.ChangeValue(anId);
aGTrsf.Transforms(aP.ChangeCoord());
}
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_GTrsfModification::NewPolygonOnTriangulation(
const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly)
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theFace, aLoc);
if (aT.IsNull())
{
return Standard_False;
}
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aT, aLoc);
if (!thePoly.IsNull())
thePoly = thePoly->Copy();
return Standard_True;
}

View File

@@ -0,0 +1,153 @@
// Created on: 1996-12-30
// Created by: Stagiaire Mary FABIEN
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepTools_GTrsfModification_HeaderFile
#define _BRepTools_GTrsfModification_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <gp_GTrsf.hxx>
#include <BRepTools_Modification.hxx>
#include <GeomAbs_Shape.hxx>
class TopoDS_Face;
class Geom_Surface;
class TopLoc_Location;
class TopoDS_Edge;
class Geom_Curve;
class TopoDS_Vertex;
class gp_Pnt;
class Geom2d_Curve;
class BRepTools_GTrsfModification;
DEFINE_STANDARD_HANDLE(BRepTools_GTrsfModification, BRepTools_Modification)
//! Defines a modification of the geometry by a GTrsf
//! from gp. All methods return True and transform the
//! geometry.
class BRepTools_GTrsfModification : public BRepTools_Modification
{
public:
Standard_EXPORT BRepTools_GTrsfModification(const gp_GTrsf& T);
//! Gives an access on the GTrsf.
Standard_EXPORT gp_GTrsf& GTrsf();
//! Returns Standard_True if the face <F> has been
//! modified. In this case, <S> is the new geometric
//! support of the face, <L> the new location,<Tol>
//! the new tolerance.<RevWires> has to be set to
//! Standard_True when the modification reverses the
//! normal of the surface.(the wires have to be
//! reversed). <RevFace> has to be set to
//! Standard_True if the orientation of the modified
//! face changes in the shells which contain it. --
//! Here, <RevFace> will return Standard_True if the
//! -- gp_Trsf is negative.
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& Tol,
Standard_Boolean& RevWires,
Standard_Boolean& RevFace) Standard_OVERRIDE;
//! Returns Standard_True if the edge <E> has been
//! modified. In this case, <C> is the new geometric
//! support of the edge, <L> the new location, <Tol>
//! the new tolerance. Otherwise, returns
//! Standard_False, and <C>, <L>, <Tol> are not
//! significant.
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,
Handle(Geom_Curve)& C,
TopLoc_Location& L,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns Standard_True if the vertex <V> has been
//! modified. In this case, <P> is the new geometric
//! support of the vertex, <Tol> the new tolerance.
//! Otherwise, returns Standard_False, and <P>, <Tol>
//! are not significant.
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,
gp_Pnt& P,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns Standard_True if the edge <E> has a new
//! curve on surface on the face <F>.In this case, <C>
//! is the new geometric support of the edge, <L> the
//! new location, <Tol> the new tolerance.
//! Otherwise, returns Standard_False, and <C>, <L>,
//! <Tol> are not significant.
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,
const TopoDS_Face& F,
const TopoDS_Edge& NewE,
const TopoDS_Face& NewF,
Handle(Geom2d_Curve)& C,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns Standard_True if the Vertex <V> has a new
//! parameter on the edge <E>. In this case, <P> is
//! the parameter, <Tol> the new tolerance.
//! Otherwise, returns Standard_False, and <P>, <Tol>
//! are not significant.
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
Standard_Real& P,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns the continuity of <NewE> between <NewF1>
//! and <NewF2>.
//!
//! <NewE> is the new edge created from <E>. <NewF1>
//! (resp. <NewF2>) is the new face created from <F1>
//! (resp. <F2>).
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopoDS_Edge& NewE,
const TopoDS_Face& NewF1,
const TopoDS_Face& NewF2) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - theTri is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri)
Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - thePoly is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - thePoly is a new polygon on triangulation
Standard_EXPORT Standard_Boolean
NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BRepTools_GTrsfModification, BRepTools_Modification)
protected:
private:
gp_GTrsf myGTrsf;
Standard_Real myGScale;
};
#endif // _BRepTools_GTrsfModification_HeaderFile

View File

@@ -0,0 +1,382 @@
// Created on: 2017-04-21
// Created by: Alexander Bobkov
// Copyright (c) 2017 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 <BRepTools_History.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
// Implement the OCCT RTTI for the type.
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_History, Standard_Transient)
namespace
{
//==============================================================================
// function : add
// purpose : Adds the elements of the list to the map.
//==============================================================================
void add(TopTools_MapOfShape& theMap, const TopTools_ListOfShape& theList)
{
for (TopTools_ListOfShape::Iterator aSIt(theList); aSIt.More(); aSIt.Next())
{
theMap.Add(aSIt.Value());
}
}
//==============================================================================
// function : add
// purpose : Adds the elements of the collection to the list.
//==============================================================================
template <typename TCollection>
void add(TopTools_ListOfShape& theList, const TCollection& theCollection)
{
for (typename TCollection::Iterator aSIt(theCollection); aSIt.More(); aSIt.Next())
{
theList.Append(aSIt.Value());
}
}
} // namespace
//=================================================================================================
void BRepTools_History::AddGenerated(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theGenerated)
{
if (!prepareGenerated(theInitial, theGenerated))
{
return;
}
TopTools_ListOfShape* aGenerations = myShapeToGenerated.ChangeSeek(theInitial);
if (aGenerations == NULL)
{
aGenerations = myShapeToGenerated.Bound(theInitial, TopTools_ListOfShape());
}
Standard_ASSERT_VOID(!aGenerations->Contains(theGenerated),
"Error: a duplicated generation of a shape.");
aGenerations->Append(theGenerated);
}
//=================================================================================================
void BRepTools_History::AddModified(const TopoDS_Shape& theInitial, const TopoDS_Shape& theModified)
{
if (!prepareModified(theInitial, theModified))
{
return;
}
TopTools_ListOfShape* aModifications = myShapeToModified.ChangeSeek(theInitial);
if (aModifications == NULL)
{
aModifications = myShapeToModified.Bound(theInitial, TopTools_ListOfShape());
}
Standard_ASSERT_VOID(!aModifications->Contains(theModified),
"Error: a duplicated modification of a shape.");
aModifications->Append(theModified);
}
//=================================================================================================
void BRepTools_History::Remove(const TopoDS_Shape& theRemoved)
{
// Apply the limitations.
Standard_ASSERT_RETURN(IsSupportedType(theRemoved), myMsgUnsupportedType, );
if (myShapeToModified.UnBind(theRemoved))
{
Standard_ASSERT_INVOKE_(, myMsgModifiedAndRemoved);
}
myRemoved.Add(theRemoved);
}
//=================================================================================================
void BRepTools_History::ReplaceGenerated(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theGenerated)
{
if (!prepareGenerated(theInitial, theGenerated))
{
return;
}
TopTools_ListOfShape* aGenerations = myShapeToGenerated.Bound(theInitial, TopTools_ListOfShape());
aGenerations->Append(theGenerated);
}
//=================================================================================================
void BRepTools_History::ReplaceModified(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theModified)
{
if (!prepareModified(theInitial, theModified))
{
return;
}
TopTools_ListOfShape* aModifications =
myShapeToModified.Bound(theInitial, TopTools_ListOfShape());
aModifications->Append(theModified);
}
//=================================================================================================
const TopTools_ListOfShape& BRepTools_History::Generated(const TopoDS_Shape& theInitial) const
{
// Apply the limitations.
Standard_ASSERT_RETURN(theInitial.IsNull() || IsSupportedType(theInitial),
myMsgUnsupportedType,
emptyList());
//
const TopTools_ListOfShape* aGenerations = myShapeToGenerated.Seek(theInitial);
return (aGenerations != NULL) ? *aGenerations : emptyList();
}
//=================================================================================================
const TopTools_ListOfShape& BRepTools_History::Modified(const TopoDS_Shape& theInitial) const
{
// Apply the limitations.
Standard_ASSERT_RETURN(IsSupportedType(theInitial), myMsgUnsupportedType, emptyList());
//
const TopTools_ListOfShape* aModifications = myShapeToModified.Seek(theInitial);
return (aModifications != NULL) ? *aModifications : emptyList();
}
//=================================================================================================
Standard_Boolean BRepTools_History::IsRemoved(const TopoDS_Shape& theInitial) const
{
// Apply the limitations.
Standard_ASSERT_RETURN(IsSupportedType(theInitial), myMsgUnsupportedType, Standard_False);
//
return myRemoved.Contains(theInitial);
}
//=================================================================================================
void BRepTools_History::Merge(const Handle(BRepTools_History)& theHistory23)
{
if (!theHistory23.IsNull())
Merge(*theHistory23.get());
}
//=================================================================================================
void BRepTools_History::Merge(const BRepTools_History& theHistory23)
{
if (!(theHistory23.HasModified() || theHistory23.HasGenerated() || theHistory23.HasRemoved()))
// nothing to merge
return;
// Propagate R23 directly and M23 and G23 fully to M12 and G12.
// Remember the propagated shapes.
TopTools_DataMapOfShapeListOfShape* aS1ToGAndM[] = {&myShapeToGenerated, &myShapeToModified};
TopTools_MapOfShape aRPropagated;
{
// Propagate R23, M23 and G23 to M12 and G12 directly.
// Remember the propagated shapes.
TopTools_MapOfShape aMAndGPropagated;
for (Standard_Integer aI = 0; aI < 2; ++aI)
{
for (TopTools_DataMapOfShapeListOfShape::Iterator aMIt1(*aS1ToGAndM[aI]); aMIt1.More();
aMIt1.Next())
{
TopTools_ListOfShape& aL12 = aMIt1.ChangeValue();
TopTools_MapOfShape aAdditions[2]; // The G and M additions.
for (TopTools_ListOfShape::Iterator aSIt2(aL12); aSIt2.More();)
{
const TopoDS_Shape& aS2 = aSIt2.Value();
if (theHistory23.IsRemoved(aS2))
{
aRPropagated.Add(aS2);
aL12.Remove(aSIt2);
}
else
{
if (theHistory23.myShapeToGenerated.IsBound(aS2))
{
add(aAdditions[0], theHistory23.myShapeToGenerated(aS2));
aMAndGPropagated.Add(aS2);
}
if (theHistory23.myShapeToModified.IsBound(aS2))
{
add(aAdditions[aI], theHistory23.myShapeToModified(aS2));
aMAndGPropagated.Add(aS2);
aL12.Remove(aSIt2);
}
else
{
aSIt2.Next();
}
}
}
add(aL12, aAdditions[aI]);
if (aI != 0 && !aAdditions[0].IsEmpty())
{
const TopoDS_Shape& aS1 = aMIt1.Key();
TopTools_ListOfShape* aGAndM = aS1ToGAndM[0]->ChangeSeek(aS1);
if (aGAndM == NULL)
{
aGAndM = aS1ToGAndM[0]->Bound(aS1, TopTools_ListOfShape());
}
add(*aGAndM, aAdditions[0]);
}
}
}
// Propagate M23 and G23 to M12 and G12 sequentially.
const TopTools_DataMapOfShapeListOfShape* aS2ToGAndM[] = {&theHistory23.myShapeToGenerated,
&theHistory23.myShapeToModified};
for (Standard_Integer aI = 0; aI < 2; ++aI)
{
for (TopTools_DataMapOfShapeListOfShape::Iterator aMIt2(*aS2ToGAndM[aI]); aMIt2.More();
aMIt2.Next())
{
const TopoDS_Shape& aS2 = aMIt2.Key();
if (!aMAndGPropagated.Contains(aS2))
{
if (!aS1ToGAndM[aI]->IsBound(aS2))
{
aS1ToGAndM[aI]->Bind(aS2, TopTools_ListOfShape());
}
TopTools_ListOfShape aM2 = aMIt2.Value();
((*aS1ToGAndM[aI])(aS2)).Append(aM2);
myRemoved.Remove(aS2);
}
}
}
}
// Unbound the empty M12 and G12.
for (Standard_Integer aI = 0; aI < 2; ++aI)
{
for (TopTools_DataMapOfShapeListOfShape::Iterator aMIt1(*aS1ToGAndM[aI]); aMIt1.More();)
{
const TopoDS_Shape& aS1 = aMIt1.Key();
const TopTools_ListOfShape& aL12 = aMIt1.Value();
aMIt1.Next();
if (aL12.IsEmpty())
{
myRemoved.Add(aS1);
aS1ToGAndM[aI]->UnBind(aS1);
}
}
}
// Propagate R23 to R12 sequentially.
for (TopTools_MapOfShape::Iterator aRIt23(theHistory23.myRemoved); aRIt23.More(); aRIt23.Next())
{
const TopoDS_Shape& aS2 = aRIt23.Value();
if (!aRPropagated.Contains(aS2) && !myShapeToModified.IsBound(aS2)
&& !myShapeToGenerated.IsBound(aS2))
{
myRemoved.Add(aS2);
}
}
}
//=================================================================================================
Standard_Boolean BRepTools_History::prepareGenerated(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theGenerated)
{
Standard_ASSERT_RETURN(theInitial.IsNull() || IsSupportedType(theInitial),
myMsgUnsupportedType,
Standard_False);
if (myShapeToModified.IsBound(theInitial) && myShapeToModified(theInitial).Remove(theGenerated))
{
Standard_ASSERT_INVOKE_(, myMsgGeneratedAndModified);
}
return Standard_True;
}
//=================================================================================================
Standard_Boolean BRepTools_History::prepareModified(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theModified)
{
Standard_ASSERT_RETURN(IsSupportedType(theInitial), myMsgUnsupportedType, Standard_False);
if (myRemoved.Remove(theInitial))
{
Standard_ASSERT_INVOKE_(, myMsgModifiedAndRemoved);
}
if (myShapeToGenerated.IsBound(theInitial) && myShapeToGenerated(theInitial).Remove(theModified))
{
Standard_ASSERT_INVOKE_(, myMsgGeneratedAndModified);
}
return Standard_True;
}
//==============================================================================
// data : myEmptyList
// purpose :
//==============================================================================
const TopTools_ListOfShape BRepTools_History::myEmptyList;
//=================================================================================================
const TopTools_ListOfShape& BRepTools_History::emptyList()
{
return myEmptyList;
}
//==============================================================================
// data : myMsgUnsupportedType
// purpose :
//==============================================================================
const char* BRepTools_History::myMsgUnsupportedType = "Error: unsupported shape type.";
//==============================================================================
// data : myMsgGeneratedAndRemoved
// purpose :
//==============================================================================
const char* BRepTools_History::myMsgGeneratedAndRemoved =
"Error: a shape is generated and removed simultaneously.";
//==============================================================================
// data : myMsgModifiedAndRemoved
// purpose :
//==============================================================================
const char* BRepTools_History::myMsgModifiedAndRemoved =
"Error: a shape is modified and removed simultaneously.";
//==============================================================================
// data : myMsgGeneratedAndModified
// purpose :
//==============================================================================
const char* BRepTools_History::myMsgGeneratedAndModified =
"Error: a shape is generated and modified "
"from the same shape simultaneously.";

View File

@@ -0,0 +1,273 @@
// Created on: 2017-04-21
// Created by: Alexander Bobkov
// Copyright (c) 2017 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 _BRepTools_History_HeaderFile
#define _BRepTools_History_HeaderFile
#include <NCollection_Handle.hxx>
#include <TopExp.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
class BRepTools_History;
DEFINE_STANDARD_HANDLE(BRepTools_History, Standard_Transient)
//! The history keeps the following relations between the input shapes
//! (S1, ..., Sm) and output shapes (T1, ..., Tn):
//! 1) an output shape Tj is generated from an input shape Si: Tj <= G(Si);
//! 2) a output shape Tj is modified from an input shape Si: Tj <= M(Si);
//! 3) an input shape (Si) is removed: R(Si) == 1.
//!
//! The relations are kept only for shapes of types vertex, edge, face, and
//! solid.
//!
//! The last relation means that:
//! 1) shape Si is not an output shape and
//! 2) no any shape is modified (produced) from shape Si:
//! R(Si) == 1 ==> Si != Tj, M(Si) == 0.
//!
//! It means that the input shape cannot be removed and modified
//! simultaneously. However, the shapes may be generated from the
//! removed shape. For instance, in Fillet operation the edges
//! generate faces and then are removed.
//!
//! No any shape could be generated and modified from the same shape
//! simultaneously: sets G(Si) and M(Si) are not intersected
//! (G(Si) ^ M(Si) == 0).
//!
//! Each output shape should be:
//! 1) an input shape or
//! 2) generated or modified from an input shape (even generated from the
//! implicit null shape if necessary):
//! Tj == Si V (exists Si that Tj <= G(Si) U M(Si)).
//!
//! Recommendations to choose between relations 'generated' and 'modified':
//! 1) a shape is generated from input shapes if it dimension is greater or
//! smaller than the dimensions of the input shapes;
//! 2) a shape is generated from input shapes if these shapes are also output
//! shapes;
//! 3) a shape is generated from input shapes of the same dimension if it is
//! produced by joining shapes generated from these shapes;
//! 4) a shape is modified from an input shape if it replaces the input shape by
//! changes of the location, the tolerance, the bounds of the parametric
//! space (the faces for a solid), the parametrization and/or by applying of
//! an approximation;
//! 5) a shape is modified from input shapes of the same dimension if it is
//! produced by joining shapes modified from these shapes.
//!
//! Two sequential histories:
//! - one history (H12) of shapes S1, ..., Sm to shapes T1, ..., Tn and
//! - another history (H23) of shapes T1, ..., Tn to shapes Q1, ..., Ql
//! could be merged to the single history (H13) of shapes S1, ..., Sm to shapes
//! Q1, ..., Ql.
//!
//! During the merge:
//! 1) if shape Tj is generated from shape Si then each shape generated or
//! modified from shape Tj is considered as a shape generated from shape Si
//! among shapes Q1, ..., Ql:
//! Tj <= G12(Si), Qk <= G23(Tj) U M23(Tj) ==> Qk <= G13(Si).
//! 2) if shape Tj is modified from shape Si, shape Qk is generated from shape
//! Tj then shape Qk is considered as a shape generated from shape Si among
//! shapes Q1, ..., Ql:
//! Tj <= M12(Si), Qk <= G23(Tj) ==> Qk <= G13(Si);
//! 3) if shape Tj is modified from shape Si, shape Qk is modified from shape
//! Tj then shape Qk is considered as a shape modified from shape Si among
//! shapes Q1, ..., Ql:
//! Tj <= M12(Si), Qk <= M23(Tj) ==> Qk <= M13(Si);
class BRepTools_History : public Standard_Transient
{
public: //! @name Constructors for History creation
//! Empty constructor
BRepTools_History() {}
//! Template constructor for History creation from the algorithm having
//! standard history methods such as IsDeleted(), Modified() and Generated().
//! @param[in] theArguments Arguments of the algorithm;
//! @param[in] theAlgo The algorithm.
template <class TheAlgo>
BRepTools_History(const TopTools_ListOfShape& theArguments, TheAlgo& theAlgo)
{
// Map all argument shapes to save them in history
TopTools_IndexedMapOfShape anArgsMap;
TopTools_ListIteratorOfListOfShape aIt(theArguments);
for (; aIt.More(); aIt.Next())
{
if (!aIt.Value().IsNull())
TopExp::MapShapes(aIt.Value(), anArgsMap);
}
// Copy the history for all supported shapes from the algorithm
Standard_Integer i, aNb = anArgsMap.Extent();
for (i = 1; i <= aNb; ++i)
{
const TopoDS_Shape& aS = anArgsMap(i);
if (!IsSupportedType(aS))
continue;
if (theAlgo.IsDeleted(aS))
Remove(aS);
// Check Modified
const TopTools_ListOfShape& aModified = theAlgo.Modified(aS);
for (aIt.Initialize(aModified); aIt.More(); aIt.Next())
AddModified(aS, aIt.Value());
// Check Generated
const TopTools_ListOfShape& aGenerated = theAlgo.Generated(aS);
for (aIt.Initialize(aGenerated); aIt.More(); aIt.Next())
AddGenerated(aS, aIt.Value());
}
}
public:
//! The types of the historical relations.
enum TRelationType
{
TRelationType_Removed,
TRelationType_Generated,
TRelationType_Modified
};
public:
//! Returns 'true' if the type of the shape is supported by the history.
static Standard_Boolean IsSupportedType(const TopoDS_Shape& theShape)
{
const TopAbs_ShapeEnum aType = theShape.ShapeType();
return aType == TopAbs_VERTEX || aType == TopAbs_EDGE || aType == TopAbs_FACE
|| aType == TopAbs_SOLID;
}
public: //! Methods to set the history.
//! Set the second shape as generated one from the first shape.
Standard_EXPORT void AddGenerated(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theGenerated);
//! Set the second shape as modified one from the first shape.
Standard_EXPORT void AddModified(const TopoDS_Shape& theInitial, const TopoDS_Shape& theModified);
//! Set the shape as removed one.
Standard_EXPORT void Remove(const TopoDS_Shape& theRemoved);
//! Set the second shape as the only generated one from the first one.
Standard_EXPORT void ReplaceGenerated(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theGenerated);
//! Set the second shape as the only modified one from the first one.
Standard_EXPORT void ReplaceModified(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theModified);
//! Clears the history.
void Clear()
{
myShapeToModified.Clear();
myShapeToGenerated.Clear();
myRemoved.Clear();
}
public: //! Methods to read the history.
//! Returns all shapes generated from the shape.
Standard_EXPORT const TopTools_ListOfShape& Generated(const TopoDS_Shape& theInitial) const;
//! Returns all shapes modified from the shape.
Standard_EXPORT const TopTools_ListOfShape& Modified(const TopoDS_Shape& theInitial) const;
//! Returns 'true' if the shape is removed.
Standard_EXPORT Standard_Boolean IsRemoved(const TopoDS_Shape& theInitial) const;
//! Returns 'true' if there any shapes with Generated elements present
Standard_Boolean HasGenerated() const { return !myShapeToGenerated.IsEmpty(); }
//! Returns 'true' if there any Modified shapes present
Standard_Boolean HasModified() const { return !myShapeToModified.IsEmpty(); }
//! Returns 'true' if there any removed shapes present
Standard_Boolean HasRemoved() const { return !myRemoved.IsEmpty(); }
public: //! A method to merge a next history to this history.
//! Merges the next history to this history.
Standard_EXPORT void Merge(const Handle(BRepTools_History)& theHistory23);
//! Merges the next history to this history.
Standard_EXPORT void Merge(const BRepTools_History& theHistory23);
//! Template method for merging history of the algorithm having standard
//! history methods such as IsDeleted(), Modified() and Generated()
//! into current history object.
//! @param[in] theArguments Arguments of the algorithm;
//! @param[in] theAlgo The algorithm.
template <class TheAlgo>
void Merge(const TopTools_ListOfShape& theArguments, TheAlgo& theAlgo)
{
// Create new history object from the given algorithm and merge it into this.
Merge(BRepTools_History(theArguments, theAlgo));
}
public: //! A method to dump a history
//! Prints the brief description of the history into a stream
void Dump(Standard_OStream& theS)
{
theS << "History contains:\n";
theS << " - " << myRemoved.Extent() << " Deleted shapes;\n";
theS << " - " << myShapeToModified.Extent() << " Modified shapes;\n";
theS << " - " << myShapeToGenerated.Extent() << " Generated shapes.\n";
}
public:
//! Define the OCCT RTTI for the type.
DEFINE_STANDARD_RTTIEXT(BRepTools_History, Standard_Transient)
private:
//! Prepares the shapes generated from the first shape to set the second one
//! as generated one from the first one by the addition or the replacement.
//! Returns 'true' on success.
Standard_Boolean prepareGenerated(const TopoDS_Shape& theInitial,
const TopoDS_Shape& theGenerated);
//! Prepares the shapes modified from the first shape to set the second one
//! as modified one from the first one by the addition or the replacement.
//! Returns 'true' on success.
Standard_Boolean prepareModified(const TopoDS_Shape& theInitial, const TopoDS_Shape& theModified);
private: //! Data to keep the history.
//! Maps each input shape to all shapes modified from it.
//! If an input shape is not bound to the map then
//! there is no shapes modified from the shape.
//! No any shape should be mapped to an empty list.
TopTools_DataMapOfShapeListOfShape myShapeToModified;
//! Maps each input shape to all shapes generated from it.
//! If an input shape is not bound to the map then
//! there is no shapes generated from the shape.
//! No any shape should be mapped to an empty list.
TopTools_DataMapOfShapeListOfShape myShapeToGenerated;
TopTools_MapOfShape myRemoved; //!< The removed shapes.
private: //! Auxiliary members to read the history.
//! An auxiliary empty list.
static const TopTools_ListOfShape myEmptyList;
//! A method to export the auxiliary list.
Standard_EXPORT static const TopTools_ListOfShape& emptyList();
private:
//! Auxiliary messages.
static const char* myMsgUnsupportedType;
static const char* myMsgGeneratedAndRemoved;
static const char* myMsgModifiedAndRemoved;
static const char* myMsgGeneratedAndModified;
};
#endif // _BRepTools_History_HeaderFile

View File

@@ -0,0 +1,29 @@
// Created on: 1992-08-28
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef BRepTools_MapOfVertexPnt2d_HeaderFile
#define BRepTools_MapOfVertexPnt2d_HeaderFile
#include <TColgp_SequenceOfPnt2d.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<TopoDS_Shape, TColgp_SequenceOfPnt2d, TopTools_ShapeMapHasher>
BRepTools_MapOfVertexPnt2d;
typedef NCollection_DataMap<TopoDS_Shape, TColgp_SequenceOfPnt2d, TopTools_ShapeMapHasher>::Iterator
BRepTools_DataMapIteratorOfMapOfVertexPnt2d;
#endif

View File

@@ -0,0 +1,41 @@
// Created on: 1994-08-25
// Created by: Jacques GOUSSARD
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRepTools_Modification.hxx>
#include <Poly_Triangulation.hxx>
#include <TopoDS_Face.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_Modification, Standard_Transient)
Standard_Boolean BRepTools_Modification::NewTriangulation(const TopoDS_Face&,
Handle(Poly_Triangulation)&)
{
return Standard_False;
}
Standard_Boolean BRepTools_Modification::NewPolygon(const TopoDS_Edge&, Handle(Poly_Polygon3D)&)
{
return Standard_False;
}
Standard_Boolean BRepTools_Modification::NewPolygonOnTriangulation(
const TopoDS_Edge&,
const TopoDS_Face&,
Handle(Poly_PolygonOnTriangulation)&)
{
return Standard_False;
}

View File

@@ -0,0 +1,156 @@
// Created on: 1994-08-25
// Created by: Jacques GOUSSARD
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepTools_Modification_HeaderFile
#define _BRepTools_Modification_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Real.hxx>
#include <GeomAbs_Shape.hxx>
class TopoDS_Face;
class Geom_Surface;
class TopLoc_Location;
class TopoDS_Edge;
class Geom_Curve;
class TopoDS_Vertex;
class gp_Pnt;
class Geom2d_Curve;
class Poly_Triangulation;
class Poly_Polygon3D;
class Poly_PolygonOnTriangulation;
class BRepTools_Modification;
DEFINE_STANDARD_HANDLE(BRepTools_Modification, Standard_Transient)
//! Defines geometric modifications to a shape, i.e.
//! changes to faces, edges and vertices.
class BRepTools_Modification : public Standard_Transient
{
public:
//! Returns true if the face, F, has been modified.
//! If the face has been modified:
//! - S is the new geometry of the face,
//! - L is its new location, and
//! - Tol is the new tolerance.
//! The flag, RevWires, is set to true when the
//! modification reverses the normal of the surface, (i.e.
//! the wires have to be reversed).
//! The flag, RevFace, is set to true if the orientation of
//! the modified face changes in the shells which contain it.
//! If the face has not been modified this function returns
//! false, and the values of S, L, Tol, RevWires and
//! RevFace are not significant.
Standard_EXPORT virtual Standard_Boolean NewSurface(const TopoDS_Face& F,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& Tol,
Standard_Boolean& RevWires,
Standard_Boolean& RevFace) = 0;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - T is a new triangulation on the face
Standard_EXPORT virtual Standard_Boolean NewTriangulation(const TopoDS_Face& F,
Handle(Poly_Triangulation)& T);
//! Returns true if the edge, E, has been modified.
//! If the edge has been modified:
//! - C is the new geometry associated with the edge,
//! - L is its new location, and
//! - Tol is the new tolerance.
//! If the edge has not been modified, this function
//! returns false, and the values of C, L and Tol are not significant.
Standard_EXPORT virtual Standard_Boolean NewCurve(const TopoDS_Edge& E,
Handle(Geom_Curve)& C,
TopLoc_Location& L,
Standard_Real& Tol) = 0;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - P is a new polygon
Standard_EXPORT virtual Standard_Boolean NewPolygon(const TopoDS_Edge& E,
Handle(Poly_Polygon3D)& P);
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - P is a new polygon on triangulation
Standard_EXPORT virtual Standard_Boolean NewPolygonOnTriangulation(
const TopoDS_Edge& E,
const TopoDS_Face& F,
Handle(Poly_PolygonOnTriangulation)& P);
//! Returns true if the vertex V has been modified.
//! If V has been modified:
//! - P is the new geometry of the vertex, and
//! - Tol is the new tolerance.
//! If the vertex has not been modified this function
//! returns false, and the values of P and Tol are not significant.
Standard_EXPORT virtual Standard_Boolean NewPoint(const TopoDS_Vertex& V,
gp_Pnt& P,
Standard_Real& Tol) = 0;
//! Returns true if the edge, E, has a new curve on
//! surface on the face, F.
//! If a new curve exists:
//! - C is the new geometry of the edge,
//! - L is the new location, and
//! - Tol is the new tolerance.
//! NewE is the new edge created from E, and NewF is
//! the new face created from F.
//! If there is no new curve on the face, this function
//! returns false, and the values of C, L and Tol are not significant.
Standard_EXPORT virtual Standard_Boolean NewCurve2d(const TopoDS_Edge& E,
const TopoDS_Face& F,
const TopoDS_Edge& NewE,
const TopoDS_Face& NewF,
Handle(Geom2d_Curve)& C,
Standard_Real& Tol) = 0;
//! Returns true if the vertex V has a new parameter on the edge E.
//! If a new parameter exists:
//! - P is the parameter, and
//! - Tol is the new tolerance.
//! If there is no new parameter this function returns
//! false, and the values of P and Tol are not significant.
Standard_EXPORT virtual Standard_Boolean NewParameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
Standard_Real& P,
Standard_Real& Tol) = 0;
//! Returns the continuity of <NewE> between <NewF1>
//! and <NewF2>.
//! <NewE> is the new edge created from <E>. <NewF1>
//! (resp. <NewF2>) is the new face created from <F1>
//! (resp. <F2>).
Standard_EXPORT virtual GeomAbs_Shape Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopoDS_Edge& NewE,
const TopoDS_Face& NewF1,
const TopoDS_Face& NewF2) = 0;
DEFINE_STANDARD_RTTIEXT(BRepTools_Modification, Standard_Transient)
protected:
private:
};
#endif // _BRepTools_Modification_HeaderFile

View File

@@ -0,0 +1,800 @@
// Created on: 1994-08-25
// Created by: Jacques GOUSSARD
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
// IFV 04.06.99 - PRO18974 - processing of INTERNAL shapes.
#include <BRepTools_Modification.hxx>
#include <BRepTools_Modifier.hxx>
#include <TColStd_ListOfTransient.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#if 0
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#endif
#include <Geom2d_Line.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <BRepTools.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <gp_Pnt.hxx>
#include <gp.hxx>
#include <Standard_NullObject.hxx>
#include <BRepTools_TrsfModification.hxx>
#include <Message_ProgressScope.hxx>
#include <Geom_Surface.hxx>
static void SetShapeFlags(const TopoDS_Shape& theInSh, TopoDS_Shape& theOutSh);
//=================================================================================================
BRepTools_Modifier::BRepTools_Modifier(Standard_Boolean theMutableInput)
: myDone(Standard_False),
myMutableInput(theMutableInput)
{
}
//=================================================================================================
BRepTools_Modifier::BRepTools_Modifier(const TopoDS_Shape& S)
: myShape(S),
myDone(Standard_False),
myMutableInput(Standard_False)
{
Put(S);
}
//=================================================================================================
BRepTools_Modifier::BRepTools_Modifier(const TopoDS_Shape& S,
const Handle(BRepTools_Modification)& M)
: myShape(S),
myDone(Standard_False),
myMutableInput(Standard_False)
{
Put(S);
Perform(M);
}
//=================================================================================================
void BRepTools_Modifier::Init(const TopoDS_Shape& S)
{
myShape = S;
myDone = Standard_False;
Put(S);
}
//=================================================================================================
#ifdef DEBUG_Modifier
static TopTools_IndexedMapOfShape MapE, MapF;
#endif
void BRepTools_Modifier::Perform(const Handle(BRepTools_Modification)& M,
const Message_ProgressRange& theProgress)
{
if (myShape.IsNull())
{
throw Standard_NullObject();
}
#ifdef DEBUG_Modifier
MapE.Clear();
MapF.Clear();
TopExp::MapShapes(myShape, TopAbs_EDGE, MapE);
TopExp::MapShapes(myShape, TopAbs_FACE, MapF);
#endif
TopTools_DataMapIteratorOfDataMapOfShapeShape theIter(myMap);
Message_ProgressScope aPS(theProgress, "Converting Shape", 2);
TopTools_IndexedDataMapOfShapeListOfShape aMVE, aMEF;
TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aMEF);
CreateNewVertices(aMVE, M);
FillNewCurveInfo(aMEF, M);
FillNewSurfaceInfo(M);
if (!myMutableInput)
CreateOtherVertices(aMVE, aMEF, M);
Standard_Boolean aNewGeom;
Rebuild(myShape, M, aNewGeom, aPS.Next());
if (!aPS.More())
{
// The processing was broken
return;
}
if (myShape.ShapeType() == TopAbs_FACE)
{
if (myShape.Orientation() == TopAbs_REVERSED)
{
myMap(myShape).Reverse();
}
else
{
myMap(myShape).Orientation(myShape.Orientation());
}
}
else
{
myMap(myShape).Orientation(myShape.Orientation());
}
// Update the continuities
BRep_Builder aBB;
/*
Standard_Boolean RecomputeTriangles = Standard_False;
Standard_Real MaxDeflection = RealFirst();
Handle(Poly_Triangulation) Tr;
Handle(Poly_Polygon3D) Po;
TopLoc_Location Loc;
*/
for (int ii = 1; ii <= aMEF.Extent(); ii++)
{
const TopoDS_Edge& CurE = TopoDS::Edge(aMEF.FindKey(ii));
const TopoDS_Edge& NewE = TopoDS::Edge(myMap(CurE));
if (!CurE.IsSame(NewE))
{
TopTools_ListIteratorOfListOfShape it;
it.Initialize(aMEF.FindFromKey(CurE));
TopoDS_Face F1, F2;
while (it.More() && F2.IsNull())
{
if (F1.IsNull())
{
F1 = TopoDS::Face(it.Value());
}
else
{
F2 = TopoDS::Face(it.Value());
}
it.Next();
}
if (!F2.IsNull())
{
const TopoDS_Face& newf1 = TopoDS::Face(myMap(F1));
const TopoDS_Face& newf2 = TopoDS::Face(myMap(F2));
GeomAbs_Shape Newcont = M->Continuity(CurE, F1, F2, NewE, newf1, newf2);
if (Newcont > GeomAbs_C0)
{
aBB.Continuity(NewE, newf1, newf2, Newcont);
}
}
}
theIter.Next();
}
/*
if (RecomputeTriangles) {
BRepMesh_IncrementalMesh(myMap(myShape),MaxDeflection);
}
*/
myDone = Standard_True;
}
//=================================================================================================
void BRepTools_Modifier::Put(const TopoDS_Shape& S)
{
if (!myMap.IsBound(S))
{
myMap.Bind(S, TopoDS_Shape());
for (TopoDS_Iterator theIterator(S, Standard_False); theIterator.More(); theIterator.Next())
{
Put(theIterator.Value());
}
}
}
//=================================================================================================
Standard_Boolean BRepTools_Modifier::Rebuild(const TopoDS_Shape& S,
const Handle(BRepTools_Modification)& M,
Standard_Boolean& theNewGeom,
const Message_ProgressRange& theProgress)
{
#ifdef DEBUG_Modifier
int iF = MapF.Contains(S) ? MapF.FindIndex(S) : 0;
int iE = MapE.Contains(S) ? MapE.FindIndex(S) : 0;
#endif
TopAbs_ShapeEnum ts = S.ShapeType();
TopoDS_Shape& result = myMap(S);
if (!result.IsNull())
{
theNewGeom = myHasNewGeom.Contains(S);
return !S.IsSame(result);
}
Standard_Boolean rebuild = Standard_False, RevWires = Standard_False;
TopAbs_Orientation ResOr = TopAbs_FORWARD;
BRep_Builder B;
Standard_Real tol;
Standard_Boolean No3DCurve = Standard_False; // en fait, si on n`a pas de
// modif geometry 3d , it is necessary to test the existence of a curve 3d.
// new geometry ?
switch (ts)
{
case TopAbs_FACE: {
rebuild = myNSInfo.IsBound(TopoDS::Face(S));
if (rebuild)
{
const NewSurfaceInfo& aNSinfo = myNSInfo(TopoDS::Face(S));
RevWires = aNSinfo.myRevWires;
B.MakeFace(TopoDS::Face(result),
aNSinfo.mySurface,
aNSinfo.myLoc.Predivided(S.Location()),
aNSinfo.myToler);
result.Location(S.Location(), Standard_False);
if (aNSinfo.myRevFace)
ResOr = TopAbs_REVERSED;
// set specifics flags of a Face
B.NaturalRestriction(TopoDS::Face(result), BRep_Tool::NaturalRestriction(TopoDS::Face(S)));
}
// update triangulation on the copied face
Handle(Poly_Triangulation) aTriangulation;
if (M->NewTriangulation(TopoDS::Face(S), aTriangulation))
{
if (rebuild) // the copied face already exists => update it
B.UpdateFace(TopoDS::Face(result), aTriangulation);
else
{ // create new face with bare triangulation
B.MakeFace(TopoDS::Face(result), aTriangulation);
result.Location(S.Location(), Standard_False);
}
rebuild = Standard_True;
}
}
break;
case TopAbs_EDGE: {
rebuild = myNCInfo.IsBound(TopoDS::Edge(S));
if (rebuild)
{
const NewCurveInfo& aNCinfo = myNCInfo(TopoDS::Edge(S));
if (aNCinfo.myCurve.IsNull())
{
B.MakeEdge(TopoDS::Edge(result));
B.Degenerated(TopoDS::Edge(result), BRep_Tool::Degenerated(TopoDS::Edge(S)));
B.UpdateEdge(TopoDS::Edge(result), aNCinfo.myToler); // OCC217
No3DCurve = Standard_True;
}
else
{
B.MakeEdge(TopoDS::Edge(result),
aNCinfo.myCurve,
aNCinfo.myLoc.Predivided(S.Location()),
aNCinfo.myToler);
No3DCurve = Standard_False;
}
result.Location(S.Location(), Standard_False);
// result.Orientation(S.Orientation());
// set specifics flags of an Edge
B.SameParameter(TopoDS::Edge(result), BRep_Tool::SameParameter(TopoDS::Edge(S)));
B.SameRange(TopoDS::Edge(result), BRep_Tool::SameRange(TopoDS::Edge(S)));
}
// update polygonal structure on the edge
Handle(Poly_Polygon3D) aPolygon;
if (M->NewPolygon(TopoDS::Edge(S), aPolygon))
{
if (rebuild) // the copied edge already exists => update it
B.UpdateEdge(TopoDS::Edge(result), aPolygon, S.Location());
else
{ // create new edge with bare polygon
B.MakeEdge(TopoDS::Edge(result), aPolygon);
result.Location(S.Location(), Standard_False);
}
rebuild = Standard_True;
}
}
break;
default:;
}
// rebuild sub-shapes and test new sub-shape ?
Standard_Boolean newgeom = rebuild;
theNewGeom = rebuild;
TopoDS_Iterator it;
{
Standard_Integer aShapeCount = 0;
{
for (it.Initialize(S, Standard_False); it.More(); it.Next())
++aShapeCount;
}
Message_ProgressScope aPS(theProgress, "Converting SubShapes", aShapeCount);
//
for (it.Initialize(S, Standard_False); it.More() && aPS.More(); it.Next())
{
// always call Rebuild
Standard_Boolean isSubNewGeom = Standard_False;
Standard_Boolean subrebuilt = Rebuild(it.Value(), M, isSubNewGeom, aPS.Next());
rebuild = subrebuilt || rebuild;
theNewGeom = theNewGeom || isSubNewGeom;
}
if (!aPS.More())
{
// The processing was broken
return Standard_False;
}
}
if (theNewGeom)
myHasNewGeom.Add(S);
// make an empty copy
if (rebuild && !newgeom)
{
result = S.EmptyCopied();
result.Orientation(TopAbs_FORWARD);
}
// copy the sub-elements
if (rebuild)
{
TopAbs_Orientation orient;
for (it.Initialize(S, Standard_False); it.More(); it.Next())
{
orient = it.Value().Orientation();
if (RevWires || myMap(it.Value()).Orientation() == TopAbs_REVERSED)
{
orient = TopAbs::Reverse(orient);
}
B.Add(result, myMap(it.Value()).Oriented(orient));
}
if (ts == TopAbs_FACE)
{
// pcurves
Handle(Geom2d_Curve) curve2d; //,curve2d1;
TopoDS_Face face = TopoDS::Face(S);
TopAbs_Orientation fcor = face.Orientation();
if (fcor != TopAbs_REVERSED)
fcor = TopAbs_FORWARD;
TopExp_Explorer ex(face.Oriented(fcor), TopAbs_EDGE);
for (; ex.More(); ex.Next())
{
const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
#ifdef DEBUG_Modifier
iE = MapE.Contains(edge) ? MapE.FindIndex(edge) : 0;
#endif
if (theNewGeom
&& M->NewCurve2d(edge,
face,
TopoDS::Edge(myMap(ex.Current())),
TopoDS::Face(result),
curve2d,
tol))
{
// rem dub 16/09/97 : Make constant topology or not make at all.
// Do not make if CopySurface = 1
// Attention, TRUE sewing edges (ReallyClosed)
// stay even if CopySurface is true.
// check that edge contains two pcurves on this surface:
// either it is true seam on the current face, or belongs to two faces
// built on that same surface (see OCC21772)
// Note: this check could be made separate method in BRepTools
Standard_Boolean isClosed = Standard_False;
if (BRep_Tool::IsClosed(edge, face))
{
isClosed = (!newgeom || BRepTools::IsReallyClosed(edge, face));
if (!isClosed)
{
TopLoc_Location aLoc;
TopoDS_Shape resface = (myMap.IsBound(face) ? myMap(face) : face);
if (resface.IsNull())
resface = face;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(resface), aLoc);
// check other faces sharing the same surface
TopExp_Explorer aExpF(myShape, TopAbs_FACE);
for (; aExpF.More() && !isClosed; aExpF.Next())
{
TopoDS_Face anOther = TopoDS::Face(aExpF.Current());
if (anOther.IsSame(face))
continue;
TopoDS_Shape resface2 = (myMap.IsBound(anOther) ? myMap(anOther) : anOther);
if (resface2.IsNull())
resface2 = anOther;
TopLoc_Location anOtherLoc;
Handle(Geom_Surface) anOtherSurf =
BRep_Tool::Surface(TopoDS::Face(resface2), anOtherLoc);
if (aSurf == anOtherSurf && aLoc.IsEqual(anOtherLoc))
{
TopExp_Explorer aExpE(anOther, TopAbs_EDGE);
for (; aExpE.More() && !isClosed; aExpE.Next())
isClosed = edge.IsSame(aExpE.Current());
}
}
}
}
if (isClosed)
{
TopoDS_Edge CurE = TopoDS::Edge(myMap(edge));
TopoDS_Shape aLocalResult = result;
aLocalResult.Orientation(TopAbs_FORWARD);
TopoDS_Face CurF = TopoDS::Face(aLocalResult);
Handle(Geom2d_Curve) curve2d1, currcurv;
Standard_Real f, l;
if ((!RevWires && fcor != edge.Orientation())
|| (RevWires && fcor == edge.Orientation()))
{
CurE.Orientation(TopAbs_FORWARD);
curve2d1 = BRep_Tool::CurveOnSurface(CurE, CurF, f, l);
if (curve2d1.IsNull())
curve2d1 = new Geom2d_Line(gp::OX2d());
B.UpdateEdge(CurE, curve2d1, curve2d, CurF, 0.);
}
else
{
CurE.Orientation(TopAbs_REVERSED);
curve2d1 = BRep_Tool::CurveOnSurface(CurE, CurF, f, l);
if (curve2d1.IsNull())
curve2d1 = new Geom2d_Line(gp::OX2d());
B.UpdateEdge(CurE, curve2d, curve2d1, CurF, 0.);
}
currcurv = BRep_Tool::CurveOnSurface(CurE, CurF, f, l);
B.Range(CurE, f, l);
}
else
{
B.UpdateEdge(TopoDS::Edge(myMap(ex.Current())), curve2d, TopoDS::Face(result), 0.);
}
TopLoc_Location theLoc;
Standard_Real theF, theL;
Handle(Geom_Curve) C3D =
BRep_Tool::Curve(TopoDS::Edge(myMap(ex.Current())), theLoc, theF, theL);
if (C3D.IsNull())
{ // Update vertices
Standard_Real param;
TopExp_Explorer ex2(edge, TopAbs_VERTEX);
while (ex2.More())
{
const TopoDS_Vertex& vertex = TopoDS::Vertex(ex2.Current());
if (!M->NewParameter(vertex, edge, param, tol))
{
tol = BRep_Tool::Tolerance(vertex);
param = BRep_Tool::Parameter(vertex, edge);
}
TopAbs_Orientation vtxrelat = vertex.Orientation();
if (edge.Orientation() == TopAbs_REVERSED)
{
// Update considere l'edge FORWARD, et le vertex en relatif
vtxrelat = TopAbs::Reverse(vtxrelat);
}
// if (myMap(edge).Orientation() == TopAbs_REVERSED) {
// vtxrelat= TopAbs::Reverse(vtxrelat);
// }
TopoDS_Vertex aLocalVertex = TopoDS::Vertex(myMap(vertex));
aLocalVertex.Orientation(vtxrelat);
// B.UpdateVertex(TopoDS::Vertex
//(myMap(vertex).Oriented(vtxrelat)),
B.UpdateVertex(aLocalVertex, param, TopoDS::Edge(myMap(edge)), tol);
ex2.Next();
}
}
}
// Copy polygon on triangulation
Handle(Poly_PolygonOnTriangulation) aPolyOnTria_1, aPolyOnTria_2;
Standard_Boolean aNewPonT = M->NewPolygonOnTriangulation(edge, face, aPolyOnTria_1);
if (BRepTools::IsReallyClosed(edge, face))
{
// Obtain triangulation on reversed edge
TopoDS_Edge anEdgeRev = edge;
anEdgeRev.Reverse();
aNewPonT = M->NewPolygonOnTriangulation(anEdgeRev, face, aPolyOnTria_2) || aNewPonT;
// It there is only one polygon on triangulation, store it to aPolyOnTria_1
if (aPolyOnTria_1.IsNull() && !aPolyOnTria_2.IsNull())
{
aPolyOnTria_1 = aPolyOnTria_2;
aPolyOnTria_2 = Handle(Poly_PolygonOnTriangulation)();
}
}
if (aNewPonT)
{
TopLoc_Location aLocation;
Handle(Poly_Triangulation) aNewFaceTria =
BRep_Tool::Triangulation(TopoDS::Face(myMap(face)), aLocation);
TopoDS_Edge aNewEdge = TopoDS::Edge(myMap(edge));
if (aPolyOnTria_2.IsNull())
B.UpdateEdge(aNewEdge, aPolyOnTria_1, aNewFaceTria, aLocation);
else
{
if (edge.Orientation() == TopAbs_FORWARD)
B.UpdateEdge(aNewEdge, aPolyOnTria_1, aPolyOnTria_2, aNewFaceTria, aLocation);
else
B.UpdateEdge(aNewEdge, aPolyOnTria_2, aPolyOnTria_1, aNewFaceTria, aLocation);
}
}
}
}
// else if (ts == TopAbs_EDGE) {
else if (ts == TopAbs_EDGE && !No3DCurve)
{
// Vertices
Standard_Real param;
const TopoDS_Edge& edge = TopoDS::Edge(S);
TopAbs_Orientation edor = edge.Orientation();
if (edor != TopAbs_REVERSED)
edor = TopAbs_FORWARD;
TopExp_Explorer ex(edge.Oriented(edor), TopAbs_VERTEX);
while (ex.More())
{
const TopoDS_Vertex& vertex = TopoDS::Vertex(ex.Current());
if (!M->NewParameter(vertex, edge, param, tol))
{
tol = BRep_Tool::Tolerance(vertex);
param = BRep_Tool::Parameter(vertex, edge);
}
TopAbs_Orientation vtxrelat = vertex.Orientation();
if (edor == TopAbs_REVERSED)
{
// Update considere l'edge FORWARD, et le vertex en relatif
vtxrelat = TopAbs::Reverse(vtxrelat);
}
// if (result.Orientation() == TopAbs_REVERSED) {
// vtxrelat= TopAbs::Reverse(vtxrelat);
// }
TopoDS_Vertex aLocalVertex = TopoDS::Vertex(myMap(vertex));
aLocalVertex.Orientation(vtxrelat);
// B.UpdateVertex(TopoDS::Vertex(myMap(vertex).Oriented(vtxrelat)),
if (myMutableInput || !aLocalVertex.IsSame(vertex))
B.UpdateVertex(aLocalVertex, param, TopoDS::Edge(result), tol);
ex.Next();
}
}
// update flags
result.Orientable(S.Orientable());
result.Closed(S.Closed());
result.Infinite(S.Infinite());
}
else
result = S;
// Set flag of the shape.
result.Orientation(ResOr);
SetShapeFlags(S, result);
return rebuild;
}
void BRepTools_Modifier::CreateNewVertices(const TopTools_IndexedDataMapOfShapeListOfShape& theMVE,
const Handle(BRepTools_Modification)& M)
{
double aToler;
BRep_Builder aBB;
gp_Pnt aPnt;
for (int i = 1; i <= theMVE.Extent(); i++)
{
// fill MyMap only with vertices with NewPoint == true
const TopoDS_Vertex& aV = TopoDS::Vertex(theMVE.FindKey(i));
Standard_Boolean IsNewP = M->NewPoint(aV, aPnt, aToler);
if (IsNewP)
{
TopoDS_Vertex aNewV;
aBB.MakeVertex(aNewV, aPnt, aToler);
SetShapeFlags(aV, aNewV);
myMap(aV) = aNewV;
myHasNewGeom.Add(aV);
}
else if (myMutableInput)
myMap(aV) = aV.Oriented(TopAbs_FORWARD);
}
}
void BRepTools_Modifier::FillNewCurveInfo(const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
const Handle(BRepTools_Modification)& M)
{
Handle(Geom_Curve) aCurve;
TopLoc_Location aLocation;
BRepTools_Modifier::NewCurveInfo aNCinfo;
double aToler;
for (int i = 1; i <= theMEF.Extent(); i++)
{
const TopoDS_Edge& anE = TopoDS::Edge(theMEF.FindKey(i));
Standard_Boolean IsNewCur = M->NewCurve(anE, aCurve, aLocation, aToler);
if (IsNewCur)
{
aNCinfo.myCurve = aCurve;
aNCinfo.myLoc = aLocation;
aNCinfo.myToler = aToler;
myNCInfo.Bind(anE, aNCinfo);
myHasNewGeom.Add(anE);
}
}
}
void BRepTools_Modifier::FillNewSurfaceInfo(const Handle(BRepTools_Modification)& M)
{
TopTools_IndexedMapOfShape aMF;
TopExp::MapShapes(myShape, TopAbs_FACE, aMF);
BRepTools_Modifier::NewSurfaceInfo aNSinfo;
for (int i = 1; i <= aMF.Extent(); i++)
{
const TopoDS_Face& aF = TopoDS::Face(aMF(i));
Standard_Boolean RevFace;
Standard_Boolean RevWires;
Handle(Geom_Surface) aSurface;
TopLoc_Location aLocation;
double aToler1;
Standard_Boolean IsNewSur = M->NewSurface(aF, aSurface, aLocation, aToler1, RevWires, RevFace);
if (IsNewSur)
{
aNSinfo.mySurface = aSurface;
aNSinfo.myLoc = aLocation;
aNSinfo.myToler = aToler1;
aNSinfo.myRevWires = RevWires;
aNSinfo.myRevFace = RevFace;
myNSInfo.Bind(aF, aNSinfo);
myHasNewGeom.Add(aF);
}
else
{
// check if subshapes will be modified
Standard_Boolean notRebuilded = Standard_True;
TopExp_Explorer exE(aF, TopAbs_EDGE);
while (exE.More() && notRebuilded)
{
const TopoDS_Edge& anEE = TopoDS::Edge(exE.Current());
if (myNCInfo.IsBound(anEE))
{
notRebuilded = Standard_False;
break;
}
TopExp_Explorer exV(anEE, TopAbs_VERTEX);
while (exV.More() && notRebuilded)
{
const TopoDS_Vertex& aVV = TopoDS::Vertex(exV.Current());
if (!myMap(aVV).IsNull())
{
notRebuilded = Standard_False;
break;
}
exV.Next();
}
exE.Next();
}
if (notRebuilded)
{
// subshapes is not going to be modified
myNonUpdFace.Add(aF);
}
}
}
}
void BRepTools_Modifier::CreateOtherVertices(
const TopTools_IndexedDataMapOfShapeListOfShape& theMVE,
const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
const Handle(BRepTools_Modification)& M)
{
double aToler;
// The following logic in some ways repeats the logic from the Rebuild() method.
// If the face with its subshapes is not going to be modified
//(i.e. NewSurface() for this face and NewCurve(), NewPoint() for its edges/vertices returns
// false) then the calling of NewCurve2d() for this face with its edges is not performed.
// Therefore, the updating of vertices will not present in such cases and
// the EmptyCopied() operation for vertices from this face is not needed.
for (int i = 1; i <= theMVE.Extent(); i++)
{
const TopoDS_Vertex& aV = TopoDS::Vertex(theMVE.FindKey(i));
TopoDS_Vertex aNewV = TopoDS::Vertex(myMap(aV));
if (aNewV.IsNull())
{
const TopTools_ListOfShape& aLEdges = theMVE(i);
Standard_Boolean toReplace = Standard_False;
TopTools_ListIteratorOfListOfShape it(aLEdges);
for (; it.More() && !toReplace; it.Next())
{
const TopoDS_Edge& anE = TopoDS::Edge(it.Value());
if (myNCInfo.IsBound(anE) && !myNCInfo(anE).myCurve.IsNull())
toReplace = Standard_True;
if (!toReplace)
{
const TopTools_ListOfShape& aLFaces = theMEF.FindFromKey(anE);
TopTools_ListIteratorOfListOfShape it2(aLFaces);
for (; it2.More(); it2.Next())
{
const TopoDS_Face& aF = TopoDS::Face(it2.Value());
if (!myNonUpdFace.Contains(aF))
{
Handle(Geom2d_Curve) aCurve2d;
// some NewCurve2d()s may use NewE arg internally, so the
// null TShape as an arg may lead to the exceptions
TopoDS_Edge aDummyE = TopoDS::Edge(anE.EmptyCopied());
if (M->NewCurve2d(anE, aF, aDummyE, TopoDS_Face(), aCurve2d, aToler))
{
toReplace = true;
break;
}
}
}
}
}
if (toReplace)
aNewV = TopoDS::Vertex(aV.EmptyCopied());
else
aNewV = aV;
aNewV.Orientation(TopAbs_FORWARD);
myMap(aV) = aNewV;
}
}
}
static void SetShapeFlags(const TopoDS_Shape& theInSh, TopoDS_Shape& theOutSh)
{
theOutSh.Modified(theInSh.Modified());
theOutSh.Checked(theInSh.Checked());
theOutSh.Orientable(theInSh.Orientable());
theOutSh.Closed(theInSh.Closed());
theOutSh.Infinite(theInSh.Infinite());
theOutSh.Convex(theInSh.Convex());
}
Standard_Boolean BRepTools_Modifier::IsMutableInput() const
{
return myMutableInput;
}
void BRepTools_Modifier::SetMutableInput(Standard_Boolean theMutableInput)
{
myMutableInput = theMutableInput;
}

View File

@@ -0,0 +1,129 @@
// Created on: 1994-08-25
// Created by: Jacques GOUSSARD
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepTools_Modifier_HeaderFile
#define _BRepTools_Modifier_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <NCollection_DataMap.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <TopLoc_Location.hxx>
#include <Message_ProgressRange.hxx>
class BRepTools_Modification;
class Geom_Curve;
class Geom_Surface;
//! Performs geometric modifications on a shape.
class BRepTools_Modifier
{
public:
DEFINE_STANDARD_ALLOC
//! Creates an empty Modifier.
Standard_EXPORT BRepTools_Modifier(Standard_Boolean theMutableInput = Standard_False);
//! Creates a modifier on the shape <S>.
Standard_EXPORT BRepTools_Modifier(const TopoDS_Shape& S);
//! Creates a modifier on the shape <S>, and performs
//! the modifications described by <M>.
Standard_EXPORT BRepTools_Modifier(const TopoDS_Shape& S,
const Handle(BRepTools_Modification)& M);
//! Initializes the modifier with the shape <S>.
Standard_EXPORT void Init(const TopoDS_Shape& S);
//! Performs the modifications described by <M>.
Standard_EXPORT void Perform(const Handle(BRepTools_Modification)& M,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Returns Standard_True if the modification has
//! been computed successfully.
Standard_Boolean IsDone() const;
//! Returns the current mutable input state
Standard_EXPORT Standard_Boolean IsMutableInput() const;
//! Sets the mutable input state
//! If true then the input (original) shape can be modified
//! during modification process
Standard_EXPORT void SetMutableInput(Standard_Boolean theMutableInput);
//! Returns the modified shape corresponding to <S>.
const TopoDS_Shape& ModifiedShape(const TopoDS_Shape& S) const;
protected:
private:
struct NewCurveInfo
{
Handle(Geom_Curve) myCurve;
TopLoc_Location myLoc;
Standard_Real myToler;
};
struct NewSurfaceInfo
{
Handle(Geom_Surface) mySurface;
TopLoc_Location myLoc;
Standard_Real myToler;
Standard_Boolean myRevWires;
Standard_Boolean myRevFace;
};
Standard_EXPORT void Put(const TopoDS_Shape& S);
Standard_EXPORT Standard_Boolean
Rebuild(const TopoDS_Shape& S,
const Handle(BRepTools_Modification)& M,
Standard_Boolean& theNewGeom,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT void CreateNewVertices(const TopTools_IndexedDataMapOfShapeListOfShape& theMVE,
const Handle(BRepTools_Modification)& M);
Standard_EXPORT void FillNewCurveInfo(const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
const Handle(BRepTools_Modification)& M);
Standard_EXPORT void FillNewSurfaceInfo(const Handle(BRepTools_Modification)& M);
Standard_EXPORT void CreateOtherVertices(const TopTools_IndexedDataMapOfShapeListOfShape& theMVE,
const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
const Handle(BRepTools_Modification)& M);
TopTools_DataMapOfShapeShape myMap;
TopoDS_Shape myShape;
Standard_Boolean myDone;
NCollection_DataMap<TopoDS_Edge, NewCurveInfo, TopTools_ShapeMapHasher> myNCInfo;
NCollection_DataMap<TopoDS_Face, NewSurfaceInfo, TopTools_ShapeMapHasher> myNSInfo;
TopTools_MapOfShape myNonUpdFace;
TopTools_MapOfShape myHasNewGeom;
Standard_Boolean myMutableInput;
};
#include <BRepTools_Modifier.lxx>
#endif // _BRepTools_Modifier_HeaderFile

View File

@@ -0,0 +1,40 @@
// Created on: 1994-08-25
// Created by: Jacques GOUSSARD
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <Standard_NoSuchObject.hxx>
//=======================================================================
// function : ModifiedShape
// purpose :
//=======================================================================
inline const TopoDS_Shape& BRepTools_Modifier::ModifiedShape(const TopoDS_Shape& S) const
{
if (!myMap.IsBound(S))
{
throw Standard_NoSuchObject();
}
return myMap(S);
}
//=======================================================================
// function : IsDone
// purpose :
//=======================================================================
inline Standard_Boolean BRepTools_Modifier::IsDone() const
{
return myDone;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,156 @@
// Created on: 1996-07-12
// Created by: Stagiaire Mary FABIEN
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepTools_NurbsConvertModification_HeaderFile
#define _BRepTools_NurbsConvertModification_HeaderFile
#include <Standard.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TColStd_ListOfTransient.hxx>
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
#include <BRepTools_CopyModification.hxx>
#include <Standard_Real.hxx>
#include <GeomAbs_Shape.hxx>
class TopoDS_Face;
class Geom_Surface;
class TopLoc_Location;
class TopoDS_Edge;
class Geom_Curve;
class TopoDS_Vertex;
class gp_Pnt;
class Geom2d_Curve;
class BRepTools_NurbsConvertModification;
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_CopyModification)
//! Defines a modification of the geometry by a Trsf
//! from gp. All methods return True and transform the
//! geometry.
class BRepTools_NurbsConvertModification : public BRepTools_CopyModification
{
public:
Standard_EXPORT BRepTools_NurbsConvertModification();
//! Returns Standard_True if the face <F> has been
//! modified. In this case, <S> is the new geometric
//! support of the face, <L> the new location,<Tol>
//! the new tolerance.<RevWires> has to be set to
//! Standard_True when the modification reverses the
//! normal of the surface.(the wires have to be
//! reversed). <RevFace> has to be set to
//! Standard_True if the orientation of the modified
//! face changes in the shells which contain it. --
//! Here, <RevFace> will return Standard_True if the
//! -- gp_Trsf is negative.
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& Tol,
Standard_Boolean& RevWires,
Standard_Boolean& RevFace) Standard_OVERRIDE;
//! Returns Standard_True if the edge <E> has been
//! modified. In this case, <C> is the new geometric
//! support of the edge, <L> the new location, <Tol>
//! the new tolerance. Otherwise, returns
//! Standard_False, and <C>, <L>, <Tol> are not
//! significant.
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,
Handle(Geom_Curve)& C,
TopLoc_Location& L,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns Standard_True if the vertex <V> has been
//! modified. In this case, <P> is the new geometric
//! support of the vertex, <Tol> the new tolerance.
//! Otherwise, returns Standard_False, and <P>, <Tol>
//! are not significant.
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,
gp_Pnt& P,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns Standard_True if the edge <E> has a new
//! curve on surface on the face <F>.In this case, <C>
//! is the new geometric support of the edge, <L> the
//! new location, <Tol> the new tolerance.
//! Otherwise, returns Standard_False, and <C>, <L>,
//! <Tol> are not significant.
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,
const TopoDS_Face& F,
const TopoDS_Edge& NewE,
const TopoDS_Face& NewF,
Handle(Geom2d_Curve)& C,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns Standard_True if the Vertex <V> has a new
//! parameter on the edge <E>. In this case, <P> is
//! the parameter, <Tol> the new tolerance.
//! Otherwise, returns Standard_False, and <P>, <Tol>
//! are not significant.
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
Standard_Real& P,
Standard_Real& Tol) Standard_OVERRIDE;
//! Returns the continuity of <NewE> between <NewF1>
//! and <NewF2>.
//!
//! <NewE> is the new edge created from <E>. <NewF1>
//! (resp. <NewF2>) is the new face created from <F1>
//! (resp. <F2>).
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopoDS_Edge& NewE,
const TopoDS_Face& NewF1,
const TopoDS_Face& NewF2) Standard_OVERRIDE;
//! Returns true if the face has been modified according to changed triangulation.
//! If the face has been modified:
//! - theTri is a new triangulation on the face
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTri)
Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon.
//! If the edge has been modified:
//! - thePoly is a new polygon
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge,
Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
//! Returns true if the edge has been modified according to changed polygon on triangulation.
//! If the edge has been modified:
//! - thePoly is a new polygon on triangulation
Standard_EXPORT Standard_Boolean
NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
Standard_EXPORT const TopTools_ListOfShape& GetUpdatedEdges() const;
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification, BRepTools_CopyModification)
protected:
private:
TopTools_ListOfShape myled;
TColStd_ListOfTransient mylcu;
TColStd_IndexedDataMapOfTransientTransient myMap;
TopTools_ListOfShape myUpdatedEdges;
};
#endif // _BRepTools_NurbsConvertModification_HeaderFile

View File

@@ -0,0 +1,199 @@
// Copyright (c) 2021 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 <BRepTools_PurgeLocations.hxx>
#include <TopoDS_Iterator.hxx>
#include <NCollection_Vector.hxx>
#include <BRepTools.hxx>
#include <BRepTools_TrsfModification.hxx>
#include <BRepTools_Modifier.hxx>
#include <TopLoc_Datum3D.hxx>
//=================================================================================================
BRepTools_PurgeLocations::BRepTools_PurgeLocations()
: myDone(Standard_False)
{
}
//=================================================================================================
Standard_Boolean BRepTools_PurgeLocations::Perform(const TopoDS_Shape& theShape)
{
myShape = theShape;
myMapShapes.Clear();
myLocations.Clear();
myDone = Standard_True;
AddShape(myShape);
// Check locations;
Standard_Integer ind;
NCollection_Vector<Standard_Integer> aBadTrsfInds;
for (ind = 1;; ++ind)
{
const TopLoc_Location& aLoc = myLocations.Location(ind);
if (aLoc.IsIdentity())
break;
const gp_Trsf& aTrsf = aLoc.Transformation();
Standard_Boolean isBadTrsf =
aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
if (isBadTrsf)
{
aBadTrsfInds.Append(ind);
}
}
if (aBadTrsfInds.IsEmpty())
{
return myDone;
}
Standard_Integer aNbShapes = myMapShapes.Extent();
myMapNewShapes.Clear();
Standard_Integer inds;
for (inds = 1; inds <= aNbShapes; ++inds)
{
const TopoDS_Shape& anS = myMapShapes(inds);
Standard_Integer aLocInd = myLocations.Index(anS.Location());
if (aLocInd == 0)
{
continue;
}
Standard_Integer il;
for (il = 0; il < aBadTrsfInds.Size(); ++il)
{
if (aBadTrsfInds(il) == aLocInd)
{
TopoDS_Shape aTrS;
Standard_Boolean isDone = PurgeLocation(anS, aTrS);
myDone = myDone && isDone;
myMapNewShapes.Bind(anS, aTrS);
break;
}
}
}
if (myReShape.IsNull())
{
myReShape = new BRepTools_ReShape;
}
else
{
myReShape->Clear();
}
TopTools_DataMapIteratorOfDataMapOfShapeShape anIter(myMapNewShapes);
for (; anIter.More(); anIter.Next())
{
const TopoDS_Shape& anOldS = anIter.Key();
const TopoDS_Shape& aNewS = anIter.Value();
myReShape->Replace(anOldS, aNewS);
}
myShape = myReShape->Apply(myShape);
return myDone;
}
//=================================================================================================
Standard_Boolean BRepTools_PurgeLocations::PurgeLocation(const TopoDS_Shape& theS,
TopoDS_Shape& theRes)
{
Standard_Boolean isDone = Standard_True;
TopLoc_Location aRefLoc = theS.Location();
Standard_Boolean isEmpty = aRefLoc.IsIdentity();
if (isEmpty)
{
theRes = theS;
return isDone;
}
TopLoc_Location aNullLoc;
theRes = theS.Located(aNullLoc);
while (!isEmpty)
{
const Handle(TopLoc_Datum3D)& aFD = aRefLoc.FirstDatum();
gp_Trsf aTrsf = aFD->Trsf();
Standard_Integer aFP = aRefLoc.FirstPower();
Standard_Boolean isBad =
aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
TopLoc_Location aLoc(aFD);
aLoc = aLoc.Powered(aFP);
aTrsf = aLoc.Transformation();
if (isBad)
{
Handle(BRepTools_TrsfModification) aModification = new BRepTools_TrsfModification(aTrsf);
BRepTools_Modifier aModifier(theRes, aModification);
if (aModifier.IsDone())
{
theRes = aModifier.ModifiedShape(theRes);
}
else
{
isDone = Standard_False;
theRes = theRes.Moved(aLoc);
}
}
else
{
theRes = theRes.Moved(aLoc);
}
aRefLoc = aRefLoc.NextLocation();
isEmpty = aRefLoc.IsIdentity();
}
return isDone;
}
//=================================================================================================
void BRepTools_PurgeLocations::AddShape(const TopoDS_Shape& theS)
{
myMapShapes.Add(theS);
myLocations.Add(theS.Location());
TopoDS_Iterator It(theS, Standard_False, Standard_False);
while (It.More())
{
AddShape(It.Value());
It.Next();
}
}
//=================================================================================================
const TopoDS_Shape& BRepTools_PurgeLocations::GetResult() const
{
return myShape;
}
//=================================================================================================
Standard_Boolean BRepTools_PurgeLocations::IsDone() const
{
return myDone;
}
//=================================================================================================
TopoDS_Shape BRepTools_PurgeLocations::ModifiedShape(const TopoDS_Shape& theInitShape) const
{
TopoDS_Shape aShape = theInitShape;
if (myMapNewShapes.IsBound(theInitShape))
aShape = myMapNewShapes.Find(theInitShape);
return aShape;
}

View File

@@ -0,0 +1,54 @@
// Copyright (c) 2021 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 _BRepTools_PurgeLocations_HeaderFile
#define _BRepTools_PurgeLocations_HeaderFile
#include <Standard.hxx>
#include <Standard_Transient.hxx>
#include <BRepTools_ReShape.hxx>
#include <TopTools_LocationSet.hxx>
//! Removes location datums, which satisfy conditions:
//! aTrsf.IsNegative() || (Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec())
//! from all locations of shape and its subshapes
class BRepTools_PurgeLocations
{
public:
Standard_EXPORT BRepTools_PurgeLocations();
//! Removes all locations correspondingly to criterium from theShape.
Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theShape);
//! Returns shape with removed locations.
Standard_EXPORT const TopoDS_Shape& GetResult() const;
Standard_EXPORT Standard_Boolean IsDone() const;
//! Returns modified shape obtained from initial shape.
TopoDS_Shape ModifiedShape(const TopoDS_Shape& theInitShape) const;
private:
void AddShape(const TopoDS_Shape& theS);
Standard_Boolean PurgeLocation(const TopoDS_Shape& theS, TopoDS_Shape& theRes);
Standard_Boolean myDone;
TopoDS_Shape myShape;
TopTools_IndexedMapOfShape myMapShapes;
TopTools_LocationSet myLocations;
TopTools_DataMapOfShapeShape myMapNewShapes;
Handle(BRepTools_ReShape) myReShape;
};
#endif // _BRepTools_PurgeLocations_HeaderFile

View File

@@ -0,0 +1,548 @@
// Created on: 1994-12-23
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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 <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools_Quilt.hxx>
#include <Geom2d_Curve.hxx>
#include <Standard_NoSuchObject.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <TopTools_MapOfShape.hxx>
//=================================================================================================
BRepTools_Quilt::BRepTools_Quilt()
: hasCopy(Standard_False)
{
}
//=================================================================================================
static Standard_Boolean NeedCopied(const TopoDS_Shape& theShape,
const TopTools_IndexedDataMapOfShapeShape& myBounds)
{
// test if the shape must be copied
// i.e. it contains a bound subshape
Standard_Boolean IsCopied = Standard_False;
TopoDS_Iterator itv(theShape);
for (; itv.More(); itv.Next())
{
if (myBounds.Contains(itv.Value()))
{
IsCopied = Standard_True;
break;
}
}
return IsCopied;
}
static void CopyShape(const TopoDS_Edge& E, TopTools_IndexedDataMapOfShapeShape& myBounds)
{
TopoDS_Edge NE = E;
NE.EmptyCopy();
NE.Orientation(TopAbs_FORWARD);
BRep_Builder B;
// add the edges
TopoDS_Iterator itv;
itv.Initialize(E, Standard_False); // TCollection_DataMap
for (; itv.More(); itv.Next())
{
const TopoDS_Shape& V = itv.Value();
if (myBounds.Contains(V))
{
B.Add(NE, myBounds.FindFromKey(V).Oriented(V.Orientation()));
}
else
{
B.Add(NE, V);
}
}
// set the 3d range
Standard_Real f, l;
BRep_Tool::Range(E, f, l);
B.Range(NE, f, l);
myBounds.Add(E, NE.Oriented(TopAbs_FORWARD));
}
/*static void CopyShape(const TopoDS_Wire& W,TopTools_DataMapOfShapeShape& myBounds)
{
TopoDS_Wire NW;
B.MakeWire(NW);
TopoDS_Iterator ite(W,Standard_False);
for ( ; ite.More(); ite.Next()){
const TopoDS_Edge& E = TopoDS::Edge(ite.Value());
TopAbs_Orientation OE = E.Orientation();
if (myBounds.IsBound(E)) {
TopoDS_Edge& NE = TopoDS::Edge(myBounds(E));
B.Add(NW,NE.Oriented(OE));
}
else
B.Add(NW,E);
}
NW.Orientation(W.Orientation());
myBounds.Bind(W,NW);
}*/
void BRepTools_Quilt::Add(const TopoDS_Shape& S)
{
// std::cout <<" Version of sewing with free edges"<<std::endl;
// Binds all the faces of S
// - to the face itself if it is not copied
// - to the copy if it is copied
if (myBounds.Contains(S))
{
return;
}
BRep_Builder B;
for (TopExp_Explorer wex(S, TopAbs_WIRE, TopAbs_FACE); wex.More(); wex.Next())
{
myBounds.Add(wex.Current(), wex.Current());
}
for (TopExp_Explorer eex(S, TopAbs_EDGE, TopAbs_WIRE); eex.More(); eex.Next())
{
myBounds.Add(eex.Current(), eex.Current());
}
for (TopExp_Explorer vex(S, TopAbs_VERTEX, TopAbs_EDGE); vex.More(); vex.Next())
{
myBounds.Add(vex.Current(), vex.Current());
}
// explore the faces
for (TopExp_Explorer fex(S, TopAbs_FACE); fex.More(); fex.Next())
{
// explore the edges of the face and try to copy them
// if one edge is bound the face must be copied
Standard_Boolean copyFace = Standard_False;
const TopoDS_Face& F = TopoDS::Face(fex.Current());
if (hasCopy)
{ // if their is no binding, do not test for copy
for (TopExp_Explorer fed(F, TopAbs_EDGE); fed.More(); fed.Next())
{
if (myBounds.Contains(fed.Current()))
{
copyFace = Standard_True;
}
else
{
// test if the edge must be copied
// i.e. it contains a bound vertex
Standard_Boolean copyEdge = NeedCopied(fed.Current(), myBounds);
// Standard_Boolean copyEdge = Standard_False;
const TopoDS_Edge& E = TopoDS::Edge(fed.Current());
// TopoDS_Iterator itv(E) ;
// for ( ; itv.More(); itv.Next()) {
// if (myBounds.IsBound(itv.Value())) {
// copyEdge = Standard_True;
// break;
// }
// }
if (copyEdge)
{
// copy of an edge
copyFace = Standard_True;
CopyShape(E, myBounds);
// TopoDS_Edge NE = E; //gka version for free edges
// NE.EmptyCopy();
// NE.Orientation(TopAbs_FORWARD);
// add the edges
// itv.Initialize(E,Standard_False) ;
// for ( ; itv.More(); itv.Next()) {
// const TopoDS_Shape& V = itv.Value();
// if (myBounds.IsBound(V)) {
// B.Add(NE,myBounds(V).Oriented(V.Orientation()));
//}
// else {
// B.Add(NE,V);
//}
//}
// set the 3d range
// Standard_Real f,l;
// BRep_Tool::Range(E,f,l);
// B.Range(NE,f,l);
// myBounds.Bind(E,NE.Oriented(TopAbs_FORWARD));
}
}
}
}
// NF will be the copy of F or F itself
TopoDS_Face NF = F;
if (copyFace)
{
// copy of a face
NF.EmptyCopy();
NF.Orientation(TopAbs_FORWARD);
for (TopoDS_Iterator itw(F, Standard_False); itw.More(); itw.Next())
{
const TopoDS_Wire& W = TopoDS::Wire(itw.Value());
TopoDS_Wire NW;
B.MakeWire(NW);
TopoDS_Iterator ite(W, Standard_False);
Standard_Real UFirst, ULast;
// Reconstruction des wires.
for (; ite.More(); ite.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(ite.Value());
TopAbs_Orientation OE = E.Orientation();
if (myBounds.Contains(E))
{
const TopoDS_Edge& NE = TopoDS::Edge(myBounds.FindFromKey(E));
// pcurve.
if (NE.Orientation() == TopAbs_FORWARD)
{
B.UpdateEdge(NE,
BRep_Tool::CurveOnSurface(E, F, UFirst, ULast),
F,
BRep_Tool::Tolerance(E));
}
else
{
// Si NE est REVERSED
// => les curve3d n ont pas la meme orientation.
// ( C est une convention cf BRepTools_Quilt.cdl. et la methode
// Bind.)
// => la PCurve de E sur F doit etre inversee.
OE = TopAbs::Reverse(OE);
Handle(Geom2d_Curve) CE = BRep_Tool::CurveOnSurface(E, F, UFirst, ULast);
Handle(Geom2d_Curve) NCE = CE->Reversed();
B.UpdateEdge(NE, NCE, F, BRep_Tool::Tolerance(E));
Standard_Real tmp = UFirst;
UFirst = CE->ReversedParameter(ULast);
ULast = CE->ReversedParameter(tmp);
}
// pcurve range
B.Range(NE, F, UFirst, ULast);
B.Add(NW, NE.Oriented(OE));
}
else
{
B.Add(NW, E);
}
}
NW.Orientation(W.Orientation());
B.Add(NF, NW);
}
NF.Orientation(F.Orientation());
}
// binds the face to itself or its copy
myBounds.Add(F, NF);
}
}
//=================================================================================================
void BRepTools_Quilt::Bind(const TopoDS_Vertex& Vold, const TopoDS_Vertex& Vnew)
{
if (!myBounds.Contains(Vold))
{
myBounds.Add(Vold, Vnew);
}
}
//=================================================================================================
void BRepTools_Quilt::Bind(const TopoDS_Edge& Eold, const TopoDS_Edge& Enew)
{
if (!myBounds.Contains(Eold))
{
TopoDS_Edge ENew = Enew;
if (IsCopied(Enew))
{
ENew = TopoDS::Edge(Copy(Enew));
ENew.Orientation(Enew.Orientation());
}
if (Eold.Orientation() != ENew.Orientation())
{
myBounds.Add(Eold.Oriented(TopAbs_FORWARD), ENew.Oriented(TopAbs_REVERSED));
}
else
{
myBounds.Add(Eold.Oriented(TopAbs_FORWARD), ENew.Oriented(TopAbs_FORWARD));
}
// if new binding bind also the vertices
TopoDS_Iterator itold(Eold);
while (itold.More())
{
if (!myBounds.Contains(itold.Value()))
{
// find the vertex of Enew with same orientation
TopAbs_Orientation anOrien = itold.Value().Orientation();
TopoDS_Iterator itnew(ENew);
while (itnew.More())
{
if (itnew.Value().Orientation() == anOrien)
{
TopoDS_Vertex VNew = TopoDS::Vertex(itnew.Value());
if (IsCopied(VNew))
{
// if VNew has been copied take the copy
VNew = TopoDS::Vertex(Copy(VNew));
}
myBounds.Add(itold.Value(), VNew);
break;
}
itnew.Next();
}
}
itold.Next();
}
hasCopy = Standard_True;
}
}
//=================================================================================================
Standard_Boolean BRepTools_Quilt::IsCopied(const TopoDS_Shape& S) const
{
if (myBounds.Contains(S))
{
return !S.IsSame(myBounds.FindFromKey(S));
}
else
return Standard_False;
}
//=================================================================================================
const TopoDS_Shape& BRepTools_Quilt::Copy(const TopoDS_Shape& S) const
{
Standard_NoSuchObject_Raise_if(!IsCopied(S), "BRepTools_Quilt::Copy");
return myBounds.FindFromKey(S);
}
//=================================================================================================
TopoDS_Shape BRepTools_Quilt::Shells() const
{
// Outline of the algorithm
//
// In the map M we bind the free edges to their shells
// We explore all the faces in myBounds
// For each one we search the edges in the map and either :
//
// - Start a new shell if no edge is a free edge.
// - Add the face to an existing shell
// - Connect other shells if the face touch more than one shell
// In the Map M the Shell is bound with the relative orientation of E
// in the shell
// In the map MF we binb the face to its shell.
// In the Map MF the Shell is bound with the relative orientation of F
// in the shell
TopTools_DataMapOfShapeShape M, MF;
BRep_Builder B;
TopoDS_Compound result;
B.MakeCompound(result);
TopTools_MapOfShape MapOtherShape; // gka
TopTools_MapOfShape EdgesFaces;
// loop on the face in myBounds
// TopTools_DataMapIteratorOfDataMapOfShapeShape it(myBounds);
// while (it.More())
for (Standard_Integer ii = 1; ii <= myBounds.Extent(); ii++)
{
const TopoDS_Shape& Shape = myBounds.FindFromIndex(ii); // it.Value();
if (Shape.ShapeType() == TopAbs_FACE)
{
for (TopExp_Explorer aExpEdg(Shape, TopAbs_EDGE); aExpEdg.More(); aExpEdg.Next()) // gka
EdgesFaces.Add(aExpEdg.Current());
TopoDS_Shell SH;
TopAbs_Orientation NewO;
TopExp_Explorer itf1(Shape, TopAbs_EDGE);
for (; itf1.More(); itf1.Next())
{
const TopoDS_Shape& E = itf1.Current();
if (M.IsBound(E))
{
SH = TopoDS::Shell(M(E));
if (SH.Orientation() == E.Orientation())
NewO = TopAbs::Reverse(Shape.Orientation());
else
NewO = Shape.Orientation();
MF.Bind(Shape, SH.Oriented(NewO));
break;
}
}
if (SH.IsNull())
{
// Create a new shell, closed. Add it to the result.
B.MakeShell(SH);
SH.Closed(Standard_True);
B.Add(result, SH);
MF.Bind(Shape, SH.Oriented(Shape.Orientation()));
}
// Add the face to the shell
SH.Free(Standard_True);
// B.Add(SH.Oriented(TopAbs_FORWARD), F .Oriented(MF(F).Orientation()));
TopoDS_Shape arefShape = SH.Oriented(TopAbs_FORWARD);
B.Add(arefShape, Shape.Oriented(MF(Shape).Orientation()));
TopExp_Explorer itf(Shape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
for (; itf.More(); itf.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(itf.Current());
if (M.IsBound(E))
{
const TopoDS_Shape oldShell = M(E);
if (!oldShell.IsSame(SH))
{
// Fuse the old shell with the new one
// Compare the orientation of E in SH and in oldshell.
TopAbs_Orientation anOrien = E.Orientation();
if (MF(Shape).Orientation() == TopAbs_REVERSED)
anOrien = TopAbs::Reverse(anOrien);
Standard_Boolean Rev = (anOrien == oldShell.Orientation());
// if rev = True oldShell has to be reversed.
// Add the faces of oldShell in SH.
for (TopoDS_Iterator its(oldShell); its.More(); its.Next())
{
const TopoDS_Face Fo = TopoDS::Face(its.Value());
TopAbs_Orientation NewOFo;
// update the orientation of Fo in SH.
if (Rev)
NewOFo = TopAbs::Reverse(MF(Fo).Orientation());
else
NewOFo = MF(Fo).Orientation();
MF.Bind(Fo, SH.Oriented(NewOFo));
// B.Add (SH.Oriented(TopAbs_FORWARD),Fo.Oriented(NewO));
TopoDS_Shape arefShapeFo = SH.Oriented(TopAbs_FORWARD);
B.Add(arefShapeFo, Fo.Oriented(NewOFo));
}
// Rebind the free edges of the old shell to the new shell
// gka BUG 6491
TopExp_Explorer aexp(SH, TopAbs_EDGE);
for (; aexp.More(); aexp.Next())
{
// for (TopTools_DataMapIteratorOfDataMapOfShapeShape itm(M);
// itm.More(); ) {
if (!M.IsBound(aexp.Current()))
continue;
const TopoDS_Shape& ae = aexp.Current();
TopoDS_Shape as = M.Find(ae);
if (as.IsSame(oldShell))
{
// update the orientation of free edges in SH.
if (Rev)
NewO = TopAbs::Reverse(as.Orientation());
else
NewO = as.Orientation();
M.Bind(ae, SH.Oriented(NewO));
}
}
// remove the old shell from the result
B.Remove(result, oldShell.Oriented(TopAbs_FORWARD));
}
// Test if SH is always orientable.
TopAbs_Orientation anOrien = E.Orientation();
if (MF(Shape).Orientation() == TopAbs_REVERSED)
anOrien = TopAbs::Reverse(anOrien);
if (M(E).Orientation() == anOrien)
SH.Orientable(Standard_False);
// remove the edge from M (no more a free edge)
M.UnBind(E);
}
else
{
NewO = E.Orientation();
if (MF(Shape).Orientation() == TopAbs_REVERSED)
NewO = TopAbs::Reverse(NewO);
if (!E.IsNull())
M.Bind(E, SH.Oriented(NewO));
else
continue;
}
}
// freeze the shell
SH.Free(Standard_False);
}
else
MapOtherShape.Add(Shape);
// it.Next();
}
// Unclose all shells having free edges
for (TopTools_DataMapIteratorOfDataMapOfShapeShape it(M); it.More(); it.Next())
{
TopoDS_Shape S = it.Value();
S.Closed(Standard_False);
}
TopTools_MapIteratorOfMapOfShape itother(MapOtherShape); // gka version for free edges
for (; itother.More(); itother.Next())
{
if (!EdgesFaces.Contains(itother.Key()) && myBounds.Contains(itother.Key()))
{
TopoDS_Shape aSh = myBounds.FindFromKey(itother.Key());
B.Add(result, aSh);
}
}
return result;
}

View File

@@ -0,0 +1,96 @@
// Created on: 1994-12-22
// Created by: Remi LEQUETTE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-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.
#ifndef _BRepTools_Quilt_HeaderFile
#define _BRepTools_Quilt_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
class TopoDS_Edge;
class TopoDS_Vertex;
class TopoDS_Shape;
//! A Tool to glue faces at common edges and reconstruct shells.
//!
//! The user designate pairs of common edges using the method Bind.
//! One edge is designated as the edge to use in place of the other one
//! (they are supposed to be geometrically confused, but this not checked).
//! They can be of opposite directions, this is specified by the orientations.
//!
//! The user can add shapes with the Add method, all the faces are registered and copies of faces
//! and edges are made to glue at the bound edges.
//!
//! The user can call the Shells methods to compute a compound of shells from the current set of
//! faces.
//!
//! If no binding is made this class can be used to make shell from faces already sharing their
//! edges.
class BRepTools_Quilt
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT BRepTools_Quilt();
//! Binds <Enew> to be the new edge instead of
//! <Eold>.
//!
//! The faces of the added shape containing <Eold>
//! will be copied to substitute <Eold> by <Enew>.
//!
//! The vertices of <Eold> will be bound to the
//! vertices of <Enew> with the same orientation.
//!
//! If <Eold> and <Enew> have different orientations
//! the curves are considered to be opposite and the
//! pcurves of <Eold> will be copied and reversed in
//! the new faces.
//!
//! <Eold> must belong to the next added shape, <Enew> must belong
//! to a Shape added before.
Standard_EXPORT void Bind(const TopoDS_Edge& Eold, const TopoDS_Edge& Enew);
//! Binds <VNew> to be a new vertex instead of <Vold>.
//!
//! The faces of the added shape containing <Vold>
//! will be copied to substitute <Vold> by <Vnew>.
Standard_EXPORT void Bind(const TopoDS_Vertex& Vold, const TopoDS_Vertex& Vnew);
//! Add the faces of <S> to the Quilt, the faces
//! containing bounded edges are copied.
Standard_EXPORT void Add(const TopoDS_Shape& S);
//! Returns True if <S> has been copied (<S> is a
//! vertex, an edge or a face)
Standard_EXPORT Standard_Boolean IsCopied(const TopoDS_Shape& S) const;
//! Returns the shape substituted to <S> in the Quilt.
Standard_EXPORT const TopoDS_Shape& Copy(const TopoDS_Shape& S) const;
//! Returns a Compound of shells made from the current
//! set of faces. The shells will be flagged as closed
//! or not closed.
Standard_EXPORT TopoDS_Shape Shells() const;
protected:
private:
TopTools_IndexedDataMapOfShapeShape myBounds;
Standard_Boolean hasCopy;
};
#endif // _BRepTools_Quilt_HeaderFile

View File

@@ -0,0 +1,578 @@
// Copyright (c) 1999-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.
// abv 28.04.99 S4137: adding method Apply for work on all types of shapes
// sln 29.11.01 Bug24: correction iteration through map in method 'Status'
// sln 29.11.01 Bug22: correction of methods Replace and Value for case when mode
// myConsiderLocation is on
#include <BRep_Builder.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools_ReShape.hxx>
#include <Geom_Surface.hxx>
#include <NCollection_IndexedMap.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_ReShape, Standard_Transient)
namespace
{
//! Adds the shape to the map.
//! If the shape is a wire, shell or solid then
//! adds the sub-shapes of the shape instead.
//! Returns 'true' if the sub-shapes were added.
template <typename TMap>
void Add(TMap& theMap, const TopoDS_Shape& theShape)
{
const TopAbs_ShapeEnum aType = theShape.ShapeType();
if (aType != TopAbs_WIRE && aType != TopAbs_SHELL && aType != TopAbs_COMPSOLID)
{
theMap.Add(theShape);
return;
}
for (TopoDS_Iterator aIt(theShape); aIt.More(); aIt.Next())
{
theMap.Add(aIt.Value());
}
}
} // namespace
// include <ShapeExtend.hxx>
// #include <BRepTools_Edge.hxx>
static void CopyRanges(const TopoDS_Shape& toedge,
const TopoDS_Shape& fromedge,
const Standard_Real alpha,
const Standard_Real beta)
{
Handle(BRep_TEdge) aTEdgeFrom = Handle(BRep_TEdge)::DownCast(fromedge.TShape());
Handle(BRep_TEdge) aTEdgeTo = Handle(BRep_TEdge)::DownCast(toedge.TShape());
BRep_ListOfCurveRepresentation& tolist = aTEdgeTo->ChangeCurves();
BRep_ListIteratorOfListOfCurveRepresentation fromitcr(aTEdgeFrom->ChangeCurves());
for (; fromitcr.More(); fromitcr.Next())
{
Handle(BRep_GCurve) fromGC = Handle(BRep_GCurve)::DownCast(fromitcr.Value());
if (fromGC.IsNull())
continue;
Standard_Boolean isC3d = fromGC->IsCurve3D();
if (isC3d)
{
if (fromGC->Curve3D().IsNull())
continue;
}
else
{
if (fromGC->PCurve().IsNull())
continue;
}
// clang-format off
if ( ! isC3d && ! fromGC->IsCurveOnSurface()) continue; // only 3d curves and pcurves are treated
// clang-format on
Handle(Geom_Surface) surface;
TopLoc_Location L;
if (!isC3d)
{
surface = fromGC->Surface();
L = fromGC->Location();
}
Handle(BRep_GCurve) toGC;
for (BRep_ListIteratorOfListOfCurveRepresentation toitcr(tolist); toitcr.More(); toitcr.Next())
{
toGC = Handle(BRep_GCurve)::DownCast(toitcr.Value());
if (toGC.IsNull())
continue;
if (isC3d)
{
if (!toGC->IsCurve3D())
continue;
}
else if (!toGC->IsCurveOnSurface() || surface != toGC->Surface() || L != toGC->Location())
continue;
Standard_Real first = fromGC->First();
Standard_Real last = fromGC->Last();
Standard_Real len = last - first;
toGC->SetRange(first + alpha * len, first + beta * len);
break;
}
}
}
//=================================================================================================
BRepTools_ReShape::BRepTools_ReShape()
: myStatus(-1)
{
myConsiderLocation = Standard_False;
}
//=================================================================================================
void BRepTools_ReShape::Clear()
{
myShapeToReplacement.Clear();
myNewShapes.Clear();
}
//=================================================================================================
void BRepTools_ReShape::Remove(const TopoDS_Shape& shape)
{
TopoDS_Shape nulshape;
replace(shape, nulshape, TReplacementKind_Remove);
}
//=================================================================================================
void BRepTools_ReShape::replace(const TopoDS_Shape& ashape,
const TopoDS_Shape& anewshape,
const TReplacementKind theKind)
{
TopoDS_Shape shape = ashape;
TopoDS_Shape newshape = anewshape;
if (shape.IsNull() || shape == newshape)
return;
if (shape.Orientation() == TopAbs_REVERSED)
{
shape.Reverse();
newshape.Reverse();
}
// protect against INTERNAL or EXTERNAL shape
else if (shape.Orientation() == TopAbs_INTERNAL || shape.Orientation() == TopAbs_EXTERNAL)
{
newshape.Orientation((newshape.Orientation() == shape.Orientation()) ? TopAbs_FORWARD
: TopAbs_REVERSED);
shape.Orientation(TopAbs_FORWARD);
}
if (myConsiderLocation)
{
// sln 29.11.01 Bug22: Change location of 'newshape' in accordance with location of 'shape'
newshape.Location(newshape.Location().Multiplied(shape.Location().Inverted()), Standard_False);
TopLoc_Location nullLoc;
shape.Location(nullLoc);
}
#ifdef OCCT_DEBUG
if (IsRecorded(shape)
&& ((myConsiderLocation && !Value(shape).IsPartner(newshape))
|| (!myConsiderLocation && !Value(shape).IsSame(newshape))))
std::cout << "Warning: BRepTools_ReShape::Replace: shape already recorded" << std::endl;
#endif
myShapeToReplacement.Bind(shape, TReplacement(newshape, theKind));
myNewShapes.Add(newshape);
}
//=================================================================================================
Standard_Boolean BRepTools_ReShape::IsRecorded(const TopoDS_Shape& ashape) const
{
TopoDS_Shape shape = ashape;
if (myConsiderLocation)
{
TopLoc_Location nullLoc;
shape.Location(nullLoc);
}
if (shape.IsNull())
return Standard_False;
return myShapeToReplacement.IsBound(shape);
}
//=================================================================================================
TopoDS_Shape BRepTools_ReShape::Value(const TopoDS_Shape& ashape) const
{
TopoDS_Shape res;
if (ashape.IsNull())
return res;
TopoDS_Shape shape = ashape;
if (myConsiderLocation)
{
TopLoc_Location nullLoc;
shape.Location(nullLoc);
}
Standard_Boolean fromMap = Standard_False;
if (!myShapeToReplacement.IsBound(shape))
{
res = shape;
}
else
{
res = myShapeToReplacement(shape).Result();
if (shape.Orientation() == TopAbs_REVERSED)
{
res.Reverse();
}
fromMap = Standard_True;
}
// for INTERNAL/EXTERNAL, since they are not fully supported, keep orientation
if (shape.Orientation() == TopAbs_INTERNAL || shape.Orientation() == TopAbs_EXTERNAL)
res.Orientation(shape.Orientation());
if (myConsiderLocation)
{
// sln 29.11.01 Bug22: Recalculate location of resulting shape in accordance with
// whether result is from map or not
if (fromMap)
res.Location(ashape.Location() * res.Location(), Standard_False);
else
res.Location(ashape.Location(), Standard_False);
}
return res;
}
//=================================================================================================
Standard_Integer BRepTools_ReShape::Status(const TopoDS_Shape& ashape,
TopoDS_Shape& newsh,
const Standard_Boolean last)
{
Standard_Integer res = 0;
if (ashape.IsNull())
{
newsh.Nullify();
return res;
}
TopoDS_Shape shape = ashape;
TopLoc_Location aLocSh = shape.Location();
if (myConsiderLocation)
{
TopLoc_Location nullLoc;
shape.Location(nullLoc);
}
if (!myShapeToReplacement.IsBound(shape))
{
newsh = shape;
res = 0;
}
else
{
newsh = myShapeToReplacement(shape).Result();
res = 1;
}
if (res > 0)
{
if (newsh.IsNull())
res = -1;
else if (newsh.IsEqual(shape))
res = 0;
else if (last
&& ((myConsiderLocation && !newsh.IsPartner(shape))
|| (!myConsiderLocation && !newsh.IsSame(shape))))
{
// TopoDS_Shape newnewsh;
// Standard_Integer newres = Status (newsh, newnewsh, last);
// newsh = newnewsh;
// if (newres) res = newres;
// sln 29.11.01 Bug24: Correction iteration through maps. Way of iteration used early does
// not correspond to way of storing information in the maps.
newsh = Apply(shape, TopAbs_SHAPE);
if (newsh.IsNull())
res = -1;
if (newsh.IsEqual(shape))
res = 0;
}
}
if (myConsiderLocation && !newsh.IsNull())
{
TopLoc_Location aResLoc =
(res > 0 && !newsh.Location().IsIdentity() ? aLocSh * newsh.Location() : aLocSh);
newsh.Location(aResLoc, Standard_False);
}
return res;
}
//=================================================================================================
static Standard_Integer EncodeStatus(const Standard_Integer status)
{
switch (status)
{
case 0:
return 0x0000; // ShapeExtend_OK
case 1:
return 0x0001; // ShapeExtend_DONE1
case 2:
return 0x0002; //....
case 3:
return 0x0004;
case 4:
return 0x0008;
case 5:
return 0x0010;
case 6:
return 0x0020;
case 7:
return 0x0040;
case 8:
return 0x0080; //....
case 9:
return 0x00ff; // ShapeExtend_DONE
case 10:
return 0x0100; // ShapeExtend_FAIL1
case 11:
return 0x0200; //...
case 12:
return 0x0400;
case 13:
return 0x0800;
case 14:
return 0x1000;
case 15:
return 0x2000;
case 16:
return 0x4000;
case 17:
return 0x8000; //....
case 18:
return 0xff00; // ShapeExtend_FAIL
}
return 0;
}
//=================================================================================================
TopoDS_Shape BRepTools_ReShape::Apply(const TopoDS_Shape& shape, const TopAbs_ShapeEnum until)
{
myStatus = EncodeStatus(0); // ShapeExtend::EncodeStatus ( ShapeExtend_OK );
if (shape.IsNull())
return shape;
// apply direct replacement
TopoDS_Shape newsh = Value(shape);
// if shape removed, return NULL
if (newsh.IsNull())
{
myStatus = EncodeStatus(2); // ShapeExtend_DONE2
return newsh;
}
// if shape replaced, apply modifications to the result recursively
if ((myConsiderLocation && !newsh.IsPartner(shape))
|| (!myConsiderLocation && !newsh.IsSame(shape)))
{
TopoDS_Shape res = Apply(newsh, until);
myStatus |= EncodeStatus(1); // ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
return res;
}
TopAbs_ShapeEnum st = shape.ShapeType();
if (st > until || (st == until && until > TopAbs_COMPOUND))
return newsh; // stopping criteria
if (st == TopAbs_VERTEX || st == TopAbs_SHAPE)
return shape;
// define allowed types of components
// fix for SAMTECH bug OCC322 about absent internal vertices after sewing.
/*
switch ( st ) {
case TopAbs_COMPOUND: subt = TopAbs_SHAPE; break;
case TopAbs_COMPSOLID: subt = TopAbs_SOLID; break;
case TopAbs_SOLID: subt = TopAbs_SHELL; break;
case TopAbs_SHELL: subt = TopAbs_FACE; break;
case TopAbs_FACE: subt = TopAbs_WIRE; break;
case TopAbs_WIRE: subt = TopAbs_EDGE; break;
case TopAbs_EDGE: subt = TopAbs_VERTEX; break;
case TopAbs_VERTEX:
case TopAbs_SHAPE:
default: return shape;
}
*/
BRep_Builder B;
TopoDS_Shape result = shape.EmptyCopied();
TopAbs_Orientation orien = shape.Orientation();
result.Orientation(TopAbs_FORWARD); // protect against INTERNAL or EXTERNAL shapes
Standard_Boolean modif = Standard_False;
Standard_Integer locStatus = myStatus;
// apply recorded modifications to subshapes
Standard_Boolean isEmpty = Standard_True;
for (TopoDS_Iterator it(shape, Standard_False); it.More(); it.Next())
{
const TopoDS_Shape& sh = it.Value();
newsh = Apply(sh, until);
if (newsh != sh)
{
if (myStatus & EncodeStatus(4)) // ShapeExtend::DecodeStatus ( myStatus, ShapeExtend_DONE4 ) )
locStatus |= EncodeStatus(4); //|= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 );
modif = 1;
}
if (newsh.IsNull())
{
locStatus |= EncodeStatus(4); // ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 );
continue;
}
if (isEmpty)
isEmpty = Standard_False;
locStatus |= EncodeStatus(3); // ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
if (st == TopAbs_COMPOUND || newsh.ShapeType() == sh.ShapeType())
{ // fix for SAMTECH bug OCC322 about absent internal vertices after sewing.
B.Add(result, newsh);
continue;
}
Standard_Integer nitems = 0;
for (TopoDS_Iterator subit(newsh); subit.More(); subit.Next(), nitems++)
{
const TopoDS_Shape& subsh = subit.Value();
// clang-format off
if ( subsh.ShapeType() == sh.ShapeType() ) B.Add ( result, subsh );//fix for SAMTECH bug OCC322 about absent internal vertices after sewing.
else locStatus |= EncodeStatus(10);//ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
}
if ( ! nitems ) locStatus |= EncodeStatus(10);//ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
// clang-format on
}
if (!modif)
return shape;
// For empty topological containers (any kind of shape except vertex, edge
// and face) we have to produce an empty result
if (isEmpty && st != TopAbs_VERTEX && st != TopAbs_EDGE && st != TopAbs_FACE)
{
result = TopoDS_Shape();
}
else
{
// restore Range on edge broken by EmptyCopied()
if (st == TopAbs_EDGE)
{
CopyRanges(result, shape, 0, 1);
}
else if (st == TopAbs_FACE)
{
TopoDS_Face face = TopoDS::Face(shape);
if (BRep_Tool::NaturalRestriction(face))
{
BRep_Builder aB;
aB.NaturalRestriction(TopoDS::Face(result), Standard_True);
}
}
else if (st == TopAbs_WIRE || st == TopAbs_SHELL)
result.Closed(BRep_Tool::IsClosed(result));
result.Orientation(orien);
}
replace(shape, result, result.IsNull() ? TReplacementKind_Remove : TReplacementKind_Modify);
myStatus = locStatus;
return result;
}
//=================================================================================================
/*Standard_Boolean BRepTools_ReShape::Status (const ShapeExtend_Status status) const
{
return ShapeExtend::DecodeStatus ( myStatus, status );
}*/
//=================================================================================================
TopoDS_Vertex BRepTools_ReShape::CopyVertex(const TopoDS_Vertex& theV, const Standard_Real theTol)
{
return CopyVertex(theV, BRep_Tool::Pnt(theV), theTol);
}
//=================================================================================================
TopoDS_Vertex BRepTools_ReShape::CopyVertex(const TopoDS_Vertex& theV,
const gp_Pnt& theNewPos,
const Standard_Real theTol)
{
TopoDS_Vertex aVertexCopy;
Standard_Boolean isRecorded = IsRecorded(theV);
aVertexCopy = isRecorded ? TopoDS::Vertex(Apply(theV)) : TopoDS::Vertex(theV.EmptyCopied());
BRep_Builder B;
Standard_Real aNewTol = theTol > 0.0 ? theTol : BRep_Tool::Tolerance(theV);
B.UpdateVertex(aVertexCopy, theNewPos, aNewTol);
if (!isRecorded)
Replace(theV, aVertexCopy);
return aVertexCopy;
}
Standard_Boolean BRepTools_ReShape::IsNewShape(const TopoDS_Shape& theShape) const
{
return myNewShapes.Contains(theShape);
}
//=================================================================================================
Handle(BRepTools_History) BRepTools_ReShape::History() const
{
Handle(BRepTools_History) aHistory = new BRepTools_History;
// Fill the history.
for (TShapeToReplacement::Iterator aRIt(myShapeToReplacement); aRIt.More(); aRIt.Next())
{
const TopoDS_Shape& aShape = aRIt.Key();
if (!BRepTools_History::IsSupportedType(aShape) || myNewShapes.Contains(aShape))
{
continue;
}
NCollection_IndexedMap<TopoDS_Shape> aIntermediates;
NCollection_Map<TopoDS_Shape> aModified;
aIntermediates.Add(aShape);
for (Standard_Integer aI = 1; aI <= aIntermediates.Size(); ++aI)
{
const TopoDS_Shape& aIntermediate = aIntermediates(aI);
const TReplacement* aReplacement = myShapeToReplacement.Seek(aIntermediate);
if (aReplacement == NULL)
{
Add(aModified, aIntermediate);
}
else if (aReplacement->RelationKind() != BRepTools_History::TRelationType_Removed)
{
const TopoDS_Shape aResult = aReplacement->RelationResult();
if (!aResult.IsNull())
{
Add(aIntermediates, aResult);
}
}
}
if (aModified.IsEmpty())
{
aHistory->Remove(aShape);
}
else
{
for (NCollection_Map<TopoDS_Shape>::Iterator aIt(aModified); aIt.More(); aIt.Next())
{
aHistory->AddModified(aShape, aIt.Value());
}
}
}
return aHistory;
}

Some files were not shown because too many files have changed in this diff Show More