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

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

126
src/ShapeExtend/ShapeExtend.cdl Executable file
View File

@@ -0,0 +1,126 @@
-- File: ShapeExtend.cdl
-- Created: Tue Jul 21 09:12:57 1998
-- Author: data exchange team
-- <det@androx.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
package ShapeExtend
---Purpose: This package provides general tools and data structures common
-- for other packages in SHAPEWORKS and extending CAS.CADE
-- structures.
-- The following items are provided by this package:
-- - enumeration Status used for coding status flags in methods
-- inside the SHAPEWORKS
-- - enumeration Parametrisation used for setting global parametrisation
-- on the composite surface
-- - class CompositeSurface representing a composite surface
-- made of a grid of surface patches
-- - class WireData representing a wire in the form of ordered
-- list of edges
-- - class MsgRegistrator for attaching messages to the objects
-- - tools for exploring the shapes
-- - tools for creating new shapes.
uses
TCollection,
gp,
Geom,
GeomAbs,
TColStd,
TColGeom,
TopAbs,
TopoDS,
TopTools,
Message
is
enumeration Status is
---Purpose: This enumeration is used in
-- ShapeHealing toolkit for representing flags in the
-- return statuses of class methods.
-- The status is a field of the class which is set by one or
-- several methods of that class.
-- It is used for reporting about errors and other situations
-- encountered during execution of the method.
-- There are defined 8 values for DONE and 8 for FAIL flags:
-- ShapeExtend_DONE1 ... ShapeExtend_DONE8,
-- ShapeExtend_FAIL1 ... ShapeExtend_FAIL8
-- and also enumerations for representing combinations of flags:
-- ShapeExtend_OK - no flags at all,
-- ShapeExtend_DONE - any of flags DONEi,
-- ShapeExtend_FAIL - any of flags FAILi.
-- The class that uses statuses provides a method(s) which
-- answers whether the flag corresponding to a given
-- enumerative value is (are) set:
-- Standard_Boolean Status(const ShapeExtend_Status test);
-- Note that status can have several flags set simultaneously.
-- Status(ShapeExtend_OK) gives True when no flags are set.
OK, -- Nothing done, everything OK
DONE1, -- Something was done, case 1
DONE2, -- Something was done, case 2
DONE3, -- Something was done, case 3
DONE4, -- Something was done, case 4
DONE5, -- Something was done, case 5
DONE6, -- Something was done, case 6
DONE7, -- Something was done, case 7
DONE8, -- Something was done, case 8
DONE, -- Something was done (any of DONE#)
FAIL1, -- The method failed, case 1
FAIL2, -- The method failed, case 2
FAIL3, -- The method failed, case 3
FAIL4, -- The method failed, case 4
FAIL5, -- The method failed, case 5
FAIL6, -- The method failed, case 6
FAIL7, -- The method failed, case 7
FAIL8, -- The method failed, case 8
FAIL -- The mathod failed (any of FAIL# occured)
end Status;
enumeration Parametrisation is
---Purpose: Defines kind of global parametrisation on the composite surface
Natural, -- each patch of the 1st row and column adds its range, Ui+1 = Ui + URange(i,1), etc.
Uniform, -- each patch gives range 1.: Ui = i-1, Vj = j-1
Unitary -- uniform parametrisation with global range [0,1]
end Parametrisation;
deferred class ComplexCurve;
class CompositeSurface;
---Purpose: Defines surface composed of grid of connected patches
class WireData;
---Purpose: Defines data structure for work on a wire as a list of edges
class BasicMsgRegistrator;
---Purpose: Abstract class to send messages to the objects
class MsgRegistrator;
---Purpose: Collects messages to be attached messages to the objects
class Explorer;
---Purpose: Exploring of shapes (compounds)
class DataMapOfShapeListOfMsg instantiates DataMap from TCollection
(Shape from TopoDS,
ListOfMsg from Message,
ShapeMapHasher from TopTools);
class DataMapOfTransientListOfMsg instantiates DataMap from TCollection
(Transient,
ListOfMsg from Message,
MapTransientHasher from TColStd);
Init;
---Purpose: Inits using of ShapeExtend.
-- Currently, loads messages output by ShapeHealing algorithms.
EncodeStatus ( status: Status from ShapeExtend ) returns Integer;
---Purpose: Encodes status (enumeration) to a bit flag
DecodeStatus ( flag: Integer; status: Status from ShapeExtend ) returns Boolean;
---Purpose: Tells if a bit flag contains bit corresponding to enumerated status
end ShapeExtend;

67
src/ShapeExtend/ShapeExtend.cxx Executable file
View File

@@ -0,0 +1,67 @@
// File: ShapeExtend.cxx
// Created: Wed Jun 10 16:03:56 1998
// Author: data exchange team
// <det@nicebox.nnov.matra-dtv.fr>
#include <ShapeExtend.ixx>
#include <Message_MsgFile.hxx>
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ShapeExtend::Init()
{
static Standard_Boolean init = Standard_False;
if (init) return;
init = Standard_True;
// load Message File for Shape Healing
Message_MsgFile::LoadFromEnv ("CSF_SHMessage", "SHAPE");
}
//=======================================================================
//function : EncodeStatus
//purpose :
//=======================================================================
Standard_Integer ShapeExtend::EncodeStatus (const ShapeExtend_Status status)
{
switch ( status ) {
case ShapeExtend_OK : return 0x0000;
case ShapeExtend_DONE1: return 0x0001;
case ShapeExtend_DONE2: return 0x0002;
case ShapeExtend_DONE3: return 0x0004;
case ShapeExtend_DONE4: return 0x0008;
case ShapeExtend_DONE5: return 0x0010;
case ShapeExtend_DONE6: return 0x0020;
case ShapeExtend_DONE7: return 0x0040;
case ShapeExtend_DONE8: return 0x0080;
case ShapeExtend_DONE : return 0x00ff;
case ShapeExtend_FAIL1: return 0x0100;
case ShapeExtend_FAIL2: return 0x0200;
case ShapeExtend_FAIL3: return 0x0400;
case ShapeExtend_FAIL4: return 0x0800;
case ShapeExtend_FAIL5: return 0x1000;
case ShapeExtend_FAIL6: return 0x2000;
case ShapeExtend_FAIL7: return 0x4000;
case ShapeExtend_FAIL8: return 0x8000;
case ShapeExtend_FAIL : return 0xff00;
}
return 0;
}
//=======================================================================
//function : DecodeStatus
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend::DecodeStatus (const Standard_Integer flag,
const ShapeExtend_Status status)
{
if ( status == ShapeExtend_OK ) return ( flag == 0 );
return ( flag & ShapeExtend::EncodeStatus ( status ) ? Standard_True : Standard_False );
}

View File

@@ -0,0 +1,46 @@
-- File: ShapeExtend_BasicMsgRegistrator.cdl
-- Created: Fri Jan 28 19:33:57 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class BasicMsgRegistrator from ShapeExtend inherits TShared from MMgt
---Purpose: Abstract class that can be used for attaching messages
-- to the objects (e.g. shapes).
-- It is used by ShapeHealing algorithms to attach a message
-- describing encountered case (e.g. removing small edge from
-- a wire).
--
-- The methods of this class are empty and redefined, for instance,
-- in the classes for Data Exchange processors for attaching
-- messages to interface file entities or CAS.CADE shapes.
uses
Shape from TopoDS,
Msg from Message,
Gravity from Message
is
Create returns mutable BasicMsgRegistrator from ShapeExtend;
---Purpose: Empty constructor.
Send (me: mutable; object : Transient;
message: Msg from Message;
gravity: Gravity from Message) is virtual;
---Purpose: Sends a message to be attached to the object.
-- Object can be of any type interpreted by redefined MsgRegistrator.
Send (me: mutable; shape : Shape from TopoDS;
message: Msg from Message;
gravity: Gravity from Message) is virtual;
---Purpose: Sends a message to be attached to the shape.
Send (me: mutable; message: Msg from Message;
gravity: Gravity from Message) is virtual;
---Purpose: Calls Send method with Null Transient.
end BasicMsgRegistrator;

View File

@@ -0,0 +1,51 @@
// File: ShapeExtend_BasicMsgRegistrator.cxx
// Created: Fri Jan 28 19:52:05 2000
// Author: data exchange team
// <det@kinox>
#include <ShapeExtend_BasicMsgRegistrator.ixx>
//=======================================================================
//function : ShapeExtend_BasicMsgRegistrator
//purpose :
//=======================================================================
ShapeExtend_BasicMsgRegistrator::ShapeExtend_BasicMsgRegistrator()
{
}
//=======================================================================
//function : Send
//purpose :
//=======================================================================
void ShapeExtend_BasicMsgRegistrator::Send(const Handle(Standard_Transient)& /*object*/,
const Message_Msg& /*message*/,
const Message_Gravity /*gravity*/)
{
}
//=======================================================================
//function : Send
//purpose :
//=======================================================================
void ShapeExtend_BasicMsgRegistrator::Send(const TopoDS_Shape& /*shape*/,
const Message_Msg& /*message*/,
const Message_Gravity /*gravity*/)
{
}
//=======================================================================
//function : Send
//purpose :
//=======================================================================
void ShapeExtend_BasicMsgRegistrator::Send(const Message_Msg& message,
const Message_Gravity gravity)
{
Handle(Standard_Transient) dummy;
Send (dummy, message, gravity);
}

View File

@@ -0,0 +1,106 @@
-- File: ShapeExtend_ComplexCurve.cdl
-- Created: Tue Jun 22 19:08:30 1999
-- Author: Roman LYGIN
-- <rln@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
deferred class ComplexCurve from ShapeExtend inherits Curve from Geom
---Purpose: Defines a curve which consists of several segments.
-- Implements basic interface to it.
uses
Pnt from gp,
Vec from gp,
Trsf from gp,
Shape from GeomAbs,
Curve from Geom
is
Initialize returns mutable ComplexCurve from ShapeExtend;
---Purpose:
NbCurves (me) returns Integer is deferred;
---Purpose: Returns number of curves
Curve (me; index: Integer) returns Curve from Geom is deferred;
---C++: return const &
---Purpose: Returns curve given by its index
LocateParameter (me; U : Real;
UOut: out Real)
returns Integer is deferred;
---Purpose: Returns number of the curve for the given parameter U
-- and local paramete r UOut for the found curve
LocalToGlobal (me; index : Integer;
Ulocal: Real)
returns Real is deferred;
---Purpose: Returns global parameter for the whole curve according
-- to the segment and local parameter on it
Transform (me: mutable; T: Trsf) is redefined;
---Purpose: Applies transformation to each curve
ReversedParameter(me; U: Real) returns Real is redefined;
---C++: inline
---Purpose: Returns 1 - U
FirstParameter (me) returns Real is redefined;
---C++: inline
---Purpose: Returns 0
LastParameter (me) returns Real is redefined;
---C++: inline
---Purpose: Returns 1
IsClosed (me) returns Boolean is redefined;
---C++: inline
---Purpose: Returns True if the curve is closed
IsPeriodic (me) returns Boolean is redefined;
---C++: inline
---Purpose: Returns False
Continuity (me) returns Shape from GeomAbs is redefined;
---C++: inline
---Purpose: Returns GeomAbs_C0
IsCN (me; N: Integer) returns Boolean is redefined;
---C++: inline
---Purpose: Returns False if N > 0
D0 (me; U: Real; P: out Pnt) is redefined;
---Purpose: Returns point at parameter U.
-- Finds appropriate curve and local parameter on it.
D1 (me; U: Real; P: out Pnt; V1: out Vec) is redefined;
D2 (me; U: Real; P: out Pnt; V1, V2: out Vec) is redefined;
D3 (me; U: Real; P: out Pnt; V1, V2, V3: out Vec) is redefined;
DN (me; U: Real; N: Integer) returns Vec is redefined;
GetScaleFactor(me; ind: Integer) returns Real is deferred;
---Purpose: Returns scale factor for recomputing of deviatives.
---Level: Internal
CheckConnectivity (me: mutable; Preci: Real) returns Boolean;
---Purpose: Checks geometrical connectivity of the curves, including
-- closure (sets fields myClosed)
TransformDN (me; V: in out Vec; ind: Integer; N: Integer)
is protected;
---Purpose: Transform the derivative according to its order
fields
myClosed: Boolean is protected;
end ComplexCurve;

View File

@@ -0,0 +1,132 @@
// File: ShapeExtend_ComplexCurve.cxx
// Created: Tue Jun 22 19:19:20 1999
// Author: Roman LYGIN
// <rln@kinox.nnov.matra-dtv.fr>
// pdn 13.07.99 Derivatives are scaled in accordance with local/global parameter transition
#include <ShapeExtend_ComplexCurve.ixx>
#include <Precision.hxx>
//=======================================================================
//function : ShapeExtend_ComplexCurve
//purpose :
//=======================================================================
ShapeExtend_ComplexCurve::ShapeExtend_ComplexCurve()
{
myClosed = Standard_False;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void ShapeExtend_ComplexCurve::Transform(const gp_Trsf& T)
{
for (Standard_Integer i = 1; i <= NbCurves(); i++)
Curve(i)->Transform(T);
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void ShapeExtend_ComplexCurve::D0(const Standard_Real U,gp_Pnt& P) const
{
Standard_Real UOut;
Standard_Integer ind = LocateParameter (U, UOut);
Curve(ind)->D0(UOut, P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void ShapeExtend_ComplexCurve::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V1) const
{
Standard_Real UOut;
Standard_Integer ind = LocateParameter (U, UOut);
Curve(ind)->D1(UOut, P, V1);
TransformDN(V1,ind,1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void ShapeExtend_ComplexCurve::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
{
Standard_Real UOut;
Standard_Integer ind = LocateParameter (U, UOut);
Curve(ind)->D2(UOut, P, V1, V2);
TransformDN(V1,ind,1);
TransformDN(V2,ind,2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void ShapeExtend_ComplexCurve::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const
{
Standard_Real UOut;
Standard_Integer ind = LocateParameter (U, UOut);
Curve(ind)->D3(UOut, P, V1, V2, V3);
TransformDN(V1,ind,1);
TransformDN(V2,ind,2);
TransformDN(V3,ind,3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec ShapeExtend_ComplexCurve::DN(const Standard_Real U,const Standard_Integer N) const
{
Standard_Real UOut;
Standard_Integer ind = LocateParameter (U, UOut);
gp_Vec res = Curve(ind)->DN(UOut, N);
if(N)
TransformDN(res,ind,N);
return res;
}
//=======================================================================
//function : CheckConnectivity
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_ComplexCurve::CheckConnectivity (const Standard_Real Preci)
{
Standard_Integer NbC = NbCurves();
Standard_Boolean ok = Standard_True;
for (Standard_Integer i = 1; i < NbC; i++ ) {
if (i == 1) myClosed = Value (FirstParameter()).IsEqual (Value (LastParameter()), Preci);
ok &= Curve (i)->Value (Curve(i)->LastParameter()).IsEqual
(Curve (i + 1)->Value (Curve(i + 1)->FirstParameter()), Preci);
}
#ifdef DEB
if (!ok) cout << "Warning: ShapeExtend_ComplexCurve: not connected in 3d" << endl;
#endif
return ok;
}
//=======================================================================
//function : TransformDN
//purpose :
//=======================================================================
void ShapeExtend_ComplexCurve::TransformDN (gp_Vec& V,
const Standard_Integer ind,
const Standard_Integer N) const
{
Standard_Real fact = GetScaleFactor(ind);
for(Standard_Integer i = 1; i <= N; i++)
V*= fact;
}

View File

@@ -0,0 +1,76 @@
// File: ShapeExtend_ComplexCurve.lxx
// Created: Tue Jun 22 19:24:28 1999
// Author: Roman LYGIN
// <rln@kinox.nnov.matra-dtv.fr>
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
inline Standard_Real ShapeExtend_ComplexCurve::ReversedParameter(const Standard_Real U) const
{
return (1 - U);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
inline Standard_Real ShapeExtend_ComplexCurve::FirstParameter() const
{
return 0;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
inline Standard_Real ShapeExtend_ComplexCurve::LastParameter() const
{
return 1;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
inline Standard_Boolean ShapeExtend_ComplexCurve::IsClosed() const
{
return myClosed;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
inline Standard_Boolean ShapeExtend_ComplexCurve::IsPeriodic() const
{
return Standard_False;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
inline GeomAbs_Shape ShapeExtend_ComplexCurve::Continuity() const
{
return GeomAbs_C0;
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
inline Standard_Boolean ShapeExtend_ComplexCurve::IsCN(const Standard_Integer N) const
{
return N <=0;
}

View File

@@ -0,0 +1,305 @@
-- File: ShapeExtend_CompositeSurface.cdl
-- Created: Tue Apr 27 17:28:27 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov>
---Copyright: Matra Datavision 1999
class CompositeSurface from ShapeExtend inherits Surface from Geom
---Purpose: Composite surface is represented by a grid of surfaces
-- (patches) connected geometrically. Patches may have different
-- parametrisation ranges, but they should be parametrised in
-- the same manner so that parameter of each patch (u,v) can be converted
-- to global parameter on the whole surface (U,V) with help of linear
-- transformation:
--
-- for any i,j-th patch
-- U = Ui + ( u - uijmin ) * ( Ui+1 - Ui ) / ( uijmax - uijmin )
-- V = Vj + ( v - vijmin ) * ( Vj+1 - Vj ) / ( vijmax - vijmin )
--
-- where
--
-- [uijmin, uijmax] * [ vijmin, vijmax] - parametric range of i,j-th patch,
--
-- Ui (i=1,..,Nu+1), Vi (j=1,..,Nv+1) - values defining global
-- parametrisation by U and V (correspond to points between patches and
-- bounds, (Ui,Uj) corresponds to (uijmin,vijmin) on i,j-th patch) and to
-- (u(i-1)(j-1)max,v(i-1)(j-1)max) on (i-1),(j-1)-th patch.
--
-- Geometrical connectivity is expressed via global parameters:
-- S[i,j](Ui+1,V) = S[i+1,j](Ui+1,V) for any i, j, V
-- S[i,j](U,Vj+1) = S[i,j+1](U,Vj+1) for any i, j, U
-- It is checked with Precision::Confusion() by default.
--
-- NOTE 1: This class is inherited from Geom_Surface in order to
-- make it more easy to store and deal with it. However, it should
-- not be passed to standard methods dealing with geometry since
-- this type is not known to them.
-- NOTE 2: Not all the inherited methods are implemented, and some are
-- implemented not in the full form.
uses
Pnt2d from gp,
Pnt from gp,
Vec from gp,
Trsf from gp,
Trsf2d from gp,
Surface from Geom,
Curve from Geom,
Array1OfReal from TColStd,
HArray1OfReal from TColStd,
HArray2OfSurface from TColGeom,
Shape from GeomAbs,
Parametrisation from ShapeExtend
is
Create returns mutable CompositeSurface from ShapeExtend;
---Purpose: Empty constructor.
Create (GridSurf: HArray2OfSurface from TColGeom;
param : Parametrisation from ShapeExtend = ShapeExtend_Natural)
returns mutable CompositeSurface from ShapeExtend;
---Purpose: Initializes by a grid of surfaces (calls Init()).
Create (GridSurf: HArray2OfSurface from TColGeom;
UJoints, VJoints : Array1OfReal from TColStd)
returns mutable CompositeSurface from ShapeExtend;
---Purpose: Initializes by a grid of surfaces (calls Init()).
Init (me: mutable; GridSurf: HArray2OfSurface from TColGeom;
param : Parametrisation from ShapeExtend = ShapeExtend_Natural)
returns Boolean;
---Purpose: Initializes by a grid of surfaces.
-- All the Surfaces of the grid must have geometrical
-- connectivity as stated above.
-- If geometrical connectivity is not satisfied, method
-- returns False.
-- However, class is initialized even in that case.
--
-- Last parameter defines how global parametrisation
-- (joint values) will be computed:
-- ShapeExtend_Natural: U1 = u11min, Ui+1 = Ui + (ui1max-ui1min), etc.
-- ShapeExtend_Uniform: Ui = i-1, Vj = j-1
-- ShapeExtend_Unitary: Ui = (i-1)/Nu, Vi = (j-1)/Nv
Init (me: mutable; GridSurf: HArray2OfSurface from TColGeom;
UJoints, VJoints : Array1OfReal from TColStd)
returns Boolean;
---Purpose: Initializes by a grid of surfaces with given global
-- parametrisation defined by UJoints and VJoints arrays,
-- each having langth equal to number of patches in corresponding
-- direction + 1. Global joint values should be sorted in
-- increasing order.
-- All the Surfaces of the grid must have geometrical
-- connectivity as stated above.
-- If geometrical connectivity is not satisfied, method
-- returns False.
-- However, class is initialized even in that case.
NbUPatches (me) returns Integer;
---Purpose: Returns number of patches in U direction.
NbVPatches (me) returns Integer;
---Purpose: Returns number of patches in V direction.
Patch (me; i, j: Integer) returns Surface from Geom;
---C++: return const &
---Purpose: Returns one surface patch
Patches (me) returns HArray2OfSurface from TColGeom;
---C++: return const &
---Purpose: Returns grid of surfaces
UJointValues (me) returns HArray1OfReal from TColStd;
---Purpose: Returns the array of U values corresponding to joint
-- points between patches as well as to start and end points,
-- which define global parametrisation of the surface
VJointValues (me) returns HArray1OfReal from TColStd;
---Purpose: Returns the array of V values corresponding to joint
-- points between patches as well as to start and end points,
-- which define global parametrisation of the surface
UJointValue (me; i: Integer) returns Real;
---Purpose: Returns i-th joint value in U direction
-- (1-st is global Umin, (NbUPatches()+1)-th is global Umax
-- on the composite surface)
VJointValue (me; j: Integer) returns Real;
---Purpose: Returns j-th joint value in V direction
-- (1-st is global Vmin, (NbVPatches()+1)-th is global Vmax
-- on the composite surface)
SetUJointValues (me: mutable; UJoints: Array1OfReal from TColStd)
returns Boolean;
---Purpose: Sets the array of U values corresponding to joint
-- points, which define global parametrisation of the surface.
-- Number of values in array should be equal to NbUPatches()+1.
-- All the values should be sorted in increasing order.
-- If this is not satisfied, does nothing and returns False.
SetVJointValues (me: mutable; VJoints: Array1OfReal from TColStd)
returns Boolean;
---Purpose: Sets the array of V values corresponding to joint
-- points, which define global parametrisation of the surface
-- Number of values in array should be equal to NbVPatches()+1.
-- All the values should be sorted in increasing order.
-- If this is not satisfied, does nothing and returns False.
SetUFirstValue (me: mutable; UFirst: Real);
---Purpose: Changes starting value for global U parametrisation (all
-- other joint values are shifted accordingly)
SetVFirstValue (me: mutable; VFirst: Real);
---Purpose: Changes starting value for global V parametrisation (all
-- other joint values are shifted accordingly)
LocateUParameter(me; U: Real) returns Integer;
---Purpose: Returns number of col that contains given (global) parameter
LocateVParameter(me; V: Real) returns Integer;
---Purpose: Returns number of row that contains given (global) parameter
LocateUVPoint(me; pnt: Pnt2d from gp;
i : out Integer;
j : out Integer);
---Purpose: Returns number of row and col of surface that contains
-- given point
Patch(me; U, V: Real) returns Surface from Geom;
---C++: return const &
---Purpose: Returns one surface patch that contains given (global) parameters
Patch(me; pnt: Pnt2d from gp) returns Surface from Geom;
---C++: return const &
---Purpose: Returns one surface patch that contains given point
---Advanced: Work with local parameters on patches
ULocalToGlobal (me; i, j: Integer; u: Real) returns Real;
---Purpose: Converts local parameter u on patch i,j to global parameter U
VLocalToGlobal (me; i, j: Integer; v: Real) returns Real;
---Purpose: Converts local parameter v on patch i,j to global parameter V
LocalToGlobal (me; i, j: Integer; uv: Pnt2d from gp) returns Pnt2d from gp;
---Purpose: Converts local parameters uv on patch i,j to global parameters UV
UGlobalToLocal (me; i, j: Integer; U: Real) returns Real;
---Purpose: Converts global parameter U to local parameter u on patch i,j
VGlobalToLocal (me; i, j: Integer; V: Real) returns Real;
---Purpose: Converts global parameter V to local parameter v on patch i,j
GlobalToLocal (me; i, j: Integer; UV: Pnt2d from gp) returns Pnt2d from gp;
---Purpose: Converts global parameters UV to local parameters uv on patch i,j
GlobalToLocalTransformation (me; i, j : Integer;
uFact: out Real; Trsf: out Trsf2d from gp )
returns Boolean;
---Purpose: Computes transformation operator and uFactor descrinbing affine
-- transformation required to convert global parameters on composite
-- surface to local parameters on patch (i,j):
-- uv = ( uFactor, 1. ) X Trsf * UV;
-- NOTE: Thus Trsf contains shift and scale by V, scale by U is stored in uFact.
-- Returns True if transformation is not an identity
---Inherited: methods of Geom_Geometry and Geom_Surface
Transform (me : mutable; T : Trsf) is redefined;
---Purpose: Applies transformation to all the patches
Copy (me) returns mutable like me is redefined;
---Purpose: Returns a copy of the surface
UReverse (me : mutable) is redefined;
---Purpose: NOT IMPLEMENTED (does nothing)
UReversedParameter (me; U : Real) returns Real is redefined;
---Purpose: Returns U
VReverse (me : mutable) is redefined;
---Purpose: NOT IMPLEMENTED (does nothing)
VReversedParameter (me; V : Real) returns Real is redefined;
---Purpose: Returns V
Bounds(me; U1, U2, V1, V2 : out Real) is redefined;
---Purpose: Returns the parametric bounds of grid
IsUClosed (me) returns Boolean is redefined;
---Purpose: Returns True if grid is closed in U direction
-- (i.e. connected with Precision::Confusion)
IsVClosed (me) returns Boolean is redefined;
---Purpose: Returns True if grid is closed in V direction
-- (i.e. connected with Precision::Confusion)
IsUPeriodic (me) returns Boolean is redefined;
---Purpose: Returns False
IsVPeriodic (me) returns Boolean is redefined;
---Purpose: Returns False
UIso (me; U : Real) returns mutable Curve is redefined;
---Purpose: NOT IMPLEMENTED (returns Null curve)
VIso (me; V : Real) returns mutable Curve is redefined;
---Purpose: NOT IMPLEMENTED (returns Null curve)
Continuity (me) returns Shape from GeomAbs is redefined;
---Purpose: returns C0
IsCNu (me; N : Integer) returns Boolean is redefined;
---Purpose: returns True if N <=0
IsCNv (me; N : Integer) returns Boolean is redefined;
---Purpose: returns True if N <=0
D0 (me; U, V : Real; P : out Pnt) is redefined;
---Purpose: Computes the point of parameter U,V on the grid.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec) is redefined;
---Purpose: Computes the point P and the first derivatives in the
-- directions U and V at this point.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec) is redefined;
---Purpose: Computes the point P, the first and the second derivatives in
-- the directions U and V at this point.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV: out Vec) is redefined;
---Purpose: Computes the point P, the first,the second and the third
-- derivatives in the directions U and V at this point.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec is redefined;
---Purpose: Computes the derivative of order Nu in the direction U and Nv
-- in the direction V at the point P(U, V).
Value(me; pnt: Pnt2d from gp) returns Pnt from gp;
---Purpose: Computes the point of parameter pnt on the grid.
---Private: internal methods
ComputeJointValues (me: mutable; param : Parametrisation from ShapeExtend = ShapeExtend_Natural);
---Purpose: Computes Joint values according to parameter
CheckConnectivity (me: mutable; prec: Real) returns Boolean;
---Purpose: Checks geometrical connectivity of the patches, including
-- closedness (sets fields muUClosed and myVClosed)
fields
myPatches : HArray2OfSurface from TColGeom;
myUJointValues: HArray1OfReal from TColStd;
myVJointValues: HArray1OfReal from TColStd;
myUClosed : Boolean; -- closedness (periodicity) measured with Precision::Confusion()
myVClosed : Boolean;
end;

View File

@@ -0,0 +1,823 @@
// File: ShapeExtend_CompositeSurface.cxx
// Created: Tue Apr 27 16:17:25 1999
// Author: Pavel DURANDIN
// <pdn@friendox.nnov.matra-dtv.fr>
#include <ShapeExtend_CompositeSurface.ixx>
#include <Precision.hxx>
//=======================================================================
//function : ShapeExtend_CompositeSurface
//purpose :
//=======================================================================
ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface()
{
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
const ShapeExtend_Parametrisation param)
{
Init ( GridSurf, param );
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
const TColStd_Array1OfReal &UJoints,
const TColStd_Array1OfReal &VJoints)
{
Init ( GridSurf, UJoints, VJoints );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::Init (const Handle(TColGeom_HArray2OfSurface)& GridSurf,
const ShapeExtend_Parametrisation param)
{
if ( GridSurf.IsNull() ) return Standard_False;
myPatches = GridSurf;
ComputeJointValues ( param );
return CheckConnectivity ( Precision::Confusion() );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::Init (const Handle(TColGeom_HArray2OfSurface)& GridSurf,
const TColStd_Array1OfReal &UJoints,
const TColStd_Array1OfReal &VJoints)
{
if ( GridSurf.IsNull() ) return Standard_False;
myPatches = GridSurf;
Standard_Boolean ok = Standard_True;
if ( ! SetUJointValues ( UJoints ) || ! SetVJointValues ( VJoints ) ) {
ok = Standard_False;
ComputeJointValues ( ShapeExtend_Natural );
#ifdef DEB
cout << "Warning: ShapeExtend_CompositeSurface::Init: bad joint values" << endl;
#endif
}
return ( CheckConnectivity ( Precision::Confusion() ) ? ok : Standard_False );
}
//=======================================================================
//function : NbUPatches
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_CompositeSurface::NbUPatches() const
{
return myPatches->ColLength();
}
//=======================================================================
//function : NbVPatches
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_CompositeSurface::NbVPatches() const
{
return myPatches->RowLength();
}
//=======================================================================
//function : Patch
//purpose :
//=======================================================================
const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const Standard_Integer i,
const Standard_Integer j) const
{
return myPatches->Value(i,j);
}
//=======================================================================
//function : Patches
//purpose :
//=======================================================================
const Handle(TColGeom_HArray2OfSurface)& ShapeExtend_CompositeSurface::Patches() const
{
return myPatches;
}
//=======================================================================
//function : UJointValues
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) ShapeExtend_CompositeSurface::UJointValues() const
{
return myUJointValues;
}
//=======================================================================
//function : VJointValues
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) ShapeExtend_CompositeSurface::VJointValues() const
{
return myVJointValues;
}
//=======================================================================
//function : UJointValue
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::UJointValue(const Standard_Integer i) const
{
return myUJointValues->Value(i);
}
//=======================================================================
//function : VJointValue
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::VJointValue(const Standard_Integer i) const
{
return myVJointValues->Value(i);
}
//=======================================================================
//function : SetUJointValues
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::SetUJointValues (const TColStd_Array1OfReal &UJoints)
{
Standard_Integer NbU = NbUPatches();
if ( UJoints.Length() != NbU+1 ) return Standard_False;
Handle(TColStd_HArray1OfReal) UJointValues = new TColStd_HArray1OfReal(1,NbU+1);
for ( Standard_Integer i=1, j=UJoints.Lower(); i <= NbU+1; i++, j++ ) {
UJointValues->SetValue ( i, UJoints(j) );
if ( i >1 && UJoints(j) - UJoints(j-1) < Precision::PConfusion() )
return Standard_False;
}
myUJointValues = UJointValues;
return Standard_True;
}
//=======================================================================
//function : SetVJointValues
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::SetVJointValues (const TColStd_Array1OfReal &VJoints)
{
Standard_Integer NbV = NbVPatches();
if ( VJoints.Length() != NbV+1 ) return Standard_False;
Handle(TColStd_HArray1OfReal) VJointValues = new TColStd_HArray1OfReal(1,NbV+1);
for ( Standard_Integer i=1, j=VJoints.Lower(); i <= NbV+1; i++, j++ ) {
VJointValues->SetValue ( i, VJoints(j) );
if ( i >1 && VJoints(j) - VJoints(j-1) < Precision::PConfusion() )
return Standard_False;
}
myVJointValues = VJointValues;
return Standard_True;
}
//=======================================================================
//function : SetUFirstValue
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::SetUFirstValue (const Standard_Real UFirst)
{
if ( myUJointValues.IsNull() ) return;
Standard_Real shift = UFirst - myUJointValues->Value(1);
Standard_Integer NbU = myUJointValues->Length();
for ( Standard_Integer i=1; i <= NbU; i++ ) {
myUJointValues->SetValue ( i, myUJointValues->Value(i) + shift );
}
}
//=======================================================================
//function : SetVFirstValue
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::SetVFirstValue (const Standard_Real VFirst)
{
if ( myVJointValues.IsNull() ) return;
Standard_Real shift = VFirst - myVJointValues->Value(1);
Standard_Integer NbV = myVJointValues->Length();
for ( Standard_Integer i=1; i <= NbV; i++ ) {
myVJointValues->SetValue ( i, myVJointValues->Value(i) + shift );
}
}
//=======================================================================
//function : LocateUParameter
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_CompositeSurface::LocateUParameter(const Standard_Real U) const
{
Standard_Integer nbPatch = NbUPatches();
for(Standard_Integer i = 2; i <= nbPatch; i++)
if (U < myUJointValues->Value(i)) return i-1;
return nbPatch;
}
//=======================================================================
//function : LocateVParameter
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_CompositeSurface::LocateVParameter(const Standard_Real V) const
{
Standard_Integer nbPatch = NbVPatches();
for(Standard_Integer i = 2; i <= nbPatch; i++)
if (V < myVJointValues->Value(i)) return i-1;
return nbPatch;
}
//=======================================================================
//function : LocateUVPoint
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::LocateUVPoint(const gp_Pnt2d& pnt,
Standard_Integer& i,
Standard_Integer& j) const
{
i = LocateUParameter(pnt.X());
j = LocateVParameter(pnt.Y());
}
//=======================================================================
//function : Patch
//purpose :
//=======================================================================
const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const Standard_Real U,
const Standard_Real V) const
{
return myPatches->Value ( LocateUParameter(U), LocateVParameter(V) );
}
//=======================================================================
//function : Patch
//purpose :
//=======================================================================
const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const gp_Pnt2d& pnt) const
{
return myPatches->Value ( LocateUParameter(pnt.X()), LocateVParameter(pnt.Y()) );
}
//=======================================================================
//function : ULocalToGlobal
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::ULocalToGlobal (const Standard_Integer i,
const Standard_Integer j,
const Standard_Real u) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scale = ( myUJointValues->Value(i+1) - myUJointValues->Value(i) ) / ( u2 - u1 );
return u * scale + ( myUJointValues->Value(i) - u1 * scale ); // ! this formula is stable if u1 is infinite
}
//=======================================================================
//function : VLocalToGlobal
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::VLocalToGlobal (const Standard_Integer i,
const Standard_Integer j,
const Standard_Real v) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scale = ( myVJointValues->Value(j+1) - myVJointValues->Value(j) ) / ( v2 - v1 );
return v * scale + ( myVJointValues->Value(j) - v1 * scale ); // ! this formula is stable if v1 is infinite
}
//=======================================================================
//function : LocalToGlobal
//purpose :
//=======================================================================
gp_Pnt2d ShapeExtend_CompositeSurface::LocalToGlobal (const Standard_Integer i,
const Standard_Integer j,
const gp_Pnt2d &uv) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scaleu = ( myUJointValues->Value(i+1) - myUJointValues->Value(i) ) / ( u2 - u1 );
Standard_Real scalev = ( myVJointValues->Value(j+1) - myVJointValues->Value(j) ) / ( v2 - v1 );
return gp_Pnt2d ( uv.X() * scaleu + ( myUJointValues->Value(i) - u1 * scaleu ), // ! this formula is stable if u1 or v1 is infinite
uv.Y() * scalev + ( myVJointValues->Value(j) - v1 * scalev ) );
}
//=======================================================================
//function : UGlobalToLocal
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::UGlobalToLocal (const Standard_Integer i,
const Standard_Integer j,
const Standard_Real U) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scale = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
return U * scale + ( u1 - myUJointValues->Value(i) * scale ); // ! this formula is stable if u1 is infinite
}
//=======================================================================
//function : VGlobalToLocal
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::VGlobalToLocal (const Standard_Integer i,
const Standard_Integer j,
const Standard_Real V) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scale = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
return V * scale + ( v1 - myVJointValues->Value(j) * scale ); // ! this formula is stable if v1 is infinite
}
//=======================================================================
//function : GlobalToLocal
//purpose :
//=======================================================================
gp_Pnt2d ShapeExtend_CompositeSurface::GlobalToLocal (const Standard_Integer i,
const Standard_Integer j,
const gp_Pnt2d &UV) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scaleu = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
Standard_Real scalev = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
return gp_Pnt2d ( UV.X() * scaleu + ( u1 - myUJointValues->Value(i) * scaleu ), // ! this formula is stable if u1 or v1 is infinite
UV.Y() * scalev + ( v1 - myVJointValues->Value(j) * scalev ) );
}
//=======================================================================
//function : GlobalToLocalTransformation
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::GlobalToLocalTransformation (const Standard_Integer i,
const Standard_Integer j,
Standard_Real &uFact,
gp_Trsf2d &Trsf) const
{
Standard_Real u1, u2, v1, v2;
myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
Standard_Real scaleu = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
Standard_Real scalev = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
gp_Vec2d shift ( u1 / scaleu - myUJointValues->Value(i),
v1 / scalev - myVJointValues->Value(j) );
uFact = scaleu / scalev;
gp_Trsf2d Shift, Scale;
if ( shift.X() != 0. || shift.Y() != 0. ) Shift.SetTranslation ( shift );
if ( scalev != 1. ) Scale.SetScale ( gp_Pnt2d(0,0), scalev );
Trsf = Scale * Shift;
return uFact != 1. || Trsf.Form() != gp_Identity;
}
//=======================================================================
// Inherited methods (from Geom_Geometry and Geom_Surface)
//=======================================================================
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::Transform (const gp_Trsf &T)
{
if ( myPatches.IsNull() ) return;
for ( Standard_Integer i=1; i <= NbUPatches(); i++ )
for ( Standard_Integer j=1; j <= NbVPatches(); j++ )
Patch(i,j)->Transform ( T );
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) ShapeExtend_CompositeSurface::Copy () const
{
Handle(ShapeExtend_CompositeSurface) surf = new ShapeExtend_CompositeSurface;
if ( myPatches.IsNull() ) return surf;
Handle(TColGeom_HArray2OfSurface) patches =
new TColGeom_HArray2OfSurface ( 1, NbUPatches(), 1, NbVPatches() );
for ( Standard_Integer i=1; i <= NbUPatches(); i++ )
for ( Standard_Integer j=1; j <= NbVPatches(); j++ )
patches->SetValue ( i, j, Handle(Geom_Surface)::DownCast ( Patch(i,j)->Copy() ) );
surf->Init ( patches );
return surf;
}
//=======================================================================
//function : UReverse
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::UReverse ()
{
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::UReversedParameter (const Standard_Real U) const
{
return U;
}
//=======================================================================
//function : VReverse
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::VReverse ()
{
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real ShapeExtend_CompositeSurface::VReversedParameter (const Standard_Real V) const
{
return V;
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::Bounds(Standard_Real& U1,
Standard_Real& U2,
Standard_Real& V1,
Standard_Real& V2) const
{
U1 = UJointValue(1);
V1 = VJointValue(1);
U2 = UJointValue(NbUPatches()+1);
V2 = VJointValue(NbVPatches()+1);
}
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::IsUPeriodic () const
{
return Standard_False;
}
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::IsVPeriodic () const
{
return Standard_False;
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) ShapeExtend_CompositeSurface::UIso (const Standard_Real ) const
{
Handle(Geom_Curve) dummy;
return dummy;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Geom_Curve) ShapeExtend_CompositeSurface::VIso (const Standard_Real ) const
{
Handle(Geom_Curve) dummy;
return dummy;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape ShapeExtend_CompositeSurface::Continuity () const
{
return GeomAbs_C0;
}
//=======================================================================
//function : IsCNu
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::IsCNu (const Standard_Integer N) const
{
return N <=0;
}
//=======================================================================
//function : IsCNv
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::IsCNv (const Standard_Integer N) const
{
return N <=0;
}
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::IsUClosed () const
{
return myUClosed;
}
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_CompositeSurface::IsVClosed () const
{
return myVClosed;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::D0 (const Standard_Real U,
const Standard_Real V,
gp_Pnt& P) const
{
Standard_Integer i = LocateUParameter ( U );
Standard_Integer j = LocateVParameter ( V );
gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
myPatches->Value(i,j)->D0 ( uv.X(), uv.Y(), P );
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::D1 (const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V) const
{
Standard_Integer i = LocateUParameter ( U );
Standard_Integer j = LocateVParameter ( V );
gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
myPatches->Value(i,j)->D1 ( uv.X(), uv.Y(), P, D1U, D1V );
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::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_Integer i = LocateUParameter ( U );
Standard_Integer j = LocateVParameter ( V );
gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
myPatches->Value(i,j)->D2 ( uv.X(), uv.Y(), P, D1U, D1V, D2U, D2V, D2UV );
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::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_Integer i = LocateUParameter ( U );
Standard_Integer j = LocateVParameter ( V );
gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
myPatches->Value(i,j)->D3 ( uv.X(), uv.Y(), P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV );
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec ShapeExtend_CompositeSurface::DN (const Standard_Real U,
const Standard_Real V,
const Standard_Integer Nu,
const Standard_Integer Nv) const
{
Standard_Integer i = LocateUParameter ( U );
Standard_Integer j = LocateVParameter ( V );
gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
return myPatches->Value(i,j)->DN ( uv.X(), uv.Y(), Nu, Nv );
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
gp_Pnt ShapeExtend_CompositeSurface::Value (const gp_Pnt2d& pnt) const
{
Standard_Integer i = LocateUParameter ( pnt.X() );
Standard_Integer j = LocateVParameter ( pnt.Y() );
gp_Pnt2d uv = GlobalToLocal ( i, j, pnt );
gp_Pnt point;
myPatches->Value(i,j)->D0 ( uv.X(), uv.Y(), point );
return point;
}
//=======================================================================
//function : ComputeJointValues
//purpose :
//=======================================================================
void ShapeExtend_CompositeSurface::ComputeJointValues (const ShapeExtend_Parametrisation param)
{
Standard_Integer NbU = NbUPatches();
Standard_Integer NbV = NbVPatches();
myUJointValues = new TColStd_HArray1OfReal(1,NbU+1);
myVJointValues = new TColStd_HArray1OfReal(1,NbV+1);
if ( param == ShapeExtend_Natural ) {
Standard_Real U1, U2, V1, V2, U=0, V=0;
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
for ( i = 1; i <= NbU; i++ ) {
myPatches->Value(i,1)->Bounds(U1,U2,V1,V2);
if ( i ==1 ) myUJointValues->SetValue ( 1, U = U1 );
U += ( U2 - U1 );
myUJointValues->SetValue ( i+1, U );
}
for ( i = 1; i <= NbV; i++ ) {
myPatches->Value(1,i)->Bounds(U1,U2,V1,V2);
if ( i ==1 ) myVJointValues->SetValue ( 1, V = V1 );
V += ( V2 - V1 );
myVJointValues->SetValue ( i+1, V );
}
}
else {
Standard_Real stepu = 1., stepv = 1.; // suppose param == ShapeExtend_Uniform
if ( param == ShapeExtend_Unitary ) {
stepu /= NbU;
stepv /= NbV;
}
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
for ( i=0; i <= NbU; i++ )
myUJointValues->SetValue ( i+1, i * stepu );
for ( i=0; i <= NbV; i++ )
myVJointValues->SetValue ( i+1, i * stepv );
}
}
//=======================================================================
//function : CheckConnectivity
//purpose :
//=======================================================================
static inline Standard_Real LimitValue (const Standard_Real &par)
{
return Precision::IsInfinite(par) ? ( par <0 ? -10000. : 10000. ) : par;
}
static void GetLimitedBounds (const Handle(Geom_Surface) &surf,
Standard_Real &U1, Standard_Real &U2,
Standard_Real &V1, Standard_Real &V2)
{
surf->Bounds ( U1, U2, V1, V2 );
U1 = LimitValue ( U1 );
U2 = LimitValue ( U2 );
V1 = LimitValue ( V1 );
V2 = LimitValue ( V2 );
}
Standard_Boolean ShapeExtend_CompositeSurface::CheckConnectivity (const Standard_Real Prec)
{
const Standard_Integer NPOINTS = 23;
Standard_Boolean ok = Standard_True;
Standard_Integer NbU = NbUPatches();
Standard_Integer NbV = NbVPatches();
// check in u direction
Standard_Integer i,j; // svv Jan 10 2000 : porting on DEC
for ( i=1, j = NbU; i <= NbU; j = i++ ) {
Standard_Real maxdist2 = 0.;
for ( Standard_Integer k=1; k <= NbV; k++ ) {
Handle(Geom_Surface) sj = myPatches->Value(j,k);
Handle(Geom_Surface) si = myPatches->Value(i,k);
Standard_Real Uj1, Uj2, Vj1, Vj2;
GetLimitedBounds ( sj, Uj1, Uj2, Vj1, Vj2 );
Standard_Real Ui1, Ui2, Vi1, Vi2;
GetLimitedBounds ( si, Ui1, Ui2, Vi1, Vi2 );
Standard_Real stepj = ( Vj2 - Vj1 ) / ( NPOINTS - 1 );
Standard_Real stepi = ( Vi2 - Vi1 ) / ( NPOINTS - 1 );
for ( Standard_Integer isample=0; isample < NPOINTS; isample++ ) {
Standard_Real parj = Vj1 + stepj * isample;
Standard_Real pari = Vi1 + stepi * isample;
Standard_Real dist2 = sj->Value ( Uj2, parj ).SquareDistance ( si->Value ( Ui1, pari ) );
if ( maxdist2 < dist2 ) maxdist2 = dist2;
}
}
if ( i==1 ) myUClosed = ( maxdist2 <= Prec*Prec );
else if ( maxdist2 > Prec*Prec ) ok = Standard_False;
}
// check in v direction
for ( i=1, j = NbV; i <= NbV; j = i++ ) {
Standard_Real maxdist2 = 0.;
for ( Standard_Integer k=1; k <= NbU; k++ ) {
Handle(Geom_Surface) sj = myPatches->Value(k,j);
Handle(Geom_Surface) si = myPatches->Value(k,i);
Standard_Real Uj1, Uj2, Vj1, Vj2;
GetLimitedBounds ( sj, Uj1, Uj2, Vj1, Vj2 );
Standard_Real Ui1, Ui2, Vi1, Vi2;
GetLimitedBounds ( si, Ui1, Ui2, Vi1, Vi2 );
Standard_Real stepj = ( Uj2 - Uj1 ) / ( NPOINTS - 1 );
Standard_Real stepi = ( Ui2 - Ui1 ) / ( NPOINTS - 1 );
for ( Standard_Integer isample=0; isample < NPOINTS; isample++ ) {
Standard_Real parj = Uj1 + stepj * isample;
Standard_Real pari = Ui1 + stepi * isample;
Standard_Real dist2 = sj->Value ( parj, Vj2 ).SquareDistance ( si->Value ( pari, Vi1 ) );
if ( maxdist2 < dist2 ) maxdist2 = dist2;
}
}
if ( i==1 ) myVClosed = ( maxdist2 <= Prec*Prec );
else if ( maxdist2 > Prec*Prec ) ok = Standard_False;
}
#ifdef DEB
if ( ! ok ) cout << "Warning: ShapeExtend_CompositeSurface: not connected in 3d" << endl;
#endif
return ok;
}

View File

@@ -0,0 +1,86 @@
-- File: ShapeExtend_Explorer.cdl
-- Created: Wed Jun 3 12:42:52 1998
-- Author: data exchange team
-- <det@loufox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class Explorer from ShapeExtend
---Purpose: This class is intended to
-- explore shapes and convert different representations
-- (list, sequence, compound) of complex shapes. It provides tools for:
-- - obtaining type of the shapes in context of TopoDS_Compound,
-- - exploring shapes in context of TopoDS_Compound,
-- - converting different representations of shapes (list, sequence, compound).
uses
Shape from TopoDS,
ShapeEnum from TopAbs,
HSequenceOfShape from TopTools,
ListOfShape from TopTools
raises
TypeMismatch from Standard
is
Create returns Explorer from ShapeExtend;
---Purpose: Creates an object Explorer
CompoundFromSeq (me; seqval: HSequenceOfShape)
returns Shape from TopoDS;
---Purpose: Converts a sequence of Shapes to a Compound
SeqFromCompound (me; comp: Shape from TopoDS; expcomp: Boolean)
returns HSequenceOfShape;
---Purpose: Converts a Compound to a list of Shapes
-- if <comp> is not a compound, the list contains only <comp>
-- if <comp> is Null, the list is empty
-- if <comp> is a Compound, its sub-shapes are put into the list
-- then if <expcomp> is True, if a sub-shape is a Compound, it
-- is not put to the list but its sub-shapes are (recursive)
ListFromSeq (me; seqval: HSequenceOfShape;
lisval: in out ListOfShape from TopTools;
clear: Boolean = Standard_True);
---Purpose: Converts a Sequence of Shapes to a List of Shapes
-- <clear> if True (D), commands the list to start from scratch
-- else, the list is cumulated
SeqFromList (me; lisval: ListOfShape)
returns HSequenceOfShape from TopTools;
---Purpose: Converts a List of Shapes to a Sequence of Shapes
ShapeType (me; shape: Shape from TopoDS; compound: Boolean)
returns ShapeEnum;
---Purpose: Returns the type of a Shape: true type if <compound> is False
-- If <compound> is True and <shape> is a Compound, iterates on
-- its items. If all are of the same type, returns this type.
-- Else, returns COMPOUND. If it is empty, returns SHAPE
-- For a Null Shape, returns SHAPE
SortedCompound (me; shape: Shape from TopoDS; type: ShapeEnum;
explore: Boolean; compound: Boolean)
returns Shape from TopoDS;
---Purpose: Builds a COMPOUND from the given shape.
-- It explores the shape level by level, according to the
-- <explore> argument. If <explore> is False, only COMPOUND
-- items are explored, else all items are.
-- The following shapes are added to resulting compound:
-- - shapes which comply to <type>
-- - if <type> is WIRE, considers also free edges (and makes wires)
-- - if <type> is SHELL, considers also free faces (and makes shells)
-- If <compound> is True, gathers items in compounds which
-- correspond to starting COMPOUND,SOLID or SHELL containers, or
-- items directly contained in a Compound
DispatchList (me; list: HSequenceOfShape;
vertices, edges, wires, faces, shells, solids, compsols, compounds:
in out HSequenceOfShape);
---Purpose: Dispatches starting list of shapes according to their type,
-- to the appropriate resulting lists
-- For each of these lists, if it is null, it is firstly created
-- else, new items are appended to the already existing ones
end Explorer;

View File

@@ -0,0 +1,253 @@
//szv#4 S4163
#include <ShapeExtend_Explorer.ixx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <BRep_Builder.hxx>
//=======================================================================
//function : ShapeExtend_Explorer
//purpose :
//=======================================================================
ShapeExtend_Explorer::ShapeExtend_Explorer()
{
}
//=======================================================================
//function : CompoundFromSeq
//purpose :
//=======================================================================
TopoDS_Shape ShapeExtend_Explorer::CompoundFromSeq
(const Handle(TopTools_HSequenceOfShape)& seqval) const
{
BRep_Builder B;
TopoDS_Compound C;
B.MakeCompound(C);
Standard_Integer i,n = seqval->Length();
for (i = 1; i <= n ; i ++) B.Add(C,seqval->Value(i));
return C;
}
//=======================================================================
//function : SeqFromCompound
//purpose :
//=======================================================================
static void FillList (const Handle(TopTools_HSequenceOfShape)& list,
const TopoDS_Shape& comp, const Standard_Boolean expcomp)
{
for (TopoDS_Iterator it (comp); it.More(); it.Next()) {
TopoDS_Shape sub = it.Value();
if (sub.ShapeType() != TopAbs_COMPOUND) list->Append (sub);
else if (!expcomp) list->Append (sub);
else FillList (list,sub,expcomp);
}
}
Handle(TopTools_HSequenceOfShape) ShapeExtend_Explorer::SeqFromCompound
(const TopoDS_Shape& comp, const Standard_Boolean expcomp) const
{
Handle(TopTools_HSequenceOfShape) list = new TopTools_HSequenceOfShape();
if (comp.IsNull()) return list;
if (comp.ShapeType() != TopAbs_COMPOUND) {
list->Append (comp);
return list;
}
FillList (list,comp,expcomp);
return list;
}
//=======================================================================
//function : ListFromSeq
//purpose :
//=======================================================================
void ShapeExtend_Explorer::ListFromSeq (const Handle(TopTools_HSequenceOfShape)& seqval,
TopTools_ListOfShape& lisval,
const Standard_Boolean clear) const
{
if (clear) lisval.Clear();
if (seqval.IsNull()) return;
Standard_Integer i, nb = seqval->Length();
for (i = 1; i <= nb; i ++) lisval.Append (seqval->Value(i));
}
//=======================================================================
//function : SeqFromList
//purpose :
//=======================================================================
Handle(TopTools_HSequenceOfShape) ShapeExtend_Explorer::SeqFromList
(const TopTools_ListOfShape& lisval) const
{
Handle(TopTools_HSequenceOfShape) seqval = new TopTools_HSequenceOfShape();
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(lisval); it.More(); it.Next()) seqval->Append (it.Value());
return seqval;
}
//=======================================================================
//function : ShapeType
//purpose :
//=======================================================================
TopAbs_ShapeEnum ShapeExtend_Explorer::ShapeType (const TopoDS_Shape& shape,
const Standard_Boolean compound) const
{
if (shape.IsNull()) return TopAbs_SHAPE;
TopAbs_ShapeEnum res = shape.ShapeType();
if (!compound || res != TopAbs_COMPOUND) return res;
res = TopAbs_SHAPE;
for (TopoDS_Iterator iter(shape); iter.More(); iter.Next()) {
TopoDS_Shape sh = iter.Value();
if (sh.IsNull()) continue;
TopAbs_ShapeEnum typ = sh.ShapeType();
if (typ == TopAbs_COMPOUND) typ = ShapeType (sh,compound);
if (res == TopAbs_SHAPE) res = typ;
// Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL
else if (res == TopAbs_EDGE && typ == TopAbs_WIRE) res = typ;
else if (res == TopAbs_WIRE && typ == TopAbs_EDGE) continue;
else if (res == TopAbs_FACE && typ == TopAbs_SHELL) res = typ;
else if (res == TopAbs_SHELL && typ == TopAbs_FACE) continue;
else if (res != typ) return TopAbs_COMPOUND;
}
return res;
}
//=======================================================================
//function : SortedCompound
//purpose :
//=======================================================================
TopoDS_Shape ShapeExtend_Explorer::SortedCompound (const TopoDS_Shape& shape,
const TopAbs_ShapeEnum type,
const Standard_Boolean explore,
const Standard_Boolean compound) const
{
if (shape.IsNull()) return shape;
TopAbs_ShapeEnum typ = shape.ShapeType();
TopoDS_Shape sh, sh0;
Standard_Integer nb = 0;
// Compound : on le prend, soit tel quel, soit son contenu
if (typ == TopAbs_COMPOUND || typ == TopAbs_COMPSOLID) {
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound (C);
for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
sh0 = SortedCompound (it.Value(),type,explore,compound);
if (sh0.IsNull()) continue;
sh = sh0;
typ = sh.ShapeType();
if (typ == TopAbs_COMPOUND && !compound) {
for (TopoDS_Iterator it2 (sh); it2.More(); it2.Next())
{ nb ++; sh = it2.Value(); B.Add (C, sh); }
}
else { nb ++; B.Add (C,sh); }
}
if (nb == 0) C.Nullify();
else if (nb == 1) return sh;
return C;
}
// Egalite : OK; Pseudo-Egalite : EDGE/WIRE ou FACE/SHELL
if (typ == type) return shape;
if (typ == TopAbs_EDGE && type == TopAbs_WIRE) {
BRep_Builder B;
TopoDS_Wire W;
B.MakeWire (W);
B.Add (W,shape);
return W;
}
if (typ == TopAbs_FACE && type == TopAbs_SHELL) {
BRep_Builder B;
TopoDS_Shell S;
B.MakeShell (S);
B.Add (S,shape);
return S;
}
// Le reste : selon exploration
if (!explore) {
TopoDS_Shape nulsh;
return nulsh;
}
// Ici, on doit explorer
// SOLID + mode COMPOUND : reconduire les SHELLs
if (typ == TopAbs_SOLID && compound) {
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound (C);
for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
sh0 = SortedCompound (it.Value(),type,explore,compound);
if (sh0.IsNull()) continue;
sh = sh0;
nb ++; B.Add (C,sh);
}
if (nb == 0) C.Nullify();
else if (nb == 1) return sh;
return C;
}
// Exploration classique
TopoDS_Compound CC;
BRep_Builder BB;
BB.MakeCompound(CC);
//Standard_Integer iena = Standard_False; //szv#4:S4163:12Mar99 unused
for (TopExp_Explorer expl (shape,type); expl.More(); expl.Next()) {
nb ++; sh = expl.Current();
BB.Add (CC,sh);
}
if (nb == 0) CC.Nullify();
else if (nb == 1) return sh;
return CC;
}
//=======================================================================
//function : DispatchList
//purpose :
//=======================================================================
void ShapeExtend_Explorer::DispatchList (const Handle(TopTools_HSequenceOfShape)& list,
Handle(TopTools_HSequenceOfShape)& vertices,
Handle(TopTools_HSequenceOfShape)& edges,
Handle(TopTools_HSequenceOfShape)& wires,
Handle(TopTools_HSequenceOfShape)& faces,
Handle(TopTools_HSequenceOfShape)& shells,
Handle(TopTools_HSequenceOfShape)& solids,
Handle(TopTools_HSequenceOfShape)& compsols,
Handle(TopTools_HSequenceOfShape)& compounds) const
{
if (list.IsNull()) return;
if (vertices.IsNull()) vertices = new TopTools_HSequenceOfShape();
if (edges.IsNull()) edges = new TopTools_HSequenceOfShape();
if (wires.IsNull()) wires = new TopTools_HSequenceOfShape();
if (faces.IsNull()) faces = new TopTools_HSequenceOfShape();
if (shells.IsNull()) shells = new TopTools_HSequenceOfShape();
if (solids.IsNull()) solids = new TopTools_HSequenceOfShape();
if (compsols.IsNull()) compsols = new TopTools_HSequenceOfShape();
if (compounds.IsNull()) compounds = new TopTools_HSequenceOfShape();
Standard_Integer i,nb = list->Length();
for (i = 1; i <= nb; i ++) {
TopoDS_Shape sh = list->Value(i);
if (sh.IsNull()) continue;
switch (sh.ShapeType()) {
case TopAbs_VERTEX : vertices->Append(sh); break;
case TopAbs_EDGE : edges->Append(sh); break;
case TopAbs_WIRE : wires->Append(sh); break;
case TopAbs_FACE : faces->Append(sh); break;
case TopAbs_SHELL : shells->Append(sh); break;
case TopAbs_SOLID : solids->Append(sh); break;
case TopAbs_COMPSOLID : compsols->Append(sh); break;
case TopAbs_COMPOUND : compounds->Append(sh); break;
default : break;
}
}
}

View File

@@ -0,0 +1,63 @@
-- File: ShapeExtend_MsgRegistrator.cdl
-- Created: Fri Jan 28 19:56:33 2000
-- Author: data exchange team
-- <det@kinox>
---Copyright: Matra Datavision 2000
class MsgRegistrator from ShapeExtend inherits BasicMsgRegistrator from ShapeExtend
---Purpose: Attaches messages to the objects (generic Transient or shape).
-- The objects of this class are transmitted to the Shape Healing
-- algorithms so that they could collect messages occurred during
-- processing.
--
-- Messages are added to the Maps (stored as a field) that can be
-- used, for instance, by Data Exchange processors to attach those
-- messages to initial file entities.
uses
Shape from TopoDS,
Gravity from Message,
Msg from Message,
ListOfMsg from Message,
DataMapOfTransientListOfMsg from ShapeExtend,
DataMapOfShapeListOfMsg from ShapeExtend
is
Create returns mutable MsgRegistrator from ShapeExtend;
---Purpose: Creates an object.
Send (me: mutable; object : Transient;
message: Msg from Message;
gravity: Gravity from Message) is redefined;
---Purpose: Sends a message to be attached to the object.
-- If the object is in the map then the message is added to the
-- list, otherwise the object is firstly added to the map.
Send (me: mutable; shape : Shape from TopoDS;
message: Msg from Message;
gravity: Gravity from Message) is redefined;
---Purpose: Sends a message to be attached to the shape.
-- If the shape is in the map then the message is added to the
-- list, otherwise the shape is firstly added to the map.
MapTransient (me) returns DataMapOfTransientListOfMsg from ShapeExtend;
---C++ : inline
---C++ : return const&
---Purpose: Returns a Map of objects and message list
MapShape (me) returns DataMapOfShapeListOfMsg from ShapeExtend;
---C++ : inline
---C++ : return const&
---Purpose: Returns a Map of shapes and message list
fields
myMapTransient: DataMapOfTransientListOfMsg from ShapeExtend;
myMapShape: DataMapOfShapeListOfMsg from ShapeExtend;
end MsgRegistrator;

View File

@@ -0,0 +1,70 @@
// File: ShapeExtend_MsgRegistrator.cxx
// Created: Mon Jan 31 13:20:23 2000
// Author: data exchange team
// <det@kinox>
#include <ShapeExtend_MsgRegistrator.ixx>
#include <Message_ListOfMsg.hxx>
//=======================================================================
//function : ShapeExtend_MsgRegistrator
//purpose :
//=======================================================================
ShapeExtend_MsgRegistrator::ShapeExtend_MsgRegistrator() : ShapeExtend_BasicMsgRegistrator()
{
}
//=======================================================================
//function : Send
//purpose :
//=======================================================================
void ShapeExtend_MsgRegistrator::Send(const Handle(Standard_Transient)& object,
const Message_Msg& message,
const Message_Gravity)
{
if (object.IsNull()) {
#ifdef DEB
cout << "Warning: ShapeExtend_MsgRegistrator::Send: null object" << endl;
#endif
return;
}
if (myMapTransient.IsBound (object)) {
Message_ListOfMsg& list = myMapTransient.ChangeFind (object);
list.Append (message);
}
else {
Message_ListOfMsg list;
list.Append (message);
myMapTransient.Bind (object, list);
}
}
//=======================================================================
//function : Send
//purpose :
//=======================================================================
void ShapeExtend_MsgRegistrator::Send(const TopoDS_Shape& shape,
const Message_Msg& message,
const Message_Gravity)
{
if (shape.IsNull()) {
#ifdef DEB
cout << "Warning: ShapeExtend_MsgRegistrator::Send: null shape" << endl;
#endif
return;
}
if (myMapShape.IsBound (shape)) {
Message_ListOfMsg& list = myMapShape.ChangeFind (shape);
list.Append (message);
}
else {
Message_ListOfMsg list;
list.Append (message);
myMapShape.Bind (shape, list);
}
}

View File

@@ -0,0 +1,30 @@
// File: ShapeExtend_MsgRegistrator.lxx
// Created: Mon Jan 31 13:17:28 2000
// Author: data exchange team
// <det@kinox>
#include <ShapeExtend_MsgRegistrator.hxx>
//=======================================================================
//function : MapTransient
//purpose :
//=======================================================================
inline const ShapeExtend_DataMapOfTransientListOfMsg& ShapeExtend_MsgRegistrator::MapTransient() const
{
return myMapTransient;
}
//=======================================================================
//function : MapShape
//purpose :
//=======================================================================
inline const ShapeExtend_DataMapOfShapeListOfMsg& ShapeExtend_MsgRegistrator::MapShape() const
{
return myMapShape;
}

View File

@@ -0,0 +1,218 @@
-- File: ShapeExtend_WireData.cdl
-- Created: Wed Jun 3 12:42:27 1998
-- Author: data exchange team
-- <det@loufox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class WireData from ShapeExtend inherits TShared from MMgt
---Purpose: This class provides a data structure necessary for work with the wire as with
-- ordered list of edges, what is required for many algorithms. The advantage of
-- this class is that it allows to work with wires which are not correct.
-- The object of the class ShapeExtend_WireData can be initialized by
-- TopoDS_Wire, and converted back to TopoDS_Wire.
-- An edge in the wire is defined by its rank number. Operations of accessing,
-- adding and removing edge at the given rank number are provided. On the whole
-- wire, operations of circular permutation and reversing (both orientations of
-- all edges and order of edges) are provided as well.
-- This class also provides a method to check if the edge in the wire is a seam
-- (if the wire lies on a face).
-- This class is handled by reference. Such an approach gives the following advantages:
-- 1. Sharing the object of this class strongly optimizes the processes of
-- analysis and fixing performed in parallel on the wire stored in the form
-- of this class. Fixing tool (e.g. ShapeFix_Wire) fixes problems one by
-- one using analyzing tool (e.g. ShapeAnalysis_Wire). Sharing allows not
-- to reinitialize each time the analyzing tool with modified
-- ShapeExtend_WireData what consumes certain time.
-- 2. No copying of contents. The object of ShapeExtend_WireData class has
-- quite big size, returning it as a result of the function would cause
-- additional copying of contents if this class were one handled by value.
-- Moreover, this class is stored as a field in other classes which are
-- they returned as results of functions, storing only a handle to
-- ShapeExtend_WireData saves time and memory.
uses
HSequenceOfInteger from TColStd,
Shape from TopoDS,
Edge from TopoDS,
Wire from TopoDS,
Face from TopoDS,
HSequenceOfShape from TopTools
is
Create returns mutable WireData from ShapeExtend;
---Purpose: Empty constructor, creates empty wire with no edges
Create (wire: Wire from TopoDS; chained: Boolean = Standard_True ;
theManifoldMode :Boolean = Standard_True)
returns mutable WireData from ShapeExtend;
---Purpose: Constructor initializing the data from TopoDS_Wire. Calls Init(wire,chained).
Init (me: mutable; other: WireData from ShapeExtend);
---Purpose: Copies data from another WireData
Init (me: mutable; wire: Wire from TopoDS; chained: Boolean = Standard_True;
theManifoldMode :Boolean = Standard_True)
returns Boolean;
---Purpose: Loads an already existing wire
-- If <chained> is True (default), edges are added in the
-- sequence as they are explored by TopoDS_Iterator
-- Else, if <chained> is False, wire is explored by
-- BRepTools_WireExplorer and it is guaranteed that edges will
-- be sequencially connected.
-- Remark : In the latter case it can happen that not all edges
-- will be found (because of limitations of
-- BRepTools_WireExplorer for disconnected wires and wires
-- with seam edges).
Clear (me: mutable);
---Purpose: Clears data about Wire.
ComputeSeams (me: mutable; enforce: Boolean = Standard_True);
---Purpose: Computes the list of seam edges
-- By default (direct call), computing is enforced
-- For indirect call (from IsSeam) it is redone only if not yet
-- already done or if the list of edges has changed
-- Remark : A Seam Edge is an Edge present twice in the list, once as
-- FORWARD and once as REVERSED
-- Each sense has its own PCurve, the one for FORWARD
-- must be set in first
SetLast (me: mutable; num: Integer);
---Purpose: Does a circular permutation in order to set <num>th edge last
SetDegeneratedLast (me: mutable);
---Purpose: When the wire contains at least one degenerated edge, sets it
-- as last one
-- Note : It is useful to process pcurves, for instance, while the pcurve
-- of a DGNR may not be computed from its 3D part (there is none)
-- it is computed after the other edges have been computed and
-- chained.
Add (me: mutable; edge: Edge from TopoDS; atnum: Integer = 0);
---Purpose: Adds an edge to a wire, being defined (not yet ended)
-- This is the plain, basic, function to add an edge
-- <num> = 0 (D): Appends at end
-- <num> = 1: Preprends at start
-- else, Insert before <num>
-- Remark : Null Edge is simply ignored
Add (me: mutable; wire: Wire from TopoDS; atnum: Integer = 0);
---Purpose: Adds an entire wire, considered as a list of edges
-- Remark : The wire is assumed to be ordered (TopoDS_Iterator
-- is used)
Add (me: mutable; wire: WireData from ShapeExtend; atnum: Integer = 0);
---Purpose: Adds a wire in the form of WireData
Add (me: mutable; shape: Shape from TopoDS; atnum: Integer = 0);
---Purpose: Adds an edge or a wire invoking corresponding method Add
AddOriented (me: mutable; edge: Edge from TopoDS; mode: Integer);
---Purpose: Adds an edge to start or end of <me>, according to <mode>
-- 0: at end, as direct
-- 1: at end, as reversed
-- 2: at start, as direct
-- 3: at start, as reversed
-- < 0: no adding
AddOriented (me: mutable; wire: Wire from TopoDS; mode: Integer);
---Purpose: Adds a wire to start or end of <me>, according to <mode>
-- 0: at end, as direct
-- 1: at end, as reversed
-- 2: at start, as direct
-- 3: at start, as reversed
-- < 0: no adding
AddOriented (me: mutable; shape: Shape from TopoDS; mode: Integer);
---Purpose: Adds an edge or a wire invoking corresponding method
-- AddOriented
Remove (me: mutable; num: Integer = 0);
---Purpose: Removes an Edge, given its rank. By default removes the last edge.
Set (me: mutable; edge: Edge from TopoDS; num: Integer = 0);
---Purpose: Replaces an edge at the given
-- rank number <num> with new one. Default is last edge (<num> = 0).
Reverse (me: mutable);
---Purpose: Reverses the sense of the list and the orientation of each Edge
-- This method should be called when either wire has no seam edges
-- or face is not available
Reverse (me: mutable; face: Face from TopoDS);
---Purpose: Reverses the sense of the list and the orientation of each Edge
-- The face is necessary for swapping pcurves for seam edges
-- (first pcurve corresponds to orientation FORWARD, and second to
-- REVERSED; when edge is reversed, pcurves must be swapped)
-- If face is NULL, no swapping is performed
---Basic Querying:
NbEdges (me) returns Integer;
---Purpose: Returns the count of currently recorded edges
NbNonManifoldEdges (me) returns Integer;
---Purpose: Returns the count of currently recorded non-manifold edges
NonmanifoldEdge (me; num: Integer) returns Edge from TopoDS;
---Purpose: Returns <num>th nonmanifold Edge
NonmanifoldEdges(me) returns HSequenceOfShape from TopTools;
---Purpose: Returns sequence of non-manifold edges
-- This sequence can be not empty if wire data set in manifold mode but
-- initial wire has INTERNAL orientation or contains INTERNAL edges
--
ManifoldMode(me: mutable) returns Boolean;
---Purpose: Returns mode defining manifold wire data or not.
-- If manifold that nonmanifold edges will not be not
-- consider during operations(previous behaviour)
-- and they will be added only in result wire
-- else non-manifold edges will consider during operations
---C++: return &
---Default: True
Edge (me; num: Integer) returns Edge from TopoDS;
---Purpose: Returns <num>th Edge
Index (me: mutable; edge: Edge from TopoDS) returns Integer;
---Purpose: Returns the index of the edge
-- If the edge is a seam the orientation is also checked
-- Returns 0 if the edge is not found in the list
IsSeam (me: mutable; num: Integer) returns Boolean;
---Purpose: Tells if an Edge is seam (see ComputeSeams)
-- An edge is considered as seam if it presents twice in
-- the edge list, once as FORWARD and once as REVERSED.
Wire (me) returns Wire from TopoDS;
---Purpose: Makes TopoDS_Wire using
-- BRep_Builder (just creates the TopoDS_Wire object and adds
-- all edges into it). This method should be called when
-- the wire is correct (for example, after successful
-- fixes by ShapeFix_Wire) and adjacent edges share common
-- vertices. In case if adjacent edges do not share the same
-- vertices the resulting TopoDS_Wire will be invalid.
WireAPIMake (me) returns Wire from TopoDS;
---Purpose: Makes TopoDS_Wire using
-- BRepAPI_MakeWire. Class BRepAPI_MakeWire merges
-- geometrically coincided vertices and can disturb
-- correct order of edges in the wire. If this class fails,
-- null shape is returned.
fields
myEdges: HSequenceOfShape from TopTools;
myNonmanifoldEdges : HSequenceOfShape from TopTools;
mySeams: HSequenceOfInteger from TColStd;
mySeamF: Integer;
mySeamR: Integer;
myManifoldMode : Boolean;
end WireData;

View File

@@ -0,0 +1,609 @@
//:q0 abv 12.03.99: mat-a.stp: protection against no pcurves in SwapSeam()
// abv 28.04.99 S4137: added method Add(WireData), method SetLast fixed
// abv 05.05.99 S4174: protection against INTERNAL/EXTERNAL edges
#include <ShapeExtend_WireData.ixx>
#include <Geom2d_Curve.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepTools_WireExplorer.hxx>
//=======================================================================
//function : ShapeExtend_WireData
//purpose :
//=======================================================================
ShapeExtend_WireData::ShapeExtend_WireData()
{
Clear();
}
//=======================================================================
//function : ShapeExtend_WireData
//purpose :
//=======================================================================
ShapeExtend_WireData::ShapeExtend_WireData (const TopoDS_Wire& wire,
const Standard_Boolean chained,
const Standard_Boolean theManifold)
{
Init ( wire, chained ,theManifold);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ShapeExtend_WireData::Init (const Handle(ShapeExtend_WireData)& other)
{
Clear();
Standard_Integer i, nb = other->NbEdges();
for (i = 1; i <= nb; i++) Add ( other->Edge(i) );
nb = other->NbNonManifoldEdges();
for (i = 1; i <= nb; i++) Add ( other->NonmanifoldEdge(i) );
myManifoldMode = other->ManifoldMode();
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_WireData::Init (const TopoDS_Wire& wire,
const Standard_Boolean chained,
const Standard_Boolean theManifold)
{
Clear();
myManifoldMode = theManifold;
Standard_Boolean OK = Standard_True;
TopoDS_Vertex Vlast;
for ( TopoDS_Iterator it(wire); it.More(); it.Next() ) {
TopoDS_Edge E = TopoDS::Edge ( it.Value() );
// protect against INTERNAL/EXTERNAL edges
if ( (E.Orientation() != TopAbs_REVERSED &&
E.Orientation() != TopAbs_FORWARD)) {
myNonmanifoldEdges->Append(E);
continue;
}
TopoDS_Vertex V1, V2;
for ( TopoDS_Iterator itv(E); itv.More(); itv.Next() ) {
TopoDS_Vertex V = TopoDS::Vertex ( itv.Value() );
if ( V.Orientation() == TopAbs_FORWARD ) V1 = V;
else if ( V.Orientation() == TopAbs_REVERSED ) V2 = V;
}
// chainage? Si pas bon et chained False on repart sur WireExplorer
if ( ! Vlast.IsNull() && ! Vlast.IsSame ( V1 ) && theManifold) {
OK = Standard_False;
if ( ! chained ) break;
}
Vlast = V2;
if(wire.Orientation() == TopAbs_REVERSED)
myEdges->Prepend( E );
else
myEdges->Append ( E );
}
if(!myManifoldMode) {
Standard_Integer nb = myNonmanifoldEdges->Length();
Standard_Integer i =1;
for( ; i <= nb; i++)
myEdges->Append(myNonmanifoldEdges->Value(i));
myNonmanifoldEdges->Clear();
}
// refaire chainage ? Par WireExplorer
if ( OK || chained ) return OK;
Clear();
for ( BRepTools_WireExplorer we(wire); we.More(); we.Next() )
myEdges->Append ( TopoDS::Edge ( we.Current() ) );
return OK;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void ShapeExtend_WireData::Clear()
{
myEdges = new TopTools_HSequenceOfShape();
myNonmanifoldEdges = new TopTools_HSequenceOfShape;
mySeamF = mySeamR = -1;
mySeams.Nullify();
myManifoldMode = Standard_True;
}
//=======================================================================
//function : ComputeSeams
//purpose :
//=======================================================================
void ShapeExtend_WireData::ComputeSeams (const Standard_Boolean enforce)
{
if (mySeamF >= 0 && !enforce) return;
mySeams = new TColStd_HSequenceOfInteger();
mySeamF = mySeamR = 0;
TopoDS_Shape S;
Standard_Integer i, nb = NbEdges();
TopTools_IndexedMapOfShape ME;
Standard_Integer* SE = new Standard_Integer [nb+1];
// deux passes : d abord on mappe les Edges REVERSED
// Pour chacune, on note aussi son RANG dans la liste
for (i = 1; i <= nb; i ++) {
S = Edge(i);
if (S.Orientation() == TopAbs_REVERSED) {
Standard_Integer num = ME.Add (S);
SE[num] = i;
}
}
// ensuite on voit les Edges FORWARD qui y seraient deja -> on note leur n0
// c-a-d le n0 de la directe ET de la reverse
for (i = 1; i <= nb; i ++) {
S = Edge(i);
if (S.Orientation() == TopAbs_REVERSED) continue;
Standard_Integer num = ME.FindIndex (S);
if (num <= 0) continue;
if (mySeamF == 0) { mySeamF = i; mySeamR = SE[num]; }
else { mySeams->Append(i); mySeams->Append( SE[num] ); }
}
delete [] SE; // ne pas oublier !!
}
//=======================================================================
//function : SetLast
//purpose :
//=======================================================================
void ShapeExtend_WireData::SetLast (const Standard_Integer num)
{
if (num == 0) return;
Standard_Integer i, nb = NbEdges();
for (i = nb; i > num; i--) {
TopoDS_Edge edge = TopoDS::Edge ( myEdges->Value(nb) );
myEdges->Remove (nb);
myEdges->InsertBefore (1, edge);
}
mySeamF = -1;
}
//=======================================================================
//function : SetDegeneratedLast
//purpose :
//=======================================================================
void ShapeExtend_WireData::SetDegeneratedLast()
{
Standard_Integer i, nb = NbEdges();
for (i = 1; i <= nb; i ++) {
if ( BRep_Tool::Degenerated ( Edge(i) ) ) {
SetLast ( i );
return;
}
}
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void ShapeExtend_WireData::Add (const TopoDS_Edge& edge,
const Standard_Integer atnum)
{
if(edge.Orientation()!= TopAbs_REVERSED &&
edge.Orientation() != TopAbs_FORWARD && myManifoldMode) {
myNonmanifoldEdges->Append(edge);
return;
}
if (edge.IsNull()) return;
if (atnum == 0) {
myEdges->Append (edge);
}
else {
myEdges->InsertBefore (atnum,edge);
}
mySeamF = -1;
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void ShapeExtend_WireData::Add (const TopoDS_Wire& wire,
const Standard_Integer atnum)
{
if (wire.IsNull()) return;
Standard_Integer n = atnum;
TopTools_SequenceOfShape aNMEdges;
for (TopoDS_Iterator it(wire); it.More(); it.Next()) {
TopoDS_Edge edge = TopoDS::Edge (it.Value());
if(edge.Orientation()!= TopAbs_REVERSED &&
edge.Orientation() != TopAbs_FORWARD) {
if(myManifoldMode)
myNonmanifoldEdges->Append(edge);
else
aNMEdges.Append(edge);
continue;
}
if (n == 0) {
myEdges->Append (edge);
} else {
myEdges->InsertBefore (n,edge);
n++;
}
}
Standard_Integer i =1, nb = aNMEdges.Length();
for( ; i <= nb ; i++)
myEdges->Append(aNMEdges.Value(i));
mySeamF = -1;
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void ShapeExtend_WireData::Add (const Handle(ShapeExtend_WireData) &wire,
const Standard_Integer atnum)
{
if ( wire.IsNull() ) return;
TopTools_SequenceOfShape aNMEdges;
Standard_Integer n = atnum;
Standard_Integer i=1;
for (; i <= wire->NbEdges(); i++ ) {
TopoDS_Edge aE = wire->Edge(i);
if(aE.Orientation() == TopAbs_INTERNAL ||
aE.Orientation() == TopAbs_EXTERNAL) {
aNMEdges.Append(aE);
continue;
}
if (n == 0 ) {
myEdges->Append ( wire->Edge(i) );
}
else {
myEdges->InsertBefore ( n, wire->Edge(i) );
n++;
}
}
//non-manifold edges for non-manifold wire shoud be added at end
for (i=1; i <=aNMEdges.Length(); i++)
myEdges->Append(aNMEdges.Value(i));
for (i=1; i <= wire->NbNonManifoldEdges(); i++) {
if( myManifoldMode)
myNonmanifoldEdges->Append(wire->NonmanifoldEdge(i));
else {
if (n == 0)
myEdges->Append ( wire->Edge(i) );
else {
myEdges->InsertBefore ( n, wire->Edge(i) );
n++;
}
}
}
mySeamF = -1;
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void ShapeExtend_WireData::Add (const TopoDS_Shape& shape,
const Standard_Integer atnum)
{
if (shape.ShapeType() == TopAbs_EDGE) Add (TopoDS::Edge (shape), atnum);
else if (shape.ShapeType() == TopAbs_WIRE) Add (TopoDS::Wire (shape), atnum);
}
//=======================================================================
//function : AddOriented
//purpose :
//=======================================================================
void ShapeExtend_WireData::AddOriented (const TopoDS_Edge& edge,
const Standard_Integer mode)
{
if (edge.IsNull() || mode < 0) return;
TopoDS_Edge E = edge;
if (mode == 1 || mode == 3) E.Reverse();
Add (E, mode/2); // mode = 0,1 -> 0 mode = 2,3 -> 1
}
//=======================================================================
//function : AddOriented
//purpose :
//=======================================================================
void ShapeExtend_WireData::AddOriented (const TopoDS_Wire& wire,
const Standard_Integer mode)
{
if (wire.IsNull() || mode < 0) return;
TopoDS_Wire W = wire;
if (mode == 1 || mode == 3) W.Reverse();
Add (W, mode/2); // mode = 0,1 -> 0 mode = 2,3 -> 1
}
void ShapeExtend_WireData::AddOriented (const TopoDS_Shape& shape,
const Standard_Integer mode)
{
if (shape.ShapeType() == TopAbs_EDGE) AddOriented (TopoDS::Edge (shape), mode);
else if (shape.ShapeType() == TopAbs_WIRE) AddOriented (TopoDS::Wire (shape), mode);
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void ShapeExtend_WireData::Remove (const Standard_Integer num)
{
myEdges->Remove ( num > 0 ? num : NbEdges() );
mySeamF = -1;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void ShapeExtend_WireData::Set (const TopoDS_Edge& edge,
const Standard_Integer num)
{
if(edge.Orientation()!= TopAbs_REVERSED &&
edge.Orientation() != TopAbs_FORWARD && myManifoldMode) {
if(num <= myNonmanifoldEdges->Length())
myNonmanifoldEdges->SetValue(num,edge);
else
myNonmanifoldEdges->Append(edge);
}
else
myEdges->SetValue ( ( num > 0 ? num : NbEdges() ), edge);
mySeamF = -1;
}
//=======================================================================
//function : Reverse
//purpose : reverse order of edges in the wire
//=======================================================================
void ShapeExtend_WireData::Reverse ()
{
Standard_Integer i, nb = NbEdges();
// inverser les edges + les permuter pour inverser le wire
for (i = 1; i <= nb/2; i ++) {
TopoDS_Shape S1 = myEdges->Value(i); S1.Reverse();
TopoDS_Shape S2 = myEdges->Value(nb+1-i); S2.Reverse();
myEdges->SetValue (i, S2);
myEdges->SetValue (nb+1-i, S1);
}
// nb d edges impair : inverser aussi l edge du milieu (rang inchange)
if ( nb % 2 ) { // test impair
i = (nb+1)/2;
TopoDS_Shape SI = myEdges->Value(i); SI.Reverse();
myEdges->SetValue (i, SI);
}
mySeamF = -1;
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
// Fonction auxiliaire SwapSeam pour inverser
static void SwapSeam (const TopoDS_Shape& S, const TopoDS_Face& F)
{
TopoDS_Edge E = TopoDS::Edge (S);
if ( E.IsNull() || F.IsNull() ) return;
if ( E.Orientation() == TopAbs_REVERSED ) return; // ne le faire qu une fois !
TopoDS_Face theface = F;
theface.Orientation(TopAbs_FORWARD);
//:S4136 Standard_Real Tol = BRep_Tool::Tolerance(theface);
Handle(Geom2d_Curve) c2df,c2dr;
Standard_Real uff,ulf,ufr,ulr;
// d abord FWD puis REV
c2df = BRep_Tool::CurveOnSurface (E,theface,uff,ulf);
E.Orientation (TopAbs_REVERSED);
c2dr = BRep_Tool::CurveOnSurface (E,theface,ufr,ulr);
if ( c2df.IsNull() || c2dr.IsNull() ) return; //:q0
// On permute
E.Orientation (TopAbs_FORWARD);
BRep_Builder B;
B.UpdateEdge (E,c2dr,c2df,theface,0.); //:S4136: Tol
B.Range (E,theface,uff,ulf);
}
void ShapeExtend_WireData::Reverse (const TopoDS_Face &face)
{
Reverse();
if ( face.IsNull() ) return;
// ATTENTION aux coutures
// Une edge de couture est presente deux fois, FWD et REV
// Les inverser revient a permuter leur role ... donc ne rien faire
// Il faut donc aussi permuter leurs pcurves
ComputeSeams(Standard_True);
if (mySeamF > 0) SwapSeam (myEdges->Value(mySeamF),face);
if (mySeamR > 0) SwapSeam (myEdges->Value(mySeamR),face);
Standard_Integer nb = (mySeams.IsNull() ? 0 : mySeams->Length());
for ( Standard_Integer i = 1; i <= nb; i ++) {
SwapSeam (myEdges->Value(mySeams->Value(i)),face);
}
mySeamF = -1;
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_WireData::NbEdges() const
{
return myEdges->Length();
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
TopoDS_Edge ShapeExtend_WireData::Edge (const Standard_Integer num) const
{
if (num < 0) {
TopoDS_Edge E = Edge (-num);
E.Reverse();
return E;
}
return TopoDS::Edge ( myEdges->Value ( num ) );
}
//=======================================================================
//function : NbNonManifoldEdges
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_WireData::NbNonManifoldEdges() const
{
return myNonmanifoldEdges->Length();
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
TopoDS_Edge ShapeExtend_WireData::NonmanifoldEdge (const Standard_Integer num) const
{
TopoDS_Edge E;
if (num < 0)
return E;
return TopoDS::Edge ( myNonmanifoldEdges->Value ( num ) );
}
//=======================================================================
//function : Index
//purpose :
//=======================================================================
Standard_Integer ShapeExtend_WireData::Index (const TopoDS_Edge& edge)
{
for (Standard_Integer i = 1; i <= NbEdges(); i++)
if (Edge (i).IsSame (edge) && (Edge(i).Orientation() == edge.Orientation() || !IsSeam(i)))
return i;
return 0;
}
//=======================================================================
//function : IsSeam
//purpose :
//=======================================================================
Standard_Boolean ShapeExtend_WireData::IsSeam (const Standard_Integer num)
{
if (mySeamF < 0) ComputeSeams();
if (mySeamF == 0) return Standard_False;
if (num == mySeamF || num == mySeamR) return Standard_True;
// Pas suffisant : on regarde dans la liste
Standard_Integer i, nb = mySeams->Length();
for (i = 1; i <= nb; i ++) {
if (num == mySeams->Value(i)) return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Make
//purpose :
//=======================================================================
TopoDS_Wire ShapeExtend_WireData::Wire() const
{
TopoDS_Wire W;
BRep_Builder B;
B.MakeWire (W);
Standard_Integer i, nb = NbEdges();
Standard_Boolean ismanifold = Standard_True;
for (i = 1; i <= nb; i ++) {
TopoDS_Edge aE = Edge(i);
if (aE.Orientation() != TopAbs_FORWARD &&
aE.Orientation() != TopAbs_REVERSED)
ismanifold = Standard_False;
B.Add (W, aE);
}
if(ismanifold) {
TopoDS_Vertex vf, vl;
TopExp::Vertices (W, vf, vl);
if (!vf.IsNull() && !vl.IsNull() && vf.IsSame (vl)) W.Closed (Standard_True);
}
if(myManifoldMode) {
nb = NbNonManifoldEdges();
for (i = 1; i <= nb; i ++) B.Add (W, NonmanifoldEdge(i));
}
return W;
}
//=======================================================================
//function : APIMake
//purpose :
//=======================================================================
TopoDS_Wire ShapeExtend_WireData::WireAPIMake() const
{
TopoDS_Wire W;
BRepBuilderAPI_MakeWire MW;
Standard_Integer i, nb = NbEdges();
for (i = 1; i <= nb; i ++) MW.Add (Edge(i));
if(myManifoldMode) {
nb = NbNonManifoldEdges();
for (i = 1; i <= nb; i ++) MW.Add (NonmanifoldEdge(i));
}
if ( MW.IsDone() ) W = MW.Wire();
return W;
}
//=======================================================================
//function : NonmanifoldEdges
//purpose :
//=======================================================================
Handle(TopTools_HSequenceOfShape) ShapeExtend_WireData::NonmanifoldEdges() const
{
return myNonmanifoldEdges;
}
//=======================================================================
//function : ManifoldMode
//purpose :
//=======================================================================
Standard_Boolean& ShapeExtend_WireData::ManifoldMode()
{
return myManifoldMode;
}