file-pattern:
description: 'Pattern to match files for ASCII check'
required: false
- default: '^(src)/.*\.(cpp|hxx|cxx|lxx|h|pxx|hpp)$'
+ default: '^(src)/.*\.(cpp|hxx|cxx|lxx|h|pxx|hpp|gxx)$'
outputs:
has-non-ascii:
file-pattern:
description: 'Pattern to match files for formatting check'
required: false
- default: '^(src)/.*\.(cpp|hxx|cxx|lxx|h|pxx|hpp)$'
+ default: '^(src)/.*\.(cpp|hxx|cxx|lxx|h|pxx|hpp|gxx)$'
clang-format-version:
description: 'Required clang-format version'
required: false
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <IFSelect_FileModifier.ixx>
+// #include <IFSelect_FileModifier.ixx>
-
-
-IFSelect_FileModifier::IFSelect_FileModifier ()
- : IFSelect_GeneralModifier (Standard_False) { }
+IFSelect_FileModifier::IFSelect_FileModifier()
+ : IFSelect_GeneralModifier(Standard_False)
+{
+}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <IFSelect_ModelModifier.ixx>
+// #include <IFSelect_ModelModifier.ixx>
#include <Interface_Check.hxx>
-IFSelect_ModelModifier::IFSelect_ModelModifier (const Standard_Boolean grf)
- : IFSelect_Modifier (grf) { }
+IFSelect_ModelModifier::IFSelect_ModelModifier(const Standard_Boolean grf)
+ : IFSelect_Modifier(grf)
+{
+}
- void IFSelect_ModelModifier::Perform
- (IFSelect_ContextModif& ctx,
- const Handle(Interface_InterfaceModel)& target,
- const Handle(Interface_Protocol)& protocol,
- Interface_CopyTool& TC) const
+void IFSelect_ModelModifier::Perform(IFSelect_ContextModif& ctx,
+ const Handle(Interface_InterfaceModel)& target,
+ const Handle(Interface_Protocol)& protocol,
+ Interface_CopyTool& TC) const
{
ctx.TraceModifier(this);
Handle(Model) targ = Handle(Model)::DownCast(target);
Handle(Proto) prot = Handle(Proto)::DownCast(protocol);
- if (targ.IsNull()) {
+ if (targ.IsNull())
+ {
ctx.CCheck()->AddFail("Model to Modify : unproper type");
return;
}
- PerformProtocol (ctx,targ,prot,TC);
+ PerformProtocol(ctx, targ, prot, TC);
}
- void IFSelect_ModelModifier::PerformProtocol
- (IFSelect_ContextModif& ctx,
- const Handle(Model)& target,
- const Handle(Proto)& protocol,
- Interface_CopyTool& TC) const
-{ ctx.SetProtocol(protocol); Performing (ctx,target,TC); }
+void IFSelect_ModelModifier::PerformProtocol(IFSelect_ContextModif& ctx,
+ const Handle(Model)& target,
+ const Handle(Proto)& protocol,
+ Interface_CopyTool& TC) const
+{
+ ctx.SetProtocol(protocol);
+ Performing(ctx, target, TC);
+}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <Interface_JaggedArray.ixx>
-
-Interface_JaggedArray::Interface_JaggedArray
- (const Standard_Integer low, const Standard_Integer up)
-: thelist (low,up) { Handle(Standard_Transient) nulo; thelist.Init(nulo); }
-
- Standard_Integer Interface_JaggedArray::Lower () const
- { return thelist.Lower(); }
-
- Standard_Integer Interface_JaggedArray::Upper () const
- { return thelist.Upper(); }
-
- Standard_Integer Interface_JaggedArray::Length () const
- { return thelist.Length(); }
-
- void Interface_JaggedArray::SetValue
- (const Standard_Integer num, const Handle(TheKey)& val)
- { thelist.SetValue(num,val); }
-
- Handle(TheKey) Interface_JaggedArray::Value
- (const Standard_Integer num) const
- { return Handle(TheKey)::DownCast(thelist.Value(num)); }
+// #include <Interface_JaggedArray.ixx>
+
+Interface_JaggedArray::Interface_JaggedArray(const Standard_Integer low, const Standard_Integer up)
+ : thelist(low, up)
+{
+ Handle(Standard_Transient) nulo;
+ thelist.Init(nulo);
+}
+
+Standard_Integer Interface_JaggedArray::Lower() const
+{
+ return thelist.Lower();
+}
+
+Standard_Integer Interface_JaggedArray::Upper() const
+{
+ return thelist.Upper();
+}
+
+Standard_Integer Interface_JaggedArray::Length() const
+{
+ return thelist.Length();
+}
+
+void Interface_JaggedArray::SetValue(const Standard_Integer num, const Handle(TheKey)& val)
+{
+ thelist.SetValue(num, val);
+}
+
+Handle(TheKey) Interface_JaggedArray::Value(const Standard_Integer num) const
+{
+ return Handle(TheKey)::DownCast(thelist.Value(num));
+}
// Handle(TheKey)& Interface_JaggedArray::ChangeValue
// (const Standard_Integer num)
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <Interface_Recognizer.ixx>
+// #include <Interface_Recognizer.ixx>
#include <Standard_NoSuchObject.hxx>
// WARNING: TransRecognizer has exactly the same code ...
// in case of failure, following the return from Eval, Recognizer knows that SetOK was not
// called
-Interface_Recognizer::Interface_Recognizer ()
- { hasnext = Standard_False; }
- //thekey.Nullify(); useless, done by the constructor ...
+Interface_Recognizer::Interface_Recognizer()
+{
+ hasnext = Standard_False;
+}
+
+// thekey.Nullify(); useless, done by the constructor ...
- Standard_Boolean Interface_Recognizer::Evaluate
- (const TheKey& akey, Handle(TheResul)& res)
+Standard_Boolean Interface_Recognizer::Evaluate(const TheKey& akey, Handle(TheResul)& res)
{
theres.Nullify();
Eval(akey);
- if (!theres.IsNull()) {
+ if (!theres.IsNull())
+ {
res = theres;
return Standard_True;
}
- else if (hasnext) return thenext->Evaluate(akey,res);
+ else if (hasnext)
+ return thenext->Evaluate(akey, res);
return Standard_False;
}
- Handle(TheResul) Interface_Recognizer::Result () const
+Handle(TheResul) Interface_Recognizer::Result() const
{
- if (!theres.IsNull()) return theres;
- if (hasnext) return thenext->Result();
+ if (!theres.IsNull())
+ return theres;
+ if (hasnext)
+ return thenext->Result();
throw Standard_NoSuchObject("Recognizer evaluation has failed");
}
- void Interface_Recognizer::Add (const Handle(Interface_Recognizer)& reco)
- { thenext = reco; hasnext = Standard_True; }
+void Interface_Recognizer::Add(const Handle(Interface_Recognizer)& reco)
+{
+ thenext = reco;
+ hasnext = Standard_True;
+}
- void Interface_Recognizer::SetOK (const Handle(TheResul)& aresult)
- { theres = aresult; }
+void Interface_Recognizer::SetOK(const Handle(TheResul)& aresult)
+{
+ theres = aresult;
+}
- void Interface_Recognizer::SetKO ()
- { theres.Nullify(); }
+void Interface_Recognizer::SetKO()
+{
+ theres.Nullify();
+}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <LibCtl_GlobalNode.ixx>
+// #include <LibCtl_GlobalNode.ixx>
// Generic class nested in Library: used to build the
// global lists of Modules attached to an instantiated class of Library
// (see Library for more details)
-
-LibCtl_GlobalNode::LibCtl_GlobalNode () { }
+LibCtl_GlobalNode::LibCtl_GlobalNode() {}
// WARNING, Add acts as substitution: for a given Protocol, it is the
// last call wins
- void LibCtl_GlobalNode::Add
- (const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol)
+void LibCtl_GlobalNode::Add(const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol)
{
- if (themod == amodule) return;
- if (theprot == aprotocol) themod = amodule;
- else if (thenext.IsNull()) {
- if (themod.IsNull()) { themod = amodule; theprot = aprotocol; }
- else {
+ if (themod == amodule)
+ return;
+ if (theprot == aprotocol)
+ themod = amodule;
+ else if (thenext.IsNull())
+ {
+ if (themod.IsNull())
+ {
+ themod = amodule;
+ theprot = aprotocol;
+ }
+ else
+ {
thenext = new LibCtl_GlobalNode;
- thenext->Add (amodule,aprotocol);
+ thenext->Add(amodule, aprotocol);
}
}
- else thenext->Add (amodule,aprotocol);
+ else
+ thenext->Add(amodule, aprotocol);
}
- const Handle(TheModule)& LibCtl_GlobalNode::Module () const
- { return themod; }
+const Handle(TheModule)& LibCtl_GlobalNode::Module() const
+{
+ return themod;
+}
- const Handle(TheProtocol)& LibCtl_GlobalNode::Protocol () const
- { return theprot; }
+const Handle(TheProtocol)& LibCtl_GlobalNode::Protocol() const
+{
+ return theprot;
+}
- const Handle(LibCtl_GlobalNode)& LibCtl_GlobalNode::Next () const
- { return thenext; }
+const Handle(LibCtl_GlobalNode)& LibCtl_GlobalNode::Next() const
+{
+ return thenext;
+}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <LibCtl_Library.ixx>
+// #include <LibCtl_Library.ixx>
#include <Standard_NoSuchObject.hxx>
-
// Global List of Modules, from which we will be served
static Handle(LibCtl_GlobalNode) theglobal;
static Handle(TheProtocol) theprotocol;
static Handle(LibCtl_Node) thelast;
-
// Feeding the global list
// WARNING: SetGlobal performs substitution, i.e. it's the last one
// that is right for a given Protocol
- void LibCtl_Library::SetGlobal
- (const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol)
+void LibCtl_Library::SetGlobal(const Handle(TheModule)& amodule,
+ const Handle(TheProtocol)& aprotocol)
{
- if (theglobal.IsNull()) theglobal = new LibCtl_GlobalNode;
- theglobal->Add(amodule,aprotocol);
+ if (theglobal.IsNull())
+ theglobal = new LibCtl_GlobalNode;
+ theglobal->Add(amodule, aprotocol);
}
// Constructor from Protocol
- LibCtl_Library::LibCtl_Library (const Handle(TheProtocol)& aprotocol)
+LibCtl_Library::LibCtl_Library(const Handle(TheProtocol)& aprotocol)
{
Standard_Boolean last = Standard_False;
- if (aprotocol.IsNull()) return; // NO protocol = EMPTY Lib
- if (!theprotocol.IsNull()) last =
- (theprotocol == aprotocol);
-
- if (last) thelist = thelast;
-// If no optimization available: build the list
- else {
+ if (aprotocol.IsNull())
+ return; // NO protocol = EMPTY Lib
+ if (!theprotocol.IsNull())
+ last = (theprotocol == aprotocol);
+
+ if (last)
+ thelist = thelast;
+ // If no optimization available: build the list
+ else
+ {
AddProtocol(aprotocol);
-// This defines the optimization (for the next time)
+ // This defines the optimization (for the next time)
thelast = thelist;
theprotocol = aprotocol;
}
}
// Constructeur vide
- LibCtl_Library::LibCtl_Library () { }
-
+LibCtl_Library::LibCtl_Library() {}
// Adding a Protocol: beware, deoptimizes (otherwise risk of confusion!)
- void LibCtl_Library::AddProtocol
- (const Handle(Standard_Transient)& aprotocol)
+void LibCtl_Library::AddProtocol(const Handle(Standard_Transient)& aprotocol)
{
-// DownCast because Protocol->Resources, even redefined and used in other
-// libraries, must always return the highest type
+ // DownCast because Protocol->Resources, even redefined and used in other
+ // libraries, must always return the highest type
Handle(TheProtocol) aproto = Handle(TheProtocol)::DownCast(aprotocol);
- if (aproto.IsNull()) return;
+ if (aproto.IsNull())
+ return;
-// First, add this one to the list: search for the Node
+ // First, add this one to the list: search for the Node
Handle(LibCtl_GlobalNode) curr;
- for (curr = theglobal; !curr.IsNull(); ) { // curr->Next : plus loin
+ for (curr = theglobal; !curr.IsNull();)
+ { // curr->Next : plus loin
const Handle(TheProtocol)& protocol = curr->Protocol();
- if (!protocol.IsNull()) {
-// Match Protocol ?
- if (protocol->DynamicType() == aprotocol->DynamicType()) {
- if (thelist.IsNull()) thelist = new LibCtl_Node;
- thelist->AddNode(curr);
- break; // UN SEUL MODULE PAR PROTOCOLE
+ if (!protocol.IsNull())
+ {
+ // Match Protocol ?
+ if (protocol->DynamicType() == aprotocol->DynamicType())
+ {
+ if (thelist.IsNull())
+ thelist = new LibCtl_Node;
+ thelist->AddNode(curr);
+ break; // UN SEUL MODULE PAR PROTOCOLE
}
}
- curr = curr->Next(); // this formula is refused in "for"
+ curr = curr->Next(); // this formula is refused in "for"
}
-// Then, process the resources
+ // Then, process the resources
Standard_Integer nb = aproto->NbResources();
- for (Standard_Integer i = 1; i <= nb; i ++) {
- AddProtocol (aproto->Resource(i));
+ for (Standard_Integer i = 1; i <= nb; i++)
+ {
+ AddProtocol(aproto->Resource(i));
}
-// Don't forget to deoptimize
+ // Don't forget to deoptimize
theprotocol.Nullify();
thelast.Nullify();
}
- void LibCtl_Library::Clear ()
- { thelist = new LibCtl_Node; }
+void LibCtl_Library::Clear()
+{
+ thelist = new LibCtl_Node;
+}
- void LibCtl_Library::SetComplete ()
+void LibCtl_Library::SetComplete()
{
thelist = new LibCtl_Node;
-// We take each of the Protocols from the Global List and add it
+ // We take each of the Protocols from the Global List and add it
Handle(LibCtl_GlobalNode) curr;
- for (curr = theglobal; !curr.IsNull(); ) { // curr->Next : plus loin
+ for (curr = theglobal; !curr.IsNull();)
+ { // curr->Next : plus loin
const Handle(TheProtocol)& protocol = curr->Protocol();
-// Since we take everything, we don't worry about Resources!
- if (!protocol.IsNull()) thelist->AddNode(curr);
- curr = curr->Next(); // this formula is refused in "for"
+ // Since we take everything, we don't worry about Resources!
+ if (!protocol.IsNull())
+ thelist->AddNode(curr);
+ curr = curr->Next(); // this formula is refused in "for"
}
}
-
// Selection: Very powerful, we return the Module corresponding to a Type
// (as well as the CaseNumber returned by the corresponding protocol)
- Standard_Boolean LibCtl_Library::Select
- (const TheObject& obj,
- Handle(TheModule)& module, Standard_Integer& CN) const
+Standard_Boolean LibCtl_Library::Select(const TheObject& obj,
+ Handle(TheModule)& module,
+ Standard_Integer& CN) const
{
- module.Nullify(); CN = 0; // Response "not found"
- if (thelist.IsNull()) return Standard_False;
+ module.Nullify();
+ CN = 0; // Response "not found"
+ if (thelist.IsNull())
+ return Standard_False;
Handle(LibCtl_Node) curr = thelist;
- for (curr = thelist; !curr.IsNull(); ) { // curr->Next : plus loin
+ for (curr = thelist; !curr.IsNull();)
+ { // curr->Next : plus loin
const Handle(TheProtocol)& protocol = curr->Protocol();
- if (!protocol.IsNull()) {
+ if (!protocol.IsNull())
+ {
CN = protocol->CaseNumber(obj);
- if (CN > 0) {
- module = curr->Module();
- return Standard_True;
+ if (CN > 0)
+ {
+ module = curr->Module();
+ return Standard_True;
}
}
- curr = curr->Next(); // this formula is refused in "for"
+ curr = curr->Next(); // this formula is refused in "for"
}
- return Standard_False; // here, not found
+ return Standard_False; // here, not found
}
-
// .... Iteration ....
- void LibCtl_Library::Start ()
- { thecurr = thelist; }
+void LibCtl_Library::Start()
+{
+ thecurr = thelist;
+}
- Standard_Boolean LibCtl_Library::More () const
- { return (!thecurr.IsNull()); }
+Standard_Boolean LibCtl_Library::More() const
+{
+ return (!thecurr.IsNull());
+}
- void LibCtl_Library::Next ()
- { if (!thecurr.IsNull()) thecurr = thecurr->Next(); }
+void LibCtl_Library::Next()
+{
+ if (!thecurr.IsNull())
+ thecurr = thecurr->Next();
+}
- const Handle(TheModule)& LibCtl_Library::Module () const
+const Handle(TheModule)& LibCtl_Library::Module() const
{
- if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl");
+ if (thecurr.IsNull())
+ throw Standard_NoSuchObject("Library from LibCtl");
return thecurr->Module();
}
- const Handle(TheProtocol)& LibCtl_Library::Protocol () const
+const Handle(TheProtocol)& LibCtl_Library::Protocol() const
{
- if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl");
+ if (thecurr.IsNull())
+ throw Standard_NoSuchObject("Library from LibCtl");
return thecurr->Protocol();
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <LibCtl_Node.ixx>
-
+// #include <LibCtl_Node.ixx>
// Generic class nested in Library: used to build the
// lists of Modules of a library (see Library for more details)
// (In fact: List of Global Nodes -> Module + Protocol)
-LibCtl_Node::LibCtl_Node () { }
+LibCtl_Node::LibCtl_Node() {}
- void LibCtl_Node::AddNode (const Handle(LibCtl_GlobalNode)& anode)
+void LibCtl_Node::AddNode(const Handle(LibCtl_GlobalNode)& anode)
{
- if (thenode == anode) return;
- if (thenext.IsNull()) {
- if (thenode.IsNull()) thenode = anode;
- else {
+ if (thenode == anode)
+ return;
+ if (thenext.IsNull())
+ {
+ if (thenode.IsNull())
+ thenode = anode;
+ else
+ {
thenext = new LibCtl_Node;
- thenext->AddNode (anode);
+ thenext->AddNode(anode);
}
}
- else thenext->AddNode (anode);
+ else
+ thenext->AddNode(anode);
}
+const Handle(TheModule)& LibCtl_Node::Module() const
+{
+ return thenode->Module();
+}
- const Handle(TheModule)& LibCtl_Node::Module () const
- { return thenode->Module(); }
-
- const Handle(TheProtocol)& LibCtl_Node::Protocol () const
- { return thenode->Protocol(); }
+const Handle(TheProtocol)& LibCtl_Node::Protocol() const
+{
+ return thenode->Protocol();
+}
- const Handle(LibCtl_Node)& LibCtl_Node::Next () const
- { return thenext; }
+const Handle(LibCtl_Node)& LibCtl_Node::Next() const
+{
+ return thenext;
+}
#include <math_Matrix.hxx>
//=======================================================================
-//struct : BSplCLib_DataContainer
-//purpose: Auxiliary structure providing buffers for poles and knots used in
+// struct : BSplCLib_DataContainer
+// purpose: Auxiliary structure providing buffers for poles and knots used in
// evaluation of bspline (allocated in the stack)
//=======================================================================
-struct BSplCLib_DataContainer
+struct BSplCLib_DataContainer
{
- BSplCLib_DataContainer(Standard_Integer Degree)
+ BSplCLib_DataContainer(Standard_Integer Degree)
{
(void)Degree; // avoid compiler warning
- Standard_OutOfRange_Raise_if (Degree > BSplCLib::MaxDegree() ||
- BSplCLib::MaxDegree() > 25,
- "BSplCLib: bspline degree is greater than maximum supported");
+ Standard_OutOfRange_Raise_if(Degree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25,
+ "BSplCLib: bspline degree is greater than maximum supported");
}
- Standard_Real poles[(25+1)*(Dimension_gen+1)];
- Standard_Real knots[2*25];
- Standard_Real ders[Dimension_gen*4];
+ Standard_Real poles[(25 + 1) * (Dimension_gen + 1)];
+ Standard_Real knots[2 * 25];
+ Standard_Real ders[Dimension_gen * 4];
};
//=================================================================================================
-
-void BSplCLib::Reverse(Array1OfPoints& Poles,
- const Standard_Integer L)
+void BSplCLib::Reverse(Array1OfPoints& Poles, const Standard_Integer L)
{
Standard_Integer i, l = L;
- l = Poles.Lower() + (l-Poles.Lower()) % (Poles.Upper()-Poles.Lower()+1);
-
- Array1OfPoints temp(0,Poles.Length()-1);
-
+ l = Poles.Lower() + (l - Poles.Lower()) % (Poles.Upper() - Poles.Lower() + 1);
+
+ Array1OfPoints temp(0, Poles.Length() - 1);
+
for (i = Poles.Lower(); i <= l; i++)
- temp(l-i) = Poles(i);
-
- for (i = l+1; i <= Poles.Upper(); i++)
- temp(l-Poles.Lower()+Poles.Upper()-i+1) = Poles(i);
-
+ temp(l - i) = Poles(i);
+
+ for (i = l + 1; i <= Poles.Upper(); i++)
+ temp(l - Poles.Lower() + Poles.Upper() - i + 1) = Poles(i);
+
for (i = Poles.Lower(); i <= Poles.Upper(); i++)
- Poles(i) = temp(i-Poles.Lower());
+ Poles(i) = temp(i - Poles.Lower());
}
//
//=================================================================================================
-
-Standard_Boolean BSplCLib::RemoveKnot
-(const Standard_Integer Index,
- const Standard_Integer Mult,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights,
- TColStd_Array1OfReal& NewKnots,
- TColStd_Array1OfInteger& NewMults,
- const Standard_Real Tolerance)
+Standard_Boolean BSplCLib::RemoveKnot(const Standard_Integer Index,
+ const Standard_Integer Mult,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights,
+ TColStd_Array1OfReal& NewKnots,
+ TColStd_Array1OfInteger& NewMults,
+ const Standard_Real Tolerance)
{
- Standard_Boolean rational = Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim;
dim = Dimension_gen;
- if (rational) dim++;
-
- TColStd_Array1OfReal poles(1,dim*Poles.Length());
- TColStd_Array1OfReal newpoles(1,dim*NewPoles.Length());
-
- if (rational) PLib::SetPoles(Poles,*Weights,poles);
- else PLib::SetPoles(Poles,poles);
-
- if (!RemoveKnot(Index,Mult,Degree,Periodic,dim,
- poles,Knots,Mults,newpoles,NewKnots,NewMults,Tolerance))
+ if (rational)
+ dim++;
+
+ TColStd_Array1OfReal poles(1, dim * Poles.Length());
+ TColStd_Array1OfReal newpoles(1, dim * NewPoles.Length());
+
+ if (rational)
+ PLib::SetPoles(Poles, *Weights, poles);
+ else
+ PLib::SetPoles(Poles, poles);
+
+ if (!RemoveKnot(Index,
+ Mult,
+ Degree,
+ Periodic,
+ dim,
+ poles,
+ Knots,
+ Mults,
+ newpoles,
+ NewKnots,
+ NewMults,
+ Tolerance))
return Standard_False;
- if (rational) PLib::GetPoles(newpoles,NewPoles,*NewWeights);
- else PLib::GetPoles(newpoles,NewPoles);
+ if (rational)
+ PLib::GetPoles(newpoles, NewPoles, *NewWeights);
+ else
+ PLib::GetPoles(newpoles, NewPoles);
return Standard_True;
}
//=======================================================================
-//function : InsertKnots
-//purpose : insert an array of knots and multiplicities
+// function : InsertKnots
+// purpose : insert an array of knots and multiplicities
//=======================================================================
-void BSplCLib::InsertKnots
-(const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const TColStd_Array1OfReal& AddKnots,
- const TColStd_Array1OfInteger* AddMults,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights,
- TColStd_Array1OfReal& NewKnots,
- TColStd_Array1OfInteger& NewMults,
- const Standard_Real Epsilon,
- const Standard_Boolean Add)
+void BSplCLib::InsertKnots(const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const TColStd_Array1OfReal& AddKnots,
+ const TColStd_Array1OfInteger* AddMults,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights,
+ TColStd_Array1OfReal& NewKnots,
+ TColStd_Array1OfInteger& NewMults,
+ const Standard_Real Epsilon,
+ const Standard_Boolean Add)
{
- Standard_Boolean rational = Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim;
dim = Dimension_gen;
- if (rational) dim++;
-
- TColStd_Array1OfReal poles(1,dim*Poles.Length());
- TColStd_Array1OfReal newpoles(1,dim*NewPoles.Length());
-
- if (rational) PLib::SetPoles(Poles,*Weights,poles);
- else PLib::SetPoles(Poles,poles);
-
- InsertKnots(Degree,Periodic,dim,poles,Knots,Mults,
- AddKnots,AddMults,newpoles,NewKnots,NewMults,Epsilon,Add);
-
- if (rational) PLib::GetPoles(newpoles,NewPoles,*NewWeights);
- else PLib::GetPoles(newpoles,NewPoles);
+ if (rational)
+ dim++;
+
+ TColStd_Array1OfReal poles(1, dim * Poles.Length());
+ TColStd_Array1OfReal newpoles(1, dim * NewPoles.Length());
+
+ if (rational)
+ PLib::SetPoles(Poles, *Weights, poles);
+ else
+ PLib::SetPoles(Poles, poles);
+
+ InsertKnots(Degree,
+ Periodic,
+ dim,
+ poles,
+ Knots,
+ Mults,
+ AddKnots,
+ AddMults,
+ newpoles,
+ NewKnots,
+ NewMults,
+ Epsilon,
+ Add);
+
+ if (rational)
+ PLib::GetPoles(newpoles, NewPoles, *NewWeights);
+ else
+ PLib::GetPoles(newpoles, NewPoles);
}
//=================================================================================================
-
-void BSplCLib::InsertKnot(const Standard_Integer ,
- const Standard_Real U,
- const Standard_Integer UMult,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights)
+void BSplCLib::InsertKnot(const Standard_Integer,
+ const Standard_Real U,
+ const Standard_Integer UMult,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights)
{
- TColStd_Array1OfReal k(1,1);
+ TColStd_Array1OfReal k(1, 1);
k(1) = U;
- TColStd_Array1OfInteger m(1,1);
+ TColStd_Array1OfInteger m(1, 1);
m(1) = UMult;
- TColStd_Array1OfReal nk(1,Knots.Length()+1);
- TColStd_Array1OfInteger nm(1,Knots.Length()+1);
- InsertKnots(Degree,Periodic,Poles,Weights,Knots,Mults,
- k,&m,NewPoles,NewWeights,nk,nm,Epsilon(U));
+ TColStd_Array1OfReal nk(1, Knots.Length() + 1);
+ TColStd_Array1OfInteger nm(1, Knots.Length() + 1);
+ InsertKnots(Degree,
+ Periodic,
+ Poles,
+ Weights,
+ Knots,
+ Mults,
+ k,
+ &m,
+ NewPoles,
+ NewWeights,
+ nk,
+ nm,
+ Epsilon(U));
}
//=================================================================================================
-
-void BSplCLib::RaiseMultiplicity(const Standard_Integer KnotIndex,
- const Standard_Integer Mult,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights)
+void BSplCLib::RaiseMultiplicity(const Standard_Integer KnotIndex,
+ const Standard_Integer Mult,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights)
{
- TColStd_Array1OfReal k(1,1);
+ TColStd_Array1OfReal k(1, 1);
k(1) = Knots(KnotIndex);
- TColStd_Array1OfInteger m(1,1);
+ TColStd_Array1OfInteger m(1, 1);
m(1) = Mult - Mults(KnotIndex);
- TColStd_Array1OfReal nk(1,Knots.Length());
- TColStd_Array1OfInteger nm(1,Knots.Length());
- InsertKnots(Degree,Periodic,Poles,Weights,Knots,Mults,
- k,&m,NewPoles,NewWeights,nk,nm,Epsilon(k(1)));
+ TColStd_Array1OfReal nk(1, Knots.Length());
+ TColStd_Array1OfInteger nm(1, Knots.Length());
+ InsertKnots(Degree,
+ Periodic,
+ Poles,
+ Weights,
+ Knots,
+ Mults,
+ k,
+ &m,
+ NewPoles,
+ NewWeights,
+ nk,
+ nm,
+ Epsilon(k(1)));
}
//=================================================================================================
-
-void BSplCLib::IncreaseDegree
-(const Standard_Integer Degree,
- const Standard_Integer NewDegree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights,
- TColStd_Array1OfReal& NewKnots,
- TColStd_Array1OfInteger& NewMults)
+void BSplCLib::IncreaseDegree(const Standard_Integer Degree,
+ const Standard_Integer NewDegree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights,
+ TColStd_Array1OfReal& NewKnots,
+ TColStd_Array1OfInteger& NewMults)
{
- Standard_Boolean rational = Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim;
dim = Dimension_gen;
- if (rational) dim++;
-
- TColStd_Array1OfReal poles(1,dim*Poles.Length());
- TColStd_Array1OfReal newpoles(1,dim*NewPoles.Length());
-
- if (rational) PLib::SetPoles(Poles,*Weights,poles);
- else PLib::SetPoles(Poles,poles);
-
- IncreaseDegree(Degree,NewDegree,Periodic,dim,poles,Knots,Mults,
- newpoles,NewKnots,NewMults);
-
- if (rational) PLib::GetPoles(newpoles,NewPoles,*NewWeights);
- else PLib::GetPoles(newpoles,NewPoles);
+ if (rational)
+ dim++;
+
+ TColStd_Array1OfReal poles(1, dim * Poles.Length());
+ TColStd_Array1OfReal newpoles(1, dim * NewPoles.Length());
+
+ if (rational)
+ PLib::SetPoles(Poles, *Weights, poles);
+ else
+ PLib::SetPoles(Poles, poles);
+
+ IncreaseDegree(Degree,
+ NewDegree,
+ Periodic,
+ dim,
+ poles,
+ Knots,
+ Mults,
+ newpoles,
+ NewKnots,
+ NewMults);
+
+ if (rational)
+ PLib::GetPoles(newpoles, NewPoles, *NewWeights);
+ else
+ PLib::GetPoles(newpoles, NewPoles);
}
//=================================================================================================
-
-void BSplCLib::Unperiodize
-(const Standard_Integer Degree,
- const TColStd_Array1OfInteger& Mults,
- const TColStd_Array1OfReal& Knots,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- TColStd_Array1OfInteger& NewMults,
- TColStd_Array1OfReal& NewKnots,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights)
+void BSplCLib::Unperiodize(const Standard_Integer Degree,
+ const TColStd_Array1OfInteger& Mults,
+ const TColStd_Array1OfReal& Knots,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ TColStd_Array1OfInteger& NewMults,
+ TColStd_Array1OfReal& NewKnots,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights)
{
- Standard_Boolean rational = Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim;
dim = Dimension_gen;
- if (rational) dim++;
-
- TColStd_Array1OfReal poles(1,dim*Poles.Length());
- TColStd_Array1OfReal newpoles(1,dim*NewPoles.Length());
-
- if (rational) PLib::SetPoles(Poles,*Weights,poles);
- else PLib::SetPoles(Poles,poles);
-
- Unperiodize(Degree, dim, Mults, Knots, poles,
- NewMults,NewKnots, newpoles);
-
- if (rational) PLib::GetPoles(newpoles,NewPoles,*NewWeights);
- else PLib::GetPoles(newpoles,NewPoles);
+ if (rational)
+ dim++;
+
+ TColStd_Array1OfReal poles(1, dim * Poles.Length());
+ TColStd_Array1OfReal newpoles(1, dim * NewPoles.Length());
+
+ if (rational)
+ PLib::SetPoles(Poles, *Weights, poles);
+ else
+ PLib::SetPoles(Poles, poles);
+
+ Unperiodize(Degree, dim, Mults, Knots, poles, NewMults, NewKnots, newpoles);
+
+ if (rational)
+ PLib::GetPoles(newpoles, NewPoles, *NewWeights);
+ else
+ PLib::GetPoles(newpoles, NewPoles);
}
//=================================================================================================
-
-void BSplCLib::Trimming(const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const Standard_Real U1,
- const Standard_Real U2,
- TColStd_Array1OfReal& NewKnots,
- TColStd_Array1OfInteger& NewMults,
- Array1OfPoints& NewPoles,
- TColStd_Array1OfReal* NewWeights)
+void BSplCLib::Trimming(const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const Standard_Real U1,
+ const Standard_Real U2,
+ TColStd_Array1OfReal& NewKnots,
+ TColStd_Array1OfInteger& NewMults,
+ Array1OfPoints& NewPoles,
+ TColStd_Array1OfReal* NewWeights)
{
- Standard_Boolean rational = Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim;
dim = Dimension_gen;
- if (rational) dim++;
-
- TColStd_Array1OfReal poles(1,dim*Poles.Length());
- TColStd_Array1OfReal newpoles(1,dim*NewPoles.Length());
-
- if (rational) PLib::SetPoles(Poles,*Weights,poles);
- else PLib::SetPoles(Poles,poles);
-
- Trimming(Degree, Periodic, dim, Knots, Mults, poles, U1, U2,
- NewKnots, NewMults, newpoles);
-
- if (rational) PLib::GetPoles(newpoles,NewPoles,*NewWeights);
- else PLib::GetPoles(newpoles,NewPoles);
+ if (rational)
+ dim++;
+
+ TColStd_Array1OfReal poles(1, dim * Poles.Length());
+ TColStd_Array1OfReal newpoles(1, dim * NewPoles.Length());
+
+ if (rational)
+ PLib::SetPoles(Poles, *Weights, poles);
+ else
+ PLib::SetPoles(Poles, poles);
+
+ Trimming(Degree, Periodic, dim, Knots, Mults, poles, U1, U2, NewKnots, NewMults, newpoles);
+
+ if (rational)
+ PLib::GetPoles(newpoles, NewPoles, *NewWeights);
+ else
+ PLib::GetPoles(newpoles, NewPoles);
}
//--------------------------------------------------------------------------
-//ELEMENTARY COMPUTATIONS
+// ELEMENTARY COMPUTATIONS
//--------------------------------------------------------------------------
//
-// All the following methods are methods of low level used in BSplCLib
+// All the following methods are methods of low level used in BSplCLib
// but also in BSplSLib (but not in Geom)
-// At the creation time of this package there is no possibility
+// At the creation time of this package there is no possibility
// to declare private methods of package and to declare friend
// methods of package. It could interesting to declare that BSplSLib
// is a package friend to BSplCLib because it uses all the basis methods
//--------------------------------------------------------------------------
//=======================================================================
-//function : BuildEval
-//purpose : builds the local array for evaluation
+// function : BuildEval
+// purpose : builds the local array for evaluation
//=======================================================================
-void BSplCLib::BuildEval(const Standard_Integer Degree,
- const Standard_Integer Index,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- Standard_Real& LP)
+void BSplCLib::BuildEval(const Standard_Integer Degree,
+ const Standard_Integer Index,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ Standard_Real& LP)
{
- Standard_Real w, *pole = &LP;
+ Standard_Real w, *pole = &LP;
Standard_Integer PLower = Poles.Lower();
Standard_Integer PUpper = Poles.Upper();
Standard_Integer i;
Standard_Integer ip = PLower + Index - 1;
- if (Weights == NULL) {
- for (i = 0; i <= Degree; i++) {
+ if (Weights == NULL)
+ {
+ for (i = 0; i <= Degree; i++)
+ {
ip++;
- if (ip > PUpper) ip = PLower;
+ if (ip > PUpper)
+ ip = PLower;
const Point& P = Poles(ip);
- PointToCoords (pole,P,+0);
+ PointToCoords(pole, P, +0);
pole += Dimension_gen;
}
}
- else {
- for (i = 0; i <= Degree; i++) {
+ else
+ {
+ for (i = 0; i <= Degree; i++)
+ {
ip++;
- if (ip > PUpper) ip = PLower;
- const Point& P = Poles(ip);
+ if (ip > PUpper)
+ ip = PLower;
+ const Point& P = Poles(ip);
pole[Dimension_gen] = w = (*Weights)(ip);
- PointToCoords (pole, P, * w);
+ PointToCoords(pole, P, *w);
pole += Dimension_gen + 1;
}
}
}
//=======================================================================
-//function : PrepareEval
-//purpose : stores data for Eval in the local arrays
+// function : PrepareEval
+// purpose : stores data for Eval in the local arrays
// dc.poles and dc.knots
//=======================================================================
-static void PrepareEval
-(Standard_Real& u,
- Standard_Integer& index,
- Standard_Integer& dim,
- Standard_Boolean& rational,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger* Mults,
- BSplCLib_DataContainer& dc)
+static void PrepareEval(Standard_Real& u,
+ Standard_Integer& index,
+ Standard_Integer& dim,
+ Standard_Boolean& rational,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger* Mults,
+ BSplCLib_DataContainer& dc)
{
// Set the Index
- BSplCLib::LocateParameter(Degree,Knots,Mults,u,Periodic,index,u);
+ BSplCLib::LocateParameter(Degree, Knots, Mults, u, Periodic, index, u);
// make the knots
- BSplCLib::BuildKnots(Degree,index,Periodic,Knots,Mults,*dc.knots);
+ BSplCLib::BuildKnots(Degree, index, Periodic, Knots, Mults, *dc.knots);
if (Mults == NULL)
index -= Knots.Lower() + Degree;
else
- index = BSplCLib::PoleIndex(Degree,index,Periodic,*Mults);
-
+ index = BSplCLib::PoleIndex(Degree, index, Periodic, *Mults);
+
// check truly rational
rational = (Weights != NULL);
- if (rational) {
+ if (rational)
+ {
Standard_Integer WLower = Weights->Lower() + index;
- rational = BSplCLib::IsRational(*Weights, WLower, WLower + Degree);
+ rational = BSplCLib::IsRational(*Weights, WLower, WLower + Degree);
}
-
+
// make the poles
- if (rational) {
+ if (rational)
+ {
dim = Dimension_gen + 1;
- BSplCLib::BuildEval(Degree, index, Poles, Weights , *dc.poles);
+ BSplCLib::BuildEval(Degree, index, Poles, Weights, *dc.poles);
}
- else {
- dim = Dimension_gen;
+ else
+ {
+ dim = Dimension_gen;
BSplCLib::BuildEval(Degree, index, Poles, BSplCLib::NoWeights(), *dc.poles);
}
}
//=================================================================================================
-
-void BSplCLib::D0
-(const Standard_Real U,
- const Standard_Integer Index,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger* Mults,
- Point& P)
-{
-// Standard_Integer k,dim,index = Index;
- Standard_Integer dim,index = Index;
- Standard_Real u = U;
- Standard_Boolean rational;
+void BSplCLib::D0(const Standard_Real U,
+ const Standard_Integer Index,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger* Mults,
+ Point& P)
+{
+ // Standard_Integer k,dim,index = Index;
+ Standard_Integer dim, index = Index;
+ Standard_Real u = U;
+ Standard_Boolean rational;
BSplCLib_DataContainer dc(Degree);
- PrepareEval(u,index,dim,rational,Degree,Periodic,Poles,Weights,Knots,Mults,dc);
- BSplCLib::Eval(u,Degree,*dc.knots,dim,*dc.poles);
+ PrepareEval(u, index, dim, rational, Degree, Periodic, Poles, Weights, Knots, Mults, dc);
+ BSplCLib::Eval(u, Degree, *dc.knots, dim, *dc.poles);
- if (rational) {
+ if (rational)
+ {
Standard_Real w = dc.poles[Dimension_gen];
- CoordsToPoint (P, dc.poles, / w);
+ CoordsToPoint(P, dc.poles, / w);
}
else
- CoordsToPoint (P, dc.poles, );
+ CoordsToPoint(P, dc.poles, );
}
//=================================================================================================
-
-void BSplCLib::D1
-(const Standard_Real U,
- const Standard_Integer Index,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger* Mults,
- Point& P,
- Vector& V)
-{
- Standard_Integer dim,index = Index;
- Standard_Real u = U;
- Standard_Boolean rational;
+void BSplCLib::D1(const Standard_Real U,
+ const Standard_Integer Index,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger* Mults,
+ Point& P,
+ Vector& V)
+{
+ Standard_Integer dim, index = Index;
+ Standard_Real u = U;
+ Standard_Boolean rational;
BSplCLib_DataContainer dc(Degree);
- PrepareEval(u,index,dim,rational,Degree,Periodic,Poles,Weights,Knots,Mults,dc);
- BSplCLib::Bohm(u,Degree,1,*dc.knots,dim,*dc.poles);
- Standard_Real *result = dc.poles;
- if (rational) {
- PLib::RationalDerivative(Degree,1,Dimension_gen,*dc.poles,*dc.ders);
+ PrepareEval(u, index, dim, rational, Degree, Periodic, Poles, Weights, Knots, Mults, dc);
+ BSplCLib::Bohm(u, Degree, 1, *dc.knots, dim, *dc.poles);
+ Standard_Real* result = dc.poles;
+ if (rational)
+ {
+ PLib::RationalDerivative(Degree, 1, Dimension_gen, *dc.poles, *dc.ders);
result = dc.ders;
}
-
- CoordsToPoint (P, result, );
- CoordsToPoint (V, result + Dimension_gen, );
+
+ CoordsToPoint(P, result, );
+ CoordsToPoint(V, result + Dimension_gen, );
}
//=================================================================================================
-
-void BSplCLib::D2
-(const Standard_Real U,
- const Standard_Integer Index,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger* Mults,
- Point& P,
- Vector& V1,
- Vector& V2)
-{
- Standard_Integer dim,index = Index;
- Standard_Real u = U;
- Standard_Boolean rational;
+void BSplCLib::D2(const Standard_Real U,
+ const Standard_Integer Index,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger* Mults,
+ Point& P,
+ Vector& V1,
+ Vector& V2)
+{
+ Standard_Integer dim, index = Index;
+ Standard_Real u = U;
+ Standard_Boolean rational;
BSplCLib_DataContainer dc(Degree);
- PrepareEval(u,index,dim,rational,Degree,Periodic,Poles,Weights,Knots,Mults,dc);
- BSplCLib::Bohm(u,Degree,2,*dc.knots,dim,*dc.poles);
- Standard_Real *result = dc.poles;
- if (rational) {
- PLib::RationalDerivative(Degree,2,Dimension_gen,*dc.poles,*dc.ders);
+ PrepareEval(u, index, dim, rational, Degree, Periodic, Poles, Weights, Knots, Mults, dc);
+ BSplCLib::Bohm(u, Degree, 2, *dc.knots, dim, *dc.poles);
+ Standard_Real* result = dc.poles;
+ if (rational)
+ {
+ PLib::RationalDerivative(Degree, 2, Dimension_gen, *dc.poles, *dc.ders);
result = dc.ders;
}
-
- CoordsToPoint (P, result, );
- CoordsToPoint (V1, result + Dimension_gen, );
- if (!rational && (Degree < 2))
- NullifyPoint (V2);
+
+ CoordsToPoint(P, result, );
+ CoordsToPoint(V1, result + Dimension_gen, );
+ if (!rational && (Degree < 2))
+ NullifyPoint(V2);
else
- CoordsToPoint (V2, result + 2 * Dimension_gen, );
+ CoordsToPoint(V2, result + 2 * Dimension_gen, );
}
//=================================================================================================
-
-void BSplCLib::D3
-(const Standard_Real U,
- const Standard_Integer Index,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger* Mults,
- Point& P,
- Vector& V1,
- Vector& V2,
- Vector& V3)
-{
- Standard_Integer dim,index = Index;
- Standard_Real u = U;
- Standard_Boolean rational;
+void BSplCLib::D3(const Standard_Real U,
+ const Standard_Integer Index,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger* Mults,
+ Point& P,
+ Vector& V1,
+ Vector& V2,
+ Vector& V3)
+{
+ Standard_Integer dim, index = Index;
+ Standard_Real u = U;
+ Standard_Boolean rational;
BSplCLib_DataContainer dc(Degree);
- PrepareEval(u,index,dim,rational,Degree,Periodic,Poles,Weights,Knots,Mults,dc);
- BSplCLib::Bohm(u,Degree,3,*dc.knots,dim,*dc.poles);
- Standard_Real *result = dc.poles;
- if (rational) {
- PLib::RationalDerivative(Degree,3,Dimension_gen,*dc.poles,*dc.ders);
+ PrepareEval(u, index, dim, rational, Degree, Periodic, Poles, Weights, Knots, Mults, dc);
+ BSplCLib::Bohm(u, Degree, 3, *dc.knots, dim, *dc.poles);
+ Standard_Real* result = dc.poles;
+ if (rational)
+ {
+ PLib::RationalDerivative(Degree, 3, Dimension_gen, *dc.poles, *dc.ders);
result = dc.ders;
}
- CoordsToPoint (P, result, );
- CoordsToPoint (V1, result + Dimension_gen, );
- if (!rational && (Degree < 2))
- NullifyPoint (V2);
+ CoordsToPoint(P, result, );
+ CoordsToPoint(V1, result + Dimension_gen, );
+ if (!rational && (Degree < 2))
+ NullifyPoint(V2);
else
- CoordsToPoint (V2, result + 2 * Dimension_gen, );
- if (!rational && (Degree < 3))
- NullifyPoint (V3);
+ CoordsToPoint(V2, result + 2 * Dimension_gen, );
+ if (!rational && (Degree < 3))
+ NullifyPoint(V3);
else
- CoordsToPoint (V3, result + 3 * Dimension_gen, );
+ CoordsToPoint(V3, result + 3 * Dimension_gen, );
}
//=================================================================================================
-
-void BSplCLib::DN
-(const Standard_Real U,
- const Standard_Integer N,
- const Standard_Integer Index,
- const Standard_Integer Degree,
- const Standard_Boolean Periodic,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger* Mults,
- Vector& VN)
-{
- Standard_Integer dim,index = Index;
- Standard_Real u = U;
- Standard_Boolean rational;
+void BSplCLib::DN(const Standard_Real U,
+ const Standard_Integer N,
+ const Standard_Integer Index,
+ const Standard_Integer Degree,
+ const Standard_Boolean Periodic,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger* Mults,
+ Vector& VN)
+{
+ Standard_Integer dim, index = Index;
+ Standard_Real u = U;
+ Standard_Boolean rational;
BSplCLib_DataContainer dc(Degree);
- PrepareEval(u,index,dim,rational,Degree,Periodic,Poles,Weights,Knots,Mults,dc);
- BSplCLib::Bohm(u,Degree,N,*dc.knots,dim,*dc.poles);
+ PrepareEval(u, index, dim, rational, Degree, Periodic, Poles, Weights, Knots, Mults, dc);
+ BSplCLib::Bohm(u, Degree, N, *dc.knots, dim, *dc.poles);
- if (rational) {
+ if (rational)
+ {
Standard_Real v[Dimension_gen];
- PLib::RationalDerivative(Degree,N,Dimension_gen,*dc.poles,v[0],Standard_False);
- CoordsToPoint (VN, v, );
+ PLib::RationalDerivative(Degree, N, Dimension_gen, *dc.poles, v[0], Standard_False);
+ CoordsToPoint(VN, v, );
}
- else {
- if (N > Degree)
- NullifyPoint (VN);
- else {
- Standard_Real *DN = dc.poles + N * Dimension_gen;
- CoordsToPoint (VN, DN, );
+ else
+ {
+ if (N > Degree)
+ NullifyPoint(VN);
+ else
+ {
+ Standard_Real* DN = dc.poles + N * Dimension_gen;
+ CoordsToPoint(VN, DN, );
}
}
}
//=================================================================================================
-
-Standard_Integer
-BSplCLib::SolveBandedSystem(const math_Matrix& Matrix,
- const Standard_Integer UpperBandWidth,
- const Standard_Integer LowerBandWidth,
- Array1OfPoints& PolesArray)
+Standard_Integer BSplCLib::SolveBandedSystem(const math_Matrix& Matrix,
+ const Standard_Integer UpperBandWidth,
+ const Standard_Integer LowerBandWidth,
+ Array1OfPoints& PolesArray)
{
- Standard_Real *PArray ;
- PArray = (Standard_Real *) &PolesArray(PolesArray.Lower()) ;
-
+ Standard_Real* PArray;
+ PArray = (Standard_Real*)&PolesArray(PolesArray.Lower());
+
return BSplCLib::SolveBandedSystem(Matrix,
- UpperBandWidth,
- LowerBandWidth,
- Dimension_gen,
- PArray[0]) ;
+ UpperBandWidth,
+ LowerBandWidth,
+ Dimension_gen,
+ PArray[0]);
}
//=======================================================================
-//function : Solves a LU factored Matrix
-//purpose : if HomogeneousFlag is 1 then the input and the output
+// function : Solves a LU factored Matrix
+// purpose : if HomogeneousFlag is 1 then the input and the output
// will be homogeneous that is no division or multiplication
// by weights will happen. On the contrary if HomogeneousFlag
// is 0 then the poles will be multiplied first by the weights
// and after interpolation they will be divided by the weights
//=======================================================================
-Standard_Integer
-BSplCLib::SolveBandedSystem(const math_Matrix& Matrix,
- const Standard_Integer UpperBandWidth,
- const Standard_Integer LowerBandWidth,
- const Standard_Boolean HomogeneousFlag,
- Array1OfPoints& PolesArray,
- TColStd_Array1OfReal& WeightsArray)
+Standard_Integer BSplCLib::SolveBandedSystem(const math_Matrix& Matrix,
+ const Standard_Integer UpperBandWidth,
+ const Standard_Integer LowerBandWidth,
+ const Standard_Boolean HomogeneousFlag,
+ Array1OfPoints& PolesArray,
+ TColStd_Array1OfReal& WeightsArray)
{
- Standard_Real *PArray,
- * WArray ;
- PArray = (Standard_Real *) &PolesArray(PolesArray.Lower()) ;
- WArray = (Standard_Real *) &WeightsArray(WeightsArray.Lower()) ;
+ Standard_Real *PArray, *WArray;
+ PArray = (Standard_Real*)&PolesArray(PolesArray.Lower());
+ WArray = (Standard_Real*)&WeightsArray(WeightsArray.Lower());
return BSplCLib::SolveBandedSystem(Matrix,
- UpperBandWidth,
- LowerBandWidth,
- HomogeneousFlag,
- Dimension_gen,
- PArray[0],
- WArray[0]) ;
+ UpperBandWidth,
+ LowerBandWidth,
+ HomogeneousFlag,
+ Dimension_gen,
+ PArray[0],
+ WArray[0]);
}
//=======================================================================
-//function : Evaluates a Bspline function : uses the ExtrapMode
-//purpose : the function is extrapolated using the Taylor expansion
+// function : Evaluates a Bspline function : uses the ExtrapMode
+// purpose : the function is extrapolated using the Taylor expansion
// of degree ExtrapMode[0] to the left and the Taylor
-// expansion of degree ExtrapMode[1] to the right
+// expansion of degree ExtrapMode[1] to the right
// if the HomogeneousFlag == True than the Poles are supposed
// to be stored homogeneously and the result will also be homogeneous
-// Valid only if Weights
+// Valid only if Weights
//=======================================================================
-void BSplCLib::Eval(const Standard_Real Parameter,
- const Standard_Boolean PeriodicFlag,
- const Standard_Boolean HomogeneousFlag,
- Standard_Integer& ExtrapMode,
- const Standard_Integer Degree,
- const TColStd_Array1OfReal& FlatKnots,
- const Array1OfPoints& PolesArray,
- const TColStd_Array1OfReal& WeightsArray,
- Point& aPoint,
- Standard_Real& aWeight)
+void BSplCLib::Eval(const Standard_Real Parameter,
+ const Standard_Boolean PeriodicFlag,
+ const Standard_Boolean HomogeneousFlag,
+ Standard_Integer& ExtrapMode,
+ const Standard_Integer Degree,
+ const TColStd_Array1OfReal& FlatKnots,
+ const Array1OfPoints& PolesArray,
+ const TColStd_Array1OfReal& WeightsArray,
+ Point& aPoint,
+ Standard_Real& aWeight)
{
- Standard_Real Inverse,
- P[Dimension_gen],
- *PArray,
- *WArray ;
- Standard_Integer kk ;
- PArray = (Standard_Real *) &PolesArray(PolesArray.Lower()) ;
- WArray = (Standard_Real *) &WeightsArray(WeightsArray.Lower()) ;
- if (HomogeneousFlag) {
+ Standard_Real Inverse, P[Dimension_gen], *PArray, *WArray;
+ Standard_Integer kk;
+ PArray = (Standard_Real*)&PolesArray(PolesArray.Lower());
+ WArray = (Standard_Real*)&WeightsArray(WeightsArray.Lower());
+ if (HomogeneousFlag)
+ {
BSplCLib::Eval(Parameter,
- PeriodicFlag,
- 0,
- ExtrapMode,
- Degree,
- FlatKnots,
- Dimension_gen,
- PArray[0],
- P[0]) ;
+ PeriodicFlag,
+ 0,
+ ExtrapMode,
+ Degree,
+ FlatKnots,
+ Dimension_gen,
+ PArray[0],
+ P[0]);
BSplCLib::Eval(Parameter,
- PeriodicFlag,
- 0,
- ExtrapMode,
- Degree,
- FlatKnots,
- 1,
- WArray[0],
- aWeight) ;
+ PeriodicFlag,
+ 0,
+ ExtrapMode,
+ Degree,
+ FlatKnots,
+ 1,
+ WArray[0],
+ aWeight);
}
- else {
+ else
+ {
BSplCLib::Eval(Parameter,
- PeriodicFlag,
- 0,
- ExtrapMode,
- Degree,
- FlatKnots,
- Dimension_gen,
- PArray[0],
- WArray[0],
- P[0],
- aWeight) ;
- Inverse = 1.0e0 / aWeight ;
-
- for (kk = 0 ; kk < Dimension_gen ; kk++) {
- P[kk] *= Inverse ;
- }
+ PeriodicFlag,
+ 0,
+ ExtrapMode,
+ Degree,
+ FlatKnots,
+ Dimension_gen,
+ PArray[0],
+ WArray[0],
+ P[0],
+ aWeight);
+ Inverse = 1.0e0 / aWeight;
+
+ for (kk = 0; kk < Dimension_gen; kk++)
+ {
+ P[kk] *= Inverse;
+ }
}
-
- for (kk = 0 ; kk < Dimension_gen ; kk++)
- aPoint.SetCoord(kk + 1, P[kk]) ;
+
+ for (kk = 0; kk < Dimension_gen; kk++)
+ aPoint.SetCoord(kk + 1, P[kk]);
}
//=======================================================================
-//function : CacheD0
-//purpose : Evaluates the polynomial cache of the Bspline Curve
-//
+// function : CacheD0
+// purpose : Evaluates the polynomial cache of the Bspline Curve
+//
//=======================================================================
-void BSplCLib::CacheD0(const Standard_Real Parameter,
- const Standard_Integer Degree,
- const Standard_Real CacheParameter,
- const Standard_Real SpanLenght,
- const Array1OfPoints& PolesArray,
- const TColStd_Array1OfReal* WeightsArray,
- Point& aPoint)
+void BSplCLib::CacheD0(const Standard_Real Parameter,
+ const Standard_Integer Degree,
+ const Standard_Real CacheParameter,
+ const Standard_Real SpanLenght,
+ const Array1OfPoints& PolesArray,
+ const TColStd_Array1OfReal* WeightsArray,
+ Point& aPoint)
{
//
// the CacheParameter is where the cache polynomial was evaluated in homogeneous
// form
// the SpanLenght is the normalizing factor so that the polynomial is between
- // 0 and 1
- Standard_Real NewParameter, Inverse;
- Standard_Real * PArray = (Standard_Real *) &(PolesArray(PolesArray.Lower())) ;
- Standard_Real * myPoint = (Standard_Real *) &aPoint ;
- NewParameter = (Parameter - CacheParameter) / SpanLenght ;
+ // 0 and 1
+ Standard_Real NewParameter, Inverse;
+ Standard_Real* PArray = (Standard_Real*)&(PolesArray(PolesArray.Lower()));
+ Standard_Real* myPoint = (Standard_Real*)&aPoint;
+ NewParameter = (Parameter - CacheParameter) / SpanLenght;
PLib::NoDerivativeEvalPolynomial(NewParameter,
- Degree,
- Dimension_gen,
- Degree * Dimension_gen,
- PArray[0],
- myPoint[0]) ;
- if (WeightsArray != NULL) {
+ Degree,
+ Dimension_gen,
+ Degree * Dimension_gen,
+ PArray[0],
+ myPoint[0]);
+ if (WeightsArray != NULL)
+ {
const TColStd_Array1OfReal& refWeights = *WeightsArray;
- Standard_Real *
- WArray = (Standard_Real *) &refWeights(refWeights.Lower()) ;
- PLib::NoDerivativeEvalPolynomial(NewParameter,
- Degree,
- 1,
- Degree,
- WArray[0],
- Inverse) ;
-
+ Standard_Real* WArray = (Standard_Real*)&refWeights(refWeights.Lower());
+ PLib::NoDerivativeEvalPolynomial(NewParameter, Degree, 1, Degree, WArray[0], Inverse);
+
Inverse = 1.0e0 / Inverse;
- ModifyCoords (myPoint, *= Inverse);
+ ModifyCoords(myPoint, *= Inverse);
}
}
//=======================================================================
-//function : CacheD1
-//purpose : Evaluates the polynomial cache of the Bspline Curve
-//
+// function : CacheD1
+// purpose : Evaluates the polynomial cache of the Bspline Curve
+//
//=======================================================================
-void BSplCLib::CacheD1(const Standard_Real Parameter,
- const Standard_Integer Degree,
- const Standard_Real CacheParameter,
- const Standard_Real SpanLenght,
- const Array1OfPoints& PolesArray,
- const TColStd_Array1OfReal* WeightsArray,
- Point& aPoint,
- Vector& aVector)
+void BSplCLib::CacheD1(const Standard_Real Parameter,
+ const Standard_Integer Degree,
+ const Standard_Real CacheParameter,
+ const Standard_Real SpanLenght,
+ const Array1OfPoints& PolesArray,
+ const TColStd_Array1OfReal* WeightsArray,
+ Point& aPoint,
+ Vector& aVector)
{
//
// the CacheParameter is where the cache polynomial was evaluated in homogeneous
// form
// the SpanLenght is the normalizing factor so that the polynomial is between
- // 0 and 1
- Standard_Real LocalPDerivatives[Dimension_gen << 1] ;
-// Standard_Real LocalWDerivatives[2], NewParameter, Inverse ;
- Standard_Real LocalWDerivatives[2], NewParameter ;
-
- Standard_Real *
- PArray = (Standard_Real *) &(PolesArray(PolesArray.Lower())) ;
- Standard_Real *
- myPoint = (Standard_Real *) &aPoint ;
- Standard_Real *
- myVector = (Standard_Real *) &aVector ;
- NewParameter = (Parameter - CacheParameter) / SpanLenght ;
- PLib::EvalPolynomial(NewParameter,
- 1,
- Degree,
- Dimension_gen,
- PArray[0],
- LocalPDerivatives[0]) ;
- //
+ // 0 and 1
+ Standard_Real LocalPDerivatives[Dimension_gen << 1];
+ // Standard_Real LocalWDerivatives[2], NewParameter, Inverse ;
+ Standard_Real LocalWDerivatives[2], NewParameter;
+
+ Standard_Real* PArray = (Standard_Real*)&(PolesArray(PolesArray.Lower()));
+ Standard_Real* myPoint = (Standard_Real*)&aPoint;
+ Standard_Real* myVector = (Standard_Real*)&aVector;
+ NewParameter = (Parameter - CacheParameter) / SpanLenght;
+ PLib::EvalPolynomial(NewParameter, 1, Degree, Dimension_gen, PArray[0], LocalPDerivatives[0]);
+ //
// unormalize derivatives since those are computed normalized
//
- ModifyCoords (LocalPDerivatives + Dimension_gen, /= SpanLenght);
-
- if (WeightsArray != NULL) {
+ ModifyCoords(LocalPDerivatives + Dimension_gen, /= SpanLenght);
+
+ if (WeightsArray != NULL)
+ {
const TColStd_Array1OfReal& refWeights = *WeightsArray;
- Standard_Real *
- WArray = (Standard_Real *) &refWeights(refWeights.Lower()) ;
- PLib::EvalPolynomial(NewParameter,
- 1,
- Degree,
- 1,
- WArray[0],
- LocalWDerivatives[0]) ;
- //
+ Standard_Real* WArray = (Standard_Real*)&refWeights(refWeights.Lower());
+ PLib::EvalPolynomial(NewParameter, 1, Degree, 1, WArray[0], LocalWDerivatives[0]);
+ //
// unormalize the result since the polynomial stored in the cache
// is normalized between 0 and 1
//
- LocalWDerivatives[1] /= SpanLenght ;
-
+ LocalWDerivatives[1] /= SpanLenght;
+
PLib::RationalDerivatives(1,
- Dimension_gen,
- LocalPDerivatives[0],
- LocalWDerivatives[0],
- LocalPDerivatives[0]) ;
+ Dimension_gen,
+ LocalPDerivatives[0],
+ LocalWDerivatives[0],
+ LocalPDerivatives[0]);
}
-
- CopyCoords (myPoint, LocalPDerivatives);
- CopyCoords (myVector, LocalPDerivatives + Dimension_gen);
+
+ CopyCoords(myPoint, LocalPDerivatives);
+ CopyCoords(myVector, LocalPDerivatives + Dimension_gen);
}
//=======================================================================
-//function : CacheD2
-//purpose : Evaluates the polynomial cache of the Bspline Curve
-//
+// function : CacheD2
+// purpose : Evaluates the polynomial cache of the Bspline Curve
+//
//=======================================================================
-void BSplCLib::CacheD2(const Standard_Real Parameter,
- const Standard_Integer Degree,
- const Standard_Real CacheParameter,
- const Standard_Real SpanLenght,
- const Array1OfPoints& PolesArray,
- const TColStd_Array1OfReal* WeightsArray,
- Point& aPoint,
- Vector& aVector1,
- Vector& aVector2)
+void BSplCLib::CacheD2(const Standard_Real Parameter,
+ const Standard_Integer Degree,
+ const Standard_Real CacheParameter,
+ const Standard_Real SpanLenght,
+ const Array1OfPoints& PolesArray,
+ const TColStd_Array1OfReal* WeightsArray,
+ Point& aPoint,
+ Vector& aVector1,
+ Vector& aVector2)
{
//
// the CacheParameter is where the cache polynomial was evaluated in homogeneous
// form
// the SpanLenght is the normalizing factor so that the polynomial is between
- // 0 and 1
- Standard_Integer ii,Index,EndIndex;
- Standard_Real LocalPDerivatives[(Dimension_gen << 1) + Dimension_gen] ;
-// Standard_Real LocalWDerivatives[3], NewParameter, Factor, Inverse ;
- Standard_Real LocalWDerivatives[3], NewParameter, Factor ;
- Standard_Real * PArray = (Standard_Real *) &(PolesArray(PolesArray.Lower())) ;
- Standard_Real * myPoint = (Standard_Real *) &aPoint ;
- Standard_Real * myVector1 = (Standard_Real *) &aVector1 ;
- Standard_Real * myVector2 = (Standard_Real *) &aVector2 ;
- NewParameter = (Parameter - CacheParameter) / SpanLenght ;
- PLib::EvalPolynomial(NewParameter,
- 2,
- Degree,
- Dimension_gen,
- PArray[0],
- LocalPDerivatives[0]) ;
- //
+ // 0 and 1
+ Standard_Integer ii, Index, EndIndex;
+ Standard_Real LocalPDerivatives[(Dimension_gen << 1) + Dimension_gen];
+ // Standard_Real LocalWDerivatives[3], NewParameter, Factor, Inverse ;
+ Standard_Real LocalWDerivatives[3], NewParameter, Factor;
+ Standard_Real* PArray = (Standard_Real*)&(PolesArray(PolesArray.Lower()));
+ Standard_Real* myPoint = (Standard_Real*)&aPoint;
+ Standard_Real* myVector1 = (Standard_Real*)&aVector1;
+ Standard_Real* myVector2 = (Standard_Real*)&aVector2;
+ NewParameter = (Parameter - CacheParameter) / SpanLenght;
+ PLib::EvalPolynomial(NewParameter, 2, Degree, Dimension_gen, PArray[0], LocalPDerivatives[0]);
+ //
// unormalize derivatives since those are computed normalized
//
- Factor = 1.0e0/ SpanLenght ;
- Index = Dimension_gen ;
- EndIndex = Min (2, Degree) ;
-
- for (ii = 1 ; ii <= EndIndex ; ii++) {
- ModifyCoords (LocalPDerivatives + Index, *= Factor);
- Factor /= SpanLenght ;
- Index += Dimension_gen;
+ Factor = 1.0e0 / SpanLenght;
+ Index = Dimension_gen;
+ EndIndex = Min(2, Degree);
+
+ for (ii = 1; ii <= EndIndex; ii++)
+ {
+ ModifyCoords(LocalPDerivatives + Index, *= Factor);
+ Factor /= SpanLenght;
+ Index += Dimension_gen;
}
Index = (Degree + 1) * Dimension_gen;
- for (ii = Degree ; ii < 2 ; ii++) {
- NullifyCoords (LocalPDerivatives + Index);
+ for (ii = Degree; ii < 2; ii++)
+ {
+ NullifyCoords(LocalPDerivatives + Index);
Index += Dimension_gen;
}
- if (WeightsArray != NULL) {
+ if (WeightsArray != NULL)
+ {
const TColStd_Array1OfReal& refWeights = *WeightsArray;
- Standard_Real *
- WArray = (Standard_Real *) &refWeights(refWeights.Lower()) ;
-
- PLib::EvalPolynomial(NewParameter,
- 2,
- Degree,
- 1,
- WArray[0],
- LocalWDerivatives[0]) ;
-
- for (ii = Degree + 1 ; ii <= 2 ; ii++) {
- LocalWDerivatives[ii] = 0.0e0 ;
+ Standard_Real* WArray = (Standard_Real*)&refWeights(refWeights.Lower());
+
+ PLib::EvalPolynomial(NewParameter, 2, Degree, 1, WArray[0], LocalWDerivatives[0]);
+
+ for (ii = Degree + 1; ii <= 2; ii++)
+ {
+ LocalWDerivatives[ii] = 0.0e0;
}
- //
+ //
// unormalize the result since the polynomial stored in the cache
// is normalized between 0 and 1
//
- Factor = 1.0e0 / SpanLenght ;
+ Factor = 1.0e0 / SpanLenght;
- for (ii = 1 ; ii <= EndIndex ; ii++) {
- LocalWDerivatives[ii] *= Factor ;
- Factor /= SpanLenght ;
+ for (ii = 1; ii <= EndIndex; ii++)
+ {
+ LocalWDerivatives[ii] *= Factor;
+ Factor /= SpanLenght;
}
PLib::RationalDerivatives(2,
- Dimension_gen,
- LocalPDerivatives[0],
- LocalWDerivatives[0],
- LocalPDerivatives[0]) ;
+ Dimension_gen,
+ LocalPDerivatives[0],
+ LocalWDerivatives[0],
+ LocalPDerivatives[0]);
}
- CopyCoords (myPoint, LocalPDerivatives);
- CopyCoords (myVector1, LocalPDerivatives + Dimension_gen);
- CopyCoords (myVector2, LocalPDerivatives + Dimension_gen * 2);
+ CopyCoords(myPoint, LocalPDerivatives);
+ CopyCoords(myVector1, LocalPDerivatives + Dimension_gen);
+ CopyCoords(myVector2, LocalPDerivatives + Dimension_gen * 2);
}
//=======================================================================
-//function : CacheD3
-//purpose : Evaluates the polynomial cache of the Bspline Curve
-//
+// function : CacheD3
+// purpose : Evaluates the polynomial cache of the Bspline Curve
+//
//=======================================================================
-void BSplCLib::CacheD3(const Standard_Real Parameter,
- const Standard_Integer Degree,
- const Standard_Real CacheParameter,
- const Standard_Real SpanLenght,
- const Array1OfPoints& PolesArray,
- const TColStd_Array1OfReal* WeightsArray,
- Point& aPoint,
- Vector& aVector1,
- Vector& aVector2,
- Vector& aVector3)
+void BSplCLib::CacheD3(const Standard_Real Parameter,
+ const Standard_Integer Degree,
+ const Standard_Real CacheParameter,
+ const Standard_Real SpanLenght,
+ const Array1OfPoints& PolesArray,
+ const TColStd_Array1OfReal* WeightsArray,
+ Point& aPoint,
+ Vector& aVector1,
+ Vector& aVector2,
+ Vector& aVector3)
{
//
// the CacheParameter is where the cache polynomial was evaluated in homogeneous
// form
// the SpanLenght is the normalizing factor so that the polynomial is between
- // 0 and 1
+ // 0 and 1
Standard_Integer ii, Index, EndIndex;
- Standard_Real LocalPDerivatives[Dimension_gen << 2] ;
-// Standard_Real LocalWDerivatives[4], Factor, NewParameter, Inverse ;
- Standard_Real LocalWDerivatives[4], Factor, NewParameter ;
- Standard_Real * PArray = (Standard_Real *) &(PolesArray(PolesArray.Lower())) ;
- Standard_Real * myPoint = (Standard_Real *) &aPoint ;
- Standard_Real * myVector1 = (Standard_Real *) &aVector1 ;
- Standard_Real * myVector2 = (Standard_Real *) &aVector2 ;
- Standard_Real * myVector3 = (Standard_Real *) &aVector3 ;
- NewParameter = (Parameter - CacheParameter) / SpanLenght ;
- PLib::EvalPolynomial(NewParameter,
- 3,
- Degree,
- Dimension_gen,
- PArray[0],
- LocalPDerivatives[0]) ;
+ Standard_Real LocalPDerivatives[Dimension_gen << 2];
+ // Standard_Real LocalWDerivatives[4], Factor, NewParameter, Inverse ;
+ Standard_Real LocalWDerivatives[4], Factor, NewParameter;
+ Standard_Real* PArray = (Standard_Real*)&(PolesArray(PolesArray.Lower()));
+ Standard_Real* myPoint = (Standard_Real*)&aPoint;
+ Standard_Real* myVector1 = (Standard_Real*)&aVector1;
+ Standard_Real* myVector2 = (Standard_Real*)&aVector2;
+ Standard_Real* myVector3 = (Standard_Real*)&aVector3;
+ NewParameter = (Parameter - CacheParameter) / SpanLenght;
+ PLib::EvalPolynomial(NewParameter, 3, Degree, Dimension_gen, PArray[0], LocalPDerivatives[0]);
Index = (Degree + 1) * Dimension_gen;
- for (ii = Degree ; ii < 3 ; ii++) {
- NullifyCoords (LocalPDerivatives + Index);
+ for (ii = Degree; ii < 3; ii++)
+ {
+ NullifyCoords(LocalPDerivatives + Index);
Index += Dimension_gen;
}
-
- //
+
+ //
// unormalize derivatives since those are computed normalized
//
- Factor = 1.0e0 / SpanLenght ;
- Index = Dimension_gen ;
- EndIndex = Min(3,Degree) ;
+ Factor = 1.0e0 / SpanLenght;
+ Index = Dimension_gen;
+ EndIndex = Min(3, Degree);
- for (ii = 1 ; ii <= EndIndex ; ii++) {
- ModifyCoords (LocalPDerivatives + Index, *= Factor);
+ for (ii = 1; ii <= EndIndex; ii++)
+ {
+ ModifyCoords(LocalPDerivatives + Index, *= Factor);
Factor /= SpanLenght;
- Index += Dimension_gen;
+ Index += Dimension_gen;
}
-
- if (WeightsArray != NULL) {
+
+ if (WeightsArray != NULL)
+ {
const TColStd_Array1OfReal& refWeights = *WeightsArray;
- Standard_Real *
- WArray = (Standard_Real *) &refWeights(refWeights.Lower()) ;
-
- PLib::EvalPolynomial(NewParameter,
- 3,
- Degree,
- 1,
- WArray[0],
- LocalWDerivatives[0]) ;
- //
+ Standard_Real* WArray = (Standard_Real*)&refWeights(refWeights.Lower());
+
+ PLib::EvalPolynomial(NewParameter, 3, Degree, 1, WArray[0], LocalWDerivatives[0]);
+ //
// unormalize the result since the polynomial stored in the cache
// is normalized between 0 and 1
//
- Factor = 1.0e0 / SpanLenght ;
+ Factor = 1.0e0 / SpanLenght;
- for (ii = 1 ; ii <= EndIndex ; ii++) {
- LocalWDerivatives[ii] *= Factor ;
- Factor /= SpanLenght ;
+ for (ii = 1; ii <= EndIndex; ii++)
+ {
+ LocalWDerivatives[ii] *= Factor;
+ Factor /= SpanLenght;
}
- for (ii = (Degree + 1) ; ii <= 3 ; ii++) {
- LocalWDerivatives[ii] = 0.0e0 ;
+ for (ii = (Degree + 1); ii <= 3; ii++)
+ {
+ LocalWDerivatives[ii] = 0.0e0;
}
PLib::RationalDerivatives(3,
- Dimension_gen,
- LocalPDerivatives[0],
- LocalWDerivatives[0],
- LocalPDerivatives[0]) ;
+ Dimension_gen,
+ LocalPDerivatives[0],
+ LocalWDerivatives[0],
+ LocalPDerivatives[0]);
}
-
- CopyCoords (myPoint, LocalPDerivatives);
- CopyCoords (myVector1, LocalPDerivatives + Dimension_gen);
- CopyCoords (myVector2, LocalPDerivatives + Dimension_gen * 2);
- CopyCoords (myVector3, LocalPDerivatives + Dimension_gen * 3);
+
+ CopyCoords(myPoint, LocalPDerivatives);
+ CopyCoords(myVector1, LocalPDerivatives + Dimension_gen);
+ CopyCoords(myVector2, LocalPDerivatives + Dimension_gen * 2);
+ CopyCoords(myVector3, LocalPDerivatives + Dimension_gen * 3);
}
//=======================================================================
-//function : BuildCache
-//purpose : Stores theTaylor expansion normalized between 0,1 in the
+// function : BuildCache
+// purpose : Stores theTaylor expansion normalized between 0,1 in the
// Cache : in case of a rational function the Poles are
-// stored in homogeneous form
+// stored in homogeneous form
//=======================================================================
-void BSplCLib::BuildCache
-(const Standard_Real U,
- const Standard_Real SpanDomain,
- const Standard_Boolean Periodic,
- const Standard_Integer Degree,
- const TColStd_Array1OfReal& FlatKnots,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- Array1OfPoints& CachePoles,
- TColStd_Array1OfReal* CacheWeights)
-{
- Standard_Integer ii,
- Dimension,
- LocalIndex,
- index = 0 ;
- Standard_Real u = U,
- LocalValue ;
+void BSplCLib::BuildCache(const Standard_Real U,
+ const Standard_Real SpanDomain,
+ const Standard_Boolean Periodic,
+ const Standard_Integer Degree,
+ const TColStd_Array1OfReal& FlatKnots,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ Array1OfPoints& CachePoles,
+ TColStd_Array1OfReal* CacheWeights)
+{
+ Standard_Integer ii, Dimension, LocalIndex, index = 0;
+ Standard_Real u = U, LocalValue;
Standard_Boolean rational;
-
+
BSplCLib_DataContainer dc(Degree);
PrepareEval(u,
index,
FlatKnots,
(BSplCLib::NoMults()),
dc);
- //
+ //
// Watch out : PrepareEval checks if locally the Bspline is polynomial
- // therefore rational flag could be set to False even if there are
+ // therefore rational flag could be set to False even if there are
// Weights. The Dimension is set accordingly.
//
-
- BSplCLib::Bohm(u,Degree,Degree,*dc.knots,Dimension,*dc.poles);
-
- LocalValue = 1.0e0 ;
- LocalIndex = 0 ;
-
- if (rational) {
-
- for (ii = 1 ; ii <= Degree + 1 ; ii++) {
- CoordsToPoint (CachePoles(ii), dc.poles + LocalIndex, * LocalValue);
+
+ BSplCLib::Bohm(u, Degree, Degree, *dc.knots, Dimension, *dc.poles);
+
+ LocalValue = 1.0e0;
+ LocalIndex = 0;
+
+ if (rational)
+ {
+
+ for (ii = 1; ii <= Degree + 1; ii++)
+ {
+ CoordsToPoint(CachePoles(ii), dc.poles + LocalIndex, *LocalValue);
LocalIndex += Dimension_gen + 1;
- LocalValue *= SpanDomain / (Standard_Real) ii ;
+ LocalValue *= SpanDomain / (Standard_Real)ii;
}
LocalIndex = Dimension_gen;
- LocalValue = 1.0e0 ;
- for (ii = 1 ; ii <= Degree + 1 ; ii++) {
- (*CacheWeights)(ii) = dc.poles[LocalIndex] * LocalValue ;
+ LocalValue = 1.0e0;
+ for (ii = 1; ii <= Degree + 1; ii++)
+ {
+ (*CacheWeights)(ii) = dc.poles[LocalIndex] * LocalValue;
LocalIndex += Dimension_gen + 1;
- LocalValue *= SpanDomain / (Standard_Real) ii ;
+ LocalValue *= SpanDomain / (Standard_Real)ii;
}
}
- else {
-
- for (ii = 1 ; ii <= Degree + 1 ; ii++) {
- CoordsToPoint (CachePoles(ii), dc.poles + LocalIndex, * LocalValue);
+ else
+ {
+
+ for (ii = 1; ii <= Degree + 1; ii++)
+ {
+ CoordsToPoint(CachePoles(ii), dc.poles + LocalIndex, *LocalValue);
LocalIndex += Dimension_gen;
- LocalValue *= SpanDomain / (Standard_Real) ii ;
+ LocalValue *= SpanDomain / (Standard_Real)ii;
}
- if (Weights != NULL) {
- for (ii = 1 ; ii <= Degree + 1 ; ii++)
- (*CacheWeights)(ii) = 0.0e0 ;
- (*CacheWeights)(1) = 1.0e0 ;
+ if (Weights != NULL)
+ {
+ for (ii = 1; ii <= Degree + 1; ii++)
+ (*CacheWeights)(ii) = 0.0e0;
+ (*CacheWeights)(1) = 1.0e0;
}
}
}
-void BSplCLib::BuildCache(const Standard_Real theParameter,
- const Standard_Real theSpanDomain,
- const Standard_Boolean thePeriodicFlag,
- const Standard_Integer theDegree,
- const Standard_Integer theSpanIndex,
- const TColStd_Array1OfReal& theFlatKnots,
- const Array1OfPoints& thePoles,
- const TColStd_Array1OfReal* theWeights,
- TColStd_Array2OfReal& theCacheArray)
+void BSplCLib::BuildCache(const Standard_Real theParameter,
+ const Standard_Real theSpanDomain,
+ const Standard_Boolean thePeriodicFlag,
+ const Standard_Integer theDegree,
+ const Standard_Integer theSpanIndex,
+ const TColStd_Array1OfReal& theFlatKnots,
+ const Array1OfPoints& thePoles,
+ const TColStd_Array1OfReal* theWeights,
+ TColStd_Array2OfReal& theCacheArray)
{
- Standard_Real aParam = theParameter;
+ Standard_Real aParam = theParameter;
Standard_Integer anIndex = theSpanIndex;
Standard_Integer aDimension;
Standard_Boolean isRational;
-
+
BSplCLib_DataContainer dc(theDegree);
PrepareEval(aParam,
anIndex,
dc);
//
// Watch out : PrepareEval checks if locally the Bspline is polynomial
- // therefore rational flag could be set to False even if there are
+ // therefore rational flag could be set to False even if there are
// Weights. The Dimension is set accordingly.
//
- Standard_Integer aCacheShift = // helps to store weights when PrepareEval did not found that the curve is locally polynomial
+ Standard_Integer aCacheShift = // helps to store weights when PrepareEval did not found that the
+ // curve is locally polynomial
(theWeights != NULL && !isRational) ? aDimension + 1 : aDimension;
BSplCLib::Bohm(aParam, theDegree, theDegree, *dc.knots, aDimension, *dc.poles);
- Standard_Real aCoeff = 1.0;
- Standard_Real* aCache = (Standard_Real *) &(theCacheArray(theCacheArray.LowerRow(), theCacheArray.LowerCol()));
+ Standard_Real aCoeff = 1.0;
+ Standard_Real* aCache =
+ (Standard_Real*)&(theCacheArray(theCacheArray.LowerRow(), theCacheArray.LowerCol()));
Standard_Real* aPolyCoeffs = dc.poles;
for (Standard_Integer i = 0; i <= theDegree; i++)
{
- for (Standard_Integer j = 0; j< aDimension; j++)
+ for (Standard_Integer j = 0; j < aDimension; j++)
aCache[j] = aPolyCoeffs[j] * aCoeff;
- aCoeff *= theSpanDomain / (i+1);
+ aCoeff *= theSpanDomain / (i + 1);
aPolyCoeffs += aDimension;
aCache += aDimension;
if (aCacheShift > aDimension)
}
if (aCacheShift > aDimension)
- theCacheArray.SetValue(theCacheArray.LowerRow(), theCacheArray.LowerCol() + aCacheShift - 1, 1.0);
+ theCacheArray.SetValue(theCacheArray.LowerRow(),
+ theCacheArray.LowerCol() + aCacheShift - 1,
+ 1.0);
}
//=================================================================================================
+void BSplCLib::Interpolate(const Standard_Integer Degree,
+ const TColStd_Array1OfReal& FlatKnots,
+ const TColStd_Array1OfReal& Parameters,
+ const TColStd_Array1OfInteger& ContactOrderArray,
+ Array1OfPoints& Poles,
+ Standard_Integer& InversionProblem)
-void BSplCLib::Interpolate(const Standard_Integer Degree,
- const TColStd_Array1OfReal& FlatKnots,
- const TColStd_Array1OfReal& Parameters,
- const TColStd_Array1OfInteger& ContactOrderArray,
- Array1OfPoints& Poles,
- Standard_Integer& InversionProblem)
-
{
- Standard_Real *PArray ;
-
- PArray = (Standard_Real *) &Poles(Poles.Lower()) ;
-
+ Standard_Real* PArray;
+
+ PArray = (Standard_Real*)&Poles(Poles.Lower());
+
BSplCLib::Interpolate(Degree,
- FlatKnots,
- Parameters,
- ContactOrderArray,
- Dimension_gen,
- PArray[0],
- InversionProblem) ;
+ FlatKnots,
+ Parameters,
+ ContactOrderArray,
+ Dimension_gen,
+ PArray[0],
+ InversionProblem);
}
//=================================================================================================
-
-void BSplCLib::Interpolate(const Standard_Integer Degree,
- const TColStd_Array1OfReal& FlatKnots,
- const TColStd_Array1OfReal& Parameters,
- const TColStd_Array1OfInteger& ContactOrderArray,
- Array1OfPoints& Poles,
- TColStd_Array1OfReal& Weights,
- Standard_Integer& InversionProblem)
+void BSplCLib::Interpolate(const Standard_Integer Degree,
+ const TColStd_Array1OfReal& FlatKnots,
+ const TColStd_Array1OfReal& Parameters,
+ const TColStd_Array1OfInteger& ContactOrderArray,
+ Array1OfPoints& Poles,
+ TColStd_Array1OfReal& Weights,
+ Standard_Integer& InversionProblem)
{
- Standard_Real *PArray,
- * WArray ;
- PArray = (Standard_Real *) &Poles(Poles.Lower()) ;
- WArray = (Standard_Real *) &Weights(Weights.Lower()) ;
+ Standard_Real *PArray, *WArray;
+ PArray = (Standard_Real*)&Poles(Poles.Lower());
+ WArray = (Standard_Real*)&Weights(Weights.Lower());
BSplCLib::Interpolate(Degree,
- FlatKnots,
- Parameters,
- ContactOrderArray,
- Dimension_gen,
- PArray[0],
+ FlatKnots,
+ Parameters,
+ ContactOrderArray,
+ Dimension_gen,
+ PArray[0],
WArray[0],
- InversionProblem) ;
+ InversionProblem);
}
//=======================================================================
-//function : MovePoint
-//purpose : Find the new poles which allows an old point (with a
+// function : MovePoint
+// purpose : Find the new poles which allows an old point (with a
// given u as parameter) to reach a new position
//=======================================================================
-void BSplCLib::MovePoint (const Standard_Real U,
- const Vector& Displ,
- const Standard_Integer Index1,
- const Standard_Integer Index2,
- const Standard_Integer Degree,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& FlatKnots,
- Standard_Integer& FirstIndex,
- Standard_Integer& LastIndex,
- Array1OfPoints& NewPoles)
+void BSplCLib::MovePoint(const Standard_Real U,
+ const Vector& Displ,
+ const Standard_Integer Index1,
+ const Standard_Integer Index2,
+ const Standard_Integer Degree,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& FlatKnots,
+ Standard_Integer& FirstIndex,
+ Standard_Integer& LastIndex,
+ Array1OfPoints& NewPoles)
{
// calculate the BSplineBasis in the parameter U
Standard_Integer FirstNonZeroBsplineIndex;
- math_Matrix BSplineBasis(1, 1,
- 1, Degree+1);
+ math_Matrix BSplineBasis(1, 1, 1, Degree + 1);
Standard_Integer ErrorCode =
- BSplCLib::EvalBsplineBasis(0,
- Degree+1,
- FlatKnots,
- U,
- FirstNonZeroBsplineIndex,
- BSplineBasis);
- if (ErrorCode != 0) {
+ BSplCLib::EvalBsplineBasis(0, Degree + 1, FlatKnots, U, FirstNonZeroBsplineIndex, BSplineBasis);
+ if (ErrorCode != 0)
+ {
FirstIndex = 0;
- LastIndex = 0;
+ LastIndex = 0;
- for (Standard_Integer i=Poles.Lower(); i<=Poles.Upper(); i++) {
+ for (Standard_Integer i = Poles.Lower(); i <= Poles.Upper(); i++)
+ {
NewPoles(i) = Poles(i);
}
return;
}
-
+
// find the span which is predominant for parameter U
FirstIndex = FirstNonZeroBsplineIndex;
- LastIndex = FirstNonZeroBsplineIndex + Degree ;
- if (FirstIndex < Index1) FirstIndex = Index1;
- if (LastIndex > Index2) LastIndex = Index2;
-
- Standard_Real maxValue = 0.0;
- Standard_Integer i, kk1=0, kk2, ii;
-
- for (i = FirstIndex-FirstNonZeroBsplineIndex+1;
- i <= LastIndex-FirstNonZeroBsplineIndex+1; i++) {
- if (BSplineBasis(1,i) > maxValue) {
- kk1 = i + FirstNonZeroBsplineIndex - 1;
- maxValue = BSplineBasis(1,i);
+ LastIndex = FirstNonZeroBsplineIndex + Degree;
+ if (FirstIndex < Index1)
+ FirstIndex = Index1;
+ if (LastIndex > Index2)
+ LastIndex = Index2;
+
+ Standard_Real maxValue = 0.0;
+ Standard_Integer i, kk1 = 0, kk2, ii;
+
+ for (i = FirstIndex - FirstNonZeroBsplineIndex + 1; i <= LastIndex - FirstNonZeroBsplineIndex + 1;
+ i++)
+ {
+ if (BSplineBasis(1, i) > maxValue)
+ {
+ kk1 = i + FirstNonZeroBsplineIndex - 1;
+ maxValue = BSplineBasis(1, i);
}
}
-
+
// find a kk2 if symmetry
kk2 = kk1;
- i = kk1 - FirstNonZeroBsplineIndex + 2;
- if ((kk1+1) <= LastIndex) {
- if (Abs(BSplineBasis(1, kk1-FirstNonZeroBsplineIndex+2) - maxValue) < 1.e-10) {
- kk2 = kk1+1;
+ i = kk1 - FirstNonZeroBsplineIndex + 2;
+ if ((kk1 + 1) <= LastIndex)
+ {
+ if (Abs(BSplineBasis(1, kk1 - FirstNonZeroBsplineIndex + 2) - maxValue) < 1.e-10)
+ {
+ kk2 = kk1 + 1;
}
}
-
+
// compute the vector of displacement
Standard_Real D1 = 0.0;
Standard_Real D2 = 0.0;
Standard_Real hN, Coef, Dval;
-
- for (i = 1; i <= Degree+1; i++) {
+
+ for (i = 1; i <= Degree + 1; i++)
+ {
ii = i + FirstNonZeroBsplineIndex - 1;
- if (Weights != NULL) {
- hN = Weights->Value(ii)*BSplineBasis(1, i);
+ if (Weights != NULL)
+ {
+ hN = Weights->Value(ii) * BSplineBasis(1, i);
D2 += hN;
}
- else {
+ else
+ {
hN = BSplineBasis(1, i);
}
- if (ii >= FirstIndex && ii <= LastIndex) {
- if (ii < kk1) {
- Dval = kk1-ii;
+ if (ii >= FirstIndex && ii <= LastIndex)
+ {
+ if (ii < kk1)
+ {
+ Dval = kk1 - ii;
}
- else if (ii > kk2) {
- Dval = ii - kk2;
+ else if (ii > kk2)
+ {
+ Dval = ii - kk2;
}
- else {
- Dval = 0.0;
+ else
+ {
+ Dval = 0.0;
}
- D1 += 1./(Dval + 1.) * hN;
+ D1 += 1. / (Dval + 1.) * hN;
}
}
-
- if (Weights != NULL) {
- Coef = D2/D1;
+
+ if (Weights != NULL)
+ {
+ Coef = D2 / D1;
}
- else {
- Coef = 1./D1;
+ else
+ {
+ Coef = 1. / D1;
}
-
+
// compute the new poles
- for (i=Poles.Lower(); i<=Poles.Upper(); i++) {
- if (i >= FirstIndex && i <= LastIndex) {
- if (i < kk1) {
- Dval = kk1-i;
+ for (i = Poles.Lower(); i <= Poles.Upper(); i++)
+ {
+ if (i >= FirstIndex && i <= LastIndex)
+ {
+ if (i < kk1)
+ {
+ Dval = kk1 - i;
}
- else if (i > kk2) {
- Dval = i - kk2;
+ else if (i > kk2)
+ {
+ Dval = i - kk2;
}
- else {
- Dval = 0.0;
+ else
+ {
+ Dval = 0.0;
}
- NewPoles(i) = Poles(i).Translated((Coef/(Dval+1.))*Displ);
+ NewPoles(i) = Poles(i).Translated((Coef / (Dval + 1.)) * Displ);
}
- else {
+ else
+ {
NewPoles(i) = Poles(i);
}
}
}
//=======================================================================
-//function : MovePoint
-//purpose : Find the new poles which allows an old point (with a
+// function : MovePoint
+// purpose : Find the new poles which allows an old point (with a
// given u as parameter) to reach a new position
//=======================================================================
//=================================================================================================
-
-void BSplCLib::MovePointAndTangent (const Standard_Real U,
- const Vector& Delta,
- const Vector& DeltaDerivatives,
- const Standard_Real Tolerance,
- const Standard_Integer Degree,
- const Standard_Integer StartingCondition,
- const Standard_Integer EndingCondition,
- const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const TColStd_Array1OfReal& FlatKnots,
- Array1OfPoints& NewPoles,
- Standard_Integer & ErrorStatus)
+void BSplCLib::MovePointAndTangent(const Standard_Real U,
+ const Vector& Delta,
+ const Vector& DeltaDerivatives,
+ const Standard_Real Tolerance,
+ const Standard_Integer Degree,
+ const Standard_Integer StartingCondition,
+ const Standard_Integer EndingCondition,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const TColStd_Array1OfReal& FlatKnots,
+ Array1OfPoints& NewPoles,
+ Standard_Integer& ErrorStatus)
{
- Standard_Real *delta_array,
- *delta_derivative_array,
- *poles_array,
- *new_poles_array ;
-
- Standard_Integer num_poles ;
- num_poles = Poles.Length() ;
-
- if (NewPoles.Length() != num_poles) {
+ Standard_Real *delta_array, *delta_derivative_array, *poles_array, *new_poles_array;
+
+ Standard_Integer num_poles;
+ num_poles = Poles.Length();
+
+ if (NewPoles.Length() != num_poles)
+ {
throw Standard_ConstructionError();
}
- delta_array = (Standard_Real *) &Delta ;
- delta_derivative_array = (Standard_Real *)&DeltaDerivatives ;
- poles_array = (Standard_Real *) &Poles(Poles.Lower()) ;
-
- new_poles_array = (Standard_Real *) &NewPoles(NewPoles.Lower()) ;
+ delta_array = (Standard_Real*)Δ
+ delta_derivative_array = (Standard_Real*)&DeltaDerivatives;
+ poles_array = (Standard_Real*)&Poles(Poles.Lower());
+
+ new_poles_array = (Standard_Real*)&NewPoles(NewPoles.Lower());
MovePointAndTangent(U,
- Dimension_gen,
- delta_array[0],
- delta_derivative_array[0],
- Tolerance,
- Degree,
- StartingCondition,
- EndingCondition,
- poles_array[0],
- Weights,
- FlatKnots,
- new_poles_array[0],
- ErrorStatus) ;
+ Dimension_gen,
+ delta_array[0],
+ delta_derivative_array[0],
+ Tolerance,
+ Degree,
+ StartingCondition,
+ EndingCondition,
+ poles_array[0],
+ Weights,
+ FlatKnots,
+ new_poles_array[0],
+ ErrorStatus);
}
//=================================================================================================
-
-void BSplCLib::Resolution(const Array1OfPoints& Poles,
- const TColStd_Array1OfReal* Weights,
- const Standard_Integer NumPoles,
- const TColStd_Array1OfReal& FlatKnots,
- const Standard_Integer Degree,
- const Standard_Real Tolerance3D,
- Standard_Real& UTolerance)
+void BSplCLib::Resolution(const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal* Weights,
+ const Standard_Integer NumPoles,
+ const TColStd_Array1OfReal& FlatKnots,
+ const Standard_Integer Degree,
+ const Standard_Real Tolerance3D,
+ Standard_Real& UTolerance)
{
- Standard_Real *PolesArray ;
- PolesArray = (Standard_Real *) &Poles(Poles.Lower()) ;
+ Standard_Real* PolesArray;
+ PolesArray = (Standard_Real*)&Poles(Poles.Lower());
BSplCLib::Resolution(PolesArray[0],
- Dimension_gen,
- NumPoles,
- Weights,
- FlatKnots,
- Degree,
- Tolerance3D,
- UTolerance) ;
+ Dimension_gen,
+ NumPoles,
+ Weights,
+ FlatKnots,
+ Degree,
+ Tolerance3D,
+ UTolerance);
}
//=================================================================================================
+void BSplCLib::FunctionMultiply(const BSplCLib_EvaluatorFunction& FunctionPtr,
+ const Standard_Integer BSplineDegree,
+ const TColStd_Array1OfReal& BSplineFlatKnots,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal& FlatKnots,
+ const Standard_Integer NewDegree,
+ Array1OfPoints& NewPoles,
+ Standard_Integer& theStatus)
+{
+ Standard_Integer num_bspline_poles = BSplineFlatKnots.Length() - BSplineDegree - 1;
+ Standard_Integer num_new_poles = FlatKnots.Length() - NewDegree - 1;
-void BSplCLib::FunctionMultiply
-(const BSplCLib_EvaluatorFunction & FunctionPtr,
- const Standard_Integer BSplineDegree,
- const TColStd_Array1OfReal & BSplineFlatKnots,
- const Array1OfPoints & Poles,
- const TColStd_Array1OfReal & FlatKnots,
- const Standard_Integer NewDegree,
- Array1OfPoints & NewPoles,
- Standard_Integer & theStatus)
-{
- Standard_Integer num_bspline_poles =
- BSplineFlatKnots.Length() - BSplineDegree - 1 ;
- Standard_Integer num_new_poles =
- FlatKnots.Length() - NewDegree - 1 ;
-
- if (Poles.Length() != num_bspline_poles ||
- NewPoles.Length() != num_new_poles) {
+ if (Poles.Length() != num_bspline_poles || NewPoles.Length() != num_new_poles)
+ {
throw Standard_ConstructionError();
}
- Standard_Real * array_of_poles =
- (Standard_Real *) &Poles(Poles.Lower()) ;
- Standard_Real * array_of_new_poles =
- (Standard_Real *) &NewPoles(NewPoles.Lower()) ;
+ Standard_Real* array_of_poles = (Standard_Real*)&Poles(Poles.Lower());
+ Standard_Real* array_of_new_poles = (Standard_Real*)&NewPoles(NewPoles.Lower());
BSplCLib::FunctionMultiply(FunctionPtr,
- BSplineDegree,
- BSplineFlatKnots,
- Dimension_gen,
- array_of_poles[0],
- FlatKnots,
- NewDegree,
- array_of_new_poles[0],
- theStatus);
+ BSplineDegree,
+ BSplineFlatKnots,
+ Dimension_gen,
+ array_of_poles[0],
+ FlatKnots,
+ NewDegree,
+ array_of_new_poles[0],
+ theStatus);
}
//=================================================================================================
+void BSplCLib::FunctionReparameterise(const BSplCLib_EvaluatorFunction& FunctionPtr,
+ const Standard_Integer BSplineDegree,
+ const TColStd_Array1OfReal& BSplineFlatKnots,
+ const Array1OfPoints& Poles,
+ const TColStd_Array1OfReal& FlatKnots,
+ const Standard_Integer NewDegree,
+ Array1OfPoints& NewPoles,
+ Standard_Integer& theStatus)
+{
+ Standard_Integer num_bspline_poles = BSplineFlatKnots.Length() - BSplineDegree - 1;
+ Standard_Integer num_new_poles = FlatKnots.Length() - NewDegree - 1;
-void BSplCLib::FunctionReparameterise
-(const BSplCLib_EvaluatorFunction & FunctionPtr,
- const Standard_Integer BSplineDegree,
- const TColStd_Array1OfReal & BSplineFlatKnots,
- const Array1OfPoints & Poles,
- const TColStd_Array1OfReal & FlatKnots,
- const Standard_Integer NewDegree,
- Array1OfPoints & NewPoles,
- Standard_Integer & theStatus)
-{
- Standard_Integer num_bspline_poles =
- BSplineFlatKnots.Length() - BSplineDegree - 1 ;
- Standard_Integer num_new_poles =
- FlatKnots.Length() - NewDegree - 1 ;
-
- if (Poles.Length() != num_bspline_poles ||
- NewPoles.Length() != num_new_poles) {
+ if (Poles.Length() != num_bspline_poles || NewPoles.Length() != num_new_poles)
+ {
throw Standard_ConstructionError();
}
- Standard_Real * array_of_poles =
- (Standard_Real *) &Poles(Poles.Lower()) ;
- Standard_Real * array_of_new_poles =
- (Standard_Real *) &NewPoles(NewPoles.Lower()) ;
+ Standard_Real* array_of_poles = (Standard_Real*)&Poles(Poles.Lower());
+ Standard_Real* array_of_new_poles = (Standard_Real*)&NewPoles(NewPoles.Lower());
BSplCLib::FunctionReparameterise(FunctionPtr,
- BSplineDegree,
- BSplineFlatKnots,
- Dimension_gen,
- array_of_poles[0],
- FlatKnots,
- NewDegree,
- array_of_new_poles[0],
- theStatus);
+ BSplineDegree,
+ BSplineFlatKnots,
+ Dimension_gen,
+ array_of_poles[0],
+ FlatKnots,
+ NewDegree,
+ array_of_new_poles[0],
+ theStatus);
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-inline Standard_Boolean _compareDist (const RealType aHSize[2],
- const RealType aDist[2])
+inline Standard_Boolean _compareDist(const RealType aHSize[2], const RealType aDist[2])
{
return (Abs(aDist[0]) > aHSize[0] || Abs(aDist[1]) > aHSize[1]);
}
-inline Standard_Boolean _compareDistD (const gp_XY& aHSize, const gp_XY& aDist)
+inline Standard_Boolean _compareDistD(const gp_XY& aHSize, const gp_XY& aDist)
{
return (Abs(aDist.X()) > aHSize.X() || Abs(aDist.Y()) > aHSize.Y());
}
//=======================================================================
-//function : Add
-//purpose : Update the box by a point
+// function : Add
+// purpose : Update the box by a point
//=======================================================================
-void Bnd_B2x::Add (const gp_XY& thePnt) {
- if (IsVoid()) {
+void Bnd_B2x::Add(const gp_XY& thePnt)
+{
+ if (IsVoid())
+ {
myCenter[0] = RealType(thePnt.X());
myCenter[1] = RealType(thePnt.Y());
- myHSize [0] = 0.;
- myHSize [1] = 0.;
- } else {
- const RealType aDiff[2] = {
- RealType(thePnt.X()) - myCenter[0],
- RealType(thePnt.Y()) - myCenter[1]
- };
- if (aDiff[0] > myHSize[0]) {
+ myHSize[0] = 0.;
+ myHSize[1] = 0.;
+ }
+ else
+ {
+ const RealType aDiff[2] = {RealType(thePnt.X()) - myCenter[0],
+ RealType(thePnt.Y()) - myCenter[1]};
+ if (aDiff[0] > myHSize[0])
+ {
const RealType aShift = (aDiff[0] - myHSize[0]) / 2;
myCenter[0] += aShift;
- myHSize [0] += aShift;
- } else if (aDiff[0] < -myHSize[0]) {
+ myHSize[0] += aShift;
+ }
+ else if (aDiff[0] < -myHSize[0])
+ {
const RealType aShift = (aDiff[0] + myHSize[0]) / 2;
myCenter[0] += aShift;
- myHSize [0] -= aShift;
+ myHSize[0] -= aShift;
}
- if (aDiff[1] > myHSize[1]) {
+ if (aDiff[1] > myHSize[1])
+ {
const RealType aShift = (aDiff[1] - myHSize[1]) / 2;
myCenter[1] += aShift;
- myHSize [1] += aShift;
- } else if (aDiff[1] < -myHSize[1]) {
+ myHSize[1] += aShift;
+ }
+ else if (aDiff[1] < -myHSize[1])
+ {
const RealType aShift = (aDiff[1] + myHSize[1]) / 2;
myCenter[1] += aShift;
- myHSize [1] -= aShift;
+ myHSize[1] -= aShift;
}
}
}
//=======================================================================
-//function : Limit
-//purpose : limit the current box with the internals of theBox
+// function : Limit
+// purpose : limit the current box with the internals of theBox
//=======================================================================
-Standard_Boolean Bnd_B2x::Limit (const Bnd_B2x& theBox)
+Standard_Boolean Bnd_B2x::Limit(const Bnd_B2x& theBox)
{
- Standard_Boolean aResult (Standard_False);
- const RealType diffC[2] = {
- theBox.myCenter[0] - myCenter[0],
- theBox.myCenter[1] - myCenter[1]
- };
- const RealType sumH[2] = {
- theBox.myHSize[0] + myHSize[0],
- theBox.myHSize[1] + myHSize[1]
- };
+ Standard_Boolean aResult(Standard_False);
+ const RealType diffC[2] = {theBox.myCenter[0] - myCenter[0], theBox.myCenter[1] - myCenter[1]};
+ const RealType sumH[2] = {theBox.myHSize[0] + myHSize[0], theBox.myHSize[1] + myHSize[1]};
// check the condition IsOut
- if (_compareDist (sumH, diffC) == Standard_False) {
- const RealType diffH[2] = {
- theBox.myHSize[0] - myHSize[0],
- theBox.myHSize[1] - myHSize[1]
- };
- if (diffC[0] - diffH[0] > 0.) {
+ if (_compareDist(sumH, diffC) == Standard_False)
+ {
+ const RealType diffH[2] = {theBox.myHSize[0] - myHSize[0], theBox.myHSize[1] - myHSize[1]};
+ if (diffC[0] - diffH[0] > 0.)
+ {
const RealType aShift = (diffC[0] - diffH[0]) / 2; // positive
myCenter[0] += aShift;
- myHSize [0] -= aShift;
- } else if (diffC[0] + diffH[0] < 0.) {
+ myHSize[0] -= aShift;
+ }
+ else if (diffC[0] + diffH[0] < 0.)
+ {
const RealType aShift = (diffC[0] + diffH[0]) / 2; // negative
myCenter[0] += aShift;
- myHSize [0] += aShift;
+ myHSize[0] += aShift;
}
- if (diffC[1] - diffH[1] > 0.) {
+ if (diffC[1] - diffH[1] > 0.)
+ {
const RealType aShift = (diffC[1] - diffH[1]) / 2; // positive
myCenter[1] += aShift;
- myHSize [1] -= aShift;
- } else if (diffC[1] + diffH[1] < 0.) {
+ myHSize[1] -= aShift;
+ }
+ else if (diffC[1] + diffH[1] < 0.)
+ {
const RealType aShift = (diffC[1] + diffH[1]) / 2; // negative
myCenter[1] += aShift;
- myHSize [1] += aShift;
+ myHSize[1] += aShift;
}
aResult = Standard_True;
}
//=================================================================================================
-
-Bnd_B2x Bnd_B2x::Transformed (const gp_Trsf2d& theTrsf) const
+Bnd_B2x Bnd_B2x::Transformed(const gp_Trsf2d& theTrsf) const
{
- Bnd_B2x aResult;
- const gp_TrsfForm aForm = theTrsf.Form();
- const Standard_Real aScale = theTrsf.ScaleFactor();
+ Bnd_B2x aResult;
+ const gp_TrsfForm aForm = theTrsf.Form();
+ const Standard_Real aScale = theTrsf.ScaleFactor();
const Standard_Real aScaleAbs = Abs(aScale);
if (aForm == gp_Identity)
- aResult = * this;
- else if (aForm== gp_Translation || aForm== gp_PntMirror || aForm== gp_Scale)
+ aResult = *this;
+ else if (aForm == gp_Translation || aForm == gp_PntMirror || aForm == gp_Scale)
+ {
+ aResult.myCenter[0] = (RealType)(myCenter[0] * aScale + theTrsf.TranslationPart().X());
+ aResult.myCenter[1] = (RealType)(myCenter[1] * aScale + theTrsf.TranslationPart().Y());
+ aResult.myHSize[0] = (RealType)(myHSize[0] * aScaleAbs);
+ aResult.myHSize[1] = (RealType)(myHSize[1] * aScaleAbs);
+ }
+ else
{
- aResult.myCenter[0] =
- (RealType)(myCenter[0] * aScale + theTrsf.TranslationPart().X());
- aResult.myCenter[1] =
- (RealType)(myCenter[1] * aScale + theTrsf.TranslationPart().Y());
- aResult.myHSize[0] = (RealType)(myHSize[0] * aScaleAbs);
- aResult.myHSize[1] = (RealType)(myHSize[1] * aScaleAbs);
- } else {
- gp_XY aCenter ((Standard_Real)myCenter[0],
- (Standard_Real)myCenter[1]);
- theTrsf.Transforms (aCenter);
+ gp_XY aCenter((Standard_Real)myCenter[0], (Standard_Real)myCenter[1]);
+ theTrsf.Transforms(aCenter);
aResult.myCenter[0] = (RealType)aCenter.X();
aResult.myCenter[1] = (RealType)aCenter.Y();
- const Standard_Real * aMat = &theTrsf.HVectorialPart().Value(1,1);
- aResult.myHSize[0] = (RealType)(aScaleAbs * (Abs(aMat[0]) * myHSize[0]+
- Abs(aMat[1]) * myHSize[1]));
- aResult.myHSize[1] = (RealType)(aScaleAbs * (Abs(aMat[2]) * myHSize[0]+
- Abs(aMat[3]) * myHSize[1]));
+ const Standard_Real* aMat = &theTrsf.HVectorialPart().Value(1, 1);
+ aResult.myHSize[0] =
+ (RealType)(aScaleAbs * (Abs(aMat[0]) * myHSize[0] + Abs(aMat[1]) * myHSize[1]));
+ aResult.myHSize[1] =
+ (RealType)(aScaleAbs * (Abs(aMat[2]) * myHSize[0] + Abs(aMat[3]) * myHSize[1]));
}
return aResult;
}
//=======================================================================
-//function : IsOut
-//purpose : Intersection Box - Circle
+// function : IsOut
+// purpose : Intersection Box - Circle
//=======================================================================
-Standard_Boolean Bnd_B2x::IsOut (const gp_XY& theCenter,
- const Standard_Real theRadius,
- const Standard_Boolean isCircleHollow) const
+Standard_Boolean Bnd_B2x::IsOut(const gp_XY& theCenter,
+ const Standard_Real theRadius,
+ const Standard_Boolean isCircleHollow) const
{
- Standard_Boolean aResult (Standard_True);
- if (isCircleHollow == Standard_False) {
+ Standard_Boolean aResult(Standard_True);
+ if (isCircleHollow == Standard_False)
+ {
// vector from the center of the circle to the nearest box face
const Standard_Real aDist[2] = {
- Abs(theCenter.X()-Standard_Real(myCenter[0])) - Standard_Real(myHSize[0]),
- Abs(theCenter.Y()-Standard_Real(myCenter[1])) - Standard_Real(myHSize[1])
- };
- Standard_Real aD (0.);
+ Abs(theCenter.X() - Standard_Real(myCenter[0])) - Standard_Real(myHSize[0]),
+ Abs(theCenter.Y() - Standard_Real(myCenter[1])) - Standard_Real(myHSize[1])};
+ Standard_Real aD(0.);
if (aDist[0] > 0.)
- aD = aDist[0]*aDist[0];
+ aD = aDist[0] * aDist[0];
if (aDist[1] > 0.)
- aD += aDist[1]*aDist[1];
- aResult = (aD > theRadius*theRadius);
- } else {
- const Standard_Real aDistC[2] = {
- Abs(theCenter.X()-Standard_Real(myCenter[0])),
- Abs(theCenter.Y()-Standard_Real(myCenter[1]))
- };
+ aD += aDist[1] * aDist[1];
+ aResult = (aD > theRadius * theRadius);
+ }
+ else
+ {
+ const Standard_Real aDistC[2] = {Abs(theCenter.X() - Standard_Real(myCenter[0])),
+ Abs(theCenter.Y() - Standard_Real(myCenter[1]))};
// vector from the center of the circle to the nearest box face
- Standard_Real aDist[2] = {
- aDistC[0] - Standard_Real(myHSize[0]),
- aDistC[1] - Standard_Real(myHSize[1])
- };
- Standard_Real aD (0.);
+ Standard_Real aDist[2] = {aDistC[0] - Standard_Real(myHSize[0]),
+ aDistC[1] - Standard_Real(myHSize[1])};
+ Standard_Real aD(0.);
if (aDist[0] > 0.)
- aD = aDist[0]*aDist[0];
+ aD = aDist[0] * aDist[0];
if (aDist[1] > 0.)
- aD += aDist[1]*aDist[1];
- if (aD < theRadius*theRadius) {
+ aD += aDist[1] * aDist[1];
+ if (aD < theRadius * theRadius)
+ {
// the box intersects the solid circle; check if it is completely
// inside the circle (in such case return isOut==True)
aDist[0] = aDistC[0] + Standard_Real(myHSize[0]);
aDist[1] = aDistC[1] + Standard_Real(myHSize[1]);
- if (aDist[0]*aDist[0]+aDist[1]*aDist[1] > theRadius*theRadius)
+ if (aDist[0] * aDist[0] + aDist[1] * aDist[1] > theRadius * theRadius)
aResult = Standard_False;
}
}
}
//=======================================================================
-//function : IsOut
-//purpose : Intersection Box - transformed Box
+// function : IsOut
+// purpose : Intersection Box - transformed Box
//=======================================================================
-Standard_Boolean Bnd_B2x::IsOut (const Bnd_B2x& theBox,
- const gp_Trsf2d& theTrsf) const
+Standard_Boolean Bnd_B2x::IsOut(const Bnd_B2x& theBox, const gp_Trsf2d& theTrsf) const
{
- Standard_Boolean aResult (Standard_False);
- const gp_TrsfForm aForm = theTrsf.Form();
- const Standard_Real aScale = theTrsf.ScaleFactor();
+ Standard_Boolean aResult(Standard_False);
+ const gp_TrsfForm aForm = theTrsf.Form();
+ const Standard_Real aScale = theTrsf.ScaleFactor();
const Standard_Real aScaleAbs = Abs(aScale);
- if (aForm == gp_Translation || aForm == gp_Identity ||
- aForm == gp_PntMirror || aForm == gp_Scale)
+ if (aForm == gp_Translation || aForm == gp_Identity || aForm == gp_PntMirror || aForm == gp_Scale)
{
aResult =
- (Abs (RealType(theBox.myCenter[0]*aScale + theTrsf.TranslationPart().X())
- - myCenter[0])
- > RealType (theBox.myHSize[0]*aScaleAbs) + myHSize[0] ||
- Abs (RealType(theBox.myCenter[1]*aScale + theTrsf.TranslationPart().Y())
- - myCenter[1])
- > RealType (theBox.myHSize[1]*aScaleAbs) + myHSize[1]);
-
+ (Abs(RealType(theBox.myCenter[0] * aScale + theTrsf.TranslationPart().X()) - myCenter[0])
+ > RealType(theBox.myHSize[0] * aScaleAbs) + myHSize[0]
+ || Abs(RealType(theBox.myCenter[1] * aScale + theTrsf.TranslationPart().Y()) - myCenter[1])
+ > RealType(theBox.myHSize[1] * aScaleAbs) + myHSize[1]);
}
- else {
+ else
+ {
// theBox is transformed and we check the resulting (enlarged) box against
// 'this' box.
- const Standard_Real * aMat = &theTrsf.HVectorialPart().Value(1,1);
+ const Standard_Real* aMat = &theTrsf.HVectorialPart().Value(1, 1);
- gp_XY aCenter ((Standard_Real)theBox.myCenter[0],
- (Standard_Real)theBox.myCenter[1]);
- theTrsf.Transforms (aCenter);
- const Standard_Real aDist[2] = {
- aCenter.X() - (Standard_Real)myCenter[0],
- aCenter.Y() - (Standard_Real)myCenter[1]
- };
- const Standard_Real aMatAbs[4] = {
- Abs(aMat[0]), Abs(aMat[1]), Abs(aMat[2]), Abs(aMat[3])
- };
- if (Abs(aDist[0]) > (aScaleAbs * (aMatAbs[0]*theBox.myHSize[0]+
- aMatAbs[1]*theBox.myHSize[1]) +
- (Standard_Real)myHSize[0]) ||
- Abs(aDist[1]) > (aScaleAbs * (aMatAbs[2]*theBox.myHSize[0]+
- aMatAbs[3]*theBox.myHSize[1]) +
- (Standard_Real)myHSize[1]))
+ gp_XY aCenter((Standard_Real)theBox.myCenter[0], (Standard_Real)theBox.myCenter[1]);
+ theTrsf.Transforms(aCenter);
+ const Standard_Real aDist[2] = {aCenter.X() - (Standard_Real)myCenter[0],
+ aCenter.Y() - (Standard_Real)myCenter[1]};
+ const Standard_Real aMatAbs[4] = {Abs(aMat[0]), Abs(aMat[1]), Abs(aMat[2]), Abs(aMat[3])};
+ if (Abs(aDist[0])
+ > (aScaleAbs * (aMatAbs[0] * theBox.myHSize[0] + aMatAbs[1] * theBox.myHSize[1])
+ + (Standard_Real)myHSize[0])
+ || Abs(aDist[1])
+ > (aScaleAbs * (aMatAbs[2] * theBox.myHSize[0] + aMatAbs[3] * theBox.myHSize[1])
+ + (Standard_Real)myHSize[1]))
aResult = Standard_True;
- else {
- // theBox is rotated, scaled and translated. We apply the reverse
- // translation and scaling then check against the rotated box 'this'
- if ((Abs(aMat[0]*aDist[0]+aMat[2]*aDist[1])
- > theBox.myHSize[0]*aScaleAbs + (aMatAbs[0]*myHSize[0] +
- aMatAbs[2]*myHSize[1])) ||
- (Abs(aMat[1]*aDist[0]+aMat[3]*aDist[1])
- > theBox.myHSize[1]*aScaleAbs + (aMatAbs[1]*myHSize[0] +
- aMatAbs[3]*myHSize[1])))
+ else
+ {
+ // theBox is rotated, scaled and translated. We apply the reverse
+ // translation and scaling then check against the rotated box 'this'
+ if ((Abs(aMat[0] * aDist[0] + aMat[2] * aDist[1])
+ > theBox.myHSize[0] * aScaleAbs + (aMatAbs[0] * myHSize[0] + aMatAbs[2] * myHSize[1]))
+ || (Abs(aMat[1] * aDist[0] + aMat[3] * aDist[1])
+ > theBox.myHSize[1] * aScaleAbs
+ + (aMatAbs[1] * myHSize[0] + aMatAbs[3] * myHSize[1])))
aResult = Standard_True;
}
}
}
//=======================================================================
-//function : IsOut
-//purpose : Intersection Box - Line
+// function : IsOut
+// purpose : Intersection Box - Line
//=======================================================================
-Standard_Boolean Bnd_B2x::IsOut (const gp_Ax2d& theLine) const
+Standard_Boolean Bnd_B2x::IsOut(const gp_Ax2d& theLine) const
{
if (IsVoid())
return Standard_True;
// Intersect the line containing the segment.
const Standard_Real aProd[3] = {
- theLine.Direction().XY() ^ (gp_XY (myCenter[0] - theLine.Location().X(),
- myCenter[1] - theLine.Location().Y())),
+ theLine.Direction().XY()
+ ^ (gp_XY(myCenter[0] - theLine.Location().X(), myCenter[1] - theLine.Location().Y())),
theLine.Direction().X() * Standard_Real(myHSize[1]),
- theLine.Direction().Y() * Standard_Real(myHSize[0])
- };
+ theLine.Direction().Y() * Standard_Real(myHSize[0])};
return (Abs(aProd[0]) > (Abs(aProd[1]) + Abs(aProd[2])));
}
//=======================================================================
-//function : IsOut
-//purpose : Intersection Box - Segment
+// function : IsOut
+// purpose : Intersection Box - Segment
//=======================================================================
-Standard_Boolean Bnd_B2x::IsOut (const gp_XY& theP0, const gp_XY& theP1) const
+Standard_Boolean Bnd_B2x::IsOut(const gp_XY& theP0, const gp_XY& theP1) const
{
- Standard_Boolean aResult (Standard_True);
+ Standard_Boolean aResult(Standard_True);
if (IsVoid() == Standard_False)
{
// Intersect the line containing the segment.
- const gp_XY aSegDelta (theP1 - theP0);
- const Standard_Real aProd[3] = {
- aSegDelta ^ (gp_XY (myCenter[0], myCenter[1]) - theP0),
- aSegDelta.X() * Standard_Real(myHSize[1]),
- aSegDelta.Y() * Standard_Real(myHSize[0])
- };
+ const gp_XY aSegDelta(theP1 - theP0);
+ const Standard_Real aProd[3] = {aSegDelta ^ (gp_XY(myCenter[0], myCenter[1]) - theP0),
+ aSegDelta.X() * Standard_Real(myHSize[1]),
+ aSegDelta.Y() * Standard_Real(myHSize[0])};
if (Abs(aProd[0]) < (Abs(aProd[1]) + Abs(aProd[2])))
{
// Intersection with line detected; check the segment as bounding box
- const gp_XY aHSeg (0.5 * aSegDelta.X(), 0.5 * aSegDelta.Y());
- const gp_XY aHSegAbs (Abs(aHSeg.X()), Abs(aHSeg.Y()));
- aResult = _compareDistD (gp_XY((Standard_Real)myHSize[0],
- (Standard_Real)myHSize[1]) + aHSegAbs,
- theP0 + aHSeg-gp_XY((Standard_Real)myCenter[0],
- (Standard_Real)myCenter[1]));
+ const gp_XY aHSeg(0.5 * aSegDelta.X(), 0.5 * aSegDelta.Y());
+ const gp_XY aHSegAbs(Abs(aHSeg.X()), Abs(aHSeg.Y()));
+ aResult = _compareDistD(
+ gp_XY((Standard_Real)myHSize[0], (Standard_Real)myHSize[1]) + aHSegAbs,
+ theP0 + aHSeg - gp_XY((Standard_Real)myCenter[0], (Standard_Real)myCenter[1]));
}
}
return aResult;
}
//=======================================================================
-//function : IsIn
-//purpose : Test the complete inclusion of this box in transformed theOtherBox
+// function : IsIn
+// purpose : Test the complete inclusion of this box in transformed theOtherBox
//=======================================================================
-Standard_Boolean Bnd_B2x::IsIn (const Bnd_B2x& theBox,
- const gp_Trsf2d& theTrsf) const
+Standard_Boolean Bnd_B2x::IsIn(const Bnd_B2x& theBox, const gp_Trsf2d& theTrsf) const
{
- Standard_Boolean aResult (Standard_False);
- const gp_TrsfForm aForm = theTrsf.Form();
- const Standard_Real aScale = theTrsf.ScaleFactor();
+ Standard_Boolean aResult(Standard_False);
+ const gp_TrsfForm aForm = theTrsf.Form();
+ const Standard_Real aScale = theTrsf.ScaleFactor();
const Standard_Real aScaleAbs = Abs(aScale);
- if (aForm == gp_Translation || aForm == gp_Identity ||
- aForm == gp_PntMirror || aForm == gp_Scale)
+ if (aForm == gp_Translation || aForm == gp_Identity || aForm == gp_PntMirror || aForm == gp_Scale)
{
aResult =
- (Abs (RealType(theBox.myCenter[0]*aScale + theTrsf.TranslationPart().X())
- - myCenter[0])
- < RealType (theBox.myHSize[0]*aScaleAbs) - myHSize[0] &&
- Abs (RealType(theBox.myCenter[1]*aScale + theTrsf.TranslationPart().Y())
- - myCenter[1])
- < RealType (theBox.myHSize[1]*aScaleAbs) - myHSize[1]);
-
- } else {
+ (Abs(RealType(theBox.myCenter[0] * aScale + theTrsf.TranslationPart().X()) - myCenter[0])
+ < RealType(theBox.myHSize[0] * aScaleAbs) - myHSize[0]
+ && Abs(RealType(theBox.myCenter[1] * aScale + theTrsf.TranslationPart().Y()) - myCenter[1])
+ < RealType(theBox.myHSize[1] * aScaleAbs) - myHSize[1]);
+ }
+ else
+ {
// theBox is rotated, scaled and translated. We apply the reverse
// translation and scaling then check against the rotated box 'this'
- const Standard_Real * aMat = &theTrsf.HVectorialPart().Value(1,1);
- gp_XY aCenter ((Standard_Real)theBox.myCenter[0],
- (Standard_Real)theBox.myCenter[1]);
- theTrsf.Transforms (aCenter);
- const Standard_Real aDist[2] = {
- aCenter.X() - (Standard_Real)myCenter[0],
- aCenter.Y() - (Standard_Real)myCenter[1]
- };
- if ((Abs(aMat[0]*aDist[0]+aMat[2]*aDist[1])
- < theBox.myHSize[0]*aScaleAbs - (Abs(aMat[0])*myHSize[0] +
- Abs(aMat[2])*myHSize[1])) &&
- (Abs(aMat[1]*aDist[0]+aMat[3]*aDist[1])
- < theBox.myHSize[1]*aScaleAbs - (Abs(aMat[1])*myHSize[0] +
- Abs(aMat[3])*myHSize[1])))
+ const Standard_Real* aMat = &theTrsf.HVectorialPart().Value(1, 1);
+ gp_XY aCenter((Standard_Real)theBox.myCenter[0], (Standard_Real)theBox.myCenter[1]);
+ theTrsf.Transforms(aCenter);
+ const Standard_Real aDist[2] = {aCenter.X() - (Standard_Real)myCenter[0],
+ aCenter.Y() - (Standard_Real)myCenter[1]};
+ if ((Abs(aMat[0] * aDist[0] + aMat[2] * aDist[1])
+ < theBox.myHSize[0] * aScaleAbs - (Abs(aMat[0]) * myHSize[0] + Abs(aMat[2]) * myHSize[1]))
+ && (Abs(aMat[1] * aDist[0] + aMat[3] * aDist[1])
+ < theBox.myHSize[1] * aScaleAbs
+ - (Abs(aMat[1]) * myHSize[0] + Abs(aMat[3]) * myHSize[1])))
aResult = Standard_True;
}
return aResult;
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-inline Standard_Boolean _compareDist (const RealType aHSize[3],
- const RealType aDist [3])
+inline Standard_Boolean _compareDist(const RealType aHSize[3], const RealType aDist[3])
{
- return (Abs(aDist[0]) > aHSize[0] ||
- Abs(aDist[1]) > aHSize[1] ||
- Abs(aDist[2]) > aHSize[2]);
+ return (Abs(aDist[0]) > aHSize[0] || Abs(aDist[1]) > aHSize[1] || Abs(aDist[2]) > aHSize[2]);
}
-inline Standard_Boolean _compareDistD (const gp_XYZ& aHSize,const gp_XYZ& aDist)
+inline Standard_Boolean _compareDistD(const gp_XYZ& aHSize, const gp_XYZ& aDist)
{
- return (Abs(aDist.X()) > aHSize.X() ||
- Abs(aDist.Y()) > aHSize.Y() ||
- Abs(aDist.Z()) > aHSize.Z());
+ return (Abs(aDist.X()) > aHSize.X() || Abs(aDist.Y()) > aHSize.Y()
+ || Abs(aDist.Z()) > aHSize.Z());
}
//=======================================================================
-//function : Add
-//purpose : Update the box by a point
+// function : Add
+// purpose : Update the box by a point
//=======================================================================
-void Bnd_B3x::Add (const gp_XYZ& thePnt) {
- if (IsVoid()) {
+void Bnd_B3x::Add(const gp_XYZ& thePnt)
+{
+ if (IsVoid())
+ {
myCenter[0] = RealType(thePnt.X());
myCenter[1] = RealType(thePnt.Y());
myCenter[2] = RealType(thePnt.Z());
- myHSize [0] = 0.;
- myHSize [1] = 0.;
- myHSize [2] = 0.;
- } else {
- const RealType aDiff[3] = {
- RealType(thePnt.X()) - myCenter[0],
- RealType(thePnt.Y()) - myCenter[1],
- RealType(thePnt.Z()) - myCenter[2]
- };
- if (aDiff[0] > myHSize[0]) {
+ myHSize[0] = 0.;
+ myHSize[1] = 0.;
+ myHSize[2] = 0.;
+ }
+ else
+ {
+ const RealType aDiff[3] = {RealType(thePnt.X()) - myCenter[0],
+ RealType(thePnt.Y()) - myCenter[1],
+ RealType(thePnt.Z()) - myCenter[2]};
+ if (aDiff[0] > myHSize[0])
+ {
const RealType aShift = (aDiff[0] - myHSize[0]) / 2;
myCenter[0] += aShift;
- myHSize [0] += aShift;
- } else if (aDiff[0] < -myHSize[0]) {
+ myHSize[0] += aShift;
+ }
+ else if (aDiff[0] < -myHSize[0])
+ {
const RealType aShift = (aDiff[0] + myHSize[0]) / 2;
myCenter[0] += aShift;
- myHSize [0] -= aShift;
+ myHSize[0] -= aShift;
}
- if (aDiff[1] > myHSize[1]) {
+ if (aDiff[1] > myHSize[1])
+ {
const RealType aShift = (aDiff[1] - myHSize[1]) / 2;
- myCenter[1] +=aShift;
- myHSize [1] +=aShift;
- } else if (aDiff[1] < -myHSize[1]) {
+ myCenter[1] += aShift;
+ myHSize[1] += aShift;
+ }
+ else if (aDiff[1] < -myHSize[1])
+ {
const RealType aShift = (aDiff[1] + myHSize[1]) / 2;
myCenter[1] += aShift;
- myHSize [1] -= aShift;
+ myHSize[1] -= aShift;
}
- if (aDiff[2] > myHSize[2]) {
+ if (aDiff[2] > myHSize[2])
+ {
const RealType aShift = (aDiff[2] - myHSize[2]) / 2;
- myCenter[2] +=aShift;
- myHSize [2] +=aShift;
- } else if (aDiff[2] < -myHSize[2]) {
+ myCenter[2] += aShift;
+ myHSize[2] += aShift;
+ }
+ else if (aDiff[2] < -myHSize[2])
+ {
const RealType aShift = (aDiff[2] + myHSize[2]) / 2;
myCenter[2] += aShift;
- myHSize [2] -= aShift;
+ myHSize[2] -= aShift;
}
}
}
//=======================================================================
-//function : Limit
-//purpose : limit the current box with the internals of theBox
+// function : Limit
+// purpose : limit the current box with the internals of theBox
//=======================================================================
-Standard_Boolean Bnd_B3x::Limit (const Bnd_B3x& theBox)
+Standard_Boolean Bnd_B3x::Limit(const Bnd_B3x& theBox)
{
- Standard_Boolean aResult (Standard_False);
- const RealType diffC[3] = {
- theBox.myCenter[0] - myCenter[0],
- theBox.myCenter[1] - myCenter[1],
- theBox.myCenter[2] - myCenter[2]
- };
- const RealType sumH[3] = {
- theBox.myHSize[0] + myHSize[0],
- theBox.myHSize[1] + myHSize[1],
- theBox.myHSize[2] + myHSize[2]
- };
+ Standard_Boolean aResult(Standard_False);
+ const RealType diffC[3] = {theBox.myCenter[0] - myCenter[0],
+ theBox.myCenter[1] - myCenter[1],
+ theBox.myCenter[2] - myCenter[2]};
+ const RealType sumH[3] = {theBox.myHSize[0] + myHSize[0],
+ theBox.myHSize[1] + myHSize[1],
+ theBox.myHSize[2] + myHSize[2]};
// check the condition IsOut
- if (_compareDist (sumH, diffC) == Standard_False) {
- const RealType diffH[3] = {
- theBox.myHSize[0] - myHSize[0],
- theBox.myHSize[1] - myHSize[1],
- theBox.myHSize[2] - myHSize[2]
- };
- if (diffC[0] - diffH[0] > 0.) {
+ if (_compareDist(sumH, diffC) == Standard_False)
+ {
+ const RealType diffH[3] = {theBox.myHSize[0] - myHSize[0],
+ theBox.myHSize[1] - myHSize[1],
+ theBox.myHSize[2] - myHSize[2]};
+ if (diffC[0] - diffH[0] > 0.)
+ {
const RealType aShift = (diffC[0] - diffH[0]) / 2; // positive
myCenter[0] += aShift;
- myHSize [0] -= aShift;
- } else if (diffC[0] + diffH[0] < 0.) {
+ myHSize[0] -= aShift;
+ }
+ else if (diffC[0] + diffH[0] < 0.)
+ {
const RealType aShift = (diffC[0] + diffH[0]) / 2; // negative
myCenter[0] += aShift;
- myHSize [0] += aShift;
+ myHSize[0] += aShift;
}
- if (diffC[1] - diffH[1] > 0.) {
+ if (diffC[1] - diffH[1] > 0.)
+ {
const RealType aShift = (diffC[1] - diffH[1]) / 2; // positive
myCenter[1] += aShift;
- myHSize [1] -= aShift;
- } else if (diffC[1] + diffH[1] < 0.) {
+ myHSize[1] -= aShift;
+ }
+ else if (diffC[1] + diffH[1] < 0.)
+ {
const RealType aShift = (diffC[1] + diffH[1]) / 2; // negative
myCenter[1] += aShift;
- myHSize [1] += aShift;
+ myHSize[1] += aShift;
}
- if (diffC[2] - diffH[2] > 0.) {
+ if (diffC[2] - diffH[2] > 0.)
+ {
const RealType aShift = (diffC[2] - diffH[2]) / 2; // positive
myCenter[2] += aShift;
- myHSize [2] -= aShift;
- } else if (diffC[2] + diffH[2] < 0.) {
+ myHSize[2] -= aShift;
+ }
+ else if (diffC[2] + diffH[2] < 0.)
+ {
const RealType aShift = (diffC[2] + diffH[2]) / 2; // negative
myCenter[2] += aShift;
- myHSize [2] += aShift;
+ myHSize[2] += aShift;
}
aResult = Standard_True;
}
//=================================================================================================
-
-Bnd_B3x Bnd_B3x::Transformed (const gp_Trsf& theTrsf) const
+Bnd_B3x Bnd_B3x::Transformed(const gp_Trsf& theTrsf) const
{
- Bnd_B3x aResult;
- const gp_TrsfForm aForm = theTrsf.Form();
- const Standard_Real aScale = theTrsf.ScaleFactor();
+ Bnd_B3x aResult;
+ const gp_TrsfForm aForm = theTrsf.Form();
+ const Standard_Real aScale = theTrsf.ScaleFactor();
const Standard_Real aScaleAbs = Abs(aScale);
if (aForm == gp_Identity)
- aResult = * this;
- else if (aForm== gp_Translation || aForm== gp_PntMirror || aForm== gp_Scale)
+ aResult = *this;
+ else if (aForm == gp_Translation || aForm == gp_PntMirror || aForm == gp_Scale)
{
- aResult.myCenter[0] =
- (RealType)(myCenter[0] * aScale + theTrsf.TranslationPart().X());
- aResult.myCenter[1] =
- (RealType)(myCenter[1] * aScale + theTrsf.TranslationPart().Y());
- aResult.myCenter[2] =
- (RealType)(myCenter[2] * aScale + theTrsf.TranslationPart().Z());
- aResult.myHSize[0] = (RealType)(myHSize[0] * aScaleAbs);
- aResult.myHSize[1] = (RealType)(myHSize[1] * aScaleAbs);
- aResult.myHSize[2] = (RealType)(myHSize[2] * aScaleAbs);
- } else {
- gp_XYZ aCenter ((Standard_Real)myCenter[0],
- (Standard_Real)myCenter[1],
- (Standard_Real)myCenter[2]);
- theTrsf.Transforms (aCenter);
+ aResult.myCenter[0] = (RealType)(myCenter[0] * aScale + theTrsf.TranslationPart().X());
+ aResult.myCenter[1] = (RealType)(myCenter[1] * aScale + theTrsf.TranslationPart().Y());
+ aResult.myCenter[2] = (RealType)(myCenter[2] * aScale + theTrsf.TranslationPart().Z());
+ aResult.myHSize[0] = (RealType)(myHSize[0] * aScaleAbs);
+ aResult.myHSize[1] = (RealType)(myHSize[1] * aScaleAbs);
+ aResult.myHSize[2] = (RealType)(myHSize[2] * aScaleAbs);
+ }
+ else
+ {
+ gp_XYZ aCenter((Standard_Real)myCenter[0],
+ (Standard_Real)myCenter[1],
+ (Standard_Real)myCenter[2]);
+ theTrsf.Transforms(aCenter);
aResult.myCenter[0] = (RealType)aCenter.X();
aResult.myCenter[1] = (RealType)aCenter.Y();
aResult.myCenter[2] = (RealType)aCenter.Z();
- const Standard_Real * aMat = &theTrsf.HVectorialPart().Value(1,1);
- aResult.myHSize[0] = (RealType)(aScaleAbs * (Abs(aMat[0]) * myHSize[0]+
- Abs(aMat[1]) * myHSize[1]+
- Abs(aMat[2]) * myHSize[2]));
- aResult.myHSize[1] = (RealType)(aScaleAbs * (Abs(aMat[3]) * myHSize[0]+
- Abs(aMat[4]) * myHSize[1]+
- Abs(aMat[5]) * myHSize[2]));
- aResult.myHSize[2] = (RealType)(aScaleAbs * (Abs(aMat[6]) * myHSize[0]+
- Abs(aMat[7]) * myHSize[1]+
- Abs(aMat[8]) * myHSize[2]));
+ const Standard_Real* aMat = &theTrsf.HVectorialPart().Value(1, 1);
+ aResult.myHSize[0] = (RealType)(aScaleAbs
+ * (Abs(aMat[0]) * myHSize[0] + Abs(aMat[1]) * myHSize[1]
+ + Abs(aMat[2]) * myHSize[2]));
+ aResult.myHSize[1] = (RealType)(aScaleAbs
+ * (Abs(aMat[3]) * myHSize[0] + Abs(aMat[4]) * myHSize[1]
+ + Abs(aMat[5]) * myHSize[2]));
+ aResult.myHSize[2] = (RealType)(aScaleAbs
+ * (Abs(aMat[6]) * myHSize[0] + Abs(aMat[7]) * myHSize[1]
+ + Abs(aMat[8]) * myHSize[2]));
}
return aResult;
}
//=======================================================================
-//function : IsOut
-//purpose : Intersection Box - Sphere
+// function : IsOut
+// purpose : Intersection Box - Sphere
//=======================================================================
-Standard_Boolean Bnd_B3x::IsOut (const gp_XYZ& theCenter,
- const Standard_Real theRadius,
- const Standard_Boolean isSphereHollow) const
+Standard_Boolean Bnd_B3x::IsOut(const gp_XYZ& theCenter,
+ const Standard_Real theRadius,
+ const Standard_Boolean isSphereHollow) const
{
- Standard_Boolean aResult (Standard_True);
- if (isSphereHollow == Standard_False) {
+ Standard_Boolean aResult(Standard_True);
+ if (isSphereHollow == Standard_False)
+ {
// vector from the center of the sphere to the nearest box face
const Standard_Real aDist[3] = {
- Abs(theCenter.X()-Standard_Real(myCenter[0])) - Standard_Real(myHSize[0]),
- Abs(theCenter.Y()-Standard_Real(myCenter[1])) - Standard_Real(myHSize[1]),
- Abs(theCenter.Z()-Standard_Real(myCenter[2])) - Standard_Real(myHSize[2])
- };
- Standard_Real aD (0.);
+ Abs(theCenter.X() - Standard_Real(myCenter[0])) - Standard_Real(myHSize[0]),
+ Abs(theCenter.Y() - Standard_Real(myCenter[1])) - Standard_Real(myHSize[1]),
+ Abs(theCenter.Z() - Standard_Real(myCenter[2])) - Standard_Real(myHSize[2])};
+ Standard_Real aD(0.);
if (aDist[0] > 0.)
- aD = aDist[0]*aDist[0];
+ aD = aDist[0] * aDist[0];
if (aDist[1] > 0.)
- aD += aDist[1]*aDist[1];
+ aD += aDist[1] * aDist[1];
if (aDist[2] > 0.)
- aD += aDist[2]*aDist[2];
- aResult = (aD > theRadius*theRadius);
- } else {
- const Standard_Real aDistC[3] = {
- Abs(theCenter.X()-Standard_Real(myCenter[0])),
- Abs(theCenter.Y()-Standard_Real(myCenter[1])),
- Abs(theCenter.Z()-Standard_Real(myCenter[2]))
- };
+ aD += aDist[2] * aDist[2];
+ aResult = (aD > theRadius * theRadius);
+ }
+ else
+ {
+ const Standard_Real aDistC[3] = {Abs(theCenter.X() - Standard_Real(myCenter[0])),
+ Abs(theCenter.Y() - Standard_Real(myCenter[1])),
+ Abs(theCenter.Z() - Standard_Real(myCenter[2]))};
// vector from the center of the sphere to the nearest box face
- Standard_Real aDist[3] = {
- aDistC[0] - Standard_Real(myHSize[0]),
- aDistC[1] - Standard_Real(myHSize[1]),
- aDistC[2] - Standard_Real(myHSize[2])
- };
- Standard_Real aD (0.);
+ Standard_Real aDist[3] = {aDistC[0] - Standard_Real(myHSize[0]),
+ aDistC[1] - Standard_Real(myHSize[1]),
+ aDistC[2] - Standard_Real(myHSize[2])};
+ Standard_Real aD(0.);
if (aDist[0] > 0.)
- aD = aDist[0]*aDist[0];
+ aD = aDist[0] * aDist[0];
if (aDist[1] > 0.)
- aD += aDist[1]*aDist[1];
+ aD += aDist[1] * aDist[1];
if (aDist[2] > 0.)
- aD += aDist[2]*aDist[2];
- if (aD < theRadius*theRadius) {
+ aD += aDist[2] * aDist[2];
+ if (aD < theRadius * theRadius)
+ {
// the box intersects the solid sphere; check if it is completely
// inside the circle (in such case return isOut==True)
aDist[0] = aDistC[0] + Standard_Real(myHSize[0]);
aDist[1] = aDistC[1] + Standard_Real(myHSize[1]);
aDist[2] = aDistC[2] + Standard_Real(myHSize[2]);
- if (aDist[0]*aDist[0]+aDist[1]*aDist[1]+aDist[2]*aDist[2]
- > theRadius*theRadius)
+ if (aDist[0] * aDist[0] + aDist[1] * aDist[1] + aDist[2] * aDist[2] > theRadius * theRadius)
aResult = Standard_False;
}
}
}
//=======================================================================
-//function : IsOut
-//purpose : Intersection Box - transformed Box
+// function : IsOut
+// purpose : Intersection Box - transformed Box
//=======================================================================
-Standard_Boolean Bnd_B3x::IsOut (const Bnd_B3x& theBox,
- const gp_Trsf& theTrsf) const
+Standard_Boolean Bnd_B3x::IsOut(const Bnd_B3x& theBox, const gp_Trsf& theTrsf) const
{
- Standard_Boolean aResult (Standard_False);
- const gp_TrsfForm aForm = theTrsf.Form();
- const Standard_Real aScale = theTrsf.ScaleFactor();
+ Standard_Boolean aResult(Standard_False);
+ const gp_TrsfForm aForm = theTrsf.Form();
+ const Standard_Real aScale = theTrsf.ScaleFactor();
const Standard_Real aScaleAbs = Abs(aScale);
- if (aForm == gp_Translation || aForm == gp_Identity ||
- aForm == gp_PntMirror || aForm == gp_Scale)
+ if (aForm == gp_Translation || aForm == gp_Identity || aForm == gp_PntMirror || aForm == gp_Scale)
{
aResult =
- (Abs (RealType(theBox.myCenter[0]*aScale + theTrsf.TranslationPart().X())
- - myCenter[0])
- > RealType (theBox.myHSize[0]*aScaleAbs) + myHSize[0] ||
- Abs (RealType(theBox.myCenter[1]*aScale + theTrsf.TranslationPart().Y())
- - myCenter[1])
- > RealType (theBox.myHSize[1]*aScaleAbs) + myHSize[1] ||
- Abs (RealType(theBox.myCenter[2]*aScale + theTrsf.TranslationPart().Y())
- - myCenter[2])
- > RealType (theBox.myHSize[2]*aScaleAbs) + myHSize[2]);
-
+ (Abs(RealType(theBox.myCenter[0] * aScale + theTrsf.TranslationPart().X()) - myCenter[0])
+ > RealType(theBox.myHSize[0] * aScaleAbs) + myHSize[0]
+ || Abs(RealType(theBox.myCenter[1] * aScale + theTrsf.TranslationPart().Y()) - myCenter[1])
+ > RealType(theBox.myHSize[1] * aScaleAbs) + myHSize[1]
+ || Abs(RealType(theBox.myCenter[2] * aScale + theTrsf.TranslationPart().Y()) - myCenter[2])
+ > RealType(theBox.myHSize[2] * aScaleAbs) + myHSize[2]);
}
- else {
+ else
+ {
// theBox is transformed and we check the resulting (enlarged) box against
// 'this' box.
- const Standard_Real * aMat = &theTrsf.HVectorialPart().Value(1,1);
+ const Standard_Real* aMat = &theTrsf.HVectorialPart().Value(1, 1);
- gp_XYZ aCenter ((Standard_Real)theBox.myCenter[0],
- (Standard_Real)theBox.myCenter[1],
- (Standard_Real)theBox.myCenter[2]);
- theTrsf.Transforms (aCenter);
- const Standard_Real aDist[3] = {
- aCenter.X() - (Standard_Real)myCenter[0],
- aCenter.Y() - (Standard_Real)myCenter[1],
- aCenter.Z() - (Standard_Real)myCenter[2]
- };
- const Standard_Real aMatAbs[9] = {
- Abs(aMat[0]), Abs(aMat[1]), Abs(aMat[2]), Abs(aMat[3]), Abs(aMat[4]),
- Abs(aMat[5]), Abs(aMat[6]), Abs(aMat[7]), Abs(aMat[8])
- };
- if (Abs(aDist[0]) > (aScaleAbs*(aMatAbs[0]*theBox.myHSize[0]+
- aMatAbs[1]*theBox.myHSize[1]+
- aMatAbs[2]*theBox.myHSize[2]) +
- (Standard_Real)myHSize[0]) ||
- Abs(aDist[1]) > (aScaleAbs*(aMatAbs[3]*theBox.myHSize[0]+
- aMatAbs[4]*theBox.myHSize[1]+
- aMatAbs[5]*theBox.myHSize[2]) +
- (Standard_Real)myHSize[1]) ||
- Abs(aDist[2]) > (aScaleAbs*(aMatAbs[6]*theBox.myHSize[0]+
- aMatAbs[7]*theBox.myHSize[1]+
- aMatAbs[8]*theBox.myHSize[2]) +
- (Standard_Real)myHSize[2]))
+ gp_XYZ aCenter((Standard_Real)theBox.myCenter[0],
+ (Standard_Real)theBox.myCenter[1],
+ (Standard_Real)theBox.myCenter[2]);
+ theTrsf.Transforms(aCenter);
+ const Standard_Real aDist[3] = {aCenter.X() - (Standard_Real)myCenter[0],
+ aCenter.Y() - (Standard_Real)myCenter[1],
+ aCenter.Z() - (Standard_Real)myCenter[2]};
+ const Standard_Real aMatAbs[9] = {Abs(aMat[0]),
+ Abs(aMat[1]),
+ Abs(aMat[2]),
+ Abs(aMat[3]),
+ Abs(aMat[4]),
+ Abs(aMat[5]),
+ Abs(aMat[6]),
+ Abs(aMat[7]),
+ Abs(aMat[8])};
+ if (Abs(aDist[0]) > (aScaleAbs
+ * (aMatAbs[0] * theBox.myHSize[0] + aMatAbs[1] * theBox.myHSize[1]
+ + aMatAbs[2] * theBox.myHSize[2])
+ + (Standard_Real)myHSize[0])
+ || Abs(aDist[1]) > (aScaleAbs
+ * (aMatAbs[3] * theBox.myHSize[0] + aMatAbs[4] * theBox.myHSize[1]
+ + aMatAbs[5] * theBox.myHSize[2])
+ + (Standard_Real)myHSize[1])
+ || Abs(aDist[2]) > (aScaleAbs
+ * (aMatAbs[6] * theBox.myHSize[0] + aMatAbs[7] * theBox.myHSize[1]
+ + aMatAbs[8] * theBox.myHSize[2])
+ + (Standard_Real)myHSize[2]))
aResult = Standard_True;
- else {
- // theBox is rotated, scaled and translated. We apply the reverse
- // translation and scaling then check against the rotated box 'this'
- if ((Abs(aMat[0]*aDist[0]+aMat[3]*aDist[1]+aMat[6]*aDist[2])
- > theBox.myHSize[0]*aScaleAbs + (aMatAbs[0]*myHSize[0] +
- aMatAbs[3]*myHSize[1] +
- aMatAbs[6]*myHSize[2])) ||
- (Abs(aMat[1]*aDist[0]+aMat[4]*aDist[1]+aMat[7]*aDist[2])
- > theBox.myHSize[1]*aScaleAbs + (aMatAbs[1]*myHSize[0] +
- aMatAbs[4]*myHSize[1] +
- aMatAbs[7]*myHSize[2])) ||
- (Abs(aMat[2]*aDist[0]+aMat[5]*aDist[1]+aMat[8]*aDist[2])
- > theBox.myHSize[2]*aScaleAbs + (aMatAbs[2]*myHSize[0] +
- aMatAbs[5]*myHSize[1] +
- aMatAbs[8]*myHSize[2])))
+ else
+ {
+ // theBox is rotated, scaled and translated. We apply the reverse
+ // translation and scaling then check against the rotated box 'this'
+ if ((Abs(aMat[0] * aDist[0] + aMat[3] * aDist[1] + aMat[6] * aDist[2])
+ > theBox.myHSize[0] * aScaleAbs
+ + (aMatAbs[0] * myHSize[0] + aMatAbs[3] * myHSize[1] + aMatAbs[6] * myHSize[2]))
+ || (Abs(aMat[1] * aDist[0] + aMat[4] * aDist[1] + aMat[7] * aDist[2])
+ > theBox.myHSize[1] * aScaleAbs
+ + (aMatAbs[1] * myHSize[0] + aMatAbs[4] * myHSize[1] + aMatAbs[7] * myHSize[2]))
+ || (Abs(aMat[2] * aDist[0] + aMat[5] * aDist[1] + aMat[8] * aDist[2])
+ > theBox.myHSize[2] * aScaleAbs
+ + (aMatAbs[2] * myHSize[0] + aMatAbs[5] * myHSize[1] + aMatAbs[8] * myHSize[2])))
aResult = Standard_True;
}
}
//=================================================================================================
-
-Standard_Boolean Bnd_B3x::IsOut (const gp_Ax3& thePlane) const
+Standard_Boolean Bnd_B3x::IsOut(const gp_Ax3& thePlane) const
{
if (IsVoid())
return Standard_True;
- const gp_XYZ& anOrigin = thePlane.Location().XYZ();
- const gp_XYZ& aDir = thePlane.Direction().XYZ();
- const gp_XYZ aBoxCenter ((Standard_Real)myCenter[0],
- (Standard_Real)myCenter[1],
- (Standard_Real)myCenter[2]);
+ const gp_XYZ& anOrigin = thePlane.Location().XYZ();
+ const gp_XYZ& aDir = thePlane.Direction().XYZ();
+ const gp_XYZ aBoxCenter((Standard_Real)myCenter[0],
+ (Standard_Real)myCenter[1],
+ (Standard_Real)myCenter[2]);
const Standard_Real aDist0 = (aBoxCenter - anOrigin) * aDir;
// Find the signed distances from two opposite corners of the box to the plane
// If the distances are not the same sign, then the plane crosses the box
- const Standard_Real aDist1 = // proj of HSize on aDir
- Standard_Real(myHSize[0]) * Abs(aDir.X()) +
- Standard_Real(myHSize[1]) * Abs(aDir.Y()) +
- Standard_Real(myHSize[2]) * Abs(aDir.Z());
+ const Standard_Real aDist1 = // proj of HSize on aDir
+ Standard_Real(myHSize[0]) * Abs(aDir.X()) + Standard_Real(myHSize[1]) * Abs(aDir.Y())
+ + Standard_Real(myHSize[2]) * Abs(aDir.Z());
return ((aDist0 + aDist1) * (aDist0 - aDist1) > 0.);
}
//=================================================================================================
-
-Standard_Boolean Bnd_B3x::IsOut (const gp_Ax1& theLine,
- const Standard_Boolean isRay,
- const Standard_Real theOverthickness) const
+Standard_Boolean Bnd_B3x::IsOut(const gp_Ax1& theLine,
+ const Standard_Boolean isRay,
+ const Standard_Real theOverthickness) const
{
const Standard_Real aRes = gp::Resolution() * 100.;
if (IsVoid())
return Standard_True;
- Standard_Real
- anInter0[2] = {-RealLast(), RealLast()},
- anInter1[2] = {-RealLast(), RealLast()};
+ Standard_Real anInter0[2] = {-RealLast(), RealLast()}, anInter1[2] = {-RealLast(), RealLast()};
const gp_XYZ& aDir = theLine.Direction().XYZ();
- const gp_XYZ aDiff ((Standard_Real)myCenter[0] - theLine.Location().X(),
- (Standard_Real)myCenter[1] - theLine.Location().Y(),
- (Standard_Real)myCenter[2] - theLine.Location().Z());
+ const gp_XYZ aDiff((Standard_Real)myCenter[0] - theLine.Location().X(),
+ (Standard_Real)myCenter[1] - theLine.Location().Y(),
+ (Standard_Real)myCenter[2] - theLine.Location().Z());
// Find the parameter interval in X dimension
- Standard_Real aHSize = (Standard_Real)myHSize[0]+theOverthickness;
- if (aDir.X() > aRes) {
- anInter0[0]= (aDiff.X() - aHSize) / aDir.X();
- anInter0[1]= (aDiff.X() + aHSize) / aDir.X();
- } else if (aDir.X() < -aRes) {
- anInter0[0]= (aDiff.X() + aHSize) / aDir.X();
- anInter0[1]= (aDiff.X() - aHSize) / aDir.X();
- } else
+ Standard_Real aHSize = (Standard_Real)myHSize[0] + theOverthickness;
+ if (aDir.X() > aRes)
+ {
+ anInter0[0] = (aDiff.X() - aHSize) / aDir.X();
+ anInter0[1] = (aDiff.X() + aHSize) / aDir.X();
+ }
+ else if (aDir.X() < -aRes)
+ {
+ anInter0[0] = (aDiff.X() + aHSize) / aDir.X();
+ anInter0[1] = (aDiff.X() - aHSize) / aDir.X();
+ }
+ else
// the line is orthogonal to OX axis. Test for inclusion in box limits
if (Abs(aDiff.X()) > aHSize)
return Standard_True;
-
+
// Find the parameter interval in Y dimension
- aHSize = (Standard_Real)myHSize[1]+theOverthickness;
- if (aDir.Y() > aRes) {
- anInter1[0]= (aDiff.Y() - aHSize) / aDir.Y();
- anInter1[1]= (aDiff.Y() + aHSize) / aDir.Y();
- } else if (aDir.Y() < -aRes) {
- anInter1[0]= (aDiff.Y() + aHSize) / aDir.Y();
- anInter1[1]= (aDiff.Y() - aHSize) / aDir.Y();
- } else
+ aHSize = (Standard_Real)myHSize[1] + theOverthickness;
+ if (aDir.Y() > aRes)
+ {
+ anInter1[0] = (aDiff.Y() - aHSize) / aDir.Y();
+ anInter1[1] = (aDiff.Y() + aHSize) / aDir.Y();
+ }
+ else if (aDir.Y() < -aRes)
+ {
+ anInter1[0] = (aDiff.Y() + aHSize) / aDir.Y();
+ anInter1[1] = (aDiff.Y() - aHSize) / aDir.Y();
+ }
+ else
// the line is orthogonal to OY axis. Test for inclusion in box limits
if (Abs(aDiff.Y()) > aHSize)
return Standard_True;
- // Intersect Y-interval with X-interval
+ // Intersect Y-interval with X-interval
if (anInter0[0] > (anInter1[1] + aRes) || anInter0[1] < (anInter1[0] - aRes))
return Standard_True;
if (anInter1[0] > anInter0[0])
return Standard_True;
// Find the parameter interval in Z dimension
- aHSize = (Standard_Real)myHSize[2]+theOverthickness;
- if (aDir.Z() > aRes) {
- anInter1[0]= (aDiff.Z() - aHSize) / aDir.Z();
- anInter1[1]= (aDiff.Z() + aHSize) / aDir.Z();
- } else if (aDir.Z() < -aRes) {
- anInter1[0]= (aDiff.Z() + aHSize) / aDir.Z();
- anInter1[1]= (aDiff.Z() - aHSize) / aDir.Z();
- } else
+ aHSize = (Standard_Real)myHSize[2] + theOverthickness;
+ if (aDir.Z() > aRes)
+ {
+ anInter1[0] = (aDiff.Z() - aHSize) / aDir.Z();
+ anInter1[1] = (aDiff.Z() + aHSize) / aDir.Z();
+ }
+ else if (aDir.Z() < -aRes)
+ {
+ anInter1[0] = (aDiff.Z() + aHSize) / aDir.Z();
+ anInter1[1] = (aDiff.Z() - aHSize) / aDir.Z();
+ }
+ else
// the line is orthogonal to OZ axis. Test for inclusion in box limits
return (Abs(aDiff.Z()) > aHSize);
if (isRay && anInter1[1] < -aRes)
return Standard_True;
- return (anInter0[0] > (anInter1[1]+aRes) || anInter0[1] < (anInter1[0]-aRes));
+ return (anInter0[0] > (anInter1[1] + aRes) || anInter0[1] < (anInter1[0] - aRes));
}
//=======================================================================
-//function : IsIn
-//purpose : Test the complete inclusion of this box in transformed theOtherBox
+// function : IsIn
+// purpose : Test the complete inclusion of this box in transformed theOtherBox
//=======================================================================
-Standard_Boolean Bnd_B3x::IsIn (const Bnd_B3x& theBox,
- const gp_Trsf& theTrsf) const
+Standard_Boolean Bnd_B3x::IsIn(const Bnd_B3x& theBox, const gp_Trsf& theTrsf) const
{
- Standard_Boolean aResult (Standard_False);
- const gp_TrsfForm aForm = theTrsf.Form();
- const Standard_Real aScale = theTrsf.ScaleFactor();
+ Standard_Boolean aResult(Standard_False);
+ const gp_TrsfForm aForm = theTrsf.Form();
+ const Standard_Real aScale = theTrsf.ScaleFactor();
const Standard_Real aScaleAbs = Abs(aScale);
- if (aForm == gp_Translation || aForm == gp_Identity ||
- aForm == gp_PntMirror || aForm == gp_Scale)
+ if (aForm == gp_Translation || aForm == gp_Identity || aForm == gp_PntMirror || aForm == gp_Scale)
{
aResult =
- (Abs (RealType(theBox.myCenter[0]*aScale + theTrsf.TranslationPart().X())
- - myCenter[0])
- < RealType (theBox.myHSize[0]*aScaleAbs) - myHSize[0] &&
- Abs (RealType(theBox.myCenter[1]*aScale + theTrsf.TranslationPart().Y())
- - myCenter[1])
- < RealType (theBox.myHSize[1]*aScaleAbs) - myHSize[1] &&
- Abs (RealType(theBox.myCenter[2]*aScale + theTrsf.TranslationPart().Y())
- - myCenter[2])
- < RealType (theBox.myHSize[2]*aScaleAbs) - myHSize[2]);
-
- } else {
+ (Abs(RealType(theBox.myCenter[0] * aScale + theTrsf.TranslationPart().X()) - myCenter[0])
+ < RealType(theBox.myHSize[0] * aScaleAbs) - myHSize[0]
+ && Abs(RealType(theBox.myCenter[1] * aScale + theTrsf.TranslationPart().Y()) - myCenter[1])
+ < RealType(theBox.myHSize[1] * aScaleAbs) - myHSize[1]
+ && Abs(RealType(theBox.myCenter[2] * aScale + theTrsf.TranslationPart().Y()) - myCenter[2])
+ < RealType(theBox.myHSize[2] * aScaleAbs) - myHSize[2]);
+ }
+ else
+ {
// theBox is rotated, scaled and translated. We apply the reverse
// translation and scaling then check against the rotated box 'this'
- const Standard_Real * aMat = &theTrsf.HVectorialPart().Value(1,1);
- gp_XYZ aCenter ((Standard_Real)theBox.myCenter[0],
- (Standard_Real)theBox.myCenter[1],
- (Standard_Real)theBox.myCenter[2]);
- theTrsf.Transforms (aCenter);
- const Standard_Real aDist[3] = {
- aCenter.X() - (Standard_Real)myCenter[0],
- aCenter.Y() - (Standard_Real)myCenter[1],
- aCenter.Z() - (Standard_Real)myCenter[2]
- };
- if ((Abs(aMat[0]*aDist[0]+aMat[3]*aDist[1]+aMat[6]*aDist[2])
- < theBox.myHSize[0]*aScaleAbs - (Abs(aMat[0])*myHSize[0] +
- Abs(aMat[3])*myHSize[1] +
- Abs(aMat[6])*myHSize[2])) &&
- (Abs(aMat[1]*aDist[0]+aMat[4]*aDist[1]+aMat[7]*aDist[2])
- < theBox.myHSize[1]*aScaleAbs - (Abs(aMat[1])*myHSize[0] +
- Abs(aMat[4])*myHSize[1] +
- Abs(aMat[7])*myHSize[2])) &&
- (Abs(aMat[2]*aDist[0]+aMat[5]*aDist[1]+aMat[8]*aDist[2])
- < theBox.myHSize[2]*aScaleAbs - (Abs(aMat[2])*myHSize[0] +
- Abs(aMat[5])*myHSize[1] +
- Abs(aMat[8])*myHSize[2])))
+ const Standard_Real* aMat = &theTrsf.HVectorialPart().Value(1, 1);
+ gp_XYZ aCenter((Standard_Real)theBox.myCenter[0],
+ (Standard_Real)theBox.myCenter[1],
+ (Standard_Real)theBox.myCenter[2]);
+ theTrsf.Transforms(aCenter);
+ const Standard_Real aDist[3] = {aCenter.X() - (Standard_Real)myCenter[0],
+ aCenter.Y() - (Standard_Real)myCenter[1],
+ aCenter.Z() - (Standard_Real)myCenter[2]};
+ if ((Abs(aMat[0] * aDist[0] + aMat[3] * aDist[1] + aMat[6] * aDist[2])
+ < theBox.myHSize[0] * aScaleAbs
+ - (Abs(aMat[0]) * myHSize[0] + Abs(aMat[3]) * myHSize[1] + Abs(aMat[6]) * myHSize[2]))
+ && (Abs(aMat[1] * aDist[0] + aMat[4] * aDist[1] + aMat[7] * aDist[2])
+ < theBox.myHSize[1] * aScaleAbs
+ - (Abs(aMat[1]) * myHSize[0] + Abs(aMat[4]) * myHSize[1]
+ + Abs(aMat[7]) * myHSize[2]))
+ && (Abs(aMat[2] * aDist[0] + aMat[5] * aDist[1] + aMat[8] * aDist[2])
+ < theBox.myHSize[2] * aScaleAbs
+ - (Abs(aMat[2]) * myHSize[0] + Abs(aMat[5]) * myHSize[1]
+ + Abs(aMat[8]) * myHSize[2])))
aResult = Standard_True;
}
return aResult;
}
-
#include <AppParCurves_HArray1OfConstraintCouple.hxx>
#include <AppDef_Variational.hxx>
-static Standard_Boolean scal = 1;
+static Standard_Boolean scal = 1;
-Standard_EXPORT Standard_Boolean AppBlend_GetContextSplineApprox();
-Standard_EXPORT Standard_Boolean AppBlend_GetContextApproxWithNoTgt();
+Standard_EXPORT Standard_Boolean AppBlend_GetContextSplineApprox();
+Standard_EXPORT Standard_Boolean AppBlend_GetContextApproxWithNoTgt();
// modified by EAP (Edward AGAPOV) Fri Jan 4 2002, bug OCC9
// --- keep pipe parametrized like path
-
//=================================================================================================
-
-AppBlend_AppSurf::AppBlend_AppSurf ()
-: done(Standard_False),
- dmin(0),
- dmax(0),
- tol3d(0.0),
- tol2d(0.0),
- nbit(0),
- udeg(0),
- vdeg(0),
- knownp(Standard_False),
- tol3dreached(0.0),
- tol2dreached(0.0),
- paramtype(Approx_ChordLength),
- continuity(GeomAbs_C2)
+AppBlend_AppSurf::AppBlend_AppSurf()
+ : done(Standard_False),
+ dmin(0),
+ dmax(0),
+ tol3d(0.0),
+ tol2d(0.0),
+ nbit(0),
+ udeg(0),
+ vdeg(0),
+ knownp(Standard_False),
+ tol3dreached(0.0),
+ tol2dreached(0.0),
+ paramtype(Approx_ChordLength),
+ continuity(GeomAbs_C2)
{
- critweights[0]=0.4;
- critweights[1]=0.2;
- critweights[2]=0.4;
+ critweights[0] = 0.4;
+ critweights[1] = 0.2;
+ critweights[2] = 0.4;
}
-
//=================================================================================================
-
-AppBlend_AppSurf::AppBlend_AppSurf (const Standard_Integer Degmin,
- const Standard_Integer Degmax,
- const Standard_Real Tol3d,
- const Standard_Real Tol2d,
- const Standard_Integer NbIt,
- const Standard_Boolean KnownParameters)
-: done(Standard_False),
- dmin(Degmin),
- dmax(Degmax),
- tol3d(Tol3d),
- tol2d(Tol2d),
- nbit(NbIt),
- udeg(0),
- vdeg(0),
- knownp(KnownParameters),
- tol3dreached(0.0),
- tol2dreached(0.0),
- paramtype(Approx_ChordLength),
- continuity(GeomAbs_C2)
+AppBlend_AppSurf::AppBlend_AppSurf(const Standard_Integer Degmin,
+ const Standard_Integer Degmax,
+ const Standard_Real Tol3d,
+ const Standard_Real Tol2d,
+ const Standard_Integer NbIt,
+ const Standard_Boolean KnownParameters)
+ : done(Standard_False),
+ dmin(Degmin),
+ dmax(Degmax),
+ tol3d(Tol3d),
+ tol2d(Tol2d),
+ nbit(NbIt),
+ udeg(0),
+ vdeg(0),
+ knownp(KnownParameters),
+ tol3dreached(0.0),
+ tol2dreached(0.0),
+ paramtype(Approx_ChordLength),
+ continuity(GeomAbs_C2)
{
- critweights[0]=0.4;
- critweights[1]=0.2;
- critweights[2]=0.4;
+ critweights[0] = 0.4;
+ critweights[1] = 0.2;
+ critweights[2] = 0.4;
}
//=================================================================================================
-
-void AppBlend_AppSurf::Init (const Standard_Integer Degmin,
- const Standard_Integer Degmax,
- const Standard_Real Tol3d,
- const Standard_Real Tol2d,
- const Standard_Integer NbIt,
- const Standard_Boolean KnownParameters)
+void AppBlend_AppSurf::Init(const Standard_Integer Degmin,
+ const Standard_Integer Degmax,
+ const Standard_Real Tol3d,
+ const Standard_Real Tol2d,
+ const Standard_Integer NbIt,
+ const Standard_Boolean KnownParameters)
{
- done = Standard_False;
- dmin = Degmin;
- dmax = Degmax;
- tol3d = Tol3d;
- tol2d = Tol2d;
- nbit = NbIt;
- knownp = KnownParameters;
- continuity = GeomAbs_C2;
- paramtype = Approx_ChordLength;
- critweights[0]=0.4;
- critweights[1]=0.2;
- critweights[2]=0.4;
+ done = Standard_False;
+ dmin = Degmin;
+ dmax = Degmax;
+ tol3d = Tol3d;
+ tol2d = Tol2d;
+ nbit = NbIt;
+ knownp = KnownParameters;
+ continuity = GeomAbs_C2;
+ paramtype = Approx_ChordLength;
+ critweights[0] = 0.4;
+ critweights[1] = 0.2;
+ critweights[2] = 0.4;
}
//=======================================================================
-//function : CriteriumWeight
-//purpose : returns the Weights associed to the criterium used in
+// function : CriteriumWeight
+// purpose : returns the Weights associed to the criterium used in
// the optimization.
//=======================================================================
//
-void AppBlend_AppSurf::CriteriumWeight(Standard_Real& W1, Standard_Real& W2, Standard_Real& W3) const
+void AppBlend_AppSurf::CriteriumWeight(Standard_Real& W1,
+ Standard_Real& W2,
+ Standard_Real& W3) const
{
W1 = critweights[0];
W2 = critweights[1];
- W3 = critweights[2] ;
+ W3 = critweights[2];
}
-//=================================================================================================
+//=================================================================================================
-void AppBlend_AppSurf::SetCriteriumWeight(const Standard_Real W1, const Standard_Real W2, const Standard_Real W3)
+void AppBlend_AppSurf::SetCriteriumWeight(const Standard_Real W1,
+ const Standard_Real W2,
+ const Standard_Real W3)
{
- if (W1 < 0 || W2 < 0 || W3 < 0 ) throw Standard_DomainError();
+ if (W1 < 0 || W2 < 0 || W3 < 0)
+ throw Standard_DomainError();
critweights[0] = W1;
critweights[1] = W2;
critweights[2] = W3;
}
-//=================================================================================================
+//=================================================================================================
-void AppBlend_AppSurf::SetContinuity (const GeomAbs_Shape TheCont)
+void AppBlend_AppSurf::SetContinuity(const GeomAbs_Shape TheCont)
{
continuity = TheCont;
}
//=================================================================================================
-
-GeomAbs_Shape AppBlend_AppSurf::Continuity () const
+GeomAbs_Shape AppBlend_AppSurf::Continuity() const
{
return continuity;
}
//=================================================================================================
-
-void AppBlend_AppSurf::SetParType (const Approx_ParametrizationType ParType)
+void AppBlend_AppSurf::SetParType(const Approx_ParametrizationType ParType)
{
paramtype = ParType;
}
//=================================================================================================
-
-Approx_ParametrizationType AppBlend_AppSurf::ParType () const
+Approx_ParametrizationType AppBlend_AppSurf::ParType() const
{
return paramtype;
}
-
//=================================================================================================
-
void AppBlend_AppSurf::Perform(const Handle(TheLine)& Lin,
- TheSectionGenerator& F,
- const Standard_Boolean SpApprox)
+ TheSectionGenerator& F,
+ const Standard_Boolean SpApprox)
{
InternalPerform(Lin, F, SpApprox, Standard_False);
//=================================================================================================
-
-void AppBlend_AppSurf::PerformSmoothing(const Handle(TheLine)& Lin,
- TheSectionGenerator& F)
+void AppBlend_AppSurf::PerformSmoothing(const Handle(TheLine)& Lin, TheSectionGenerator& F)
{
InternalPerform(Lin, F, Standard_True, Standard_True);
//=================================================================================================
-
void AppBlend_AppSurf::InternalPerform(const Handle(TheLine)& Lin,
- TheSectionGenerator& F,
- const Standard_Boolean SpApprox,
- const Standard_Boolean UseSmoothing)
+ TheSectionGenerator& F,
+ const Standard_Boolean SpApprox,
+ const Standard_Boolean UseSmoothing)
{
done = Standard_False;
- if (Lin.IsNull()) {return;}
- Standard_Integer i,j,k,NbPoint;
- Standard_Integer NbUPoles,NbUKnots,NbPoles2d,NbVPoles;
- Standard_Boolean withderiv;
- AppParCurves_Constraint Cfirst,Clast;
+ if (Lin.IsNull())
+ {
+ return;
+ }
+ Standard_Integer i, j, k, NbPoint;
+ Standard_Integer NbUPoles, NbUKnots, NbPoles2d, NbVPoles;
+ Standard_Boolean withderiv;
+ AppParCurves_Constraint Cfirst, Clast;
- Standard_Real mytol3d,mytol2d;
- gp_XYZ newDv;
+ Standard_Real mytol3d, mytol2d;
+ gp_XYZ newDv;
seqPoles2d.Clear();
- NbPoint=Lin->NbPoints();
+ NbPoint = Lin->NbPoints();
AppDef_MultiPointConstraint multP;
- AppDef_MultiLine multL(NbPoint);
+ AppDef_MultiLine multL(NbPoint);
- F.GetShape(NbUPoles,NbUKnots,udeg,NbPoles2d);
+ F.GetShape(NbUPoles, NbUKnots, udeg, NbPoles2d);
- tabUKnots = new TColStd_HArray1OfReal (1,NbUKnots);
- tabUMults = new TColStd_HArray1OfInteger (1,NbUKnots);
+ tabUKnots = new TColStd_HArray1OfReal(1, NbUKnots);
+ tabUMults = new TColStd_HArray1OfInteger(1, NbUKnots);
F.Knots(tabUKnots->ChangeArray1());
F.Mults(tabUMults->ChangeArray1());
- TColgp_Array1OfPnt tabAppP(1,NbUPoles);
- TColgp_Array1OfVec tabAppV(1,NbUPoles);
-
- TColgp_Array1OfPnt2d tabP2d(1,Max(1,NbPoles2d));
- TColgp_Array1OfVec2d tabV2d(1,Max(1,NbPoles2d));
+ TColgp_Array1OfPnt tabAppP(1, NbUPoles);
+ TColgp_Array1OfVec tabAppV(1, NbUPoles);
- TColStd_Array1OfReal tabW(1,NbUPoles),tabDW(1,NbUPoles);
+ TColgp_Array1OfPnt2d tabP2d(1, Max(1, NbPoles2d));
+ TColgp_Array1OfVec2d tabV2d(1, Max(1, NbPoles2d));
- TColgp_Array1OfPnt2d tabAppP2d(1,NbPoles2d+NbUPoles); // points2d + poids
- TColgp_Array1OfVec2d tabAppV2d(1,NbPoles2d+NbUPoles);
+ TColStd_Array1OfReal tabW(1, NbUPoles), tabDW(1, NbUPoles);
+ TColgp_Array1OfPnt2d tabAppP2d(1, NbPoles2d + NbUPoles); // points2d + poids
+ TColgp_Array1OfVec2d tabAppV2d(1, NbPoles2d + NbUPoles);
AppParCurves_MultiBSpCurve multC;
-// Standard_Boolean SpApprox = Standard_False;
+ // Standard_Boolean SpApprox = Standard_False;
- withderiv = F.Section(Lin->Point(1),tabAppP,tabAppV,tabP2d,tabV2d,
- tabW,tabDW);
+ withderiv = F.Section(Lin->Point(1), tabAppP, tabAppV, tabP2d, tabV2d, tabW, tabDW);
- if(AppBlend_GetContextApproxWithNoTgt()) withderiv = Standard_False;
+ if (AppBlend_GetContextApproxWithNoTgt())
+ withderiv = Standard_False;
- for (j=1; j<=NbPoles2d; j++) {
+ for (j = 1; j <= NbPoles2d; j++)
+ {
tabAppP2d(j) = tabP2d(j);
- if (withderiv) {
+ if (withderiv)
+ {
tabAppV2d(j) = tabV2d(j);
}
}
- for (j=1; j<=NbUPoles; j++) {
+ for (j = 1; j <= NbUPoles; j++)
+ {
// pour les courbes rationnelles il faut multiplier les poles par
// leurs poids respectifs
- if (withderiv) {
- tabAppV2d(NbPoles2d+j).SetCoord(tabDW(j),0.);
- newDv.SetLinearForm(tabDW(j),tabAppP(j).XYZ(),tabW(j),tabAppV(j).XYZ());
+ if (withderiv)
+ {
+ tabAppV2d(NbPoles2d + j).SetCoord(tabDW(j), 0.);
+ newDv.SetLinearForm(tabDW(j), tabAppP(j).XYZ(), tabW(j), tabAppV(j).XYZ());
tabAppV(j).SetXYZ(newDv);
}
tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
- tabAppP2d(NbPoles2d+j).SetCoord(tabW(j),0.);
+ tabAppP2d(NbPoles2d + j).SetCoord(tabW(j), 0.);
}
-
- if (withderiv) {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d,tabAppV,tabAppV2d);
+
+ if (withderiv)
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d, tabAppV, tabAppV2d);
Cfirst = AppParCurves_TangencyPoint;
}
- else {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d);
+ else
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d);
Cfirst = AppParCurves_PassPoint;
}
- multL.SetValue(1,multP);
+ multL.SetValue(1, multP);
- for (i=2; i<=NbPoint-1; i++) {
- if (SpApprox) {
- F.Section(Lin->Point(i),tabAppP,tabP2d,tabW);
- for (j=1; j<=NbPoles2d; j++) {
- tabAppP2d(j) = tabP2d(j);
+ for (i = 2; i <= NbPoint - 1; i++)
+ {
+ if (SpApprox)
+ {
+ F.Section(Lin->Point(i), tabAppP, tabP2d, tabW);
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ tabAppP2d(j) = tabP2d(j);
}
- for (j=1; j<=NbUPoles; j++) {
- // pour les courbes rationnelles il faut multiplier les poles par
- // leurs poids respectifs
- tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
- tabAppP2d(NbPoles2d+j).SetCoord(tabW(j),0.);
+ for (j = 1; j <= NbUPoles; j++)
+ {
+ // pour les courbes rationnelles il faut multiplier les poles par
+ // leurs poids respectifs
+ tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
+ tabAppP2d(NbPoles2d + j).SetCoord(tabW(j), 0.);
}
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d);
- multL.SetValue(i,multP);
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d);
+ multL.SetValue(i, multP);
}
-// ***********************
- else {
- withderiv = F.Section(Lin->Point(i),tabAppP,tabAppV,tabP2d,tabV2d,
- tabW,tabDW);
- if(AppBlend_GetContextApproxWithNoTgt()) withderiv = Standard_False;
-
- for (j=1; j<=NbPoles2d; j++) {
- tabAppP2d(j) = tabP2d(j);
- if (withderiv) {
- tabAppV2d(j) = tabV2d(j);
- }
- }
- for (j=1; j<=NbUPoles; j++) {
- // pour les courbes rationnelles il faut multiplier les poles par
- // leurs poids respectifs
- if (withderiv) {
- tabAppV2d(NbPoles2d+j).SetCoord(tabDW(j),0.);
- newDv.SetLinearForm(tabDW(j),tabAppP(j).XYZ(),tabW(j),tabAppV(j).XYZ());
- tabAppV(j).SetXYZ(newDv);
- }
- tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
- tabAppP2d(NbPoles2d+j).SetCoord(tabW(j),0.);
- }
- if (withderiv) {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d,tabAppV,tabAppV2d);
- }
- else {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d);
- }
- multL.SetValue(i,multP);
+ // ***********************
+ else
+ {
+ withderiv = F.Section(Lin->Point(i), tabAppP, tabAppV, tabP2d, tabV2d, tabW, tabDW);
+ if (AppBlend_GetContextApproxWithNoTgt())
+ withderiv = Standard_False;
+
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ tabAppP2d(j) = tabP2d(j);
+ if (withderiv)
+ {
+ tabAppV2d(j) = tabV2d(j);
+ }
+ }
+ for (j = 1; j <= NbUPoles; j++)
+ {
+ // pour les courbes rationnelles il faut multiplier les poles par
+ // leurs poids respectifs
+ if (withderiv)
+ {
+ tabAppV2d(NbPoles2d + j).SetCoord(tabDW(j), 0.);
+ newDv.SetLinearForm(tabDW(j), tabAppP(j).XYZ(), tabW(j), tabAppV(j).XYZ());
+ tabAppV(j).SetXYZ(newDv);
+ }
+ tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
+ tabAppP2d(NbPoles2d + j).SetCoord(tabW(j), 0.);
+ }
+ if (withderiv)
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d, tabAppV, tabAppV2d);
+ }
+ else
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d);
+ }
+ multL.SetValue(i, multP);
}
-// ******************************
+ // ******************************
}
-
- withderiv = F.Section(Lin->Point(NbPoint),tabAppP,tabAppV,tabP2d,tabV2d,
- tabW,tabDW);
- if(AppBlend_GetContextApproxWithNoTgt()) withderiv = Standard_False;
- for (j=1; j<=NbPoles2d; j++) {
+ withderiv = F.Section(Lin->Point(NbPoint), tabAppP, tabAppV, tabP2d, tabV2d, tabW, tabDW);
+ if (AppBlend_GetContextApproxWithNoTgt())
+ withderiv = Standard_False;
+
+ for (j = 1; j <= NbPoles2d; j++)
+ {
tabAppP2d(j) = tabP2d(j);
- if (withderiv) {
+ if (withderiv)
+ {
tabAppV2d(j) = tabV2d(j);
}
}
- for (j=1; j<=NbUPoles; j++) {
+ for (j = 1; j <= NbUPoles; j++)
+ {
// pour les courbes rationnelles il faut multiplier les poles par
// leurs poids respectifs
- if (withderiv) {
- tabAppV2d(NbPoles2d+j).SetCoord(tabDW(j),0.);
- newDv.SetLinearForm(tabDW(j),tabAppP(j).XYZ(),tabW(j),tabAppV(j).XYZ());
+ if (withderiv)
+ {
+ tabAppV2d(NbPoles2d + j).SetCoord(tabDW(j), 0.);
+ newDv.SetLinearForm(tabDW(j), tabAppP(j).XYZ(), tabW(j), tabAppV(j).XYZ());
tabAppV(j).SetXYZ(newDv);
}
tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
- tabAppP2d(NbPoles2d+j).SetCoord(tabW(j),0.);
+ tabAppP2d(NbPoles2d + j).SetCoord(tabW(j), 0.);
}
- if (withderiv) {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d,tabAppV,tabAppV2d);
+ if (withderiv)
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d, tabAppV, tabAppV2d);
Clast = AppParCurves_TangencyPoint;
}
- else {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d);
+ else
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d);
Clast = AppParCurves_PassPoint;
}
- multL.SetValue(NbPoint,multP);
+ multL.SetValue(NbPoint, multP);
- //IFV 04.06.07 occ13904
- if(NbPoint == 2) {
+ // IFV 04.06.07 occ13904
+ if (NbPoint == 2)
+ {
dmin = 1;
- if(Cfirst == AppParCurves_PassPoint && Clast == AppParCurves_PassPoint) {
+ if (Cfirst == AppParCurves_PassPoint && Clast == AppParCurves_PassPoint)
+ {
dmax = 1;
}
}
-
- if (!SpApprox) {
- AppDef_Compute theapprox (dmin,dmax,tol3d,tol2d,nbit, Standard_True, paramtype);
- if (knownp) {
- math_Vector theParams(1,NbPoint);
+ if (!SpApprox)
+ {
+ AppDef_Compute theapprox(dmin, dmax, tol3d, tol2d, nbit, Standard_True, paramtype);
+ if (knownp)
+ {
+ math_Vector theParams(1, NbPoint);
// On recale les parametres entre 0 et 1.
- theParams(1) = 0.;
+ theParams(1) = 0.;
theParams(NbPoint) = 1.;
- Standard_Real Uf = F.Parameter(Lin->Point(1));
- Standard_Real Ul = F.Parameter(Lin->Point(NbPoint))-Uf;
- for (i=2; i<NbPoint; i++) {
- theParams(i) = (F.Parameter(Lin->Point(i))-Uf)/Ul;
+ Standard_Real Uf = F.Parameter(Lin->Point(1));
+ Standard_Real Ul = F.Parameter(Lin->Point(NbPoint)) - Uf;
+ for (i = 2; i < NbPoint; i++)
+ {
+ theParams(i) = (F.Parameter(Lin->Point(i)) - Uf) / Ul;
}
- AppDef_Compute theAppDef(theParams,dmin,dmax,tol3d,tol2d,nbit,
- Standard_True, Standard_True);
+ AppDef_Compute
+ theAppDef(theParams, dmin, dmax, tol3d, tol2d, nbit, Standard_True, Standard_True);
theapprox = theAppDef;
}
- theapprox.SetConstraints(Cfirst,Clast);
+ theapprox.SetConstraints(Cfirst, Clast);
theapprox.Perform(multL);
Standard_Real TheTol3d, TheTol2d;
mytol3d = mytol2d = 0.0;
- for (Standard_Integer Index=1; Index<=theapprox.NbMultiCurves(); Index++) {
+ for (Standard_Integer Index = 1; Index <= theapprox.NbMultiCurves(); Index++)
+ {
theapprox.Error(Index, TheTol3d, TheTol2d);
mytol3d = Max(TheTol3d, mytol3d);
mytol2d = Max(TheTol2d, mytol2d);
}
#ifdef OCCT_DEBUG
- std::cout << " Tolerances obtenues --> 3d : "<< mytol3d << std::endl;
- std::cout << " --> 2d : "<< mytol2d << std::endl;
+ std::cout << " Tolerances obtenues --> 3d : " << mytol3d << std::endl;
+ std::cout << " --> 2d : " << mytol2d << std::endl;
#endif
multC = theapprox.SplineValue();
- }
+ }
- else {
- if(!UseSmoothing) {
+ else
+ {
+ if (!UseSmoothing)
+ {
Standard_Boolean UseSquares = Standard_False;
- if(nbit == 0) UseSquares = Standard_True;
- AppDef_BSplineCompute theapprox (dmin,dmax,tol3d,tol2d,nbit,Standard_True, paramtype,
- UseSquares);
- if(continuity == GeomAbs_C0) {
- theapprox.SetContinuity(0);
+ if (nbit == 0)
+ UseSquares = Standard_True;
+ AppDef_BSplineCompute
+ theapprox(dmin, dmax, tol3d, tol2d, nbit, Standard_True, paramtype, UseSquares);
+ if (continuity == GeomAbs_C0)
+ {
+ theapprox.SetContinuity(0);
}
- if(continuity == GeomAbs_C1) {
- theapprox.SetContinuity(1);
+ if (continuity == GeomAbs_C1)
+ {
+ theapprox.SetContinuity(1);
}
- else if(continuity == GeomAbs_C2) {
- theapprox.SetContinuity(2);
+ else if (continuity == GeomAbs_C2)
+ {
+ theapprox.SetContinuity(2);
}
- else {
- theapprox.SetContinuity(3);
+ else
+ {
+ theapprox.SetContinuity(3);
}
- theapprox.SetConstraints(Cfirst,Clast);
+ theapprox.SetConstraints(Cfirst, Clast);
- if (knownp) {
- math_Vector theParams(1,NbPoint);
- // On recale les parametres entre 0 et 1.
- theParams(1) = 0.;
- theParams(NbPoint) = 1.;
- Standard_Real Uf = F.Parameter(Lin->Point(1));
- Standard_Real Ul = F.Parameter(Lin->Point(NbPoint))-Uf;
- for (i=2; i<NbPoint; i++) {
- theParams(i) = (F.Parameter(Lin->Point(i))-Uf)/Ul;
- }
-
- theapprox.Init(dmin,dmax,tol3d,tol2d,nbit,Standard_True,
- Approx_IsoParametric,Standard_True);
- theapprox.SetParameters(theParams);
+ if (knownp)
+ {
+ math_Vector theParams(1, NbPoint);
+ // On recale les parametres entre 0 et 1.
+ theParams(1) = 0.;
+ theParams(NbPoint) = 1.;
+ Standard_Real Uf = F.Parameter(Lin->Point(1));
+ Standard_Real Ul = F.Parameter(Lin->Point(NbPoint)) - Uf;
+ for (i = 2; i < NbPoint; i++)
+ {
+ theParams(i) = (F.Parameter(Lin->Point(i)) - Uf) / Ul;
+ }
+
+ theapprox
+ .Init(dmin, dmax, tol3d, tol2d, nbit, Standard_True, Approx_IsoParametric, Standard_True);
+ theapprox.SetParameters(theParams);
}
theapprox.Perform(multL);
- theapprox.Error(mytol3d,mytol2d);
+ theapprox.Error(mytol3d, mytol2d);
#ifdef OCCT_DEBUG
- std::cout << " Tolerances obtenues --> 3d : "<< mytol3d << std::endl;
- std::cout << " --> 2d : "<< mytol2d << std::endl;
-#endif
+ std::cout << " Tolerances obtenues --> 3d : " << mytol3d << std::endl;
+ std::cout << " --> 2d : " << mytol2d << std::endl;
+#endif
tol3dreached = mytol3d;
tol2dreached = mytol2d;
- multC = theapprox.Value();
+ multC = theapprox.Value();
}
- else {
- //Variational algo
- Handle(AppParCurves_HArray1OfConstraintCouple) TABofCC =
- new AppParCurves_HArray1OfConstraintCouple(1, NbPoint);
- AppParCurves_Constraint Constraint=AppParCurves_NoConstraint;
+ else
+ {
+ // Variational algo
+ Handle(AppParCurves_HArray1OfConstraintCouple) TABofCC =
+ new AppParCurves_HArray1OfConstraintCouple(1, NbPoint);
+ AppParCurves_Constraint Constraint = AppParCurves_NoConstraint;
- for(i = 1; i <= NbPoint; ++i) {
- AppParCurves_ConstraintCouple ACC(i,Constraint);
- TABofCC->SetValue(i,ACC);
+ for (i = 1; i <= NbPoint; ++i)
+ {
+ AppParCurves_ConstraintCouple ACC(i, Constraint);
+ TABofCC->SetValue(i, ACC);
}
-
+
TABofCC->ChangeValue(1).SetConstraint(Cfirst);
TABofCC->ChangeValue(NbPoint).SetConstraint(Clast);
AppDef_Variational Variation(multL, 1, NbPoint, TABofCC);
-//===================================
+ //===================================
Standard_Integer theMaxSegments = 1000;
- Standard_Boolean theWithMinMax = Standard_False;
+ Standard_Boolean theWithMinMax = Standard_False;
Standard_Boolean theWithCutting = Standard_True;
-//===================================
+ //===================================
Variation.SetMaxDegree(dmax);
Variation.SetContinuity(continuity);
Variation.SetCriteriumWeight(critweights[0], critweights[1], critweights[2]);
- if(!Variation.IsCreated()) {
- return;
+ if (!Variation.IsCreated())
+ {
+ return;
}
-
- if(Variation.IsOverConstrained()) {
- return;
+
+ if (Variation.IsOverConstrained())
+ {
+ return;
}
- try {
- Variation.Approximate();
+ try
+ {
+ Variation.Approximate();
}
- catch (Standard_Failure const&) {
- return;
+ catch (Standard_Failure const&)
+ {
+ return;
}
- if(!Variation.IsDone()) {
- return;
+ if (!Variation.IsDone())
+ {
+ return;
}
mytol3d = Variation.MaxError();
mytol2d = 0.;
#ifdef OCCT_DEBUG
- std::cout << " Tolerances obtenues --> 3d : "<< mytol3d << std::endl;
- std::cout << " --> 2d : "<< mytol2d << std::endl;
-#endif
+ std::cout << " Tolerances obtenues --> 3d : " << mytol3d << std::endl;
+ std::cout << " --> 2d : " << mytol2d << std::endl;
+#endif
tol3dreached = mytol3d;
tol2dreached = mytol2d;
- multC = Variation.Value();
+ multC = Variation.Value();
}
}
- vdeg = multC.Degree();
+ vdeg = multC.Degree();
NbVPoles = multC.NbPoles();
-
- tabPoles = new TColgp_HArray2OfPnt (1,NbUPoles,1,NbVPoles);
- tabWeights = new TColStd_HArray2OfReal (1,NbUPoles,1,NbVPoles);
- tabVKnots = new TColStd_HArray1OfReal (multC.Knots().Lower(),
- multC.Knots().Upper());
+
+ tabPoles = new TColgp_HArray2OfPnt(1, NbUPoles, 1, NbVPoles);
+ tabWeights = new TColStd_HArray2OfReal(1, NbUPoles, 1, NbVPoles);
+ tabVKnots = new TColStd_HArray1OfReal(multC.Knots().Lower(), multC.Knots().Upper());
tabVKnots->ChangeArray1() = multC.Knots();
- if (knownp && !UseSmoothing) {
+ if (knownp && !UseSmoothing)
+ {
BSplCLib::Reparametrize(F.Parameter(Lin->Point(1)),
- F.Parameter(Lin->Point(NbPoint)),
- tabVKnots->ChangeArray1());
+ F.Parameter(Lin->Point(NbPoint)),
+ tabVKnots->ChangeArray1());
}
- tabVMults = new TColStd_HArray1OfInteger (multC.Multiplicities().Lower(),
- multC.Multiplicities().Upper());
+ tabVMults =
+ new TColStd_HArray1OfInteger(multC.Multiplicities().Lower(), multC.Multiplicities().Upper());
tabVMults->ChangeArray1() = multC.Multiplicities();
-
- TColgp_Array1OfPnt newtabP(1,NbVPoles);
- Handle(TColgp_HArray1OfPnt2d) newtabP2d =
- new TColgp_HArray1OfPnt2d(1,NbVPoles);
- for (j=1; j <=NbUPoles; j++) {
- multC.Curve(j,newtabP);
- multC.Curve(j+NbUPoles+NbPoles2d,newtabP2d->ChangeArray1());
- for (k=1; k<=NbVPoles; k++) {
+ TColgp_Array1OfPnt newtabP(1, NbVPoles);
+ Handle(TColgp_HArray1OfPnt2d) newtabP2d = new TColgp_HArray1OfPnt2d(1, NbVPoles);
+ for (j = 1; j <= NbUPoles; j++)
+ {
+ multC.Curve(j, newtabP);
+ multC.Curve(j + NbUPoles + NbPoles2d, newtabP2d->ChangeArray1());
+ for (k = 1; k <= NbVPoles; k++)
+ {
// pour les courbes rationnelles il faut maintenant diviser
// les poles par leurs poids respectifs
- tabPoles->ChangeValue(j,k).SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X());
+ tabPoles->ChangeValue(j, k).SetXYZ(newtabP(k).XYZ() / newtabP2d->Value(k).X());
Standard_Real aWeight = newtabP2d->Value(k).X();
- if (aWeight < gp::Resolution()) {
+ if (aWeight < gp::Resolution())
+ {
done = Standard_False;
return;
}
- tabWeights->SetValue(j,k,aWeight);
+ tabWeights->SetValue(j, k, aWeight);
}
}
- for (j=1; j<=NbPoles2d; j++) {
- newtabP2d = new TColgp_HArray1OfPnt2d(1,NbVPoles);
- multC.Curve(NbUPoles+j,newtabP2d->ChangeArray1());
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ newtabP2d = new TColgp_HArray1OfPnt2d(1, NbVPoles);
+ multC.Curve(NbUPoles + j, newtabP2d->ChangeArray1());
seqPoles2d.Append(newtabP2d);
}
-
+
done = Standard_True;
}
-
//=================================================================================================
-
void AppBlend_AppSurf::Perform(const Handle(TheLine)& Lin,
- TheSectionGenerator& F,
- const Standard_Integer NbMaxP)
+ TheSectionGenerator& F,
+ const Standard_Integer NbMaxP)
{
done = Standard_False;
- if (Lin.IsNull()) {return;}
- Standard_Integer i,j,k;
- Standard_Integer NbUPoles,NbUKnots,NbPoles2d,NbVPoles;
- Standard_Boolean withderiv;
- AppParCurves_Constraint Cfirst=AppParCurves_NoConstraint,Clast=AppParCurves_NoConstraint;
+ if (Lin.IsNull())
+ {
+ return;
+ }
+ Standard_Integer i, j, k;
+ Standard_Integer NbUPoles, NbUKnots, NbPoles2d, NbVPoles;
+ Standard_Boolean withderiv;
+ AppParCurves_Constraint Cfirst = AppParCurves_NoConstraint, Clast = AppParCurves_NoConstraint;
Standard_Real mytol3d = 0.0, mytol2d = 0.0;
- gp_XYZ newDv;
+ gp_XYZ newDv;
seqPoles2d.Clear();
Standard_Integer NbPointTot = Lin->NbPoints();
- F.GetShape(NbUPoles,NbUKnots,udeg,NbPoles2d);
+ F.GetShape(NbUPoles, NbUKnots, udeg, NbPoles2d);
- tabUKnots = new TColStd_HArray1OfReal (1,NbUKnots);
- tabUMults = new TColStd_HArray1OfInteger (1,NbUKnots);
+ tabUKnots = new TColStd_HArray1OfReal(1, NbUKnots);
+ tabUMults = new TColStd_HArray1OfInteger(1, NbUKnots);
F.Knots(tabUKnots->ChangeArray1());
F.Mults(tabUMults->ChangeArray1());
- TColgp_Array1OfPnt tabAppP(1,NbUPoles);
- TColgp_Array1OfVec tabAppV(1,NbUPoles);
- Standard_Real X,Y,Z,DX,DY,DZ;
+ TColgp_Array1OfPnt tabAppP(1, NbUPoles);
+ TColgp_Array1OfVec tabAppV(1, NbUPoles);
+ Standard_Real X, Y, Z, DX, DY, DZ;
X = Y = Z = RealLast();
DX = DY = DZ = RealFirst();
- TColgp_Array1OfPnt2d tabP2d(1,Max(1,NbPoles2d));
- TColgp_Array1OfVec2d tabV2d(1,Max(1,NbPoles2d));
- TColStd_Array1OfReal X2d(1,Max(1,NbPoles2d));X2d.Init(RealLast());
- TColStd_Array1OfReal Y2d(1,Max(1,NbPoles2d));Y2d.Init(RealLast());
- TColStd_Array1OfReal DX2d(1,Max(1,NbPoles2d));DX2d.Init(RealFirst());
- TColStd_Array1OfReal DY2d(1,Max(1,NbPoles2d));DY2d.Init(RealFirst());
+ TColgp_Array1OfPnt2d tabP2d(1, Max(1, NbPoles2d));
+ TColgp_Array1OfVec2d tabV2d(1, Max(1, NbPoles2d));
+ TColStd_Array1OfReal X2d(1, Max(1, NbPoles2d));
+ X2d.Init(RealLast());
+ TColStd_Array1OfReal Y2d(1, Max(1, NbPoles2d));
+ Y2d.Init(RealLast());
+ TColStd_Array1OfReal DX2d(1, Max(1, NbPoles2d));
+ DX2d.Init(RealFirst());
+ TColStd_Array1OfReal DY2d(1, Max(1, NbPoles2d));
+ DY2d.Init(RealFirst());
- TColStd_Array1OfReal tabW(1,NbUPoles),tabDW(1,NbUPoles);
+ TColStd_Array1OfReal tabW(1, NbUPoles), tabDW(1, NbUPoles);
- TColgp_Array1OfPnt2d tabAppP2d(1,NbPoles2d+NbUPoles); // points2d + poids
- TColgp_Array1OfVec2d tabAppV2d(1,NbPoles2d+NbUPoles);
+ TColgp_Array1OfPnt2d tabAppP2d(1, NbPoles2d + NbUPoles); // points2d + poids
+ TColgp_Array1OfVec2d tabAppV2d(1, NbPoles2d + NbUPoles);
// On calcule les boites de chaque ligne (box for all lines)
- for(i = 1; i <= NbPointTot; i++){
- F.Section(Lin->Point(i),tabAppP,tabAppV,tabP2d,tabV2d,tabW,tabDW);
- Standard_Real x,y,z;
+ for (i = 1; i <= NbPointTot; i++)
+ {
+ F.Section(Lin->Point(i), tabAppP, tabAppV, tabP2d, tabV2d, tabW, tabDW);
+ Standard_Real x, y, z;
for (j = 1; j <= NbUPoles; j++)
{
- tabAppP(j).Coord(x,y,z);
- if(x < X) { X = x; }
- if(x > DX) { DX = x; }
- if(y < Y) { Y = y; }
- if(y > DY) { DY = y; }
- if(z < Z) { Z = z; }
- if(z > DZ) { DZ = z; }
+ tabAppP(j).Coord(x, y, z);
+ if (x < X)
+ {
+ X = x;
+ }
+ if (x > DX)
+ {
+ DX = x;
+ }
+ if (y < Y)
+ {
+ Y = y;
+ }
+ if (y > DY)
+ {
+ DY = y;
+ }
+ if (z < Z)
+ {
+ Z = z;
+ }
+ if (z > DZ)
+ {
+ DZ = z;
+ }
}
for (j = 1; j <= NbPoles2d; j++)
{
- tabP2d(j).Coord(x,y);
- if(x < X2d (j)) { X2d (j) = x; }
- if(x > DX2d(j)) { DX2d(j) = x; }
- if(y < Y2d (j)) { Y2d (j) = y; }
- if(y > DY2d(j)) { DY2d(j) = y; }
+ tabP2d(j).Coord(x, y);
+ if (x < X2d(j))
+ {
+ X2d(j) = x;
+ }
+ if (x > DX2d(j))
+ {
+ DX2d(j) = x;
+ }
+ if (y < Y2d(j))
+ {
+ Y2d(j) = y;
+ }
+ if (y > DY2d(j))
+ {
+ DY2d(j) = y;
+ }
}
}
// On calcule pour chaque ligne la transformation vers 0 1.
- Standard_Real seuil = 1000.*tol3d;
- Standard_Real seuil2d = 1000.*tol2d;
- if((DX - X) < seuil ){ DX = 1.; X = 0.; }
- else{ DX = 1./(DX - X); X *= -DX; }
- if((DY - Y) < seuil){ DY = 1.; Y = 0.; }
- else{ DY = 1./(DY - Y); Y *= -DY; }
- if((DZ - Z) < seuil){ DZ = 1.; Z = 0.; }
- else{ DZ = 1./(DZ - Z); Z *= -DZ; }
- for(j = 1; j <= NbPoles2d; j++){
- if((DX2d(j) - X2d(j)) < seuil2d){ DX2d(j) = 1.; X2d(j) = 0.; }
- else{ DX2d(j) = 1./(DX2d(j) - X2d(j)); X2d(j) *= -DX2d(j); }
- if((DY2d(j) - Y2d(j)) < seuil2d){ DY2d(j) = 1.; Y2d(j) = 0.; }
- else{ DY2d(j) = 1./(DY2d(j) - Y2d(j)); Y2d(j) *= -DY2d(j); }
- }
- if(!scal){
- DX = 1.; X = 0.;
- DY = 1.; Y = 0.;
- DZ = 1.; Z = 0.;
- for(j = 1; j <= NbPoles2d; j++){
- DX2d(j) = 1.; X2d(j) = 0.;
- DY2d(j) = 1.; Y2d(j) = 0.;
+ Standard_Real seuil = 1000. * tol3d;
+ Standard_Real seuil2d = 1000. * tol2d;
+ if ((DX - X) < seuil)
+ {
+ DX = 1.;
+ X = 0.;
+ }
+ else
+ {
+ DX = 1. / (DX - X);
+ X *= -DX;
+ }
+ if ((DY - Y) < seuil)
+ {
+ DY = 1.;
+ Y = 0.;
+ }
+ else
+ {
+ DY = 1. / (DY - Y);
+ Y *= -DY;
+ }
+ if ((DZ - Z) < seuil)
+ {
+ DZ = 1.;
+ Z = 0.;
+ }
+ else
+ {
+ DZ = 1. / (DZ - Z);
+ Z *= -DZ;
+ }
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ if ((DX2d(j) - X2d(j)) < seuil2d)
+ {
+ DX2d(j) = 1.;
+ X2d(j) = 0.;
+ }
+ else
+ {
+ DX2d(j) = 1. / (DX2d(j) - X2d(j));
+ X2d(j) *= -DX2d(j);
+ }
+ if ((DY2d(j) - Y2d(j)) < seuil2d)
+ {
+ DY2d(j) = 1.;
+ Y2d(j) = 0.;
+ }
+ else
+ {
+ DY2d(j) = 1. / (DY2d(j) - Y2d(j));
+ Y2d(j) *= -DY2d(j);
+ }
+ }
+ if (!scal)
+ {
+ DX = 1.;
+ X = 0.;
+ DY = 1.;
+ Y = 0.;
+ DZ = 1.;
+ Z = 0.;
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ DX2d(j) = 1.;
+ X2d(j) = 0.;
+ DY2d(j) = 1.;
+ Y2d(j) = 0.;
}
}
-// modified by eap Thu Jan 3 14:45:22 2002 ___BEGIN___
+ // modified by eap Thu Jan 3 14:45:22 2002 ___BEGIN___
// Keep "inter-troncons" parameters, not only first and last
-// Standard_Real Ufirst=0,Ulast=0;
+ // Standard_Real Ufirst=0,Ulast=0;
TColStd_SequenceOfReal aParamSeq;
- if (knownp) {
-// Ufirst = F.Parameter(Lin->Point(1));
-// Ulast = F.Parameter(Lin->Point(NbPointTot));
- aParamSeq.Append( F.Parameter (Lin->Point(1)) );
- }
-// modified by EAP Thu Jan 3 14:45:41 2002 ___END___
+ if (knownp)
+ {
+ // Ufirst = F.Parameter(Lin->Point(1));
+ // Ulast = F.Parameter(Lin->Point(NbPointTot));
+ aParamSeq.Append(F.Parameter(Lin->Point(1)));
+ }
+ // modified by EAP Thu Jan 3 14:45:41 2002 ___END___
Approx_MCurvesToBSpCurve concat;
- //On calcule le nombre de troncons.
- Standard_Integer nbtronc = NbPointTot/NbMaxP;
- Standard_Integer reste = NbPointTot - (nbtronc * NbMaxP);
+ // On calcule le nombre de troncons.
+ Standard_Integer nbtronc = NbPointTot / NbMaxP;
+ Standard_Integer reste = NbPointTot - (nbtronc * NbMaxP);
// On regarde si il faut prendre un troncon de plus.
Standard_Integer nmax = NbMaxP;
- if(nbtronc > 0 && reste > 0){
- nmax = NbPointTot/(nbtronc + 1);
- if(nmax > (2*NbMaxP)/3) {
+ if (nbtronc > 0 && reste > 0)
+ {
+ nmax = NbPointTot / (nbtronc + 1);
+ if (nmax > (2 * NbMaxP) / 3)
+ {
nbtronc++;
reste = NbPointTot - (nbtronc * nmax);
}
- else nmax = NbMaxP;
+ else
+ nmax = NbMaxP;
}
- else if(nbtronc == 0){
+ else if (nbtronc == 0)
+ {
nbtronc = 1;
- nmax = reste;
- reste = 0;
+ nmax = reste;
+ reste = 0;
}
// Approximate each "troncon" with nb of Bezier's using AppDef_Compute
- // and concat them into BSpline with Approx_MCurvesToBSpCurve
+ // and concat them into BSpline with Approx_MCurvesToBSpCurve
- TColStd_Array1OfInteger troncsize(1,nbtronc);
- TColStd_Array1OfInteger troncstart(1,nbtronc);
+ TColStd_Array1OfInteger troncsize(1, nbtronc);
+ TColStd_Array1OfInteger troncstart(1, nbtronc);
- Standard_Integer rab = reste/nbtronc + 1;
+ Standard_Integer rab = reste / nbtronc + 1;
Standard_Integer start = 1;
- Standard_Integer itronc ;
- for( itronc = 1; itronc <= nbtronc; itronc++){
- troncstart(itronc) = start;
- Standard_Integer rabrab = Min(rab,reste);
- if(reste > 0){ reste -= rabrab; }
+ Standard_Integer itronc;
+ for (itronc = 1; itronc <= nbtronc; itronc++)
+ {
+ troncstart(itronc) = start;
+ Standard_Integer rabrab = Min(rab, reste);
+ if (reste > 0)
+ {
+ reste -= rabrab;
+ }
troncsize(itronc) = nmax + rabrab + 1;
start += (nmax + rabrab);
}
troncsize(nbtronc) = troncsize(nbtronc) - 1;
- for(itronc = 1; itronc <= nbtronc; itronc++){
- Standard_Integer NbPoint = troncsize(itronc);
- Standard_Integer StPoint = troncstart(itronc);
+ for (itronc = 1; itronc <= nbtronc; itronc++)
+ {
+ Standard_Integer NbPoint = troncsize(itronc);
+ Standard_Integer StPoint = troncstart(itronc);
AppDef_MultiPointConstraint multP;
- AppDef_MultiLine multL(NbPoint);
-
- for (i=1; i<=NbPoint; i++) {
+ AppDef_MultiLine multL(NbPoint);
+
+ for (i = 1; i <= NbPoint; i++)
+ {
Standard_Integer iLin = StPoint + i - 1;
- Standard_Real x,y,z;
- withderiv = F.Section(Lin->Point(iLin),tabAppP,tabAppV,tabP2d,tabV2d,
- tabW,tabDW);
- if(AppBlend_GetContextApproxWithNoTgt()) withderiv = Standard_False;
-
- for (j=1; j<=NbPoles2d; j++) {
- tabP2d(j).Coord(x,y);
- tabAppP2d(j).SetCoord(DX2d(j)*x+X2d(j),DY2d(j)*y+Y2d(j));
- if (withderiv) {
- tabV2d(j).Coord(x,y);
- tabAppV2d(j).SetCoord(DX2d(j)*x,DY2d(j)*y);
- }
- }
- for (j=1; j<=NbUPoles; j++) {
- // pour les courbes rationnelles il faut multiplier les poles par
- // leurs poids respectifs
- if (withderiv) {
- tabAppV2d(NbPoles2d+j).SetCoord(tabDW(j),0.);
- newDv.SetLinearForm(tabDW(j),tabAppP(j).XYZ(),tabW(j),tabAppV(j).XYZ());
- tabAppV(j).SetCoord(DX*newDv.X(),DY*newDv.Y(),DZ*newDv.Z());
- }
- tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
- tabAppP2d(NbPoles2d+j).SetCoord(tabW(j),0.);
- tabAppP(j).Coord(x,y,z);
- tabAppP(j).SetCoord(DX*x+X,DY*y+Y,DZ*z+Z);
- }
- if (withderiv) {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d,tabAppV,tabAppV2d);
- if(i == 1) Cfirst = AppParCurves_TangencyPoint;
- else if(i == NbPoint) Clast = AppParCurves_TangencyPoint;
- }
- else {
- multP = AppDef_MultiPointConstraint(tabAppP,tabAppP2d);
- if(i == 1) Cfirst = AppParCurves_PassPoint;
- else if(i == NbPoint) Clast = AppParCurves_PassPoint;
- }
- multL.SetValue(i,multP);
+ Standard_Real x, y, z;
+ withderiv = F.Section(Lin->Point(iLin), tabAppP, tabAppV, tabP2d, tabV2d, tabW, tabDW);
+ if (AppBlend_GetContextApproxWithNoTgt())
+ withderiv = Standard_False;
+
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ tabP2d(j).Coord(x, y);
+ tabAppP2d(j).SetCoord(DX2d(j) * x + X2d(j), DY2d(j) * y + Y2d(j));
+ if (withderiv)
+ {
+ tabV2d(j).Coord(x, y);
+ tabAppV2d(j).SetCoord(DX2d(j) * x, DY2d(j) * y);
+ }
+ }
+ for (j = 1; j <= NbUPoles; j++)
+ {
+ // pour les courbes rationnelles il faut multiplier les poles par
+ // leurs poids respectifs
+ if (withderiv)
+ {
+ tabAppV2d(NbPoles2d + j).SetCoord(tabDW(j), 0.);
+ newDv.SetLinearForm(tabDW(j), tabAppP(j).XYZ(), tabW(j), tabAppV(j).XYZ());
+ tabAppV(j).SetCoord(DX * newDv.X(), DY * newDv.Y(), DZ * newDv.Z());
+ }
+ tabAppP(j).SetXYZ(tabAppP(j).XYZ() * tabW(j));
+ tabAppP2d(NbPoles2d + j).SetCoord(tabW(j), 0.);
+ tabAppP(j).Coord(x, y, z);
+ tabAppP(j).SetCoord(DX * x + X, DY * y + Y, DZ * z + Z);
+ }
+ if (withderiv)
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d, tabAppV, tabAppV2d);
+ if (i == 1)
+ Cfirst = AppParCurves_TangencyPoint;
+ else if (i == NbPoint)
+ Clast = AppParCurves_TangencyPoint;
+ }
+ else
+ {
+ multP = AppDef_MultiPointConstraint(tabAppP, tabAppP2d);
+ if (i == 1)
+ Cfirst = AppParCurves_PassPoint;
+ else if (i == NbPoint)
+ Clast = AppParCurves_PassPoint;
+ }
+ multL.SetValue(i, multP);
}
-
- //IFV 04.06.07 occ13904
- if(NbPoint == 2) {
+ // IFV 04.06.07 occ13904
+ if (NbPoint == 2)
+ {
dmin = 1;
- if(Cfirst == AppParCurves_PassPoint && Clast == AppParCurves_PassPoint) {
- dmax = 1;
+ if (Cfirst == AppParCurves_PassPoint && Clast == AppParCurves_PassPoint)
+ {
+ dmax = 1;
}
}
-// modified by EAP Thu Jan 3 15:44:13 2002 ___BEGIN___
- Standard_Real Ufloc=0., Ulloc=0.;
- AppDef_Compute theapprox (dmin,dmax,tol3d,tol2d,nbit);
- if (knownp) {
- math_Vector theParams(1,NbPoint);
+ // modified by EAP Thu Jan 3 15:44:13 2002 ___BEGIN___
+ Standard_Real Ufloc = 0., Ulloc = 0.;
+ AppDef_Compute theapprox(dmin, dmax, tol3d, tol2d, nbit);
+ if (knownp)
+ {
+ math_Vector theParams(1, NbPoint);
// On recale les parametres entre 0 et 1.
/*Standard_Real*/ Ufloc = F.Parameter(Lin->Point(StPoint));
- /*Standard_Real*/ Ulloc = F.Parameter(Lin->Point(StPoint+NbPoint-1));
-// modified by EAP Thu Jan 3 15:45:17 2002 ___END___
- for (i=1; i <= NbPoint; i++) {
- Standard_Integer iLin = StPoint + i - 1;
- theParams(i) = (F.Parameter(Lin->Point(iLin))-Ufloc)/(Ulloc - Ufloc);
+ /*Standard_Real*/ Ulloc = F.Parameter(Lin->Point(StPoint + NbPoint - 1));
+ // modified by EAP Thu Jan 3 15:45:17 2002 ___END___
+ for (i = 1; i <= NbPoint; i++)
+ {
+ Standard_Integer iLin = StPoint + i - 1;
+ theParams(i) = (F.Parameter(Lin->Point(iLin)) - Ufloc) / (Ulloc - Ufloc);
}
- AppDef_Compute theAppDef1(theParams,dmin,dmax,tol3d,tol2d,nbit, Standard_True,Standard_True);
+ AppDef_Compute
+ theAppDef1(theParams, dmin, dmax, tol3d, tol2d, nbit, Standard_True, Standard_True);
theapprox = theAppDef1;
}
- theapprox.SetConstraints(Cfirst,Clast);
+ theapprox.SetConstraints(Cfirst, Clast);
theapprox.Perform(multL);
-// modified by EAP Thu Jan 3 16:00:43 2002 ___BEGIN___
+ // modified by EAP Thu Jan 3 16:00:43 2002 ___BEGIN___
// To know internal parameters if multicurve is approximated by several Bezier's
TColStd_SequenceOfReal aPoleDistSeq;
- Standard_Real aWholeDist=0;
-// modified by EAP Thu Jan 3 16:45:48 2002 ___END___
+ Standard_Real aWholeDist = 0;
+ // modified by EAP Thu Jan 3 16:45:48 2002 ___END___
Standard_Real TheTol3d, TheTol2d;
- for (Standard_Integer Index=1; Index<=theapprox.NbMultiCurves(); Index++) {
+ for (Standard_Integer Index = 1; Index <= theapprox.NbMultiCurves(); Index++)
+ {
AppParCurves_MultiCurve& mucu = theapprox.ChangeValue(Index);
theapprox.Error(Index, TheTol3d, TheTol2d);
- mytol3d = Max(TheTol3d/DX, mytol3d);
- mytol3d = Max(TheTol3d/DY, mytol3d);
- mytol3d = Max(TheTol3d/DZ, mytol3d);
- for(j = 1; j <= NbUPoles; j++){
- mucu.Transform(j,
- -X/DX,1./DX,
- -Y/DY,1./DY,
- -Z/DZ,1./DZ);
- }
- for(j = 1; j <= NbPoles2d; j++){
- mucu.Transform2d(j + NbUPoles,
- -X2d(j)/DX2d(j),1./DX2d(j),
- -Y2d(j)/DY2d(j),1./DY2d(j));
- mytol2d = Max(TheTol2d/DX2d(j), mytol2d);
- mytol2d = Max(TheTol2d/DY2d(j), mytol2d);
+ mytol3d = Max(TheTol3d / DX, mytol3d);
+ mytol3d = Max(TheTol3d / DY, mytol3d);
+ mytol3d = Max(TheTol3d / DZ, mytol3d);
+ for (j = 1; j <= NbUPoles; j++)
+ {
+ mucu.Transform(j, -X / DX, 1. / DX, -Y / DY, 1. / DY, -Z / DZ, 1. / DZ);
+ }
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ mucu.Transform2d(j + NbUPoles,
+ -X2d(j) / DX2d(j),
+ 1. / DX2d(j),
+ -Y2d(j) / DY2d(j),
+ 1. / DY2d(j));
+ mytol2d = Max(TheTol2d / DX2d(j), mytol2d);
+ mytol2d = Max(TheTol2d / DY2d(j), mytol2d);
}
concat.Append(mucu);
-
-// modified by EAP Thu Jan 3 15:45:23 2002 ___BEGIN___
- if (knownp && theapprox.NbMultiCurves() > 1)
+
+ // modified by EAP Thu Jan 3 15:45:23 2002 ___BEGIN___
+ if (knownp && theapprox.NbMultiCurves() > 1)
{
- gp_Pnt aFirstPole = mucu.Pole(Index, 1);
- gp_Pnt aLastPole = mucu.Pole(Index, mucu.NbPoles());
- aPoleDistSeq.Append (aFirstPole.Distance(aLastPole));
- aWholeDist += aPoleDistSeq.Last();
+ gp_Pnt aFirstPole = mucu.Pole(Index, 1);
+ gp_Pnt aLastPole = mucu.Pole(Index, mucu.NbPoles());
+ aPoleDistSeq.Append(aFirstPole.Distance(aLastPole));
+ aWholeDist += aPoleDistSeq.Last();
}
}
if (knownp)
{
Standard_Integer iDist;
- Standard_Real iU = Ufloc;
- for (iDist=1; iDist<aPoleDistSeq.Length(); iDist++)
+ Standard_Real iU = Ufloc;
+ for (iDist = 1; iDist < aPoleDistSeq.Length(); iDist++)
{
- iU += aPoleDistSeq(iDist) / aWholeDist * (Ulloc - Ufloc);
- //cout << "Internal: " << iU << endl;
- aParamSeq.Append(iU);
+ iU += aPoleDistSeq(iDist) / aWholeDist * (Ulloc - Ufloc);
+ // cout << "Internal: " << iU << endl;
+ aParamSeq.Append(iU);
}
aParamSeq.Append(Ulloc);
}
-// modified by EAP Thu Jan 3 15:45:27 2002 ___END___
+ // modified by EAP Thu Jan 3 15:45:27 2002 ___END___
}
#ifdef OCCT_DEBUG
- std::cout << " Tolerances obtenues --> 3d : "<< mytol3d << std::endl;
- std::cout << " --> 2d : "<< mytol2d << std::endl;
+ std::cout << " Tolerances obtenues --> 3d : " << mytol3d << std::endl;
+ std::cout << " --> 2d : " << mytol2d << std::endl;
#endif
tol3dreached = mytol3d;
tol2dreached = mytol2d;
concat.Perform();
const AppParCurves_MultiBSpCurve& multC = concat.Value();
- vdeg = multC.Degree();
- NbVPoles = multC.NbPoles();
-
- tabPoles = new TColgp_HArray2OfPnt (1,NbUPoles,1,NbVPoles);
- tabWeights = new TColStd_HArray2OfReal (1,NbUPoles,1,NbVPoles);
- tabVKnots = new TColStd_HArray1OfReal (multC.Knots().Lower(),
- multC.Knots().Upper());
+ vdeg = multC.Degree();
+ NbVPoles = multC.NbPoles();
+
+ tabPoles = new TColgp_HArray2OfPnt(1, NbUPoles, 1, NbVPoles);
+ tabWeights = new TColStd_HArray2OfReal(1, NbUPoles, 1, NbVPoles);
+ tabVKnots = new TColStd_HArray1OfReal(multC.Knots().Lower(), multC.Knots().Upper());
tabVKnots->ChangeArray1() = multC.Knots();
-
- if (knownp) {
-// modified by EAP Fri Jan 4 12:07:30 2002 ___BEGIN___
+
+ if (knownp)
+ {
+ // modified by EAP Fri Jan 4 12:07:30 2002 ___BEGIN___
if (aParamSeq.Length() != tabVKnots->Length())
{
BSplCLib::Reparametrize(F.Parameter(Lin->Point(1)),
- F.Parameter(Lin->Point(Lin->NbPoints())),
- tabVKnots->ChangeArray1()
- );
+ F.Parameter(Lin->Point(Lin->NbPoints())),
+ tabVKnots->ChangeArray1());
#ifdef OCCT_DEBUG
- std::cout << "Warning: AppBlend_AppSurf::Perform(), bad length of aParamSeq: " <<
- aParamSeq.Length() << " instead of " << tabVKnots->Length() << std::endl;
+ std::cout << "Warning: AppBlend_AppSurf::Perform(), bad length of aParamSeq: "
+ << aParamSeq.Length() << " instead of " << tabVKnots->Length() << std::endl;
#endif
}
else
{
Standard_Integer iKnot, iTabKnot = tabVKnots->Lower();
- for (iKnot=1; iKnot<=aParamSeq.Length(); iKnot++, iTabKnot++)
+ for (iKnot = 1; iKnot <= aParamSeq.Length(); iKnot++, iTabKnot++)
{
- //cout << "Replace " << tabVKnots->Value(iTabKnot) << " with " << aParamSeq(iKnot) << endl;
- tabVKnots->SetValue(iTabKnot, aParamSeq(iKnot));
+ // cout << "Replace " << tabVKnots->Value(iTabKnot) << " with " << aParamSeq(iKnot) << endl;
+ tabVKnots->SetValue(iTabKnot, aParamSeq(iKnot));
}
}
-// modified by EAP Fri Jan 4 12:07:35 2002 ___END___
+ // modified by EAP Fri Jan 4 12:07:35 2002 ___END___
}
-
- tabVMults = new TColStd_HArray1OfInteger (multC.Multiplicities().Lower(),
- multC.Multiplicities().Upper());
+
+ tabVMults =
+ new TColStd_HArray1OfInteger(multC.Multiplicities().Lower(), multC.Multiplicities().Upper());
tabVMults->ChangeArray1() = multC.Multiplicities();
-
-
- TColgp_Array1OfPnt newtabP(1,NbVPoles);
- Handle(TColgp_HArray1OfPnt2d) newtabP2d =
- new TColgp_HArray1OfPnt2d(1,NbVPoles);
- for (j=1; j <=NbUPoles; j++) {
- multC.Curve(j,newtabP);
- multC.Curve(j+NbUPoles+NbPoles2d,newtabP2d->ChangeArray1());
- for (k=1; k<=NbVPoles; k++) {
+
+ TColgp_Array1OfPnt newtabP(1, NbVPoles);
+ Handle(TColgp_HArray1OfPnt2d) newtabP2d = new TColgp_HArray1OfPnt2d(1, NbVPoles);
+ for (j = 1; j <= NbUPoles; j++)
+ {
+ multC.Curve(j, newtabP);
+ multC.Curve(j + NbUPoles + NbPoles2d, newtabP2d->ChangeArray1());
+ for (k = 1; k <= NbVPoles; k++)
+ {
// pour les courbes rationnelles il faut maintenant diviser
// les poles par leurs poids respectifs
- tabPoles->ChangeValue(j,k).SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X());
+ tabPoles->ChangeValue(j, k).SetXYZ(newtabP(k).XYZ() / newtabP2d->Value(k).X());
Standard_Real aWeight = newtabP2d->Value(k).X();
- if (aWeight < gp::Resolution()) {
+ if (aWeight < gp::Resolution())
+ {
done = Standard_False;
return;
}
- tabWeights->SetValue(j,k,aWeight);
+ tabWeights->SetValue(j, k, aWeight);
}
}
-
- for (j=1; j<=NbPoles2d; j++) {
- newtabP2d = new TColgp_HArray1OfPnt2d(1,NbVPoles);
- multC.Curve(NbUPoles+j,newtabP2d->ChangeArray1());
+
+ for (j = 1; j <= NbPoles2d; j++)
+ {
+ newtabP2d = new TColgp_HArray1OfPnt2d(1, NbVPoles);
+ multC.Curve(NbUPoles + j, newtabP2d->ChangeArray1());
seqPoles2d.Append(newtabP2d);
}
-
+
done = Standard_True;
}
-
//=================================================================================================
-
-void AppBlend_AppSurf::SurfShape (Standard_Integer& UDegree,
- Standard_Integer& VDegree,
- Standard_Integer& NbUPoles,
- Standard_Integer& NbVPoles,
- Standard_Integer& NbUKnots,
- Standard_Integer& NbVKnots) const
+void AppBlend_AppSurf::SurfShape(Standard_Integer& UDegree,
+ Standard_Integer& VDegree,
+ Standard_Integer& NbUPoles,
+ Standard_Integer& NbVPoles,
+ Standard_Integer& NbUKnots,
+ Standard_Integer& NbVKnots) const
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
UDegree = udeg;
VDegree = vdeg;
NbUPoles = tabPoles->ColLength();
NbVKnots = tabVKnots->Length();
}
-
-void AppBlend_AppSurf::Surface(TColgp_Array2OfPnt& TPoles,
- TColStd_Array2OfReal& TWeights,
- TColStd_Array1OfReal& TUKnots,
- TColStd_Array1OfReal& TVKnots,
- TColStd_Array1OfInteger& TUMults,
- TColStd_Array1OfInteger& TVMults) const
+void AppBlend_AppSurf::Surface(TColgp_Array2OfPnt& TPoles,
+ TColStd_Array2OfReal& TWeights,
+ TColStd_Array1OfReal& TUKnots,
+ TColStd_Array1OfReal& TVKnots,
+ TColStd_Array1OfInteger& TUMults,
+ TColStd_Array1OfInteger& TVMults) const
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
TPoles = tabPoles->Array2();
TWeights = tabWeights->Array2();
TUKnots = tabUKnots->Array1();
//=================================================================================================
-
void AppBlend_AppSurf::Curves2dShape(Standard_Integer& Degree,
- Standard_Integer& NbPoles,
- Standard_Integer& NbKnots) const
+ Standard_Integer& NbPoles,
+ Standard_Integer& NbKnots) const
{
- if (!done) {throw StdFail_NotDone();}
- if (seqPoles2d.Length() == 0) {throw Standard_DomainError();}
- Degree = vdeg;
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
+ if (seqPoles2d.Length() == 0)
+ {
+ throw Standard_DomainError();
+ }
+ Degree = vdeg;
NbPoles = tabPoles->ColLength();
NbKnots = tabVKnots->Length();
}
//=================================================================================================
-
-void AppBlend_AppSurf::Curve2d(const Standard_Integer Index,
- TColgp_Array1OfPnt2d& TPoles,
- TColStd_Array1OfReal& TKnots,
- TColStd_Array1OfInteger& TMults) const
+void AppBlend_AppSurf::Curve2d(const Standard_Integer Index,
+ TColgp_Array1OfPnt2d& TPoles,
+ TColStd_Array1OfReal& TKnots,
+ TColStd_Array1OfInteger& TMults) const
{
- if (!done) {throw StdFail_NotDone();}
- if (seqPoles2d.Length() == 0) {throw Standard_DomainError();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
+ if (seqPoles2d.Length() == 0)
+ {
+ throw Standard_DomainError();
+ }
TPoles = seqPoles2d(Index)->Array1();
- TKnots = tabVKnots->Array1();
- TMults = tabVMults->Array1();
+ TKnots = tabVKnots->Array1();
+ TMults = tabVMults->Array1();
}
//=================================================================================================
-
Standard_Real AppBlend_AppSurf::TolCurveOnSurf(const Standard_Integer) const
{
- return tol3dreached; //On ne s'embete pas !!
+ return tol3dreached; // On ne s'embete pas !!
}
-
-
-
//=================================================================================================
-ApproxInt_Approx::ApproxInt_Approx() :
- myComputeLine(4, 8, 0.001, 0.001, 5),
- myComputeLineBezier(4, 8, 0.001, 0.001, 5),
- myWithTangency(Standard_True),
- myTol3d(0.001),
- myTol2d(0.001),
- myDegMin(4),
- myDegMax(8),
- myNbIterMax(5),
- myTolReached3d(0.0),
- myTolReached2d(0.0)
+ApproxInt_Approx::ApproxInt_Approx()
+ : myComputeLine(4, 8, 0.001, 0.001, 5),
+ myComputeLineBezier(4, 8, 0.001, 0.001, 5),
+ myWithTangency(Standard_True),
+ myTol3d(0.001),
+ myTol2d(0.001),
+ myDegMin(4),
+ myDegMax(8),
+ myNbIterMax(5),
+ myTolReached3d(0.0),
+ myTolReached2d(0.0)
{
myComputeLine.SetContinuity(2);
// myComputeLineBezier.SetContinuity(2);
const GeomAbs_SurfaceType typeS2 = ThePSurfaceTool::GetType(Surf2);
const Standard_Boolean isQuadric =
- ((typeS1 == GeomAbs_Plane) || (typeS1 == GeomAbs_Cylinder) || (typeS1 == GeomAbs_Sphere) ||
- (typeS1 == GeomAbs_Cone) || (typeS2 == GeomAbs_Plane) || (typeS2 == GeomAbs_Cylinder) ||
- (typeS2 == GeomAbs_Sphere) || (typeS2 == GeomAbs_Cone));
+ ((typeS1 == GeomAbs_Plane) || (typeS1 == GeomAbs_Cylinder) || (typeS1 == GeomAbs_Sphere)
+ || (typeS1 == GeomAbs_Cone) || (typeS2 == GeomAbs_Plane) || (typeS2 == GeomAbs_Cylinder)
+ || (typeS2 == GeomAbs_Sphere) || (typeS2 == GeomAbs_Cone));
if (isQuadric)
{
const ApproxInt_TheMultiLine aTestLine(theline,
thePtrSVSurf,
((myData.ApproxXYZ) ? 1 : 0),
- ((myData.ApproxU1V1) ? 1 : 0) +
- ((myData.ApproxU2V2) ? 1 : 0),
+ ((myData.ApproxU1V1) ? 1 : 0)
+ + ((myData.ApproxU2V2) ? 1 : 0),
myData.ApproxU1V1,
myData.ApproxU2V2,
myData.Xo,
ApproxInt_TheMultiLine myMultiLine(theline,
thePtrSVSurf,
((myData.ApproxXYZ) ? 1 : 0),
- ((myData.ApproxU1V1) ? 1 : 0) +
- ((myData.ApproxU2V2) ? 1 : 0),
+ ((myData.ApproxU1V1) ? 1 : 0)
+ + ((myData.ApproxU2V2) ? 1 : 0),
myData.ApproxU1V1,
myData.ApproxU2V2,
myData.Xo,
//=================================================================================================
ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces(const TheISurface& ISurf,
- const ThePSurface& PSurf) :
- MyIsTangent(Standard_False),
- MyHasBeenComputed(Standard_False),
- MyIsTangentbis(Standard_False),
- MyHasBeenComputedbis(Standard_False),
- MyImplicitFirst(Standard_True),
- MyZerImpFunc(PSurf, ISurf)
+ const ThePSurface& PSurf)
+ : MyIsTangent(Standard_False),
+ MyHasBeenComputed(Standard_False),
+ MyIsTangentbis(Standard_False),
+ MyHasBeenComputedbis(Standard_False),
+ MyImplicitFirst(Standard_True),
+ MyZerImpFunc(PSurf, ISurf)
{
SetUseSolver(Standard_True);
}
//=================================================================================================
ApproxInt_ImpPrmSvSurfaces::ApproxInt_ImpPrmSvSurfaces(const ThePSurface& PSurf,
- const TheISurface& ISurf) :
- MyIsTangent(Standard_False),
- MyHasBeenComputed(Standard_False),
- MyIsTangentbis(Standard_False),
- MyHasBeenComputedbis(Standard_False),
- MyImplicitFirst(Standard_False),
- MyZerImpFunc(PSurf, ISurf)
+ const TheISurface& ISurf)
+ : MyIsTangent(Standard_False),
+ MyHasBeenComputed(Standard_False),
+ MyIsTangentbis(Standard_False),
+ MyHasBeenComputedbis(Standard_False),
+ MyImplicitFirst(Standard_False),
+ MyZerImpFunc(PSurf, ISurf)
{
SetUseSolver(Standard_True);
}
if (MyHasBeenComputed)
{
- if ((MyParOnS1.X() == u1) && (MyParOnS1.Y() == v1) && (MyParOnS2.X() == u2) &&
- (MyParOnS2.Y() == v2))
+ if ((MyParOnS1.X() == u1) && (MyParOnS1.Y() == v1) && (MyParOnS2.X() == u2)
+ && (MyParOnS2.Y() == v2))
{
return (MyIsTangent);
}
if (MyHasBeenComputedbis)
{
- if ((MyParOnS1bis.X() == u1) && (MyParOnS1bis.Y() == v1) && (MyParOnS2bis.X() == u2) &&
- (MyParOnS2bis.Y() == v2))
+ if ((MyParOnS1bis.X() == u1) && (MyParOnS1bis.Y() == v1) && (MyParOnS2bis.X() == u2)
+ && (MyParOnS2bis.Y() == v2))
{
gp_Vec TV(MyTg);
#include <math_Vector.hxx>
#ifdef DRAW
-#include <DrawTrSurf.hxx>
+ #include <DrawTrSurf.hxx>
#endif
//=================================================================================================
ApproxInt_MultiLine::ApproxInt_MultiLine()
{
PtrOnmySvSurfaces = NULL;
- myLine = NULL;
- indicemin = 0;
- indicemax = 0;
- nbp3d = 0;
- nbp2d = 0;
- myApproxU1V1 = Standard_False;
- myApproxU2V2 = Standard_False;
- p2donfirst = Standard_True;
- Xo = 0.;
- Yo = 0.;
- Zo = 0.;
- U1o = 0.;
- V1o = 0.;
- U2o = 0.;
- V2o = 0.;
+ myLine = NULL;
+ indicemin = 0;
+ indicemax = 0;
+ nbp3d = 0;
+ nbp2d = 0;
+ myApproxU1V1 = Standard_False;
+ myApproxU2V2 = Standard_False;
+ p2donfirst = Standard_True;
+ Xo = 0.;
+ Yo = 0.;
+ Zo = 0.;
+ U1o = 0.;
+ V1o = 0.;
+ U2o = 0.;
+ V2o = 0.;
}
//=================================================================================================
-ApproxInt_MultiLine::
- ApproxInt_MultiLine(const Handle_TheLine& line,
- const Standard_Address svsurf,
- const Standard_Integer NbP3d,
- const Standard_Integer NbP2d,
- const Standard_Boolean ApproxU1V1,
- const Standard_Boolean ApproxU2V2,
- const Standard_Real xo,
- const Standard_Real yo,
- const Standard_Real zo,
- const Standard_Real u1o,
- const Standard_Real v1o,
- const Standard_Real u2o,
- const Standard_Real v2o,
- const Standard_Boolean P2DOnFirst,
- const Standard_Integer IndMin,
- const Standard_Integer IndMax): PtrOnmySvSurfaces(svsurf),
- myLine(line),
- indicemin(Min(IndMin, IndMax)),
- indicemax(Max(IndMin, IndMax)),
- nbp3d(NbP3d), nbp2d(NbP2d),
- myApproxU1V1(ApproxU1V1),
- myApproxU2V2(ApproxU2V2),
- p2donfirst(P2DOnFirst),
- Xo(xo), Yo(yo), Zo(zo),
- U1o(u1o), V1o(v1o),
- U2o(u2o), V2o(v2o)
+ApproxInt_MultiLine::ApproxInt_MultiLine(const Handle_TheLine& line,
+ const Standard_Address svsurf,
+ const Standard_Integer NbP3d,
+ const Standard_Integer NbP2d,
+ const Standard_Boolean ApproxU1V1,
+ const Standard_Boolean ApproxU2V2,
+ const Standard_Real xo,
+ const Standard_Real yo,
+ const Standard_Real zo,
+ const Standard_Real u1o,
+ const Standard_Real v1o,
+ const Standard_Real u2o,
+ const Standard_Real v2o,
+ const Standard_Boolean P2DOnFirst,
+ const Standard_Integer IndMin,
+ const Standard_Integer IndMax)
+ : PtrOnmySvSurfaces(svsurf),
+ myLine(line),
+ indicemin(Min(IndMin, IndMax)),
+ indicemax(Max(IndMin, IndMax)),
+ nbp3d(NbP3d),
+ nbp2d(NbP2d),
+ myApproxU1V1(ApproxU1V1),
+ myApproxU2V2(ApproxU2V2),
+ p2donfirst(P2DOnFirst),
+ Xo(xo),
+ Yo(yo),
+ Zo(zo),
+ U1o(u1o),
+ V1o(v1o),
+ U2o(u2o),
+ V2o(v2o)
{
#ifdef OCCT_DEBUG
- //if(indicemin == indicemax)
+ // if(indicemin == indicemax)
//{
- // cout<<"ApproxInt_MultiLine: indicemin = indicemax = " << indicemin << endl;
- //}
+ // cout<<"ApproxInt_MultiLine: indicemin = indicemax = " << indicemin << endl;
+ // }
#endif
}
//=================================================================================================
-ApproxInt_MultiLine::
- ApproxInt_MultiLine(const Handle_TheLine& line,
- const Standard_Integer NbP3d,
- const Standard_Integer NbP2d,
- const Standard_Boolean ApproxU1V1,
- const Standard_Boolean ApproxU2V2,
- const Standard_Real xo,
- const Standard_Real yo,
- const Standard_Real zo,
- const Standard_Real u1o,
- const Standard_Real v1o,
- const Standard_Real u2o,
- const Standard_Real v2o,
- const Standard_Boolean P2DOnFirst,
- const Standard_Integer IndMin,
- const Standard_Integer IndMax): PtrOnmySvSurfaces(0),
- myLine(line),
- indicemin(Min(IndMin, IndMax)),
- indicemax(Max(IndMin, IndMax)),
- nbp3d(NbP3d), nbp2d(NbP2d),
- myApproxU1V1(ApproxU1V1),
- myApproxU2V2(ApproxU2V2),
- p2donfirst(P2DOnFirst),
- Xo(xo), Yo(yo), Zo(zo),
- U1o(u1o), V1o(v1o),
- U2o(u2o), V2o(v2o)
+ApproxInt_MultiLine::ApproxInt_MultiLine(const Handle_TheLine& line,
+ const Standard_Integer NbP3d,
+ const Standard_Integer NbP2d,
+ const Standard_Boolean ApproxU1V1,
+ const Standard_Boolean ApproxU2V2,
+ const Standard_Real xo,
+ const Standard_Real yo,
+ const Standard_Real zo,
+ const Standard_Real u1o,
+ const Standard_Real v1o,
+ const Standard_Real u2o,
+ const Standard_Real v2o,
+ const Standard_Boolean P2DOnFirst,
+ const Standard_Integer IndMin,
+ const Standard_Integer IndMax)
+ : PtrOnmySvSurfaces(0),
+ myLine(line),
+ indicemin(Min(IndMin, IndMax)),
+ indicemax(Max(IndMin, IndMax)),
+ nbp3d(NbP3d),
+ nbp2d(NbP2d),
+ myApproxU1V1(ApproxU1V1),
+ myApproxU2V2(ApproxU2V2),
+ p2donfirst(P2DOnFirst),
+ Xo(xo),
+ Yo(yo),
+ Zo(zo),
+ U1o(u1o),
+ V1o(v1o),
+ U2o(u2o),
+ V2o(v2o)
{
#ifdef OCCT_DEBUG
- //if(indicemin == indicemax)
+ // if(indicemin == indicemax)
//{
- // cout<<"ApproxInt_MultiLine: indicemin = indicemax = " << indicemin << endl;
- //}
+ // cout<<"ApproxInt_MultiLine: indicemin = indicemax = " << indicemin << endl;
+ // }
#endif
}
-//--------------------------------------------------------------------------------
-Standard_Integer ApproxInt_MultiLine::FirstPoint() const {
+//=================================================================================================
+
+Standard_Integer ApproxInt_MultiLine::FirstPoint() const
+{
return indicemin;
}
-//--------------------------------------------------------------------------------
-Standard_Integer ApproxInt_MultiLine::LastPoint() const {
+
+//=================================================================================================
+
+Standard_Integer ApproxInt_MultiLine::LastPoint() const
+{
return indicemax;
}
-//--------------------------------------------------------------------------------
-Approx_Status ApproxInt_MultiLine::WhatStatus() const {
- if(PtrOnmySvSurfaces)
+
+//=================================================================================================
+
+Approx_Status ApproxInt_MultiLine::WhatStatus() const
+{
+ if (PtrOnmySvSurfaces)
return Approx_PointsAdded;
- else
+ else
return Approx_NoPointsAdded;
}
-//--------------------------------------------------------------------------------
-Standard_Integer ApproxInt_MultiLine::NbP3d() const {
+
+//=================================================================================================
+
+Standard_Integer ApproxInt_MultiLine::NbP3d() const
+{
return nbp3d;
}
-//--------------------------------------------------------------------------------
-Standard_Integer ApproxInt_MultiLine::NbP2d() const {
+
+//=================================================================================================
+
+Standard_Integer ApproxInt_MultiLine::NbP2d() const
+{
return nbp2d;
}
-//================================================================================
-void ApproxInt_MultiLine::Value(const Standard_Integer Index,
- TColgp_Array1OfPnt& TabPnt) const
+
+//=================================================================================================
+
+void ApproxInt_MultiLine::Value(const Standard_Integer Index, TColgp_Array1OfPnt& TabPnt) const
{
const gp_Pnt aP = myLine->Point(Index).Value();
- TabPnt(1).SetCoord(aP.X()+Xo, aP.Y()+Yo, aP.Z()+Zo);
+ TabPnt(1).SetCoord(aP.X() + Xo, aP.Y() + Yo, aP.Z() + Zo);
}
//=================================================================================================
-void ApproxInt_MultiLine::Value(const Standard_Integer Index,
- TColgp_Array1OfPnt2d& TabPnt2d) const
+void ApproxInt_MultiLine::Value(const Standard_Integer Index, TColgp_Array1OfPnt2d& TabPnt2d) const
{
IntSurf_PntOn2S POn2S(myLine->Point(Index));
- Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
+ Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
POn2S.Parameters(u1, v1, u2, v2);
- if(nbp2d==1)
- {
- if(p2donfirst)
- {
- TabPnt2d(1).SetCoord(u1+U1o, v1+V1o);
+ if (nbp2d == 1)
+ {
+ if (p2donfirst)
+ {
+ TabPnt2d(1).SetCoord(u1 + U1o, v1 + V1o);
}
else
{
- TabPnt2d(1).SetCoord(u2+U2o, v2+V2o);
+ TabPnt2d(1).SetCoord(u2 + U2o, v2 + V2o);
}
}
else
{
- TabPnt2d(1).SetCoord(u1+U1o, v1+V1o);
- if(TabPnt2d.Length() >= 2)
- {
- TabPnt2d(2).SetCoord(u2+U2o, v2+V2o);
- }
+ TabPnt2d(1).SetCoord(u1 + U1o, v1 + V1o);
+ if (TabPnt2d.Length() >= 2)
+ {
+ TabPnt2d(2).SetCoord(u2 + U2o, v2 + V2o);
+ }
}
}
void ApproxInt_MultiLine::Value(const Standard_Integer Index,
TColgp_Array1OfPnt& TabPnt,
- TColgp_Array1OfPnt2d& TabPnt2d) const
-{
- Value(Index, TabPnt);
- Value(Index, TabPnt2d);
+ TColgp_Array1OfPnt2d& TabPnt2d) const
+{
+ Value(Index, TabPnt);
+ Value(Index, TabPnt2d);
}
//=================================================================================================
-Standard_Boolean ApproxInt_MultiLine::Tangency( const Standard_Integer Index,
- TColgp_Array1OfVec& TabVec) const
+Standard_Boolean ApproxInt_MultiLine::Tangency(const Standard_Integer Index,
+ TColgp_Array1OfVec& TabVec) const
{
- if(PtrOnmySvSurfaces==NULL)
+ if (PtrOnmySvSurfaces == NULL)
return Standard_False;
const IntSurf_PntOn2S& POn2S = myLine->Point(Index);
- Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
- POn2S.Parameters(u1,v1,u2,v2);
+ Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
+ POn2S.Parameters(u1, v1, u2, v2);
- Standard_Boolean ret=
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->Tangency(u1, v1, u2, v2, TabVec(1));
- if(!ret)
+ Standard_Boolean ret = ((TheSvSurfaces*)PtrOnmySvSurfaces)->Tangency(u1, v1, u2, v2, TabVec(1));
+ if (!ret)
{
TabVec(1).SetCoord(0.0, 0.0, 0.0);
}
//=================================================================================================
-Standard_Boolean ApproxInt_MultiLine::Tangency( const Standard_Integer Index,
- TColgp_Array1OfVec2d& TabVec2d) const
+Standard_Boolean ApproxInt_MultiLine::Tangency(const Standard_Integer Index,
+ TColgp_Array1OfVec2d& TabVec2d) const
{
- if(PtrOnmySvSurfaces==NULL)
+ if (PtrOnmySvSurfaces == NULL)
return Standard_False;
const IntSurf_PntOn2S& POn2S = myLine->Point(Index);
- Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
- POn2S.Parameters(u1,v1,u2,v2);
+ Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
+ POn2S.Parameters(u1, v1, u2, v2);
Standard_Boolean ret = Standard_False;
- if(nbp2d==1)
- {
- if(p2donfirst)
+ if (nbp2d == 1)
+ {
+ if (p2donfirst)
{
- ret=((TheSvSurfaces *)PtrOnmySvSurfaces)->TangencyOnSurf1(u1, v1, u2, v2, TabVec2d(1));
+ ret = ((TheSvSurfaces*)PtrOnmySvSurfaces)->TangencyOnSurf1(u1, v1, u2, v2, TabVec2d(1));
}
else
- {
- ret=((TheSvSurfaces *)PtrOnmySvSurfaces)->TangencyOnSurf2(u1, v1, u2, v2, TabVec2d(1));
+ {
+ ret = ((TheSvSurfaces*)PtrOnmySvSurfaces)->TangencyOnSurf2(u1, v1, u2, v2, TabVec2d(1));
}
}
else
{
- ret=((TheSvSurfaces *)PtrOnmySvSurfaces)->TangencyOnSurf1(u1, v1, u2, v2, TabVec2d(1));
- if(ret)
- {
- if(TabVec2d.Length()>=2)
+ ret = ((TheSvSurfaces*)PtrOnmySvSurfaces)->TangencyOnSurf1(u1, v1, u2, v2, TabVec2d(1));
+ if (ret)
+ {
+ if (TabVec2d.Length() >= 2)
{
- ret =
- (ret &&
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->
- TangencyOnSurf2(u1, v1, u2, v2, TabVec2d(2)));
+ ret =
+ (ret
+ && ((TheSvSurfaces*)PtrOnmySvSurfaces)->TangencyOnSurf2(u1, v1, u2, v2, TabVec2d(2)));
}
}
}
- if(!ret)
+ if (!ret)
{
TabVec2d(1) = gp_Vec2d(0.0, 0.0);
- if(TabVec2d.Length() >= 2)
+ if (TabVec2d.Length() >= 2)
{
- TabVec2d(2) = gp_Vec2d(0.0,0.0);
+ TabVec2d(2) = gp_Vec2d(0.0, 0.0);
}
}
//=================================================================================================
-Standard_Boolean ApproxInt_MultiLine::Tangency( const Standard_Integer Index,
- TColgp_Array1OfVec& TabVec,
- TColgp_Array1OfVec2d& TabVec2d) const
-{
+Standard_Boolean ApproxInt_MultiLine::Tangency(const Standard_Integer Index,
+ TColgp_Array1OfVec& TabVec,
+ TColgp_Array1OfVec2d& TabVec2d) const
+{
return (Tangency(Index, TabVec) && Tangency(Index, TabVec2d));
}
//=================================================================================================
-ApproxInt_MultiLine
- ApproxInt_MultiLine::MakeMLBetween( const Standard_Integer Low,
- const Standard_Integer High,
- const Standard_Integer aNbPntsToInsert) const
-{
- if(PtrOnmySvSurfaces==NULL) {
+ApproxInt_MultiLine ApproxInt_MultiLine::MakeMLBetween(const Standard_Integer Low,
+ const Standard_Integer High,
+ const Standard_Integer aNbPntsToInsert) const
+{
+ if (PtrOnmySvSurfaces == NULL)
+ {
//-- cout<<"\n Erreur dans : ApproxInt_MultiLine ApproxInt_MultiLine::MakeMLBetween "<<endl;
Handle(IntSurf_LineOn2S) vide1 = new IntSurf_LineOn2S();
- Handle(TheLine) vide = new TheLine(vide1,Standard_False);
+ Handle(TheLine) vide = new TheLine(vide1, Standard_False);
return (ApproxInt_MultiLine(vide,
NULL,
nbp3d,
nbp2d,
- myApproxU1V1, myApproxU2V2,
- Xo,Yo,Zo,U1o,V1o,U2o,V2o,
+ myApproxU1V1,
+ myApproxU2V2,
+ Xo,
+ Yo,
+ Zo,
+ U1o,
+ V1o,
+ U2o,
+ V2o,
p2donfirst,
- 1,1));
+ 1,
+ 1));
//-- return(*this);
}
- Standard_Boolean aSaveUseSolver = ((TheSvSurfaces *)PtrOnmySvSurfaces)->GetUseSolver();
+ Standard_Boolean aSaveUseSolver = ((TheSvSurfaces*)PtrOnmySvSurfaces)->GetUseSolver();
if (!aSaveUseSolver)
{
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(Standard_True);
+ ((TheSvSurfaces*)PtrOnmySvSurfaces)->SetUseSolver(Standard_True);
}
- Standard_Integer NbPntsToInsert=aNbPntsToInsert;
- if(NbPntsToInsert<(High-Low)) NbPntsToInsert=(High-Low);
- Standard_Integer NbPnts = NbPntsToInsert + High - Low + 1;
- Standard_Integer NbPntsmin = High-Low;
- NbPntsmin+=NbPntsmin;
-
- if(NbPnts<NbPntsmin) NbPnts=NbPntsmin;
-
-
- gp_Vec T;
- gp_Vec2d TS1,TS2;
- gp_Pnt P;
-
+ Standard_Integer NbPntsToInsert = aNbPntsToInsert;
+ if (NbPntsToInsert < (High - Low))
+ NbPntsToInsert = (High - Low);
+ Standard_Integer NbPnts = NbPntsToInsert + High - Low + 1;
+ Standard_Integer NbPntsmin = High - Low;
+ NbPntsmin += NbPntsmin;
+
+ if (NbPnts < NbPntsmin)
+ NbPnts = NbPntsmin;
+
+ gp_Vec T;
+ gp_Vec2d TS1, TS2;
+ gp_Pnt P;
+
//-----------------------l-------------------------------------------
//-- Indice : Low Low+1 I I+1 High --
//-- --
//-- constante. --
//-- L abcisse est calculee sur les params U1,V1 --
//------------------------------------------------------------------
- TColStd_Array1OfReal U1(Low,High);
- TColStd_Array1OfReal V1(Low,High);
- TColStd_Array1OfReal U2(Low,High);
- TColStd_Array1OfReal V2(Low,High);
- TColStd_Array1OfReal AC(Low,High);
- Standard_Real s,ds;
-
+ TColStd_Array1OfReal U1(Low, High);
+ TColStd_Array1OfReal V1(Low, High);
+ TColStd_Array1OfReal U2(Low, High);
+ TColStd_Array1OfReal V2(Low, High);
+ TColStd_Array1OfReal AC(Low, High);
+ Standard_Real s, ds;
+
//------------------------------------------------------------
//-- Creation des Tableaux U1 .. V2 et AC
- //--
- Standard_Real u1,v1,u2,v2;
- Standard_Integer i ;
- myLine->Point(Low).Parameters(u1,v1,u2,v2);
+ //--
+ Standard_Real u1, v1, u2, v2;
+ Standard_Integer i;
+ myLine->Point(Low).Parameters(u1, v1, u2, v2);
U1(Low) = u1;
V1(Low) = v1;
U2(Low) = u2;
V2(Low) = v2;
- AC(Low) =0.0;
-
+ AC(Low) = 0.0;
+
#if 0
for( i=Low+1; i<=High; i++) {
myLine->Point(i).Parameters(u1,v1,u2,v2);
AC(i) = AC(i-1) + sqrt((du1*du1)+(dv1*dv1));
}
-#else
+#else
//-- Essai du 19 juin 96 (parametrage selon abs curv en XYZ)
- for( i=Low+1; i<=High; i++) {
- myLine->Point(i).Parameters(u1,v1,u2,v2);
+ for (i = Low + 1; i <= High; i++)
+ {
+ myLine->Point(i).Parameters(u1, v1, u2, v2);
U1(i) = u1;
V1(i) = v1;
U2(i) = u2;
- V2(i) = v2;
- AC(i) = AC(i-1) + (myLine->Point(i-1).Value()).Distance(myLine->Point(i).Value());
+ V2(i) = v2;
+ AC(i) = AC(i - 1) + (myLine->Point(i - 1).Value()).Distance(myLine->Point(i).Value());
}
#endif
//-------------------------------------------------------------
//-- Creation des structures contenant les resultats
-
+
Handle(IntSurf_LineOn2S) ResultPntOn2SLine = new IntSurf_LineOn2S();
-
- IntSurf_PntOn2S StartPOn2S;
- TColStd_Array1OfReal StartParams(1,4);
-
- ds = AC(High) / (NbPnts-1);
- Standard_Integer Indice = Low;
+
+ IntSurf_PntOn2S StartPOn2S;
+ TColStd_Array1OfReal StartParams(1, 4);
+
+ ds = AC(High) / (NbPnts - 1);
+ Standard_Integer Indice = Low;
Standard_Boolean HasBeenInserted = Standard_False;
- Standard_Real dsmin = ds*0.3;
- Standard_Real smax = AC(High);
-
- for(i=2,s=ds; (s < smax && Indice <= High-1); i++,s+=ds) {
+ Standard_Real dsmin = ds * 0.3;
+ Standard_Real smax = AC(High);
+
+ for (i = 2, s = ds; (s < smax && Indice <= High - 1); i++, s += ds)
+ {
//----------------------------------------------------------
//-- Recherche des indices des points --
//-- Point : 2 i NbPnts-1 --
//-- s s --
//-- Current Indice tel que AC(Indice)<= s < AC(Indice+1) --
//----------------------------------------------------------
- while(AC(Indice+1) <= s)
- {
- if(!HasBeenInserted)
+ while (AC(Indice + 1) <= s)
+ {
+ if (!HasBeenInserted)
ResultPntOn2SLine->Add(myLine->Point(Indice));
HasBeenInserted = Standard_False;
if (Indice == High)
break;
}
-
+
if (Indice == High)
break;
-
- if(!HasBeenInserted && AC(Indice) <= s)
- {
+
+ if (!HasBeenInserted && AC(Indice) <= s)
+ {
ResultPntOn2SLine->Add(myLine->Point(Indice));
HasBeenInserted = Standard_True;
}
-
- Standard_Real a = s - AC(Indice);
- Standard_Real b = AC(Indice+1) - s;
- Standard_Real nab = 1.0/(a+b);
-
+
+ Standard_Real a = s - AC(Indice);
+ Standard_Real b = AC(Indice + 1) - s;
+ Standard_Real nab = 1.0 / (a + b);
+
//----------------------------------------------------------
//-- Verification : Si Dist au prochain point < dsmin --
//-- Si Dist au precedent point < dsmin --
//-- --
//----------------------------------------------------------
- if((a>dsmin) && (b>dsmin))
+ if ((a > dsmin) && (b > dsmin))
{
- u1 = (U1(Indice) * b + U1(Indice+1) * a) * nab;
- v1 = (V1(Indice) * b + V1(Indice+1) * a) * nab;
- u2 = (U2(Indice) * b + U2(Indice+1) * a) * nab;
- v2 = (V2(Indice) * b + V2(Indice+1) * a) * nab;
-
- if(((TheSvSurfaces *)PtrOnmySvSurfaces)->Compute(u1,v1,u2,v2,P,T,TS1,TS2))
+ u1 = (U1(Indice) * b + U1(Indice + 1) * a) * nab;
+ v1 = (V1(Indice) * b + V1(Indice + 1) * a) * nab;
+ u2 = (U2(Indice) * b + U2(Indice + 1) * a) * nab;
+ v2 = (V2(Indice) * b + V2(Indice + 1) * a) * nab;
+
+ if (((TheSvSurfaces*)PtrOnmySvSurfaces)->Compute(u1, v1, u2, v2, P, T, TS1, TS2))
{
- StartPOn2S.SetValue(P,u1,v1,u2,v2);
+ StartPOn2S.SetValue(P, u1, v1, u2, v2);
//-- cout<<" Insertion du point calcule : "<<u1<<","<<v1<<","<<u2<<","<<v2<<",";
//-- cout<<P.X()<<","<<P.Y()<<","<<P.Z()<<endl;
ResultPntOn2SLine->Add(StartPOn2S);
{
//-- Point non situe a distance suffisante de 2 pts existants
//-- avec le point p[indice] deja insere
-
- if(b<0.0)
+
+ if (b < 0.0)
{
- while(AC(Indice+1) <= s)
+ while (AC(Indice + 1) <= s)
{
- if(!HasBeenInserted)
+ if (!HasBeenInserted)
ResultPntOn2SLine->Add(myLine->Point(Indice));
//-- cout<<" Insertion du point :"<<Indice<<endl;
break;
}
- if(Indice == High)
+ if (Indice == High)
break;
- if(!HasBeenInserted && AC(Indice) <= s)
+ if (!HasBeenInserted && AC(Indice) <= s)
{
ResultPntOn2SLine->Add(myLine->Point(Indice));
HasBeenInserted = Standard_True;
}
else
{
- s+= (dsmin - ds);
+ s += (dsmin - ds);
}
}
}
-
- ResultPntOn2SLine->Add(myLine->Point(High)); //-- Point NbPnts
- Handle(TheLine) temp = new TheLine(ResultPntOn2SLine,Standard_False);
-
- //-- Verification a posteriori
+
+ ResultPntOn2SLine->Add(myLine->Point(High)); //-- Point NbPnts
+ Handle(TheLine) temp = new TheLine(ResultPntOn2SLine, Standard_False);
+
+ //-- Verification a posteriori
//-- On verifie qu il n y a pas de virage trop important en 2d et en 3d
-
- temp->Point(1).Parameters(u1,v1,u2,v2);
- gp_Pnt2d P1A(u1,v1);
- gp_Pnt2d P2A(u2,v2);
- temp->Point(2).Parameters(u1,v1,u2,v2);
- gp_Pnt2d P1B(u1,v1);
- gp_Pnt2d P2B(u2,v2);
+ temp->Point(1).Parameters(u1, v1, u2, v2);
+ gp_Pnt2d P1A(u1, v1);
+ gp_Pnt2d P2A(u2, v2);
+
+ temp->Point(2).Parameters(u1, v1, u2, v2);
+ gp_Pnt2d P1B(u1, v1);
+ gp_Pnt2d P2B(u2, v2);
- gp_Pnt2d P1C,P2C;
+ gp_Pnt2d P1C, P2C;
- Standard_Integer CodeErreur=0;
-
- for(i=3,NbPnts=temp->NbPnts();CodeErreur==0 && i<=NbPnts; i++)
+ Standard_Integer CodeErreur = 0;
+
+ for (i = 3, NbPnts = temp->NbPnts(); CodeErreur == 0 && i <= NbPnts; i++)
{
- Standard_Real d,du,dv,duv2;
- temp->Point(i).Parameters(u1,v1,u2,v2);
+ Standard_Real d, du, dv, duv2;
+ temp->Point(i).Parameters(u1, v1, u2, v2);
//-- Virage P1A P1B P1C
- P1C.SetCoord(u1,v1);
- du = P1B.X()-P1A.X();
- dv = P1B.Y()-P1A.Y();
- duv2= 0.25*(du*du+dv*dv);
- u1 = P1B.X() + du;
- v1 = P1B.Y() + dv;
- du = P1C.X() - u1;
- dv = P1C.Y() - v1;
- d = du*du+dv*dv;
- if(d>duv2)
- {
+ P1C.SetCoord(u1, v1);
+ du = P1B.X() - P1A.X();
+ dv = P1B.Y() - P1A.Y();
+ duv2 = 0.25 * (du * du + dv * dv);
+ u1 = P1B.X() + du;
+ v1 = P1B.Y() + dv;
+ du = P1C.X() - u1;
+ dv = P1C.Y() - v1;
+ d = du * du + dv * dv;
+ if (d > duv2)
+ {
CodeErreur = 1;
CodeErreur = 1;
break;
}
-
+
//-- Virage P2A P2B P2C
- P2C.SetCoord(u2,v2);
- du = P2B.X()-P2A.X();
- dv = P2B.Y()-P2A.Y();
- duv2= 0.25*(du*du+dv*dv);
- u2 = P2B.X() + du;
- v2 = P2B.Y() + dv;
- du = P2C.X() - u2;
- dv = P2C.Y() - v2;
- d = du*du+dv*dv;
- if(d>duv2)
+ P2C.SetCoord(u2, v2);
+ du = P2B.X() - P2A.X();
+ dv = P2B.Y() - P2A.Y();
+ duv2 = 0.25 * (du * du + dv * dv);
+ u2 = P2B.X() + du;
+ v2 = P2B.Y() + dv;
+ du = P2C.X() - u2;
+ dv = P2C.Y() - v2;
+ d = du * du + dv * dv;
+ if (d > duv2)
{
CodeErreur = 2;
break;
}
-
- P1A=P1B;
- P2A=P2B;
- P1B=P1C;
- P2B=P2C;
+
+ P1A = P1B;
+ P2A = P2B;
+ P1B = P1C;
+ P2B = P2C;
}
#ifdef OCCT_DEBUG
- //if (temp->NbPnts() < NbPntsToInsert + High - Low + 1)
- //{
- // cout<<" *** Pas assez de points entre :"<<
- // Low<<" et "<<High<<" -> "<<temp->NbPnts()<<endl;
- //}
-
- //if(CodeErreur)
- //{
- // cout<<" *** CodeErreur : "<<CodeErreur<<endl;
- //}
+ // if (temp->NbPnts() < NbPntsToInsert + High - Low + 1)
+ //{
+ // cout<<" *** Pas assez de points entre :"<<
+ // Low<<" et "<<High<<" -> "<<temp->NbPnts()<<endl;
+ // }
+
+ // if(CodeErreur)
+ //{
+ // cout<<" *** CodeErreur : "<<CodeErreur<<endl;
+ // }
#endif
- if((temp->NbPnts() >= NbPntsToInsert + High - Low + 1) && (CodeErreur==0))
+ if ((temp->NbPnts() >= NbPntsToInsert + High - Low + 1) && (CodeErreur == 0))
{
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
- return (ApproxInt_MultiLine( temp,
- (High-Low>10)? PtrOnmySvSurfaces : NULL,
- nbp3d,
- nbp2d,
- myApproxU1V1, myApproxU2V2,
- Xo,Yo,Zo,
- U1o,V1o,
- U2o,V2o,
- p2donfirst,
- 1,ResultPntOn2SLine->NbPoints()));
+ ((TheSvSurfaces*)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
+ return (ApproxInt_MultiLine(temp,
+ (High - Low > 10) ? PtrOnmySvSurfaces : NULL,
+ nbp3d,
+ nbp2d,
+ myApproxU1V1,
+ myApproxU2V2,
+ Xo,
+ Yo,
+ Zo,
+ U1o,
+ V1o,
+ U2o,
+ V2o,
+ p2donfirst,
+ 1,
+ ResultPntOn2SLine->NbPoints()));
}
else
{
//-- cout<<" ApproxInt_MultiLine "<<endl;
//-- cout<<" Pas de Rajout de points ds1min = "<<minds1<<" ds2min = "<<minds2<<endl;
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
+ ((TheSvSurfaces*)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
Handle(IntSurf_LineOn2S) vide1 = new IntSurf_LineOn2S();
- Handle(TheLine) vide = new TheLine(vide1,Standard_False);
- return (ApproxInt_MultiLine( vide,
- NULL,
- nbp3d,
- nbp2d,
- myApproxU1V1, myApproxU2V2,
- Xo,Yo,Zo,
- U1o,V1o,
- U2o,V2o,
- p2donfirst,
- 1,1));
+ Handle(TheLine) vide = new TheLine(vide1, Standard_False);
+ return (ApproxInt_MultiLine(vide,
+ NULL,
+ nbp3d,
+ nbp2d,
+ myApproxU1V1,
+ myApproxU2V2,
+ Xo,
+ Yo,
+ Zo,
+ U1o,
+ V1o,
+ U2o,
+ V2o,
+ p2donfirst,
+ 1,
+ 1));
}
}
//=================================================================================================
-Standard_Boolean
- ApproxInt_MultiLine::MakeMLOneMorePoint(const Standard_Integer theLow,
- const Standard_Integer theHigh,
- const Standard_Integer theIndbad,
- ApproxInt_MultiLine& theNewMultiLine) const
+Standard_Boolean ApproxInt_MultiLine::MakeMLOneMorePoint(const Standard_Integer theLow,
+ const Standard_Integer theHigh,
+ const Standard_Integer theIndbad,
+ ApproxInt_MultiLine& theNewMultiLine) const
{
Standard_Boolean OtherLineMade = Standard_False;
- if(PtrOnmySvSurfaces==NULL)
+ if (PtrOnmySvSurfaces == NULL)
return Standard_False;
- Standard_Boolean aSaveUseSolver = ((TheSvSurfaces *)PtrOnmySvSurfaces)->GetUseSolver();
+ Standard_Boolean aSaveUseSolver = ((TheSvSurfaces*)PtrOnmySvSurfaces)->GetUseSolver();
if (!aSaveUseSolver)
{
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(Standard_True);
+ ((TheSvSurfaces*)PtrOnmySvSurfaces)->SetUseSolver(Standard_True);
}
constexpr Standard_Real SqTol3d = Precision::SquareConfusion();
- math_Vector tolerance(1,2);
+ math_Vector tolerance(1, 2);
tolerance(1) = tolerance(2) = 1.e-8;
-
+
Handle(IntSurf_LineOn2S) ResultPntOn2SLine = new IntSurf_LineOn2S();
for (Standard_Integer Indice = theLow; Indice <= theHigh; Indice++)
ResultPntOn2SLine->Add(myLine->Point(Indice));
- //Insert new point between (theIndbad-1) and theIndbad
- //Using <thePtrSVSurf> for Rsnld: it may be ImpPrm or PrmPrm
- gp_Pnt PrevPnt = myLine->Point(theIndbad-1).Value();
- gp_Pnt CurPnt = myLine->Point(theIndbad).Value();
+ // Insert new point between (theIndbad-1) and theIndbad
+ // Using <thePtrSVSurf> for Rsnld: it may be ImpPrm or PrmPrm
+ gp_Pnt PrevPnt = myLine->Point(theIndbad - 1).Value();
+ gp_Pnt CurPnt = myLine->Point(theIndbad).Value();
Standard_Real uprev1, vprev1, uprev2, vprev2, ucur1, vcur1, ucur2, vcur2;
- myLine->Point(theIndbad-1).Parameters(uprev1, vprev1, uprev2, vprev2);
+ myLine->Point(theIndbad - 1).Parameters(uprev1, vprev1, uprev2, vprev2);
myLine->Point(theIndbad).Parameters(ucur1, vcur1, ucur2, vcur2);
Standard_Real umid1, vmid1, umid2, vmid2;
- umid1 = (uprev1 + ucur1)/2;
- vmid1 = (vprev1 + vcur1)/2;
- umid2 = (uprev2 + ucur2)/2;
- vmid2 = (vprev2 + vcur2)/2;
- IntSurf_PntOn2S MidPoint;
+ umid1 = (uprev1 + ucur1) / 2;
+ vmid1 = (vprev1 + vcur1) / 2;
+ umid2 = (uprev2 + ucur2) / 2;
+ vmid2 = (vprev2 + vcur2) / 2;
+ IntSurf_PntOn2S MidPoint;
Standard_Boolean IsNewPointInvalid = Standard_False;
IsNewPointInvalid =
- myApproxU1V1 &&
- Abs(ucur1 - umid1) <= tolerance(1) &&
- Abs(vcur1 - vmid1) <= tolerance(2);
+ myApproxU1V1 && Abs(ucur1 - umid1) <= tolerance(1) && Abs(vcur1 - vmid1) <= tolerance(2);
if (!IsNewPointInvalid)
{
IsNewPointInvalid =
- myApproxU2V2 &&
- Abs(ucur2 - umid2) <= tolerance(1) &&
- Abs(vcur2 - vmid2) <= tolerance(2);
- if (!IsNewPointInvalid &&
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SeekPoint(umid1, vmid1, umid2, vmid2,
- MidPoint))
+ myApproxU2V2 && Abs(ucur2 - umid2) <= tolerance(1) && Abs(vcur2 - vmid2) <= tolerance(2);
+ if (!IsNewPointInvalid
+ && ((TheSvSurfaces*)PtrOnmySvSurfaces)->SeekPoint(umid1, vmid1, umid2, vmid2, MidPoint))
{
- const gp_Pnt& NewPnt = MidPoint.Value();
+ const gp_Pnt& NewPnt = MidPoint.Value();
Standard_Real SqDistNewPrev = NewPnt.SquareDistance(PrevPnt);
Standard_Real SqDistNewCur = NewPnt.SquareDistance(CurPnt);
- IsNewPointInvalid = (SqDistNewPrev <= SqTol3d ||
- SqDistNewCur <= SqTol3d);
+ IsNewPointInvalid = (SqDistNewPrev <= SqTol3d || SqDistNewCur <= SqTol3d);
if (!IsNewPointInvalid)
{
Standard_Real unew1, vnew1, unew2, vnew2;
if (myApproxU1V1)
{
Standard_Real SqDistCurMid1 =
- (ucur1 - umid1)*(ucur1 - umid1)+(vcur1 - vmid1)*(vcur1 - vmid1);
+ (ucur1 - umid1) * (ucur1 - umid1) + (vcur1 - vmid1) * (vcur1 - vmid1);
Standard_Real SqDistMidNew1 =
- (umid1 - unew1)*(umid1 - unew1)+(vmid1 - vnew1)*(vmid1 - vnew1);
+ (umid1 - unew1) * (umid1 - unew1) + (vmid1 - vnew1) * (vmid1 - vnew1);
IsNewPointInvalid = (SqDistMidNew1 > SqDistCurMid1);
}
if (!IsNewPointInvalid)
if (myApproxU2V2)
{
Standard_Real SqDistCurMid2 =
- (ucur2 - umid2)*(ucur2 - umid2)+(vcur2 - vmid2)*(vcur2 - vmid2);
+ (ucur2 - umid2) * (ucur2 - umid2) + (vcur2 - vmid2) * (vcur2 - vmid2);
Standard_Real SqDistMidNew2 =
- (umid2 - unew2)*(umid2 - unew2)+(vmid2 - vnew2)*(vmid2 - vnew2);
+ (umid2 - unew2) * (umid2 - unew2) + (vmid2 - vnew2) * (vmid2 - vnew2);
IsNewPointInvalid = (SqDistMidNew2 > SqDistCurMid2);
}
if (!IsNewPointInvalid)
{
- ResultPntOn2SLine->InsertBefore(theIndbad-theLow+1, MidPoint);
+ ResultPntOn2SLine->InsertBefore(theIndbad - theLow + 1, MidPoint);
OtherLineMade = Standard_True;
}
}
if (!OtherLineMade)
{
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
+ ((TheSvSurfaces*)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
return Standard_False;
}
#ifdef DRAW
- char* name = new char[100];
- Standard_Integer indc = 1;
+ char* name = new char[100];
+ Standard_Integer indc = 1;
Standard_Boolean onfirst = Standard_True;
for (Standard_Integer i = 1; i <= ResultPntOn2SLine->NbPoints(); i++)
{
const IntSurf_PntOn2S& thePoint = ResultPntOn2SLine->Value(i);
- gp_Pnt curPnt = thePoint.Value();
+ gp_Pnt curPnt = thePoint.Value();
Sprintf(name, "p%d_%d", indc, i);
DrawTrSurf::Set(name, curPnt);
gp_Pnt2d curPnt2d = thePoint.ValueOnSurface(onfirst);
DrawTrSurf::Set(name, curPnt2d);
}
#endif
- Handle(TheLine) temp = new TheLine(ResultPntOn2SLine,Standard_False);
- ((TheSvSurfaces *)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
- theNewMultiLine = ApproxInt_MultiLine( temp,
- PtrOnmySvSurfaces,
- nbp3d,
- nbp2d,
- myApproxU1V1,
- myApproxU2V2,
- Xo,Yo,Zo,
- U1o,V1o,
- U2o,V2o,
- p2donfirst,
- 1,ResultPntOn2SLine->NbPoints());
+ Handle(TheLine) temp = new TheLine(ResultPntOn2SLine, Standard_False);
+ ((TheSvSurfaces*)PtrOnmySvSurfaces)->SetUseSolver(aSaveUseSolver);
+ theNewMultiLine = ApproxInt_MultiLine(temp,
+ PtrOnmySvSurfaces,
+ nbp3d,
+ nbp2d,
+ myApproxU1V1,
+ myApproxU2V2,
+ Xo,
+ Yo,
+ Zo,
+ U1o,
+ V1o,
+ U2o,
+ V2o,
+ p2donfirst,
+ 1,
+ ResultPntOn2SLine->NbPoints());
return Standard_True;
}
void ApproxInt_MultiLine::Dump() const
{
- TColgp_Array1OfPnt anArr1(1, 1);
+ TColgp_Array1OfPnt anArr1(1, 1);
TColgp_Array1OfPnt2d anArr2(1, 2);
-
- const Standard_Integer anIndF = FirstPoint(),
- anIndL = LastPoint();
-
- for(Standard_Integer ind = anIndF; ind <= anIndL; ind++)
+
+ const Standard_Integer anIndF = FirstPoint(), anIndL = LastPoint();
+
+ for (Standard_Integer ind = anIndF; ind <= anIndL; ind++)
{
Value(ind, anArr1, anArr2);
printf("%4d [%+10.20f %+10.20f %+10.20f] "
- "[%+10.20f %+10.20f] [%+10.20f %+10.20f]\n",
- ind, anArr1(1).X(), anArr1(1).Y(), anArr1(1).Z(), anArr2(1).X(),
- anArr2(1).Y(),anArr2(2).X(),anArr2(2).Y());
+ "[%+10.20f %+10.20f] [%+10.20f %+10.20f]\n",
+ ind,
+ anArr1(1).X(),
+ anArr1(1).Y(),
+ anArr1(1).Z(),
+ anArr2(1).X(),
+ anArr2(1).Y(),
+ anArr2(2).X(),
+ anArr2(2).Y());
}
}
-
#define TOLTANGENCY 0.0000000001
-
#include <TColStd_Array1OfReal.hxx>
#include <math_FunctionSetRoot.hxx>
#include <Precision.hxx>
-#define Debug(expr) std::cout<<" expr :"<<expr;
+#define Debug(expr) std::cout << " expr :" << expr;
#define MySurf1 MyIntersectionOn2S.Function().AuxillarSurface1()
#define MySurf2 MyIntersectionOn2S.Function().AuxillarSurface2()
+//=================================================================================================
-//--------------------------------------------------------------------------------
-ApproxInt_PrmPrmSvSurfaces::ApproxInt_PrmPrmSvSurfaces( const ThePSurface& Surf1
- ,const ThePSurface& Surf2):
- MyIsTangent(Standard_False),
- MyHasBeenComputed(Standard_False),
- MyIsTangentbis(Standard_False),
- MyHasBeenComputedbis(Standard_False),
- MyIntersectionOn2S(Surf1,Surf2,TOLTANGENCY)
-{
+ApproxInt_PrmPrmSvSurfaces::ApproxInt_PrmPrmSvSurfaces(const ThePSurface& Surf1,
+ const ThePSurface& Surf2)
+ : MyIsTangent(Standard_False),
+ MyHasBeenComputed(Standard_False),
+ MyIsTangentbis(Standard_False),
+ MyHasBeenComputedbis(Standard_False),
+ MyIntersectionOn2S(Surf1, Surf2, TOLTANGENCY)
+{
}
//=======================================================================
-//function : Compute
-//purpose : Computes point on curve, 3D and 2D-tangents of a curve and
+// function : Compute
+// purpose : Computes point on curve, 3D and 2D-tangents of a curve and
// parameters on the surfaces.
//=======================================================================
-Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute( Standard_Real& u1
- ,Standard_Real& v1
- ,Standard_Real& u2
- ,Standard_Real& v2
- ,gp_Pnt& P
- ,gp_Vec& Tg
- ,gp_Vec2d& Tguv1
- ,gp_Vec2d& Tguv2) {
-
- Standard_Real tu1=u1;
- Standard_Real tu2=u2;
- Standard_Real tv1=v1;
- Standard_Real tv2=v2;
-
- if(MyHasBeenComputed) {
- if( (MyParOnS1.X()==u1)&&(MyParOnS1.Y()==v1)
- &&(MyParOnS2.X()==u2)&&(MyParOnS2.Y()==v2)) {
- return(MyIsTangent);
+Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute(Standard_Real& u1,
+ Standard_Real& v1,
+ Standard_Real& u2,
+ Standard_Real& v2,
+ gp_Pnt& P,
+ gp_Vec& Tg,
+ gp_Vec2d& Tguv1,
+ gp_Vec2d& Tguv2)
+{
+
+ Standard_Real tu1 = u1;
+ Standard_Real tu2 = u2;
+ Standard_Real tv1 = v1;
+ Standard_Real tv2 = v2;
+
+ if (MyHasBeenComputed)
+ {
+ if ((MyParOnS1.X() == u1) && (MyParOnS1.Y() == v1) && (MyParOnS2.X() == u2)
+ && (MyParOnS2.Y() == v2))
+ {
+ return (MyIsTangent);
}
- else if(MyHasBeenComputedbis == Standard_False) {
- MyTgbis = MyTg;
- MyTguv1bis = MyTguv1;
- MyTguv2bis = MyTguv2;
- MyPntbis = MyPnt;
- MyParOnS1bis = MyParOnS1;
- MyParOnS2bis = MyParOnS2;
- MyIsTangentbis = MyIsTangent;
- MyHasBeenComputedbis = MyHasBeenComputed;
+ else if (MyHasBeenComputedbis == Standard_False)
+ {
+ MyTgbis = MyTg;
+ MyTguv1bis = MyTguv1;
+ MyTguv2bis = MyTguv2;
+ MyPntbis = MyPnt;
+ MyParOnS1bis = MyParOnS1;
+ MyParOnS2bis = MyParOnS2;
+ MyIsTangentbis = MyIsTangent;
+ MyHasBeenComputedbis = MyHasBeenComputed;
}
}
- if(MyHasBeenComputedbis) {
- if( (MyParOnS1bis.X()==u1)&&(MyParOnS1bis.Y()==v1)
- &&(MyParOnS2bis.X()==u2)&&(MyParOnS2bis.Y()==v2)) {
-
- gp_Vec TV(MyTg);
- gp_Vec2d TV1(MyTguv1);
- gp_Vec2d TV2(MyTguv2);
- gp_Pnt TP(MyPnt);
- gp_Pnt2d TP1(MyParOnS1);
- gp_Pnt2d TP2(MyParOnS2);
- Standard_Boolean TB=MyIsTangent;
+ if (MyHasBeenComputedbis)
+ {
+ if ((MyParOnS1bis.X() == u1) && (MyParOnS1bis.Y() == v1) && (MyParOnS2bis.X() == u2)
+ && (MyParOnS2bis.Y() == v2))
+ {
+
+ gp_Vec TV(MyTg);
+ gp_Vec2d TV1(MyTguv1);
+ gp_Vec2d TV2(MyTguv2);
+ gp_Pnt TP(MyPnt);
+ gp_Pnt2d TP1(MyParOnS1);
+ gp_Pnt2d TP2(MyParOnS2);
+ Standard_Boolean TB = MyIsTangent;
MyTg = MyTgbis;
MyTguv1 = MyTguv1bis;
MyParOnS2 = MyParOnS2bis;
MyIsTangent = MyIsTangentbis;
- MyTgbis = TV;
- MyTguv1bis = TV1;
- MyTguv2bis = TV2;
- MyPntbis = TP;
- MyParOnS1bis = TP1;
- MyParOnS2bis = TP2;
- MyIsTangentbis = TB;
+ MyTgbis = TV;
+ MyTguv1bis = TV1;
+ MyTguv2bis = TV2;
+ MyPntbis = TP;
+ MyParOnS1bis = TP1;
+ MyParOnS2bis = TP2;
+ MyIsTangentbis = TB;
- return(MyIsTangent);
+ return (MyIsTangent);
}
}
-
MyIsTangent = Standard_True;
- Standard_Real aParam[4];//stack vs heap allocation
- TColStd_Array1OfReal Param (aParam[0],1,4);
- Param(1) = u1; Param(2) = v1;
- Param(3) = u2; Param(4) = v2;
- math_FunctionSetRoot Rsnld(MyIntersectionOn2S.Function());
- MyIntersectionOn2S.Perform(Param,Rsnld);
- if (!MyIntersectionOn2S.IsDone()) {
+ Standard_Real aParam[4]; // stack vs heap allocation
+ TColStd_Array1OfReal Param(aParam[0], 1, 4);
+ Param(1) = u1;
+ Param(2) = v1;
+ Param(3) = u2;
+ Param(4) = v2;
+ math_FunctionSetRoot Rsnld(MyIntersectionOn2S.Function());
+ MyIntersectionOn2S.Perform(Param, Rsnld);
+ if (!MyIntersectionOn2S.IsDone())
+ {
MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
- return(Standard_False);
+ return (Standard_False);
}
- if (MyIntersectionOn2S.IsEmpty()) {
- MyIsTangent=Standard_False;
- //cout<<"\n----- Parametree Parametree : IsEmpty ds Compute "<<endl;
- //Debug(u1); Debug(u2); Debug(v1); Debug(v2); cout<<endl;
+ if (MyIntersectionOn2S.IsEmpty())
+ {
+ MyIsTangent = Standard_False;
+ // cout<<"\n----- Parametree Parametree : IsEmpty ds Compute "<<endl;
+ // Debug(u1); Debug(u2); Debug(v1); Debug(v2); cout<<endl;
MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
- return(Standard_False);
+ return (Standard_False);
}
MyHasBeenComputed = Standard_True;
MyPnt = P = MyIntersectionOn2S.Point().Value();
-
- MyIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
- MyParOnS1.SetCoord(tu1,tv1);
- MyParOnS2.SetCoord(tu2,tv2);
-
- if(MyIntersectionOn2S.IsTangent()) {
- MyIsTangent=Standard_False;
+
+ MyIntersectionOn2S.Point().Parameters(u1, v1, u2, v2);
+ MyParOnS1.SetCoord(tu1, tv1);
+ MyParOnS2.SetCoord(tu2, tv2);
+
+ if (MyIntersectionOn2S.IsTangent())
+ {
+ MyIsTangent = Standard_False;
MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
- return(Standard_False);
+ return (Standard_False);
}
- MyTg = Tg = MyIntersectionOn2S.Direction();
+ MyTg = Tg = MyIntersectionOn2S.Direction();
MyTguv1 = Tguv1 = MyIntersectionOn2S.DirectionOnS1();
MyTguv2 = Tguv2 = MyIntersectionOn2S.DirectionOnS2();
//----------------------------------------------------------------------
- //-- Si ( Tg ) TU et TV sont normes
- //--
+ //-- Si ( Tg ) TU et TV sont normes
+ //--
//-- On a Tg = DeltaU * TU + DeltaV * TV
- //--
+ //--
//-- soit : Tg.TU = DeltaU TU.TU + DeltaV TU.TV
- //-- Tg.TV = DeltaU TV.TU + DeltaV TV.TV
- //--
- //-- Donc :
+ //-- Tg.TV = DeltaU TV.TU + DeltaV TV.TV
+ //--
+ //-- Donc :
//--
//-- Tg.TU TV.TV - Tg.TV * TU.TV
//-- DeltaU = -------------------------------
//-- TU.TU TV.TV - (TU.TV)**2
- //--
+ //--
//-- Tg.TV TU.TU - Tg.TU * TU.TV
//-- DeltaV = -------------------------------
//-- TU.TU TV.TV - (TU.TV)**2
//--
//--
- Tg.Normalize(); MyTg = Tg;
+ Tg.Normalize();
+ MyTg = Tg;
- Standard_Real DeltaU,DeltaV;
- gp_Vec TU,TV;
- gp_Pnt Pbid;
- Standard_Real TUTV,TgTU,TgTV,TUTU,TVTV,DIS;
+ Standard_Real DeltaU, DeltaV;
+ gp_Vec TU, TV;
+ gp_Pnt Pbid;
+ Standard_Real TUTV, TgTU, TgTV, TUTU, TVTV, DIS;
//------------------------------------------------------------
//-- Calcul de Tguv1
//--
- ThePSurfaceTool::D1(MySurf1,u1,v1,Pbid,TU,TV);
-
+ ThePSurfaceTool::D1(MySurf1, u1, v1, Pbid, TU, TV);
+
TUTU = TU.Dot(TU);
TVTV = TV.Dot(TV);
TUTV = TU.Dot(TV);
TgTU = Tg.Dot(TU);
TgTV = Tg.Dot(TV);
DIS = TUTU * TVTV - TUTV * TUTV;
- if(fabs(DIS)<Precision::Angular()) {
- MyIsTangent=Standard_False;
+ if (fabs(DIS) < Precision::Angular())
+ {
+ MyIsTangent = Standard_False;
MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
- return(Standard_False);
+ return (Standard_False);
}
-
- DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ;
- DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
- Tguv1.SetCoord(DeltaU,DeltaV); MyTguv1 = Tguv1;
+ DeltaU = (TgTU * TVTV - TgTV * TUTV) / DIS;
+ DeltaV = (TgTV * TUTU - TgTU * TUTV) / DIS;
+
+ Tguv1.SetCoord(DeltaU, DeltaV);
+ MyTguv1 = Tguv1;
//------------------------------------------------------------
//-- Calcul de Tguv2
- //--
- ThePSurfaceTool::D1(MySurf2,u2,v2,Pbid,TU,TV);
+ //--
+ ThePSurfaceTool::D1(MySurf2, u2, v2, Pbid, TU, TV);
TUTU = TU.Dot(TU);
TVTV = TV.Dot(TV);
TgTU = Tg.Dot(TU);
TgTV = Tg.Dot(TV);
DIS = TUTU * TVTV - TUTV * TUTV;
- if(fabs(DIS)<Precision::Angular()) {
- MyIsTangent=Standard_False;
+ if (fabs(DIS) < Precision::Angular())
+ {
+ MyIsTangent = Standard_False;
MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
- return(Standard_False);
+ return (Standard_False);
}
- DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ;
- DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
-
- Tguv2.SetCoord(DeltaU,DeltaV); MyTguv2 = Tguv2;
+ DeltaU = (TgTU * TVTV - TgTV * TUTV) / DIS;
+ DeltaV = (TgTV * TUTU - TgTU * TUTV) / DIS;
- return(Standard_True);
+ Tguv2.SetCoord(DeltaU, DeltaV);
+ MyTguv2 = Tguv2;
+
+ return (Standard_True);
}
-//--------------------------------------------------------------------------------
+
+//=================================================================================================
+
void ApproxInt_PrmPrmSvSurfaces::Pnt(const Standard_Real u1,
- const Standard_Real v1,
- const Standard_Real u2,
- const Standard_Real v2,
- gp_Pnt& P) {
- gp_Pnt aP;
- gp_Vec aT;
- gp_Vec2d aTS1,aTS2;
- Standard_Real tu1=u1;
- Standard_Real tu2=u2;
- Standard_Real tv1=v1;
- Standard_Real tv2=v2;
- this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
- P=MyPnt;
+ const Standard_Real v1,
+ const Standard_Real u2,
+ const Standard_Real v2,
+ gp_Pnt& P)
+{
+ gp_Pnt aP;
+ gp_Vec aT;
+ gp_Vec2d aTS1, aTS2;
+ Standard_Real tu1 = u1;
+ Standard_Real tu2 = u2;
+ Standard_Real tv1 = v1;
+ Standard_Real tv2 = v2;
+ this->Compute(tu1, tv1, tu2, tv2, aP, aT, aTS1, aTS2);
+ P = MyPnt;
}
//=======================================================================
-//function : SeekPoint
-//purpose : Computes point on curve and
+// function : SeekPoint
+// purpose : Computes point on curve and
// parameters on the surfaces.
//=======================================================================
Standard_Boolean ApproxInt_PrmPrmSvSurfaces::SeekPoint(const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2,
- IntSurf_PntOn2S& Point)
+ IntSurf_PntOn2S& Point)
{
- gp_Pnt aP;
- gp_Vec aT;
- gp_Vec2d aTS1,aTS2;
- Standard_Real tu1=u1;
- Standard_Real tu2=u2;
- Standard_Real tv1=v1;
- Standard_Real tv2=v2;
- if (!Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2))
+ gp_Pnt aP;
+ gp_Vec aT;
+ gp_Vec2d aTS1, aTS2;
+ Standard_Real tu1 = u1;
+ Standard_Real tu2 = u2;
+ Standard_Real tv1 = v1;
+ Standard_Real tv2 = v2;
+ if (!Compute(tu1, tv1, tu2, tv2, aP, aT, aTS1, aTS2))
return Standard_False;
-
- Point.SetValue(aP, tu1,tv1,tu2,tv2);
+
+ Point.SetValue(aP, tu1, tv1, tu2, tv2);
return Standard_True;
}
-//--------------------------------------------------------------------------------
+
+//=================================================================================================
+
Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Tangency(const Standard_Real u1,
- const Standard_Real v1,
- const Standard_Real u2,
- const Standard_Real v2,
- gp_Vec& T) {
- gp_Pnt aP;
- gp_Vec aT;
- gp_Vec2d aTS1,aTS2;
- Standard_Real tu1=u1;
- Standard_Real tu2=u2;
- Standard_Real tv1=v1;
- Standard_Real tv2=v2;
- Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
- T=MyTg;
- return(t);
+ const Standard_Real v1,
+ const Standard_Real u2,
+ const Standard_Real v2,
+ gp_Vec& T)
+{
+ gp_Pnt aP;
+ gp_Vec aT;
+ gp_Vec2d aTS1, aTS2;
+ Standard_Real tu1 = u1;
+ Standard_Real tu2 = u2;
+ Standard_Real tv1 = v1;
+ Standard_Real tv2 = v2;
+ Standard_Boolean t = this->Compute(tu1, tv1, tu2, tv2, aP, aT, aTS1, aTS2);
+ T = MyTg;
+ return (t);
}
-//--------------------------------------------------------------------------------
+
+//=================================================================================================
+
Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf1(const Standard_Real u1,
- const Standard_Real v1,
- const Standard_Real u2,
- const Standard_Real v2,
- gp_Vec2d& T) {
- gp_Pnt aP;
- gp_Vec aT;
- gp_Vec2d aTS1,aTS2;
- Standard_Real tu1=u1;
- Standard_Real tu2=u2;
- Standard_Real tv1=v1;
- Standard_Real tv2=v2;
- Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
- T=MyTguv1;
- return(t);
-}
-//--------------------------------------------------------------------------------
-Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf2(const Standard_Real u1,
- const Standard_Real v1,
- const Standard_Real u2,
- const Standard_Real v2,
- gp_Vec2d& T) {
- gp_Pnt aP;
- gp_Vec aT;
- gp_Vec2d aTS1,aTS2;
- Standard_Real tu1=u1;
- Standard_Real tu2=u2;
- Standard_Real tv1=v1;
- Standard_Real tv2=v2;
- Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
- T=MyTguv2;
- return(t);
+ const Standard_Real v1,
+ const Standard_Real u2,
+ const Standard_Real v2,
+ gp_Vec2d& T)
+{
+ gp_Pnt aP;
+ gp_Vec aT;
+ gp_Vec2d aTS1, aTS2;
+ Standard_Real tu1 = u1;
+ Standard_Real tu2 = u2;
+ Standard_Real tv1 = v1;
+ Standard_Real tv2 = v2;
+ Standard_Boolean t = this->Compute(tu1, tv1, tu2, tv2, aP, aT, aTS1, aTS2);
+ T = MyTguv1;
+ return (t);
}
-//--------------------------------------------------------------------------------
+//=================================================================================================
+Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf2(const Standard_Real u1,
+ const Standard_Real v1,
+ const Standard_Real u2,
+ const Standard_Real v2,
+ gp_Vec2d& T)
+{
+ gp_Pnt aP;
+ gp_Vec aT;
+ gp_Vec2d aTS1, aTS2;
+ Standard_Real tu1 = u1;
+ Standard_Real tu2 = u2;
+ Standard_Real tv1 = v1;
+ Standard_Real tv2 = v2;
+ Standard_Boolean t = this->Compute(tu1, tv1, tu2, tv2, aP, aT, aTS1, aTS2);
+ T = MyTguv2;
+ return (t);
+}
+//--------------------------------------------------------------------------------
#if 0
//------------------------------------------------------------
return(Standard_True);
}
#endif
-
-
-
-
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
-
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Pnt2d.hxx>
+#define THECURVE1 (*((TheCurve*)thecurve1))
+#define THECURVE2 (*((TheCurve*)thecurve2))
-#define THECURVE1 (*((TheCurve *)thecurve1))
-#define THECURVE2 (*((TheCurve *)thecurve2))
+//=================================================================================================
-//======================================================================
-IntCurve_DistBetweenPCurvesGen::IntCurve_DistBetweenPCurvesGen( const TheCurve& C1
- ,const TheCurve& C2) {
- thecurve1 = (Standard_Address) (&C1);
- thecurve2 = (Standard_Address )(&C2);
+IntCurve_DistBetweenPCurvesGen::IntCurve_DistBetweenPCurvesGen(const TheCurve& C1,
+ const TheCurve& C2)
+{
+ thecurve1 = (Standard_Address)(&C1);
+ thecurve2 = (Standard_Address)(&C2);
}
-//======================================================================
-Standard_Integer IntCurve_DistBetweenPCurvesGen::NbVariables(void) const {
- return(2);
+
+//=================================================================================================
+
+Standard_Integer IntCurve_DistBetweenPCurvesGen::NbVariables(void) const
+{
+ return (2);
}
-//======================================================================
-Standard_Integer IntCurve_DistBetweenPCurvesGen::NbEquations(void) const {
- return(2);
+
+//=================================================================================================
+
+Standard_Integer IntCurve_DistBetweenPCurvesGen::NbEquations(void) const
+{
+ return (2);
}
-//======================================================================
-Standard_Boolean IntCurve_DistBetweenPCurvesGen::Value
- (const math_Vector& X
- ,math_Vector& F)
+
+//=================================================================================================
+
+Standard_Boolean IntCurve_DistBetweenPCurvesGen::Value(const math_Vector& X, math_Vector& F)
{
- gp_Pnt2d P1,P2;
- TheCurveTool::D0(THECURVE1,X(1),P1);
- TheCurveTool::D0(THECURVE2,X(2),P2);
+ gp_Pnt2d P1, P2;
+ TheCurveTool::D0(THECURVE1, X(1), P1);
+ TheCurveTool::D0(THECURVE2, X(2), P2);
F(1) = P1.X() - P2.X();
F(2) = P1.Y() - P2.Y();
- return(Standard_True);
+ return (Standard_True);
}
-//======================================================================
-Standard_Boolean IntCurve_DistBetweenPCurvesGen::Derivatives
- (const math_Vector& X
- ,math_Matrix& D)
+
+//=================================================================================================
+
+Standard_Boolean IntCurve_DistBetweenPCurvesGen::Derivatives(const math_Vector& X, math_Matrix& D)
{
gp_Vec2d T;
gp_Pnt2d P;
- TheCurveTool::D1(THECURVE1,X(1),P,T);
- D.Value(1,1) = T.X();
- D.Value(2,1) = T.Y();
-
- TheCurveTool::D1(THECURVE2,X(2),P,T);
- D.Value(1,2) = -(T.X());
- D.Value(2,2) = -(T.Y());
-
-return(Standard_True);
+ TheCurveTool::D1(THECURVE1, X(1), P, T);
+ D.Value(1, 1) = T.X();
+ D.Value(2, 1) = T.Y();
+
+ TheCurveTool::D1(THECURVE2, X(2), P, T);
+ D.Value(1, 2) = -(T.X());
+ D.Value(2, 2) = -(T.Y());
+
+ return (Standard_True);
}
-//======================================================================
-Standard_Boolean IntCurve_DistBetweenPCurvesGen::Values
- (const math_Vector& X
- ,math_Vector& F
- ,math_Matrix& D)
+
+//=================================================================================================
+
+Standard_Boolean IntCurve_DistBetweenPCurvesGen::Values(const math_Vector& X,
+ math_Vector& F,
+ math_Matrix& D)
{
gp_Vec2d T;
- gp_Pnt2d P1,P2;
-
- TheCurveTool::D1(THECURVE1,X(1),P1,T);
- D.Value(1,1) = T.X();
- D.Value(2,1) = T.Y();
-
- TheCurveTool::D1(THECURVE2,X(2),P2,T);
- D.Value(1,2) = -(T.X());
- D.Value(2,2) = -(T.Y());
+ gp_Pnt2d P1, P2;
+
+ TheCurveTool::D1(THECURVE1, X(1), P1, T);
+ D.Value(1, 1) = T.X();
+ D.Value(2, 1) = T.Y();
+
+ TheCurveTool::D1(THECURVE2, X(2), P2, T);
+ D.Value(1, 2) = -(T.X());
+ D.Value(2, 2) = -(T.Y());
F.Value(1) = P1.X() - P2.X();
F.Value(2) = P1.Y() - P2.Y();
-return(Standard_True);
+ return (Standard_True);
}
-//======================================================================
-
+
+//======================================================================
#include <math_NewtonFunctionSetRoot.hxx>
#include <gp_Vec2d.hxx>
-
-
//======================================================================
-//===
+//===
//======================================================================
-IntCurve_ExactIntersectionPoint::IntCurve_ExactIntersectionPoint(const TheCurve& C1,const TheCurve& C2,const Standard_Real Tol)
+IntCurve_ExactIntersectionPoint::IntCurve_ExactIntersectionPoint(const TheCurve& C1,
+ const TheCurve& C2,
+ const Standard_Real Tol)
: done(Standard_False),
nbroots(0),
- myTol(Tol*Tol),
- FctDist(C1,C2),
- ToleranceVector(1,2),
- BInfVector(1,2),
- BSupVector(1,2),
- StartingPoint(1,2),
- Root(1,2),
+ myTol(Tol * Tol),
+ FctDist(C1, C2),
+ ToleranceVector(1, 2),
+ BInfVector(1, 2),
+ BSupVector(1, 2),
+ StartingPoint(1, 2),
+ Root(1, 2),
anErrorOccurred(Standard_False)
{
ToleranceVector.Value(1) = TheCurveTool::EpsX(C1);
ToleranceVector.Value(2) = TheCurveTool::EpsX(C2);
}
- //----------------------------------------------------------------------
-void IntCurve_ExactIntersectionPoint::Perform( const IntCurve_ThePolygon2d& Poly1
- ,const IntCurve_ThePolygon2d& Poly2
- ,Standard_Integer& NumSegOn1
- ,Standard_Integer& NumSegOn2
- ,Standard_Real& ParamOnSeg1
- ,Standard_Real& ParamOnSeg2)
+
+//=================================================================================================
+
+void IntCurve_ExactIntersectionPoint::Perform(const IntCurve_ThePolygon2d& Poly1,
+ const IntCurve_ThePolygon2d& Poly2,
+ Standard_Integer& NumSegOn1,
+ Standard_Integer& NumSegOn2,
+ Standard_Real& ParamOnSeg1,
+ Standard_Real& ParamOnSeg2)
{
//----------------------------------------------------------------------
- //-- On prend comme bornes de recherches :
+ //-- On prend comme bornes de recherches :
//--
- //-- Segment : i-1 i i+1 i+2
+ //-- Segment : i-1 i i+1 i+2
//--
//-- |---------|-----X-------|---------|----------|
//-- Inf Sup
- //--
- if(NumSegOn1 >= Poly1.NbSegments() && ParamOnSeg1==0.0) {
- NumSegOn1--; ParamOnSeg1 = 1.0;
+ //--
+ if (NumSegOn1 >= Poly1.NbSegments() && ParamOnSeg1 == 0.0)
+ {
+ NumSegOn1--;
+ ParamOnSeg1 = 1.0;
}
- if(NumSegOn2 >= Poly2.NbSegments() && ParamOnSeg2==0.0) {
- NumSegOn2--; ParamOnSeg2 = 1.0;
+ if (NumSegOn2 >= Poly2.NbSegments() && ParamOnSeg2 == 0.0)
+ {
+ NumSegOn2--;
+ ParamOnSeg2 = 1.0;
}
- if(NumSegOn1 <=0) {
- NumSegOn1=1; ParamOnSeg1 = 0.0;
+ if (NumSegOn1 <= 0)
+ {
+ NumSegOn1 = 1;
+ ParamOnSeg1 = 0.0;
}
- if(NumSegOn2 <=0) {
- NumSegOn2=1; ParamOnSeg2 = 0.0;
+ if (NumSegOn2 <= 0)
+ {
+ NumSegOn2 = 1;
+ ParamOnSeg2 = 0.0;
}
- StartingPoint.Value(1) = Poly1.ApproxParamOnCurve(NumSegOn1,ParamOnSeg1);
- if(NumSegOn1<=2) BInfVector.Value(1)= Poly1.InfParameter();
- else BInfVector.Value(1)= Poly1.ApproxParamOnCurve(NumSegOn1-1,(Standard_Real)0.0);
- if(NumSegOn1 >= (Poly1.NbSegments() -2)) BSupVector.Value(1)= Poly1.SupParameter();
- else BSupVector.Value(1)= Poly1.ApproxParamOnCurve(NumSegOn1+2,(Standard_Real)0.0);
-
- StartingPoint.Value(2) = Poly2.ApproxParamOnCurve(NumSegOn2,ParamOnSeg2);
- if(NumSegOn2<=2) BInfVector.Value(2)= Poly2.InfParameter();
- else BInfVector.Value(2)= Poly2.ApproxParamOnCurve(NumSegOn2-1,(Standard_Real)0.0);
- if(NumSegOn2 >= (Poly2.NbSegments() -2)) BSupVector.Value(2)= Poly2.SupParameter();
- else BSupVector.Value(2)= Poly2.ApproxParamOnCurve(NumSegOn2+2,(Standard_Real)0.0);
+ StartingPoint.Value(1) = Poly1.ApproxParamOnCurve(NumSegOn1, ParamOnSeg1);
+ if (NumSegOn1 <= 2)
+ BInfVector.Value(1) = Poly1.InfParameter();
+ else
+ BInfVector.Value(1) = Poly1.ApproxParamOnCurve(NumSegOn1 - 1, (Standard_Real)0.0);
+ if (NumSegOn1 >= (Poly1.NbSegments() - 2))
+ BSupVector.Value(1) = Poly1.SupParameter();
+ else
+ BSupVector.Value(1) = Poly1.ApproxParamOnCurve(NumSegOn1 + 2, (Standard_Real)0.0);
+ StartingPoint.Value(2) = Poly2.ApproxParamOnCurve(NumSegOn2, ParamOnSeg2);
+ if (NumSegOn2 <= 2)
+ BInfVector.Value(2) = Poly2.InfParameter();
+ else
+ BInfVector.Value(2) = Poly2.ApproxParamOnCurve(NumSegOn2 - 1, (Standard_Real)0.0);
+ if (NumSegOn2 >= (Poly2.NbSegments() - 2))
+ BSupVector.Value(2) = Poly2.SupParameter();
+ else
+ BSupVector.Value(2) = Poly2.ApproxParamOnCurve(NumSegOn2 + 2, (Standard_Real)0.0);
IntCurve_ExactIntersectionPoint::MathPerform();
- if(nbroots == 0) {
+ if (nbroots == 0)
+ {
// Standard_Real DeflectionOn1 = Poly1.DeflectionOverEstimation();
Poly1.DeflectionOverEstimation();
// Standard_Real DeflectionOn2 = Poly2.DeflectionOverEstimation();
Poly2.DeflectionOverEstimation();
// if(DeflectionOn2 > Poly1.BeginOfSeg(NumSegOn1).Distance(Poly1.EndOfSeg(NumSegOn1))) {
{
- //-- On risque de donner des bornes sur la courbe 1 trop etroites.
- Standard_Integer diff=1;
- Standard_Real AnBinfVector = BInfVector.Value(1);
- Standard_Real AnBsupVector = BSupVector.Value(1);
+ //-- On risque de donner des bornes sur la courbe 1 trop etroites.
+ Standard_Integer diff = 1;
+ Standard_Real AnBinfVector = BInfVector.Value(1);
+ Standard_Real AnBsupVector = BSupVector.Value(1);
//---------------- On elargit les bornes par la gauche --------------------
- do {
+ do
+ {
diff++;
- if((NumSegOn1-diff)<=1) {
- BInfVector.Value(1)= Poly1.InfParameter();
- diff=0;
+ if ((NumSegOn1 - diff) <= 1)
+ {
+ BInfVector.Value(1) = Poly1.InfParameter();
+ diff = 0;
}
- else BInfVector.Value(1)= Poly1.ApproxParamOnCurve(NumSegOn1-diff,(Standard_Real)0.0);
+ else
+ BInfVector.Value(1) = Poly1.ApproxParamOnCurve(NumSegOn1 - diff, (Standard_Real)0.0);
IntCurve_ExactIntersectionPoint::MathPerform();
- //-- le 18 nov 97
- if(diff>3) diff+=NumSegOn1/2;
- }
- while( nbroots==0 && diff!=0);
- //---------------- On elargit les bornes par la droite --------------------
- if(nbroots==0) {
+ //-- le 18 nov 97
+ if (diff > 3)
+ diff += NumSegOn1 / 2;
+ } while (nbroots == 0 && diff != 0);
+ //---------------- On elargit les bornes par la droite --------------------
+ if (nbroots == 0)
+ {
BInfVector.Value(1) = AnBinfVector;
- diff=1;
- do {
+ diff = 1;
+ do
+ {
diff++;
- if((NumSegOn1+diff) >= (Poly1.NbSegments() -1)) {
- BSupVector.Value(1)= Poly1.SupParameter();
- diff=0;
+ if ((NumSegOn1 + diff) >= (Poly1.NbSegments() - 1))
+ {
+ BSupVector.Value(1) = Poly1.SupParameter();
+ diff = 0;
}
- else BSupVector.Value(1)= Poly1.ApproxParamOnCurve(NumSegOn1+1+diff,(Standard_Real)0.0);
+ else
+ BSupVector.Value(1) =
+ Poly1.ApproxParamOnCurve(NumSegOn1 + 1 + diff, (Standard_Real)0.0);
IntCurve_ExactIntersectionPoint::MathPerform();
- //-- le 18 nov 97
- if(diff>3) diff+=1+(Poly1.NbSegments()-NumSegOn1)/2;
- }
- while( nbroots==0 && diff!=0);
+ //-- le 18 nov 97
+ if (diff > 3)
+ diff += 1 + (Poly1.NbSegments() - NumSegOn1) / 2;
+ } while (nbroots == 0 && diff != 0);
}
BSupVector.Value(1) = AnBsupVector;
}
- if(nbroots==0) {
- //-- On risque de donner des bornes sur la courbe 1 trop etroites.
- Standard_Integer diff=1;
- Standard_Real AnBinfVector = BInfVector.Value(2);
- Standard_Real AnBsupVector = BSupVector.Value(2);
+ if (nbroots == 0)
+ {
+ //-- On risque de donner des bornes sur la courbe 1 trop etroites.
+ Standard_Integer diff = 1;
+ Standard_Real AnBinfVector = BInfVector.Value(2);
+ Standard_Real AnBsupVector = BSupVector.Value(2);
//---------------- On elargit les bornes par la gauche --------------------
- do {
+ do
+ {
diff++;
- if((NumSegOn2-diff)<=1) {
- BInfVector.Value(2)= Poly2.InfParameter();
- diff=0;
+ if ((NumSegOn2 - diff) <= 1)
+ {
+ BInfVector.Value(2) = Poly2.InfParameter();
+ diff = 0;
}
- else BInfVector.Value(2)= Poly2.ApproxParamOnCurve(NumSegOn2-diff,(Standard_Real)0.0);
+ else
+ BInfVector.Value(2) = Poly2.ApproxParamOnCurve(NumSegOn2 - diff, (Standard_Real)0.0);
IntCurve_ExactIntersectionPoint::MathPerform();
- //-- le 18 nov 97
- if(diff>3) diff+=NumSegOn2/2;
- }
- while( nbroots==0 && diff!=0);
- //---------------- On elargit les bornes par la droite --------------------
- if(nbroots==0)
- {
+ //-- le 18 nov 97
+ if (diff > 3)
+ diff += NumSegOn2 / 2;
+ } while (nbroots == 0 && diff != 0);
+ //---------------- On elargit les bornes par la droite --------------------
+ if (nbroots == 0)
+ {
BInfVector.Value(2) = AnBinfVector;
- diff=1;
- do {
+ diff = 1;
+ do
+ {
diff++;
- if((NumSegOn2+diff) >= (Poly2.NbSegments() -1)) {
- BSupVector.Value(2)= Poly2.SupParameter();
- diff=0;
+ if ((NumSegOn2 + diff) >= (Poly2.NbSegments() - 1))
+ {
+ BSupVector.Value(2) = Poly2.SupParameter();
+ diff = 0;
}
- else BSupVector.Value(2)= Poly2.ApproxParamOnCurve(NumSegOn2+1+diff,(Standard_Real)0.0);
+ else
+ BSupVector.Value(2) =
+ Poly2.ApproxParamOnCurve(NumSegOn2 + 1 + diff, (Standard_Real)0.0);
IntCurve_ExactIntersectionPoint::MathPerform();
- //-- le 18 nov 97
- if(diff>3) diff+=1+(Poly2.NbSegments()-NumSegOn2)/2;
- }
- while( nbroots==0 && diff!=0);
+ //-- le 18 nov 97
+ if (diff > 3)
+ diff += 1 + (Poly2.NbSegments() - NumSegOn2) / 2;
+ } while (nbroots == 0 && diff != 0);
}
BSupVector.Value(2) = AnBsupVector;
}
}
}
- //----------------------------------------------------------------------
-void IntCurve_ExactIntersectionPoint::Perform( const Standard_Real Uo
- ,const Standard_Real Vo
- ,const Standard_Real UInf
- ,const Standard_Real VInf
- ,const Standard_Real USup
- ,const Standard_Real VSup) {
-
- done = Standard_True;
-
- BInfVector.Value(1) = UInf;
- BInfVector.Value(2) = VInf;
- BSupVector.Value(1) = USup;
- BSupVector.Value(2) = VSup;
- StartingPoint.Value(1) = Uo;
- StartingPoint.Value(2) = Vo;
-
- IntCurve_ExactIntersectionPoint::MathPerform();
-
- }
- //----------------------------------------------------------------------
-Standard_Integer IntCurve_ExactIntersectionPoint::NbRoots() const { return(nbroots); }
- //----------------------------------------------------------------------
-void IntCurve_ExactIntersectionPoint::Roots(Standard_Real& U,Standard_Real& V) {
- U=Root.Value(1);
- V=Root.Value(2);
- }
- //----------------------------------------------------------------------
+//=================================================================================================
+
+void IntCurve_ExactIntersectionPoint::Perform(const Standard_Real Uo,
+ const Standard_Real Vo,
+ const Standard_Real UInf,
+ const Standard_Real VInf,
+ const Standard_Real USup,
+ const Standard_Real VSup)
+{
+
+ done = Standard_True;
+
+ BInfVector.Value(1) = UInf;
+ BInfVector.Value(2) = VInf;
+ BSupVector.Value(1) = USup;
+ BSupVector.Value(2) = VSup;
+ StartingPoint.Value(1) = Uo;
+ StartingPoint.Value(2) = Vo;
+
+ IntCurve_ExactIntersectionPoint::MathPerform();
+}
+
+//=================================================================================================
+
+Standard_Integer IntCurve_ExactIntersectionPoint::NbRoots() const
+{
+ return (nbroots);
+}
+
+//=================================================================================================
+
+void IntCurve_ExactIntersectionPoint::Roots(Standard_Real& U, Standard_Real& V)
+{
+ U = Root.Value(1);
+ V = Root.Value(2);
+}
+
+//=================================================================================================
void IntCurve_ExactIntersectionPoint::MathPerform(void)
{
math_FunctionSetRoot Fct(FctDist, ToleranceVector, 60);
Fct.Perform(FctDist, StartingPoint, BInfVector, BSupVector);
- if(Fct.IsDone()) {
- Fct.Root(Root); nbroots = 1;
- math_Vector XY(1,2);
- FctDist.Value(Root,XY);
- Standard_Real dist2 = ((XY(1)*XY(1)+XY(2)*XY(2)));
+ if (Fct.IsDone())
+ {
+ Fct.Root(Root);
+ nbroots = 1;
+ math_Vector XY(1, 2);
+ FctDist.Value(Root, XY);
+ Standard_Real dist2 = ((XY(1) * XY(1) + XY(2) * XY(2)));
- if(dist2 > myTol)
+ if (dist2 > myTol)
{
nbroots = 0;
}
}
- else {
+ else
+ {
anErrorOccurred = Standard_True;
- nbroots = 0;
+ nbroots = 0;
}
}
-
+
//======================================================================
Standard_Boolean IntCurve_ExactIntersectionPoint::AnErrorOccurred() const
#include <IntRes2d_Domain.hxx>
#include <IntCurve_IConicTool.hxx>
-//--------------------------------------------------------------------------------
-IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen (const gp_Circ2d& C,
- const IntRes2d_Domain& D1,
- const ThePCurve& PCurve,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- if(!D1.IsClosed()) {
+//=================================================================================================
+
+IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen(const gp_Circ2d& C,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& PCurve,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ if (!D1.IsClosed())
+ {
IntRes2d_Domain D(D1);
- D.SetEquivalentParameters(D1.FirstParameter(),D1.FirstParameter()+M_PI+M_PI);
- Perform(IntCurve_IConicTool(C),D,PCurve,D2,TolConf,Tol);
+ D.SetEquivalentParameters(D1.FirstParameter(), D1.FirstParameter() + M_PI + M_PI);
+ Perform(IntCurve_IConicTool(C), D, PCurve, D2, TolConf, Tol);
//-- throw Standard_ConstructionError("Domaine incorrect");
}
- else {
- Perform(IntCurve_IConicTool(C),D1,PCurve,D2,TolConf,Tol);
+ else
+ {
+ Perform(IntCurve_IConicTool(C), D1, PCurve, D2, TolConf, Tol);
}
}
-//--------------------------------------------------------------------------------
-IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen (const gp_Elips2d& E,
- const IntRes2d_Domain& D1,
- const ThePCurve& PCurve,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- if(!D1.IsClosed()) {
+
+//=================================================================================================
+
+IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen(const gp_Elips2d& E,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& PCurve,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ if (!D1.IsClosed())
+ {
IntRes2d_Domain D(D1);
- D.SetEquivalentParameters(D1.FirstParameter(),D1.FirstParameter()+M_PI+M_PI);
- Perform(IntCurve_IConicTool(E),D,PCurve,D2,TolConf,Tol);
+ D.SetEquivalentParameters(D1.FirstParameter(), D1.FirstParameter() + M_PI + M_PI);
+ Perform(IntCurve_IConicTool(E), D, PCurve, D2, TolConf, Tol);
//-- throw Standard_ConstructionError("Domaine incorrect");
}
- else {
- Perform(IntCurve_IConicTool(E),D1,PCurve,D2,TolConf,Tol);
+ else
+ {
+ Perform(IntCurve_IConicTool(E), D1, PCurve, D2, TolConf, Tol);
}
}
-//--------------------------------------------------------------------------------
-IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen (const gp_Parab2d& Prb,
- const IntRes2d_Domain& D1,
- const ThePCurve& PCurve,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
-
- Perform(IntCurve_IConicTool(Prb),D1,PCurve,D2,TolConf,Tol);
-}
-//--------------------------------------------------------------------------------
-IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen (const gp_Hypr2d& H,
- const IntRes2d_Domain& D1,
- const ThePCurve& PCurve,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
-
- Perform(IntCurve_IConicTool(H),D1,PCurve,D2,TolConf,Tol);
+
+//=================================================================================================
+
+IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen(const gp_Parab2d& Prb,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& PCurve,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+
+ Perform(IntCurve_IConicTool(Prb), D1, PCurve, D2, TolConf, Tol);
}
-//--------------------------------------------------------------------------------
+//=================================================================================================
+IntCurve_IntConicCurveGen::IntCurve_IntConicCurveGen(const gp_Hypr2d& H,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& PCurve,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+
+ Perform(IntCurve_IConicTool(H), D1, PCurve, D2, TolConf, Tol);
+}
+
+//--------------------------------------------------------------------------------
#include <GeomAbs_CurveType.hxx>
-
#include <IntCurve_IntConicConic.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <TColStd_Array1OfReal.hxx>
-
-void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
IntRes2d_Domain D1;
- Standard_Real TolDomain = Tol;
- if(Tol<TolConf) TolDomain = TolConf;
+ Standard_Real TolDomain = Tol;
+ if (Tol < TolConf)
+ TolDomain = TolConf;
GeomAbs_CurveType typ = TheCurveTool::GetType(C);
- switch(typ) {
- case GeomAbs_Ellipse:
- case GeomAbs_Circle:
- case GeomAbs_Parabola:
- case GeomAbs_Hyperbola:
- case GeomAbs_Line:
- ResetFields();
- done = Standard_True;
- return;
-
- default:
- {
+ switch (typ)
+ {
+ case GeomAbs_Ellipse:
+ case GeomAbs_Circle:
+ case GeomAbs_Parabola:
+ case GeomAbs_Hyperbola:
+ case GeomAbs_Line:
+ ResetFields();
+ done = Standard_True;
+ return;
+
+ default: {
Standard_Real paraminf = TheCurveTool::FirstParameter(C);
Standard_Real paramsup = TheCurveTool::LastParameter(C);
- if (Precision::IsInfinite(paraminf) && Precision::IsInfinite(paramsup)) {
+ if (Precision::IsInfinite(paraminf) && Precision::IsInfinite(paramsup))
+ {
done = Standard_False;
return;
}
//
- if(paraminf>-Precision::Infinite()) {
- if(paramsup<Precision::Infinite()) {
- //-- paraminf-----------paramsup
- D1.SetValues(TheCurveTool::Value(C,paraminf),
- paraminf,
- TolDomain,
- TheCurveTool::Value(C,paramsup),
- paramsup,
- TolDomain);
- }
- else {
- //-- paraminf------------...
- D1.SetValues(TheCurveTool::Value(C,paraminf),
- paraminf,
- TolDomain,
- Standard_True);
- }
+ if (paraminf > -Precision::Infinite())
+ {
+ if (paramsup < Precision::Infinite())
+ {
+ //-- paraminf-----------paramsup
+ D1.SetValues(TheCurveTool::Value(C, paraminf),
+ paraminf,
+ TolDomain,
+ TheCurveTool::Value(C, paramsup),
+ paramsup,
+ TolDomain);
+ }
+ else
+ {
+ //-- paraminf------------...
+ D1.SetValues(TheCurveTool::Value(C, paraminf), paraminf, TolDomain, Standard_True);
+ }
}
- else {
- if(paramsup<Precision::Infinite()) {
- //-- ...-----------------paramsup
- D1.SetValues(TheCurveTool::Value(C,paramsup),
- paramsup,
- TolDomain,
- Standard_False);
- }
+ else
+ {
+ if (paramsup < Precision::Infinite())
+ {
+ //-- ...-----------------paramsup
+ D1.SetValues(TheCurveTool::Value(C, paramsup), paramsup, TolDomain, Standard_False);
+ }
}
this->ResetFields();
- intcurvcurv.SetReversedParameters(Standard_False);
- intcurvcurv.Perform(C,D1,TolConf,Tol);
+ intcurvcurv.SetReversedParameters(Standard_False);
+ intcurvcurv.Perform(C, D1, TolConf, Tol);
this->SetValues(intcurvcurv);
done = Standard_True;
}
}
}
-
-void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C,
- const IntRes2d_Domain& D,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C,
+ const IntRes2d_Domain& D,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
GeomAbs_CurveType typ = TheCurveTool::GetType(C);
- switch(typ) {
- case GeomAbs_Ellipse:
- case GeomAbs_Circle:
- case GeomAbs_Parabola:
- case GeomAbs_Hyperbola:
- case GeomAbs_Line:
- ResetFields();
- done = Standard_True;
- return;
-
- default:
- {
+ switch (typ)
+ {
+ case GeomAbs_Ellipse:
+ case GeomAbs_Circle:
+ case GeomAbs_Parabola:
+ case GeomAbs_Hyperbola:
+ case GeomAbs_Line:
+ ResetFields();
+ done = Standard_True;
+ return;
+
+ default: {
this->ResetFields();
- intcurvcurv.SetReversedParameters(Standard_False);
- intcurvcurv.Perform(C,D,TolConf,Tol);
+ intcurvcurv.SetReversedParameters(Standard_False);
+ intcurvcurv.Perform(C, D, TolConf, Tol);
this->SetValues(intcurvcurv);
done = Standard_True;
}
}
}
+//=================================================================================================
-
-
-//----------------------------------------------------------------------
-IntRes2d_Domain IntCurve_IntCurveCurveGen::ComputeDomain(const TheCurve& C1,
- const Standard_Real TolDomain) const {
+IntRes2d_Domain IntCurve_IntCurveCurveGen::ComputeDomain(const TheCurve& C1,
+ const Standard_Real TolDomain) const
+{
IntRes2d_Domain D1;
GeomAbs_CurveType typ = TheCurveTool::GetType(C1);
- switch(typ) {
-
- case GeomAbs_Ellipse:
- case GeomAbs_Circle: {
- //---------------------------------------------------------------
- //-- if the curve is a trimmed curve, first and last parameters
- //-- will be the parameters used to build the domain
- //--
- Standard_Real firstparameter = TheCurveTool::FirstParameter(C1);
- Standard_Real lastparameter = TheCurveTool::LastParameter(C1);
-
- gp_Pnt2d P1(TheCurveTool::Value(C1,firstparameter));
- gp_Pnt2d P2(TheCurveTool::Value(C1,lastparameter));
- D1.SetValues(P1,firstparameter ,TolDomain,
- P2,lastparameter ,TolDomain);
- D1.SetEquivalentParameters(firstparameter,firstparameter+M_PI+M_PI);
- break;
- }
- default: {
- Standard_Real paraminf = TheCurveTool::FirstParameter(C1);
- Standard_Real paramsup = TheCurveTool::LastParameter(C1);
- if(paraminf>-Precision::Infinite()) {
- if(paramsup<Precision::Infinite()) {
- //-- paraminf-----------paramsup
- D1.SetValues(TheCurveTool::Value(C1,paraminf),
- paraminf,
- TolDomain,
- TheCurveTool::Value(C1,paramsup),
- paramsup,
- TolDomain);
- }
- else {
- //-- paraminf------------...
- D1.SetValues(TheCurveTool::Value(C1,paraminf),
- paraminf,
- TolDomain,
- Standard_True);
- }
+ switch (typ)
+ {
+
+ case GeomAbs_Ellipse:
+ case GeomAbs_Circle: {
+ //---------------------------------------------------------------
+ //-- if the curve is a trimmed curve, first and last parameters
+ //-- will be the parameters used to build the domain
+ //--
+ Standard_Real firstparameter = TheCurveTool::FirstParameter(C1);
+ Standard_Real lastparameter = TheCurveTool::LastParameter(C1);
+
+ gp_Pnt2d P1(TheCurveTool::Value(C1, firstparameter));
+ gp_Pnt2d P2(TheCurveTool::Value(C1, lastparameter));
+ D1.SetValues(P1, firstparameter, TolDomain, P2, lastparameter, TolDomain);
+ D1.SetEquivalentParameters(firstparameter, firstparameter + M_PI + M_PI);
+ break;
}
- else {
- if(paramsup<Precision::Infinite()) {
- //-- ...-----------------paramsup
- D1.SetValues(TheCurveTool::Value(C1,paramsup),
- paramsup,
- TolDomain,
- Standard_False);
+ default: {
+ Standard_Real paraminf = TheCurveTool::FirstParameter(C1);
+ Standard_Real paramsup = TheCurveTool::LastParameter(C1);
+ if (paraminf > -Precision::Infinite())
+ {
+ if (paramsup < Precision::Infinite())
+ {
+ //-- paraminf-----------paramsup
+ D1.SetValues(TheCurveTool::Value(C1, paraminf),
+ paraminf,
+ TolDomain,
+ TheCurveTool::Value(C1, paramsup),
+ paramsup,
+ TolDomain);
+ }
+ else
+ {
+ //-- paraminf------------...
+ D1.SetValues(TheCurveTool::Value(C1, paraminf), paraminf, TolDomain, Standard_True);
+ }
+ }
+ else
+ {
+ if (paramsup < Precision::Infinite())
+ {
+ //-- ...-----------------paramsup
+ D1.SetValues(TheCurveTool::Value(C1, paramsup), paramsup, TolDomain, Standard_False);
+ }
}
+ break;
}
- break;
}
- }
- return(D1);
+ return (D1);
}
+
//----------------------------------------------------------------------
//-- Perform : Si Une des courbes est Composite Alors decompose les appels
//----------------------------------------------------------------------
-void IntCurve_IntCurveCurveGen::Perform (const TheCurve& C1,
- const IntRes2d_Domain& D1,
- const TheCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+void IntCurve_IntCurveCurveGen::Perform(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const TheCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
this->ResetFields();
Standard_Integer nbi1 = TheCurveTool::NbIntervals(C1);
- if(nbi1 > 1) {
+ if (nbi1 > 1)
+ {
param1inf = TheCurveTool::FirstParameter(C1);
param1sup = TheCurveTool::LastParameter(C1);
}
- else {
- param1inf = (D1.HasFirstPoint())? (D1.FirstParameter()) : -Precision::Infinite();
- param1sup = (D1.HasLastPoint()) ? (D1.LastParameter()) : Precision::Infinite();
+ else
+ {
+ param1inf = (D1.HasFirstPoint()) ? (D1.FirstParameter()) : -Precision::Infinite();
+ param1sup = (D1.HasLastPoint()) ? (D1.LastParameter()) : Precision::Infinite();
}
Standard_Integer nbi2 = TheCurveTool::NbIntervals(C2);
- if(nbi2 > 1) {
+ if (nbi2 > 1)
+ {
param2inf = TheCurveTool::FirstParameter(C2);
param2sup = TheCurveTool::LastParameter(C2);
}
- else {
- param2inf = (D2.HasFirstPoint())? (D2.FirstParameter()) : -Precision::Infinite();
- param2sup = (D2.HasLastPoint()) ? (D2.LastParameter()) : Precision::Infinite();
+ else
+ {
+ param2inf = (D2.HasFirstPoint()) ? (D2.FirstParameter()) : -Precision::Infinite();
+ param2sup = (D2.HasLastPoint()) ? (D2.LastParameter()) : Precision::Infinite();
}
- if(nbi1>1 || nbi2>1) {
- TColStd_Array1OfReal Tab1(1,nbi1+1);
- TColStd_Array1OfReal Tab2(1,nbi2+1);
- TheCurveTool::Intervals(C1,Tab1);
- TheCurveTool::Intervals(C2,Tab2);
- InternalCompositePerform(C1,D1,1,nbi1,Tab1,
- C2,D2,1,nbi2,Tab2,
- TolConf,Tol,Standard_True);
+ if (nbi1 > 1 || nbi2 > 1)
+ {
+ TColStd_Array1OfReal Tab1(1, nbi1 + 1);
+ TColStd_Array1OfReal Tab2(1, nbi2 + 1);
+ TheCurveTool::Intervals(C1, Tab1);
+ TheCurveTool::Intervals(C2, Tab2);
+ InternalCompositePerform(C1,
+ D1,
+ 1,
+ nbi1,
+ Tab1,
+ C2,
+ D2,
+ 1,
+ nbi2,
+ Tab2,
+ TolConf,
+ Tol,
+ Standard_True);
return;
}
- else {
- InternalPerform(C1,D1,C2,D2,TolConf,Tol,Standard_False);
+ else
+ {
+ InternalPerform(C1, D1, C2, D2, TolConf, Tol, Standard_False);
}
}
//----------------------------------------------------------------------
-//-- InternalPerform
-//-- Suppose des Courbes Lin...Other
-//-- Si Composite == True
-//-- Les Resultats sont Ajoutes
+//-- InternalPerform
+//-- Suppose des Courbes Lin...Other
+//-- Si Composite == True
+//-- Les Resultats sont Ajoutes
//-- Sinon
//-- Les Resultats sont Copies
//----------------------------------------------------------------------
-void IntCurve_IntCurveCurveGen::InternalPerform (const TheCurve& C1,
- const IntRes2d_Domain& D1,
- const TheCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean Composite)
+void IntCurve_IntCurveCurveGen::InternalPerform(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const TheCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean Composite)
{
GeomAbs_CurveType typ1 = TheCurveTool::GetType(C1);
GeomAbs_CurveType typ2 = TheCurveTool::GetType(C2);
-
switch (typ1)
{
- case GeomAbs_Line:
- switch (typ2)
- {
case GeomAbs_Line:
+ switch (typ2)
{
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Line(C1),D1,
- TheCurveTool::Line(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
+ case GeomAbs_Line: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi.Perform(TheCurveTool::Line(C1), D1, TheCurveTool::Line(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Circle:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Line(C1),D1,
- TheCurveTool::Circle(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
+ case GeomAbs_Circle: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Line(C1), D1, TheCurveTool::Circle(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Ellipse:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Line(C1),D1,
- TheCurveTool::Ellipse(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
+ case GeomAbs_Ellipse: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Line(C1), D1, TheCurveTool::Ellipse(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Parabola:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Line(C1),D1,
- TheCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
+ case GeomAbs_Parabola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Line(C1), D1, TheCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Hyperbola:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Line(C1),D1,
- TheCurveTool::Hyperbola(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
+ case GeomAbs_Hyperbola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Line(C1), D1, TheCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
-
- break;
- default:
- {
- intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(TheCurveTool::Line(C1),D1,
- C2,D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconicurv);
- }
- }
- break;
- }
- break;
+ break;
- case GeomAbs_Circle:
- switch (typ2)
- {
- case GeomAbs_Line:
- {
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Line(C2),D2,
- TheCurveTool::Circle(C1),D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
+ default: {
+ intconicurv.SetReversedParameters(Standard_False);
+ intconicurv.Perform(TheCurveTool::Line(C1), D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
+ break;
}
break;
case GeomAbs_Circle:
+ switch (typ2)
{
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Circle(C1),D1,
- TheCurveTool::Circle(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
- }
- break;
-
- case GeomAbs_Ellipse:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Circle(C1),D1,
- TheCurveTool::Ellipse(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
- }
- break;
-
- case GeomAbs_Parabola:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Circle(C1),D1,
- TheCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
- }
- break;
-
- case GeomAbs_Hyperbola:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Circle(C1),D1,
- TheCurveTool::Hyperbola(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
- }
- break;
-
- default:
- {
- intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(TheCurveTool::Circle(C1),D1,
- C2,D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else
- {
- this->SetValues(intconicurv);
- }
- }
-
- break;
- }
- break;
-
- case GeomAbs_Ellipse:
- switch (typ2)
- {
- case GeomAbs_Line:
- {
+ case GeomAbs_Line: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Line(C2),D2,
- TheCurveTool::Ellipse(C1),D1,
- TolConf,Tol);
-
- if(Composite)
+ intconiconi
+ .Perform(TheCurveTool::Line(C2), D2, TheCurveTool::Circle(C1), D1, TolConf, Tol);
+ if (Composite)
{
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
}
else
{
}
break;
- case GeomAbs_Circle:
- {
- intconiconi.SetReversedParameters(Standard_True);
-
- intconiconi.Perform(TheCurveTool::Circle(C2),D2,
- TheCurveTool::Ellipse(C1),D1,TolConf,Tol);
- if(Composite)
+ case GeomAbs_Circle: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Circle(C1), D1, TheCurveTool::Circle(C2), D2, TolConf, Tol);
+ if (Composite)
{
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
}
else
{
}
break;
- case GeomAbs_Ellipse:
- {
+ case GeomAbs_Ellipse: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Ellipse(C1),D1,
- TheCurveTool::Ellipse(C2),D2,TolConf,Tol);
- if(Composite)
+ intconiconi
+ .Perform(TheCurveTool::Circle(C1), D1, TheCurveTool::Ellipse(C2), D2, TolConf, Tol);
+ if (Composite)
{
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
}
else
{
}
break;
- case GeomAbs_Parabola:
- {
+ case GeomAbs_Parabola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Ellipse(C1),D1,
- TheCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite)
+ intconiconi
+ .Perform(TheCurveTool::Circle(C1), D1, TheCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
{
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
}
else
{
}
break;
- case GeomAbs_Hyperbola:
- {
+ case GeomAbs_Hyperbola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Ellipse(C1),D1,
- TheCurveTool::Hyperbola(C2),D2,
- TolConf,Tol);
- if(Composite)
+ intconiconi
+ .Perform(TheCurveTool::Circle(C1), D1, TheCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
{
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
}
else
{
}
break;
- default:
- {
+ default: {
intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(TheCurveTool::Ellipse(C1),D1,
- C2,D2,TolConf,Tol);
- if(Composite)
+ intconicurv.Perform(TheCurveTool::Circle(C1), D1, C2, D2, TolConf, Tol);
+ if (Composite)
{
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
}
else
{
this->SetValues(intconicurv);
}
}
- break;
- }
- break;
-
- case GeomAbs_Parabola:
- switch (typ2)
- {
- case GeomAbs_Line:
- {
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Line(C2),D2,
- TheCurveTool::Parabola(C1),D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
- }
- break;
- case GeomAbs_Circle:
- {
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Circle(C2),D2,
- TheCurveTool::Parabola(C1),D1,TolConf,Tol);
- if(Composite)
- { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
+ break;
}
break;
case GeomAbs_Ellipse:
+ switch (typ2)
{
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Ellipse(C2),D2,
- TheCurveTool::Parabola(C1),D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconiconi);
- }
- }
- break;
+ case GeomAbs_Line: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Line(C2), D2, TheCurveTool::Ellipse(C1), D1, TolConf, Tol);
- case GeomAbs_Parabola:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Parabola(C1),D1,
- TheCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- else
- {
- this->SetValues(intconiconi);
+ break;
+
+ case GeomAbs_Circle: {
+ intconiconi.SetReversedParameters(Standard_True);
+
+ intconiconi
+ .Perform(TheCurveTool::Circle(C2), D2, TheCurveTool::Ellipse(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Hyperbola:
- {
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Parabola(C1),D1,
- TheCurveTool::Hyperbola(C2),D2,
- TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Ellipse: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Ellipse(C1), D1, TheCurveTool::Ellipse(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- else
- {
- this->SetValues(intconiconi);
+ break;
+
+ case GeomAbs_Parabola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Ellipse(C1), D1, TheCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- default:
- {
- intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(TheCurveTool::Parabola(C1),D1,
- C2,D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Hyperbola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Ellipse(C1), D1, TheCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- else
- {
- this->SetValues(intconicurv);
+ break;
+
+ default: {
+ intconicurv.SetReversedParameters(Standard_False);
+ intconicurv.Perform(TheCurveTool::Ellipse(C1), D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
+ break;
}
break;
- }
- break;
- case GeomAbs_Hyperbola:
- switch (typ2)
- {
- case GeomAbs_Line:
+ case GeomAbs_Parabola:
+ switch (typ2)
{
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Line(C2),D2,
- TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Line: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Line(C2), D2, TheCurveTool::Parabola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- else
- {
- this->SetValues(intconiconi);
+ break;
+
+ case GeomAbs_Circle: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Circle(C2), D2, TheCurveTool::Parabola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Circle:
- {
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Circle(C2),D2,
- TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
- }
- break;
+ case GeomAbs_Ellipse: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Ellipse(C2), D2, TheCurveTool::Parabola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
+ }
+ break;
- case GeomAbs_Ellipse:
- {
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Ellipse(C2),D2,
- TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
- }
- break;
+ case GeomAbs_Parabola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Parabola(C1), D1, TheCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
+ }
+ break;
- case GeomAbs_Parabola:
- {
- intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(TheCurveTool::Parabola(C2),D2,
- TheCurveTool::Hyperbola(C1),D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ case GeomAbs_Hyperbola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi
+ .Perform(TheCurveTool::Parabola(C1), D1, TheCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
+ }
+ break;
+
+ default: {
+ intconicurv.SetReversedParameters(Standard_False);
+ intconicurv.Perform(TheCurveTool::Parabola(C1), D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
+ }
+ break;
}
break;
case GeomAbs_Hyperbola:
+ switch (typ2)
{
- intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(TheCurveTool::Hyperbola(C1),D1,
- TheCurveTool::Hyperbola(C2),D2,
- TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
- }
- break;
+ case GeomAbs_Line: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Line(C2), D2, TheCurveTool::Hyperbola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
+ }
+ break;
- default:
- {
- intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(TheCurveTool::Hyperbola(C1),D1,
- C2,D2,TolConf,Tol);
- if(Composite) { this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconicurv); }
- }
- break;
- }
- break;
+ case GeomAbs_Circle: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Circle(C2), D2, TheCurveTool::Hyperbola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
+ }
+ break;
- default:
- switch (typ2)
- {
- case GeomAbs_Line:
- {
- intconicurv.SetReversedParameters(Standard_True);
- intconicurv.Perform(TheCurveTool::Line(C2),D2, C1,D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Ellipse: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Ellipse(C2), D2, TheCurveTool::Hyperbola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- else
- {
- this->SetValues(intconicurv);
+ break;
+
+ case GeomAbs_Parabola: {
+ intconiconi.SetReversedParameters(Standard_True);
+ intconiconi
+ .Perform(TheCurveTool::Parabola(C2), D2, TheCurveTool::Hyperbola(C1), D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Circle:
- {
- intconicurv.SetReversedParameters(Standard_True);
- intconicurv.Perform(TheCurveTool::Circle(C2),D2, C1,D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Hyperbola: {
+ intconiconi.SetReversedParameters(Standard_False);
+ intconiconi.Perform(TheCurveTool::Hyperbola(C1),
+ D1,
+ TheCurveTool::Hyperbola(C2),
+ D2,
+ TolConf,
+ Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
- else
- {
- this->SetValues(intconicurv);
+ break;
+
+ default: {
+ intconicurv.SetReversedParameters(Standard_False);
+ intconicurv.Perform(TheCurveTool::Hyperbola(C1), D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
+ break;
}
break;
- case GeomAbs_Ellipse:
+ default:
+ switch (typ2)
{
- intconicurv.SetReversedParameters(Standard_True);
- intconicurv.Perform(TheCurveTool::Ellipse(C2),D2, C1,D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
- }
- else
- {
- this->SetValues(intconicurv);
+ case GeomAbs_Line: {
+ intconicurv.SetReversedParameters(Standard_True);
+ intconicurv.Perform(TheCurveTool::Line(C2), D2, C1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Parabola:
- {
- intconicurv.SetReversedParameters(Standard_True);
- intconicurv.Perform(TheCurveTool::Parabola(C2),D2,C1,D1,TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Circle: {
+ intconicurv.SetReversedParameters(Standard_True);
+ intconicurv.Perform(TheCurveTool::Circle(C2), D2, C1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
- else
- {
- this->SetValues(intconicurv);
+ break;
+
+ case GeomAbs_Ellipse: {
+ intconicurv.SetReversedParameters(Standard_True);
+ intconicurv.Perform(TheCurveTool::Ellipse(C2), D2, C1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
- }
- break;
+ break;
- case GeomAbs_Hyperbola:
- {
- intconicurv.SetReversedParameters(Standard_True);
- intconicurv.Perform(TheCurveTool::Hyperbola(C2),D2,C1,D1,
- TolConf,Tol);
- if(Composite)
- {
- this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup);
+ case GeomAbs_Parabola: {
+ intconicurv.SetReversedParameters(Standard_True);
+ intconicurv.Perform(TheCurveTool::Parabola(C2), D2, C1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
- else
- {
- this->SetValues(intconicurv);
+ break;
+
+ case GeomAbs_Hyperbola: {
+ intconicurv.SetReversedParameters(Standard_True);
+ intconicurv.Perform(TheCurveTool::Hyperbola(C2), D2, C1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
- }
- break;
+ break;
- default:
- {
- intcurvcurv.SetReversedParameters(Standard_False);
- intcurvcurv.Perform(C1,D1, C2,D2,TolConf,Tol);
- if(Composite)
- {
- this->Append(intcurvcurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else
- {
- this->SetValues(intcurvcurv);
+ default: {
+ intcurvcurv.SetReversedParameters(Standard_False);
+ intcurvcurv.Perform(C1, D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intcurvcurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intcurvcurv);
+ }
+ done = Standard_True;
}
- done = Standard_True;
+ break;
}
break;
- }
- break;
}
}
-void IntCurve_IntCurveCurveGen::InternalCompositePerform_noRecurs(
- const Standard_Integer NbInterC1,
- const TheCurve& C1,
- const Standard_Integer NumInterC1,
- const TColStd_Array1OfReal& Tab1,
- const IntRes2d_Domain& D1,
- const Standard_Integer NbInterC2,
- const TheCurve& C2,
- const Standard_Integer NumInterC2,
- const TColStd_Array1OfReal& Tab2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol)
+void IntCurve_IntCurveCurveGen::InternalCompositePerform_noRecurs(const Standard_Integer NbInterC1,
+ const TheCurve& C1,
+ const Standard_Integer NumInterC1,
+ const TColStd_Array1OfReal& Tab1,
+ const IntRes2d_Domain& D1,
+ const Standard_Integer NbInterC2,
+ const TheCurve& C2,
+ const Standard_Integer NumInterC2,
+ const TColStd_Array1OfReal& Tab2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
{
-
-
- if(NumInterC2>NbInterC2)
+
+ if (NumInterC2 > NbInterC2)
return;
-
IntRes2d_Domain DomainC1NumInter;
IntRes2d_Domain DomainC2NumInter;
//-- Creation du domaine associe a la portion de C1
//----------------------------------------------------------------------
Standard_Boolean DomainIsOK = Standard_True;
- Standard_Real ParamInf,ParamSup;
-
- if(NbInterC1>1) {
- TheCurveTool::GetInterval(C1,NumInterC1,Tab1,ParamInf,ParamSup);
+ Standard_Real ParamInf, ParamSup;
+
+ if (NbInterC1 > 1)
+ {
+ TheCurveTool::GetInterval(C1, NumInterC1, Tab1, ParamInf, ParamSup);
//--------------------------------------------------------------
//-- Verification : Domaine Inclu dans Intervalle de Definition
//--------------------------------------------------------------
Standard_Real u;
u = D1.FirstParameter();
- if(ParamInf < u) { ParamInf = u; }
+ if (ParamInf < u)
+ {
+ ParamInf = u;
+ }
u = D1.LastParameter();
- if(ParamSup > u) { ParamSup = u; }
+ if (ParamSup > u)
+ {
+ ParamSup = u;
+ }
- if((ParamSup - ParamInf) > 1e-10) {
- DomainC1NumInter.SetValues(TheCurveTool::Value(C1,ParamInf),
+ if ((ParamSup - ParamInf) > 1e-10)
+ {
+ DomainC1NumInter.SetValues(TheCurveTool::Value(C1, ParamInf),
ParamInf,
D1.FirstTolerance(),
- TheCurveTool::Value(C1,ParamSup),
+ TheCurveTool::Value(C1, ParamSup),
ParamSup,
D1.LastTolerance());
- } else {
+ }
+ else
+ {
DomainIsOK = Standard_False;
}
- } else {
+ }
+ else
+ {
DomainC1NumInter = D1;
}
-
+
//----------------------------------------------------------------------
//-- Creation du domaine associe a la portion de C2
//----------------------------------------------------------------------
- if(NbInterC2 > 1) {
- TheCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
+ if (NbInterC2 > 1)
+ {
+ TheCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
//--------------------------------------------------------------
//-- Verification : Domaine Inclu dans Intervalle de Definition
//--------------------------------------------------------------
Standard_Real u;
u = D2.FirstParameter();
- if(ParamInf < u) { ParamInf = u; }
+ if (ParamInf < u)
+ {
+ ParamInf = u;
+ }
u = D2.LastParameter();
- if(ParamSup > u) { ParamSup = u; }
+ if (ParamSup > u)
+ {
+ ParamSup = u;
+ }
- if((ParamSup - ParamInf) > 1e-10) {
- DomainC2NumInter.SetValues(TheCurveTool::Value(C2,ParamInf),
+ if ((ParamSup - ParamInf) > 1e-10)
+ {
+ DomainC2NumInter.SetValues(TheCurveTool::Value(C2, ParamInf),
ParamInf,
D2.FirstTolerance(),
- TheCurveTool::Value(C2,ParamSup),
+ TheCurveTool::Value(C2, ParamSup),
ParamSup,
D2.LastTolerance());
- } else {
+ }
+ else
+ {
DomainIsOK = Standard_False;
}
- } else {
+ }
+ else
+ {
DomainC2NumInter = D2;
}
- if(DomainIsOK) {
- InternalPerform(C2,DomainC2NumInter,
- C1,DomainC1NumInter,
- TolConf,Tol,
- Standard_True);
+ if (DomainIsOK)
+ {
+ InternalPerform(C2, DomainC2NumInter, C1, DomainC1NumInter, TolConf, Tol, Standard_True);
}
}
+//-- C1 ou C2 sont des courbes composites
+//--
+
+void IntCurve_IntCurveCurveGen::InternalCompositePerform(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const Standard_Integer XXXNumInterC1,
+ const Standard_Integer NbInterC1,
+ const TColStd_Array1OfReal& Tab1,
+ const TheCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Integer XXXNumInterC2,
+ const Standard_Integer NbInterC2,
+ const TColStd_Array1OfReal& Tab2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean RecursOnC2)
+{
+ Standard_Integer NumInterC2 = XXXNumInterC2;
+ Standard_Integer NumInterC1 = XXXNumInterC1;
+ // Standard_Boolean Arret=Standard_False;
-//-- C1 ou C2 sont des courbes composites
-//--
-
-void
-IntCurve_IntCurveCurveGen::InternalCompositePerform(const TheCurve& C1,
- const IntRes2d_Domain& D1,
- const Standard_Integer XXXNumInterC1,
- const Standard_Integer NbInterC1,
- const TColStd_Array1OfReal& Tab1,
- const TheCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Integer XXXNumInterC2,
- const Standard_Integer NbInterC2,
- const TColStd_Array1OfReal& Tab2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean RecursOnC2) {
-
- Standard_Integer NumInterC2=XXXNumInterC2;
- Standard_Integer NumInterC1=XXXNumInterC1;
-
-
-// Standard_Boolean Arret=Standard_False;
-
- if(NumInterC2>NbInterC2)
+ if (NumInterC2 > NbInterC2)
return;
- if(!RecursOnC2){
- InternalCompositePerform_noRecurs(NbInterC1, C1, NumInterC1, Tab1, D1, NbInterC2, C2, NumInterC2, Tab2, D2, TolConf, Tol);
+ if (!RecursOnC2)
+ {
+ InternalCompositePerform_noRecurs(NbInterC1,
+ C1,
+ NumInterC1,
+ Tab1,
+ D1,
+ NbInterC2,
+ C2,
+ NumInterC2,
+ Tab2,
+ D2,
+ TolConf,
+ Tol);
return;
}
- for(Standard_Integer i=NumInterC1 ; i<=NbInterC1; i++) {
- NumInterC1=i;
+ for (Standard_Integer i = NumInterC1; i <= NbInterC1; i++)
+ {
+ NumInterC1 = i;
/*
InternalCompositePerform(C2,D2,NumInterC2,NbInterC2,Tab2,
- C1,D1,NumInterC1,NbInterC1,Tab1,
- TolConf,Tol,Standard_False);
+ C1,D1,NumInterC1,NbInterC1,Tab1,
+ TolConf,Tol,Standard_False);
*/
- InternalCompositePerform_noRecurs(NbInterC2,C2,NumInterC2,Tab2,D2,NbInterC1,C1,NumInterC1,Tab1,D1,TolConf,Tol);
+ InternalCompositePerform_noRecurs(NbInterC2,
+ C2,
+ NumInterC2,
+ Tab2,
+ D2,
+ NbInterC1,
+ C1,
+ NumInterC1,
+ Tab1,
+ D1,
+ TolConf,
+ Tol);
}
- if(NumInterC2<NbInterC2) {
+ if (NumInterC2 < NbInterC2)
+ {
NumInterC2++;
- NumInterC1=1;
-
- InternalCompositePerform(C1,D1,NumInterC1,NbInterC1,Tab1,
- C2,D2,NumInterC2,NbInterC2,Tab2,
- TolConf,Tol,
+ NumInterC1 = 1;
+
+ InternalCompositePerform(C1,
+ D1,
+ NumInterC1,
+ NbInterC1,
+ Tab1,
+ C2,
+ D2,
+ NumInterC2,
+ NbInterC2,
+ Tab2,
+ TolConf,
+ Tol,
Standard_True);
}
}
// Modified by skv - Tue Mar 1 14:22:09 2005 OCC8169
-
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
#include <Standard_ConstructionError.hxx>
#include <IntRes2d_Domain.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
-
#include <IntImpParGen.hxx>
#include <Intf_SectionPoint.hxx>
//======================================================================
#define NBITER_MAX_POLYGON 10
-#define TOL_CONF_MINI 0.0000000001
-#define TOL_MINI 0.0000000001
-
-//----------------------------------------------------------------------
-
-
-void GetIntersection(const TheCurve& theC1, const Standard_Real theT1f, const Standard_Real theT1l,
- const TheCurve& theC2, const Standard_Real theT2f, const Standard_Real theT2l,
- const Standard_Real theTolConf,
- const Standard_Integer theMaxCount,
- IntRes2d_IntersectionPoint& thePInt, Standard_Real& theDist,
- Standard_Integer& theCount);
+#define TOL_CONF_MINI 0.0000000001
+#define TOL_MINI 0.0000000001
+//=================================================================================================
-Standard_Boolean HeadOrEndPoint( const IntRes2d_Domain& D1
- ,const TheCurve& C1
- ,const Standard_Real u
- ,const IntRes2d_Domain& D2
- ,const TheCurve& C2
- ,const Standard_Real v
- ,const Standard_Real TolConf
- ,IntRes2d_IntersectionPoint& IntPt
- ,Standard_Boolean& HeadOn1
- ,Standard_Boolean& HeadOn2
- ,Standard_Boolean& EndOn1
- ,Standard_Boolean& EndOn2
- ,Standard_Integer PosSegment);
+void GetIntersection(const TheCurve& theC1,
+ const Standard_Real theT1f,
+ const Standard_Real theT1l,
+ const TheCurve& theC2,
+ const Standard_Real theT2f,
+ const Standard_Real theT2l,
+ const Standard_Real theTolConf,
+ const Standard_Integer theMaxCount,
+ IntRes2d_IntersectionPoint& thePInt,
+ Standard_Real& theDist,
+ Standard_Integer& theCount);
+
+Standard_Boolean HeadOrEndPoint(const IntRes2d_Domain& D1,
+ const TheCurve& C1,
+ const Standard_Real u,
+ const IntRes2d_Domain& D2,
+ const TheCurve& C2,
+ const Standard_Real v,
+ const Standard_Real TolConf,
+ IntRes2d_IntersectionPoint& IntPt,
+ Standard_Boolean& HeadOn1,
+ Standard_Boolean& HeadOn2,
+ Standard_Boolean& EndOn1,
+ Standard_Boolean& EndOn2,
+ Standard_Integer PosSegment);
+//=================================================================================================
-//======================================================================
IntCurve_IntPolyPolyGen::IntCurve_IntPolyPolyGen()
{
const Standard_Integer aMinPntNb = 20; // Minimum number of samples.
- myMinPntNb = aMinPntNb;
- done = Standard_False;
+ myMinPntNb = aMinPntNb;
+ done = Standard_False;
}
-//======================================================================
-void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
- ,const IntRes2d_Domain& D1
- ,const TheCurve& C2
- ,const IntRes2d_Domain& D2
- ,const Standard_Real TheTolConf
- ,const Standard_Real TheTol)
+
+//=================================================================================================
+
+void IntCurve_IntPolyPolyGen::Perform(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const TheCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TheTolConf,
+ const Standard_Real TheTol)
{
this->ResetFields();
- DomainOnCurve1=D1;
- DomainOnCurve2=D2;
- Standard_Real DU = D1.LastParameter()-D1.FirstParameter();
- Standard_Real DV = D2.LastParameter()-D2.FirstParameter();
- Standard_Real Tl=(TheTol < TOL_MINI)? TOL_MINI : TheTol;
- Standard_Real TlConf=(TheTolConf < TOL_CONF_MINI)? TOL_CONF_MINI : TheTolConf;
- Perform(C1,D1,C2,D2,TlConf,Tl,0,DU,DV);
+ DomainOnCurve1 = D1;
+ DomainOnCurve2 = D2;
+ Standard_Real DU = D1.LastParameter() - D1.FirstParameter();
+ Standard_Real DV = D2.LastParameter() - D2.FirstParameter();
+ Standard_Real Tl = (TheTol < TOL_MINI) ? TOL_MINI : TheTol;
+ Standard_Real TlConf = (TheTolConf < TOL_CONF_MINI) ? TOL_CONF_MINI : TheTolConf;
+ Perform(C1, D1, C2, D2, TlConf, Tl, 0, DU, DV);
//----------------------------------------------------------------------
//-- Processing of end points
//----------------------------------------------------------------------
Standard_Boolean EndOn1 = Standard_False;
Standard_Boolean EndOn2 = Standard_False;
Standard_Integer i;
- Standard_Integer n=this->NbPoints();
-
+ Standard_Integer n = this->NbPoints();
//--------------------------------------------------------------------
//-- The points Head Head ... End End are not rejected if
- //-- they are already present at the end of segment
+ //-- they are already present at the end of segment
//-- ( It is not possible to test the equities on the parameters)
//-- ( these points are not found at EpsX precision )
//-- PosSegment = 1 if Head Head
//--------------------------------------------------------------------
Standard_Integer PosSegment = 0;
- for(i=1;i<=n;i++) {
+ for (i = 1; i <= n; i++)
+ {
IntRes2d_Position Pos1 = this->Point(i).TransitionOfFirst().PositionOnCurve();
- if(Pos1 == IntRes2d_Head) HeadOn1 = Standard_True;
- else if(Pos1 == IntRes2d_End) EndOn1 = Standard_True;
-
- IntRes2d_Position Pos2 = this->Point(i).TransitionOfSecond().PositionOnCurve();
- if(Pos2 == IntRes2d_Head) HeadOn2 = Standard_True;
- else if(Pos2 == IntRes2d_End) EndOn2 = Standard_True;
-
- if(Pos1 == IntRes2d_Head) {
- if(Pos2 == IntRes2d_Head) PosSegment|=1;
- else if(Pos2 == IntRes2d_End) PosSegment|=2;
+ if (Pos1 == IntRes2d_Head)
+ HeadOn1 = Standard_True;
+ else if (Pos1 == IntRes2d_End)
+ EndOn1 = Standard_True;
+
+ IntRes2d_Position Pos2 = this->Point(i).TransitionOfSecond().PositionOnCurve();
+ if (Pos2 == IntRes2d_Head)
+ HeadOn2 = Standard_True;
+ else if (Pos2 == IntRes2d_End)
+ EndOn2 = Standard_True;
+
+ if (Pos1 == IntRes2d_Head)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 1;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 2;
}
- else if(Pos1 == IntRes2d_End) {
- if(Pos2 == IntRes2d_Head) PosSegment|=4;
- else if(Pos2 == IntRes2d_End) PosSegment|=8;
+ else if (Pos1 == IntRes2d_End)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 4;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 8;
}
}
-
- n=this->NbSegments();
- for(i=1;i<=n;i++) {
+
+ n = this->NbSegments();
+ for (i = 1; i <= n; i++)
+ {
IntRes2d_Position Pos1 = this->Segment(i).FirstPoint().TransitionOfFirst().PositionOnCurve();
- if(Pos1 == IntRes2d_Head) HeadOn1 = Standard_True;
- else if(Pos1 == IntRes2d_End) EndOn1 = Standard_True;
-
- IntRes2d_Position Pos2 = this->Segment(i).FirstPoint().TransitionOfSecond().PositionOnCurve();
- if(Pos2 == IntRes2d_Head) HeadOn2 = Standard_True;
- else if(Pos2 == IntRes2d_End) EndOn2 = Standard_True;
-
- if(Pos1 == IntRes2d_Head) {
- if(Pos2 == IntRes2d_Head) PosSegment|=1;
- else if(Pos2 == IntRes2d_End) PosSegment|=2;
+ if (Pos1 == IntRes2d_Head)
+ HeadOn1 = Standard_True;
+ else if (Pos1 == IntRes2d_End)
+ EndOn1 = Standard_True;
+
+ IntRes2d_Position Pos2 = this->Segment(i).FirstPoint().TransitionOfSecond().PositionOnCurve();
+ if (Pos2 == IntRes2d_Head)
+ HeadOn2 = Standard_True;
+ else if (Pos2 == IntRes2d_End)
+ EndOn2 = Standard_True;
+
+ if (Pos1 == IntRes2d_Head)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 1;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 2;
}
- else if(Pos1 == IntRes2d_End) {
- if(Pos2 == IntRes2d_Head) PosSegment|=4;
- else if(Pos2 == IntRes2d_End) PosSegment|=8;
+ else if (Pos1 == IntRes2d_End)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 4;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 8;
}
Pos1 = this->Segment(i).LastPoint().TransitionOfFirst().PositionOnCurve();
- if(Pos1 == IntRes2d_Head) HeadOn1 = Standard_True;
- else if(Pos1 == IntRes2d_End) EndOn1 = Standard_True;
-
- Pos2 = this->Segment(i).LastPoint().TransitionOfSecond().PositionOnCurve();
- if(Pos2 == IntRes2d_Head) HeadOn2 = Standard_True;
- else if(Pos2 == IntRes2d_End) EndOn2 = Standard_True;
-
- if(Pos1 == IntRes2d_Head) {
- if(Pos2 == IntRes2d_Head) PosSegment|=1;
- else if(Pos2 == IntRes2d_End) PosSegment|=2;
+ if (Pos1 == IntRes2d_Head)
+ HeadOn1 = Standard_True;
+ else if (Pos1 == IntRes2d_End)
+ EndOn1 = Standard_True;
+
+ Pos2 = this->Segment(i).LastPoint().TransitionOfSecond().PositionOnCurve();
+ if (Pos2 == IntRes2d_Head)
+ HeadOn2 = Standard_True;
+ else if (Pos2 == IntRes2d_End)
+ EndOn2 = Standard_True;
+
+ if (Pos1 == IntRes2d_Head)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 1;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 2;
}
- else if(Pos1 == IntRes2d_End) {
- if(Pos2 == IntRes2d_Head) PosSegment|=4;
- else if(Pos2 == IntRes2d_End) PosSegment|=8;
+ else if (Pos1 == IntRes2d_End)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 4;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 8;
}
}
- Standard_Real U0 = D1.FirstParameter();
- Standard_Real U1 = D1.LastParameter();
- Standard_Real V0 = D2.FirstParameter();
- Standard_Real V1 = D2.LastParameter();
+ Standard_Real U0 = D1.FirstParameter();
+ Standard_Real U1 = D1.LastParameter();
+ Standard_Real V0 = D2.FirstParameter();
+ Standard_Real V1 = D2.LastParameter();
IntRes2d_IntersectionPoint IntPt;
-
- if(D1.FirstTolerance() || D2.FirstTolerance()) {
- if(HeadOrEndPoint(D1,C1,U0,D2,C2,V0,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
+
+ if (D1.FirstTolerance() || D2.FirstTolerance())
+ {
+ if (HeadOrEndPoint(D1,
+ C1,
+ U0,
+ D2,
+ C2,
+ V0,
+ TheTolConf,
+ IntPt,
+ HeadOn1,
+ HeadOn2,
+ EndOn1,
+ EndOn2,
+ PosSegment))
this->Insert(IntPt);
}
- if(D1.FirstTolerance() || D2.LastTolerance()) {
- if(HeadOrEndPoint(D1,C1,U0,D2,C2,V1,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
+ if (D1.FirstTolerance() || D2.LastTolerance())
+ {
+ if (HeadOrEndPoint(D1,
+ C1,
+ U0,
+ D2,
+ C2,
+ V1,
+ TheTolConf,
+ IntPt,
+ HeadOn1,
+ HeadOn2,
+ EndOn1,
+ EndOn2,
+ PosSegment))
this->Insert(IntPt);
}
- if(D1.LastTolerance() || D2.FirstTolerance()) {
- if(HeadOrEndPoint(D1,C1,U1,D2,C2,V0,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
+ if (D1.LastTolerance() || D2.FirstTolerance())
+ {
+ if (HeadOrEndPoint(D1,
+ C1,
+ U1,
+ D2,
+ C2,
+ V0,
+ TheTolConf,
+ IntPt,
+ HeadOn1,
+ HeadOn2,
+ EndOn1,
+ EndOn2,
+ PosSegment))
this->Insert(IntPt);
}
- if(D1.LastTolerance() || D2.LastTolerance()) {
- if(HeadOrEndPoint(D1,C1,U1,D2,C2,V1,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
+ if (D1.LastTolerance() || D2.LastTolerance())
+ {
+ if (HeadOrEndPoint(D1,
+ C1,
+ U1,
+ D2,
+ C2,
+ V1,
+ TheTolConf,
+ IntPt,
+ HeadOn1,
+ HeadOn2,
+ EndOn1,
+ EndOn2,
+ PosSegment))
this->Insert(IntPt);
}
}
-
//======================================================================
-//== A u t o I n t e r s e c t i o n
+//== A u t o I n t e r s e c t i o n
//======================================================================
-void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
- ,const IntRes2d_Domain& D1
- ,const Standard_Real TheTolConf
- ,const Standard_Real TheTol)
+void IntCurve_IntPolyPolyGen::Perform(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const Standard_Real TheTolConf,
+ const Standard_Real TheTol)
{
this->ResetFields();
- DomainOnCurve1=D1;
- DomainOnCurve2=D1;
- Standard_Real DU = D1.LastParameter()-D1.FirstParameter();
- Standard_Real Tl=(TheTol < TOL_MINI)? TOL_MINI : TheTol;
- Standard_Real TlConf=(TheTolConf < TOL_CONF_MINI)? TOL_CONF_MINI : TheTolConf;
- Perform(C1,D1,TlConf,Tl,0,DU,DU);
+ DomainOnCurve1 = D1;
+ DomainOnCurve2 = D1;
+ Standard_Real DU = D1.LastParameter() - D1.FirstParameter();
+ Standard_Real Tl = (TheTol < TOL_MINI) ? TOL_MINI : TheTol;
+ Standard_Real TlConf = (TheTolConf < TOL_CONF_MINI) ? TOL_CONF_MINI : TheTolConf;
+ Perform(C1, D1, TlConf, Tl, 0, DU, DU);
Standard_Integer i;
- Standard_Integer n=this->NbPoints();
+ Standard_Integer n = this->NbPoints();
//--------------------------------------------------------------------
- //-- The points Head Head ... End End are not rejected if
- //-- they are already present at the end of segment
+ //-- The points Head Head ... End End are not rejected if
+ //-- they are already present at the end of segment
//-- ( It is not possible to test the equities on the parameters)
//-- ( these points are not found at EpsX precision )
//-- PosSegment = 1 if Head Head
//--------------------------------------------------------------------
Standard_Integer PosSegment = 0;
- for(i=1;i<=n;i++) {
+ for (i = 1; i <= n; i++)
+ {
IntRes2d_Position Pos1 = this->Point(i).TransitionOfFirst().PositionOnCurve();
- IntRes2d_Position Pos2 = this->Point(i).TransitionOfSecond().PositionOnCurve();
+ IntRes2d_Position Pos2 = this->Point(i).TransitionOfSecond().PositionOnCurve();
- if(Pos1 == IntRes2d_Head) {
- if(Pos2 == IntRes2d_Head) PosSegment|=1;
- else if(Pos2 == IntRes2d_End) PosSegment|=2;
+ if (Pos1 == IntRes2d_Head)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 1;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 2;
}
- else if(Pos1 == IntRes2d_End) {
- if(Pos2 == IntRes2d_Head) PosSegment|=4;
- else if(Pos2 == IntRes2d_End) PosSegment|=8;
+ else if (Pos1 == IntRes2d_End)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 4;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 8;
}
}
-
- n=this->NbSegments();
- for(i=1;i<=n;i++) {
+
+ n = this->NbSegments();
+ for (i = 1; i <= n; i++)
+ {
IntRes2d_Position Pos1 = this->Segment(i).FirstPoint().TransitionOfFirst().PositionOnCurve();
- IntRes2d_Position Pos2 = this->Segment(i).FirstPoint().TransitionOfSecond().PositionOnCurve();
+ IntRes2d_Position Pos2 = this->Segment(i).FirstPoint().TransitionOfSecond().PositionOnCurve();
- if(Pos1 == IntRes2d_Head) {
- if(Pos2 == IntRes2d_Head) PosSegment|=1;
- else if(Pos2 == IntRes2d_End) PosSegment|=2;
+ if (Pos1 == IntRes2d_Head)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 1;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 2;
}
- else if(Pos1 == IntRes2d_End) {
- if(Pos2 == IntRes2d_Head) PosSegment|=4;
- else if(Pos2 == IntRes2d_End) PosSegment|=8;
+ else if (Pos1 == IntRes2d_End)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 4;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 8;
}
Pos1 = this->Segment(i).LastPoint().TransitionOfFirst().PositionOnCurve();
- Pos2 = this->Segment(i).LastPoint().TransitionOfSecond().PositionOnCurve();
+ Pos2 = this->Segment(i).LastPoint().TransitionOfSecond().PositionOnCurve();
- if(Pos1 == IntRes2d_Head) {
- if(Pos2 == IntRes2d_Head) PosSegment|=1;
- else if(Pos2 == IntRes2d_End) PosSegment|=2;
+ if (Pos1 == IntRes2d_Head)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 1;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 2;
}
- else if(Pos1 == IntRes2d_End) {
- if(Pos2 == IntRes2d_Head) PosSegment|=4;
- else if(Pos2 == IntRes2d_End) PosSegment|=8;
+ else if (Pos1 == IntRes2d_End)
+ {
+ if (Pos2 == IntRes2d_Head)
+ PosSegment |= 4;
+ else if (Pos2 == IntRes2d_End)
+ PosSegment |= 8;
}
}
- (void )PosSegment;
+ (void)PosSegment;
}
+
//======================================================================
-void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
- ,const IntRes2d_Domain& D1
- ,const Standard_Real TolConf
- ,const Standard_Real Tol
- ,const Standard_Integer NbIter
- ,const Standard_Real /*DeltaU*/
- ,const Standard_Real) {
-
- gp_Vec2d Tan1,Tan2,Norm1,Norm2;
- gp_Pnt2d P1,P2;
+void IntCurve_IntPolyPolyGen::Perform(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Integer NbIter,
+ const Standard_Real /*DeltaU*/
+ ,
+ const Standard_Real)
+{
+
+ gp_Vec2d Tan1, Tan2, Norm1, Norm2;
+ gp_Pnt2d P1, P2;
Standard_Integer nbsamples;
done = Standard_False;
-
- nbsamples = TheCurveTool::NbSamples(C1,D1.FirstParameter(),D1.LastParameter());
- if(NbIter>3 || (NbIter>2 && nbsamples>100)) return;
+ nbsamples = TheCurveTool::NbSamples(C1, D1.FirstParameter(), D1.LastParameter());
+
+ if (NbIter > 3 || (NbIter > 2 && nbsamples > 100))
+ return;
- nbsamples*=2; //--- We take systematically two times more points
- //-- than on a normal curve.
- //-- Auto-intersecting curves often produce
+ nbsamples *= 2; //--- We take systematically two times more points
+ //-- than on a normal curve.
+ //-- Auto-intersecting curves often produce
//-- polygons rather far from the curve with parameter ct.
- if(NbIter>0) {
- nbsamples=(3*(nbsamples*NbIter))/2;
+ if (NbIter > 0)
+ {
+ nbsamples = (3 * (nbsamples * NbIter)) / 2;
}
- IntCurve_ThePolygon2d Poly1(C1,nbsamples,D1,Tol);
- if(!Poly1.AutoIntersectionIsPossible()) {
+ IntCurve_ThePolygon2d Poly1(C1, nbsamples, D1, Tol);
+ if (!Poly1.AutoIntersectionIsPossible())
+ {
done = Standard_True;
return;
}
//-- then the deflection of the polygon is set in TolConf
//-- (Detection of Tangency Zones)
//----------------------------------------------------------------------
- if(Poly1.DeflectionOverEstimation() < TolConf) {
+ if (Poly1.DeflectionOverEstimation() < TolConf)
+ {
Poly1.SetDeflectionOverEstimation(TolConf);
}
- Intf_InterferencePolygon2d InterPP(Poly1);
- IntCurve_ExactIntersectionPoint EIP(C1,C1,TolConf);
- Standard_Real U,V;
-
+ Intf_InterferencePolygon2d InterPP(Poly1);
+ IntCurve_ExactIntersectionPoint EIP(C1, C1, TolConf);
+ Standard_Real U, V;
+
//----------------------------------------------------------------------
- //-- Processing of SectionPoint
+ //-- Processing of SectionPoint
//----------------------------------------------------------------------
Standard_Integer Nbsp = InterPP.NbSectionPoints();
- if(Nbsp>=1) {
-
+ if (Nbsp >= 1)
+ {
+
//-- ---------------------------------------------------------------------
//-- filtering, filtering, filtering ...
- //--
- Standard_Integer* TriIndex = new Standard_Integer [Nbsp+1];
- Standard_Integer* PtrSegIndex1 = new Standard_Integer [Nbsp+1];
- Standard_Integer* PtrSegIndex2 = new Standard_Integer [Nbsp+1];
- Standard_Boolean Triok;
- Standard_Integer SegIndex1,SegIndex2,SegIndex_1,SegIndex_2;
-// Standard_Real ParamOn1,ParamOn2,ParamOn_1,ParamOn_2;
- Standard_Real ParamOn1,ParamOn2;
- Intf_PIType Type;
- Standard_Integer i ;
- for( i=1;i<=Nbsp;i++) {
- TriIndex[i]=i;
+ //--
+ Standard_Integer* TriIndex = new Standard_Integer[Nbsp + 1];
+ Standard_Integer* PtrSegIndex1 = new Standard_Integer[Nbsp + 1];
+ Standard_Integer* PtrSegIndex2 = new Standard_Integer[Nbsp + 1];
+ Standard_Boolean Triok;
+ Standard_Integer SegIndex1, SegIndex2, SegIndex_1, SegIndex_2;
+ // Standard_Real ParamOn1,ParamOn2,ParamOn_1,ParamOn_2;
+ Standard_Real ParamOn1, ParamOn2;
+ Intf_PIType Type;
+ Standard_Integer i;
+ for (i = 1; i <= Nbsp; i++)
+ {
+ TriIndex[i] = i;
const Intf_SectionPoint& SPnt1 = InterPP.PntValue(i);
- SPnt1.InfoFirst(Type,PtrSegIndex1[i],ParamOn1);
- SPnt1.InfoSecond(Type,PtrSegIndex2[i],ParamOn2);
+ SPnt1.InfoFirst(Type, PtrSegIndex1[i], ParamOn1);
+ SPnt1.InfoSecond(Type, PtrSegIndex2[i], ParamOn2);
}
-
-
- do {
- Triok=Standard_True;
-
- for(Standard_Integer tr=1;tr<Nbsp;tr++) {
- SegIndex1=PtrSegIndex1[TriIndex[tr]];
- SegIndex_1=PtrSegIndex1[TriIndex[tr+1]];
-
- SegIndex2=PtrSegIndex2[TriIndex[tr]];
- SegIndex_2=PtrSegIndex2[TriIndex[tr+1]];
-
- if(SegIndex1 > SegIndex_1) {
- Standard_Integer q=TriIndex[tr];
- TriIndex[tr]=TriIndex[tr+1];
- TriIndex[tr+1]=q;
- Triok=Standard_False;
- }
- else if(SegIndex1 == SegIndex_1) {
- if(SegIndex2 > SegIndex_2) {
- Standard_Integer q=TriIndex[tr];
- TriIndex[tr]=TriIndex[tr+1];
- TriIndex[tr+1]=q;
- Triok=Standard_False;
- }
- }
+
+ do
+ {
+ Triok = Standard_True;
+
+ for (Standard_Integer tr = 1; tr < Nbsp; tr++)
+ {
+ SegIndex1 = PtrSegIndex1[TriIndex[tr]];
+ SegIndex_1 = PtrSegIndex1[TriIndex[tr + 1]];
+
+ SegIndex2 = PtrSegIndex2[TriIndex[tr]];
+ SegIndex_2 = PtrSegIndex2[TriIndex[tr + 1]];
+
+ if (SegIndex1 > SegIndex_1)
+ {
+ Standard_Integer q = TriIndex[tr];
+ TriIndex[tr] = TriIndex[tr + 1];
+ TriIndex[tr + 1] = q;
+ Triok = Standard_False;
+ }
+ else if (SegIndex1 == SegIndex_1)
+ {
+ if (SegIndex2 > SegIndex_2)
+ {
+ Standard_Integer q = TriIndex[tr];
+ TriIndex[tr] = TriIndex[tr + 1];
+ TriIndex[tr + 1] = q;
+ Triok = Standard_False;
+ }
+ }
}
- }
- while(Triok==Standard_False);
+ } while (Triok == Standard_False);
//-- supression des doublons Si Si !
- for(i=1; i<Nbsp;i++) {
- if( (PtrSegIndex1[TriIndex[i]] == PtrSegIndex1[TriIndex[i+1]])
- && (PtrSegIndex2[TriIndex[i]] == PtrSegIndex2[TriIndex[i+1]])) {
- TriIndex[i]=-i;
+ for (i = 1; i < Nbsp; i++)
+ {
+ if ((PtrSegIndex1[TriIndex[i]] == PtrSegIndex1[TriIndex[i + 1]])
+ && (PtrSegIndex2[TriIndex[i]] == PtrSegIndex2[TriIndex[i + 1]]))
+ {
+ TriIndex[i] = -i;
}
}
- for(Standard_Integer sp=1; sp <= Nbsp; sp++) {
- if(TriIndex[sp]>0) {
- const Intf_SectionPoint& SPnt = InterPP.PntValue(TriIndex[sp]);
-
- SPnt.InfoFirst(Type,SegIndex1,ParamOn1);
- SPnt.InfoSecond(Type,SegIndex2,ParamOn2);
-
- if(Abs(SegIndex1-SegIndex2)>1) {
-
- EIP.Perform(Poly1,Poly1,SegIndex1,SegIndex2,ParamOn1,ParamOn2);
- if(EIP.NbRoots()>=1) {
- //--------------------------------------------------------------------
- //-- It is checked if the found point is a root
- //--------------------------------------------------------------------
- EIP.Roots(U,V);
-
- TheCurveTool::D1(C1,U,P1,Tan1);
- TheCurveTool::D1(C1,V,P2,Tan2);
- Standard_Real Dist = P1.Distance(P2);
- Standard_Real EpsX1 = 10.0*TheCurveTool::EpsX(C1);
-
- if(Abs(U-V)<=EpsX1) {
- //-----------------------------------------
- //-- Solution not valid
- //-- The maths should have converged in a
- //-- trivial solution ( point U = V )
- //-----------------------------------------
- Dist = TolConf+1.0;
- }
-
- //-----------------------------------------------------------------
- //-- It is checked if the point (u,v) already exists
- //--
- done = Standard_True;
- Standard_Integer nbp=NbPoints();
-
- for(Standard_Integer p=1; p<=nbp; p++) {
- const IntRes2d_IntersectionPoint& P=Point(p);
- if(Abs(U-P.ParamOnFirst()) <= EpsX1) {
- if(Abs(V-P.ParamOnSecond()) <= EpsX1) {
- Dist = TolConf+1.0; p+=nbp;
- }
- }
- }
-
- if(Dist <= TolConf) { //-- Or the point is already present
- IntRes2d_Position Pos1 = IntRes2d_Middle;
- IntRes2d_Position Pos2 = IntRes2d_Middle;
- IntRes2d_Transition Trans1,Trans2;
- //-----------------------------------------------------------------
- //-- Calculate Positions of Points on the curve
- //--
- if(P1.Distance(DomainOnCurve1.FirstPoint())<=DomainOnCurve1.FirstTolerance())
- Pos1 = IntRes2d_Head;
- else if(P1.Distance(DomainOnCurve1.LastPoint())<=DomainOnCurve1.LastTolerance())
- Pos1 = IntRes2d_End;
-
- if(P2.Distance(DomainOnCurve2.FirstPoint())<=DomainOnCurve2.FirstTolerance())
- Pos2 = IntRes2d_Head;
- else if(P2.Distance(DomainOnCurve2.LastPoint())<=DomainOnCurve2.LastTolerance())
- Pos2 = IntRes2d_End;
- //-----------------------------------------------------------------
- if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1
- ,Pos2,Tan2,Trans2
- ,TolConf) == Standard_False)
+ for (Standard_Integer sp = 1; sp <= Nbsp; sp++)
+ {
+ if (TriIndex[sp] > 0)
+ {
+ const Intf_SectionPoint& SPnt = InterPP.PntValue(TriIndex[sp]);
+
+ SPnt.InfoFirst(Type, SegIndex1, ParamOn1);
+ SPnt.InfoSecond(Type, SegIndex2, ParamOn2);
+
+ if (Abs(SegIndex1 - SegIndex2) > 1)
+ {
+
+ EIP.Perform(Poly1, Poly1, SegIndex1, SegIndex2, ParamOn1, ParamOn2);
+ if (EIP.NbRoots() >= 1)
+ {
+ //--------------------------------------------------------------------
+ //-- It is checked if the found point is a root
+ //--------------------------------------------------------------------
+ EIP.Roots(U, V);
+
+ TheCurveTool::D1(C1, U, P1, Tan1);
+ TheCurveTool::D1(C1, V, P2, Tan2);
+ Standard_Real Dist = P1.Distance(P2);
+ Standard_Real EpsX1 = 10.0 * TheCurveTool::EpsX(C1);
+
+ if (Abs(U - V) <= EpsX1)
+ {
+ //-----------------------------------------
+ //-- Solution not valid
+ //-- The maths should have converged in a
+ //-- trivial solution ( point U = V )
+ //-----------------------------------------
+ Dist = TolConf + 1.0;
+ }
+
+ //-----------------------------------------------------------------
+ //-- It is checked if the point (u,v) already exists
+ //--
+ done = Standard_True;
+ Standard_Integer nbp = NbPoints();
+
+ for (Standard_Integer p = 1; p <= nbp; p++)
+ {
+ const IntRes2d_IntersectionPoint& P = Point(p);
+ if (Abs(U - P.ParamOnFirst()) <= EpsX1)
{
- TheCurveTool::D2(C1,U,P1,Tan1,Norm1);
- TheCurveTool::D2(C1,V,P2,Tan2,Norm2);
- IntImpParGen::DetermineTransition( Pos1,Tan1,Norm1,Trans1
- ,Pos2,Tan2,Norm2,Trans2
- ,TolConf);
- }
- IntRes2d_IntersectionPoint IP(P1,U,V,Trans1,Trans2,Standard_False);
- Insert(IP);
- }
- }
- }
+ if (Abs(V - P.ParamOnSecond()) <= EpsX1)
+ {
+ Dist = TolConf + 1.0;
+ p += nbp;
+ }
+ }
+ }
+
+ if (Dist <= TolConf)
+ { //-- Or the point is already present
+ IntRes2d_Position Pos1 = IntRes2d_Middle;
+ IntRes2d_Position Pos2 = IntRes2d_Middle;
+ IntRes2d_Transition Trans1, Trans2;
+ //-----------------------------------------------------------------
+ //-- Calculate Positions of Points on the curve
+ //--
+ if (P1.Distance(DomainOnCurve1.FirstPoint()) <= DomainOnCurve1.FirstTolerance())
+ Pos1 = IntRes2d_Head;
+ else if (P1.Distance(DomainOnCurve1.LastPoint()) <= DomainOnCurve1.LastTolerance())
+ Pos1 = IntRes2d_End;
+
+ if (P2.Distance(DomainOnCurve2.FirstPoint()) <= DomainOnCurve2.FirstTolerance())
+ Pos2 = IntRes2d_Head;
+ else if (P2.Distance(DomainOnCurve2.LastPoint()) <= DomainOnCurve2.LastTolerance())
+ Pos2 = IntRes2d_End;
+ //-----------------------------------------------------------------
+ if (IntImpParGen::DetermineTransition(Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf)
+ == Standard_False)
+ {
+ TheCurveTool::D2(C1, U, P1, Tan1, Norm1);
+ TheCurveTool::D2(C1, V, P2, Tan2, Norm2);
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ TolConf);
+ }
+ IntRes2d_IntersectionPoint IP(P1, U, V, Trans1, Trans2, Standard_False);
+ Insert(IP);
+ }
+ }
+ }
}
}
- delete [] TriIndex;
- delete [] PtrSegIndex1;
- delete [] PtrSegIndex2;
+ delete[] TriIndex;
+ delete[] PtrSegIndex1;
+ delete[] PtrSegIndex2;
}
//----------------------------------------------------------------------
//-- Processing of TangentZone
//----------------------------------------------------------------------
Standard_Integer Nbtz = InterPP.NbTangentZones();
- for(Standard_Integer tz=1; tz <= Nbtz; tz++) {
+ for (Standard_Integer tz = 1; tz <= Nbtz; tz++)
+ {
Standard_Integer NbPnts = InterPP.ZoneValue(tz).NumberOfPoints();
//====================================================================
//== Find the first and the last point in the tangency zone.
//====================================================================
- Standard_Real ParamSupOnCurve2,ParamInfOnCurve2;
- Standard_Real ParamSupOnCurve1,ParamInfOnCurve1;
-// Standard_Integer SegIndex,SegIndex1onP1,SegIndex1onP2,SegIndex2onP1,SegIndex2onP2;
- Standard_Integer SegIndex1onP1,SegIndex1onP2;
- Intf_PIType Type;
- Standard_Real ParamOnLine;
- Standard_Real PolyUInf,PolyUSup,PolyVInf,PolyVSup;
- ParamSupOnCurve2=ParamSupOnCurve1=PolyUSup=PolyVSup=-RealLast();
- ParamInfOnCurve2=ParamInfOnCurve1=PolyUInf=PolyVInf= RealLast();
- for(Standard_Integer qq=1;qq<=NbPnts;qq++) {
+ Standard_Real ParamSupOnCurve2, ParamInfOnCurve2;
+ Standard_Real ParamSupOnCurve1, ParamInfOnCurve1;
+ // Standard_Integer SegIndex,SegIndex1onP1,SegIndex1onP2,SegIndex2onP1,SegIndex2onP2;
+ Standard_Integer SegIndex1onP1, SegIndex1onP2;
+ Intf_PIType Type;
+ Standard_Real ParamOnLine;
+ Standard_Real PolyUInf, PolyUSup, PolyVInf, PolyVSup;
+ ParamSupOnCurve2 = ParamSupOnCurve1 = PolyUSup = PolyVSup = -RealLast();
+ ParamInfOnCurve2 = ParamInfOnCurve1 = PolyUInf = PolyVInf = RealLast();
+ for (Standard_Integer qq = 1; qq <= NbPnts; qq++)
+ {
const Intf_SectionPoint& SPnt1 = InterPP.ZoneValue(tz).GetPoint(qq);
//====================================================================
- //== The zones of tangency are discretized
- //== Test of stop : Check if
+ //== The zones of tangency are discretized
+ //== Test of stop : Check if
//== (Deflection < Tolerance)
- //== Or (Sample < EpsX) (normally the first condition is
+ //== Or (Sample < EpsX) (normally the first condition is
//== more strict)
//====================================================================
-// Standard_Real _PolyUInf,_PolyUSup,_PolyVInf,_PolyVSup;
- Standard_Real _PolyUInf,_PolyVInf;
-
- SPnt1.InfoFirst(Type,SegIndex1onP1,ParamOnLine);
- if(SegIndex1onP1 > Poly1.NbSegments()) { SegIndex1onP1--; ParamOnLine = 1.0; }
- if(SegIndex1onP1 <= 0) { SegIndex1onP1=1; ParamOnLine = 0.0; }
- _PolyUInf = Poly1.ApproxParamOnCurve(SegIndex1onP1,ParamOnLine);
-
- SPnt1.InfoSecond(Type,SegIndex1onP2,ParamOnLine);
- if(SegIndex1onP2 > Poly1.NbSegments()) { SegIndex1onP2--; ParamOnLine = 1.0; }
- if(SegIndex1onP2 <= 0) { SegIndex1onP2=1; ParamOnLine = 0.0; }
- _PolyVInf = Poly1.ApproxParamOnCurve(SegIndex1onP2,ParamOnLine);
-
+ // Standard_Real _PolyUInf,_PolyUSup,_PolyVInf,_PolyVSup;
+ Standard_Real _PolyUInf, _PolyVInf;
+
+ SPnt1.InfoFirst(Type, SegIndex1onP1, ParamOnLine);
+ if (SegIndex1onP1 > Poly1.NbSegments())
+ {
+ SegIndex1onP1--;
+ ParamOnLine = 1.0;
+ }
+ if (SegIndex1onP1 <= 0)
+ {
+ SegIndex1onP1 = 1;
+ ParamOnLine = 0.0;
+ }
+ _PolyUInf = Poly1.ApproxParamOnCurve(SegIndex1onP1, ParamOnLine);
+
+ SPnt1.InfoSecond(Type, SegIndex1onP2, ParamOnLine);
+ if (SegIndex1onP2 > Poly1.NbSegments())
+ {
+ SegIndex1onP2--;
+ ParamOnLine = 1.0;
+ }
+ if (SegIndex1onP2 <= 0)
+ {
+ SegIndex1onP2 = 1;
+ ParamOnLine = 0.0;
+ }
+ _PolyVInf = Poly1.ApproxParamOnCurve(SegIndex1onP2, ParamOnLine);
+
//----------------------------------------------------------------------
- if(ParamInfOnCurve1 > _PolyUInf) ParamInfOnCurve1=_PolyUInf;
- if(ParamInfOnCurve2 > _PolyVInf) ParamInfOnCurve2=_PolyVInf;
+ if (ParamInfOnCurve1 > _PolyUInf)
+ ParamInfOnCurve1 = _PolyUInf;
+ if (ParamInfOnCurve2 > _PolyVInf)
+ ParamInfOnCurve2 = _PolyVInf;
- if(ParamSupOnCurve1 < _PolyUInf) ParamSupOnCurve1=_PolyUInf;
- if(ParamSupOnCurve2 < _PolyVInf) ParamSupOnCurve2=_PolyVInf;
+ if (ParamSupOnCurve1 < _PolyUInf)
+ ParamSupOnCurve1 = _PolyUInf;
+ if (ParamSupOnCurve2 < _PolyVInf)
+ ParamSupOnCurve2 = _PolyVInf;
}
- PolyUInf= ParamInfOnCurve1;
- PolyUSup= ParamSupOnCurve1;
- PolyVInf= ParamInfOnCurve2;
- PolyVSup= ParamSupOnCurve2;
-
- TheCurveTool::D0(C1,PolyUInf,P1);
- TheCurveTool::D0(C1,PolyVInf,P2);
+ PolyUInf = ParamInfOnCurve1;
+ PolyUSup = ParamSupOnCurve1;
+ PolyVInf = ParamInfOnCurve2;
+ PolyVSup = ParamSupOnCurve2;
+
+ TheCurveTool::D0(C1, PolyUInf, P1);
+ TheCurveTool::D0(C1, PolyVInf, P2);
Standard_Real distmemesens = P1.SquareDistance(P2);
- TheCurveTool::D0(C1,PolyVSup,P2);
+ TheCurveTool::D0(C1, PolyVSup, P2);
Standard_Real distdiffsens = P1.SquareDistance(P2);
- if(distmemesens > distdiffsens) {
- Standard_Real qwerty=PolyVInf; PolyVInf=PolyVSup; PolyVSup=qwerty;
+ if (distmemesens > distdiffsens)
+ {
+ Standard_Real qwerty = PolyVInf;
+ PolyVInf = PolyVSup;
+ PolyVSup = qwerty;
}
//-----------------------------------------------------------------
- //-- Calculate Positions of Points on the curve and
+ //-- Calculate Positions of Points on the curve and
//-- Transitions on each limit of the segment
-
- IntRes2d_Position Pos1 = IntRes2d_Middle;
- IntRes2d_Position Pos2 = IntRes2d_Middle;
- IntRes2d_Transition Trans1,Trans2;
-
- TheCurveTool::D1(C1,PolyUInf,P1,Tan1);
- TheCurveTool::D1(C1,PolyVInf,P2,Tan2);
-
- if(P1.Distance(DomainOnCurve1.FirstPoint())<=DomainOnCurve1.FirstTolerance()) {
+
+ IntRes2d_Position Pos1 = IntRes2d_Middle;
+ IntRes2d_Position Pos2 = IntRes2d_Middle;
+ IntRes2d_Transition Trans1, Trans2;
+
+ TheCurveTool::D1(C1, PolyUInf, P1, Tan1);
+ TheCurveTool::D1(C1, PolyVInf, P2, Tan2);
+
+ if (P1.Distance(DomainOnCurve1.FirstPoint()) <= DomainOnCurve1.FirstTolerance())
+ {
Pos1 = IntRes2d_Head;
}
- else if(P1.Distance(DomainOnCurve1.LastPoint())<=DomainOnCurve1.LastTolerance()) {
- Pos1 = IntRes2d_End;
+ else if (P1.Distance(DomainOnCurve1.LastPoint()) <= DomainOnCurve1.LastTolerance())
+ {
+ Pos1 = IntRes2d_End;
}
- if(P2.Distance(DomainOnCurve2.FirstPoint())<=DomainOnCurve2.FirstTolerance()) {
- Pos2 = IntRes2d_Head;
+ if (P2.Distance(DomainOnCurve2.FirstPoint()) <= DomainOnCurve2.FirstTolerance())
+ {
+ Pos2 = IntRes2d_Head;
}
- else if(P2.Distance(DomainOnCurve2.LastPoint())<=DomainOnCurve2.LastTolerance()) {
- Pos2 = IntRes2d_End;
+ else if (P2.Distance(DomainOnCurve2.LastPoint()) <= DomainOnCurve2.LastTolerance())
+ {
+ Pos2 = IntRes2d_End;
}
-
- if(Pos1==IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
- PolyUInf=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+
+ if (Pos1 == IntRes2d_Middle && Pos2 != IntRes2d_Middle)
+ {
+ PolyUInf = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else if(Pos1!=IntRes2d_Middle && Pos2==IntRes2d_Middle) {
- PolyVInf=TheProjPCur::FindParameter( C1,P1,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else if (Pos1 != IntRes2d_Middle && Pos2 == IntRes2d_Middle)
+ {
+ PolyVInf = TheProjPCur::FindParameter(C1,
+ P1,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else if(Abs(ParamInfOnCurve1-ParamSupOnCurve1) > Abs(ParamInfOnCurve2-ParamSupOnCurve2)) {
- PolyVInf=TheProjPCur::FindParameter( C1,P1,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else if (Abs(ParamInfOnCurve1 - ParamSupOnCurve1) > Abs(ParamInfOnCurve2 - ParamSupOnCurve2))
+ {
+ PolyVInf = TheProjPCur::FindParameter(C1,
+ P1,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else {
- PolyUInf=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else
+ {
+ PolyUInf = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
-
-
- if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1,Pos2,Tan2,Trans2,TolConf)
- == Standard_False)
+ if (IntImpParGen::DetermineTransition(Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf)
+ == Standard_False)
{
- TheCurveTool::D2(C1,PolyUInf,P1,Tan1,Norm1);
- TheCurveTool::D2(C1,PolyVInf,P2,Tan2,Norm2);
- IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
- Pos2,Tan2,Norm2,Trans2,TolConf);
+ TheCurveTool::D2(C1, PolyUInf, P1, Tan1, Norm1);
+ TheCurveTool::D2(C1, PolyVInf, P2, Tan2, Norm2);
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ TolConf);
}
- IntRes2d_IntersectionPoint PtSeg1(P1,PolyUInf,PolyVInf
- ,Trans1,Trans2,Standard_False);
+ IntRes2d_IntersectionPoint PtSeg1(P1, PolyUInf, PolyVInf, Trans1, Trans2, Standard_False);
//----------------------------------------------------------------------
-
- if((Abs(PolyUInf-PolyUSup) <= TheCurveTool::EpsX(C1)) ||
- (Abs(PolyVInf-PolyVSup) <= TheCurveTool::EpsX(C1)))
- {
- //bad segment
+
+ if ((Abs(PolyUInf - PolyUSup) <= TheCurveTool::EpsX(C1))
+ || (Abs(PolyVInf - PolyVSup) <= TheCurveTool::EpsX(C1)))
+ {
+ // bad segment
}
- else
- {
- TheCurveTool::D1(C1,PolyUSup,P1,Tan1);
- TheCurveTool::D1(C1,PolyVSup,P2,Tan2);
- Pos1 = IntRes2d_Middle; Pos2 = IntRes2d_Middle;
-
- if(P1.Distance(DomainOnCurve1.FirstPoint())<=DomainOnCurve1.FirstTolerance()) {
- Pos1 = IntRes2d_Head;
+ else
+ {
+ TheCurveTool::D1(C1, PolyUSup, P1, Tan1);
+ TheCurveTool::D1(C1, PolyVSup, P2, Tan2);
+ Pos1 = IntRes2d_Middle;
+ Pos2 = IntRes2d_Middle;
+
+ if (P1.Distance(DomainOnCurve1.FirstPoint()) <= DomainOnCurve1.FirstTolerance())
+ {
+ Pos1 = IntRes2d_Head;
}
- else if(P1.Distance(DomainOnCurve1.LastPoint())<=DomainOnCurve1.LastTolerance()) {
- Pos1 = IntRes2d_End;
+ else if (P1.Distance(DomainOnCurve1.LastPoint()) <= DomainOnCurve1.LastTolerance())
+ {
+ Pos1 = IntRes2d_End;
}
- if(P2.Distance(DomainOnCurve2.FirstPoint())<=DomainOnCurve2.FirstTolerance()) {
- Pos2 = IntRes2d_Head;
+ if (P2.Distance(DomainOnCurve2.FirstPoint()) <= DomainOnCurve2.FirstTolerance())
+ {
+ Pos2 = IntRes2d_Head;
}
- else if(P2.Distance(DomainOnCurve2.LastPoint())<=DomainOnCurve2.LastTolerance()) {
- Pos2 = IntRes2d_End;
+ else if (P2.Distance(DomainOnCurve2.LastPoint()) <= DomainOnCurve2.LastTolerance())
+ {
+ Pos2 = IntRes2d_End;
}
-
-
- if(Pos1==IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
- PolyUSup=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+
+ if (Pos1 == IntRes2d_Middle && Pos2 != IntRes2d_Middle)
+ {
+ PolyUSup = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else if(Pos1!=IntRes2d_Middle && Pos2==IntRes2d_Middle) {
- PolyVSup=TheProjPCur::FindParameter( C1,P1,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else if (Pos1 != IntRes2d_Middle && Pos2 == IntRes2d_Middle)
+ {
+ PolyVSup = TheProjPCur::FindParameter(C1,
+ P1,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else if(Abs(ParamInfOnCurve1-ParamSupOnCurve1) > Abs(ParamInfOnCurve2-ParamSupOnCurve2)) {
- PolyVSup=TheProjPCur::FindParameter( C1,P1,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else if (Abs(ParamInfOnCurve1 - ParamSupOnCurve1) > Abs(ParamInfOnCurve2 - ParamSupOnCurve2))
+ {
+ PolyVSup = TheProjPCur::FindParameter(C1,
+ P1,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else {
- PolyUSup=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else
+ {
+ PolyUSup = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
-
- if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1,Pos2,Tan2,Trans2,TolConf)
- ==Standard_False) {
- TheCurveTool::D2(C1,PolyUSup,P1,Tan1,Norm1);
- TheCurveTool::D2(C1,PolyVSup,P2,Tan2,Norm2);
- IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
- Pos2,Tan2,Norm2,Trans2,TolConf);
+
+ if (IntImpParGen::DetermineTransition(Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf)
+ == Standard_False)
+ {
+ TheCurveTool::D2(C1, PolyUSup, P1, Tan1, Norm1);
+ TheCurveTool::D2(C1, PolyVSup, P2, Tan2, Norm2);
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ TolConf);
}
- IntRes2d_IntersectionPoint PtSeg2(P1,PolyUSup,PolyVSup
- ,Trans1,Trans2,Standard_False);
-
- Standard_Boolean Oppos = (Tan1.Dot(Tan2) > 0.0)? Standard_False : Standard_True;
- if(ParamInfOnCurve1 > ParamSupOnCurve1) {
- IntRes2d_IntersectionSegment Seg(PtSeg2,PtSeg1,Oppos,Standard_False);
+ IntRes2d_IntersectionPoint PtSeg2(P1, PolyUSup, PolyVSup, Trans1, Trans2, Standard_False);
+
+ Standard_Boolean Oppos = (Tan1.Dot(Tan2) > 0.0) ? Standard_False : Standard_True;
+ if (ParamInfOnCurve1 > ParamSupOnCurve1)
+ {
+ IntRes2d_IntersectionSegment Seg(PtSeg2, PtSeg1, Oppos, Standard_False);
Append(Seg);
}
- else {
- IntRes2d_IntersectionSegment Seg(PtSeg1,PtSeg2,Oppos,Standard_False);
+ else
+ {
+ IntRes2d_IntersectionSegment Seg(PtSeg1, PtSeg2, Oppos, Standard_False);
Append(Seg);
}
}
- } //end of processing of TangentZone
-
- done = Standard_True;
+ } // end of processing of TangentZone
+
+ done = Standard_True;
}
+Standard_Boolean HeadOrEndPoint(const IntRes2d_Domain& D1,
+ const TheCurve& C1,
+ const Standard_Real tu,
+ const IntRes2d_Domain& D2,
+ const TheCurve& C2,
+ const Standard_Real tv,
+ const Standard_Real TolConf,
+ IntRes2d_IntersectionPoint& IntPt,
+ Standard_Boolean& HeadOn1,
+ Standard_Boolean& HeadOn2,
+ Standard_Boolean& EndOn1,
+ Standard_Boolean& EndOn2,
+ Standard_Integer PosSegment)
+{
-Standard_Boolean HeadOrEndPoint( const IntRes2d_Domain& D1
- ,const TheCurve& C1
- ,const Standard_Real tu
- ,const IntRes2d_Domain& D2
- ,const TheCurve& C2
- ,const Standard_Real tv
- ,const Standard_Real TolConf
- ,IntRes2d_IntersectionPoint& IntPt
- ,Standard_Boolean& HeadOn1
- ,Standard_Boolean& HeadOn2
- ,Standard_Boolean& EndOn1
- ,Standard_Boolean& EndOn2
- ,Standard_Integer PosSegment) {
-
- gp_Pnt2d P1,P2,SP1,SP2;
- gp_Vec2d T1,T2,N1,N2;
- Standard_Real u=tu;
- Standard_Real v=tv;
+ gp_Pnt2d P1, P2, SP1, SP2;
+ gp_Vec2d T1, T2, N1, N2;
+ Standard_Real u = tu;
+ Standard_Real v = tv;
Standard_Real svu = u;
Standard_Real svv = v;
- TheCurveTool::D1(C1,u,P1,T1);
- TheCurveTool::D1(C2,v,P2,T2);
-
- IntRes2d_Position Pos1 = IntRes2d_Middle;
- IntRes2d_Position Pos2 = IntRes2d_Middle;
- IntRes2d_Transition Trans1,Trans2;
+ TheCurveTool::D1(C1, u, P1, T1);
+ TheCurveTool::D1(C2, v, P2, T2);
+
+ IntRes2d_Position Pos1 = IntRes2d_Middle;
+ IntRes2d_Position Pos2 = IntRes2d_Middle;
+ IntRes2d_Transition Trans1, Trans2;
//----------------------------------------------------------------------
//-- Head On 1 : Head1 <-> P2
- if(P2.Distance(D1.FirstPoint())<=D1.FirstTolerance()) {
- Pos1 = IntRes2d_Head;
- HeadOn1 = Standard_True;
- SP1 = D1.FirstPoint();
- u = D1.FirstParameter();
+ if (P2.Distance(D1.FirstPoint()) <= D1.FirstTolerance())
+ {
+ Pos1 = IntRes2d_Head;
+ HeadOn1 = Standard_True;
+ SP1 = D1.FirstPoint();
+ u = D1.FirstParameter();
}
//----------------------------------------------------------------------
//-- End On 1 : End1 <-> P2
- else if(P2.Distance(D1.LastPoint())<=D1.LastTolerance()) {
- Pos1 = IntRes2d_End;
+ else if (P2.Distance(D1.LastPoint()) <= D1.LastTolerance())
+ {
+ Pos1 = IntRes2d_End;
EndOn1 = Standard_True;
- SP1 = D1.LastPoint();
- u = D1.LastParameter();
+ SP1 = D1.LastPoint();
+ u = D1.LastParameter();
}
//----------------------------------------------------------------------
//-- Head On 2 : Head2 <-> P1
- else if(P1.Distance(D2.FirstPoint())<=D2.FirstTolerance()) {
- Pos2 = IntRes2d_Head;
- HeadOn2 = Standard_True;
- SP2 = D2.FirstPoint();
- v = D2.FirstParameter();
+ else if (P1.Distance(D2.FirstPoint()) <= D2.FirstTolerance())
+ {
+ Pos2 = IntRes2d_Head;
+ HeadOn2 = Standard_True;
+ SP2 = D2.FirstPoint();
+ v = D2.FirstParameter();
}
//----------------------------------------------------------------------
//-- End On 2 : End2 <-> P1
- else if(P1.Distance(D2.LastPoint())<=D2.LastTolerance()) {
- Pos2 = IntRes2d_End;
+ else if (P1.Distance(D2.LastPoint()) <= D2.LastTolerance())
+ {
+ Pos2 = IntRes2d_End;
EndOn2 = Standard_True;
- SP2 = D2.LastPoint();
- v = D2.LastParameter();
+ SP2 = D2.LastPoint();
+ v = D2.LastParameter();
}
Standard_Real EpsX1 = TheCurveTool::EpsX(C1);
Standard_Real EpsX2 = TheCurveTool::EpsX(C2);
- if((Pos1 != IntRes2d_Middle)||(Pos2 != IntRes2d_Middle)) {
- if(Pos1 == IntRes2d_Middle) {
- if(Abs(u-D1.FirstParameter()) <= EpsX1) {
- Pos1 = IntRes2d_Head;
- P1 = D1.FirstPoint();
- HeadOn1 = Standard_True;
+ if ((Pos1 != IntRes2d_Middle) || (Pos2 != IntRes2d_Middle))
+ {
+ if (Pos1 == IntRes2d_Middle)
+ {
+ if (Abs(u - D1.FirstParameter()) <= EpsX1)
+ {
+ Pos1 = IntRes2d_Head;
+ P1 = D1.FirstPoint();
+ HeadOn1 = Standard_True;
}
- else if(Abs(u-D1.LastParameter()) <= EpsX1) {
- Pos1 = IntRes2d_End;
- P1 = D1.LastPoint();
- EndOn1 = Standard_True;
+ else if (Abs(u - D1.LastParameter()) <= EpsX1)
+ {
+ Pos1 = IntRes2d_End;
+ P1 = D1.LastPoint();
+ EndOn1 = Standard_True;
}
}
- else if(u!=tu) {
- P1 = SP1;
+ else if (u != tu)
+ {
+ P1 = SP1;
}
-
-
- if(Pos2 == IntRes2d_Middle) {
- if(Abs(v-D2.FirstParameter()) <= EpsX2) {
- Pos2 = IntRes2d_Head;
- HeadOn2 = Standard_True;
- P2 = D2.FirstPoint();
- if(Pos1 != IntRes2d_Middle) {
- P1.SetCoord(0.5*(P1.X()+P2.X()),0.5*(P1.Y()+P2.Y()));
- }
- else {
- P2 = P1;
- }
+
+ if (Pos2 == IntRes2d_Middle)
+ {
+ if (Abs(v - D2.FirstParameter()) <= EpsX2)
+ {
+ Pos2 = IntRes2d_Head;
+ HeadOn2 = Standard_True;
+ P2 = D2.FirstPoint();
+ if (Pos1 != IntRes2d_Middle)
+ {
+ P1.SetCoord(0.5 * (P1.X() + P2.X()), 0.5 * (P1.Y() + P2.Y()));
+ }
+ else
+ {
+ P2 = P1;
+ }
}
- else if(Abs(v-D2.LastParameter()) <= EpsX2) {
- Pos2 = IntRes2d_End;
- EndOn2 = Standard_True;
- P2 = D2.LastPoint();
- if(Pos1 != IntRes2d_Middle) {
- P1.SetCoord(0.5*(P1.X()+P2.X()),0.5*(P1.Y()+P2.Y()));
- }
- else {
- P2 = P1;
- }
+ else if (Abs(v - D2.LastParameter()) <= EpsX2)
+ {
+ Pos2 = IntRes2d_End;
+ EndOn2 = Standard_True;
+ P2 = D2.LastPoint();
+ if (Pos1 != IntRes2d_Middle)
+ {
+ P1.SetCoord(0.5 * (P1.X() + P2.X()), 0.5 * (P1.Y() + P2.Y()));
+ }
+ else
+ {
+ P2 = P1;
+ }
}
}
//--------------------------------------------------------------------
//-- It is tested if a point at the end of segment already has its transitions
//-- If Yes, the new point is not created
- //--
+ //--
//-- PosSegment = 1 if Head Head
//-- 2 if Head End
//-- 4 if End Head
//-- 8 if End End
//--------------------------------------------------------------------
- if(Pos1 == IntRes2d_Head) {
- if((Pos2 == IntRes2d_Head)&&(PosSegment & 1)) return(Standard_False);
- if((Pos2 == IntRes2d_End )&&(PosSegment & 2)) return(Standard_False);
+ if (Pos1 == IntRes2d_Head)
+ {
+ if ((Pos2 == IntRes2d_Head) && (PosSegment & 1))
+ return (Standard_False);
+ if ((Pos2 == IntRes2d_End) && (PosSegment & 2))
+ return (Standard_False);
}
- else if(Pos1 == IntRes2d_End) {
- if((Pos2 == IntRes2d_Head)&&(PosSegment & 4)) return(Standard_False);
- if((Pos2 == IntRes2d_End )&&(PosSegment & 8)) return(Standard_False);
+ else if (Pos1 == IntRes2d_End)
+ {
+ if ((Pos2 == IntRes2d_Head) && (PosSegment & 4))
+ return (Standard_False);
+ if ((Pos2 == IntRes2d_End) && (PosSegment & 8))
+ return (Standard_False);
}
-
- if(IntImpParGen::DetermineTransition( Pos1,T1,Trans1,Pos2,T2,Trans2,TolConf)
- == Standard_False) {
- TheCurveTool::D2(C1,svu,P1,T1,N1);
- TheCurveTool::D2(C2,svv,P2,T2,N2);
- IntImpParGen::DetermineTransition(Pos1,T1,N1,Trans1,
- Pos2,T2,N2,Trans2,TolConf);
+ if (IntImpParGen::DetermineTransition(Pos1, T1, Trans1, Pos2, T2, Trans2, TolConf)
+ == Standard_False)
+ {
+ TheCurveTool::D2(C1, svu, P1, T1, N1);
+ TheCurveTool::D2(C2, svv, P2, T2, N2);
+ IntImpParGen::DetermineTransition(Pos1, T1, N1, Trans1, Pos2, T2, N2, Trans2, TolConf);
}
- IntPt.SetValues(P1,u,v,Trans1,Trans2,Standard_False);
- return(Standard_True);
+ IntPt.SetValues(P1, u, v, Trans1, Trans2, Standard_False);
+ return (Standard_True);
}
- else
- return(Standard_False);
+ else
+ return (Standard_False);
}
//=======================================================================
-//function : Perform
-//purpose : Base method to perform polyline / polyline intersection for
+// function : Perform
+// purpose : Base method to perform polyline / polyline intersection for
// pair of curves.
//=======================================================================
-void IntCurve_IntPolyPolyGen::Perform(const TheCurve& C1,
+void IntCurve_IntPolyPolyGen::Perform(const TheCurve& C1,
const IntRes2d_Domain& D1,
- const TheCurve& C2,
+ const TheCurve& C2,
const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
const Standard_Integer NbIter,
- const Standard_Real DeltaU,
- const Standard_Real DeltaV)
+ const Standard_Real DeltaU,
+ const Standard_Real DeltaV)
{
- Standard_Integer nbsamplesOnC1,nbsamplesOnC2;
+ Standard_Integer nbsamplesOnC1, nbsamplesOnC2;
done = Standard_False;
- if(NbIter>NBITER_MAX_POLYGON) return;
+ if (NbIter > NBITER_MAX_POLYGON)
+ return;
// Number of samples running.
- nbsamplesOnC1 = TheCurveTool::NbSamples(C1,D1.FirstParameter(),D1.LastParameter());
- nbsamplesOnC2 = TheCurveTool::NbSamples(C2,D2.FirstParameter(),D2.LastParameter());
+ nbsamplesOnC1 = TheCurveTool::NbSamples(C1, D1.FirstParameter(), D1.LastParameter());
+ nbsamplesOnC2 = TheCurveTool::NbSamples(C2, D2.FirstParameter(), D2.LastParameter());
if (NbIter == 0)
{
else
{
// Increase number of samples in second and next iterations.
- nbsamplesOnC1=(5 * (nbsamplesOnC1 * NbIter)) / 4;
- nbsamplesOnC2=(5 * (nbsamplesOnC2 * NbIter)) / 4;
+ nbsamplesOnC1 = (5 * (nbsamplesOnC1 * NbIter)) / 4;
+ nbsamplesOnC2 = (5 * (nbsamplesOnC2 * NbIter)) / 4;
}
- NCollection_Handle<IntCurve_ThePolygon2d>
- aPoly1 = new IntCurve_ThePolygon2d(C1,nbsamplesOnC1,D1,Tol),
- aPoly2 = new IntCurve_ThePolygon2d(C2,nbsamplesOnC2,D2,Tol);
+ NCollection_Handle<IntCurve_ThePolygon2d> aPoly1 =
+ new IntCurve_ThePolygon2d(C1, nbsamplesOnC1, D1, Tol),
+ aPoly2 =
+ new IntCurve_ThePolygon2d(C2, nbsamplesOnC2, D2, Tol);
- if( (aPoly1->DeflectionOverEstimation() > TolConf) &&
- (aPoly2->DeflectionOverEstimation() > TolConf))
+ if ((aPoly1->DeflectionOverEstimation() > TolConf)
+ && (aPoly2->DeflectionOverEstimation() > TolConf))
{
- const Standard_Real aDeflectionSum =
- Max(aPoly1->DeflectionOverEstimation(), TolConf) +
- Max(aPoly2->DeflectionOverEstimation(), TolConf);
+ const Standard_Real aDeflectionSum = Max(aPoly1->DeflectionOverEstimation(), TolConf)
+ + Max(aPoly2->DeflectionOverEstimation(), TolConf);
if (nbsamplesOnC2 > nbsamplesOnC1)
{
//-- (Detection of Tangency Zones)
//----------------------------------------------------------------------
- if(aPoly1->DeflectionOverEstimation() < TolConf) {
+ if (aPoly1->DeflectionOverEstimation() < TolConf)
+ {
aPoly1->SetDeflectionOverEstimation(TolConf);
}
- if(aPoly2->DeflectionOverEstimation() < TolConf) {
+ if (aPoly2->DeflectionOverEstimation() < TolConf)
+ {
aPoly2->SetDeflectionOverEstimation(TolConf);
}
// for case when a few polygon points were replaced by line
- // if exact solution was not found
- // then search of precise solution will be repeated
+ // if exact solution was not found
+ // then search of precise solution will be repeated
// for polygon contains all initial points
// secondary search will be performed only for case when initial points
// were dropped
- Standard_Boolean isFullRepresentation = ( aPoly1->NbSegments() == nbsamplesOnC1 &&
- aPoly2->NbSegments() == nbsamplesOnC2 );
-
- if( !findIntersect( C1, D1, C2, D2, TolConf, Tol, NbIter,
- DeltaU, DeltaV, *aPoly1, *aPoly2, isFullRepresentation ) && !isFullRepresentation )
+ Standard_Boolean isFullRepresentation =
+ (aPoly1->NbSegments() == nbsamplesOnC1 && aPoly2->NbSegments() == nbsamplesOnC2);
+
+ if (!findIntersect(C1,
+ D1,
+ C2,
+ D2,
+ TolConf,
+ Tol,
+ NbIter,
+ DeltaU,
+ DeltaV,
+ *aPoly1,
+ *aPoly2,
+ isFullRepresentation)
+ && !isFullRepresentation)
{
- if(aPoly1->NbSegments() < nbsamplesOnC1)
+ if (aPoly1->NbSegments() < nbsamplesOnC1)
{
- aPoly1 = new IntCurve_ThePolygon2d(C1,nbsamplesOnC1,D1,Tol);
+ aPoly1 = new IntCurve_ThePolygon2d(C1, nbsamplesOnC1, D1, Tol);
}
- if(aPoly2->NbSegments() < nbsamplesOnC2)
+ if (aPoly2->NbSegments() < nbsamplesOnC2)
{
- aPoly2 = new IntCurve_ThePolygon2d(C2,nbsamplesOnC2,D2,Tol);
+ aPoly2 = new IntCurve_ThePolygon2d(C2, nbsamplesOnC2, D2, Tol);
}
- findIntersect( C1, D1, C2, D2, TolConf, Tol, NbIter,
- DeltaU, DeltaV, *aPoly1, *aPoly2,
- Standard_True);
-
+ findIntersect(C1,
+ D1,
+ C2,
+ D2,
+ TolConf,
+ Tol,
+ NbIter,
+ DeltaU,
+ DeltaV,
+ *aPoly1,
+ *aPoly2,
+ Standard_True);
}
-
+
done = Standard_True;
}
// Purpose : findIntersect
//======================================================================
-Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
- const TheCurve& C1,
- const IntRes2d_Domain& D1,
- const TheCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Integer NbIter,
- const Standard_Real DeltaU,
- const Standard_Real DeltaV,
- const IntCurve_ThePolygon2d& thePoly1,
- const IntCurve_ThePolygon2d& thePoly2,
- Standard_Boolean isFullPolygon )
+Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(const TheCurve& C1,
+ const IntRes2d_Domain& D1,
+ const TheCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Integer NbIter,
+ const Standard_Real DeltaU,
+ const Standard_Real DeltaV,
+ const IntCurve_ThePolygon2d& thePoly1,
+ const IntCurve_ThePolygon2d& thePoly2,
+ Standard_Boolean isFullPolygon)
{
- gp_Vec2d Tan1,Tan2,Norm1,Norm2;
- gp_Pnt2d P1,P2;
- Intf_InterferencePolygon2d InterPP(thePoly1,thePoly2);
- IntCurve_ExactIntersectionPoint EIP(C1,C2,TolConf);
- Standard_Real U = 0., V = 0.;
- Standard_Boolean AnErrorOccurred = Standard_False;
+ gp_Vec2d Tan1, Tan2, Norm1, Norm2;
+ gp_Pnt2d P1, P2;
+ Intf_InterferencePolygon2d InterPP(thePoly1, thePoly2);
+ IntCurve_ExactIntersectionPoint EIP(C1, C2, TolConf);
+ Standard_Real U = 0., V = 0.;
+ Standard_Boolean AnErrorOccurred = Standard_False;
done = Standard_True; // To prevent exception in nbp=NbPoints();
//----------------------------------------------------------------------
- //-- Processing of SectionPoint
+ //-- Processing of SectionPoint
//----------------------------------------------------------------------
Standard_Integer Nbsp = InterPP.NbSectionPoints();
- for(Standard_Integer sp=1; sp <= Nbsp; sp++) {
+ for (Standard_Integer sp = 1; sp <= Nbsp; sp++)
+ {
const Intf_SectionPoint& SPnt = InterPP.PntValue(sp);
- Standard_Integer SegIndex1,SegIndex2;
- Standard_Real ParamOn1,ParamOn2;
- Intf_PIType Type;
+ Standard_Integer SegIndex1, SegIndex2;
+ Standard_Real ParamOn1, ParamOn2;
+ Intf_PIType Type;
- SPnt.InfoFirst(Type,SegIndex1,ParamOn1);
- SPnt.InfoSecond(Type,SegIndex2,ParamOn2);
- EIP.Perform(thePoly1,thePoly2,SegIndex1,SegIndex2,ParamOn1,ParamOn2);
+ SPnt.InfoFirst(Type, SegIndex1, ParamOn1);
+ SPnt.InfoSecond(Type, SegIndex2, ParamOn2);
+ EIP.Perform(thePoly1, thePoly2, SegIndex1, SegIndex2, ParamOn1, ParamOn2);
AnErrorOccurred = EIP.AnErrorOccurred();
- if( !EIP.NbRoots() && !isFullPolygon)
+ if (!EIP.NbRoots() && !isFullPolygon)
return Standard_False;
- if(AnErrorOccurred)
+ if (AnErrorOccurred)
{
continue;
}
//-- It is checked if the found point is really a root
//--------------------------------------------------------------------
- EIP.Roots(U,V);
- TheCurveTool::D1(C1,U,P1,Tan1);
- TheCurveTool::D1(C2,V,P2,Tan2);
+ EIP.Roots(U, V);
+ TheCurveTool::D1(C1, U, P1, Tan1);
+ TheCurveTool::D1(C2, V, P2, Tan2);
Standard_Real Dist = P1.Distance(P2);
- if(EIP.NbRoots() == 0 && Dist > TolConf)
+ if (EIP.NbRoots() == 0 && Dist > TolConf)
{
- IntRes2d_Transition aTrans;
+ IntRes2d_Transition aTrans;
IntRes2d_IntersectionPoint aPInt(P1, U, V, aTrans, aTrans, Standard_False);
- Standard_Real aT1f, aT1l, aT2f, aT2l;
- aT1f= thePoly1.ApproxParamOnCurve(SegIndex1, 0.0);
- aT1l= thePoly1.ApproxParamOnCurve(SegIndex1, 1.0);
- aT2f= thePoly2.ApproxParamOnCurve(SegIndex2, 0.0);
- aT2l= thePoly2.ApproxParamOnCurve(SegIndex2, 1.0);
+ Standard_Real aT1f, aT1l, aT2f, aT2l;
+ aT1f = thePoly1.ApproxParamOnCurve(SegIndex1, 0.0);
+ aT1l = thePoly1.ApproxParamOnCurve(SegIndex1, 1.0);
+ aT2f = thePoly2.ApproxParamOnCurve(SegIndex2, 0.0);
+ aT2l = thePoly2.ApproxParamOnCurve(SegIndex2, 1.0);
//
Standard_Integer aMaxCount = 16, aCount = 0;
- GetIntersection(C1, aT1f, aT1l, C2, aT2f, aT2l, TolConf, aMaxCount,
- aPInt, Dist, aCount);
+ GetIntersection(C1, aT1f, aT1l, C2, aT2f, aT2l, TolConf, aMaxCount, aPInt, Dist, aCount);
U = aPInt.ParamOnFirst();
V = aPInt.ParamOnSecond();
- TheCurveTool::D1(C1,U,P1,Tan1);
- TheCurveTool::D1(C2,V,P2,Tan2);
+ TheCurveTool::D1(C1, U, P1, Tan1);
+ TheCurveTool::D1(C2, V, P2, Tan2);
Dist = P1.Distance(P2);
}
//-----------------------------------------------------------------
- //-- It is checked if the point (u,v) does not exist already
+ //-- It is checked if the point (u,v) does not exist already
//--
- Standard_Integer nbp=NbPoints();
- Standard_Real EpsX1 = 10.0*TheCurveTool::EpsX(C1);
- Standard_Real EpsX2 = 10.0*TheCurveTool::EpsX(C2);
- for(Standard_Integer p=1; p<=nbp; p++) {
- const IntRes2d_IntersectionPoint& P=Point(p);
- if(Abs(U-P.ParamOnFirst()) <= EpsX1) {
- if(Abs(V-P.ParamOnSecond()) <= EpsX2) {
- Dist = TolConf+1.0; p+=nbp;
+ Standard_Integer nbp = NbPoints();
+ Standard_Real EpsX1 = 10.0 * TheCurveTool::EpsX(C1);
+ Standard_Real EpsX2 = 10.0 * TheCurveTool::EpsX(C2);
+ for (Standard_Integer p = 1; p <= nbp; p++)
+ {
+ const IntRes2d_IntersectionPoint& P = Point(p);
+ if (Abs(U - P.ParamOnFirst()) <= EpsX1)
+ {
+ if (Abs(V - P.ParamOnSecond()) <= EpsX2)
+ {
+ Dist = TolConf + 1.0;
+ p += nbp;
}
}
}
- if(Dist <= TolConf) { //-- Or the point is already present
- IntRes2d_Position Pos1 = IntRes2d_Middle;
- IntRes2d_Position Pos2 = IntRes2d_Middle;
- IntRes2d_Transition Trans1,Trans2;
+ if (Dist <= TolConf)
+ { //-- Or the point is already present
+ IntRes2d_Position Pos1 = IntRes2d_Middle;
+ IntRes2d_Position Pos2 = IntRes2d_Middle;
+ IntRes2d_Transition Trans1, Trans2;
//-----------------------------------------------------------------
//-- Calculate the Positions of Points on the curve
//--
- if(P1.Distance(DomainOnCurve1.FirstPoint())<=DomainOnCurve1.FirstTolerance())
+ if (P1.Distance(DomainOnCurve1.FirstPoint()) <= DomainOnCurve1.FirstTolerance())
Pos1 = IntRes2d_Head;
- else if(P1.Distance(DomainOnCurve1.LastPoint())<=DomainOnCurve1.LastTolerance())
+ else if (P1.Distance(DomainOnCurve1.LastPoint()) <= DomainOnCurve1.LastTolerance())
Pos1 = IntRes2d_End;
- if(P2.Distance(DomainOnCurve2.FirstPoint())<=DomainOnCurve2.FirstTolerance())
+ if (P2.Distance(DomainOnCurve2.FirstPoint()) <= DomainOnCurve2.FirstTolerance())
Pos2 = IntRes2d_Head;
- else if(P2.Distance(DomainOnCurve2.LastPoint())<=DomainOnCurve2.LastTolerance())
+ else if (P2.Distance(DomainOnCurve2.LastPoint()) <= DomainOnCurve2.LastTolerance())
Pos2 = IntRes2d_End;
//-----------------------------------------------------------------
//-- Calculate the Transitions (see IntImpParGen.cxx)
//--
- if(IntImpParGen::DetermineTransition (Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf) == Standard_False) {
- TheCurveTool::D2(C1,U,P1,Tan1,Norm1);
- TheCurveTool::D2(C2,V,P2,Tan2,Norm2);
- IntImpParGen::DetermineTransition (Pos1, Tan1, Norm1, Trans1, Pos2, Tan2, Norm2, Trans2, TolConf);
+ if (IntImpParGen::DetermineTransition(Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf)
+ == Standard_False)
+ {
+ TheCurveTool::D2(C1, U, P1, Tan1, Norm1);
+ TheCurveTool::D2(C2, V, P2, Tan2, Norm2);
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ TolConf);
}
- IntRes2d_IntersectionPoint IP(P1,U,V,Trans1,Trans2,Standard_False);
+ IntRes2d_IntersectionPoint IP(P1, U, V, Trans1, Trans2, Standard_False);
Insert(IP);
}
}
-
+
//----------------------------------------------------------------------
//-- Processing of TangentZone
//----------------------------------------------------------------------
Standard_Integer Nbtz = InterPP.NbTangentZones();
- for(Standard_Integer tz=1; tz <= Nbtz; tz++) {
+ for (Standard_Integer tz = 1; tz <= Nbtz; tz++)
+ {
Standard_Integer NbPnts = InterPP.ZoneValue(tz).NumberOfPoints();
//====================================================================
//== Find the first and the last point in the tangency zone.
//====================================================================
- Standard_Real ParamSupOnCurve2,ParamInfOnCurve2;
- Standard_Real ParamSupOnCurve1,ParamInfOnCurve1;
-// Standard_Integer SegIndex,SegIndex1onP1,SegIndex1onP2,SegIndex2onP1,SegIndex2onP2;
- Standard_Integer SegIndex1onP1,SegIndex1onP2;
- Intf_PIType Type;
- Standard_Real ParamOnLine;
- Standard_Real PolyUInf,PolyUSup,PolyVInf,PolyVSup;
- ParamSupOnCurve2=ParamSupOnCurve1=PolyUSup=PolyVSup=-RealLast();
- ParamInfOnCurve2=ParamInfOnCurve1=PolyUInf=PolyVInf= RealLast();
- for(Standard_Integer qq=1;qq<=NbPnts;qq++) {
+ Standard_Real ParamSupOnCurve2, ParamInfOnCurve2;
+ Standard_Real ParamSupOnCurve1, ParamInfOnCurve1;
+ // Standard_Integer SegIndex,SegIndex1onP1,SegIndex1onP2,SegIndex2onP1,SegIndex2onP2;
+ Standard_Integer SegIndex1onP1, SegIndex1onP2;
+ Intf_PIType Type;
+ Standard_Real ParamOnLine;
+ Standard_Real PolyUInf, PolyUSup, PolyVInf, PolyVSup;
+ ParamSupOnCurve2 = ParamSupOnCurve1 = PolyUSup = PolyVSup = -RealLast();
+ ParamInfOnCurve2 = ParamInfOnCurve1 = PolyUInf = PolyVInf = RealLast();
+ for (Standard_Integer qq = 1; qq <= NbPnts; qq++)
+ {
const Intf_SectionPoint& SPnt1 = InterPP.ZoneValue(tz).GetPoint(qq);
//====================================================================
- //== The zones of tangency are discretized
- //== Test of stop : Check if
+ //== The zones of tangency are discretized
+ //== Test of stop : Check if
//== (Deflection < Tolerance)
- //== Or (Sample < EpsX) (normally the first condition is
+ //== Or (Sample < EpsX) (normally the first condition is
//== more strict)
//====================================================================
-// Standard_Real _PolyUInf,_PolyUSup,_PolyVInf,_PolyVSup;
- Standard_Real _PolyUInf,_PolyVInf;
-
- SPnt1.InfoFirst(Type,SegIndex1onP1,ParamOnLine);
- if(SegIndex1onP1 > thePoly1.NbSegments()) { SegIndex1onP1--; ParamOnLine = 1.0; }
- if(SegIndex1onP1 <= 0) { SegIndex1onP1=1; ParamOnLine = 0.0; }
- _PolyUInf = thePoly1.ApproxParamOnCurve(SegIndex1onP1,ParamOnLine);
-
- SPnt1.InfoSecond(Type,SegIndex1onP2,ParamOnLine);
- if(SegIndex1onP2 > thePoly2.NbSegments()) { SegIndex1onP2--; ParamOnLine = 1.0; }
- if(SegIndex1onP2 <= 0) { SegIndex1onP2=1; ParamOnLine = 0.0; }
- _PolyVInf = thePoly2.ApproxParamOnCurve(SegIndex1onP2,ParamOnLine);
-
+ // Standard_Real _PolyUInf,_PolyUSup,_PolyVInf,_PolyVSup;
+ Standard_Real _PolyUInf, _PolyVInf;
+
+ SPnt1.InfoFirst(Type, SegIndex1onP1, ParamOnLine);
+ if (SegIndex1onP1 > thePoly1.NbSegments())
+ {
+ SegIndex1onP1--;
+ ParamOnLine = 1.0;
+ }
+ if (SegIndex1onP1 <= 0)
+ {
+ SegIndex1onP1 = 1;
+ ParamOnLine = 0.0;
+ }
+ _PolyUInf = thePoly1.ApproxParamOnCurve(SegIndex1onP1, ParamOnLine);
+
+ SPnt1.InfoSecond(Type, SegIndex1onP2, ParamOnLine);
+ if (SegIndex1onP2 > thePoly2.NbSegments())
+ {
+ SegIndex1onP2--;
+ ParamOnLine = 1.0;
+ }
+ if (SegIndex1onP2 <= 0)
+ {
+ SegIndex1onP2 = 1;
+ ParamOnLine = 0.0;
+ }
+ _PolyVInf = thePoly2.ApproxParamOnCurve(SegIndex1onP2, ParamOnLine);
+
//----------------------------------------------------------------------
- if(ParamInfOnCurve1 > _PolyUInf) ParamInfOnCurve1=_PolyUInf;
- if(ParamInfOnCurve2 > _PolyVInf) ParamInfOnCurve2=_PolyVInf;
+ if (ParamInfOnCurve1 > _PolyUInf)
+ ParamInfOnCurve1 = _PolyUInf;
+ if (ParamInfOnCurve2 > _PolyVInf)
+ ParamInfOnCurve2 = _PolyVInf;
- if(ParamSupOnCurve1 < _PolyUInf) ParamSupOnCurve1=_PolyUInf;
- if(ParamSupOnCurve2 < _PolyVInf) ParamSupOnCurve2=_PolyVInf;
+ if (ParamSupOnCurve1 < _PolyUInf)
+ ParamSupOnCurve1 = _PolyUInf;
+ if (ParamSupOnCurve2 < _PolyVInf)
+ ParamSupOnCurve2 = _PolyVInf;
}
- PolyUInf= ParamInfOnCurve1;
- PolyUSup= ParamSupOnCurve1;
- PolyVInf= ParamInfOnCurve2;
- PolyVSup= ParamSupOnCurve2;
-
- TheCurveTool::D0(C1,PolyUInf,P1);
- TheCurveTool::D0(C2,PolyVInf,P2);
+ PolyUInf = ParamInfOnCurve1;
+ PolyUSup = ParamSupOnCurve1;
+ PolyVInf = ParamInfOnCurve2;
+ PolyVSup = ParamSupOnCurve2;
+
+ TheCurveTool::D0(C1, PolyUInf, P1);
+ TheCurveTool::D0(C2, PolyVInf, P2);
Standard_Real distmemesens = P1.SquareDistance(P2);
- TheCurveTool::D0(C2,PolyVSup,P2);
+ TheCurveTool::D0(C2, PolyVSup, P2);
Standard_Real distdiffsens = P1.SquareDistance(P2);
- if(distmemesens > distdiffsens) {
- Standard_Real qwerty=PolyVInf; PolyVInf=PolyVSup; PolyVSup=qwerty;
+ if (distmemesens > distdiffsens)
+ {
+ Standard_Real qwerty = PolyVInf;
+ PolyVInf = PolyVSup;
+ PolyVSup = qwerty;
}
- if( ( (thePoly1.DeflectionOverEstimation() > TolConf)
- ||(thePoly2.DeflectionOverEstimation() > TolConf))
- &&(NbIter<NBITER_MAX_POLYGON)) {
-
- IntRes2d_Domain RecursD1( TheCurveTool::Value(C1,ParamInfOnCurve1)
- ,ParamInfOnCurve1,TolConf
- ,TheCurveTool::Value(C1,ParamSupOnCurve1)
- ,ParamSupOnCurve1,TolConf);
- IntRes2d_Domain RecursD2( TheCurveTool::Value(C2,ParamInfOnCurve2)
- ,ParamInfOnCurve2,TolConf
- ,TheCurveTool::Value(C2,ParamSupOnCurve2)
- ,ParamSupOnCurve2,TolConf);
+ if (((thePoly1.DeflectionOverEstimation() > TolConf)
+ || (thePoly2.DeflectionOverEstimation() > TolConf))
+ && (NbIter < NBITER_MAX_POLYGON))
+ {
+
+ IntRes2d_Domain RecursD1(TheCurveTool::Value(C1, ParamInfOnCurve1),
+ ParamInfOnCurve1,
+ TolConf,
+ TheCurveTool::Value(C1, ParamSupOnCurve1),
+ ParamSupOnCurve1,
+ TolConf);
+ IntRes2d_Domain RecursD2(TheCurveTool::Value(C2, ParamInfOnCurve2),
+ ParamInfOnCurve2,
+ TolConf,
+ TheCurveTool::Value(C2, ParamSupOnCurve2),
+ ParamSupOnCurve2,
+ TolConf);
//-- thePoly1(2) are not deleted,
- //-- finally they are destroyed.
+ //-- finally they are destroyed.
//-- !! No untimely return !!
- Perform(C1,RecursD1,C2,RecursD2,Tol,TolConf,NbIter+1,DeltaU,DeltaV);
+ Perform(C1, RecursD1, C2, RecursD2, Tol, TolConf, NbIter + 1, DeltaU, DeltaV);
}
- else {
+ else
+ {
//-----------------------------------------------------------------
- //-- Calculate Positions of Points on the curve and
+ //-- Calculate Positions of Points on the curve and
//-- Transitions on each limit of the segment
-
- IntRes2d_Position Pos1 = IntRes2d_Middle;
- IntRes2d_Position Pos2 = IntRes2d_Middle;
- IntRes2d_Transition Trans1,Trans2;
-
- TheCurveTool::D1(C1,PolyUInf,P1,Tan1);
- TheCurveTool::D1(C2,PolyVInf,P2,Tan2);
-
- if(P1.Distance(DomainOnCurve1.FirstPoint())<=DomainOnCurve1.FirstTolerance()) {
- Pos1 = IntRes2d_Head;
+
+ IntRes2d_Position Pos1 = IntRes2d_Middle;
+ IntRes2d_Position Pos2 = IntRes2d_Middle;
+ IntRes2d_Transition Trans1, Trans2;
+
+ TheCurveTool::D1(C1, PolyUInf, P1, Tan1);
+ TheCurveTool::D1(C2, PolyVInf, P2, Tan2);
+
+ if (P1.Distance(DomainOnCurve1.FirstPoint()) <= DomainOnCurve1.FirstTolerance())
+ {
+ Pos1 = IntRes2d_Head;
}
- else if(P1.Distance(DomainOnCurve1.LastPoint())<=DomainOnCurve1.LastTolerance()) {
- Pos1 = IntRes2d_End;
+ else if (P1.Distance(DomainOnCurve1.LastPoint()) <= DomainOnCurve1.LastTolerance())
+ {
+ Pos1 = IntRes2d_End;
}
- if(P2.Distance(DomainOnCurve2.FirstPoint())<=DomainOnCurve2.FirstTolerance()) {
- Pos2 = IntRes2d_Head;
+ if (P2.Distance(DomainOnCurve2.FirstPoint()) <= DomainOnCurve2.FirstTolerance())
+ {
+ Pos2 = IntRes2d_Head;
}
- else if(P2.Distance(DomainOnCurve2.LastPoint())<=DomainOnCurve2.LastTolerance()) {
- Pos2 = IntRes2d_End;
+ else if (P2.Distance(DomainOnCurve2.LastPoint()) <= DomainOnCurve2.LastTolerance())
+ {
+ Pos2 = IntRes2d_End;
}
- if(Pos1==IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
- PolyUInf=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ if (Pos1 == IntRes2d_Middle && Pos2 != IntRes2d_Middle)
+ {
+ PolyUInf = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
- else if(Pos1!=IntRes2d_Middle && Pos2==IntRes2d_Middle) {
- PolyVInf=TheProjPCur::FindParameter( C2,P1,D2.FirstParameter(),D2.LastParameter(),TheCurveTool::EpsX(C2));
+ else if (Pos1 != IntRes2d_Middle && Pos2 == IntRes2d_Middle)
+ {
+ PolyVInf = TheProjPCur::FindParameter(C2,
+ P1,
+ D2.FirstParameter(),
+ D2.LastParameter(),
+ TheCurveTool::EpsX(C2));
}
- else if(Abs(ParamInfOnCurve1-ParamSupOnCurve1) > Abs(ParamInfOnCurve2-ParamSupOnCurve2)) {
- PolyVInf=TheProjPCur::FindParameter( C2,P1,D2.FirstParameter(),D2.LastParameter(),TheCurveTool::EpsX(C2));
+ else if (Abs(ParamInfOnCurve1 - ParamSupOnCurve1) > Abs(ParamInfOnCurve2 - ParamSupOnCurve2))
+ {
+ PolyVInf = TheProjPCur::FindParameter(C2,
+ P1,
+ D2.FirstParameter(),
+ D2.LastParameter(),
+ TheCurveTool::EpsX(C2));
}
- else {
- PolyUInf=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
+ else
+ {
+ PolyUInf = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
}
-
-
- if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1,Pos2,Tan2,Trans2,TolConf)
- == Standard_False)
+ if (IntImpParGen::DetermineTransition(Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf)
+ == Standard_False)
{
- TheCurveTool::D2(C1,PolyUInf,P1,Tan1,Norm1);
- TheCurveTool::D2(C2,PolyVInf,P2,Tan2,Norm2);
- IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
- Pos2,Tan2,Norm2,Trans2,TolConf);
+ TheCurveTool::D2(C1, PolyUInf, P1, Tan1, Norm1);
+ TheCurveTool::D2(C2, PolyVInf, P2, Tan2, Norm2);
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ TolConf);
}
- IntRes2d_IntersectionPoint PtSeg1(P1,PolyUInf,PolyVInf
- ,Trans1,Trans2,Standard_False);
+ IntRes2d_IntersectionPoint PtSeg1(P1, PolyUInf, PolyVInf, Trans1, Trans2, Standard_False);
//----------------------------------------------------------------------
-
- if((Abs(PolyUInf-PolyUSup) <= TheCurveTool::EpsX(C1))
- || (Abs(PolyVInf-PolyVSup) <= TheCurveTool::EpsX(C2)))
- {
- Insert(PtSeg1);
+
+ if ((Abs(PolyUInf - PolyUSup) <= TheCurveTool::EpsX(C1))
+ || (Abs(PolyVInf - PolyVSup) <= TheCurveTool::EpsX(C2)))
+ {
+ Insert(PtSeg1);
}
- else
- {
- TheCurveTool::D1(C1,PolyUSup,P1,Tan1);
- TheCurveTool::D1(C2,PolyVSup,P2,Tan2);
- Pos1 = IntRes2d_Middle; Pos2 = IntRes2d_Middle;
-
- if(P1.Distance(DomainOnCurve1.FirstPoint())<=DomainOnCurve1.FirstTolerance()) {
- Pos1 = IntRes2d_Head;
- }
- else if(P1.Distance(DomainOnCurve1.LastPoint())<=DomainOnCurve1.LastTolerance()) {
- Pos1 = IntRes2d_End;
- }
- if(P2.Distance(DomainOnCurve2.FirstPoint())<=DomainOnCurve2.FirstTolerance()) {
- Pos2 = IntRes2d_Head;
- }
- else if(P2.Distance(DomainOnCurve2.LastPoint())<=DomainOnCurve2.LastTolerance()) {
- Pos2 = IntRes2d_End;
- }
-
-
- if(Pos1==IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
- PolyUSup=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
- }
- else if(Pos1!=IntRes2d_Middle && Pos2==IntRes2d_Middle) {
- PolyVSup=TheProjPCur::FindParameter( C2,P1,D2.FirstParameter(),D2.LastParameter(),TheCurveTool::EpsX(C2));
- }
- else if(Abs(ParamInfOnCurve1-ParamSupOnCurve1) > Abs(ParamInfOnCurve2-ParamSupOnCurve2)) {
- PolyVSup=TheProjPCur::FindParameter( C2,P1,D2.FirstParameter(),D2.LastParameter(),TheCurveTool::EpsX(C2));
- }
- else {
- PolyUSup=TheProjPCur::FindParameter( C1,P2,D1.FirstParameter(),D1.LastParameter(),TheCurveTool::EpsX(C1));
- }
-
- if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1,Pos2,Tan2,Trans2,TolConf)
- ==Standard_False) {
- TheCurveTool::D2(C1,PolyUSup,P1,Tan1,Norm1);
- TheCurveTool::D2(C2,PolyVSup,P2,Tan2,Norm2);
- IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
- Pos2,Tan2,Norm2,Trans2,TolConf);
+ else
+ {
+ TheCurveTool::D1(C1, PolyUSup, P1, Tan1);
+ TheCurveTool::D1(C2, PolyVSup, P2, Tan2);
+ Pos1 = IntRes2d_Middle;
+ Pos2 = IntRes2d_Middle;
+
+ if (P1.Distance(DomainOnCurve1.FirstPoint()) <= DomainOnCurve1.FirstTolerance())
+ {
+ Pos1 = IntRes2d_Head;
+ }
+ else if (P1.Distance(DomainOnCurve1.LastPoint()) <= DomainOnCurve1.LastTolerance())
+ {
+ Pos1 = IntRes2d_End;
+ }
+ if (P2.Distance(DomainOnCurve2.FirstPoint()) <= DomainOnCurve2.FirstTolerance())
+ {
+ Pos2 = IntRes2d_Head;
+ }
+ else if (P2.Distance(DomainOnCurve2.LastPoint()) <= DomainOnCurve2.LastTolerance())
+ {
+ Pos2 = IntRes2d_End;
+ }
+
+ if (Pos1 == IntRes2d_Middle && Pos2 != IntRes2d_Middle)
+ {
+ PolyUSup = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
+ }
+ else if (Pos1 != IntRes2d_Middle && Pos2 == IntRes2d_Middle)
+ {
+ PolyVSup = TheProjPCur::FindParameter(C2,
+ P1,
+ D2.FirstParameter(),
+ D2.LastParameter(),
+ TheCurveTool::EpsX(C2));
+ }
+ else if (Abs(ParamInfOnCurve1 - ParamSupOnCurve1)
+ > Abs(ParamInfOnCurve2 - ParamSupOnCurve2))
+ {
+ PolyVSup = TheProjPCur::FindParameter(C2,
+ P1,
+ D2.FirstParameter(),
+ D2.LastParameter(),
+ TheCurveTool::EpsX(C2));
+ }
+ else
+ {
+ PolyUSup = TheProjPCur::FindParameter(C1,
+ P2,
+ D1.FirstParameter(),
+ D1.LastParameter(),
+ TheCurveTool::EpsX(C1));
+ }
+
+ if (IntImpParGen::DetermineTransition(Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf)
+ == Standard_False)
+ {
+ TheCurveTool::D2(C1, PolyUSup, P1, Tan1, Norm1);
+ TheCurveTool::D2(C2, PolyVSup, P2, Tan2, Norm2);
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ TolConf);
+ }
+ IntRes2d_IntersectionPoint PtSeg2(P1, PolyUSup, PolyVSup, Trans1, Trans2, Standard_False);
+
+ Standard_Boolean Oppos = (Tan1.Dot(Tan2) > 0.0) ? Standard_False : Standard_True;
+ if (ParamInfOnCurve1 > ParamSupOnCurve1)
+ {
+ IntRes2d_IntersectionSegment Seg(PtSeg2, PtSeg1, Oppos, Standard_False);
+ Append(Seg);
+ }
+ else
+ {
+ IntRes2d_IntersectionSegment Seg(PtSeg1, PtSeg2, Oppos, Standard_False);
+ Append(Seg);
}
- IntRes2d_IntersectionPoint PtSeg2(P1,PolyUSup,PolyVSup
- ,Trans1,Trans2,Standard_False);
-
- Standard_Boolean Oppos = (Tan1.Dot(Tan2) > 0.0)? Standard_False : Standard_True;
- if(ParamInfOnCurve1 > ParamSupOnCurve1) {
- IntRes2d_IntersectionSegment Seg(PtSeg2,PtSeg1,Oppos,Standard_False);
- Append(Seg);
- }
- else {
- IntRes2d_IntersectionSegment Seg(PtSeg1,PtSeg2,Oppos,Standard_False);
- Append(Seg);
- }
}
}
}
- return Standard_True;
+ return Standard_True;
}
//======================================================================
// GetIntersection
//======================================================================
-void GetIntersection(const TheCurve& theC1, const Standard_Real theT1f, const Standard_Real theT1l,
- const TheCurve& theC2, const Standard_Real theT2f, const Standard_Real theT2l,
- const Standard_Real theTolConf,
- const Standard_Integer theMaxCount,
- IntRes2d_IntersectionPoint& thePInt, Standard_Real& theDist,
- Standard_Integer& theCount)
+void GetIntersection(const TheCurve& theC1,
+ const Standard_Real theT1f,
+ const Standard_Real theT1l,
+ const TheCurve& theC2,
+ const Standard_Real theT2f,
+ const Standard_Real theT2l,
+ const Standard_Real theTolConf,
+ const Standard_Integer theMaxCount,
+ IntRes2d_IntersectionPoint& thePInt,
+ Standard_Real& theDist,
+ Standard_Integer& theCount)
{
theCount++;
//
- Standard_Real aTol2 = theTolConf*theTolConf;
- Standard_Real aPTol1 = Max(100.*Epsilon(Max(Abs(theT1f), Abs(theT1l))), Precision::PConfusion());
- Standard_Real aPTol2 = Max(100.*Epsilon(Max(Abs(theT2f), Abs(theT2l))), Precision::PConfusion());
- gp_Pnt2d aP1f, aP1l, aP2f, aP2l;
+ Standard_Real aTol2 = theTolConf * theTolConf;
+ Standard_Real aPTol1 =
+ Max(100. * Epsilon(Max(Abs(theT1f), Abs(theT1l))), Precision::PConfusion());
+ Standard_Real aPTol2 =
+ Max(100. * Epsilon(Max(Abs(theT2f), Abs(theT2l))), Precision::PConfusion());
+ gp_Pnt2d aP1f, aP1l, aP2f, aP2l;
Bnd_Box2d aB1, aB2;
//
TheCurveTool::D0(theC1, theT1f, aP1f);
aB2.Add(aP2l);
aB2.Enlarge(theTolConf);
//
- if(aB1.IsOut(aB2))
+ if (aB1.IsOut(aB2))
{
theCount--;
return;
}
//
- Standard_Boolean isSmall1 = (theT1l - theT1f) <= aPTol1 || aP1f.SquareDistance(aP1l) / 4. <= aTol2;
- Standard_Boolean isSmall2 = (theT2l - theT2f) <= aPTol2 || aP2f.SquareDistance(aP2l) / 4. <= aTol2;
+ Standard_Boolean isSmall1 =
+ (theT1l - theT1f) <= aPTol1 || aP1f.SquareDistance(aP1l) / 4. <= aTol2;
+ Standard_Boolean isSmall2 =
+ (theT2l - theT2f) <= aPTol2 || aP2f.SquareDistance(aP2l) / 4. <= aTol2;
- if((isSmall1 && isSmall2) || (theCount > theMaxCount))
+ if ((isSmall1 && isSmall2) || (theCount > theMaxCount))
{
- //Seems to be intersection
- //Simple treatment of segment intersection
- gp_XY aPnts1[3] = {aP1f.XY(), (aP1f.XY() + aP1l.XY()) / 2., aP1l.XY()};
- gp_XY aPnts2[3] = {aP2f.XY(), (aP2f.XY() + aP2l.XY()) / 2., aP2l.XY()};
+ // Seems to be intersection
+ // Simple treatment of segment intersection
+ gp_XY aPnts1[3] = {aP1f.XY(), (aP1f.XY() + aP1l.XY()) / 2., aP1l.XY()};
+ gp_XY aPnts2[3] = {aP2f.XY(), (aP2f.XY() + aP2l.XY()) / 2., aP2l.XY()};
Standard_Integer i, j, imin = -1, jmin = -1;
- Standard_Real dmin = RealLast(), d;
- for(i = 0; i < 3; i++)
+ Standard_Real dmin = RealLast(), d;
+ for (i = 0; i < 3; i++)
{
- for(j = 0; j < 3; j++)
+ for (j = 0; j < 3; j++)
{
d = (aPnts1[i] - aPnts2[j]).SquareModulus();
- if(d < dmin)
+ if (d < dmin)
{
- dmin=d;
+ dmin = d;
imin = i;
jmin = j;
}
}
//
dmin = Sqrt(dmin);
- if(theDist > dmin)
+ if (theDist > dmin)
{
theDist = dmin;
//
Standard_Real t1;
- if(imin == 0)
+ if (imin == 0)
{
t1 = theT1f;
}
- else if(imin == 1)
+ else if (imin == 1)
{
t1 = (theT1f + theT1l) / 2.;
}
}
//
Standard_Real t2;
- if(jmin == 0)
+ if (jmin == 0)
{
t2 = theT2f;
}
- else if(jmin == 1)
+ else if (jmin == 1)
{
t2 = (theT2f + theT2l) / 2.;
}
t2 = theT2l;
}
//
- gp_Pnt2d aPint((aPnts1[imin] + aPnts2[jmin])/2.);
+ gp_Pnt2d aPint((aPnts1[imin] + aPnts2[jmin]) / 2.);
//
IntRes2d_Transition aTrans1, aTrans2;
thePInt.SetValues(aPint, t1, t2, aTrans1, aTrans2, Standard_False);
return;
}
- if(isSmall1)
+ if (isSmall1)
{
Standard_Real aT2m = (theT2l + theT2f) / 2.;
- GetIntersection(theC1, theT1f, theT1l, theC2, theT2f, aT2m, theTolConf, theMaxCount, thePInt, theDist, theCount);
- GetIntersection(theC1, theT1f, theT1l, theC2, aT2m, theT2l, theTolConf, theMaxCount, thePInt, theDist, theCount);
+ GetIntersection(theC1,
+ theT1f,
+ theT1l,
+ theC2,
+ theT2f,
+ aT2m,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
+ GetIntersection(theC1,
+ theT1f,
+ theT1l,
+ theC2,
+ aT2m,
+ theT2l,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
}
- else if(isSmall2)
+ else if (isSmall2)
{
Standard_Real aT1m = (theT1l + theT1f) / 2.;
- GetIntersection(theC1, theT1f, aT1m, theC2, theT2f, theT2l, theTolConf, theMaxCount, thePInt, theDist, theCount);
- GetIntersection(theC1, aT1m, theT1l, theC2, theT2f, theT2l, theTolConf, theMaxCount, thePInt, theDist, theCount);
+ GetIntersection(theC1,
+ theT1f,
+ aT1m,
+ theC2,
+ theT2f,
+ theT2l,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
+ GetIntersection(theC1,
+ aT1m,
+ theT1l,
+ theC2,
+ theT2f,
+ theT2l,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
}
else
{
Standard_Real aT1m = (theT1l + theT1f) / 2.;
Standard_Real aT2m = (theT2l + theT2f) / 2.;
- GetIntersection(theC1, theT1f, aT1m, theC2, theT2f, aT2m, theTolConf, theMaxCount, thePInt, theDist, theCount);
- GetIntersection(theC1, theT1f, aT1m, theC2, aT2m, theT2l, theTolConf, theMaxCount, thePInt, theDist, theCount);
- GetIntersection(theC1, aT1m, theT1l, theC2, theT2f, aT2m, theTolConf, theMaxCount, thePInt, theDist, theCount);
- GetIntersection(theC1, aT1m, theT1l, theC2, aT2m, theT2l, theTolConf, theMaxCount, thePInt, theDist, theCount);
+ GetIntersection(theC1,
+ theT1f,
+ aT1m,
+ theC2,
+ theT2f,
+ aT2m,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
+ GetIntersection(theC1,
+ theT1f,
+ aT1m,
+ theC2,
+ aT2m,
+ theT2l,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
+ GetIntersection(theC1,
+ aT1m,
+ theT1l,
+ theC2,
+ theT2f,
+ aT2m,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
+ GetIntersection(theC1,
+ aT1m,
+ theT1l,
+ theC2,
+ aT2m,
+ theT2l,
+ theTolConf,
+ theMaxCount,
+ thePInt,
+ theDist,
+ theCount);
}
-
}
//=================================================================================================
#include <gp_Vec2d.hxx>
#include <gp_Dir2d.hxx>
-
#define MAJORATION_DEFLECTION 1.5
+
//======================================================================
-//== We take samples on the Domain of the Curve NbPts Points
+//== We take samples on the Domain of the Curve NbPts Points
//== with constant parameters.
-//==
+//==
//== We estimate the maximum deflection taking the max distance between the
-//== right Curve.Value(X(i))-->Curve.Value(X(i+1))
+//== right Curve.Value(X(i))-->Curve.Value(X(i+1))
//== and the point Curve.Value(X(i+1/2))
//======================================================================
// Modified by Sergey KHROMOV - Mon Mar 24 12:02:43 2003 Begin
IntCurve_Polygon2dGen::IntCurve_Polygon2dGen(const TheCurve& C,
- const Standard_Integer tNbPts,
- const IntRes2d_Domain& D,
- const Standard_Real Tol):
-// Modified by Sergey KHROMOV - Mon Mar 24 12:02:45 2003 End
- ThePnts(1,(tNbPts<3)? 6 : (tNbPts+tNbPts)),
- TheParams(1,(tNbPts<3)? 6 : (tNbPts+tNbPts)),
- TheIndex(1,(tNbPts<3)? 6 : (tNbPts+tNbPts))
-{
-
- Standard_Integer NbPts = (tNbPts<3)? 3 : tNbPts;
- TheMaxNbPoints = NbPts+NbPts;
- NbPntIn = NbPts;
- //-----------------------------------------------------
+ const Standard_Integer tNbPts,
+ const IntRes2d_Domain& D,
+ const Standard_Real Tol)
+ : // Modified by Sergey KHROMOV - Mon Mar 24 12:02:45 2003 End
+ ThePnts(1, (tNbPts < 3) ? 6 : (tNbPts + tNbPts)),
+ TheParams(1, (tNbPts < 3) ? 6 : (tNbPts + tNbPts)),
+ TheIndex(1, (tNbPts < 3) ? 6 : (tNbPts + tNbPts))
+{
+
+ Standard_Integer NbPts = (tNbPts < 3) ? 3 : tNbPts;
+ TheMaxNbPoints = NbPts + NbPts;
+ NbPntIn = NbPts;
+ //-----------------------------------------------------
//--- Initialization of the breaking with d_Parametre constant
//---
Binf = D.FirstParameter();
//-----------------------------------------------------
//-- IntRes2d Raise if HasFirst returns False
//-- and accesses First Parameter
- //--
- Standard_Real u=Binf;
- Standard_Real u1=Bsup;
- Standard_Real du=(u1-u)/(Standard_Real)(NbPts-1);
-// Standard_Integer ip1,i=1;
- Standard_Integer i=1;
-
- do {
- gp_Pnt2d P=TheCurveTool::Value(C,u);
+ //--
+ Standard_Real u = Binf;
+ Standard_Real u1 = Bsup;
+ Standard_Real du = (u1 - u) / (Standard_Real)(NbPts - 1);
+ // Standard_Integer ip1,i=1;
+ Standard_Integer i = 1;
+
+ do
+ {
+ gp_Pnt2d P = TheCurveTool::Value(C, u);
myBox.Add(P);
- TheIndex.SetValue(i,i);
- ThePnts.SetValue(i,P);
- TheParams.SetValue(i,u);
- u+=du;
+ TheIndex.SetValue(i, i);
+ ThePnts.SetValue(i, P);
+ TheParams.SetValue(i, u);
+ u += du;
i++;
- }
- while(i<=NbPts);
-
+ } while (i <= NbPts);
//-----------------------------------------------------
//--- Calculate a maximal deflection
//---
-// Modified by Sergey KHROMOV - Mon Mar 24 12:03:05 2003 Begin
-// TheDeflection = 0.000000001;
- TheDeflection = Min(0.000000001, Tol/100.);
-// Modified by Sergey KHROMOV - Mon Mar 24 12:03:05 2003 End
- i=1;
- u=D.FirstParameter();
- u+=du * 0.5;
-
- do {
- gp_Pnt2d Pm = TheCurveTool::Value(C,u);
+ // Modified by Sergey KHROMOV - Mon Mar 24 12:03:05 2003 Begin
+ // TheDeflection = 0.000000001;
+ TheDeflection = Min(0.000000001, Tol / 100.);
+ // Modified by Sergey KHROMOV - Mon Mar 24 12:03:05 2003 End
+ i = 1;
+ u = D.FirstParameter();
+ u += du * 0.5;
+
+ do
+ {
+ gp_Pnt2d Pm = TheCurveTool::Value(C, u);
const gp_Pnt2d& P1 = ThePnts.Value(i);
- const gp_Pnt2d& P2 = ThePnts.Value(i+1);
+ const gp_Pnt2d& P2 = ThePnts.Value(i + 1);
- u+=du;
+ u += du;
i++;
-
- Standard_Real dx,dy,t=0;
- dx=P1.X()-P2.X(); if(dx<0) dx=-dx;
- dy=P1.Y()-P2.Y(); if(dy<0) dy=-dy;
- if(dx+dy>1e-12) {
- gp_Lin2d L(P1,gp_Dir2d(gp_Vec2d(P1,P2)));
+ Standard_Real dx, dy, t = 0;
+ dx = P1.X() - P2.X();
+ if (dx < 0)
+ dx = -dx;
+ dy = P1.Y() - P2.Y();
+ if (dy < 0)
+ dy = -dy;
+ if (dx + dy > 1e-12)
+ {
+ gp_Lin2d L(P1, gp_Dir2d(gp_Vec2d(P1, P2)));
t = L.Distance(Pm);
- if(t>TheDeflection) {
- TheDeflection = t;
+ if (t > TheDeflection)
+ {
+ TheDeflection = t;
}
}
- }
- while(i<NbPts);
+ } while (i < NbPts);
- myBox.Enlarge(TheDeflection*MAJORATION_DEFLECTION);
+ myBox.Enlarge(TheDeflection * MAJORATION_DEFLECTION);
ClosedPolygon = Standard_False;
}
-//======================================================================
-void IntCurve_Polygon2dGen::ComputeWithBox(const TheCurve& C,
- const Bnd_Box2d& BoxOtherPolygon) {
- if(myBox.IsOut(BoxOtherPolygon)) {
- NbPntIn=2;
+
+//=================================================================================================
+
+void IntCurve_Polygon2dGen::ComputeWithBox(const TheCurve& C, const Bnd_Box2d& BoxOtherPolygon)
+{
+ if (myBox.IsOut(BoxOtherPolygon))
+ {
+ NbPntIn = 2;
myBox.SetVoid();
}
- else {
- Standard_Real bx0,bx1,by0,by1;
- BoxOtherPolygon.Get(bx0,by0,bx1,by1);
+ else
+ {
+ Standard_Real bx0, bx1, by0, by1;
+ BoxOtherPolygon.Get(bx0, by0, bx1, by1);
- bx0-=TheDeflection;
- by0-=TheDeflection;
- bx1+=TheDeflection;
- by1+=TheDeflection;
+ bx0 -= TheDeflection;
+ by0 -= TheDeflection;
+ bx1 += TheDeflection;
+ by1 += TheDeflection;
Standard_Integer MaxIndexUsed = 1;
- Standard_Integer i,nbp;
- Standard_Integer Rprec,Ri;
- Standard_Real x,y;
-
+ Standard_Integer i, nbp;
+ Standard_Integer Rprec, Ri;
+ Standard_Real x, y;
+
nbp = 0;
- x = ThePnts.Value(TheIndex.Value(1)).X();
- y = ThePnts.Value(TheIndex.Value(1)).Y();
-
- Rprec = CalculRegion(x,y,bx0,bx1,by0,by1);
- for(i = 2; i<=NbPntIn; i++) {
+ x = ThePnts.Value(TheIndex.Value(1)).X();
+ y = ThePnts.Value(TheIndex.Value(1)).Y();
+
+ Rprec = CalculRegion(x, y, bx0, bx1, by0, by1);
+ for (i = 2; i <= NbPntIn; i++)
+ {
const gp_Pnt2d& P2d = ThePnts.Value(TheIndex.Value(i));
- Ri = CalculRegion(P2d.X(),P2d.Y(),bx0,bx1,by0,by1);
- if((Ri & Rprec)==0) {
- if(nbp) {
- if(TheIndex.Value(nbp) != TheIndex.Value(i-1)) {
+ Ri = CalculRegion(P2d.X(), P2d.Y(), bx0, bx1, by0, by1);
+ if ((Ri & Rprec) == 0)
+ {
+ if (nbp)
+ {
+ if (TheIndex.Value(nbp) != TheIndex.Value(i - 1))
+ {
nbp++;
- TheIndex.SetValue(nbp,TheIndex.Value(i-1));
+ TheIndex.SetValue(nbp, TheIndex.Value(i - 1));
}
}
- else {
+ else
+ {
nbp++;
- TheIndex.SetValue(nbp,TheIndex.Value(i-1));
+ TheIndex.SetValue(nbp, TheIndex.Value(i - 1));
}
nbp++;
- TheIndex.SetValue(nbp,TheIndex.Value(i));
- if(TheIndex.Value(i) > MaxIndexUsed) MaxIndexUsed = TheIndex.Value(i);
+ TheIndex.SetValue(nbp, TheIndex.Value(i));
+ if (TheIndex.Value(i) > MaxIndexUsed)
+ MaxIndexUsed = TheIndex.Value(i);
Rprec = Ri;
- }//if((Ri & Rprec)==0) condition
+ } // if((Ri & Rprec)==0) condition
Rprec = Ri;
}
- if(nbp==1) {
- NbPntIn=2;
+ if (nbp == 1)
+ {
+ NbPntIn = 2;
myBox.SetVoid();
}
- else {
+ else
+ {
myBox.SetVoid();
- if(nbp) {
- myBox.Add(ThePnts.Value(TheIndex.Value(1)));
+ if (nbp)
+ {
+ myBox.Add(ThePnts.Value(TheIndex.Value(1)));
}
Standard_Real RatioDeflection;
Standard_Integer nbpassagedeflection = 0;
-// Standard_Integer PointHasBeenAdded = 0;
- do {
- nbpassagedeflection++;
-// Modified by Sergey KHROMOV - Mon Mar 24 12:05:28 2003 Begin
-// Standard_Real NewDeflection = 0.0000001;
- Standard_Real NewDeflection = TheDeflection;
-// Modified by Sergey KHROMOV - Mon Mar 24 12:05:29 2003 End
- for(i=2; i<=nbp; i++) {
- Standard_Integer Ii = TheIndex.Value(i);
- Standard_Integer Iim1= TheIndex.Value(i-1);
- const gp_Pnt2d& Pi = ThePnts.Value(Ii);
- const gp_Pnt2d& Pim1 = ThePnts.Value(Iim1);
- myBox.Add(Pi);
- Standard_Integer Regi = CalculRegion(Pi.X(),Pi.Y(),bx0,bx1,by0,by1);
- Standard_Integer Regim1 = CalculRegion(Pim1.X(),Pim1.Y(),bx0,bx1,by0,by1);
- if((Regi & Regim1) == 0) {
- Standard_Real u = 0.5*( TheParams.Value(Ii)
- +TheParams.Value(Iim1));
- gp_Pnt2d Pm = TheCurveTool::Value(C,u);
- Standard_Real dx,dy,t=0;
- dx=Pim1.X()-Pi.X(); if(dx<0) dx=-dx;
- dy=Pim1.Y()-Pi.Y(); if(dy<0) dy=-dy;
- if(dx+dy>1e-12) {
- gp_Lin2d L(Pim1,gp_Dir2d(gp_Vec2d(Pim1,Pi)));
- t = L.Distance(Pm);
- if((MaxIndexUsed<(TheMaxNbPoints-1)) && (t>(TheDeflection * 0.5))) {
- const gp_Pnt2d& P1=Pim1;
- nbp++;
- for(Standard_Integer j=nbp; j>=i+1; j--) {
- TheIndex.SetValue(j,TheIndex.Value(j-1));
- }
- MaxIndexUsed++;
- TheIndex.SetValue(i,MaxIndexUsed);
- ThePnts.SetValue(MaxIndexUsed,Pm);
- TheParams.SetValue(MaxIndexUsed,u);
-
- Standard_Real u1m = 0.5*(u+TheParams.Value(TheIndex.Value(i-1)));
- gp_Pnt2d P1m = TheCurveTool::Value(C,u1m);
- gp_Lin2d L1m(P1,gp_Dir2d(gp_Vec2d(P1,Pm)));
- t = L1m.Distance(P1m);
- i--;
- }
- }
- else {
- if(t>NewDeflection) {
- NewDeflection = t;
- }
- }
- }
- }
- if(NewDeflection)
- RatioDeflection = TheDeflection / NewDeflection;
- else RatioDeflection = 10.0;
- TheDeflection = NewDeflection;
- NbPntIn = nbp;
- }
- while((RatioDeflection<3.0)
- && (nbpassagedeflection < 3)
- && (MaxIndexUsed<(TheMaxNbPoints-2)));
+ // Standard_Integer PointHasBeenAdded = 0;
+ do
+ {
+ nbpassagedeflection++;
+ // Modified by Sergey KHROMOV - Mon Mar 24 12:05:28 2003 Begin
+ // Standard_Real NewDeflection = 0.0000001;
+ Standard_Real NewDeflection = TheDeflection;
+ // Modified by Sergey KHROMOV - Mon Mar 24 12:05:29 2003 End
+ for (i = 2; i <= nbp; i++)
+ {
+ Standard_Integer Ii = TheIndex.Value(i);
+ Standard_Integer Iim1 = TheIndex.Value(i - 1);
+ const gp_Pnt2d& Pi = ThePnts.Value(Ii);
+ const gp_Pnt2d& Pim1 = ThePnts.Value(Iim1);
+ myBox.Add(Pi);
+ Standard_Integer Regi = CalculRegion(Pi.X(), Pi.Y(), bx0, bx1, by0, by1);
+ Standard_Integer Regim1 = CalculRegion(Pim1.X(), Pim1.Y(), bx0, bx1, by0, by1);
+ if ((Regi & Regim1) == 0)
+ {
+ Standard_Real u = 0.5 * (TheParams.Value(Ii) + TheParams.Value(Iim1));
+ gp_Pnt2d Pm = TheCurveTool::Value(C, u);
+ Standard_Real dx, dy, t = 0;
+ dx = Pim1.X() - Pi.X();
+ if (dx < 0)
+ dx = -dx;
+ dy = Pim1.Y() - Pi.Y();
+ if (dy < 0)
+ dy = -dy;
+ if (dx + dy > 1e-12)
+ {
+ gp_Lin2d L(Pim1, gp_Dir2d(gp_Vec2d(Pim1, Pi)));
+ t = L.Distance(Pm);
+ if ((MaxIndexUsed < (TheMaxNbPoints - 1)) && (t > (TheDeflection * 0.5)))
+ {
+ const gp_Pnt2d& P1 = Pim1;
+ nbp++;
+ for (Standard_Integer j = nbp; j >= i + 1; j--)
+ {
+ TheIndex.SetValue(j, TheIndex.Value(j - 1));
+ }
+ MaxIndexUsed++;
+ TheIndex.SetValue(i, MaxIndexUsed);
+ ThePnts.SetValue(MaxIndexUsed, Pm);
+ TheParams.SetValue(MaxIndexUsed, u);
+
+ Standard_Real u1m = 0.5 * (u + TheParams.Value(TheIndex.Value(i - 1)));
+ gp_Pnt2d P1m = TheCurveTool::Value(C, u1m);
+ gp_Lin2d L1m(P1, gp_Dir2d(gp_Vec2d(P1, Pm)));
+ t = L1m.Distance(P1m);
+ i--;
+ }
+ }
+ else
+ {
+ if (t > NewDeflection)
+ {
+ NewDeflection = t;
+ }
+ }
+ }
+ }
+ if (NewDeflection)
+ RatioDeflection = TheDeflection / NewDeflection;
+ else
+ RatioDeflection = 10.0;
+ TheDeflection = NewDeflection;
+ NbPntIn = nbp;
+ } while ((RatioDeflection < 3.0) && (nbpassagedeflection < 3)
+ && (MaxIndexUsed < (TheMaxNbPoints - 2)));
}
- TheDeflection*=MAJORATION_DEFLECTION;
+ TheDeflection *= MAJORATION_DEFLECTION;
myBox.Enlarge(TheDeflection);
}
ClosedPolygon = Standard_False;
Dump();
}
+Standard_Boolean IntCurve_Polygon2dGen::AutoIntersectionIsPossible() const
+{
-Standard_Boolean IntCurve_Polygon2dGen::AutoIntersectionIsPossible() const {
-
- gp_Vec2d VRef(ThePnts.Value(TheIndex.Value(1)),
- ThePnts.Value(TheIndex.Value(2)));
- for(Standard_Integer i=3; i<=NbPntIn; i++) {
- gp_Vec2d V(ThePnts.Value(TheIndex.Value(i-1)),
- ThePnts.Value(TheIndex.Value(i)));
- if(V.Dot(VRef)<0.0) {
- return(Standard_True);
+ gp_Vec2d VRef(ThePnts.Value(TheIndex.Value(1)), ThePnts.Value(TheIndex.Value(2)));
+ for (Standard_Integer i = 3; i <= NbPntIn; i++)
+ {
+ gp_Vec2d V(ThePnts.Value(TheIndex.Value(i - 1)), ThePnts.Value(TheIndex.Value(i)));
+ if (V.Dot(VRef) < 0.0)
+ {
+ return (Standard_True);
}
}
- return(Standard_False);
+ return (Standard_False);
}
-//======================================================================
-Standard_Real IntCurve_Polygon2dGen::ApproxParamOnCurve( const Standard_Integer Aindex
- ,const Standard_Real TheParamOnLine)
- const
+//=================================================================================================
+
+Standard_Real IntCurve_Polygon2dGen::ApproxParamOnCurve(const Standard_Integer Aindex,
+ const Standard_Real TheParamOnLine) const
{
- Standard_Integer Indexp1,Index = Aindex;
+ Standard_Integer Indexp1, Index = Aindex;
Standard_Real ParamOnLine = TheParamOnLine;
- if (Index > NbPntIn) {
- std::cout << "OutOfRange Polygon2d::ApproxParamOnCurve " <<std::endl;
+ if (Index > NbPntIn)
+ {
+ std::cout << "OutOfRange Polygon2d::ApproxParamOnCurve " << std::endl;
}
- if((Index == NbPntIn) && (ParamOnLine == 0.0)) {
- Index--; ParamOnLine=1.0;
+ if ((Index == NbPntIn) && (ParamOnLine == 0.0))
+ {
+ Index--;
+ ParamOnLine = 1.0;
}
- if(Index==0) {
- Index=1;
+ if (Index == 0)
+ {
+ Index = 1;
ParamOnLine = 0.0;
}
- Indexp1 = TheIndex.Value(Index+1);
+ Indexp1 = TheIndex.Value(Index + 1);
Index = TheIndex.Value(Index);
- Standard_Real du = TheParams.Value(Indexp1)-TheParams.Value(Index);
+ Standard_Real du = TheParams.Value(Indexp1) - TheParams.Value(Index);
Standard_Real u = TheParams.Value(Index) + ParamOnLine * du;
- return(u);
+ return (u);
}
-
//======================================================================
#if TEST
extern Standard_Boolean DebugPolygon2d;
-extern void DrawSegmentBlanc(const gp_Pnt2d& _P1,const gp_Pnt2d& _P2);
-extern void DrawSegment(const gp_Pnt2d& _P1,const gp_Pnt2d& _P2);
+extern void DrawSegmentBlanc(const gp_Pnt2d& _P1, const gp_Pnt2d& _P2);
+extern void DrawSegment(const gp_Pnt2d& _P1, const gp_Pnt2d& _P2);
-void IntCurve_Polygon2dGen::Dump(void) const {
- if(!DebugPolygon2d) return;
- Standard_Real bx0,bx1,by0,by1;
- if(myBox.IsVoid()) return;
- myBox.Get(bx0,by0,bx1,by1);
- DrawSegment(gp_Pnt2d(bx0,by0),gp_Pnt2d(bx1,by0));
- DrawSegment(gp_Pnt2d(bx1,by0),gp_Pnt2d(bx1,by1));
- DrawSegment(gp_Pnt2d(bx1,by1),gp_Pnt2d(bx0,by1));
- DrawSegment(gp_Pnt2d(bx0,by1),gp_Pnt2d(bx0,by0));
+void IntCurve_Polygon2dGen::Dump(void) const
+{
+ if (!DebugPolygon2d)
+ return;
+ Standard_Real bx0, bx1, by0, by1;
+ if (myBox.IsVoid())
+ return;
+ myBox.Get(bx0, by0, bx1, by1);
+ DrawSegment(gp_Pnt2d(bx0, by0), gp_Pnt2d(bx1, by0));
+ DrawSegment(gp_Pnt2d(bx1, by0), gp_Pnt2d(bx1, by1));
+ DrawSegment(gp_Pnt2d(bx1, by1), gp_Pnt2d(bx0, by1));
+ DrawSegment(gp_Pnt2d(bx0, by1), gp_Pnt2d(bx0, by0));
Standard_Integer i;
- if(NbPntIn<=1) return;
- for(i=2;i<=NbPntIn; i++) {
- DrawSegmentBlanc(ThePnts.Value(TheIndex.Value(i-1)),ThePnts.Value(TheIndex.Value(i)));
+ if (NbPntIn <= 1)
+ return;
+ for (i = 2; i <= NbPntIn; i++)
+ {
+ DrawSegmentBlanc(ThePnts.Value(TheIndex.Value(i - 1)), ThePnts.Value(TheIndex.Value(i)));
}
}
#else
-void IntCurve_Polygon2dGen::Dump(void) const {
+void IntCurve_Polygon2dGen::Dump(void) const
+{
static int debug = 0;
- if(debug) {
- Standard_Real bx0,bx1,by0,by1;
-
- std::cout<<"\n ----- Dump of IntCurve_Polygon2dGen -----"<<std::endl;
- if(myBox.IsVoid()) {
- std::cout<<" Polygone Vide "<<std::endl;
+ if (debug)
+ {
+ Standard_Real bx0, bx1, by0, by1;
+
+ std::cout << "\n ----- Dump of IntCurve_Polygon2dGen -----" << std::endl;
+ if (myBox.IsVoid())
+ {
+ std::cout << " Polygone Vide " << std::endl;
return;
}
- myBox.Get(bx0,by0,bx1,by1);
- std::cout<<" bx0:"<<bx0 <<std::endl;
- std::cout<<" by0:"<<by0<<std::endl;
- std::cout<<" bx1:"<<bx1<<std::endl;
- std::cout<<" by1:"<<by1<<std::endl;
-
+ myBox.Get(bx0, by0, bx1, by1);
+ std::cout << " bx0:" << bx0 << std::endl;
+ std::cout << " by0:" << by0 << std::endl;
+ std::cout << " bx1:" << bx1 << std::endl;
+ std::cout << " by1:" << by1 << std::endl;
+
Standard_Integer i;
- for(i=1;i<=NbPntIn; i++) {
+ for (i = 1; i <= NbPntIn; i++)
+ {
const gp_Pnt2d& P = ThePnts(TheIndex(i));
- std::cout<<" ("<<i<<") u:"<<TheParams.Value(TheIndex(i))<<" X:"<<P.X()<<" Y:"<<P.Y()<<std::endl;
+ std::cout << " (" << i << ") u:" << TheParams.Value(TheIndex(i)) << " X:" << P.X()
+ << " Y:" << P.Y() << std::endl;
}
}
-}
+}
#endif
//======================================================================
void IntCurve_Polygon2dGen::Segment(const Standard_Integer theIndex,
- gp_Pnt2d &theBegin, gp_Pnt2d &theEnd) const
+ gp_Pnt2d& theBegin,
+ gp_Pnt2d& theEnd) const
{
Standard_Integer ind = theIndex;
- theBegin = ThePnts(TheIndex(theIndex));
- if (theIndex >= NbPntIn) {
+ theBegin = ThePnts(TheIndex(theIndex));
+ if (theIndex >= NbPntIn)
+ {
if (!ClosedPolygon)
throw Standard_OutOfRange("IntCurve_Polygon2dGen::Segment!");
ind = 0;
}
- theEnd = ThePnts(TheIndex(ind+1));
+ theEnd = ThePnts(TheIndex(ind + 1));
}
+
//======================================================================
#include <Extrema_POnCurv2d.hxx>
-Standard_Real IntCurve_ProjPCurGen::FindParameter
- (const TheCurve& C,
- const gp_Pnt2d& P,
- const Standard_Real LowParameter,
- const Standard_Real HighParameter,
- const Standard_Real)
+Standard_Real IntCurve_ProjPCurGen::FindParameter(const TheCurve& C,
+ const gp_Pnt2d& P,
+ const Standard_Real LowParameter,
+ const Standard_Real HighParameter,
+ const Standard_Real)
{
- Standard_Real theparam,defaultparam;
- Standard_Integer NbPts = TheCurveTool::NbSamples(C);
- Standard_Real theEpsX = TheCurveTool::EpsX(C);
+ Standard_Real theparam, defaultparam;
+ Standard_Integer NbPts = TheCurveTool::NbSamples(C);
+ Standard_Real theEpsX = TheCurveTool::EpsX(C);
Extrema_POnCurv2d POnC;
-
- IntCurve_TheCurveLocator::Locate(P,C,NbPts,LowParameter,HighParameter,POnC);
+
+ IntCurve_TheCurveLocator::Locate(P, C, NbPts, LowParameter, HighParameter, POnC);
defaultparam = POnC.Parameter();
- IntCurve_TheLocateExtPC Loc(P,C,defaultparam,theEpsX);
+ IntCurve_TheLocateExtPC Loc(P, C, defaultparam, theEpsX);
- if(Loc.IsDone() == Standard_False) {
+ if (Loc.IsDone() == Standard_False)
+ {
//-- cout<<"\n Erreur dans LocateExtPC "<<endl;
theparam = defaultparam;
}
- else {
- if(Loc.IsMin() == Standard_False) {
+ else
+ {
+ if (Loc.IsMin() == Standard_False)
+ {
//-- cout<<"\n Erreur dans LocateExtPC (Maximum trouve) "<<endl;
theparam = defaultparam;
}
- else {
+ else
+ {
theparam = Loc.Point().Parameter();
}
}
return theparam;
}
-
-Standard_Real IntCurve_ProjPCurGen::FindParameter
- (const TheCurve& C,
- const gp_Pnt2d& P,
- const Standard_Real Tol)
+Standard_Real IntCurve_ProjPCurGen::FindParameter(const TheCurve& C,
+ const gp_Pnt2d& P,
+ const Standard_Real Tol)
{
Standard_Real theParam;
- theParam = FindParameter( C
- ,P
- ,TheCurveTool::FirstParameter(C)
- ,TheCurveTool::LastParameter(C)
- ,Tol);
+ theParam =
+ FindParameter(C, P, TheCurveTool::FirstParameter(C), TheCurveTool::LastParameter(C), Tol);
return theParam;
}
-
-
-
-
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
-#include <Precision.hxx>
+#include <Precision.hxx>
+IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen()
+{
+ done = Standard_False;
+}
+//=================================================================================================
-IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen () {
- done = Standard_False;
+IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Lin2d& Lin1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ Perform(Lin1, D1, C2, D2, TolConf, Tol);
}
-//-------------------------------------------------------------------------------------
-IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen (const gp_Lin2d& Lin1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- Perform(Lin1,D1,C2,D2,TolConf,Tol);
+
+//=================================================================================================
+
+IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Circ2d& Circ1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ Perform(Circ1, D1, C2, D2, TolConf, Tol);
}
-//-------------------------------------------------------------------------------------
-IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen (const gp_Circ2d& Circ1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- Perform(Circ1,D1,C2,D2,TolConf,Tol);
+
+//=================================================================================================
+
+IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Parab2d& Parab1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ Perform(Parab1, D1, C2, D2, TolConf, Tol);
}
-//-------------------------------------------------------------------------------------
-IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen (const gp_Parab2d& Parab1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- Perform(Parab1,D1,C2,D2,TolConf,Tol);
+
+//=================================================================================================
+
+IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Elips2d& Elips1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ Perform(Elips1, D1, C2, D2, TolConf, Tol);
}
-//-------------------------------------------------------------------------------------
-IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen (const gp_Elips2d& Elips1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- Perform(Elips1,D1,C2,D2,TolConf,Tol);
+
+//=================================================================================================
+
+IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Hypr2d& Hyper1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
+ Perform(Hyper1, D1, C2, D2, TolConf, Tol);
}
+
//-------------------------------------------------------------------------------------
-IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen (const gp_Hypr2d& Hyper1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
- Perform(Hyper1,D1,C2,D2,TolConf,Tol);
-}
-//-------------------------------------------------------------------------------------
+//=================================================================================================
-//----------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::Perform (const gp_Lin2d& Lin1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+void IntCurve_UserIntConicCurveGen::Perform(const gp_Lin2d& Lin1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
this->ResetFields();
Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
- if(NbInterC2 > 1) {
- Standard_Real ParamInf,ParamSup;
- Standard_Real D2FirstParam = D2.FirstParameter();
- Standard_Real D2LastParam = D2.LastParameter();
- Standard_Boolean Ok = Standard_True;
+ if (NbInterC2 > 1)
+ {
+ Standard_Real ParamInf, ParamSup;
+ Standard_Real D2FirstParam = D2.FirstParameter();
+ Standard_Real D2LastParam = D2.LastParameter();
+ Standard_Boolean Ok = Standard_True;
param1inf = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
- param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
+ param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
param2inf = ThePCurveTool::FirstParameter(C2);
param2sup = ThePCurveTool::LastParameter(C2);
IntRes2d_Domain DomainC2NumInter;
- TColStd_Array1OfReal Tab2(1,NbInterC2+1);
- ThePCurveTool::Intervals(C2,Tab2);
-
- for(Standard_Integer NumInterC2=1; Ok && (NumInterC2 <= NbInterC2);NumInterC2++) {
- ThePCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
- if((ParamInf > D2LastParam)||(ParamSup < D2FirstParam)) Ok=Standard_False;
- else {
- if(ParamInf < D2FirstParam) ParamInf = D2FirstParam;
- if(ParamSup > D2LastParam) ParamSup = D2LastParam;
- if((ParamSup - ParamInf) > RealEpsilon()) {
- DomainC2NumInter.SetValues(ThePCurveTool::Value(C2,ParamInf),
- ParamInf,
- D2.FirstTolerance(),
- ThePCurveTool::Value(C2,ParamSup),
- ParamSup,
- D2.LastTolerance());
- InternalPerform(Lin1,D1,C2,DomainC2NumInter,TolConf,Tol,Standard_True);
- }
+ TColStd_Array1OfReal Tab2(1, NbInterC2 + 1);
+ ThePCurveTool::Intervals(C2, Tab2);
+
+ for (Standard_Integer NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
+ {
+ ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
+ if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
+ Ok = Standard_False;
+ else
+ {
+ if (ParamInf < D2FirstParam)
+ ParamInf = D2FirstParam;
+ if (ParamSup > D2LastParam)
+ ParamSup = D2LastParam;
+ if ((ParamSup - ParamInf) > RealEpsilon())
+ {
+ DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
+ ParamInf,
+ D2.FirstTolerance(),
+ ThePCurveTool::Value(C2, ParamSup),
+ ParamSup,
+ D2.LastTolerance());
+ InternalPerform(Lin1, D1, C2, DomainC2NumInter, TolConf, Tol, Standard_True);
+ }
}
}
}
- else {
- InternalPerform(Lin1,D1,C2,D2,TolConf,Tol,Standard_False);
+ else
+ {
+ InternalPerform(Lin1, D1, C2, D2, TolConf, Tol, Standard_False);
}
}
-//--------------------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::Perform (const gp_Circ2d& Circ1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::Perform(const gp_Circ2d& Circ1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
this->ResetFields();
Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
- if(NbInterC2 > 1) {
- Standard_Real ParamInf,ParamSup;
- Standard_Real D2FirstParam = D2.FirstParameter();
- Standard_Real D2LastParam = D2.LastParameter();
- Standard_Boolean Ok = Standard_True;
-
+ if (NbInterC2 > 1)
+ {
+ Standard_Real ParamInf, ParamSup;
+ Standard_Real D2FirstParam = D2.FirstParameter();
+ Standard_Real D2LastParam = D2.LastParameter();
+ Standard_Boolean Ok = Standard_True;
+
param1inf = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
- param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
+ param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
param2inf = ThePCurveTool::FirstParameter(C2);
param2sup = ThePCurveTool::LastParameter(C2);
IntRes2d_Domain DomainC2NumInter;
-
- TColStd_Array1OfReal Tab2(1,NbInterC2+1);
- ThePCurveTool::Intervals(C2,Tab2);
-
-
- for(Standard_Integer NumInterC2=1; Ok && (NumInterC2<=NbInterC2);NumInterC2++) {
- ThePCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
- if((ParamInf > D2LastParam)||(ParamSup < D2FirstParam)) Ok=Standard_False;
- else {
- if(ParamInf < D2FirstParam) ParamInf = D2FirstParam;
- if(ParamSup > D2LastParam) ParamSup = D2LastParam;
- if((ParamSup - ParamInf) > RealEpsilon()) {
- DomainC2NumInter.SetValues(ThePCurveTool::Value(C2,ParamInf),
- ParamInf,
- D2.FirstTolerance(),
- ThePCurveTool::Value(C2,ParamSup),
- ParamSup,
- D2.LastTolerance());
- InternalPerform(Circ1,D1,C2,DomainC2NumInter,TolConf,Tol,Standard_True);
- }
+
+ TColStd_Array1OfReal Tab2(1, NbInterC2 + 1);
+ ThePCurveTool::Intervals(C2, Tab2);
+
+ for (Standard_Integer NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
+ {
+ ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
+ if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
+ Ok = Standard_False;
+ else
+ {
+ if (ParamInf < D2FirstParam)
+ ParamInf = D2FirstParam;
+ if (ParamSup > D2LastParam)
+ ParamSup = D2LastParam;
+ if ((ParamSup - ParamInf) > RealEpsilon())
+ {
+ DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
+ ParamInf,
+ D2.FirstTolerance(),
+ ThePCurveTool::Value(C2, ParamSup),
+ ParamSup,
+ D2.LastTolerance());
+ InternalPerform(Circ1, D1, C2, DomainC2NumInter, TolConf, Tol, Standard_True);
+ }
}
}
}
- else {
- InternalPerform(Circ1,D1,C2,D2,TolConf,Tol,Standard_False);
+ else
+ {
+ InternalPerform(Circ1, D1, C2, D2, TolConf, Tol, Standard_False);
}
}
-//--------------------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::Perform (const gp_Parab2d& Parab1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::Perform(const gp_Parab2d& Parab1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
this->ResetFields();
- Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
- if(NbInterC2 > 1) {
- Standard_Real ParamInf,ParamSup;
- Standard_Real D2FirstParam = D2.FirstParameter();
- Standard_Real D2LastParam = D2.LastParameter();
- Standard_Boolean Ok = Standard_True;
+ Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
+ if (NbInterC2 > 1)
+ {
+ Standard_Real ParamInf, ParamSup;
+ Standard_Real D2FirstParam = D2.FirstParameter();
+ Standard_Real D2LastParam = D2.LastParameter();
+ Standard_Boolean Ok = Standard_True;
param1inf = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
- param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
+ param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
param2inf = ThePCurveTool::FirstParameter(C2);
param2sup = ThePCurveTool::LastParameter(C2);
IntRes2d_Domain DomainC2NumInter;
- TColStd_Array1OfReal Tab2(1,NbInterC2+1);
- ThePCurveTool::Intervals(C2,Tab2);
-
- for(Standard_Integer NumInterC2=1; Ok && (NumInterC2<=NbInterC2);NumInterC2++) {
- ThePCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
- if((ParamInf > D2LastParam)||(ParamSup < D2FirstParam)) Ok=Standard_False;
- else {
- if(ParamInf < D2FirstParam) ParamInf = D2FirstParam;
- if(ParamSup > D2LastParam) ParamSup = D2LastParam;
- if((ParamSup - ParamInf) > RealEpsilon()) {
- DomainC2NumInter.SetValues(ThePCurveTool::Value(C2,ParamInf),
- ParamInf,
- D2.FirstTolerance(),
- ThePCurveTool::Value(C2,ParamSup),
- ParamSup,
- D2.LastTolerance());
- InternalPerform(Parab1,D1,C2,DomainC2NumInter,TolConf,Tol,Standard_True);
- }
+ TColStd_Array1OfReal Tab2(1, NbInterC2 + 1);
+ ThePCurveTool::Intervals(C2, Tab2);
+
+ for (Standard_Integer NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
+ {
+ ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
+ if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
+ Ok = Standard_False;
+ else
+ {
+ if (ParamInf < D2FirstParam)
+ ParamInf = D2FirstParam;
+ if (ParamSup > D2LastParam)
+ ParamSup = D2LastParam;
+ if ((ParamSup - ParamInf) > RealEpsilon())
+ {
+ DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
+ ParamInf,
+ D2.FirstTolerance(),
+ ThePCurveTool::Value(C2, ParamSup),
+ ParamSup,
+ D2.LastTolerance());
+ InternalPerform(Parab1, D1, C2, DomainC2NumInter, TolConf, Tol, Standard_True);
+ }
}
}
}
- else {
- InternalPerform(Parab1,D1,C2,D2,TolConf,Tol,Standard_False);
+ else
+ {
+ InternalPerform(Parab1, D1, C2, D2, TolConf, Tol, Standard_False);
}
}
-//--------------------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::Perform (const gp_Elips2d& Elips1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::Perform(const gp_Elips2d& Elips1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
this->ResetFields();
- Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
- if(NbInterC2 > 1) {
- Standard_Real ParamInf,ParamSup;
- Standard_Real D2FirstParam = D2.FirstParameter();
- Standard_Real D2LastParam = D2.LastParameter();
- Standard_Boolean Ok = Standard_True;
+ Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
+ if (NbInterC2 > 1)
+ {
+ Standard_Real ParamInf, ParamSup;
+ Standard_Real D2FirstParam = D2.FirstParameter();
+ Standard_Real D2LastParam = D2.LastParameter();
+ Standard_Boolean Ok = Standard_True;
param1inf = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
- param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
+ param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
param2inf = ThePCurveTool::FirstParameter(C2);
param2sup = ThePCurveTool::LastParameter(C2);
IntRes2d_Domain DomainC2NumInter;
- TColStd_Array1OfReal Tab2(1,NbInterC2+1);
- ThePCurveTool::Intervals(C2,Tab2);
-
- for(Standard_Integer NumInterC2=1; Ok && (NumInterC2<=NbInterC2);NumInterC2++) {
- ThePCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
- if((ParamInf > D2LastParam)||(ParamSup < D2FirstParam)) Ok=Standard_False;
- else {
- if(ParamInf < D2FirstParam) ParamInf = D2FirstParam;
- if(ParamSup > D2LastParam) ParamSup = D2LastParam;
- if((ParamSup - ParamInf) > RealEpsilon()) {
- DomainC2NumInter.SetValues(ThePCurveTool::Value(C2,ParamInf),
- ParamInf,
- D2.FirstTolerance(),
- ThePCurveTool::Value(C2,ParamSup),
- ParamSup,
- D2.LastTolerance());
- InternalPerform(Elips1,D1,C2,DomainC2NumInter,TolConf,Tol,Standard_True);
- }
+ TColStd_Array1OfReal Tab2(1, NbInterC2 + 1);
+ ThePCurveTool::Intervals(C2, Tab2);
+
+ for (Standard_Integer NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
+ {
+ ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
+ if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
+ Ok = Standard_False;
+ else
+ {
+ if (ParamInf < D2FirstParam)
+ ParamInf = D2FirstParam;
+ if (ParamSup > D2LastParam)
+ ParamSup = D2LastParam;
+ if ((ParamSup - ParamInf) > RealEpsilon())
+ {
+ DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
+ ParamInf,
+ D2.FirstTolerance(),
+ ThePCurveTool::Value(C2, ParamSup),
+ ParamSup,
+ D2.LastTolerance());
+ InternalPerform(Elips1, D1, C2, DomainC2NumInter, TolConf, Tol, Standard_True);
+ }
}
}
}
- else {
- InternalPerform(Elips1,D1,C2,D2,TolConf,Tol,Standard_False);
+ else
+ {
+ InternalPerform(Elips1, D1, C2, D2, TolConf, Tol, Standard_False);
}
}
-//--------------------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::Perform (const gp_Hypr2d& Hyper1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::Perform(const gp_Hypr2d& Hyper1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
this->ResetFields();
- Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
- if(NbInterC2 > 1) {
- Standard_Real ParamInf,ParamSup;
- Standard_Real D2FirstParam = D2.FirstParameter();
- Standard_Real D2LastParam = D2.LastParameter();
- Standard_Boolean Ok = Standard_True;
+ Standard_Integer NbInterC2 = ThePCurveTool::NbIntervals(C2);
+ if (NbInterC2 > 1)
+ {
+ Standard_Real ParamInf, ParamSup;
+ Standard_Real D2FirstParam = D2.FirstParameter();
+ Standard_Real D2LastParam = D2.LastParameter();
+ Standard_Boolean Ok = Standard_True;
param1inf = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
- param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
+ param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
param2inf = ThePCurveTool::FirstParameter(C2);
param2sup = ThePCurveTool::LastParameter(C2);
IntRes2d_Domain DomainC2NumInter;
-
- TColStd_Array1OfReal Tab2(1,NbInterC2+1);
- ThePCurveTool::Intervals(C2,Tab2);
-
- for(Standard_Integer NumInterC2=1; Ok && (NumInterC2<=NbInterC2);NumInterC2++) {
- ThePCurveTool::GetInterval(C2,NumInterC2,Tab2,ParamInf,ParamSup);
- if((ParamInf > D2LastParam)||(ParamSup < D2FirstParam)) Ok=Standard_False;
- else {
- if(ParamInf < D2FirstParam) ParamInf = D2FirstParam;
- if(ParamSup > D2LastParam) ParamSup = D2LastParam;
- if((ParamSup - ParamInf) > RealEpsilon()) {
- DomainC2NumInter.SetValues(ThePCurveTool::Value(C2,ParamInf),
- ParamInf,
- D2.FirstTolerance(),
- ThePCurveTool::Value(C2,ParamSup),
- ParamSup,
- D2.LastTolerance());
- InternalPerform(Hyper1,D1,C2,DomainC2NumInter,TolConf,Tol,Standard_True);
- }
+
+ TColStd_Array1OfReal Tab2(1, NbInterC2 + 1);
+ ThePCurveTool::Intervals(C2, Tab2);
+
+ for (Standard_Integer NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
+ {
+ ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
+ if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
+ Ok = Standard_False;
+ else
+ {
+ if (ParamInf < D2FirstParam)
+ ParamInf = D2FirstParam;
+ if (ParamSup > D2LastParam)
+ ParamSup = D2LastParam;
+ if ((ParamSup - ParamInf) > RealEpsilon())
+ {
+ DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
+ ParamInf,
+ D2.FirstTolerance(),
+ ThePCurveTool::Value(C2, ParamSup),
+ ParamSup,
+ D2.LastTolerance());
+ InternalPerform(Hyper1, D1, C2, DomainC2NumInter, TolConf, Tol, Standard_True);
+ }
}
}
}
- else {
- InternalPerform(Hyper1,D1,C2,D2,TolConf,Tol,Standard_False);
+ else
+ {
+ InternalPerform(Hyper1, D1, C2, D2, TolConf, Tol, Standard_False);
}
}
//----------------------------------------------------------------------
-//-- InternalPerform
+//-- InternalPerform
//-- Suppose des Courbes Lin...Hypr
-//-- Si Composite == True
-//-- Les Resultats sont Ajoutes
+//-- Si Composite == True
+//-- Les Resultats sont Ajoutes
//-- Sinon
//-- Les Resultats sont Copies
//----------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::InternalPerform (const gp_Lin2d& Lin1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean Composite) {
+void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Lin2d& Lin1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean Composite)
+{
GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);
-
- switch (typ2) {
-
- case GeomAbs_Line:
- {
+
+ switch (typ2)
+ {
+
+ case GeomAbs_Line: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Lin1,D1,ThePCurveTool::Line(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Lin1, D1, ThePCurveTool::Line(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Circle:
- {
+
+ case GeomAbs_Circle: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Lin1,D1,ThePCurveTool::Circle(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Lin1, D1, ThePCurveTool::Circle(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Ellipse:
- {
+
+ case GeomAbs_Ellipse: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Lin1,D1,ThePCurveTool::Ellipse(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Lin1, D1, ThePCurveTool::Ellipse(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Parabola:
- {
+
+ case GeomAbs_Parabola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Lin1,D1,ThePCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Lin1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Hyperbola:
- {
+
+ case GeomAbs_Hyperbola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Lin1,D1,ThePCurveTool::Hyperbola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Lin1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- default:
- {
+
+ default: {
intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(Lin1,D1,C2,D2,TolConf,Tol);
- if(Composite) { this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconicurv); }
+ intconicurv.Perform(Lin1, D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
break;
}
}
-
-//----------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::InternalPerform (const gp_Circ2d& Circ1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean Composite) {
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Circ2d& Circ1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean Composite)
+{
GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);
-
- switch (typ2) {
-
- case GeomAbs_Line:
- {
+
+ switch (typ2)
+ {
+
+ case GeomAbs_Line: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Line(C2),D2,Circ1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Line(C2), D2, Circ1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Circle:
- {
+
+ case GeomAbs_Circle: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Circ1,D1,ThePCurveTool::Circle(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Circ1, D1, ThePCurveTool::Circle(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Ellipse:
- {
+
+ case GeomAbs_Ellipse: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Circ1,D1,ThePCurveTool::Ellipse(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Circ1, D1, ThePCurveTool::Ellipse(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Parabola:
- {
+
+ case GeomAbs_Parabola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Circ1,D1,ThePCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Circ1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Hyperbola:
- {
+
+ case GeomAbs_Hyperbola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Circ1,D1,ThePCurveTool::Hyperbola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Circ1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- default:
- {
+
+ default: {
intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(Circ1,D1,C2,D2,TolConf,Tol);
- if(Composite) { this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconicurv); }
- }
- break;
+ intconicurv.Perform(Circ1, D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
+ }
+ break;
}
}
-//----------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::InternalPerform (const gp_Elips2d& Elips1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean Composite) {
-
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Elips2d& Elips1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean Composite)
+{
+
GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);
-
- switch (typ2) {
-
- case GeomAbs_Line:
- {
+
+ switch (typ2)
+ {
+
+ case GeomAbs_Line: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Line(C2),D2,Elips1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Line(C2), D2, Elips1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Circle:
- {
+
+ case GeomAbs_Circle: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Circle(C2),D2,Elips1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Circle(C2), D2, Elips1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Ellipse:
- {
+
+ case GeomAbs_Ellipse: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Elips1,D1,ThePCurveTool::Ellipse(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Elips1, D1, ThePCurveTool::Ellipse(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Parabola:
- {
+
+ case GeomAbs_Parabola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Elips1,D1,ThePCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Elips1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Hyperbola:
- {
+
+ case GeomAbs_Hyperbola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Elips1,D1,ThePCurveTool::Hyperbola(C2),D2,
- TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Elips1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- default:
- {
+
+ default: {
intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(Elips1,D1,C2,D2,TolConf,Tol);
- if(Composite) { this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconicurv); }
+ intconicurv.Perform(Elips1, D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
break;
}
}
-//----------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::InternalPerform (const gp_Parab2d& Parab1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean Composite) {
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Parab2d& Parab1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean Composite)
+{
GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);
-
- switch (typ2) {
-
- case GeomAbs_Line:
- {
+
+ switch (typ2)
+ {
+
+ case GeomAbs_Line: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Line(C2),D2,Parab1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Line(C2), D2, Parab1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Circle:
- {
+
+ case GeomAbs_Circle: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Circle(C2),D2,Parab1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Circle(C2), D2, Parab1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Ellipse:
- {
+
+ case GeomAbs_Ellipse: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Ellipse(C2),D2,Parab1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Ellipse(C2), D2, Parab1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Parabola:
- {
+
+ case GeomAbs_Parabola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Parab1,D1,ThePCurveTool::Parabola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Parab1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Hyperbola:
- {
+
+ case GeomAbs_Hyperbola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Parab1,D1,ThePCurveTool::Hyperbola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Parab1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- default:
- {
+
+ default: {
intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(Parab1,D1,C2,D2,TolConf,Tol);
- if(Composite) { this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconicurv); }
+ intconicurv.Perform(Parab1, D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
break;
}
}
-
-//----------------------------------------------------------------------
-void IntCurve_UserIntConicCurveGen::InternalPerform (const gp_Hypr2d& Hyper1,
- const IntRes2d_Domain& D1,
- const ThePCurve& C2,
- const IntRes2d_Domain& D2,
- const Standard_Real TolConf,
- const Standard_Real Tol,
- const Standard_Boolean Composite) {
+
+//=================================================================================================
+
+void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Hypr2d& Hyper1,
+ const IntRes2d_Domain& D1,
+ const ThePCurve& C2,
+ const IntRes2d_Domain& D2,
+ const Standard_Real TolConf,
+ const Standard_Real Tol,
+ const Standard_Boolean Composite)
+{
GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);
-
- switch (typ2) {
-
- case GeomAbs_Line:
- {
+
+ switch (typ2)
+ {
+
+ case GeomAbs_Line: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Line(C2),D2,Hyper1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Line(C2), D2, Hyper1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Circle:
- {
+
+ case GeomAbs_Circle: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Circle(C2),D2,Hyper1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Circle(C2), D2, Hyper1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Ellipse:
- {
+
+ case GeomAbs_Ellipse: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Ellipse(C2),D2,Hyper1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Ellipse(C2), D2, Hyper1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Parabola:
- {
+
+ case GeomAbs_Parabola: {
intconiconi.SetReversedParameters(Standard_True);
- intconiconi.Perform(ThePCurveTool::Parabola(C2),D2,Hyper1,D1,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(ThePCurveTool::Parabola(C2), D2, Hyper1, D1, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- case GeomAbs_Hyperbola:
- {
+
+ case GeomAbs_Hyperbola: {
intconiconi.SetReversedParameters(Standard_False);
- intconiconi.Perform(Hyper1,D1,ThePCurveTool::Hyperbola(C2),D2,TolConf,Tol);
- if(Composite) { this->Append(intconiconi,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconiconi); }
+ intconiconi.Perform(Hyper1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconiconi);
+ }
}
break;
-
- default:
- {
+
+ default: {
intconicurv.SetReversedParameters(Standard_False);
- intconicurv.Perform(Hyper1,D1,
- C2,D2,TolConf,Tol);
- if(Composite) { this->Append(intconicurv,
- param1inf,
- param1sup,
- param2inf,
- param2sup); }
- else { this->SetValues(intconicurv); }
+ intconicurv.Perform(Hyper1, D1, C2, D2, TolConf, Tol);
+ if (Composite)
+ {
+ this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
+ }
+ else
+ {
+ this->SetValues(intconicurv);
+ }
}
break;
}
}
+
//--------------------------------------------------------------------------------
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#ifndef OCCT_DEBUG
-//#define No_Standard_RangeError
-//#define No_Standard_OutOfRange
-//#endif
+// #ifndef OCCT_DEBUG
+// #define No_Standard_RangeError
+// #define No_Standard_OutOfRange
+// #endif
+#define TOLTANGENCY 0.00000001
+#define TOLERANCE_ANGULAIRE 1.e-12 // 0.00000001
+#define TOLERANCE 0.00000001
-#define TOLTANGENCY 0.00000001
-#define TOLERANCE_ANGULAIRE 1.e-12//0.00000001
-#define TOLERANCE 0.00000001
-
-#define NBSAMPLESONCIRCLE 32
+#define NBSAMPLESONCIRCLE 32
#define NBSAMPLESONELLIPSE 32
-#define NBSAMPLESONPARAB 16
-#define NBSAMPLESONHYPR 32
+#define NBSAMPLESONPARAB 16
+#define NBSAMPLESONHYPR 32
#include <ElSLib.hxx>
#include <Intf_SectionPoint.hxx>
#include <Extrema_ExtElC.hxx>
#include <Extrema_POnCurv.hxx>
-
-
#include <ProjLib_Plane.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <gp_Lin2d.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_Surface.hxx>
-
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Adaptor3d_TopolTool.hxx>
#include <ElCLib.hxx>
-//#define ICS_DEB
-static
- void EstLimForInfExtr(const gp_Lin& Line,
- const TheSurface& surface,
- const Standard_Boolean IsOffSurf,
- const Standard_Integer nbsu,
- const Standard_Boolean U1inf,
- const Standard_Boolean U2inf,
- const Standard_Boolean V1inf,
- const Standard_Boolean V2inf,
- Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new,
- Standard_Boolean& NoIntersection);
-
-static
- void EstLimForInfRevl(const gp_Lin& Line,
- const TheSurface& surface,
- const Standard_Boolean U1inf,
- const Standard_Boolean U2inf,
- const Standard_Boolean V1inf,
- const Standard_Boolean V2inf,
- Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new,
- Standard_Boolean& NoIntersection);
-
-static
- void EstLimForInfOffs(const gp_Lin& Line,
- const TheSurface& surface,
- const Standard_Integer nbsu,
- const Standard_Boolean U1inf,
- const Standard_Boolean U2inf,
- const Standard_Boolean V1inf,
- const Standard_Boolean V2inf,
- Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new,
- Standard_Boolean& NoIntersection);
-
-static
- void EstLimForInfSurf(Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new);
-
-static
- void SectionPointToParameters(const Intf_SectionPoint& Sp,
- const IntCurveSurface_ThePolyhedron& Surf,
- const IntCurveSurface_ThePolygon& Curv,
- Standard_Real& u,
- Standard_Real& v,
- Standard_Real& w);
-
-static
- void IntCurveSurface_ComputeTransitions(const TheCurve& curve,
- const Standard_Real w,
- IntCurveSurface_TransitionOnCurve& TransOnCurve,
- const TheSurface& surface,
- const Standard_Real u,
- const Standard_Real v);
-
-static
- void IntCurveSurface_ComputeParamsOnQuadric(const TheSurface& surface,
- const gp_Pnt& P,
- Standard_Real& u,
- Standard_Real& v);
-
-static
- void ProjectIntersectAndEstLim(const gp_Lin& theLine,
- const gp_Pln& thePln,
- const ProjLib_Plane& theBasCurvProj,
- Standard_Real& theVmin,
- Standard_Real& theVmax,
- Standard_Boolean& theNoIntersection);
+// #define ICS_DEB
+static void EstLimForInfExtr(const gp_Lin& Line,
+ const TheSurface& surface,
+ const Standard_Boolean IsOffSurf,
+ const Standard_Integer nbsu,
+ const Standard_Boolean U1inf,
+ const Standard_Boolean U2inf,
+ const Standard_Boolean V1inf,
+ const Standard_Boolean V2inf,
+ Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new,
+ Standard_Boolean& NoIntersection);
+
+static void EstLimForInfRevl(const gp_Lin& Line,
+ const TheSurface& surface,
+ const Standard_Boolean U1inf,
+ const Standard_Boolean U2inf,
+ const Standard_Boolean V1inf,
+ const Standard_Boolean V2inf,
+ Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new,
+ Standard_Boolean& NoIntersection);
+
+static void EstLimForInfOffs(const gp_Lin& Line,
+ const TheSurface& surface,
+ const Standard_Integer nbsu,
+ const Standard_Boolean U1inf,
+ const Standard_Boolean U2inf,
+ const Standard_Boolean V1inf,
+ const Standard_Boolean V2inf,
+ Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new,
+ Standard_Boolean& NoIntersection);
+
+static void EstLimForInfSurf(Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new);
+
+static void SectionPointToParameters(const Intf_SectionPoint& Sp,
+ const IntCurveSurface_ThePolyhedron& Surf,
+ const IntCurveSurface_ThePolygon& Curv,
+ Standard_Real& u,
+ Standard_Real& v,
+ Standard_Real& w);
+
+static void IntCurveSurface_ComputeTransitions(const TheCurve& curve,
+ const Standard_Real w,
+ IntCurveSurface_TransitionOnCurve& TransOnCurve,
+ const TheSurface& surface,
+ const Standard_Real u,
+ const Standard_Real v);
+
+static void IntCurveSurface_ComputeParamsOnQuadric(const TheSurface& surface,
+ const gp_Pnt& P,
+ Standard_Real& u,
+ Standard_Real& v);
+
+static void ProjectIntersectAndEstLim(const gp_Lin& theLine,
+ const gp_Pln& thePln,
+ const ProjLib_Plane& theBasCurvProj,
+ Standard_Real& theVmin,
+ Standard_Real& theVmax,
+ Standard_Boolean& theNoIntersection);
//=================================================================================================
-IntCurveSurface_Inter::IntCurveSurface_Inter()
-{
-}
+IntCurveSurface_Inter::IntCurveSurface_Inter() {}
+
//=================================================================================================
void IntCurveSurface_Inter::DoSurface(const TheSurface& surface,
- const Standard_Real u0,
- const Standard_Real u1,
- const Standard_Real v0,
- const Standard_Real v1,
- TColgp_Array2OfPnt& pntsOnSurface,
- Bnd_Box& boxSurface,
- Standard_Real& gap)
+ const Standard_Real u0,
+ const Standard_Real u1,
+ const Standard_Real v0,
+ const Standard_Real v1,
+ TColgp_Array2OfPnt& pntsOnSurface,
+ Bnd_Box& boxSurface,
+ Standard_Real& gap)
{
Standard_Integer iU = 0, iV = 0;
- Standard_Real U = 0., V = 0;
-// modified by NIZHNY-MKK Mon Oct 3 17:38:45 2005
-// Standard_Real dU = fabs(u1-u0)/50., dV = fabs(v1-v0)/50.;
- Standard_Real dU = (u1-u0)/50., dV = (v1-v0)/50.;
- gp_Pnt aPnt;
-
- for(iU = 0; iU < 50; iU++) {
-
- if(iU == 0)
+ Standard_Real U = 0., V = 0;
+ // modified by NIZHNY-MKK Mon Oct 3 17:38:45 2005
+ // Standard_Real dU = fabs(u1-u0)/50., dV = fabs(v1-v0)/50.;
+ Standard_Real dU = (u1 - u0) / 50., dV = (v1 - v0) / 50.;
+ gp_Pnt aPnt;
+
+ for (iU = 0; iU < 50; iU++)
+ {
+
+ if (iU == 0)
U = u0;
- else if(iU == 49)
+ else if (iU == 49)
U = u1;
- else
+ else
U = u0 + dU * ((Standard_Real)iU);
-
- for(iV = 0; iV < 50; iV++) {
- if(iV == 0)
+ for (iV = 0; iV < 50; iV++)
+ {
+
+ if (iV == 0)
V = v0;
- else if(iV == 49)
+ else if (iV == 49)
V = v1;
else
V = v0 + dV * ((Standard_Real)iV);
- TheSurfaceTool::D0(surface,U,V,aPnt);
+ TheSurfaceTool::D0(surface, U, V, aPnt);
boxSurface.Add(aPnt);
- pntsOnSurface.SetValue(iU+1,iV+1,aPnt);
+ pntsOnSurface.SetValue(iU + 1, iV + 1, aPnt);
}
}
- Standard_Real Ures = TheSurfaceTool::UResolution(surface,dU);
- Standard_Real Vres = TheSurfaceTool::VResolution(surface,dV);
- gap = Max(Ures,Vres);
+ Standard_Real Ures = TheSurfaceTool::UResolution(surface, dU);
+ Standard_Real Vres = TheSurfaceTool::VResolution(surface, dV);
+ gap = Max(Ures, Vres);
}
//=================================================================================================
-void IntCurveSurface_Inter::DoNewBounds(
- const TheSurface& surface,
- const Standard_Real u0,
- const Standard_Real u1,
- const Standard_Real v0,
- const Standard_Real v1,
- const TColgp_Array2OfPnt& pntsOnSurface,
- const TColStd_Array1OfReal& X,
- const TColStd_Array1OfReal& Y,
- const TColStd_Array1OfReal& Z,
- TColStd_Array1OfReal& Bounds)
+void IntCurveSurface_Inter::DoNewBounds(const TheSurface& surface,
+ const Standard_Real u0,
+ const Standard_Real u1,
+ const Standard_Real v0,
+ const Standard_Real v1,
+ const TColgp_Array2OfPnt& pntsOnSurface,
+ const TColStd_Array1OfReal& X,
+ const TColStd_Array1OfReal& Y,
+ const TColStd_Array1OfReal& Z,
+ TColStd_Array1OfReal& Bounds)
{
- Bounds.SetValue(1,u0);
- Bounds.SetValue(2,u1);
- Bounds.SetValue(3,v0);
- Bounds.SetValue(4,v1);
-
- Standard_Boolean isUClosed = (TheSurfaceTool::IsUClosed(surface) || TheSurfaceTool::IsUPeriodic(surface));
- Standard_Boolean isVClosed = (TheSurfaceTool::IsVClosed(surface) || TheSurfaceTool::IsVPeriodic(surface));
+ Bounds.SetValue(1, u0);
+ Bounds.SetValue(2, u1);
+ Bounds.SetValue(3, v0);
+ Bounds.SetValue(4, v1);
+
+ Standard_Boolean isUClosed =
+ (TheSurfaceTool::IsUClosed(surface) || TheSurfaceTool::IsUPeriodic(surface));
+ Standard_Boolean isVClosed =
+ (TheSurfaceTool::IsVClosed(surface) || TheSurfaceTool::IsVPeriodic(surface));
Standard_Boolean checkU = (isUClosed) ? Standard_False : Standard_True;
Standard_Boolean checkV = (isVClosed) ? Standard_False : Standard_True;
Standard_Integer i = 0, j = 0, k = 0, iU = 0, iV = 0;
Standard_Integer iUmin = 50, iVmin = 50, iUmax = 1, iVmax = 1;
- for(i = 1; i <= 2; i++) {
- for(j = 1; j <= 2; j++) {
- for(k = 1; k <= 2; k++) {
- gp_Pnt aPoint(X(i),Y(j),Z(k));
- Standard_Real DistMin = 1.e+100;
+ for (i = 1; i <= 2; i++)
+ {
+ for (j = 1; j <= 2; j++)
+ {
+ for (k = 1; k <= 2; k++)
+ {
+ gp_Pnt aPoint(X(i), Y(j), Z(k));
+ Standard_Real DistMin = 1.e+100;
Standard_Integer diU = 0, diV = 0;
- for(iU = 1; iU <= 50; iU++) {
- for(iV = 1; iV <= 50; iV++) {
- const gp_Pnt aP = pntsOnSurface.Value(iU,iV);
+ for (iU = 1; iU <= 50; iU++)
+ {
+ for (iV = 1; iV <= 50; iV++)
+ {
+ const gp_Pnt aP = pntsOnSurface.Value(iU, iV);
Standard_Real dist = aP.SquareDistance(aPoint);
- if(dist < DistMin) {
+ if (dist < DistMin)
+ {
DistMin = dist;
- diU = iU;
- diV = iV;
+ diU = iU;
+ diV = iV;
}
}
}
- if(diU > 0 && diU < iUmin) iUmin = diU;
- if(diU > 0 && diU > iUmax) iUmax = diU;
- if(diV > 0 && diV < iVmin) iVmin = diV;
- if(diV > 0 && diV > iVmax) iVmax = diV;
+ if (diU > 0 && diU < iUmin)
+ iUmin = diU;
+ if (diU > 0 && diU > iUmax)
+ iUmax = diU;
+ if (diV > 0 && diV < iVmin)
+ iVmin = diV;
+ if (diV > 0 && diV > iVmax)
+ iVmax = diV;
}
}
}
-// modified by NIZHNY-MKK Mon Oct 3 17:38:43 2005
-// Standard_Real dU = fabs(u1-u0)/50., dV = fabs(v1-v0)/50.;
- Standard_Real dU = (u1-u0)/50., dV = (v1-v0)/50.;
+ // modified by NIZHNY-MKK Mon Oct 3 17:38:43 2005
+ // Standard_Real dU = fabs(u1-u0)/50., dV = fabs(v1-v0)/50.;
+ Standard_Real dU = (u1 - u0) / 50., dV = (v1 - v0) / 50.;
Standard_Real USmin = u0 + dU * ((Standard_Real)(iUmin - 1));
Standard_Real USmax = u0 + dU * ((Standard_Real)(iUmax - 1));
Standard_Real VSmin = v0 + dV * ((Standard_Real)(iVmin - 1));
Standard_Real VSmax = v0 + dV * ((Standard_Real)(iVmax - 1));
- if(USmin > USmax) {
+ if (USmin > USmax)
+ {
Standard_Real tmp = USmax;
- USmax = USmin;
- USmin = tmp;
+ USmax = USmin;
+ USmin = tmp;
}
- if(VSmin > VSmax) {
+ if (VSmin > VSmax)
+ {
Standard_Real tmp = VSmax;
- VSmax = VSmin;
- VSmin = tmp;
+ VSmax = VSmin;
+ VSmin = tmp;
}
- USmin -= 1.5*dU;
- if(USmin < u0) USmin = u0;
- USmax += 1.5*dU;
- if(USmax > u1) USmax = u1;
- VSmin -= 1.5*dV;
- if(VSmin < v0) VSmin = v0;
- VSmax += 1.5*dV;
- if(VSmax > v1) VSmax = v1;
-
- if(checkU) {
- Bounds.SetValue(1,USmin);
- Bounds.SetValue(2,USmax);
+ USmin -= 1.5 * dU;
+ if (USmin < u0)
+ USmin = u0;
+ USmax += 1.5 * dU;
+ if (USmax > u1)
+ USmax = u1;
+ VSmin -= 1.5 * dV;
+ if (VSmin < v0)
+ VSmin = v0;
+ VSmax += 1.5 * dV;
+ if (VSmax > v1)
+ VSmax = v1;
+
+ if (checkU)
+ {
+ Bounds.SetValue(1, USmin);
+ Bounds.SetValue(2, USmax);
}
- if(checkV) {
- Bounds.SetValue(3,VSmin);
- Bounds.SetValue(4,VSmax);
+ if (checkV)
+ {
+ Bounds.SetValue(3, VSmin);
+ Bounds.SetValue(4, VSmax);
}
}
//=======================================================================
-//function : Perform
-//purpose : Decompose la surface si besoin est
+// function : Perform
+// purpose : Decompose la surface si besoin est
//=======================================================================
-void IntCurveSurface_Inter::Perform(const TheCurve& curve,
- const TheSurface& surface)
+void IntCurveSurface_Inter::Perform(const TheCurve& curve, const TheSurface& surface)
{
ResetFields();
- done = Standard_True;
- Standard_Integer NbUOnS = TheSurfaceTool::NbUIntervals(surface,GeomAbs_C2);
- Standard_Integer NbVOnS = TheSurfaceTool::NbVIntervals(surface,GeomAbs_C2);
- Standard_Real U0,U1,V0,V1;
+ done = Standard_True;
+ Standard_Integer NbUOnS = TheSurfaceTool::NbUIntervals(surface, GeomAbs_C2);
+ Standard_Integer NbVOnS = TheSurfaceTool::NbVIntervals(surface, GeomAbs_C2);
+ Standard_Real U0, U1, V0, V1;
- if(NbUOnS > 1)
+ if (NbUOnS > 1)
{
- TColStd_Array1OfReal TabU(1,NbUOnS+1);
- TheSurfaceTool::UIntervals(surface,TabU,GeomAbs_C2);
- for(Standard_Integer iu = 1;iu <= NbUOnS; iu++)
+ TColStd_Array1OfReal TabU(1, NbUOnS + 1);
+ TheSurfaceTool::UIntervals(surface, TabU, GeomAbs_C2);
+ for (Standard_Integer iu = 1; iu <= NbUOnS; iu++)
{
U0 = TabU.Value(iu);
- U1 = TabU.Value(iu+1);
- if(NbVOnS > 1)
+ U1 = TabU.Value(iu + 1);
+ if (NbVOnS > 1)
{
- TColStd_Array1OfReal TabV(1,NbVOnS+1);
- TheSurfaceTool::VIntervals(surface,TabV,GeomAbs_C2);
- for(Standard_Integer iv = 1;iv <= NbVOnS; iv++)
+ TColStd_Array1OfReal TabV(1, NbVOnS + 1);
+ TheSurfaceTool::VIntervals(surface, TabV, GeomAbs_C2);
+ for (Standard_Integer iv = 1; iv <= NbVOnS; iv++)
{
// More than one interval on U and V param space.
V0 = TabV.Value(iv);
- V1 = TabV.Value(iv+1);
- Perform(curve,surface,U0,V0,U1,V1);
+ V1 = TabV.Value(iv + 1);
+ Perform(curve, surface, U0, V0, U1, V1);
}
}
else
// More than one interval only on U param space.
V0 = TheSurfaceTool::FirstVParameter(surface);
V1 = TheSurfaceTool::LastVParameter(surface);
- Perform(curve,surface,U0,V0,U1,V1);
+ Perform(curve, surface, U0, V0, U1, V1);
}
}
}
- else if(NbVOnS > 1)
+ else if (NbVOnS > 1)
{
// More than one interval only on V param space.
U0 = TheSurfaceTool::FirstUParameter(surface);
- U1 = TheSurfaceTool::LastUParameter(surface);
- TColStd_Array1OfReal TabV(1,NbVOnS+1);
- TheSurfaceTool::VIntervals(surface,TabV,GeomAbs_C2);
- for(Standard_Integer iv = 1;iv <= NbVOnS; iv++)
+ U1 = TheSurfaceTool::LastUParameter(surface);
+ TColStd_Array1OfReal TabV(1, NbVOnS + 1);
+ TheSurfaceTool::VIntervals(surface, TabV, GeomAbs_C2);
+ for (Standard_Integer iv = 1; iv <= NbVOnS; iv++)
{
V0 = TabV.Value(iv);
- V1 = TabV.Value(iv+1);
- Perform(curve,surface,U0,V0,U1,V1);
+ V1 = TabV.Value(iv + 1);
+ Perform(curve, surface, U0, V0, U1, V1);
}
}
else
U0 = TheSurfaceTool::FirstUParameter(surface);
U1 = TheSurfaceTool::LastUParameter(surface);
- Perform(curve,surface,U0,V0,U1,V1);
+ Perform(curve, surface, U0, V0, U1, V1);
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::Perform(const TheCurve& curve,
- const TheSurface& surface,
- const Standard_Real U1,const Standard_Real V1,
- const Standard_Real U2,const Standard_Real V2)
+void IntCurveSurface_Inter::Perform(const TheCurve& curve,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
{
// Protection from double type overflow.
// This may happen inside square magnitude computation based on normal,
Standard_Real UU1 = U1, UU2 = U2, VV1 = V1, VV2 = V2;
if (U1 < -1.0e50)
UU1 = -1.0e50;
- if (U2 > 1.0e50)
+ if (U2 > 1.0e50)
UU2 = 1.0e50;
if (V1 < -1.0e50)
VV1 = -1.0e50;
- if (V2 > 1.0e50)
+ if (V2 > 1.0e50)
VV2 = 1.0e50;
GeomAbs_CurveType CurveType = TheCurveTool::GetType(curve);
-
- switch(CurveType) {
- case GeomAbs_Line:
- {
- PerformConicSurf(TheCurveTool::Line(curve),curve,surface,UU1,VV1,UU2,VV2);
+
+ switch (CurveType)
+ {
+ case GeomAbs_Line: {
+ PerformConicSurf(TheCurveTool::Line(curve), curve, surface, UU1, VV1, UU2, VV2);
break;
}
- case GeomAbs_Circle:
- {
- PerformConicSurf(TheCurveTool::Circle(curve),curve,surface,UU1,VV1,UU2,VV2);
+ case GeomAbs_Circle: {
+ PerformConicSurf(TheCurveTool::Circle(curve), curve, surface, UU1, VV1, UU2, VV2);
break;
}
- case GeomAbs_Ellipse:
- {
- PerformConicSurf(TheCurveTool::Ellipse(curve),curve,surface,UU1,VV1,UU2,VV2);
+ case GeomAbs_Ellipse: {
+ PerformConicSurf(TheCurveTool::Ellipse(curve), curve, surface, UU1, VV1, UU2, VV2);
break;
- }
- case GeomAbs_Parabola:
- {
- PerformConicSurf(TheCurveTool::Parabola(curve),curve,surface,UU1,VV1,UU2,VV2);
+ }
+ case GeomAbs_Parabola: {
+ PerformConicSurf(TheCurveTool::Parabola(curve), curve, surface, UU1, VV1, UU2, VV2);
break;
}
- case GeomAbs_Hyperbola:
- {
- PerformConicSurf(TheCurveTool::Hyperbola(curve),curve,surface,UU1,VV1,UU2,VV2);
+ case GeomAbs_Hyperbola: {
+ PerformConicSurf(TheCurveTool::Hyperbola(curve), curve, surface, UU1, VV1, UU2, VV2);
break;
}
- default:
- {
- Standard_Integer nbIntervalsOnCurve = TheCurveTool::NbIntervals(curve,GeomAbs_C2);
- GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- if( (SurfaceType != GeomAbs_Plane)
- && (SurfaceType != GeomAbs_Cylinder)
- && (SurfaceType != GeomAbs_Cone)
- && (SurfaceType != GeomAbs_Sphere)) {
-
- if(nbIntervalsOnCurve > 1) {
- TColStd_Array1OfReal TabW(1,nbIntervalsOnCurve+1);
- TheCurveTool::Intervals(curve,TabW,GeomAbs_C2);
- for(Standard_Integer i = 1; i<=nbIntervalsOnCurve; i++) {
- Standard_Real u1,u2;
- u1 = TabW.Value(i);
- u2 = TabW.Value(i+1);
-
- Handle(TColStd_HArray1OfReal) aPars;
- Standard_Real defl = 0.1;
- Standard_Integer NbMin = 10;
- TheCurveTool::SamplePars(curve, u1, u2, defl, NbMin, aPars);
-
-// IntCurveSurface_ThePolygon polygon(curve,u1,u2,TheCurveTool::NbSamples(curve,u1,u2));
- IntCurveSurface_ThePolygon polygon(curve, aPars->Array1());
- InternalPerform(curve,polygon,surface,UU1,VV1,UU2,VV2);
- }
- }
- else {
- Standard_Real u1,u2;
- u1 = TheCurveTool::FirstParameter(curve);
- u2 = TheCurveTool::LastParameter(curve);
-
- Handle(TColStd_HArray1OfReal) aPars;
- Standard_Real defl = 0.1;
- Standard_Integer NbMin = 10;
- TheCurveTool::SamplePars(curve, u1, u2, defl, NbMin, aPars);
-
-// IntCurveSurface_ThePolygon polygon(curve,TheCurveTool::NbSamples(curve,u1,u2));
- IntCurveSurface_ThePolygon polygon(curve, aPars->Array1());
- InternalPerform(curve,polygon,surface,UU1,VV1,UU2,VV2);
- }
+ default: {
+ Standard_Integer nbIntervalsOnCurve = TheCurveTool::NbIntervals(curve, GeomAbs_C2);
+ GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
+ if ((SurfaceType != GeomAbs_Plane) && (SurfaceType != GeomAbs_Cylinder)
+ && (SurfaceType != GeomAbs_Cone) && (SurfaceType != GeomAbs_Sphere))
+ {
+
+ if (nbIntervalsOnCurve > 1)
+ {
+ TColStd_Array1OfReal TabW(1, nbIntervalsOnCurve + 1);
+ TheCurveTool::Intervals(curve, TabW, GeomAbs_C2);
+ for (Standard_Integer i = 1; i <= nbIntervalsOnCurve; i++)
+ {
+ Standard_Real u1, u2;
+ u1 = TabW.Value(i);
+ u2 = TabW.Value(i + 1);
+
+ Handle(TColStd_HArray1OfReal) aPars;
+ Standard_Real defl = 0.1;
+ Standard_Integer NbMin = 10;
+ TheCurveTool::SamplePars(curve, u1, u2, defl, NbMin, aPars);
+
+ // IntCurveSurface_ThePolygon
+ // polygon(curve,u1,u2,TheCurveTool::NbSamples(curve,u1,u2));
+ IntCurveSurface_ThePolygon polygon(curve, aPars->Array1());
+ InternalPerform(curve, polygon, surface, UU1, VV1, UU2, VV2);
+ }
+ }
+ else
+ {
+ Standard_Real u1, u2;
+ u1 = TheCurveTool::FirstParameter(curve);
+ u2 = TheCurveTool::LastParameter(curve);
+
+ Handle(TColStd_HArray1OfReal) aPars;
+ Standard_Real defl = 0.1;
+ Standard_Integer NbMin = 10;
+ TheCurveTool::SamplePars(curve, u1, u2, defl, NbMin, aPars);
+
+ // IntCurveSurface_ThePolygon polygon(curve,TheCurveTool::NbSamples(curve,u1,u2));
+ IntCurveSurface_ThePolygon polygon(curve, aPars->Array1());
+ InternalPerform(curve, polygon, surface, UU1, VV1, UU2, VV2);
+ }
}
- else { //-- la surface est une quadrique
- InternalPerformCurveQuadric(curve,surface);
+ else
+ { //-- la surface est une quadrique
+ InternalPerformCurveQuadric(curve, surface);
}
}
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::Perform(const TheCurve& curve,
- const IntCurveSurface_ThePolygon& polygon,
- const TheSurface& surface) {
+void IntCurveSurface_Inter::Perform(const TheCurve& curve,
+ const IntCurveSurface_ThePolygon& polygon,
+ const TheSurface& surface)
+{
ResetFields();
done = Standard_True;
- Standard_Real u1,v1,u2,v2;
+ Standard_Real u1, v1, u2, v2;
u1 = TheSurfaceTool::FirstUParameter(surface);
v1 = TheSurfaceTool::FirstVParameter(surface);
u2 = TheSurfaceTool::LastUParameter(surface);
v2 = TheSurfaceTool::LastVParameter(surface);
- Standard_Integer nbsu,nbsv;
- nbsu = TheSurfaceTool::NbSamplesU(surface,u1,u2);
- nbsv = TheSurfaceTool::NbSamplesV(surface,v1,v2);
- if(nbsu>40) nbsu=40;
- if(nbsv>40) nbsv=40;
- IntCurveSurface_ThePolyhedron polyhedron(surface,nbsu,nbsv,u1,v1,u2,v2);
- Perform(curve,polygon,surface,polyhedron);
+ Standard_Integer nbsu, nbsv;
+ nbsu = TheSurfaceTool::NbSamplesU(surface, u1, u2);
+ nbsv = TheSurfaceTool::NbSamplesV(surface, v1, v2);
+ if (nbsu > 40)
+ nbsu = 40;
+ if (nbsv > 40)
+ nbsv = 40;
+ IntCurveSurface_ThePolyhedron polyhedron(surface, nbsu, nbsv, u1, v1, u2, v2);
+ Perform(curve, polygon, surface, polyhedron);
}
+
//=================================================================================================
-void IntCurveSurface_Inter::Perform(const TheCurve& curve,
- const TheSurface& surface,
- const IntCurveSurface_ThePolyhedron& polyhedron) {
+void IntCurveSurface_Inter::Perform(const TheCurve& curve,
+ const TheSurface& surface,
+ const IntCurveSurface_ThePolyhedron& polyhedron)
+{
ResetFields();
- done = Standard_True;
- Standard_Real u1 = TheCurveTool::FirstParameter(curve);
- Standard_Real u2 = TheCurveTool::LastParameter(curve);
- IntCurveSurface_ThePolygon polygon(curve,TheCurveTool::NbSamples(curve,u1,u2));
- Perform(curve,polygon,surface,polyhedron);
+ done = Standard_True;
+ Standard_Real u1 = TheCurveTool::FirstParameter(curve);
+ Standard_Real u2 = TheCurveTool::LastParameter(curve);
+ IntCurveSurface_ThePolygon polygon(curve, TheCurveTool::NbSamples(curve, u1, u2));
+ Perform(curve, polygon, surface, polyhedron);
}
+
//=================================================================================================
-void IntCurveSurface_Inter::Perform(const TheCurve& curve,
- const IntCurveSurface_ThePolygon& polygon,
- const TheSurface& surface,
- const IntCurveSurface_ThePolyhedron& polyhedron) {
+void IntCurveSurface_Inter::Perform(const TheCurve& curve,
+ const IntCurveSurface_ThePolygon& polygon,
+ const TheSurface& surface,
+ const IntCurveSurface_ThePolyhedron& polyhedron)
+{
ResetFields();
done = Standard_True;
- Standard_Real u1,v1,u2,v2;
+ Standard_Real u1, v1, u2, v2;
u1 = TheSurfaceTool::FirstUParameter(surface);
v1 = TheSurfaceTool::FirstVParameter(surface);
u2 = TheSurfaceTool::LastUParameter(surface);
v2 = TheSurfaceTool::LastVParameter(surface);
- InternalPerform(curve,polygon,surface,polyhedron,u1,v1,u2,v2);
+ InternalPerform(curve, polygon, surface, polyhedron, u1, v1, u2, v2);
}
//=================================================================================================
-void IntCurveSurface_Inter::Perform(const TheCurve& curve,
- const IntCurveSurface_ThePolygon& polygon,
- const TheSurface& surface,
- const IntCurveSurface_ThePolyhedron& polyhedron,
- Bnd_BoundSortBox& BndBSB) {
+void IntCurveSurface_Inter::Perform(const TheCurve& curve,
+ const IntCurveSurface_ThePolygon& polygon,
+ const TheSurface& surface,
+ const IntCurveSurface_ThePolyhedron& polyhedron,
+ Bnd_BoundSortBox& BndBSB)
+{
ResetFields();
done = Standard_True;
- Standard_Real u1,v1,u2,v2;
+ Standard_Real u1, v1, u2, v2;
u1 = TheSurfaceTool::FirstUParameter(surface);
v1 = TheSurfaceTool::FirstVParameter(surface);
u2 = TheSurfaceTool::LastUParameter(surface);
v2 = TheSurfaceTool::LastVParameter(surface);
- InternalPerform(curve,polygon,surface,polyhedron,u1,v1,u2,v2,BndBSB);
+ InternalPerform(curve, polygon, surface, polyhedron, u1, v1, u2, v2, BndBSB);
}
+
//=======================================================================
-//function : InternalPerform
-//purpose : C a l c u l d u p o i n t a p p r o c h e
-//== p u i s d u p o i n t E x a c t
+// function : InternalPerform
+// purpose : C a l c u l d u p o i n t a p p r o c h e
+//== p u i s d u p o i n t E x a c t
//=======================================================================
-void IntCurveSurface_Inter::InternalPerform(const TheCurve& curve,
- const IntCurveSurface_ThePolygon& polygon,
- const TheSurface& surface,
- const IntCurveSurface_ThePolyhedron& polyhedron,
- const Standard_Real u0,
- const Standard_Real v0,
- const Standard_Real u1,
- const Standard_Real v1,
- Bnd_BoundSortBox& BSB) {
- IntCurveSurface_TheInterference interference(polygon,polyhedron,BSB);
- IntCurveSurface_TheCSFunction theicsfunction(surface,curve);
- IntCurveSurface_TheExactInter intersectionExacte(theicsfunction,TOLTANGENCY);
- math_FunctionSetRoot rsnld(intersectionExacte.Function());
-
-// Standard_Real u,v,w,winit;
- Standard_Real u,v,w;
- gp_Pnt P;
- Standard_Real winf = polygon.InfParameter();
- Standard_Real wsup = polygon.SupParameter();
+void IntCurveSurface_Inter::InternalPerform(const TheCurve& curve,
+ const IntCurveSurface_ThePolygon& polygon,
+ const TheSurface& surface,
+ const IntCurveSurface_ThePolyhedron& polyhedron,
+ const Standard_Real u0,
+ const Standard_Real v0,
+ const Standard_Real u1,
+ const Standard_Real v1,
+ Bnd_BoundSortBox& BSB)
+{
+ IntCurveSurface_TheInterference interference(polygon, polyhedron, BSB);
+ IntCurveSurface_TheCSFunction theicsfunction(surface, curve);
+ IntCurveSurface_TheExactInter intersectionExacte(theicsfunction, TOLTANGENCY);
+ math_FunctionSetRoot rsnld(intersectionExacte.Function());
+
+ // Standard_Real u,v,w,winit;
+ Standard_Real u, v, w;
+ gp_Pnt P;
+ Standard_Real winf = polygon.InfParameter();
+ Standard_Real wsup = polygon.SupParameter();
Standard_Integer NbSectionPoints = interference.NbSectionPoints();
Standard_Integer NbTangentZones = interference.NbTangentZones();
+ //-- Les interferences renvoient parfois de nombreuses fois (>20) les memes points
- //-- Les interferences renvoient parfois de nombreuses fois (>20) les memes points
-
- Standard_Integer i,NbStartPoints=NbSectionPoints;
- for(i=1; i<= NbTangentZones; i++) {
- const Intf_TangentZone& TZ = interference.ZoneValue(i);
- Standard_Integer nbpnts = TZ.NumberOfPoints();
- NbStartPoints+=nbpnts;
+ Standard_Integer i, NbStartPoints = NbSectionPoints;
+ for (i = 1; i <= NbTangentZones; i++)
+ {
+ const Intf_TangentZone& TZ = interference.ZoneValue(i);
+ Standard_Integer nbpnts = TZ.NumberOfPoints();
+ NbStartPoints += nbpnts;
}
-
- if(NbStartPoints) {
- Standard_Real *TabU = new Standard_Real [NbStartPoints+1];
- Standard_Real *TabV = new Standard_Real [NbStartPoints+1];
- Standard_Real *TabW = new Standard_Real [NbStartPoints+1];
- Standard_Integer IndexPoint=0;
-
- for(i=1; i<= NbSectionPoints; i++) {
+
+ if (NbStartPoints)
+ {
+ Standard_Real* TabU = new Standard_Real[NbStartPoints + 1];
+ Standard_Real* TabV = new Standard_Real[NbStartPoints + 1];
+ Standard_Real* TabW = new Standard_Real[NbStartPoints + 1];
+ Standard_Integer IndexPoint = 0;
+
+ for (i = 1; i <= NbSectionPoints; i++)
+ {
const Intf_SectionPoint& SP = interference.PntValue(i);
- SectionPointToParameters(SP,polyhedron,polygon,u,v,w);
- TabU[IndexPoint]=u;
- TabV[IndexPoint]=v;
- TabW[IndexPoint]=w;
+ SectionPointToParameters(SP, polyhedron, polygon, u, v, w);
+ TabU[IndexPoint] = u;
+ TabV[IndexPoint] = v;
+ TabW[IndexPoint] = w;
IndexPoint++;
}
- for(i=1; i<= NbTangentZones; i++) {
- const Intf_TangentZone& TZ = interference.ZoneValue(i);
- Standard_Integer nbpnts = TZ.NumberOfPoints();
- for(Standard_Integer j=1; j<=nbpnts; j++) {
- const Intf_SectionPoint& SP = TZ.GetPoint(j);
- SectionPointToParameters(SP,polyhedron,polygon,u,v,w);
- TabU[IndexPoint]=u;
- TabV[IndexPoint]=v;
- TabW[IndexPoint]=w;
- IndexPoint++;
+ for (i = 1; i <= NbTangentZones; i++)
+ {
+ const Intf_TangentZone& TZ = interference.ZoneValue(i);
+ Standard_Integer nbpnts = TZ.NumberOfPoints();
+ for (Standard_Integer j = 1; j <= nbpnts; j++)
+ {
+ const Intf_SectionPoint& SP = TZ.GetPoint(j);
+ SectionPointToParameters(SP, polyhedron, polygon, u, v, w);
+ TabU[IndexPoint] = u;
+ TabV[IndexPoint] = v;
+ TabW[IndexPoint] = w;
+ IndexPoint++;
}
}
-
+
//-- Tri
- Standard_Real su=0,sv=0,sw=0,ptol;
- ptol = 10*Precision::PConfusion();
-
- //-- Tri suivant la variable W
+ Standard_Real su = 0, sv = 0, sw = 0, ptol;
+ ptol = 10 * Precision::PConfusion();
+
+ //-- Tri suivant la variable W
Standard_Boolean Triok;
- do {
- Triok=Standard_True;
+ do
+ {
+ Triok = Standard_True;
Standard_Integer im1;
- for(i=1,im1=0;i<NbStartPoints;im1++,i++) {
- if(TabW[i] < TabW[im1]) {
- Standard_Real t=TabW[i]; TabW[i]=TabW[im1]; TabW[im1]=t;
- t=TabU[i]; TabU[i]=TabU[im1]; TabU[im1]=t;
- t=TabV[i]; TabV[i]=TabV[im1]; TabV[im1]=t;
- Triok=Standard_False;
- }
+ for (i = 1, im1 = 0; i < NbStartPoints; im1++, i++)
+ {
+ if (TabW[i] < TabW[im1])
+ {
+ Standard_Real t = TabW[i];
+ TabW[i] = TabW[im1];
+ TabW[im1] = t;
+ t = TabU[i];
+ TabU[i] = TabU[im1];
+ TabU[im1] = t;
+ t = TabV[i];
+ TabV[i] = TabV[im1];
+ TabV[im1] = t;
+ Triok = Standard_False;
+ }
}
- }
- while(Triok==Standard_False);
-
+ } while (Triok == Standard_False);
+
//-- On trie pour des meme W suivant U
- do {
- Triok=Standard_True;
+ do
+ {
+ Triok = Standard_True;
Standard_Integer im1;
- for(i=1,im1=0;i<NbStartPoints;im1++,i++) {
-// modified by NIZHNY-MKK Mon Oct 3 17:38:49 2005
-// if(Abs(TabW[i]-TabW[im1])<ptol) {
- if((TabW[i]-TabW[im1])<ptol) {
- TabW[i]=TabW[im1];
- if(TabU[i] < TabU[im1]) {
- Standard_Real t=TabU[i]; TabU[i]=TabU[im1]; TabU[im1]=t;
- t=TabV[i]; TabV[i]=TabV[im1]; TabV[im1]=t;
- Triok=Standard_False;
- }
- }
+ for (i = 1, im1 = 0; i < NbStartPoints; im1++, i++)
+ {
+ // modified by NIZHNY-MKK Mon Oct 3 17:38:49 2005
+ // if(Abs(TabW[i]-TabW[im1])<ptol) {
+ if ((TabW[i] - TabW[im1]) < ptol)
+ {
+ TabW[i] = TabW[im1];
+ if (TabU[i] < TabU[im1])
+ {
+ Standard_Real t = TabU[i];
+ TabU[i] = TabU[im1];
+ TabU[im1] = t;
+ t = TabV[i];
+ TabV[i] = TabV[im1];
+ TabV[im1] = t;
+ Triok = Standard_False;
+ }
+ }
}
- }
- while(Triok==Standard_False);
-
+ } while (Triok == Standard_False);
+
//-- On trie pour des meme U et W suivant V
- do {
- Triok=Standard_True;
+ do
+ {
+ Triok = Standard_True;
Standard_Integer im1;
- for(i=1,im1=0;i<NbStartPoints;im1++,i++) {
-// modified by NIZHNY-MKK Mon Oct 3 17:38:52 2005
-// if((Abs(TabW[i]-TabW[im1])<ptol) && (Abs(TabU[i]-TabU[im1])<ptol)) {
- if(((TabW[i]-TabW[im1])<ptol) && ((TabU[i]-TabU[im1])<ptol)) {
- TabU[i]=TabU[im1];
- if(TabV[i] < TabV[im1]) {
- Standard_Real t=TabV[i]; TabV[i]=TabV[im1]; TabV[im1]=t;
- Triok=Standard_False;
- }
- }
+ for (i = 1, im1 = 0; i < NbStartPoints; im1++, i++)
+ {
+ // modified by NIZHNY-MKK Mon Oct 3 17:38:52 2005
+ // if((Abs(TabW[i]-TabW[im1])<ptol) && (Abs(TabU[i]-TabU[im1])<ptol)) {
+ if (((TabW[i] - TabW[im1]) < ptol) && ((TabU[i] - TabU[im1]) < ptol))
+ {
+ TabU[i] = TabU[im1];
+ if (TabV[i] < TabV[im1])
+ {
+ Standard_Real t = TabV[i];
+ TabV[i] = TabV[im1];
+ TabV[im1] = t;
+ Triok = Standard_False;
+ }
+ }
}
- }
- while(Triok==Standard_False);
-
-
- for(i=0;i<NbStartPoints; i++) {
- u=TabU[i]; v=TabV[i]; w=TabW[i];
- if(i==0) {
- su=u-1;
+ } while (Triok == Standard_False);
+
+ for (i = 0; i < NbStartPoints; i++)
+ {
+ u = TabU[i];
+ v = TabV[i];
+ w = TabW[i];
+ if (i == 0)
+ {
+ su = u - 1;
}
- if(Abs(u-su)>ptol || Abs(v-sv)>ptol || Abs(w-sw)>ptol) {
- intersectionExacte.Perform(u,v,w,rsnld,u0,u1,v0,v1,winf,wsup);
- if(intersectionExacte.IsDone()) {
- if(!intersectionExacte.IsEmpty()) {
- P=intersectionExacte.Point();
- w=intersectionExacte.ParameterOnCurve();
- intersectionExacte.ParameterOnSurface(u,v);
- AppendPoint(curve,w,surface,u,v);
- }
- }
+ if (Abs(u - su) > ptol || Abs(v - sv) > ptol || Abs(w - sw) > ptol)
+ {
+ intersectionExacte.Perform(u, v, w, rsnld, u0, u1, v0, v1, winf, wsup);
+ if (intersectionExacte.IsDone())
+ {
+ if (!intersectionExacte.IsEmpty())
+ {
+ P = intersectionExacte.Point();
+ w = intersectionExacte.ParameterOnCurve();
+ intersectionExacte.ParameterOnSurface(u, v);
+ AppendPoint(curve, w, surface, u, v);
+ }
+ }
}
- su=TabU[i]; sv=TabV[i]; sw=TabW[i];
+ su = TabU[i];
+ sv = TabV[i];
+ sw = TabW[i];
}
- delete [] TabW;
- delete [] TabV;
- delete [] TabU;
+ delete[] TabW;
+ delete[] TabV;
+ delete[] TabU;
}
}
//=================================================================================================
-void IntCurveSurface_Inter::InternalPerform(const TheCurve& curve,
- const IntCurveSurface_ThePolygon& polygon,
- const TheSurface& surface,
- const IntCurveSurface_ThePolyhedron& polyhedron,
- const Standard_Real u0,
- const Standard_Real v0,
- const Standard_Real u1,
- const Standard_Real v1) {
- IntCurveSurface_TheInterference interference(polygon,polyhedron);
- IntCurveSurface_TheCSFunction theicsfunction(surface,curve);
- IntCurveSurface_TheExactInter intersectionExacte(theicsfunction,TOLTANGENCY);
- math_FunctionSetRoot rsnld(intersectionExacte.Function());
-
-// Standard_Real u,v,w,winit;
- Standard_Real u,v,w;
- gp_Pnt P;
- Standard_Real winf = polygon.InfParameter();
- Standard_Real wsup = polygon.SupParameter();
+void IntCurveSurface_Inter::InternalPerform(const TheCurve& curve,
+ const IntCurveSurface_ThePolygon& polygon,
+ const TheSurface& surface,
+ const IntCurveSurface_ThePolyhedron& polyhedron,
+ const Standard_Real u0,
+ const Standard_Real v0,
+ const Standard_Real u1,
+ const Standard_Real v1)
+{
+ IntCurveSurface_TheInterference interference(polygon, polyhedron);
+ IntCurveSurface_TheCSFunction theicsfunction(surface, curve);
+ IntCurveSurface_TheExactInter intersectionExacte(theicsfunction, TOLTANGENCY);
+ math_FunctionSetRoot rsnld(intersectionExacte.Function());
+
+ // Standard_Real u,v,w,winit;
+ Standard_Real u, v, w;
+ gp_Pnt P;
+ Standard_Real winf = polygon.InfParameter();
+ Standard_Real wsup = polygon.SupParameter();
Standard_Integer NbSectionPoints = interference.NbSectionPoints();
Standard_Integer NbTangentZones = interference.NbTangentZones();
+ //-- Les interferences renvoient parfois de nombreuses fois (>20) les memes points
- //-- Les interferences renvoient parfois de nombreuses fois (>20) les memes points
-
- Standard_Integer i,NbStartPoints=NbSectionPoints;
- for(i=1; i<= NbTangentZones; i++) {
- const Intf_TangentZone& TZ = interference.ZoneValue(i);
- Standard_Integer nbpnts = TZ.NumberOfPoints();
- NbStartPoints+=nbpnts;
+ Standard_Integer i, NbStartPoints = NbSectionPoints;
+ for (i = 1; i <= NbTangentZones; i++)
+ {
+ const Intf_TangentZone& TZ = interference.ZoneValue(i);
+ Standard_Integer nbpnts = TZ.NumberOfPoints();
+ NbStartPoints += nbpnts;
}
-
- if(NbStartPoints) {
- Standard_Real *TabU = new Standard_Real [NbStartPoints+1];
- Standard_Real *TabV = new Standard_Real [NbStartPoints+1];
- Standard_Real *TabW = new Standard_Real [NbStartPoints+1];
- Standard_Integer IndexPoint=0;
-
- for(i=1; i<= NbSectionPoints; i++) {
+
+ if (NbStartPoints)
+ {
+ Standard_Real* TabU = new Standard_Real[NbStartPoints + 1];
+ Standard_Real* TabV = new Standard_Real[NbStartPoints + 1];
+ Standard_Real* TabW = new Standard_Real[NbStartPoints + 1];
+ Standard_Integer IndexPoint = 0;
+
+ for (i = 1; i <= NbSectionPoints; i++)
+ {
const Intf_SectionPoint& SP = interference.PntValue(i);
- SectionPointToParameters(SP,polyhedron,polygon,u,v,w);
- TabU[IndexPoint]=u;
- TabV[IndexPoint]=v;
- TabW[IndexPoint]=w;
+ SectionPointToParameters(SP, polyhedron, polygon, u, v, w);
+ TabU[IndexPoint] = u;
+ TabV[IndexPoint] = v;
+ TabW[IndexPoint] = w;
IndexPoint++;
}
- for(i=1; i<= NbTangentZones; i++) {
- const Intf_TangentZone& TZ = interference.ZoneValue(i);
- Standard_Integer nbpnts = TZ.NumberOfPoints();
- for(Standard_Integer j=1; j<=nbpnts; j++) {
- const Intf_SectionPoint& SP = TZ.GetPoint(j);
- SectionPointToParameters(SP,polyhedron,polygon,u,v,w);
- TabU[IndexPoint]=u;
- TabV[IndexPoint]=v;
- TabW[IndexPoint]=w;
- IndexPoint++;
+ for (i = 1; i <= NbTangentZones; i++)
+ {
+ const Intf_TangentZone& TZ = interference.ZoneValue(i);
+ Standard_Integer nbpnts = TZ.NumberOfPoints();
+ for (Standard_Integer j = 1; j <= nbpnts; j++)
+ {
+ const Intf_SectionPoint& SP = TZ.GetPoint(j);
+ SectionPointToParameters(SP, polyhedron, polygon, u, v, w);
+ TabU[IndexPoint] = u;
+ TabV[IndexPoint] = v;
+ TabW[IndexPoint] = w;
+ IndexPoint++;
}
}
-
+
//-- Tri
- Standard_Real su=0,sv=0,sw=0,ptol;
- ptol = 10*Precision::PConfusion();
-
- //-- Tri suivant la variable W
+ Standard_Real su = 0, sv = 0, sw = 0, ptol;
+ ptol = 10 * Precision::PConfusion();
+
+ //-- Tri suivant la variable W
Standard_Boolean Triok;
- do {
- Triok=Standard_True;
+ do
+ {
+ Triok = Standard_True;
Standard_Integer im1;
- for(i=1,im1=0;i<NbStartPoints;im1++,i++) {
- if(TabW[i] < TabW[im1]) {
- Standard_Real t=TabW[i]; TabW[i]=TabW[im1]; TabW[im1]=t;
- t=TabU[i]; TabU[i]=TabU[im1]; TabU[im1]=t;
- t=TabV[i]; TabV[i]=TabV[im1]; TabV[im1]=t;
- Triok=Standard_False;
- }
+ for (i = 1, im1 = 0; i < NbStartPoints; im1++, i++)
+ {
+ if (TabW[i] < TabW[im1])
+ {
+ Standard_Real t = TabW[i];
+ TabW[i] = TabW[im1];
+ TabW[im1] = t;
+ t = TabU[i];
+ TabU[i] = TabU[im1];
+ TabU[im1] = t;
+ t = TabV[i];
+ TabV[i] = TabV[im1];
+ TabV[im1] = t;
+ Triok = Standard_False;
+ }
}
- }
- while(Triok==Standard_False);
-
+ } while (Triok == Standard_False);
+
//-- On trie pour des meme W suivant U
- do {
- Triok=Standard_True;
+ do
+ {
+ Triok = Standard_True;
Standard_Integer im1;
- for(i=1,im1=0;i<NbStartPoints;im1++,i++) {
-// modified by NIZHNY-MKK Mon Oct 3 17:38:56 2005
-// if(Abs(TabW[i]-TabW[im1])<ptol) {
- if((TabW[i]-TabW[im1])<ptol) {
- TabW[i]=TabW[im1];
- if(TabU[i] < TabU[im1]) {
- Standard_Real t=TabU[i]; TabU[i]=TabU[im1]; TabU[im1]=t;
- t=TabV[i]; TabV[i]=TabV[im1]; TabV[im1]=t;
- Triok=Standard_False;
- }
- }
+ for (i = 1, im1 = 0; i < NbStartPoints; im1++, i++)
+ {
+ // modified by NIZHNY-MKK Mon Oct 3 17:38:56 2005
+ // if(Abs(TabW[i]-TabW[im1])<ptol) {
+ if ((TabW[i] - TabW[im1]) < ptol)
+ {
+ TabW[i] = TabW[im1];
+ if (TabU[i] < TabU[im1])
+ {
+ Standard_Real t = TabU[i];
+ TabU[i] = TabU[im1];
+ TabU[im1] = t;
+ t = TabV[i];
+ TabV[i] = TabV[im1];
+ TabV[im1] = t;
+ Triok = Standard_False;
+ }
+ }
}
- }
- while(Triok==Standard_False);
-
+ } while (Triok == Standard_False);
+
//-- On trie pour des meme U et W suivant V
- do {
- Triok=Standard_True;
+ do
+ {
+ Triok = Standard_True;
Standard_Integer im1;
- for(i=1,im1=0;i<NbStartPoints;im1++,i++) {
-// modified by NIZHNY-MKK Mon Oct 3 17:38:58 2005
-// if((Abs(TabW[i]-TabW[im1])<ptol) && (Abs(TabU[i]-TabU[im1])<ptol)) {
- if(((TabW[i]-TabW[im1])<ptol) && ((TabU[i]-TabU[im1])<ptol)) {
- TabU[i]=TabU[im1];
- if(TabV[i] < TabV[im1]) {
- Standard_Real t=TabV[i]; TabV[i]=TabV[im1]; TabV[im1]=t;
- Triok=Standard_False;
- }
- }
+ for (i = 1, im1 = 0; i < NbStartPoints; im1++, i++)
+ {
+ // modified by NIZHNY-MKK Mon Oct 3 17:38:58 2005
+ // if((Abs(TabW[i]-TabW[im1])<ptol) && (Abs(TabU[i]-TabU[im1])<ptol)) {
+ if (((TabW[i] - TabW[im1]) < ptol) && ((TabU[i] - TabU[im1]) < ptol))
+ {
+ TabU[i] = TabU[im1];
+ if (TabV[i] < TabV[im1])
+ {
+ Standard_Real t = TabV[i];
+ TabV[i] = TabV[im1];
+ TabV[im1] = t;
+ Triok = Standard_False;
+ }
+ }
}
- }
- while(Triok==Standard_False);
-
-
- for(i=0;i<NbStartPoints; i++) {
- u=TabU[i]; v=TabV[i]; w=TabW[i];
- if(i==0) {
- su=u-1;
+ } while (Triok == Standard_False);
+
+ for (i = 0; i < NbStartPoints; i++)
+ {
+ u = TabU[i];
+ v = TabV[i];
+ w = TabW[i];
+ if (i == 0)
+ {
+ su = u - 1;
}
- if(Abs(u-su)>ptol || Abs(v-sv)>ptol || Abs(w-sw)>ptol) {
- intersectionExacte.Perform(u,v,w,rsnld,u0,u1,v0,v1,winf,wsup);
- if(intersectionExacte.IsDone()) {
- if(!intersectionExacte.IsEmpty()) {
- P=intersectionExacte.Point();
- w=intersectionExacte.ParameterOnCurve();
- intersectionExacte.ParameterOnSurface(u,v);
- AppendPoint(curve,w,surface,u,v);
- }
- }
+ if (Abs(u - su) > ptol || Abs(v - sv) > ptol || Abs(w - sw) > ptol)
+ {
+ intersectionExacte.Perform(u, v, w, rsnld, u0, u1, v0, v1, winf, wsup);
+ if (intersectionExacte.IsDone())
+ {
+ if (!intersectionExacte.IsEmpty())
+ {
+ P = intersectionExacte.Point();
+ w = intersectionExacte.ParameterOnCurve();
+ intersectionExacte.ParameterOnSurface(u, v);
+ AppendPoint(curve, w, surface, u, v);
+ }
+ }
}
- su=TabU[i]; sv=TabV[i]; sw=TabW[i];
+ su = TabU[i];
+ sv = TabV[i];
+ sw = TabW[i];
}
- delete [] TabW;
- delete [] TabV;
- delete [] TabU;
+ delete[] TabW;
+ delete[] TabV;
+ delete[] TabU;
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::InternalPerformCurveQuadric(const TheCurve& curve,
- const TheSurface& surface) {
- IntCurveSurface_TheQuadCurvExactInter QuadCurv(surface,curve);
- if(QuadCurv.IsDone()) {
+void IntCurveSurface_Inter::InternalPerformCurveQuadric(const TheCurve& curve,
+ const TheSurface& surface)
+{
+ IntCurveSurface_TheQuadCurvExactInter QuadCurv(surface, curve);
+ if (QuadCurv.IsDone())
+ {
Standard_Integer NbRoots = QuadCurv.NbRoots();
- Standard_Real u,v,w;
- for(Standard_Integer i = 1; i<= NbRoots; i++) {
- w = QuadCurv.Root(i);
- IntCurveSurface_ComputeParamsOnQuadric(surface,TheCurveTool::Value(curve,w),u,v);
- AppendPoint(curve,w,surface,u,v);
+ Standard_Real u, v, w;
+ for (Standard_Integer i = 1; i <= NbRoots; i++)
+ {
+ w = QuadCurv.Root(i);
+ IntCurveSurface_ComputeParamsOnQuadric(surface, TheCurveTool::Value(curve, w), u, v);
+ AppendPoint(curve, w, surface, u, v);
}
//-- Intervals non traites .............................................
}
//=================================================================================================
-void IntCurveSurface_Inter::InternalPerform(const TheCurve& curve,
- const IntCurveSurface_ThePolygon& polygon,
- const TheSurface& surface,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2) {
+void IntCurveSurface_Inter::InternalPerform(const TheCurve& curve,
+ const IntCurveSurface_ThePolygon& polygon,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+{
GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- if( (SurfaceType != GeomAbs_Plane)
- && (SurfaceType != GeomAbs_Cylinder)
- && (SurfaceType != GeomAbs_Cone)
- && (SurfaceType != GeomAbs_Sphere) ) {
- if(SurfaceType != GeomAbs_BSplineSurface) {
- Standard_Integer nbsu,nbsv;
- nbsu = TheSurfaceTool::NbSamplesU(surface,U1,U2);
- nbsv = TheSurfaceTool::NbSamplesV(surface,V1,V2);
- if(nbsu>40) nbsu=40;
- if(nbsv>40) nbsv=40;
- IntCurveSurface_ThePolyhedron polyhedron(surface,nbsu,nbsv,U1,V1,U2,V2);
- InternalPerform(curve,polygon,surface,polyhedron,U1,V1,U2,V2);
- }
- else {
- Handle(Adaptor3d_Surface) aS = TheSurfaceTool::UTrim(surface, U1, U2, 1.e-9);
- aS = aS->VTrim(V1, V2, 1.e-9);
+ if ((SurfaceType != GeomAbs_Plane) && (SurfaceType != GeomAbs_Cylinder)
+ && (SurfaceType != GeomAbs_Cone) && (SurfaceType != GeomAbs_Sphere))
+ {
+ if (SurfaceType != GeomAbs_BSplineSurface)
+ {
+ Standard_Integer nbsu, nbsv;
+ nbsu = TheSurfaceTool::NbSamplesU(surface, U1, U2);
+ nbsv = TheSurfaceTool::NbSamplesV(surface, V1, V2);
+ if (nbsu > 40)
+ nbsu = 40;
+ if (nbsv > 40)
+ nbsv = 40;
+ IntCurveSurface_ThePolyhedron polyhedron(surface, nbsu, nbsv, U1, V1, U2, V2);
+ InternalPerform(curve, polygon, surface, polyhedron, U1, V1, U2, V2);
+ }
+ else
+ {
+ Handle(Adaptor3d_Surface) aS = TheSurfaceTool::UTrim(surface, U1, U2, 1.e-9);
+ aS = aS->VTrim(V1, V2, 1.e-9);
Handle(Adaptor3d_TopolTool) aTopTool = new Adaptor3d_TopolTool(aS);
- Standard_Real defl = 0.1;
+ Standard_Real defl = 0.1;
aTopTool->SamplePnts(defl, 10, 10);
- Standard_Integer nbpu = aTopTool->NbSamplesU();
- Standard_Integer nbpv = aTopTool->NbSamplesV();
+ Standard_Integer nbpu = aTopTool->NbSamplesU();
+ Standard_Integer nbpv = aTopTool->NbSamplesV();
TColStd_Array1OfReal Upars(1, nbpu), Vpars(1, nbpv);
aTopTool->UParameters(Upars);
aTopTool->VParameters(Vpars);
- IntCurveSurface_ThePolyhedron polyhedron(surface,Upars, Vpars);
- InternalPerform(curve,polygon,surface,polyhedron,U1,V1,U2,V2);
+ IntCurveSurface_ThePolyhedron polyhedron(surface, Upars, Vpars);
+ InternalPerform(curve, polygon, surface, polyhedron, U1, V1, U2, V2);
}
}
- else {
- IntCurveSurface_TheQuadCurvExactInter QuadCurv(surface,curve);
- if(QuadCurv.IsDone()) {
+ else
+ {
+ IntCurveSurface_TheQuadCurvExactInter QuadCurv(surface, curve);
+ if (QuadCurv.IsDone())
+ {
Standard_Integer NbRoots = QuadCurv.NbRoots();
- Standard_Real u,v,w;
- for(Standard_Integer i = 1; i<= NbRoots; i++) {
- w = QuadCurv.Root(i);
- IntCurveSurface_ComputeParamsOnQuadric(surface,TheCurveTool::Value(curve,w),u,v);
- AppendPoint(curve,w,surface,u,v);
+ Standard_Real u, v, w;
+ for (Standard_Integer i = 1; i <= NbRoots; i++)
+ {
+ w = QuadCurv.Root(i);
+ IntCurveSurface_ComputeParamsOnQuadric(surface, TheCurveTool::Value(curve, w), u, v);
+ AppendPoint(curve, w, surface, u, v);
}
//-- Intervalles non traites .............................................
}
} //-- Fin : la Surface est une quadrique
}
+
//=================================================================================================
-void IntCurveSurface_Inter::PerformConicSurf(const gp_Lin& Line,
- const TheCurve& curve,
- const TheSurface& surface,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2) {
-
+void IntCurveSurface_Inter::PerformConicSurf(const gp_Lin& Line,
+ const TheCurve& curve,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+{
- GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- Standard_Boolean isAnaProcessed = Standard_True;
- switch(SurfaceType) {
- case GeomAbs_Plane:
- {
- IntAna_IntConicQuad LinPlane(Line,TheSurfaceTool::Plane(surface),TOLERANCE_ANGULAIRE);
- AppendIntAna(curve,surface,LinPlane);
+ GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
+ Standard_Boolean isAnaProcessed = Standard_True;
+ switch (SurfaceType)
+ {
+ case GeomAbs_Plane: {
+ IntAna_IntConicQuad LinPlane(Line, TheSurfaceTool::Plane(surface), TOLERANCE_ANGULAIRE);
+ AppendIntAna(curve, surface, LinPlane);
break;
}
- case GeomAbs_Cylinder:
- {
- IntAna_IntConicQuad LinCylinder(Line,TheSurfaceTool::Cylinder(surface));
- AppendIntAna(curve,surface,LinCylinder);
+ case GeomAbs_Cylinder: {
+ IntAna_IntConicQuad LinCylinder(Line, TheSurfaceTool::Cylinder(surface));
+ AppendIntAna(curve, surface, LinCylinder);
break;
}
- case GeomAbs_Sphere:
- {
- IntAna_IntConicQuad LinSphere(Line,TheSurfaceTool::Sphere(surface));
- AppendIntAna(curve,surface,LinSphere);
+ case GeomAbs_Sphere: {
+ IntAna_IntConicQuad LinSphere(Line, TheSurfaceTool::Sphere(surface));
+ AppendIntAna(curve, surface, LinSphere);
break;
}
- case GeomAbs_Torus:
- {
+ case GeomAbs_Torus: {
IntAna_IntLinTorus intlintorus(Line, TheSurfaceTool::Torus(surface));
- if (intlintorus.IsDone()) {
+ if (intlintorus.IsDone())
+ {
Standard_Integer nbp = intlintorus.NbPoints();
- Standard_Real fi, theta, w;
- for (Standard_Integer i = 1; i <= nbp; i++) {
+ Standard_Real fi, theta, w;
+ for (Standard_Integer i = 1; i <= nbp; i++)
+ {
const gp_Pnt aDebPnt(intlintorus.Value(i));
(void)aDebPnt;
w = intlintorus.ParamOnLine(i);
isAnaProcessed = Standard_False;
break;
}
- case GeomAbs_Cone:
- {
- constexpr Standard_Real correction = 1.E+5*Precision::Angular();
- gp_Cone cn = TheSurfaceTool::Cone(surface);
- if(Abs(cn.SemiAngle()) < M_PI/2.0 - correction) {
+ case GeomAbs_Cone: {
+ constexpr Standard_Real correction = 1.E+5 * Precision::Angular();
+ gp_Cone cn = TheSurfaceTool::Cone(surface);
+ if (Abs(cn.SemiAngle()) < M_PI / 2.0 - correction)
+ {
IntAna_IntConicQuad LinCone(Line, cn);
AppendIntAna(curve, surface, LinCone);
}
isAnaProcessed = Standard_False;
break;
}
- default:
- isAnaProcessed = Standard_False;
+ default:
+ isAnaProcessed = Standard_False;
}
if (!isAnaProcessed)
{
- Standard_Integer nbsu,nbsv;
- nbsu = TheSurfaceTool::NbSamplesU(surface,U1,U2);
- nbsv = TheSurfaceTool::NbSamplesV(surface,V1,V2);
+ Standard_Integer nbsu, nbsv;
+ nbsu = TheSurfaceTool::NbSamplesU(surface, U1, U2);
+ nbsv = TheSurfaceTool::NbSamplesV(surface, V1, V2);
Standard_Boolean U1inf = Precision::IsInfinite(U1);
Standard_Boolean U2inf = Precision::IsInfinite(U2);
Standard_Boolean V1inf = Precision::IsInfinite(V1);
Standard_Boolean V2inf = Precision::IsInfinite(V2);
- Standard_Real U1new=U1, U2new=U2, V1new=V1, V2new=V2;
+ Standard_Real U1new = U1, U2new = U2, V1new = V1, V2new = V2;
Standard_Boolean NoIntersection = Standard_False;
- if(U1inf || U2inf || V1inf || V2inf ) {
-
- if(SurfaceType == GeomAbs_SurfaceOfExtrusion) {
+ if (U1inf || U2inf || V1inf || V2inf)
+ {
- EstLimForInfExtr(Line, surface, Standard_False, nbsu,
- U1inf, U2inf, V1inf, V2inf,
- U1new, U2new, V1new, V2new, NoIntersection);
+ if (SurfaceType == GeomAbs_SurfaceOfExtrusion)
+ {
+ EstLimForInfExtr(Line,
+ surface,
+ Standard_False,
+ nbsu,
+ U1inf,
+ U2inf,
+ V1inf,
+ V2inf,
+ U1new,
+ U2new,
+ V1new,
+ V2new,
+ NoIntersection);
}
- else if (SurfaceType == GeomAbs_SurfaceOfRevolution) {
-
- EstLimForInfRevl(Line, surface,
- U1inf, U2inf, V1inf, V2inf,
- U1new, U2new, V1new, V2new, NoIntersection);
+ else if (SurfaceType == GeomAbs_SurfaceOfRevolution)
+ {
+ EstLimForInfRevl(Line,
+ surface,
+ U1inf,
+ U2inf,
+ V1inf,
+ V2inf,
+ U1new,
+ U2new,
+ V1new,
+ V2new,
+ NoIntersection);
}
- else if (SurfaceType == GeomAbs_OffsetSurface) {
+ else if (SurfaceType == GeomAbs_OffsetSurface)
+ {
- EstLimForInfOffs(Line, surface, nbsu,
- U1inf, U2inf, V1inf, V2inf,
- U1new, U2new, V1new, V2new, NoIntersection);
+ EstLimForInfOffs(Line,
+ surface,
+ nbsu,
+ U1inf,
+ U2inf,
+ V1inf,
+ V2inf,
+ U1new,
+ U2new,
+ V1new,
+ V2new,
+ NoIntersection);
}
- else {
+ else
+ {
EstLimForInfSurf(U1new, U2new, V1new, V2new);
}
-
}
-
- if(NoIntersection) return;
-
+ if (NoIntersection)
+ return;
// modified by NIZHNY-OFV Mon Aug 20 14:56:47 2001 (60963 begin)
- if(nbsu<20) nbsu=20;
- if(nbsv<20) nbsv=20;
+ if (nbsu < 20)
+ nbsu = 20;
+ if (nbsv < 20)
+ nbsv = 20;
// modified by NIZHNY-OFV Mon Aug 20 14:57:06 2001 (60963 end)
- IntCurveSurface_ThePolyhedron polyhedron(surface,nbsu,nbsv,U1new,V1new,U2new,V2new);
+ IntCurveSurface_ThePolyhedron polyhedron(surface, nbsu, nbsv, U1new, V1new, U2new, V2new);
Intf_Tool bndTool;
Bnd_Box boxLine;
- bndTool.LinBox(Line,polyhedron.Bounding(),boxLine);
- for(Standard_Integer nbseg=1; nbseg<= bndTool.NbSegments(); nbseg++) {
+ bndTool.LinBox(Line, polyhedron.Bounding(), boxLine);
+ for (Standard_Integer nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++)
+ {
Standard_Real pinf = bndTool.BeginParam(nbseg);
Standard_Real psup = bndTool.EndParam(nbseg);
- if((psup - pinf)<1e-10) { pinf-=1e-10; psup+=1e-10; }
- IntCurveSurface_ThePolygon polygon(curve, pinf,psup,2);
- InternalPerform(curve,polygon,surface,polyhedron,U1new,V1new,U2new,V2new);
+ if ((psup - pinf) < 1e-10)
+ {
+ pinf -= 1e-10;
+ psup += 1e-10;
+ }
+ IntCurveSurface_ThePolygon polygon(curve, pinf, psup, 2);
+ InternalPerform(curve, polygon, surface, polyhedron, U1new, V1new, U2new, V2new);
}
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::PerformConicSurf(const gp_Circ& Circle,
- const TheCurve& curve,
- const TheSurface& surface,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2) {
-
+void IntCurveSurface_Inter::PerformConicSurf(const gp_Circ& Circle,
+ const TheCurve& curve,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+{
+
GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- switch(SurfaceType) {
- case GeomAbs_Plane:
- {
- IntAna_IntConicQuad CircPlane(Circle,TheSurfaceTool::Plane(surface),TOLERANCE_ANGULAIRE,TOLERANCE);
- AppendIntAna(curve,surface,CircPlane);
+ switch (SurfaceType)
+ {
+ case GeomAbs_Plane: {
+ IntAna_IntConicQuad CircPlane(Circle,
+ TheSurfaceTool::Plane(surface),
+ TOLERANCE_ANGULAIRE,
+ TOLERANCE);
+ AppendIntAna(curve, surface, CircPlane);
break;
}
- case GeomAbs_Cylinder:
- {
- IntAna_IntConicQuad CircCylinder(Circle,TheSurfaceTool::Cylinder(surface));
- AppendIntAna(curve,surface,CircCylinder);
+ case GeomAbs_Cylinder: {
+ IntAna_IntConicQuad CircCylinder(Circle, TheSurfaceTool::Cylinder(surface));
+ AppendIntAna(curve, surface, CircCylinder);
break;
}
- case GeomAbs_Cone:
- {
- IntAna_IntConicQuad CircCone(Circle,TheSurfaceTool::Cone(surface));
- AppendIntAna(curve,surface,CircCone);
+ case GeomAbs_Cone: {
+ IntAna_IntConicQuad CircCone(Circle, TheSurfaceTool::Cone(surface));
+ AppendIntAna(curve, surface, CircCone);
break;
- }
- case GeomAbs_Sphere:
- {
- IntAna_IntConicQuad CircSphere(Circle,TheSurfaceTool::Sphere(surface));
- AppendIntAna(curve,surface,CircSphere);
+ }
+ case GeomAbs_Sphere: {
+ IntAna_IntConicQuad CircSphere(Circle, TheSurfaceTool::Sphere(surface));
+ AppendIntAna(curve, surface, CircSphere);
break;
}
- default:
- {
- IntCurveSurface_ThePolygon polygon(curve,NBSAMPLESONCIRCLE);
- InternalPerform(curve,polygon,surface,U1,V1,U2,V2);
+ default: {
+ IntCurveSurface_ThePolygon polygon(curve, NBSAMPLESONCIRCLE);
+ InternalPerform(curve, polygon, surface, U1, V1, U2, V2);
}
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::PerformConicSurf(const gp_Elips& Ellipse,
- const TheCurve& curve,
- const TheSurface& surface,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2) {
+void IntCurveSurface_Inter::PerformConicSurf(const gp_Elips& Ellipse,
+ const TheCurve& curve,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+{
GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- switch(SurfaceType) {
- case GeomAbs_Plane:
- {
- IntAna_IntConicQuad EllipsePlane(Ellipse,TheSurfaceTool::Plane(surface),TOLERANCE_ANGULAIRE,TOLERANCE);
- AppendIntAna(curve,surface,EllipsePlane);
+ switch (SurfaceType)
+ {
+ case GeomAbs_Plane: {
+ IntAna_IntConicQuad EllipsePlane(Ellipse,
+ TheSurfaceTool::Plane(surface),
+ TOLERANCE_ANGULAIRE,
+ TOLERANCE);
+ AppendIntAna(curve, surface, EllipsePlane);
break;
}
- case GeomAbs_Cylinder:
- {
- IntAna_IntConicQuad EllipseCylinder(Ellipse,TheSurfaceTool::Cylinder(surface));
- AppendIntAna(curve,surface,EllipseCylinder);
+ case GeomAbs_Cylinder: {
+ IntAna_IntConicQuad EllipseCylinder(Ellipse, TheSurfaceTool::Cylinder(surface));
+ AppendIntAna(curve, surface, EllipseCylinder);
break;
}
- case GeomAbs_Cone:
- {
- IntAna_IntConicQuad EllipseCone(Ellipse,TheSurfaceTool::Cone(surface));
- AppendIntAna(curve,surface,EllipseCone);
+ case GeomAbs_Cone: {
+ IntAna_IntConicQuad EllipseCone(Ellipse, TheSurfaceTool::Cone(surface));
+ AppendIntAna(curve, surface, EllipseCone);
break;
- }
- case GeomAbs_Sphere:
- {
- IntAna_IntConicQuad EllipseSphere(Ellipse,TheSurfaceTool::Sphere(surface));
- AppendIntAna(curve,surface,EllipseSphere);
+ }
+ case GeomAbs_Sphere: {
+ IntAna_IntConicQuad EllipseSphere(Ellipse, TheSurfaceTool::Sphere(surface));
+ AppendIntAna(curve, surface, EllipseSphere);
break;
}
- default:
- {
- IntCurveSurface_ThePolygon polygon(curve,NBSAMPLESONELLIPSE);
- InternalPerform(curve,polygon,surface,U1,V1,U2,V2);
+ default: {
+ IntCurveSurface_ThePolygon polygon(curve, NBSAMPLESONELLIPSE);
+ InternalPerform(curve, polygon, surface, U1, V1, U2, V2);
}
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::PerformConicSurf(const gp_Parab& Parab,
- const TheCurve& curve,
- const TheSurface& surface,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2) {
+void IntCurveSurface_Inter::PerformConicSurf(const gp_Parab& Parab,
+ const TheCurve& curve,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+{
GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- switch(SurfaceType) {
- case GeomAbs_Plane:
- {
- IntAna_IntConicQuad ParabPlane(Parab,TheSurfaceTool::Plane(surface),TOLERANCE_ANGULAIRE);
- AppendIntAna(curve,surface,ParabPlane);
+ switch (SurfaceType)
+ {
+ case GeomAbs_Plane: {
+ IntAna_IntConicQuad ParabPlane(Parab, TheSurfaceTool::Plane(surface), TOLERANCE_ANGULAIRE);
+ AppendIntAna(curve, surface, ParabPlane);
break;
}
- case GeomAbs_Cylinder:
- {
- IntAna_IntConicQuad ParabCylinder(Parab,TheSurfaceTool::Cylinder(surface));
- AppendIntAna(curve,surface,ParabCylinder);
+ case GeomAbs_Cylinder: {
+ IntAna_IntConicQuad ParabCylinder(Parab, TheSurfaceTool::Cylinder(surface));
+ AppendIntAna(curve, surface, ParabCylinder);
break;
}
- case GeomAbs_Cone:
- {
- IntAna_IntConicQuad ParabCone(Parab,TheSurfaceTool::Cone(surface));
- AppendIntAna(curve,surface,ParabCone);
+ case GeomAbs_Cone: {
+ IntAna_IntConicQuad ParabCone(Parab, TheSurfaceTool::Cone(surface));
+ AppendIntAna(curve, surface, ParabCone);
break;
- }
- case GeomAbs_Sphere:
- {
- IntAna_IntConicQuad ParabSphere(Parab,TheSurfaceTool::Sphere(surface));
- AppendIntAna(curve,surface,ParabSphere);
+ }
+ case GeomAbs_Sphere: {
+ IntAna_IntConicQuad ParabSphere(Parab, TheSurfaceTool::Sphere(surface));
+ AppendIntAna(curve, surface, ParabSphere);
break;
}
- default:
- {
- Standard_Integer nbsu,nbsv;
- nbsu = TheSurfaceTool::NbSamplesU(surface,U1,U2);
- nbsv = TheSurfaceTool::NbSamplesV(surface,V1,V2);
- if(nbsu>40) nbsu=40;
- if(nbsv>40) nbsv=40;
- IntCurveSurface_ThePolyhedron polyhedron(surface,nbsu,nbsv,U1,V1,U2,V2);
- Intf_Tool bndTool;
- Bnd_Box boxParab;
- bndTool.ParabBox(Parab,polyhedron.Bounding(),boxParab);
- for(Standard_Integer nbseg=1; nbseg<= bndTool.NbSegments(); nbseg++) {
- IntCurveSurface_ThePolygon polygon(curve,
- bndTool.BeginParam(nbseg),
- bndTool.EndParam(nbseg),
- NBSAMPLESONPARAB);
- InternalPerform(curve,polygon,surface,polyhedron,U1,V1,U2,V2);
+ default: {
+ Standard_Integer nbsu, nbsv;
+ nbsu = TheSurfaceTool::NbSamplesU(surface, U1, U2);
+ nbsv = TheSurfaceTool::NbSamplesV(surface, V1, V2);
+ if (nbsu > 40)
+ nbsu = 40;
+ if (nbsv > 40)
+ nbsv = 40;
+ IntCurveSurface_ThePolyhedron polyhedron(surface, nbsu, nbsv, U1, V1, U2, V2);
+ Intf_Tool bndTool;
+ Bnd_Box boxParab;
+ bndTool.ParabBox(Parab, polyhedron.Bounding(), boxParab);
+ for (Standard_Integer nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++)
+ {
+ IntCurveSurface_ThePolygon polygon(curve,
+ bndTool.BeginParam(nbseg),
+ bndTool.EndParam(nbseg),
+ NBSAMPLESONPARAB);
+ InternalPerform(curve, polygon, surface, polyhedron, U1, V1, U2, V2);
}
}
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::PerformConicSurf(const gp_Hypr& Hypr,
- const TheCurve& curve,
- const TheSurface& surface,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2) {
-
+void IntCurveSurface_Inter::PerformConicSurf(const gp_Hypr& Hypr,
+ const TheCurve& curve,
+ const TheSurface& surface,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+{
+
GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- switch(SurfaceType) {
- case GeomAbs_Plane:
- {
- IntAna_IntConicQuad HyprPlane(Hypr,TheSurfaceTool::Plane(surface),TOLERANCE_ANGULAIRE);
- AppendIntAna(curve,surface,HyprPlane);
+ switch (SurfaceType)
+ {
+ case GeomAbs_Plane: {
+ IntAna_IntConicQuad HyprPlane(Hypr, TheSurfaceTool::Plane(surface), TOLERANCE_ANGULAIRE);
+ AppendIntAna(curve, surface, HyprPlane);
break;
}
- case GeomAbs_Cylinder:
- {
- IntAna_IntConicQuad HyprCylinder(Hypr,TheSurfaceTool::Cylinder(surface));
- AppendIntAna(curve,surface,HyprCylinder);
+ case GeomAbs_Cylinder: {
+ IntAna_IntConicQuad HyprCylinder(Hypr, TheSurfaceTool::Cylinder(surface));
+ AppendIntAna(curve, surface, HyprCylinder);
break;
}
- case GeomAbs_Cone:
- {
- IntAna_IntConicQuad HyprCone(Hypr,TheSurfaceTool::Cone(surface));
- AppendIntAna(curve,surface,HyprCone);
+ case GeomAbs_Cone: {
+ IntAna_IntConicQuad HyprCone(Hypr, TheSurfaceTool::Cone(surface));
+ AppendIntAna(curve, surface, HyprCone);
break;
- }
- case GeomAbs_Sphere:
- {
- IntAna_IntConicQuad HyprSphere(Hypr,TheSurfaceTool::Sphere(surface));
- AppendIntAna(curve,surface,HyprSphere);
+ }
+ case GeomAbs_Sphere: {
+ IntAna_IntConicQuad HyprSphere(Hypr, TheSurfaceTool::Sphere(surface));
+ AppendIntAna(curve, surface, HyprSphere);
break;
}
- default:
- {
- Standard_Integer nbsu,nbsv;
- nbsu = TheSurfaceTool::NbSamplesU(surface,U1,U2);
- nbsv = TheSurfaceTool::NbSamplesV(surface,V1,V2);
- if(nbsu>40) nbsu=40;
- if(nbsv>40) nbsv=40;
- IntCurveSurface_ThePolyhedron polyhedron(surface,nbsu,nbsv,U1,V1,U2,V2);
- Intf_Tool bndTool;
- Bnd_Box boxHypr;
- bndTool.HyprBox(Hypr,polyhedron.Bounding(),boxHypr);
- for(Standard_Integer nbseg=1; nbseg<= bndTool.NbSegments(); nbseg++) {
- IntCurveSurface_ThePolygon polygon(curve,
- bndTool.BeginParam(nbseg),
- bndTool.EndParam(nbseg),
- NBSAMPLESONHYPR);
- InternalPerform(curve,polygon,surface,polyhedron,U1,V1,U2,V2);
+ default: {
+ Standard_Integer nbsu, nbsv;
+ nbsu = TheSurfaceTool::NbSamplesU(surface, U1, U2);
+ nbsv = TheSurfaceTool::NbSamplesV(surface, V1, V2);
+ if (nbsu > 40)
+ nbsu = 40;
+ if (nbsv > 40)
+ nbsv = 40;
+ IntCurveSurface_ThePolyhedron polyhedron(surface, nbsu, nbsv, U1, V1, U2, V2);
+ Intf_Tool bndTool;
+ Bnd_Box boxHypr;
+ bndTool.HyprBox(Hypr, polyhedron.Bounding(), boxHypr);
+ for (Standard_Integer nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++)
+ {
+ IntCurveSurface_ThePolygon polygon(curve,
+ bndTool.BeginParam(nbseg),
+ bndTool.EndParam(nbseg),
+ NBSAMPLESONHYPR);
+ InternalPerform(curve, polygon, surface, polyhedron, U1, V1, U2, V2);
}
}
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::AppendIntAna(const TheCurve& curve,
- const TheSurface& surface,
- const IntAna_IntConicQuad& intana_ConicQuad) {
- if(intana_ConicQuad.IsDone()) {
- if(intana_ConicQuad.IsInQuadric()) {
+void IntCurveSurface_Inter::AppendIntAna(const TheCurve& curve,
+ const TheSurface& surface,
+ const IntAna_IntConicQuad& intana_ConicQuad)
+{
+ if (intana_ConicQuad.IsDone())
+ {
+ if (intana_ConicQuad.IsInQuadric())
+ {
//-- std::cout<<" Courbe Dans la Quadrique !!! Non Traite !!!"<<std::endl;
myIsParallel = Standard_True;
}
- else if(intana_ConicQuad.IsParallel()) {
+ else if (intana_ConicQuad.IsParallel())
+ {
//-- std::cout<<" Courbe // a la Quadrique !!! Non Traite !!!"<<std::endl;
myIsParallel = Standard_True;
}
- else {
+ else
+ {
Standard_Integer nbp = intana_ConicQuad.NbPoints();
- Standard_Real u,v,w;
- for(Standard_Integer i = 1; i<= nbp; i++) {
- gp_Pnt P(intana_ConicQuad.Point(i));
- w = intana_ConicQuad.ParamOnConic(i);
- IntCurveSurface_ComputeParamsOnQuadric(surface,P,u,v);
- AppendPoint(curve,w,surface,u,v);
+ Standard_Real u, v, w;
+ for (Standard_Integer i = 1; i <= nbp; i++)
+ {
+ gp_Pnt P(intana_ConicQuad.Point(i));
+ w = intana_ConicQuad.ParamOnConic(i);
+ IntCurveSurface_ComputeParamsOnQuadric(surface, P, u, v);
+ AppendPoint(curve, w, surface, u, v);
}
}
}
- else {
+ else
+ {
//-- std::cout<<" IntAna Conic Quad Not Done "<<std::endl;
}
}
+
//=================================================================================================
-void IntCurveSurface_Inter::AppendPoint(const TheCurve& curve,
- const Standard_Real lw,
- const TheSurface& surface,
- const Standard_Real su,
- const Standard_Real sv) {
-
+void IntCurveSurface_Inter::AppendPoint(const TheCurve& curve,
+ const Standard_Real lw,
+ const TheSurface& surface,
+ const Standard_Real su,
+ const Standard_Real sv)
+{
+
Standard_Real W0 = TheCurveTool::FirstParameter(curve);
Standard_Real W1 = TheCurveTool::LastParameter(curve);
Standard_Real U0 = TheSurfaceTool::FirstUParameter(surface);
GeomAbs_CurveType aCType = TheCurveTool::GetType(curve);
- if(TheCurveTool::IsPeriodic(curve)
- || aCType == GeomAbs_Circle
- || aCType == GeomAbs_Ellipse) {
+ if (TheCurveTool::IsPeriodic(curve) || aCType == GeomAbs_Circle || aCType == GeomAbs_Ellipse)
+ {
w = ElCLib::InPeriod(w, W0, W0 + TheCurveTool::Period(curve));
}
- if((W0 - w) >= TOLTANGENCY || (w - W1) >= TOLTANGENCY) return;
+ if ((W0 - w) >= TOLTANGENCY || (w - W1) >= TOLTANGENCY)
+ return;
GeomAbs_SurfaceType aSType = TheSurfaceTool::GetType(surface);
- if (TheSurfaceTool::IsUPeriodic(surface)
- || aSType == GeomAbs_Cylinder
- || aSType == GeomAbs_Cone
- || aSType == GeomAbs_Sphere) {
+ if (TheSurfaceTool::IsUPeriodic(surface) || aSType == GeomAbs_Cylinder || aSType == GeomAbs_Cone
+ || aSType == GeomAbs_Sphere)
+ {
u = ElCLib::InPeriod(u, U0, U0 + TheSurfaceTool::UPeriod(surface));
}
- if (TheSurfaceTool::IsVPeriodic(surface)) {
+ if (TheSurfaceTool::IsVPeriodic(surface))
+ {
v = ElCLib::InPeriod(v, V0, V0 + TheSurfaceTool::VPeriod(surface));
}
- if((U0 - u) >= TOLTANGENCY || (u - U1) >= TOLTANGENCY) return;
- if((V0 - v) >= TOLTANGENCY || (v - V1) >= TOLTANGENCY) return;
+ if ((U0 - u) >= TOLTANGENCY || (u - U1) >= TOLTANGENCY)
+ return;
+ if ((V0 - v) >= TOLTANGENCY || (v - V1) >= TOLTANGENCY)
+ return;
- IntCurveSurface_TransitionOnCurve TransOnCurve;
- IntCurveSurface_ComputeTransitions(curve,w,TransOnCurve,
- surface,u,v);
- gp_Pnt P(TheCurveTool::Value(curve,w));
- IntCurveSurface_IntersectionPoint IP(P,u,v,w,TransOnCurve);
+ IntCurveSurface_TransitionOnCurve TransOnCurve;
+ IntCurveSurface_ComputeTransitions(curve, w, TransOnCurve, surface, u, v);
+ gp_Pnt P(TheCurveTool::Value(curve, w));
+ IntCurveSurface_IntersectionPoint IP(P, u, v, w, TransOnCurve);
Append(IP); //-- invoque la methode de IntCurveSurface_Intersection.
-
}
//=================================================================================================
-void IntCurveSurface_Inter::AppendSegment(const TheCurve& ,
- const Standard_Real ,
- const Standard_Real ,
- const TheSurface& ) {
- //std::cout<<" !!! Not Yet Implemented
- //IntCurveSurface_Inter::Append(const IntCurveSurf ...)"<<std::endl;
+void IntCurveSurface_Inter::AppendSegment(const TheCurve&,
+ const Standard_Real,
+ const Standard_Real,
+ const TheSurface&)
+{
+ // std::cout<<" !!! Not Yet Implemented
+ // IntCurveSurface_Inter::Append(const IntCurveSurf ...)"<<std::endl;
}
//=======================================================================
-//function : SectionPointToParameters
-//purpose : P o i n t d i n t e r f e r e n c e - - >
-// U , V e t W
+// function : SectionPointToParameters
+// purpose : P o i n t d i n t e r f e r e n c e - - >
+// U , V e t W
//=======================================================================
-void SectionPointToParameters(const Intf_SectionPoint& Sp,
- const IntCurveSurface_ThePolyhedron& Polyhedron,
- const IntCurveSurface_ThePolygon& Polygon,
- Standard_Real& U,
- Standard_Real& V,
- Standard_Real& W) {
-
- Intf_PIType typ;
- Standard_Integer Adr1,Adr2;
- Standard_Real Param,u,v;
- gp_Pnt P(Sp.Pnt());
-
- Standard_Integer Pt1,Pt2,Pt3;
- Standard_Real u1 = 0.,v1 = 0.,param;
+void SectionPointToParameters(const Intf_SectionPoint& Sp,
+ const IntCurveSurface_ThePolyhedron& Polyhedron,
+ const IntCurveSurface_ThePolygon& Polygon,
+ Standard_Real& U,
+ Standard_Real& V,
+ Standard_Real& W)
+{
+
+ Intf_PIType typ;
+ Standard_Integer Adr1, Adr2;
+ Standard_Real Param, u, v;
+ gp_Pnt P(Sp.Pnt());
+
+ Standard_Integer Pt1, Pt2, Pt3;
+ Standard_Real u1 = 0., v1 = 0., param;
//----------------------------------------------------------------------
//-- Calcul des parametres approches sur la surface --
//----------------------------------------------------------------------
-
- Sp.InfoSecond(typ,Adr1,Adr2,Param);
- switch(typ) {
- case Intf_VERTEX: //-- Adr1 est le numero du vertex
+
+ Sp.InfoSecond(typ, Adr1, Adr2, Param);
+ switch (typ)
+ {
+ case Intf_VERTEX: //-- Adr1 est le numero du vertex
{
- Polyhedron.Parameters(Adr1,u1,v1);
+ Polyhedron.Parameters(Adr1, u1, v1);
break;
}
- case Intf_EDGE:
- {
- Polyhedron.Parameters(Adr1,u1,v1);
- Polyhedron.Parameters(Adr2,u,v);
- u1+= Param * (u-u1);
- v1+= Param * (v-v1);
+ case Intf_EDGE: {
+ Polyhedron.Parameters(Adr1, u1, v1);
+ Polyhedron.Parameters(Adr2, u, v);
+ u1 += Param * (u - u1);
+ v1 += Param * (v - v1);
break;
}
- case Intf_FACE:
- {
- Standard_Real ua,va,ub,vb,uc,vc,ca,cb,cc,cabc;
- Polyhedron.Triangle(Adr1,Pt1,Pt2,Pt3);
+ case Intf_FACE: {
+ Standard_Real ua, va, ub, vb, uc, vc, ca, cb, cc, cabc;
+ Polyhedron.Triangle(Adr1, Pt1, Pt2, Pt3);
gp_Pnt PA(Polyhedron.Point(Pt1));
gp_Pnt PB(Polyhedron.Point(Pt2));
gp_Pnt PC(Polyhedron.Point(Pt3));
- Polyhedron.Parameters(Pt1,ua,va);
- Polyhedron.Parameters(Pt2,ub,vb);
- Polyhedron.Parameters(Pt3,uc,vc);
- gp_Vec Normale(gp_Vec(PA,PB).Crossed(gp_Vec(PA,PC)));
- cc = (gp_Vec(PA,PB).Crossed(gp_Vec(PA,P))).Dot(Normale);
- ca = (gp_Vec(PB,PC).Crossed(gp_Vec(PB,P))).Dot(Normale);
- cb = (gp_Vec(PC,PA).Crossed(gp_Vec(PC,P))).Dot(Normale);
+ Polyhedron.Parameters(Pt1, ua, va);
+ Polyhedron.Parameters(Pt2, ub, vb);
+ Polyhedron.Parameters(Pt3, uc, vc);
+ gp_Vec Normale(gp_Vec(PA, PB).Crossed(gp_Vec(PA, PC)));
+ cc = (gp_Vec(PA, PB).Crossed(gp_Vec(PA, P))).Dot(Normale);
+ ca = (gp_Vec(PB, PC).Crossed(gp_Vec(PB, P))).Dot(Normale);
+ cb = (gp_Vec(PC, PA).Crossed(gp_Vec(PC, P))).Dot(Normale);
cabc = ca + cb + cc;
-
- ca/=cabc; cb/=cabc; cc/=cabc;
-
+
+ ca /= cabc;
+ cb /= cabc;
+ cc /= cabc;
+
u1 = ca * ua + cb * ub + cc * uc;
v1 = ca * va + cb * vb + cc * vc;
break;
}
- default:
- {
- std::cout<<" Default dans SectionPointToParameters "<<std::endl;
+ default: {
+ std::cout << " Default dans SectionPointToParameters " << std::endl;
break;
}
}
//----------------------------------------------------------------------
Standard_Integer SegIndex;
- Sp.InfoFirst(typ,SegIndex,param);
- W = Polygon.ApproxParamOnCurve(SegIndex,param);
- if(param>1.0 || param<0.0) {
+ Sp.InfoFirst(typ, SegIndex, param);
+ W = Polygon.ApproxParamOnCurve(SegIndex, param);
+ if (param > 1.0 || param < 0.0)
+ {
//-- IntCurveSurface_ThePolyhedronTool::Dump(Polyhedron);
//-- IntCurveSurface_ThePolygonTool::Dump(Polygon);
- }
+ }
U = u1;
V = v1;
}
+
//=================================================================================================
-void IntCurveSurface_ComputeTransitions(const TheCurve& curve,
- const Standard_Real w,
- IntCurveSurface_TransitionOnCurve& TransOnCurve,
- const TheSurface& surface,
- const Standard_Real u,
- const Standard_Real v) {
-
- gp_Vec NSurf,D1U,D1V;//TgCurv;
- gp_Pnt Psurf;
+void IntCurveSurface_ComputeTransitions(const TheCurve& curve,
+ const Standard_Real w,
+ IntCurveSurface_TransitionOnCurve& TransOnCurve,
+ const TheSurface& surface,
+ const Standard_Real u,
+ const Standard_Real v)
+{
+
+ gp_Vec NSurf, D1U, D1V; // TgCurv;
+ gp_Pnt Psurf;
Standard_Real CosDir;
-
-
- TheSurfaceTool::D1(surface,u,v,Psurf,D1U,D1V);
+
+ TheSurfaceTool::D1(surface, u, v, Psurf, D1U, D1V);
NSurf = D1U.Crossed(D1V);
- TheCurveTool::D1(curve,w,Psurf,D1U);
+ TheCurveTool::D1(curve, w, Psurf, D1U);
Standard_Real Norm = NSurf.Magnitude();
- if(Norm>TOLERANCE_ANGULAIRE &&
- D1U.SquareMagnitude() > TOLERANCE_ANGULAIRE) {
+ if (Norm > TOLERANCE_ANGULAIRE && D1U.SquareMagnitude() > TOLERANCE_ANGULAIRE)
+ {
D1U.Normalize();
CosDir = NSurf.Dot(D1U);
- CosDir/=Norm;
- if( -CosDir > TOLERANCE_ANGULAIRE) {
+ CosDir /= Norm;
+ if (-CosDir > TOLERANCE_ANGULAIRE)
+ {
//-- --Curve---> <----Surface----
- TransOnCurve = IntCurveSurface_In;
+ TransOnCurve = IntCurveSurface_In;
}
- else if(CosDir > TOLERANCE_ANGULAIRE) {
+ else if (CosDir > TOLERANCE_ANGULAIRE)
+ {
//-- --Curve---> ----Surface-->
- TransOnCurve = IntCurveSurface_Out;
- }
- else {
- TransOnCurve = IntCurveSurface_Tangent;
+ TransOnCurve = IntCurveSurface_Out;
+ }
+ else
+ {
+ TransOnCurve = IntCurveSurface_Tangent;
}
}
- else {
- TransOnCurve = IntCurveSurface_Tangent;
+ else
+ {
+ TransOnCurve = IntCurveSurface_Tangent;
}
}
+
//=================================================================================================
void IntCurveSurface_ComputeParamsOnQuadric(const TheSurface& surface,
- const gp_Pnt& P,
- Standard_Real& u,
- Standard_Real& v) {
+ const gp_Pnt& P,
+ Standard_Real& u,
+ Standard_Real& v)
+{
GeomAbs_SurfaceType SurfaceType = TheSurfaceTool::GetType(surface);
- switch(SurfaceType) {
- case GeomAbs_Plane:
- {
- ElSLib::Parameters(TheSurfaceTool::Plane(surface),P,u,v);
- break;
- }
- case GeomAbs_Cylinder:
- {
- ElSLib::Parameters(TheSurfaceTool::Cylinder(surface),P,u,v);
- break;
- }
- case GeomAbs_Cone:
- {
- ElSLib::Parameters(TheSurfaceTool::Cone(surface),P,u,v);
- break;
- }
- case GeomAbs_Sphere:
- {
- ElSLib::Parameters(TheSurfaceTool::Sphere(surface),P,u,v);
- break;
- }
- default:
- break;
+ switch (SurfaceType)
+ {
+ case GeomAbs_Plane: {
+ ElSLib::Parameters(TheSurfaceTool::Plane(surface), P, u, v);
+ break;
+ }
+ case GeomAbs_Cylinder: {
+ ElSLib::Parameters(TheSurfaceTool::Cylinder(surface), P, u, v);
+ break;
+ }
+ case GeomAbs_Cone: {
+ ElSLib::Parameters(TheSurfaceTool::Cone(surface), P, u, v);
+ break;
+ }
+ case GeomAbs_Sphere: {
+ ElSLib::Parameters(TheSurfaceTool::Sphere(surface), P, u, v);
+ break;
+ }
+ default:
+ break;
}
}
+
//=======================================================================
-//function : EstLimForInfExtr
-//purpose : Estimation of limits for infinite surfaces
+// function : EstLimForInfExtr
+// purpose : Estimation of limits for infinite surfaces
//=======================================================================
-void EstLimForInfExtr(const gp_Lin& Line,
- const TheSurface& surface,
- const Standard_Boolean IsOffSurf,
- const Standard_Integer nbsu,
- const Standard_Boolean U1inf,
- const Standard_Boolean U2inf,
- const Standard_Boolean V1inf,
- const Standard_Boolean V2inf,
- Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new,
- Standard_Boolean& NoIntersection)
+void EstLimForInfExtr(const gp_Lin& Line,
+ const TheSurface& surface,
+ const Standard_Boolean IsOffSurf,
+ const Standard_Integer nbsu,
+ const Standard_Boolean U1inf,
+ const Standard_Boolean U2inf,
+ const Standard_Boolean V1inf,
+ const Standard_Boolean V2inf,
+ Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new,
+ Standard_Boolean& NoIntersection)
{
NoIntersection = Standard_False;
- Handle(Adaptor3d_Surface) aBasSurf;
+ Handle(Adaptor3d_Surface) aBasSurf;
- if(IsOffSurf) aBasSurf = TheSurfaceTool::BasisSurface(surface);
+ if (IsOffSurf)
+ aBasSurf = TheSurfaceTool::BasisSurface(surface);
gp_Dir aDirOfExt;
- if(IsOffSurf) aDirOfExt = aBasSurf->Direction();
- else aDirOfExt = TheSurfaceTool::Direction(surface);
+ if (IsOffSurf)
+ aDirOfExt = aBasSurf->Direction();
+ else
+ aDirOfExt = TheSurfaceTool::Direction(surface);
Standard_Real tolang = TOLERANCE_ANGULAIRE;
- if(aDirOfExt.IsParallel(Line.Direction(), tolang)) {
+ if (aDirOfExt.IsParallel(Line.Direction(), tolang))
+ {
NoIntersection = Standard_True;
return;
}
- if((V1inf || V2inf) && !(U1inf || U2inf)) {
+ if ((V1inf || V2inf) && !(U1inf || U2inf))
+ {
- Standard_Real vmin = RealLast(), vmax = -vmin;
- gp_Lin aL;
- Standard_Real step = (U2new - U1new) / nbsu;
- Standard_Real u = U1new, v;
- gp_Pnt aP;
- Extrema_POnCurv aP1, aP2;
+ Standard_Real vmin = RealLast(), vmax = -vmin;
+ gp_Lin aL;
+ Standard_Real step = (U2new - U1new) / nbsu;
+ Standard_Real u = U1new, v;
+ gp_Pnt aP;
+ Extrema_POnCurv aP1, aP2;
Standard_Integer i;
- for(i = 0; i <= nbsu; i++) {
+ for (i = 0; i <= nbsu; i++)
+ {
TheSurfaceTool::D0(surface, u, 0., aP);
aL.SetLocation(aP);
aL.SetDirection(aDirOfExt);
Extrema_ExtElC aExtr(aL, Line, tolang);
-
- if(!aExtr.IsDone()) return;
- if(aExtr.IsParallel()) {
- NoIntersection = Standard_True;
- return;
+ if (!aExtr.IsDone())
+ return;
+
+ if (aExtr.IsParallel())
+ {
+ NoIntersection = Standard_True;
+ return;
}
aExtr.Points(1, aP1, aP2);
- v = aP1.Parameter();
+ v = aP1.Parameter();
vmin = Min(vmin, v);
vmax = Max(vmax, v);
u += step;
-
}
vmin = vmin - Abs(vmin) - 10.;
V1new = Max(V1new, vmin);
V2new = Min(V2new, vmax);
-
}
- else if(U1inf || U2inf) {
+ else if (U1inf || U2inf)
+ {
Standard_Real umin = RealLast(), umax = -umin;
Standard_Real u0 = Min(Max(0., U1new), U2new);
Standard_Real v0 = Min(Max(0., V1new), V2new);
- gp_Pnt aP;
+ gp_Pnt aP;
TheSurfaceTool::D0(surface, u0, v0, aP);
gp_Pln aRefPln(aP, aDirOfExt);
Handle(Adaptor3d_Curve) aBasCurv;
- if(IsOffSurf) aBasCurv = aBasSurf->BasisCurve();
- else aBasCurv = TheSurfaceTool::BasisCurve(surface);
+ if (IsOffSurf)
+ aBasCurv = aBasSurf->BasisCurve();
+ else
+ aBasCurv = TheSurfaceTool::BasisCurve(surface);
ProjLib_Plane Projector(aRefPln);
Projector.Project(Line);
- if(!Projector.IsDone()) return;
+ if (!Projector.IsDone())
+ return;
gp_Lin2d Line2d = Projector.Line();
GeomAbs_CurveType aCurvTyp = aBasCurv->GetType();
- if(aCurvTyp == GeomAbs_Line) {
-
+ if (aCurvTyp == GeomAbs_Line)
+ {
+
Projector.Project(aBasCurv->Line());
- if(!Projector.IsDone()) return;
+ if (!Projector.IsDone())
+ return;
gp_Lin2d aL2d = Projector.Line();
IntAna2d_AnaIntersection anInter(Line2d, aL2d);
- if(!anInter.IsDone()) return;
+ if (!anInter.IsDone())
+ return;
- if(anInter.IsEmpty() || anInter.IdenticalElements() ||
- anInter.ParallelElements() ) {
- NoIntersection = Standard_True;
- return;
+ if (anInter.IsEmpty() || anInter.IdenticalElements() || anInter.ParallelElements())
+ {
+ NoIntersection = Standard_True;
+ return;
}
const IntAna2d_IntPoint& anIntPnt = anInter.Point(1);
umin = umax = anIntPnt.ParamOnSecond();
}
- else if(aCurvTyp == GeomAbs_Parabola || aCurvTyp == GeomAbs_Hyperbola) {
+ else if (aCurvTyp == GeomAbs_Parabola || aCurvTyp == GeomAbs_Hyperbola)
+ {
- IntAna2d_Conic aCon(Line2d);
+ IntAna2d_Conic aCon(Line2d);
IntAna2d_AnaIntersection anInter;
-
- if(aCurvTyp == GeomAbs_Parabola) {
- Projector.Project(aBasCurv->Parabola());
- if(!Projector.IsDone()) return;
- const gp_Parab2d& aP2d = Projector.Parabola();
+ if (aCurvTyp == GeomAbs_Parabola)
+ {
+ Projector.Project(aBasCurv->Parabola());
+ if (!Projector.IsDone())
+ return;
+
+ const gp_Parab2d& aP2d = Projector.Parabola();
- anInter.Perform(aP2d, aCon);
+ anInter.Perform(aP2d, aCon);
}
- else {
- Projector.Project(aBasCurv->Hyperbola());
- if(!Projector.IsDone()) return;
+ else
+ {
+ Projector.Project(aBasCurv->Hyperbola());
+ if (!Projector.IsDone())
+ return;
- const gp_Hypr2d& aH2d = Projector.Hyperbola();
- anInter.Perform(aH2d, aCon);
+ const gp_Hypr2d& aH2d = Projector.Hyperbola();
+ anInter.Perform(aH2d, aCon);
}
- if(!anInter.IsDone()) return;
+ if (!anInter.IsDone())
+ return;
- if(anInter.IsEmpty()) {
- NoIntersection = Standard_True;
- return;
+ if (anInter.IsEmpty())
+ {
+ NoIntersection = Standard_True;
+ return;
}
Standard_Integer i, nbint = anInter.NbPoints();
- for(i = 1; i <= nbint; i++) {
+ for (i = 1; i <= nbint; i++)
+ {
- const IntAna2d_IntPoint& anIntPnt = anInter.Point(i);
+ const IntAna2d_IntPoint& anIntPnt = anInter.Point(i);
- umin = Min(anIntPnt.ParamOnFirst(), umin);
- umax = Max(anIntPnt.ParamOnFirst(), umax);
-
+ umin = Min(anIntPnt.ParamOnFirst(), umin);
+ umax = Max(anIntPnt.ParamOnFirst(), umax);
}
-
}
- else {
+ else
+ {
return;
}
-
+
umin = umin - Abs(umin) - 10;
umax = umax + Abs(umax) + 10;
U1new = Max(U1new, umin);
U2new = Min(U2new, umax);
-
- if(V1inf || V2inf) {
- EstLimForInfExtr(Line, surface, IsOffSurf, nbsu,
- Standard_False, Standard_False, V1inf, V2inf,
- U1new, U2new, V1new, V2new, NoIntersection);
+
+ if (V1inf || V2inf)
+ {
+ EstLimForInfExtr(Line,
+ surface,
+ IsOffSurf,
+ nbsu,
+ Standard_False,
+ Standard_False,
+ V1inf,
+ V2inf,
+ U1new,
+ U2new,
+ V1new,
+ V2new,
+ NoIntersection);
}
}
-
+
return;
-
}
+
//=======================================================================
-//function : ProjectIntersectAndEstLim
-//purpose : project <theLine> and it's X-axe symmetric line to <thePln> and
+// function : ProjectIntersectAndEstLim
+// purpose : project <theLine> and it's X-axe symmetric line to <thePln> and
// intersect resulting curve with <theBasCurvProj>.
// Then estimate max and min parameters of intersection on
// <theBasCurvProj>.
// Is called from EstLimForInfRevl()
//=======================================================================
void ProjectIntersectAndEstLim(const gp_Lin& theLine,
- const gp_Pln& thePln,
- const ProjLib_Plane& theBasCurvProj,
- Standard_Real& theVmin,
- Standard_Real& theVmax,
- Standard_Boolean& theNoIntersection)
+ const gp_Pln& thePln,
+ const ProjLib_Plane& theBasCurvProj,
+ Standard_Real& theVmin,
+ Standard_Real& theVmax,
+ Standard_Boolean& theNoIntersection)
{
- ProjLib_Plane aLineProj( thePln, theLine );
- if (!aLineProj.IsDone()) {
+ ProjLib_Plane aLineProj(thePln, theLine);
+ if (!aLineProj.IsDone())
+ {
#ifdef OCCT_DEBUG
- std::cout
- << "Info: IntCurveSurface_Inter::ProjectIntersectAndEstLim(), !aLineProj.IsDone()"
- << std::endl;
+ std::cout << "Info: IntCurveSurface_Inter::ProjectIntersectAndEstLim(), !aLineProj.IsDone()"
+ << std::endl;
#endif
return;
}
gp_Lin2d aLin2d = aLineProj.Line();
- // make a second line X-axe symmetric to the first one
+ // make a second line X-axe symmetric to the first one
gp_Pnt2d aP1 = aLin2d.Location();
- gp_Pnt2d aP2 (aP1.XY() + aLin2d.Direction().XY());
- gp_Pnt2d aP1sym (aP1.X(), -aP1.Y());
- gp_Pnt2d aP2sym (aP2.X(), -aP2.Y());
- gp_Lin2d aLin2dsym (aP1sym, gp_Vec2d(aP1sym,aP2sym));
-
+ gp_Pnt2d aP2(aP1.XY() + aLin2d.Direction().XY());
+ gp_Pnt2d aP1sym(aP1.X(), -aP1.Y());
+ gp_Pnt2d aP2sym(aP2.X(), -aP2.Y());
+ gp_Lin2d aLin2dsym(aP1sym, gp_Vec2d(aP1sym, aP2sym));
+
// intersect projections
- IntAna2d_Conic aCon (aLin2d);
- IntAna2d_Conic aConSym (aLin2dsym);
+ IntAna2d_Conic aCon(aLin2d);
+ IntAna2d_Conic aConSym(aLin2dsym);
IntAna2d_AnaIntersection anIntersect;
IntAna2d_AnaIntersection anIntersectSym;
-
- switch (theBasCurvProj.GetType()) {
- case GeomAbs_Line:
- anIntersectSym.Perform(theBasCurvProj.Line(), aConSym);
- anIntersect.Perform(theBasCurvProj.Line(), aCon); break;
- case GeomAbs_Hyperbola:
- anIntersectSym.Perform(theBasCurvProj.Hyperbola(), aConSym);
- anIntersect.Perform(theBasCurvProj.Hyperbola(), aCon); break;
- case GeomAbs_Parabola:
- anIntersectSym.Perform(theBasCurvProj.Parabola(), aConSym);
- anIntersect.Perform(theBasCurvProj.Parabola(), aCon); break;
- default:
- return; // not infinite curve
+
+ switch (theBasCurvProj.GetType())
+ {
+ case GeomAbs_Line:
+ anIntersectSym.Perform(theBasCurvProj.Line(), aConSym);
+ anIntersect.Perform(theBasCurvProj.Line(), aCon);
+ break;
+ case GeomAbs_Hyperbola:
+ anIntersectSym.Perform(theBasCurvProj.Hyperbola(), aConSym);
+ anIntersect.Perform(theBasCurvProj.Hyperbola(), aCon);
+ break;
+ case GeomAbs_Parabola:
+ anIntersectSym.Perform(theBasCurvProj.Parabola(), aConSym);
+ anIntersect.Perform(theBasCurvProj.Parabola(), aCon);
+ break;
+ default:
+ return; // not infinite curve
}
// retrieve params of intersections
- Standard_Integer aNbIntPnt = anIntersect.IsDone() ? anIntersect.NbPoints() : 0;
+ Standard_Integer aNbIntPnt = anIntersect.IsDone() ? anIntersect.NbPoints() : 0;
Standard_Integer aNbIntPntSym = anIntersectSym.IsDone() ? anIntersectSym.NbPoints() : 0;
- Standard_Integer iPnt, aNbPnt = Max (aNbIntPnt, aNbIntPntSym);
-
- if (aNbPnt == 0) {
+ Standard_Integer iPnt, aNbPnt = Max(aNbIntPnt, aNbIntPntSym);
+
+ if (aNbPnt == 0)
+ {
theNoIntersection = Standard_True;
return;
}
Standard_Real aParam;
for (iPnt = 1; iPnt <= aNbPnt; iPnt++)
{
- if (iPnt <= aNbIntPnt) {
+ if (iPnt <= aNbIntPnt)
+ {
const IntAna2d_IntPoint& aIntPnt = anIntersect.Point(iPnt);
- aParam = aIntPnt.ParamOnFirst();
- theVmin = Min (theVmin, aParam );
- theVmax = Max (theVmax, aParam );
+ aParam = aIntPnt.ParamOnFirst();
+ theVmin = Min(theVmin, aParam);
+ theVmax = Max(theVmax, aParam);
}
- if (iPnt <= aNbIntPntSym) {
+ if (iPnt <= aNbIntPntSym)
+ {
const IntAna2d_IntPoint& aIntPnt = anIntersectSym.Point(iPnt);
- aParam = aIntPnt.ParamOnFirst();
- theVmin = Min (theVmin, aParam );
- theVmax = Max (theVmax, aParam );
+ aParam = aIntPnt.ParamOnFirst();
+ theVmin = Min(theVmin, aParam);
+ theVmax = Max(theVmax, aParam);
}
}
return;
}
+
//=======================================================================
-//function : EstLimForInfRevl
-//purpose : Estimate V1 and V2 to pass to InternalPerform() if they are
+// function : EstLimForInfRevl
+// purpose : Estimate V1 and V2 to pass to InternalPerform() if they are
// infinite for Surface of Revolution
// Algo: intersect projections of Line and basis curve on the
// plane passing through revolution axe
//=======================================================================
-void EstLimForInfRevl(const gp_Lin& Line,
- const TheSurface& surface,
- const Standard_Boolean U1inf,
- const Standard_Boolean U2inf,
- const Standard_Boolean V1inf,
- const Standard_Boolean V2inf,
- Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new,
- Standard_Boolean& NoIntersection)
+void EstLimForInfRevl(const gp_Lin& Line,
+ const TheSurface& surface,
+ const Standard_Boolean U1inf,
+ const Standard_Boolean U2inf,
+ const Standard_Boolean V1inf,
+ const Standard_Boolean V2inf,
+ Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new,
+ Standard_Boolean& NoIntersection)
{
NoIntersection = Standard_False;
- if (U1inf || U2inf) {
+ if (U1inf || U2inf)
+ {
if (U1inf)
- U1new = Max (0., U1new);
+ U1new = Max(0., U1new);
else
- U2new = Min (2 * M_PI, U2new);
- if (! V1inf && !V2inf) return;
+ U2new = Min(2 * M_PI, U2new);
+ if (!V1inf && !V2inf)
+ return;
}
Handle(Adaptor3d_Curve) aBasisCurve = TheSurfaceTool::BasisCurve(surface);
- gp_Ax1 aRevAx = TheSurfaceTool::AxeOfRevolution(surface);
- gp_Vec aXVec = aRevAx.Direction();
- constexpr Standard_Real aTolAng = Precision::Angular();
+ gp_Ax1 aRevAx = TheSurfaceTool::AxeOfRevolution(surface);
+ gp_Vec aXVec = aRevAx.Direction();
+ constexpr Standard_Real aTolAng = Precision::Angular();
// make plane to project a basis curve
- gp_Pnt O = aRevAx.Location();
+ gp_Pnt O = aRevAx.Location();
Standard_Real aU = 0.;
- gp_Pnt P = aBasisCurve->Value(aU);
- while (O.SquareDistance(P) <= Precision::PConfusion() ||
- aXVec.IsParallel( gp_Vec(O,P), aTolAng)) {
+ gp_Pnt P = aBasisCurve->Value(aU);
+ while (O.SquareDistance(P) <= Precision::PConfusion() || aXVec.IsParallel(gp_Vec(O, P), aTolAng))
+ {
aU += 1.;
P = aBasisCurve->Value(aU);
if (aU > 3)
// basis curve is a line coinciding with aXVec, P is any not on aXVec
- P = gp_Pnt(aU, aU+1, aU+2);
+ P = gp_Pnt(aU, aU + 1, aU + 2);
}
- gp_Vec aNVec = aXVec ^ gp_Vec(O,P);
- gp_Pln aPln (gp_Ax3 (O, aNVec ,aXVec));
+ gp_Vec aNVec = aXVec ^ gp_Vec(O, P);
+ gp_Pln aPln(gp_Ax3(O, aNVec, aXVec));
// project basic curve
ProjLib_Plane aBasCurvProj(aPln);
- switch (aBasisCurve->GetType()) {
- case GeomAbs_Line:
- aBasCurvProj.Project(aBasisCurve->Line ()); break;
- case GeomAbs_Hyperbola:
- aBasCurvProj.Project(aBasisCurve->Hyperbola()); break;
- case GeomAbs_Parabola:
- aBasCurvProj.Project(aBasisCurve->Parabola ()); break;
- default:
- return; // not infinite curve
+ switch (aBasisCurve->GetType())
+ {
+ case GeomAbs_Line:
+ aBasCurvProj.Project(aBasisCurve->Line());
+ break;
+ case GeomAbs_Hyperbola:
+ aBasCurvProj.Project(aBasisCurve->Hyperbola());
+ break;
+ case GeomAbs_Parabola:
+ aBasCurvProj.Project(aBasisCurve->Parabola());
+ break;
+ default:
+ return; // not infinite curve
}
- if (!aBasCurvProj.IsDone()) {
+ if (!aBasCurvProj.IsDone())
+ {
#ifdef OCCT_DEBUG
- std::cout << "Info: IntCurveSurface_Inter::EstLimForInfRevl(), !aBasCurvProj.IsDone()" << std::endl;
+ std::cout << "Info: IntCurveSurface_Inter::EstLimForInfRevl(), !aBasCurvProj.IsDone()"
+ << std::endl;
#endif
return;
}
// make plane to project Line
- if (aXVec.IsParallel( Line.Direction(), aTolAng)) {
+ if (aXVec.IsParallel(Line.Direction(), aTolAng))
+ {
P = Line.Location();
- while (O.SquareDistance(P) <= Precision::PConfusion()) {
+ while (O.SquareDistance(P) <= Precision::PConfusion())
+ {
aU += 1.;
- P = gp_Pnt(aU, aU+1, aU+2); // any not on aXVec
+ P = gp_Pnt(aU, aU + 1, aU + 2); // any not on aXVec
}
- aNVec = aXVec ^ gp_Vec(O,P);
- } else
- aNVec = aXVec.Crossed( Line.Direction() );
-
- aPln = gp_Pln (gp_Ax3 (O, aNVec ,aXVec));
+ aNVec = aXVec ^ gp_Vec(O, P);
+ }
+ else
+ aNVec = aXVec.Crossed(Line.Direction());
+
+ aPln = gp_Pln(gp_Ax3(O, aNVec, aXVec));
// make a second plane perpendicular to the first one, rotated around aXVec
- gp_Pln aPlnPrp = aPln.Rotated (gp_Ax1 (O,aXVec), M_PI/2.);
-
+ gp_Pln aPlnPrp = aPln.Rotated(gp_Ax1(O, aXVec), M_PI / 2.);
+
// project Line and it's X-axe symmetric one to plane and intersect
// resulting curve with projection of Basic Curve
- Standard_Real aVmin = RealLast(), aVmax = -aVmin;
+ Standard_Real aVmin = RealLast(), aVmax = -aVmin;
Standard_Boolean aNoInt1 = Standard_False, aNoInt2 = Standard_False;
- ProjectIntersectAndEstLim (Line, aPln, aBasCurvProj, aVmin, aVmax, aNoInt1);
- ProjectIntersectAndEstLim (Line, aPlnPrp, aBasCurvProj, aVmin, aVmax, aNoInt2);
+ ProjectIntersectAndEstLim(Line, aPln, aBasCurvProj, aVmin, aVmax, aNoInt1);
+ ProjectIntersectAndEstLim(Line, aPlnPrp, aBasCurvProj, aVmin, aVmax, aNoInt2);
- if (aNoInt1 && aNoInt2) {
+ if (aNoInt1 && aNoInt2)
+ {
NoIntersection = Standard_True;
return;
}
-
+
aVmin = aVmin - Abs(aVmin) - 10;
aVmax = aVmax + Abs(aVmax) + 10;
- if (V1inf) V1new = aVmin;
- if (V2inf) V2new = aVmax;
+ if (V1inf)
+ V1new = aVmin;
+ if (V2inf)
+ V2new = aVmax;
+
+ // std::cout << "EstLimForInfRevl: Vmin " << V1new << " Vmax " << V2new << std::endl;
- //std::cout << "EstLimForInfRevl: Vmin " << V1new << " Vmax " << V2new << std::endl;
-
return;
}
//=================================================================================================
-void EstLimForInfOffs(const gp_Lin& Line,
- const TheSurface& surface,
- const Standard_Integer nbsu,
- const Standard_Boolean U1inf,
- const Standard_Boolean U2inf,
- const Standard_Boolean V1inf,
- const Standard_Boolean V2inf,
- Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new,
- Standard_Boolean& NoIntersection)
+void EstLimForInfOffs(const gp_Lin& Line,
+ const TheSurface& surface,
+ const Standard_Integer nbsu,
+ const Standard_Boolean U1inf,
+ const Standard_Boolean U2inf,
+ const Standard_Boolean V1inf,
+ const Standard_Boolean V2inf,
+ Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new,
+ Standard_Boolean& NoIntersection)
{
NoIntersection = Standard_False;
const Handle(Adaptor3d_Surface)& aBasSurf = TheSurfaceTool::BasisSurface(surface);
- Standard_Real anOffVal = TheSurfaceTool::OffsetValue(surface);
+ Standard_Real anOffVal = TheSurfaceTool::OffsetValue(surface);
GeomAbs_SurfaceType aTypeOfBasSurf = aBasSurf->GetType();
// case for plane, cylinder and cone - make equivalent surface;
- if(aTypeOfBasSurf == GeomAbs_Plane) {
+ if (aTypeOfBasSurf == GeomAbs_Plane)
+ {
gp_Pln aPln = aBasSurf->Plane();
- gp_Vec aT = aPln.Position().XDirection()^aPln.Position().YDirection();
+ gp_Vec aT = aPln.Position().XDirection() ^ aPln.Position().YDirection();
aT *= anOffVal;
aPln.Translate(aT);
- IntAna_IntConicQuad LinPlane(Line,aPln,TOLERANCE_ANGULAIRE);
+ IntAna_IntConicQuad LinPlane(Line, aPln, TOLERANCE_ANGULAIRE);
- if(!LinPlane.IsDone()) return;
+ if (!LinPlane.IsDone())
+ return;
- if(LinPlane.IsParallel() || LinPlane.IsInQuadric()) {
+ if (LinPlane.IsParallel() || LinPlane.IsInQuadric())
+ {
NoIntersection = Standard_True;
return;
-
}
-
+
Standard_Real u, v;
ElSLib::Parameters(aPln, LinPlane.Point(1), u, v);
U1new = Max(U1new, u - 10.);
U2new = Min(U2new, u + 10.);
V1new = Max(V1new, v - 10.);
V2new = Min(V2new, v + 10.);
-
}
- else if(aTypeOfBasSurf == GeomAbs_Cylinder) {
+ else if (aTypeOfBasSurf == GeomAbs_Cylinder)
+ {
gp_Cylinder aCyl = aBasSurf->Cylinder();
- Standard_Real aR = aCyl.Radius();
- gp_Ax3 anA = aCyl.Position();
+ Standard_Real aR = aCyl.Radius();
+ gp_Ax3 anA = aCyl.Position();
- if (anA.Direct())
+ if (anA.Direct())
aR += anOffVal;
- else
+ else
aR -= anOffVal;
- if ( aR >= TOLTANGENCY ) {
+ if (aR >= TOLTANGENCY)
+ {
aCyl.SetRadius(aR);
}
- else if ( aR <= -TOLTANGENCY ){
+ else if (aR <= -TOLTANGENCY)
+ {
anA.Rotate(gp_Ax1(anA.Location(), anA.Direction()), M_PI);
aCyl.SetPosition(anA);
-// modified by NIZHNY-MKK Mon Oct 3 17:37:54 2005
-// aCyl.SetRadius(Abs(aR));
+ // modified by NIZHNY-MKK Mon Oct 3 17:37:54 2005
+ // aCyl.SetRadius(Abs(aR));
aCyl.SetRadius(-aR);
}
- else {
+ else
+ {
NoIntersection = Standard_True;
return;
-
}
IntAna_IntConicQuad LinCylinder(Line, aCyl);
- if(!LinCylinder.IsDone()) return;
+ if (!LinCylinder.IsDone())
+ return;
- if(LinCylinder.IsParallel() || LinCylinder.IsInQuadric()) {
+ if (LinCylinder.IsParallel() || LinCylinder.IsInQuadric())
+ {
NoIntersection = Standard_True;
return;
-
}
-
+
Standard_Integer i, nbp = LinCylinder.NbPoints();
- Standard_Real vmin = RealLast(), vmax = -vmin, u, v;
+ Standard_Real vmin = RealLast(), vmax = -vmin, u, v;
- for(i = 1; i <= nbp; i++) {
+ for (i = 1; i <= nbp; i++)
+ {
ElSLib::Parameters(aCyl, LinCylinder.Point(i), u, v);
vmin = Min(vmin, v);
vmax = Max(vmax, v);
-
- }
+ }
V1new = Max(V1new, vmin - Abs(vmin) - 10.);
V2new = Min(V2new, vmax + Abs(vmax) + 10.);
-
}
- else if(aTypeOfBasSurf == GeomAbs_Cone) {
+ else if (aTypeOfBasSurf == GeomAbs_Cone)
+ {
- gp_Cone aCon = aBasSurf->Cone();
+ gp_Cone aCon = aBasSurf->Cone();
Standard_Real anAng = aCon.SemiAngle();
- Standard_Real aR = aCon.RefRadius() + anOffVal * Cos(anAng);
- gp_Ax3 anA = aCon.Position();
- if ( aR >= 0.) {
+ Standard_Real aR = aCon.RefRadius() + anOffVal * Cos(anAng);
+ gp_Ax3 anA = aCon.Position();
+ if (aR >= 0.)
+ {
- gp_Vec aZ( anA.Direction());
- aZ *= - anOffVal * Sin(anAng);
+ gp_Vec aZ(anA.Direction());
+ aZ *= -anOffVal * Sin(anAng);
anA.Translate(aZ);
aCon.SetPosition(anA);
aCon.SetRadius(aR);
aCon.SetSemiAngle(anAng);
-
}
- else {
+ else
+ {
return;
-
}
IntAna_IntConicQuad LinCone(Line, aCon);
- if(!LinCone.IsDone()) return;
+ if (!LinCone.IsDone())
+ return;
- if(LinCone.IsParallel() || LinCone.IsInQuadric()) {
+ if (LinCone.IsParallel() || LinCone.IsInQuadric())
+ {
NoIntersection = Standard_True;
return;
-
}
-
+
Standard_Integer i, nbp = LinCone.NbPoints();
- Standard_Real vmin = RealLast(), vmax = -vmin, u, v;
+ Standard_Real vmin = RealLast(), vmax = -vmin, u, v;
- for(i = 1; i <= nbp; i++) {
+ for (i = 1; i <= nbp; i++)
+ {
ElSLib::Parameters(aCon, LinCone.Point(i), u, v);
vmin = Min(vmin, v);
vmax = Max(vmax, v);
-
- }
+ }
V1new = Max(V1new, vmin - Abs(vmin) - 10.);
V2new = Min(V2new, vmax + Abs(vmax) + 10.);
-
}
- else if(aTypeOfBasSurf == GeomAbs_SurfaceOfExtrusion) {
+ else if (aTypeOfBasSurf == GeomAbs_SurfaceOfExtrusion)
+ {
Standard_Real anU1 = U1new, anU2 = U2new;
- EstLimForInfExtr(Line, surface, Standard_True, nbsu,
- U1inf, U2inf, V1inf, V2inf,
- U1new, U2new, V1new, V2new, NoIntersection);
-
- if(NoIntersection) return;
+ EstLimForInfExtr(Line,
+ surface,
+ Standard_True,
+ nbsu,
+ U1inf,
+ U2inf,
+ V1inf,
+ V2inf,
+ U1new,
+ U2new,
+ V1new,
+ V2new,
+ NoIntersection);
+
+ if (NoIntersection)
+ return;
- if(U1inf || U2inf) {
+ if (U1inf || U2inf)
+ {
GeomAbs_CurveType aBasCurvType = aBasSurf->BasisCurve()->GetType();
- if(aBasCurvType == GeomAbs_Line) {
- U1new = Max(anU1, -1.e10);
- U2new = Min(anU2, 1.e10);
- }
- else if(aBasCurvType == GeomAbs_Parabola) {
- gp_Parab aPrb = aBasSurf->BasisCurve()->Parabola();
- Standard_Real aF = aPrb.Focal();
- Standard_Real dU = 2.e5 * Sqrt(aF);
- U1new = Max(anU1, -dU);
- U2new = Min(anU2, dU);
+ if (aBasCurvType == GeomAbs_Line)
+ {
+ U1new = Max(anU1, -1.e10);
+ U2new = Min(anU2, 1.e10);
}
- else if(aBasCurvType == GeomAbs_Hyperbola) {
- U1new = Max(anU1, -30.);
- U2new = Min(anU2, 30.);
+ else if (aBasCurvType == GeomAbs_Parabola)
+ {
+ gp_Parab aPrb = aBasSurf->BasisCurve()->Parabola();
+ Standard_Real aF = aPrb.Focal();
+ Standard_Real dU = 2.e5 * Sqrt(aF);
+ U1new = Max(anU1, -dU);
+ U2new = Min(anU2, dU);
+ }
+ else if (aBasCurvType == GeomAbs_Hyperbola)
+ {
+ U1new = Max(anU1, -30.);
+ U2new = Min(anU2, 30.);
+ }
+ else
+ {
+ U1new = Max(anU1, -1.e10);
+ U2new = Min(anU2, 1.e10);
}
- else {
- U1new = Max(anU1, -1.e10);
- U2new = Min(anU2, 1.e10);
- }
-
}
-
}
- else if(aTypeOfBasSurf == GeomAbs_SurfaceOfRevolution) {
+ else if (aTypeOfBasSurf == GeomAbs_SurfaceOfRevolution)
+ {
GeomAbs_CurveType aBasCurvType = aBasSurf->BasisCurve()->GetType();
- if(aBasCurvType == GeomAbs_Line) {
+ if (aBasCurvType == GeomAbs_Line)
+ {
V1new = Max(V1new, -1.e10);
- V2new = Min(V2new, 1.e10);
- }
- else if(aBasCurvType == GeomAbs_Parabola) {
- gp_Parab aPrb = aBasSurf->BasisCurve()->Parabola();
- Standard_Real aF = aPrb.Focal();
- Standard_Real dV = 2.e5 * Sqrt(aF);
- V1new = Max(V1new, -dV);
- V2new = Min(V2new, dV);
- }
- else if(aBasCurvType == GeomAbs_Hyperbola) {
- V1new = Max(V1new, -30.);
- V2new = Min(V2new, 30.);
- }
- else {
- V1new = Max(V1new, -1.e10);
- V2new = Min(V2new, 1.e10);
- }
-
+ V2new = Min(V2new, 1.e10);
+ }
+ else if (aBasCurvType == GeomAbs_Parabola)
+ {
+ gp_Parab aPrb = aBasSurf->BasisCurve()->Parabola();
+ Standard_Real aF = aPrb.Focal();
+ Standard_Real dV = 2.e5 * Sqrt(aF);
+ V1new = Max(V1new, -dV);
+ V2new = Min(V2new, dV);
+ }
+ else if (aBasCurvType == GeomAbs_Hyperbola)
+ {
+ V1new = Max(V1new, -30.);
+ V2new = Min(V2new, 30.);
+ }
+ else
+ {
+ V1new = Max(V1new, -1.e10);
+ V2new = Min(V2new, 1.e10);
+ }
}
- else {
+ else
+ {
V1new = Max(V1new, -1.e10);
- V2new = Min(V2new, 1.e10);
+ V2new = Min(V2new, 1.e10);
}
}
+
//=================================================================================================
-void EstLimForInfSurf(Standard_Real& U1new,
- Standard_Real& U2new,
- Standard_Real& V1new,
- Standard_Real& V2new)
+void EstLimForInfSurf(Standard_Real& U1new,
+ Standard_Real& U2new,
+ Standard_Real& V1new,
+ Standard_Real& V2new)
{
- U1new = Max(U1new, -1.e10);
- U2new = Min(U2new, 1.e10);
- V1new = Max(V1new, -1.e10);
- V2new = Min(V2new, 1.e10);
+ U1new = Max(U1new, -1.e10);
+ U2new = Min(U2new, 1.e10);
+ V1new = Max(V1new, -1.e10);
+ V2new = Min(V2new, 1.e10);
}
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
-
//======================================================================
-//== On echantillonne sur le Domain de la Curve NbPts Points
+//== On echantillonne sur le Domain de la Curve NbPts Points
//== a parametres constants.
-//==
-//== On estime la fleche maximum en prenant la distance maxi entre la
-//== droite Curve.Value(X(i))-->Curve.Value(X(i+1))
+//==
+//== On estime la fleche maximum en prenant la distance maxi entre la
+//== droite Curve.Value(X(i))-->Curve.Value(X(i+1))
//== et le point Curve.Value(X(i+1/2))
//======================================================================
-IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C,
- const Standard_Integer tNbPts):
- ThePnts(1,(tNbPts<5)? 5 : tNbPts)
-{
- Standard_Integer NbPts = (tNbPts<5)? 5 : tNbPts;
- NbPntIn = NbPts;
- Binf = TheCurveTool::FirstParameter(C);
- Bsup = TheCurveTool::LastParameter(C);
- Init(C);
+IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C, const Standard_Integer tNbPts)
+ : ThePnts(1, (tNbPts < 5) ? 5 : tNbPts)
+{
+ Standard_Integer NbPts = (tNbPts < 5) ? 5 : tNbPts;
+ NbPntIn = NbPts;
+ Binf = TheCurveTool::FirstParameter(C);
+ Bsup = TheCurveTool::LastParameter(C);
+ Init(C);
}
-
-
IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C,
- const Standard_Real U1,
- const Standard_Real U2,
- const Standard_Integer tNbPts):
- ThePnts(1,(tNbPts<5)? 5 : tNbPts) , Binf(U1) , Bsup(U2)
-{
-
-
- Standard_Integer NbPts = (tNbPts<5)? 5 : tNbPts;
- NbPntIn = NbPts;
+ const Standard_Real U1,
+ const Standard_Real U2,
+ const Standard_Integer tNbPts)
+ : ThePnts(1, (tNbPts < 5) ? 5 : tNbPts),
+ Binf(U1),
+ Bsup(U2)
+{
+
+ Standard_Integer NbPts = (tNbPts < 5) ? 5 : tNbPts;
+ NbPntIn = NbPts;
Init(C);
}
//=================================================================================================
+IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C,
+ const TColStd_Array1OfReal& Upars)
+ : ThePnts(1, Upars.Length()),
+ Binf(Upars(Upars.Lower())),
+ Bsup(Upars(Upars.Upper()))
+{
-IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C,
- const TColStd_Array1OfReal& Upars):
- ThePnts(1,Upars.Length()) , Binf(Upars(Upars.Lower())) , Bsup(Upars(Upars.Upper()))
-{
-
- //ddout << "IntCurveSurface_Polygon::IntCurveSurface_Polygon" << endl;
+ // ddout << "IntCurveSurface_Polygon::IntCurveSurface_Polygon" << endl;
Standard_Integer NbPts = Upars.Length();
- //ddout << "NbPts :" << NbPts << endl;
+ // ddout << "NbPts :" << NbPts << endl;
NbPntIn = NbPts;
Init(C, Upars);
}
+void IntCurveSurface_Polygon::Init(const TheCurve& C)
+{
-void IntCurveSurface_Polygon::Init(const TheCurve& C) {
-
- Standard_Real u=Binf;
- Standard_Real u1=Bsup;
- Standard_Real du=(u1-u)/(Standard_Real)(NbPntIn-1);
- Standard_Integer i=1;
- gp_Pnt P;
- do {
- TheCurveTool::D0(C,u,P);
+ Standard_Real u = Binf;
+ Standard_Real u1 = Bsup;
+ Standard_Real du = (u1 - u) / (Standard_Real)(NbPntIn - 1);
+ Standard_Integer i = 1;
+ gp_Pnt P;
+ do
+ {
+ TheCurveTool::D0(C, u, P);
TheBnd.Add(P);
- ThePnts.SetValue(i,P);
- u+=du;
+ ThePnts.SetValue(i, P);
+ u += du;
i++;
- }
- while(i<=NbPntIn);
-
+ } while (i <= NbPntIn);
//-----------------------------------------------------
//--- Calcul d un majorant de fleche approche
//---
TheDeflection = 0.0;
- if(NbPntIn>3) {
-
- i=1;
- u=Binf;
- u+=du * 0.5;
-
- do {
- gp_Pnt Pm=TheCurveTool::Value(C,u);
- gp_Pnt P1=ThePnts.Value(i);
- gp_Pnt P2=ThePnts.Value(i+1);
- gp_Lin L(P1,gp_Dir(gp_Vec(P1,P2)));
- Standard_Real t=L.Distance(Pm);
-
- if(t>TheDeflection) {
- TheDeflection = t;
+ if (NbPntIn > 3)
+ {
+
+ i = 1;
+ u = Binf;
+ u += du * 0.5;
+
+ do
+ {
+ gp_Pnt Pm = TheCurveTool::Value(C, u);
+ gp_Pnt P1 = ThePnts.Value(i);
+ gp_Pnt P2 = ThePnts.Value(i + 1);
+ gp_Lin L(P1, gp_Dir(gp_Vec(P1, P2)));
+ Standard_Real t = L.Distance(Pm);
+
+ if (t > TheDeflection)
+ {
+ TheDeflection = t;
}
- u+=du;
+ u += du;
i++;
- }
- while(i<NbPntIn);
-
- TheBnd.Enlarge(1.5*TheDeflection);
+ } while (i < NbPntIn);
+
+ TheBnd.Enlarge(1.5 * TheDeflection);
}
- else {
+ else
+ {
TheBnd.Enlarge(1e-10);
}
ClosedPolygon = Standard_False;
//=================================================================================================
+void IntCurveSurface_Polygon::Init(const TheCurve& C, const TColStd_Array1OfReal& Upars)
+{
-void IntCurveSurface_Polygon::Init(const TheCurve& C,
- const TColStd_Array1OfReal& Upars) {
-
- //ddout << "IntCurveSurface_Polygon::Init" << endl;
- Standard_Real u=Binf;
- Standard_Integer i=1, i0 = Upars.Lower()-1;
- gp_Pnt P;
+ // ddout << "IntCurveSurface_Polygon::Init" << endl;
+ Standard_Real u = Binf;
+ Standard_Integer i = 1, i0 = Upars.Lower() - 1;
+ gp_Pnt P;
myParams = new TColStd_HArray1OfReal(1, Upars.Length());
- do {
- //ddout << "-------------Parameter : " << i << " " << Upars(i+i0) << endl;
- myParams->SetValue(i, Upars(i+i0));
- TheCurveTool::D0(C,Upars(i+i0),P);
- //ddout << "P : " << P.X() << " " << P.Y() << " " << P.Z() << endl;
+ do
+ {
+ // ddout << "-------------Parameter : " << i << " " << Upars(i+i0) << endl;
+ myParams->SetValue(i, Upars(i + i0));
+ TheCurveTool::D0(C, Upars(i + i0), P);
+ // ddout << "P : " << P.X() << " " << P.Y() << " " << P.Z() << endl;
TheBnd.Add(P);
- ThePnts.SetValue(i,P);
+ ThePnts.SetValue(i, P);
i++;
- }
- while(i<=NbPntIn);
-
+ } while (i <= NbPntIn);
//-----------------------------------------------------
//--- Calcul d un majorant de fleche approche
//---
TheDeflection = 0.0;
- if(NbPntIn>3) {
-
- i=1;
- //ddout << "Deflection estimation" << endl;
- do {
- u = 0.5*(Upars(i0+i)+Upars(i0+i+1));
- //ddout << "===========Parameter : " << i << " " << u << endl;
- gp_Pnt Pm=TheCurveTool::Value(C,u);
- //ddout << "Pm : " << Pm.X() << " " << Pm.Y() << " " << Pm.Z() << endl;
- gp_Pnt P1=ThePnts.Value(i);
- //ddout << "P1 : " << P1.X() << " " << P1.Y() << " " << P1.Z() << endl;
- gp_Pnt P2=ThePnts.Value(i+1);
- //ddout << "P2 : " << P2.X() << " " << P2.Y() << " " << P2.Z() << endl;
- gp_Lin L(P1,gp_Dir(gp_Vec(P1,P2)));
- Standard_Real t=L.Distance(Pm);
- //ddout << "Distance " << t << endl;
- if(t>TheDeflection) {
- TheDeflection = t;
+ if (NbPntIn > 3)
+ {
+
+ i = 1;
+ // ddout << "Deflection estimation" << endl;
+ do
+ {
+ u = 0.5 * (Upars(i0 + i) + Upars(i0 + i + 1));
+ // ddout << "===========Parameter : " << i << " " << u << endl;
+ gp_Pnt Pm = TheCurveTool::Value(C, u);
+ // ddout << "Pm : " << Pm.X() << " " << Pm.Y() << " " << Pm.Z() << endl;
+ gp_Pnt P1 = ThePnts.Value(i);
+ // ddout << "P1 : " << P1.X() << " " << P1.Y() << " " << P1.Z() << endl;
+ gp_Pnt P2 = ThePnts.Value(i + 1);
+ // ddout << "P2 : " << P2.X() << " " << P2.Y() << " " << P2.Z() << endl;
+ gp_Lin L(P1, gp_Dir(gp_Vec(P1, P2)));
+ Standard_Real t = L.Distance(Pm);
+ // ddout << "Distance " << t << endl;
+ if (t > TheDeflection)
+ {
+ TheDeflection = t;
}
i++;
- }
- while(i<NbPntIn);
- //ddout << " TheDeflection = " << TheDeflection << endl;
- TheBnd.Enlarge(1.5*TheDeflection);
+ } while (i < NbPntIn);
+ // ddout << " TheDeflection = " << TheDeflection << endl;
+ TheBnd.Enlarge(1.5 * TheDeflection);
}
- else {
+ else
+ {
TheBnd.Enlarge(1e-10);
}
ClosedPolygon = Standard_False;
}
+//=================================================================================================
-//======================================================================
Standard_Real IntCurveSurface_Polygon::ApproxParamOnCurve(const Standard_Integer TheIndex,
- const Standard_Real TheParamOnLine) const
+ const Standard_Real TheParamOnLine) const
{
- //ddout << "IntCurveSurface_Polygon::ApproxParamOnCurve" << endl;
- if(TheParamOnLine < 0.0 || TheParamOnLine >1.0) {
+ // ddout << "IntCurveSurface_Polygon::ApproxParamOnCurve" << endl;
+ if (TheParamOnLine < 0.0 || TheParamOnLine > 1.0)
+ {
#ifdef OCCT_DEBUG
- std::cout<<" ParamOnLine = "<<TheParamOnLine<<" avec Index = "
- <<TheIndex<<" dans IntCurveSurface_Polygon::ApproxParamOnCurve"<<std::endl;
+ std::cout << " ParamOnLine = " << TheParamOnLine << " avec Index = " << TheIndex
+ << " dans IntCurveSurface_Polygon::ApproxParamOnCurve" << std::endl;
#endif
- return(Binf+(TheParamOnLine*(Bsup-Binf))/(Standard_Real)(NbPntIn-1));
+ return (Binf + (TheParamOnLine * (Bsup - Binf)) / (Standard_Real)(NbPntIn - 1));
}
- Standard_Integer Index = TheIndex;
+ Standard_Integer Index = TheIndex;
Standard_Real ParamOnLine = TheParamOnLine;
#ifdef OCCT_DEBUG
- if (Index > NbPntIn) {
- std::cout << "OutOfRange Polygon::ApproxParamOnCurve " <<std::endl;
+ if (Index > NbPntIn)
+ {
+ std::cout << "OutOfRange Polygon::ApproxParamOnCurve " << std::endl;
}
#endif
- if((Index == NbPntIn) && (ParamOnLine == 0.0)) {
- Index--; ParamOnLine=1.0;
+ if ((Index == NbPntIn) && (ParamOnLine == 0.0))
+ {
+ Index--;
+ ParamOnLine = 1.0;
}
Standard_Real du, u;
if (myParams.IsNull())
- {
- du = (Bsup-Binf)/(Standard_Real)(NbPntIn-1);
- u = Binf + du * (Standard_Real)(Index-1);
- }
+ {
+ du = (Bsup - Binf) / (Standard_Real)(NbPntIn - 1);
+ u = Binf + du * (Standard_Real)(Index - 1);
+ }
else
- {
- du = myParams->Value(Index+1) - myParams->Value(Index);
- u = myParams->Value(Index);
- }
+ {
+ du = myParams->Value(Index + 1) - myParams->Value(Index);
+ u = myParams->Value(Index);
+ }
u += du * ParamOnLine;
return (u);
}
-
-//======================================================================
-void IntCurveSurface_Polygon::Dump(void) const {
+//=================================================================================================
+
+void IntCurveSurface_Polygon::Dump(void) const
+{
#if 0
static Standard_Integer Compteur=0;
char tamp[100];
fclose(fp);
#endif
}
+
//======================================================================
//======================================================================
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-void IntCurveSurface_PolygonTool::Dump(const ThePolygon& L) {
+void IntCurveSurface_PolygonTool::Dump(const ThePolygon& L)
+{
- static Standard_Integer num=0;
+ static Standard_Integer num = 0;
num++;
Standard_Integer nbs = IntCurveSurface_PolygonTool::NbSegments(L);
- std::cout<<"\npol2d "<<num<<" "<<nbs<<std::endl;
- std::cout<<"Deflection "<<IntCurveSurface_PolygonTool::DeflectionOverEstimation(L)<<std::endl;
-
- for(Standard_Integer i=1;i<=nbs;i++) {
- gp_Pnt P(IntCurveSurface_PolygonTool::BeginOfSeg(L,i));
- std::cout<<"pnt "<<num<<" "<<i<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<std::endl;
+ std::cout << "\npol2d " << num << " " << nbs << std::endl;
+ std::cout << "Deflection " << IntCurveSurface_PolygonTool::DeflectionOverEstimation(L)
+ << std::endl;
+
+ for (Standard_Integer i = 1; i <= nbs; i++)
+ {
+ gp_Pnt P(IntCurveSurface_PolygonTool::BeginOfSeg(L, i));
+ std::cout << "pnt " << num << " " << i << " " << P.X() << " " << P.Y() << " " << P.Z()
+ << std::endl;
}
- gp_Pnt PF(IntCurveSurface_PolygonTool::EndOfSeg(L,nbs));
- std::cout<<"pnt "<<num<<" "<<nbs<<" "<< PF.X()<<" "<<PF.Y()<<" "<<PF.Z()<<std::endl;
+ gp_Pnt PF(IntCurveSurface_PolygonTool::EndOfSeg(L, nbs));
+ std::cout << "pnt " << num << " " << nbs << " " << PF.X() << " " << PF.Y() << " " << PF.Z()
+ << std::endl;
}
-
-
#define CHECKBOUNDS 0
-
//-----------------------------------------------------
#define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
-
//=================================================================================================
-IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
- const Standard_Integer nbdU,
- const Standard_Integer nbdV,
- const Standard_Real u1,
- const Standard_Real v1,
- const Standard_Real u2,
- const Standard_Real v2)
- : nbdeltaU((nbdU<3)? 3 : nbdU),
- nbdeltaV((nbdV<3)? 3 : nbdV),
- TheDeflection(Epsilon(100.)),
- C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
+IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron(const ThePSurface& Surface,
+ const Standard_Integer nbdU,
+ const Standard_Integer nbdV,
+ const Standard_Real u1,
+ const Standard_Real v1,
+ const Standard_Real u2,
+ const Standard_Real v2)
+ : nbdeltaU((nbdU < 3) ? 3 : nbdU),
+ nbdeltaV((nbdV < 3) ? 3 : nbdV),
+ TheDeflection(Epsilon(100.)),
+ C_MyPnts(NULL),
+ C_MyU(NULL),
+ C_MyV(NULL),
+ C_MyIsOnBounds(NULL)
{
- Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
- gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
- Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
- Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
-
-// Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
- Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
-
- C_MyIsOnBounds = (void *)CMyIsOnBounds;
-// Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
- Init(Surface,u1,v1,u2,v2);
+ Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
+ gp_Pnt* CMyPnts = new gp_Pnt[t];
+ C_MyPnts = (void*)CMyPnts;
+ Standard_Real* CMyU = new Standard_Real[t];
+ C_MyU = (void*)CMyU;
+ Standard_Real* CMyV = new Standard_Real[t];
+ C_MyV = (void*)CMyV;
+
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
+ Standard_Boolean* CMyIsOnBounds = new Standard_Boolean[t];
+
+ C_MyIsOnBounds = (void*)CMyIsOnBounds;
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
+ Init(Surface, u1, v1, u2, v2);
}
//=================================================================================================
-IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron (const ThePSurface& Surface,
- const TColStd_Array1OfReal& Upars,
- const TColStd_Array1OfReal& Vpars)
- : nbdeltaU(Upars.Length()-1),
- nbdeltaV(Vpars.Length()-1),
+IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron(const ThePSurface& Surface,
+ const TColStd_Array1OfReal& Upars,
+ const TColStd_Array1OfReal& Vpars)
+ : nbdeltaU(Upars.Length() - 1),
+ nbdeltaV(Vpars.Length() - 1),
TheDeflection(Epsilon(100.)),
- C_MyPnts(NULL),C_MyU(NULL),C_MyV(NULL),C_MyIsOnBounds(NULL)
+ C_MyPnts(NULL),
+ C_MyU(NULL),
+ C_MyV(NULL),
+ C_MyIsOnBounds(NULL)
{
- Standard_Integer t = (nbdeltaU+1)*(nbdeltaV+1)+1;
- gp_Pnt *CMyPnts = new gp_Pnt[t]; C_MyPnts = (void *)CMyPnts;
- Standard_Real *CMyU = new Standard_Real[t]; C_MyU = (void *)CMyU;
- Standard_Real *CMyV = new Standard_Real[t]; C_MyV = (void *)CMyV;
-
-// Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
- Standard_Boolean *CMyIsOnBounds = new Standard_Boolean[t];
-
- C_MyIsOnBounds = (void *)CMyIsOnBounds;
-// Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
+ Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
+ gp_Pnt* CMyPnts = new gp_Pnt[t];
+ C_MyPnts = (void*)CMyPnts;
+ Standard_Real* CMyU = new Standard_Real[t];
+ C_MyU = (void*)CMyU;
+ Standard_Real* CMyV = new Standard_Real[t];
+ C_MyV = (void*)CMyV;
+
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
+ Standard_Boolean* CMyIsOnBounds = new Standard_Boolean[t];
+
+ C_MyIsOnBounds = (void*)CMyIsOnBounds;
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
Init(Surface, Upars, Vpars);
}
-
-void IntCurveSurface_Polyhedron::Destroy() {
+void IntCurveSurface_Polyhedron::Destroy()
+{
//-- printf("\n IntCurveSurface_Polyhedron::Destroy\n");
- gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts; if(C_MyPnts) delete [] CMyPnts;
- Standard_Real *CMyU = (Standard_Real *)C_MyU; if(C_MyU) delete [] CMyU;
- Standard_Real *CMyV = (Standard_Real *)C_MyV; if(C_MyV) delete [] CMyV;
-
-// Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
- Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
-
- if(C_MyIsOnBounds) delete [] CMyIsOnBounds;
-// Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
-
- C_MyPnts=C_MyU=C_MyV=C_MyIsOnBounds=NULL;
+ gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
+ if (C_MyPnts)
+ delete[] CMyPnts;
+ Standard_Real* CMyU = (Standard_Real*)C_MyU;
+ if (C_MyU)
+ delete[] CMyU;
+ Standard_Real* CMyV = (Standard_Real*)C_MyV;
+ if (C_MyV)
+ delete[] CMyV;
+
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
+ Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
+
+ if (C_MyIsOnBounds)
+ delete[] CMyIsOnBounds;
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
+
+ C_MyPnts = C_MyU = C_MyV = C_MyIsOnBounds = NULL;
}
//=================================================================================================
-void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
- const Standard_Real U0,
- const Standard_Real V0,
- const Standard_Real U1,
- const Standard_Real V1) {
- //#define DEBUGDUMP
- Standard_Integer i1,i2;
- Standard_Real U,V;
- Standard_Real U1mU0sNbdeltaU = (U1-U0)/(Standard_Real)nbdeltaU;
- Standard_Real V1mV0sNbdeltaV = (V1-V0)/(Standard_Real)nbdeltaV;
- gp_Pnt TP;
- Standard_Integer Index=1;
+void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
+ const Standard_Real U0,
+ const Standard_Real V0,
+ const Standard_Real U1,
+ const Standard_Real V1)
+{
+ // #define DEBUGDUMP
+ Standard_Integer i1, i2;
+ Standard_Real U, V;
+ Standard_Real U1mU0sNbdeltaU = (U1 - U0) / (Standard_Real)nbdeltaU;
+ Standard_Real V1mV0sNbdeltaV = (V1 - V0) / (Standard_Real)nbdeltaV;
+ gp_Pnt TP;
+ Standard_Integer Index = 1;
//-- --------------------------------------------------
//-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
//-- V est la colonne
- //-- U est la ligne
+ //-- U est la ligne
//-- --------------------------------------------------
- gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
- Standard_Real *CMyU = (Standard_Real *)C_MyU;
- Standard_Real *CMyV = (Standard_Real *)C_MyV;
- Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
-
- for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U+= U1mU0sNbdeltaU) {
- for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V+= V1mV0sNbdeltaV ) {
- ThePSurfaceTool::D0(Surface,U,V,TP);
+ gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
+ Standard_Real* CMyU = (Standard_Real*)C_MyU;
+ Standard_Real* CMyV = (Standard_Real*)C_MyV;
+ Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
+
+ for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U += U1mU0sNbdeltaU)
+ {
+ for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V += V1mV0sNbdeltaV)
+ {
+ ThePSurfaceTool::D0(Surface, U, V, TP);
//-- Point(TP,i1, i2,U,V);
CMyPnts[Index] = TP;
CMyU[Index] = U;
CMyV[Index] = V;
-// Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
- CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
- i2 == 0 || i2 == nbdeltaV);
-// Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
+ CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU || i2 == 0 || i2 == nbdeltaV);
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
TheBnd.Add(TP);
Index++;
}
}
//-- Calcul de la deflection Triangle <-> Point milieu
- Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
- for (i1=1; i1<=nbtriangles; i1++) {
- Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
- if(tol1>tol) tol=tol1;
+ Standard_Real tol = 0.0;
+ Standard_Integer nbtriangles = NbTriangles();
+ for (i1 = 1; i1 <= nbtriangles; i1++)
+ {
+ Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
+ if (tol1 > tol)
+ tol = tol1;
}
//-- Calcul de la deflection Bord <-> Point milieu
-
- DeflectionOverEstimation(tol*1.2);
+ DeflectionOverEstimation(tol * 1.2);
FillBounding();
-// Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
+ // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
Standard_Real aDeflection;
TheBorderDeflection = RealFirst();
-// Compute the deflection on the lower bound (U-isoline) of the surface.
+ // Compute the deflection on the lower bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Compute the deflection on the upper bound (U-isoline) of the surface.
+ // Compute the deflection on the upper bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Compute the deflection on the lower bound (V-isoline) of the surface.
+ // Compute the deflection on the lower bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Compute the deflection on the upper bound (V-isoline) of the surface.
+ // Compute the deflection on the upper bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
+ // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
- #ifdef OCCT_DEBUG_DUMP
- Dump();
- #endif
+#ifdef OCCT_DEBUG_DUMP
+ Dump();
+#endif
}
+
//=================================================================================================
-void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
- const TColStd_Array1OfReal& Upars,
- const TColStd_Array1OfReal& Vpars) {
- //#define DEBUGDUMP
- Standard_Integer i1,i2;
- Standard_Real U,V;
- gp_Pnt TP;
- Standard_Integer Index=1;
+void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
+ const TColStd_Array1OfReal& Upars,
+ const TColStd_Array1OfReal& Vpars)
+{
+ // #define DEBUGDUMP
+ Standard_Integer i1, i2;
+ Standard_Real U, V;
+ gp_Pnt TP;
+ Standard_Integer Index = 1;
//-- --------------------------------------------------
//-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
//-- V est la colonne
- //-- U est la ligne
+ //-- U est la ligne
//-- --------------------------------------------------
- gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
- Standard_Real *CMyU = (Standard_Real *)C_MyU;
- Standard_Real *CMyV = (Standard_Real *)C_MyV;
- Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
- Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
-
- for (i1 = 0; i1 <= nbdeltaU; i1++) {
- U = Upars(i1+i0);
- for (i2 = 0; i2 <= nbdeltaV; i2++) {
- V = Vpars(i2+j0);
- ThePSurfaceTool::D0(Surface,U,V,TP);
+ gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
+ Standard_Real* CMyU = (Standard_Real*)C_MyU;
+ Standard_Real* CMyV = (Standard_Real*)C_MyV;
+ Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
+ Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
+
+ for (i1 = 0; i1 <= nbdeltaU; i1++)
+ {
+ U = Upars(i1 + i0);
+ for (i2 = 0; i2 <= nbdeltaV; i2++)
+ {
+ V = Vpars(i2 + j0);
+ ThePSurfaceTool::D0(Surface, U, V, TP);
//-- Point(TP,i1, i2,U,V);
CMyPnts[Index] = TP;
CMyU[Index] = U;
CMyV[Index] = V;
-// Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
- CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU ||
- i2 == 0 || i2 == nbdeltaV);
-// Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
+ CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU || i2 == 0 || i2 == nbdeltaV);
+ // Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
TheBnd.Add(TP);
Index++;
}
}
//-- Calcul de la deflection Triangle <-> Point milieu
- Standard_Real tol=0.0; Standard_Integer nbtriangles = NbTriangles();
- for (i1=1; i1<=nbtriangles; i1++) {
- Standard_Real tol1 = DeflectionOnTriangle(Surface,i1);
- if(tol1>tol) tol=tol1;
+ Standard_Real tol = 0.0;
+ Standard_Integer nbtriangles = NbTriangles();
+ for (i1 = 1; i1 <= nbtriangles; i1++)
+ {
+ Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
+ if (tol1 > tol)
+ tol = tol1;
}
//-- Calcul de la deflection Bord <-> Point milieu
-
- DeflectionOverEstimation(tol*1.2);
+ DeflectionOverEstimation(tol * 1.2);
FillBounding();
-// Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
+ // Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
Standard_Real aDeflection;
TheBorderDeflection = RealFirst();
- Standard_Real U0 = Upars(i0);
- Standard_Real V0 = Vpars(j0);
- Standard_Real U1 = Upars(Upars.Upper());
- Standard_Real V1 = Vpars(Vpars.Upper());
+ Standard_Real U0 = Upars(i0);
+ Standard_Real V0 = Vpars(j0);
+ Standard_Real U1 = Upars(Upars.Upper());
+ Standard_Real V1 = Vpars(Vpars.Upper());
-// Compute the deflection on the lower bound (U-isoline) of the surface.
+ // Compute the deflection on the lower bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Compute the deflection on the upper bound (U-isoline) of the surface.
+ // Compute the deflection on the upper bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Compute the deflection on the lower bound (V-isoline) of the surface.
+ // Compute the deflection on the lower bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Compute the deflection on the upper bound (V-isoline) of the surface.
+ // Compute the deflection on the upper bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
-// Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
+ // Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
- #ifdef OCCT_DEBUG_DUMP
- Dump();
- #endif
+#ifdef OCCT_DEBUG_DUMP
+ Dump();
+#endif
}
+
//=================================================================================================
-Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle (const ThePSurface& Surface,
- const Standard_Integer Triang) const
+Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle(const ThePSurface& Surface,
+ const Standard_Integer Triang) const
{
- Standard_Integer i1,i2,i3;
- Triangle(Triang,i1,i2,i3);
+ Standard_Integer i1, i2, i3;
+ Triangle(Triang, i1, i2, i3);
//-- Calcul de l equation du plan
- Standard_Real u1,v1,u2,v2,u3,v3;
- gp_Pnt P1,P2,P3;
- P1 = Point(i1,u1,v1);
- P2 = Point(i2,u2,v2);
- P3 = Point(i3,u3,v3);
- if(P1.SquareDistance(P2)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
- if(P1.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
- if(P2.SquareDistance(P3)<=LONGUEUR_MINI_EDGE_TRIANGLE) return(0);
- gp_XYZ XYZ1=P2.XYZ()-P1.XYZ();
- gp_XYZ XYZ2=P3.XYZ()-P2.XYZ();
- gp_XYZ XYZ3=P1.XYZ()-P3.XYZ();
- gp_Vec NormalVector((XYZ1^XYZ2)+(XYZ2^XYZ3)+(XYZ3^XYZ1));
+ Standard_Real u1, v1, u2, v2, u3, v3;
+ gp_Pnt P1, P2, P3;
+ P1 = Point(i1, u1, v1);
+ P2 = Point(i2, u2, v2);
+ P3 = Point(i3, u3, v3);
+ if (P1.SquareDistance(P2) <= LONGUEUR_MINI_EDGE_TRIANGLE)
+ return (0);
+ if (P1.SquareDistance(P3) <= LONGUEUR_MINI_EDGE_TRIANGLE)
+ return (0);
+ if (P2.SquareDistance(P3) <= LONGUEUR_MINI_EDGE_TRIANGLE)
+ return (0);
+ gp_XYZ XYZ1 = P2.XYZ() - P1.XYZ();
+ gp_XYZ XYZ2 = P3.XYZ() - P2.XYZ();
+ gp_XYZ XYZ3 = P1.XYZ() - P3.XYZ();
+ gp_Vec NormalVector((XYZ1 ^ XYZ2) + (XYZ2 ^ XYZ3) + (XYZ3 ^ XYZ1));
Standard_Real aNormLen = NormalVector.Magnitude();
- if (aNormLen < gp::Resolution()) {
+ if (aNormLen < gp::Resolution())
+ {
return 0.;
}
//
NormalVector.Divide(aNormLen);
//-- Standard_Real PolarDistance = NormalVector * P1.XYZ();
//-- Calcul du point u,v au centre du triangle
- Standard_Real u = (u1+u2+u3)/3.0;
- Standard_Real v = (v1+v2+v3)/3.0;
- gp_Pnt P = ThePSurfaceTool::Value(Surface,u,v);
- gp_Vec P1P(P1,P);
- return(Abs(P1P.Dot(NormalVector)));
+ Standard_Real u = (u1 + u2 + u3) / 3.0;
+ Standard_Real v = (v1 + v2 + v3) / 3.0;
+ gp_Pnt P = ThePSurfaceTool::Value(Surface, u, v);
+ gp_Vec P1P(P1, P);
+ return (Abs(P1P.Dot(NormalVector)));
}
+
//=================================================================================================
-void IntCurveSurface_Polyhedron::Parameters( const Standard_Integer Index
- ,Standard_Real &U
- ,Standard_Real &V) const
+void IntCurveSurface_Polyhedron::Parameters(const Standard_Integer Index,
+ Standard_Real& U,
+ Standard_Real& V) const
{
-#if CHECKBOUNDS
- if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
+#if CHECKBOUNDS
+ if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
+ {
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
- Standard_Real *CMyU = (Standard_Real *)C_MyU;
- U = CMyU[Index];
- Standard_Real *CMyV = (Standard_Real *)C_MyV;
- V = CMyV[Index];
+ Standard_Real* CMyU = (Standard_Real*)C_MyU;
+ U = CMyU[Index];
+ Standard_Real* CMyV = (Standard_Real*)C_MyV;
+ V = CMyV[Index];
}
+
//=================================================================================================
void IntCurveSurface_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
{
- if(flec<0.0001) {
- TheDeflection=0.0001;
+ if (flec < 0.0001)
+ {
+ TheDeflection = 0.0001;
TheBnd.Enlarge(0.0001);
}
- else {
- TheDeflection=flec;
+ else
+ {
+ TheDeflection = flec;
TheBnd.Enlarge(flec);
- }
+ }
}
+
//=================================================================================================
Standard_Real IntCurveSurface_Polyhedron::DeflectionOverEstimation() const
{
return TheDeflection;
}
+
//=================================================================================================
const Bnd_Box& IntCurveSurface_Polyhedron::Bounding() const
{
return TheBnd;
}
+
//=================================================================================================
void IntCurveSurface_Polyhedron::FillBounding()
{
- TheComponentsBnd=new Bnd_HArray1OfBox(1, NbTriangles());
- Bnd_Box Boite;
+ TheComponentsBnd = new Bnd_HArray1OfBox(1, NbTriangles());
+ Bnd_Box Boite;
Standard_Integer np1, np2, np3;
Standard_Integer nbtriangles = NbTriangles();
- for (Standard_Integer iTri=1; iTri<=nbtriangles; iTri++) {
+ for (Standard_Integer iTri = 1; iTri <= nbtriangles; iTri++)
+ {
Triangle(iTri, np1, np2, np3);
gp_Pnt p1(Point(np1));
gp_Pnt p2(Point(np2));
gp_Pnt p3(Point(np3));
Boite.SetVoid();
- if(p1.SquareDistance(p2)>LONGUEUR_MINI_EDGE_TRIANGLE) {
- if(p1.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
- if(p2.SquareDistance(p3)>LONGUEUR_MINI_EDGE_TRIANGLE) {
- Boite.Add(p1);
- Boite.Add(p2);
- Boite.Add(p3);
- Boite.Enlarge(TheDeflection);
- }
+ if (p1.SquareDistance(p2) > LONGUEUR_MINI_EDGE_TRIANGLE)
+ {
+ if (p1.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
+ {
+ if (p2.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
+ {
+ Boite.Add(p1);
+ Boite.Add(p2);
+ Boite.Add(p3);
+ Boite.Enlarge(TheDeflection);
+ }
}
}
Boite.Enlarge(TheDeflection);
- TheComponentsBnd->SetValue(iTri,Boite);
+ TheComponentsBnd->SetValue(iTri, Boite);
}
}
+
//=================================================================================================
-const Handle(Bnd_HArray1OfBox)&
- IntCurveSurface_Polyhedron::ComponentsBounding() const
+const Handle(Bnd_HArray1OfBox)& IntCurveSurface_Polyhedron::ComponentsBounding() const
{
- return TheComponentsBnd;
+ return TheComponentsBnd;
}
+
//=================================================================================================
-Standard_Integer IntCurveSurface_Polyhedron::NbTriangles () const
+Standard_Integer IntCurveSurface_Polyhedron::NbTriangles() const
{
- return nbdeltaU*nbdeltaV*2;
+ return nbdeltaU * nbdeltaV * 2;
}
+
//=================================================================================================
-Standard_Integer IntCurveSurface_Polyhedron::NbPoints () const
+Standard_Integer IntCurveSurface_Polyhedron::NbPoints() const
{
- return (nbdeltaU+1)*(nbdeltaV+1);
+ return (nbdeltaU + 1) * (nbdeltaV + 1);
}
+
//=================================================================================================
-Standard_Integer IntCurveSurface_Polyhedron::TriConnex
- (const Standard_Integer Triang,
- const Standard_Integer Pivot,
- const Standard_Integer Pedge,
- Standard_Integer& TriCon,
- Standard_Integer& OtherP) const
+Standard_Integer IntCurveSurface_Polyhedron::TriConnex(const Standard_Integer Triang,
+ const Standard_Integer Pivot,
+ const Standard_Integer Pedge,
+ Standard_Integer& TriCon,
+ Standard_Integer& OtherP) const
{
- Standard_Integer Pivotm1 = Pivot-1;
- Standard_Integer nbdeltaVp1 = nbdeltaV+1;
+ Standard_Integer Pivotm1 = Pivot - 1;
+ Standard_Integer nbdeltaVp1 = nbdeltaV + 1;
Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
-// Pivot position in the MaTriangle :
- Standard_Integer ligP = Pivotm1/nbdeltaVp1;
+ // Pivot position in the MaTriangle :
+ Standard_Integer ligP = Pivotm1 / nbdeltaVp1;
Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
-// Point sur Edge position in the MaTriangle and edge typ :
- Standard_Integer ligE =0, colE =0, typE =0;
- if (Pedge!=0) {
- ligE= (Pedge-1)/nbdeltaVp1;
- colE= (Pedge-1) - (ligE * nbdeltaVp1);
- // Horizontal
- if (ligP==ligE) typE=1;
- // Vertical
- else if (colP==colE) typE=2;
- // Oblique
- else typE=3;
+ // Point sur Edge position in the MaTriangle and edge typ :
+ Standard_Integer ligE = 0, colE = 0, typE = 0;
+ if (Pedge != 0)
+ {
+ ligE = (Pedge - 1) / nbdeltaVp1;
+ colE = (Pedge - 1) - (ligE * nbdeltaVp1);
+ // Horizontal
+ if (ligP == ligE)
+ typE = 1;
+ // Vertical
+ else if (colP == colE)
+ typE = 2;
+ // Oblique
+ else
+ typE = 3;
}
- else {
- typE=0;
+ else
+ {
+ typE = 0;
}
-// Triangle position General case :
-
- Standard_Integer linT =0, colT =0;
- Standard_Integer linO =0, colO =0;
- Standard_Integer t =0, tt =0;
-
- if (Triang!=0) {
- t = (Triang-1)/(nbdeltaVm2);
- tt= (Triang-1)-t*nbdeltaVm2;
- linT= 1+t;
- colT= 1+tt;
- if (typE==0) {
- if (ligP==linT) {
- ligE=ligP-1;
- colE=colP-1;
- typE=3;
+ // Triangle position General case :
+
+ Standard_Integer linT = 0, colT = 0;
+ Standard_Integer linO = 0, colO = 0;
+ Standard_Integer t = 0, tt = 0;
+
+ if (Triang != 0)
+ {
+ t = (Triang - 1) / (nbdeltaVm2);
+ tt = (Triang - 1) - t * nbdeltaVm2;
+ linT = 1 + t;
+ colT = 1 + tt;
+ if (typE == 0)
+ {
+ if (ligP == linT)
+ {
+ ligE = ligP - 1;
+ colE = colP - 1;
+ typE = 3;
}
- else {
- if (colT==ligP+ligP) {
- ligE=ligP;
- colE=colP-1;
- typE=1;
- }
- else {
- ligE=ligP+1;
- colE=colP+1;
- typE=3;
- }
+ else
+ {
+ if (colT == ligP + ligP)
+ {
+ ligE = ligP;
+ colE = colP - 1;
+ typE = 1;
+ }
+ else
+ {
+ ligE = ligP + 1;
+ colE = colP + 1;
+ typE = 3;
+ }
}
}
- switch (typE) {
- case 1: // Horizontal
- if (linT==ligP) {
- linT++;
- linO=ligP+1;
- colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
- }
- else {
- linT--;
- linO=ligP-1;
- colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
- }
- break;
- case 2: // Vertical
- if (colT==(colP+colP)) {
- colT++;
- linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
- colO=colP+1;
- }
- else {
- colT--;
- linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
- colO=colP-1;
- }
- break;
- case 3: // Oblique
- if ((colT&1)==0) {
- colT--;
- linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
- colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
- }
- else {
- colT++;
- linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
- colO=(colP>colE)? colP : colE; //--colO=Max(colP, colE);
- }
- break;
+ switch (typE)
+ {
+ case 1: // Horizontal
+ if (linT == ligP)
+ {
+ linT++;
+ linO = ligP + 1;
+ colO = (colP > colE) ? colP : colE; //--colO=Max(colP, colE);
+ }
+ else
+ {
+ linT--;
+ linO = ligP - 1;
+ colO = (colP < colE) ? colP : colE; //--colO=Min(colP, colE);
+ }
+ break;
+ case 2: // Vertical
+ if (colT == (colP + colP))
+ {
+ colT++;
+ linO = (ligP > ligE) ? ligP : ligE; //--linO=Max(ligP, ligE);
+ colO = colP + 1;
+ }
+ else
+ {
+ colT--;
+ linO = (ligP < ligE) ? ligP : ligE; //--linO=Min(ligP, ligE);
+ colO = colP - 1;
+ }
+ break;
+ case 3: // Oblique
+ if ((colT & 1) == 0)
+ {
+ colT--;
+ linO = (ligP > ligE) ? ligP : ligE; //--linO=Max(ligP, ligE);
+ colO = (colP < colE) ? colP : colE; //--colO=Min(colP, colE);
+ }
+ else
+ {
+ colT++;
+ linO = (ligP < ligE) ? ligP : ligE; //--linO=Min(ligP, ligE);
+ colO = (colP > colE) ? colP : colE; //--colO=Max(colP, colE);
+ }
+ break;
}
}
- else {
+ else
+ {
// Unknown Triangle position :
- if (Pedge==0) {
+ if (Pedge == 0)
+ {
// Unknown edge :
- linT=(1>ligP)? 1 : ligP; //--linT=Max(1, ligP);
- colT=(1>(colP+colP))? 1 : (colP+colP); //--colT=Max(1, colP+colP);
- if (ligP==0) linO=ligP+1;
- else linO=ligP-1;
- colO=colP;
+ linT = (1 > ligP) ? 1 : ligP; //--linT=Max(1, ligP);
+ colT = (1 > (colP + colP)) ? 1 : (colP + colP); //--colT=Max(1, colP+colP);
+ if (ligP == 0)
+ linO = ligP + 1;
+ else
+ linO = ligP - 1;
+ colO = colP;
}
- else {
+ else
+ {
// Known edge We take the left or down connectivity :
- switch (typE) {
- case 1: // Horizontal
- linT=ligP+1;
- colT=(colP>colE)? colP : colE; //--colT=Max(colP,colE);
- colT+=colT;
- linO=ligP+1;
- colO=(colP>colE)? colP : colE; //--colO=Max(colP,colE);
- break;
- case 2: // Vertical
- linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
- colT=colP+colP;
- linO=(ligP<ligE)? ligP : ligE; //--linO=Min(ligP, ligE);
- colO=colP-1;
- break;
- case 3: // Oblique
- linT=(ligP>ligE)? ligP : ligE; //--linT=Max(ligP, ligE);
- colT=colP+colE;
- linO=(ligP>ligE)? ligP : ligE; //--linO=Max(ligP, ligE);
- colO=(colP<colE)? colP : colE; //--colO=Min(colP, colE);
- break;
+ switch (typE)
+ {
+ case 1: // Horizontal
+ linT = ligP + 1;
+ colT = (colP > colE) ? colP : colE; //--colT=Max(colP,colE);
+ colT += colT;
+ linO = ligP + 1;
+ colO = (colP > colE) ? colP : colE; //--colO=Max(colP,colE);
+ break;
+ case 2: // Vertical
+ linT = (ligP > ligE) ? ligP : ligE; //--linT=Max(ligP, ligE);
+ colT = colP + colP;
+ linO = (ligP < ligE) ? ligP : ligE; //--linO=Min(ligP, ligE);
+ colO = colP - 1;
+ break;
+ case 3: // Oblique
+ linT = (ligP > ligE) ? ligP : ligE; //--linT=Max(ligP, ligE);
+ colT = colP + colE;
+ linO = (ligP > ligE) ? ligP : ligE; //--linO=Max(ligP, ligE);
+ colO = (colP < colE) ? colP : colE; //--colO=Min(colP, colE);
+ break;
}
}
}
- TriCon=(linT-1)*nbdeltaVm2 + colT;
+ TriCon = (linT - 1) * nbdeltaVm2 + colT;
- if (linT<1) {
- linO=0;
- colO=colP+colP-colE;
- if (colO<0) {colO=0;linO=1;}
- else if (colO>nbdeltaV) {colO=nbdeltaV;linO=1;}
- TriCon=0;
+ if (linT < 1)
+ {
+ linO = 0;
+ colO = colP + colP - colE;
+ if (colO < 0)
+ {
+ colO = 0;
+ linO = 1;
+ }
+ else if (colO > nbdeltaV)
+ {
+ colO = nbdeltaV;
+ linO = 1;
+ }
+ TriCon = 0;
}
- else if (linT>nbdeltaU) {
- linO=nbdeltaU;
- colO=colP+colP-colE;
- if (colO<0) {colO=0;linO=nbdeltaU-1;}
- else if (colO>nbdeltaV) {colO=nbdeltaV;linO=nbdeltaU-1;}
- TriCon=0;
+ else if (linT > nbdeltaU)
+ {
+ linO = nbdeltaU;
+ colO = colP + colP - colE;
+ if (colO < 0)
+ {
+ colO = 0;
+ linO = nbdeltaU - 1;
+ }
+ else if (colO > nbdeltaV)
+ {
+ colO = nbdeltaV;
+ linO = nbdeltaU - 1;
+ }
+ TriCon = 0;
}
- if (colT<1) {
- colO=0;
- linO=ligP+ligP-ligE;
- if (linO<0) {linO=0;colO=1;}
- else if (linO>nbdeltaU) {linO=nbdeltaU;colO=1;}
- TriCon=0;
+ if (colT < 1)
+ {
+ colO = 0;
+ linO = ligP + ligP - ligE;
+ if (linO < 0)
+ {
+ linO = 0;
+ colO = 1;
+ }
+ else if (linO > nbdeltaU)
+ {
+ linO = nbdeltaU;
+ colO = 1;
+ }
+ TriCon = 0;
}
- else if (colT>nbdeltaV) {
- colO=nbdeltaV;
- linO=ligP+ligP-ligE;
- if (linO<0) {linO=0;colO=nbdeltaV-1;}
- else if (linO>nbdeltaU) {linO=nbdeltaU;colO=nbdeltaV-1;}
- TriCon=0;
+ else if (colT > nbdeltaV)
+ {
+ colO = nbdeltaV;
+ linO = ligP + ligP - ligE;
+ if (linO < 0)
+ {
+ linO = 0;
+ colO = nbdeltaV - 1;
+ }
+ else if (linO > nbdeltaU)
+ {
+ linO = nbdeltaU;
+ colO = nbdeltaV - 1;
+ }
+ TriCon = 0;
}
- OtherP=linO*nbdeltaVp1 + colO+1;
+ OtherP = linO * nbdeltaVp1 + colO + 1;
return TriCon;
}
-
//=================================================================================================
-void IntCurveSurface_Polyhedron::PlaneEquation (const Standard_Integer Triang,
- gp_XYZ& NormalVector,
- Standard_Real& PolarDistance) const
+void IntCurveSurface_Polyhedron::PlaneEquation(const Standard_Integer Triang,
+ gp_XYZ& NormalVector,
+ Standard_Real& PolarDistance) const
{
- Standard_Integer i1,i2,i3;
- Triangle(Triang,i1,i2,i3);
+ Standard_Integer i1, i2, i3;
+ Triangle(Triang, i1, i2, i3);
//-- gp_XYZ v1=Point(i2).XYZ()-Point(i1).XYZ();
//-- gp_XYZ v2=Point(i3).XYZ()-Point(i2).XYZ();
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
-
- gp_XYZ v1= Pointi2 - Pointi1;
- gp_XYZ v2= Pointi3 - Pointi2;
- gp_XYZ v3= Pointi1 - Pointi3;
+ gp_XYZ v1 = Pointi2 - Pointi1;
+ gp_XYZ v2 = Pointi3 - Pointi2;
+ gp_XYZ v3 = Pointi1 - Pointi3;
- if(v1.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
- if(v2.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
- if(v3.SquareModulus()<=LONGUEUR_MINI_EDGE_TRIANGLE) { NormalVector.SetCoord(1.0,0.0,0.0); return; }
+ if (v1.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
+ {
+ NormalVector.SetCoord(1.0, 0.0, 0.0);
+ return;
+ }
+ if (v2.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
+ {
+ NormalVector.SetCoord(1.0, 0.0, 0.0);
+ return;
+ }
+ if (v3.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
+ {
+ NormalVector.SetCoord(1.0, 0.0, 0.0);
+ return;
+ }
- NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
+ NormalVector = (v1 ^ v2) + (v2 ^ v3) + (v3 ^ v1);
Standard_Real aNormLen = NormalVector.Modulus();
- if (aNormLen < gp::Resolution()) {
+ if (aNormLen < gp::Resolution())
+ {
PolarDistance = 0.;
}
- else {
+ else
+ {
NormalVector.Divide(aNormLen);
PolarDistance = NormalVector * Point(i1).XYZ();
}
}
+
//=================================================================================================
-Standard_Boolean IntCurveSurface_Polyhedron::Contain (const Standard_Integer Triang,
- const gp_Pnt& ThePnt) const
+Standard_Boolean IntCurveSurface_Polyhedron::Contain(const Standard_Integer Triang,
+ const gp_Pnt& ThePnt) const
{
- Standard_Integer i1,i2,i3;
- Triangle(Triang,i1,i2,i3);
+ Standard_Integer i1, i2, i3;
+ Triangle(Triang, i1, i2, i3);
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
-
- gp_XYZ v1=(Pointi2-Pointi1)^(ThePnt.XYZ()-Pointi1);
- gp_XYZ v2=(Pointi3-Pointi2)^(ThePnt.XYZ()-Pointi2);
- gp_XYZ v3=(Pointi1-Pointi3)^(ThePnt.XYZ()-Pointi3);
- if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.)
+
+ gp_XYZ v1 = (Pointi2 - Pointi1) ^ (ThePnt.XYZ() - Pointi1);
+ gp_XYZ v2 = (Pointi3 - Pointi2) ^ (ThePnt.XYZ() - Pointi2);
+ gp_XYZ v3 = (Pointi1 - Pointi3) ^ (ThePnt.XYZ() - Pointi3);
+ if (v1 * v2 >= 0. && v2 * v3 >= 0. && v3 * v1 >= 0.)
return Standard_True;
- else
+ else
return Standard_False;
}
+
//=================================================================================================
-void IntCurveSurface_Polyhedron::Dump() const
-{
+void IntCurveSurface_Polyhedron::Dump() const {}
-}
//=================================================================================================
-void IntCurveSurface_Polyhedron::Size (Standard_Integer& nbdu,
- Standard_Integer& nbdv) const
+void IntCurveSurface_Polyhedron::Size(Standard_Integer& nbdu, Standard_Integer& nbdv) const
{
- nbdu=nbdeltaU;
- nbdv=nbdeltaV;
+ nbdu = nbdeltaU;
+ nbdv = nbdeltaV;
}
+
//=================================================================================================
-void IntCurveSurface_Polyhedron::Triangle (const Standard_Integer Index,
- Standard_Integer& P1,
- Standard_Integer& P2,
- Standard_Integer& P3) const
+void IntCurveSurface_Polyhedron::Triangle(const Standard_Integer Index,
+ Standard_Integer& P1,
+ Standard_Integer& P2,
+ Standard_Integer& P3) const
{
- Standard_Integer line=1+((Index-1)/(nbdeltaV*2));
- Standard_Integer colon=1+((Index-1)%(nbdeltaV*2));
- Standard_Integer colpnt=(colon+1)/2;
+ Standard_Integer line = 1 + ((Index - 1) / (nbdeltaV * 2));
+ Standard_Integer colon = 1 + ((Index - 1) % (nbdeltaV * 2));
+ Standard_Integer colpnt = (colon + 1) / 2;
-// General formula = (line-1)*(nbdeltaV+1)+colpnt
-
-// Position of P1 = MesXYZ(line,colpnt);
- P1= (line-1)*(nbdeltaV+1) + colpnt;
+ // General formula = (line-1)*(nbdeltaV+1)+colpnt
-// Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
- P2= line*(nbdeltaV+1) + colpnt+((colon-1)%2);
+ // Position of P1 = MesXYZ(line,colpnt);
+ P1 = (line - 1) * (nbdeltaV + 1) + colpnt;
-// Position of P3= MesXYZ(line+(colon%2),colpnt+1);
- P3= (line-1+(colon%2))*(nbdeltaV+1) + colpnt + 1;
+ // Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
+ P2 = line * (nbdeltaV + 1) + colpnt + ((colon - 1) % 2);
+
+ // Position of P3= MesXYZ(line+(colon%2),colpnt+1);
+ P3 = (line - 1 + (colon % 2)) * (nbdeltaV + 1) + colpnt + 1;
}
+
//=======================================================================
-//function : Point
+// function : Point
//=======================================================================
-const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index
- ,Standard_Real& U
- ,Standard_Real& V) const
+const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index,
+ Standard_Real& U,
+ Standard_Real& V) const
{
-#if CHECKBOUNDS
- if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
+#if CHECKBOUNDS
+ if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
+ {
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
- gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
- Standard_Real *CMyU = (Standard_Real *)C_MyU;
- Standard_Real *CMyV = (Standard_Real *)C_MyV;
- U=CMyU[Index];
- V=CMyV[Index];
+ gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
+ Standard_Real* CMyU = (Standard_Real*)C_MyU;
+ Standard_Real* CMyV = (Standard_Real*)C_MyV;
+ U = CMyU[Index];
+ V = CMyV[Index];
return CMyPnts[Index];
}
+
//=======================================================================
-//function : Point
+// function : Point
//=======================================================================
-const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const {
-#if CHECKBOUNDS
- if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
+const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const
+{
+#if CHECKBOUNDS
+ if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
+ {
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
-
- gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
+
+ gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
return CMyPnts[Index];
}
+
//=======================================================================
-//function : Point
+// function : Point
//=======================================================================
-//void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
+// void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
// const Standard_Integer lig,
// const Standard_Integer col,
// const Standard_Real u,
-// const Standard_Real v)
-void IntCurveSurface_Polyhedron::Point (const gp_Pnt& ,
- const Standard_Integer ,
- const Standard_Integer ,
- const Standard_Real ,
- const Standard_Real )
+// const Standard_Real v)
+void IntCurveSurface_Polyhedron::Point(const gp_Pnt&,
+ const Standard_Integer,
+ const Standard_Integer,
+ const Standard_Real,
+ const Standard_Real)
{
printf("\n IntCurveSurface_Polyhedron::Point : Ne dois pas etre appelle\n");
}
+
//=======================================================================
-//function : Point
+// function : Point
//=======================================================================
-void IntCurveSurface_Polyhedron::Point (const Standard_Integer Index,gp_Pnt& P) const
+void IntCurveSurface_Polyhedron::Point(const Standard_Integer Index, gp_Pnt& P) const
{
-#if CHECKBOUNDS
- if(Index<0 || Index>((nbdeltaU+1)*(nbdeltaV+1))) {
+#if CHECKBOUNDS
+ if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
+ {
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
-
- gp_Pnt *CMyPnts = (gp_Pnt *)C_MyPnts;
- P = CMyPnts[Index];
+
+ gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
+ P = CMyPnts[Index];
}
// Modified by Sergey KHROMOV - Fri Dec 7 10:12:47 2001 Begin
//=======================================================================
-//function : IsOnBound
-//purpose : This method returns true if the edge based on points with
+// function : IsOnBound
+// purpose : This method returns true if the edge based on points with
// indices Index1 and Index2 represents a boundary edge.
//=======================================================================
-Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound
- (const Standard_Integer Index1,
- const Standard_Integer Index2) const
+Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound(const Standard_Integer Index1,
+ const Standard_Integer Index2) const
{
-#if CHECKBOUNDS
- if(Index1<0 || Index1>((nbdeltaU+1)*(nbdeltaV+1))) {
+#if CHECKBOUNDS
+ if (Index1 < 0 || Index1 > ((nbdeltaU + 1) * (nbdeltaV + 1)))
+ {
printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
}
- if(Index2<0 || Index2>((nbdeltaU+1)*(nbdeltaV+1))) {
+ if (Index2 < 0 || Index2 > ((nbdeltaU + 1) * (nbdeltaV + 1)))
+ {
printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
}
#endif
- Standard_Boolean *CMyIsOnBounds = (Standard_Boolean *)C_MyIsOnBounds;
+ Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
Standard_Integer aDiff = Abs(Index1 - Index2);
Standard_Integer i;
-// Check if points are neighbour ones.
+ // Check if points are neighbour ones.
if (aDiff != 1 && aDiff != nbdeltaV + 1)
return Standard_False;
- for (i = 0; i <= nbdeltaU; i++) {
- if ((Index1 == 1 + i*(nbdeltaV + 1)) && (Index2 == Index1 - 1))
+ for (i = 0; i <= nbdeltaU; i++)
+ {
+ if ((Index1 == 1 + i * (nbdeltaV + 1)) && (Index2 == Index1 - 1))
return Standard_False;
- if ((Index1 == (1 + i)*(nbdeltaV + 1)) && (Index2 == Index1 + 1))
+ if ((Index1 == (1 + i) * (nbdeltaV + 1)) && (Index2 == Index1 + 1))
return Standard_False;
}
}
//=======================================================================
-//function : ComputeBorderDeflection
-//purpose : This method computes and returns a deflection of isoline
+// function : ComputeBorderDeflection
+// purpose : This method computes and returns a deflection of isoline
// of given parameter on Surface.
//=======================================================================
-Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection
- (const ThePSurface &Surface,
- const Standard_Real Parameter,
- const Standard_Real PMin,
- const Standard_Real PMax,
- const Standard_Boolean isUIso) const
+Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection(
+ const ThePSurface& Surface,
+ const Standard_Real Parameter,
+ const Standard_Real PMin,
+ const Standard_Real PMax,
+ const Standard_Boolean isUIso) const
{
Standard_Integer aNbSamples;
Standard_Integer i;
-
+
if (isUIso)
aNbSamples = nbdeltaV;
else
aNbSamples = nbdeltaU;
- Standard_Real aDelta = (PMax - PMin)/aNbSamples;
+ Standard_Real aDelta = (PMax - PMin) / aNbSamples;
Standard_Real aPar = PMin;
Standard_Real aDeflection = RealFirst();
gp_XYZ aP1;
gp_XYZ aPMid;
gp_XYZ aPParMid;
- for (i = 0; i <= aNbSamples; i++, aPar+= aDelta) {
- if (isUIso) {
+ for (i = 0; i <= aNbSamples; i++, aPar += aDelta)
+ {
+ if (isUIso)
+ {
aP1 = ThePSurfaceTool::Value(Surface, Parameter, aPar).XYZ();
aP2 = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta).XYZ();
- aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta/2.).XYZ();
- } else {
- aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
- aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
- aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta/2., Parameter).XYZ();
+ aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta / 2.).XYZ();
+ }
+ else
+ {
+ aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
+ aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
+ aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta / 2., Parameter).XYZ();
}
- aPMid = (aP2 + aP1)/2.;
+ aPMid = (aP2 + aP1) / 2.;
Standard_Real aDist = (aPMid - aPParMid).Modulus();
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-void IntCurveSurface_PolyhedronTool::Dump(const ThePolyhedron& polyh) {
+void IntCurveSurface_PolyhedronTool::Dump(const ThePolyhedron& polyh)
+{
polyh.Dump();
}
#include <IntSurf_Quadric.hxx>
#include <GeomAbs_SurfaceType.hxx>
-
-#define EPSX 0.00000000000001
+#define EPSX 0.00000000000001
#define EPSDIST 0.00000001
-#define EPSNUL 0.00000001
+#define EPSNUL 0.00000001
+
+//=================================================================================================
-//================================================================================
IntCurveSurface_QuadricCurveExactInter::IntCurveSurface_QuadricCurveExactInter(const TheSurface& S,
- const TheCurve& C)
- : nbpnts(-1),nbintv(-1)
-{
+ const TheCurve& C)
+ : nbpnts(-1),
+ nbintv(-1)
+{
GeomAbs_SurfaceType QuadricType = TheSurfaceTool::GetType(S);
- IntSurf_Quadric Quadric;
- switch(QuadricType) {
- case GeomAbs_Plane: { Quadric.SetValue(TheSurfaceTool::Plane(S)); break; }
- case GeomAbs_Cylinder: { Quadric.SetValue(TheSurfaceTool::Cylinder(S)); break; }
- case GeomAbs_Cone: { Quadric.SetValue(TheSurfaceTool::Cone(S)); break; }
- case GeomAbs_Sphere: { Quadric.SetValue(TheSurfaceTool::Sphere(S)); break; }
- default: {
- //cout<<" Probleme Sur le Type de Surface dans IntCurveSurface_Inter::InternalPerform "<<endl;
- break;
- }
+ IntSurf_Quadric Quadric;
+ switch (QuadricType)
+ {
+ case GeomAbs_Plane: {
+ Quadric.SetValue(TheSurfaceTool::Plane(S));
+ break;
+ }
+ case GeomAbs_Cylinder: {
+ Quadric.SetValue(TheSurfaceTool::Cylinder(S));
+ break;
+ }
+ case GeomAbs_Cone: {
+ Quadric.SetValue(TheSurfaceTool::Cone(S));
+ break;
+ }
+ case GeomAbs_Sphere: {
+ Quadric.SetValue(TheSurfaceTool::Sphere(S));
+ break;
+ }
+ default: {
+ // cout<<" Probleme Sur le Type de Surface dans IntCurveSurface_Inter::InternalPerform
+ // "<<endl;
+ break;
+ }
}
// Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 Begin
TheCurveTool::Intervals(C, anIntervals, GeomAbs_C1);
- for (ii = 1; ii <= nbIntervals; ii++) {
+ for (ii = 1; ii <= nbIntervals; ii++)
+ {
Standard_Real U1 = anIntervals.Value(ii);
Standard_Real U2 = anIntervals.Value(ii + 1);
-
- math_FunctionSample Sample(U1,U2,TheCurveTool::NbSamples(C,U1,U2));
- IntCurveSurface_TheQuadCurvFunc Function(Quadric,C);
- math_FunctionAllRoots Roots(Function,Sample,EPSX,EPSDIST,EPSNUL);
-
- if(Roots.IsDone()) {
- Standard_Integer nbp = Roots.NbPoints();
- Standard_Integer nbi = Roots.NbIntervals();
+
+ math_FunctionSample Sample(U1, U2, TheCurveTool::NbSamples(C, U1, U2));
+ IntCurveSurface_TheQuadCurvFunc Function(Quadric, C);
+ math_FunctionAllRoots Roots(Function, Sample, EPSX, EPSDIST, EPSNUL);
+
+ if (Roots.IsDone())
+ {
+ Standard_Integer nbp = Roots.NbPoints();
+ Standard_Integer nbi = Roots.NbIntervals();
Standard_Integer i;
- for( i = 1; i<=nbp; i++) {
- pnts.Append(Roots.GetPoint(i));
- //-- cout<<" QuadricCurveExactInter : Roots("<<i<<") = "<<Roots.GetPoint(i)<<endl;
+ for (i = 1; i <= nbp; i++)
+ {
+ pnts.Append(Roots.GetPoint(i));
+ //-- cout<<" QuadricCurveExactInter : Roots("<<i<<") = "<<Roots.GetPoint(i)<<endl;
}
- Standard_Real a,b;
- for(i = 1; i<=nbi; i++) {
- Roots.GetInterval(i,a,b);
- //cout<<" QuadricCurveExactInter : RootsSeg("<<i<<") = "<<a<<" , "<<b<<endl;
- intv.Append(a);
- intv.Append(b);
+ Standard_Real a, b;
+ for (i = 1; i <= nbi; i++)
+ {
+ Roots.GetInterval(i, a, b);
+ // cout<<" QuadricCurveExactInter : RootsSeg("<<i<<") = "<<a<<" , "<<b<<endl;
+ intv.Append(a);
+ intv.Append(b);
}
- } else {
+ }
+ else
+ {
break;
}
}
- if (ii > nbIntervals) {
+ if (ii > nbIntervals)
+ {
nbpnts = pnts.Length();
- nbintv = intv.Length()/2;
+ nbintv = intv.Length() / 2;
}
-// Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 End
-}
-//================================================================================
-Standard_Boolean IntCurveSurface_QuadricCurveExactInter::IsDone() const {
- return(nbpnts!=-1);
-}
-//================================================================================
-Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbRoots() const {
- return(nbpnts);
-}
-//================================================================================
-Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbIntervals() const {
- return(nbintv);
+ // Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 End
}
-//================================================================================
-Standard_Real IntCurveSurface_QuadricCurveExactInter::Root(const Standard_Integer Index) const {
- return(pnts(Index));
-}
-//================================================================================
-void IntCurveSurface_QuadricCurveExactInter::Intervals(const Standard_Integer Index,
- Standard_Real& a,
- Standard_Real& b) const
-{
- Standard_Integer Index2 = Index+Index-1;
- a = intv(Index2);
- b = intv(Index2+1);
+
+//=================================================================================================
+
+Standard_Boolean IntCurveSurface_QuadricCurveExactInter::IsDone() const
+{
+ return (nbpnts != -1);
}
+//=================================================================================================
+Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbRoots() const
+{
+ return (nbpnts);
+}
+//=================================================================================================
+Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbIntervals() const
+{
+ return (nbintv);
+}
+//=================================================================================================
+Standard_Real IntCurveSurface_QuadricCurveExactInter::Root(const Standard_Integer Index) const
+{
+ return (pnts(Index));
+}
+//=================================================================================================
+
+void IntCurveSurface_QuadricCurveExactInter::Intervals(const Standard_Integer Index,
+ Standard_Real& a,
+ Standard_Real& b) const
+{
+ Standard_Integer Index2 = Index + Index - 1;
+ a = intv(Index2);
+ b = intv(Index2 + 1);
+}
#include <gp_Vec.hxx>
+//=================================================================================================
-//================================================================================
IntCurveSurface_QuadricCurveFunc::IntCurveSurface_QuadricCurveFunc(const TheQuadric& Q,
- const TheCurve& C)
- : myQuadric(Q), myCurve(C)
-{
-}
-//================================================================================
+ const TheCurve& C)
+ : myQuadric(Q),
+ myCurve(C)
+{
+}
+
+//=================================================================================================
+
Standard_Boolean IntCurveSurface_QuadricCurveFunc::Value(const Standard_Real Param,
- Standard_Real& F) {
- F = myQuadric.Distance(TheCurveTool::Value(myCurve,Param));
- return(Standard_True);
+ Standard_Real& F)
+{
+ F = myQuadric.Distance(TheCurveTool::Value(myCurve, Param));
+ return (Standard_True);
}
Standard_Boolean IntCurveSurface_QuadricCurveFunc::Derivative(const Standard_Real Param,
- Standard_Real& D) {
+ Standard_Real& D)
+{
gp_Pnt P;
gp_Vec T;
- TheCurveTool::D1(myCurve,Param,P,T);
+ TheCurveTool::D1(myCurve, Param, P, T);
D = T.Dot(myQuadric.Gradient(P));
- return(Standard_True);
+ return (Standard_True);
}
Standard_Boolean IntCurveSurface_QuadricCurveFunc::Values(const Standard_Real Param,
- Standard_Real& F,
- Standard_Real& D) {
+ Standard_Real& F,
+ Standard_Real& D)
+{
gp_Pnt P;
- gp_Vec T,Grad;
- TheCurveTool::D1(myCurve,Param,P,T);
- myQuadric.ValAndGrad(P,F,Grad);
+ gp_Vec T, Grad;
+ TheCurveTool::D1(myCurve, Param, P, T);
+ myQuadric.ValAndGrad(P, F, Grad);
D = T.Dot(Grad);
- return(Standard_True);
+ return (Standard_True);
}
-
-
-
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
#include <IntImp_ComputeTangence.hxx>
#include <math_FunctionSetRoot.hxx>
#include <math_Vector.hxx>
#include <Standard_ConstructionError.hxx>
#include <Precision.hxx>
-IntImp_Int2S::IntImp_Int2S(const ThePSurface& surf1,
- const ThePSurface& surf2,
- const Standard_Real TolTangency ) :
-done(Standard_True),
-empty(Standard_True),
-tangent(Standard_False),
-myZerParFunc(surf1,surf2),
-tol(TolTangency*TolTangency)
+IntImp_Int2S::IntImp_Int2S(const ThePSurface& surf1,
+ const ThePSurface& surf2,
+ const Standard_Real TolTangency)
+ : done(Standard_True),
+ empty(Standard_True),
+ tangent(Standard_False),
+ myZerParFunc(surf1, surf2),
+ tol(TolTangency * TolTangency)
{
ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
- ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
- vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
+ ures1 = ThePSurfaceTool::UResolution(surf1, Precision::Confusion());
+ vres1 = ThePSurfaceTool::VResolution(surf1, Precision::Confusion());
- ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
- vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
+ ures2 = ThePSurfaceTool::UResolution(surf2, Precision::Confusion());
+ vres2 = ThePSurfaceTool::VResolution(surf2, Precision::Confusion());
}
-
IntImp_Int2S::IntImp_Int2S(const TColStd_Array1OfReal& Param,
- const ThePSurface& surf1,
- const ThePSurface& surf2,
- const Standard_Real TolTangency ) :
-done(Standard_True),
-empty(Standard_True),
-myZerParFunc(surf1,surf2),
-tol(TolTangency*TolTangency)
+ const ThePSurface& surf1,
+ const ThePSurface& surf2,
+ const Standard_Real TolTangency)
+ : done(Standard_True),
+ empty(Standard_True),
+ myZerParFunc(surf1, surf2),
+ tol(TolTangency * TolTangency)
{
- math_FunctionSetRoot Rsnld(myZerParFunc,15); //-- Modif lbr 18 MAI ?????????????
+ math_FunctionSetRoot Rsnld(myZerParFunc, 15); //-- Modif lbr 18 MAI ?????????????
ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
- ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
- vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
+ ures1 = ThePSurfaceTool::UResolution(surf1, Precision::Confusion());
+ vres1 = ThePSurfaceTool::VResolution(surf1, Precision::Confusion());
- ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
- vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
- Perform(Param,Rsnld);
-}
+ ures2 = ThePSurfaceTool::UResolution(surf2, Precision::Confusion());
+ vres2 = ThePSurfaceTool::VResolution(surf2, Precision::Confusion());
+ Perform(Param, Rsnld);
+}
-IntImp_ConstIsoparametric IntImp_Int2S:: Perform(const TColStd_Array1OfReal& Param,
- math_FunctionSetRoot& Rsnld,
- const IntImp_ConstIsoparametric ChoixIso)
+IntImp_ConstIsoparametric IntImp_Int2S::Perform(const TColStd_Array1OfReal& Param,
+ math_FunctionSetRoot& Rsnld,
+ const IntImp_ConstIsoparametric ChoixIso)
{
Standard_Real BornInfBuf[3] = {}, BornSupBuf[3] = {}, ToleranceBuf[3] = {}, UVapBuf[3] = {};
Standard_Real UvresBuf[4] = {};
- math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3),
- Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3);
- TColStd_Array1OfReal Uvres (UvresBuf[0], 1, 4);
+ math_Vector BornInf(BornInfBuf, 1, 3), BornSup(BornSupBuf, 1, 3), Tolerance(ToleranceBuf, 1, 3),
+ UVap(UVapBuf, 1, 3);
+ TColStd_Array1OfReal Uvres(UvresBuf[0], 1, 4);
IntImp_ConstIsoparametric BestChoix;
- myZerParFunc.ComputeParameters(ChoixIso,Param,UVap,BornInf,BornSup,Tolerance);
+ myZerParFunc.ComputeParameters(ChoixIso, Param, UVap, BornInf, BornSup, Tolerance);
Rsnld.SetTolerance(Tolerance);
- Rsnld.Perform(myZerParFunc,UVap,BornInf,BornSup);
+ Rsnld.Perform(myZerParFunc, UVap, BornInf, BornSup);
BestChoix = ChoixIso;
- if (Rsnld.IsDone()) {
- if (Abs(myZerParFunc.Root()) <= tol) { //distance des 2 points
+ if (Rsnld.IsDone())
+ {
+ if (Abs(myZerParFunc.Root()) <= tol)
+ { // distance des 2 points
// dans la tolerance
Rsnld.Root(UVap);
- empty = Standard_False;
- tangent = myZerParFunc.IsTangent(UVap,Uvres,BestChoix);
- pint.SetValue(myZerParFunc.Point(),Uvres(1),Uvres(2),Uvres(3),Uvres(4));
- if (!tangent) {
+ empty = Standard_False;
+ tangent = myZerParFunc.IsTangent(UVap, Uvres, BestChoix);
+ pint.SetValue(myZerParFunc.Point(), Uvres(1), Uvres(2), Uvres(3), Uvres(4));
+ if (!tangent)
+ {
d3d = myZerParFunc.Direction();
d2d1 = myZerParFunc.DirectionOnS1();
d2d2 = myZerParFunc.DirectionOnS2();
}
}
- else {
+ else
+ {
empty = Standard_True;
}
}
- else {
+ else
+ {
empty = Standard_True;
}
return BestChoix;
}
-IntImp_ConstIsoparametric IntImp_Int2S:: Perform(const TColStd_Array1OfReal& Param,
- math_FunctionSetRoot& Rsnld)
+IntImp_ConstIsoparametric IntImp_Int2S::Perform(const TColStd_Array1OfReal& Param,
+ math_FunctionSetRoot& Rsnld)
{
- gp_Vec DPUV[4];
- gp_Pnt P1,P2;
- Standard_Real Epsuv[4];
- Standard_Real DuvBuf[4];
- TColStd_Array1OfReal Duv (DuvBuf[0], 1, 4);
- Standard_Real UVd[4],UVf[4];
+ gp_Vec DPUV[4];
+ gp_Pnt P1, P2;
+ Standard_Real Epsuv[4];
+ Standard_Real DuvBuf[4];
+ TColStd_Array1OfReal Duv(DuvBuf[0], 1, 4);
+ Standard_Real UVd[4], UVf[4];
IntImp_ConstIsoparametric ChoixIso[4];
IntImp_ConstIsoparametric BestChoix = ChoixRef(0);
- const ThePSurface& Caro1 = myZerParFunc.AuxillarSurface1();
- const ThePSurface& Caro2 = myZerParFunc.AuxillarSurface2();
+ const ThePSurface& Caro1 = myZerParFunc.AuxillarSurface1();
+ const ThePSurface& Caro2 = myZerParFunc.AuxillarSurface2();
- ThePSurfaceTool::D1(Caro1, Param(1),Param(2),P1,DPUV[0],DPUV[1]);
- ThePSurfaceTool::D1(Caro2, Param(3),Param(4),P2,DPUV[2],DPUV[3]);
+ ThePSurfaceTool::D1(Caro1, Param(1), Param(2), P1, DPUV[0], DPUV[1]);
+ ThePSurfaceTool::D1(Caro2, Param(3), Param(4), P2, DPUV[2], DPUV[3]);
- Epsuv[0] = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion());
- Epsuv[1] = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion());
+ Epsuv[0] = ThePSurfaceTool::UResolution(Caro1, Precision::Confusion());
+ Epsuv[1] = ThePSurfaceTool::VResolution(Caro1, Precision::Confusion());
- Epsuv[2] = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion());
- Epsuv[3] = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion());
+ Epsuv[2] = ThePSurfaceTool::UResolution(Caro2, Precision::Confusion());
+ Epsuv[3] = ThePSurfaceTool::VResolution(Caro2, Precision::Confusion());
- for (Standard_Integer j=0;j<=3;j++)
- UVd[j] = Param(j+1);
+ for (Standard_Integer j = 0; j <= 3; j++)
+ UVd[j] = Param(j + 1);
empty = Standard_True;
- Standard_Boolean Tangent = IntImp_ComputeTangence(DPUV,Epsuv,UVd,ChoixIso);
+ Standard_Boolean Tangent = IntImp_ComputeTangence(DPUV, Epsuv, UVd, ChoixIso);
if (Tangent)
return BestChoix;
- Standard_Integer i=0;
- IntImp_ConstIsoparametric CurrentChoix = BestChoix; //-- Modif 17 Mai 93
+ Standard_Integer i = 0;
+ IntImp_ConstIsoparametric CurrentChoix = BestChoix; //-- Modif 17 Mai 93
- while (empty && i<= 3)
+ while (empty && i <= 3)
{
- CurrentChoix = Perform(Param,Rsnld,ChoixIso[i]);
- if(!empty) {
- BestChoix = CurrentChoix;
+ CurrentChoix = Perform(Param, Rsnld, ChoixIso[i]);
+ if (!empty)
+ {
+ BestChoix = CurrentChoix;
}
i++;
}
- if (!empty) { // verifier que l on ne deborde pas les frontieres
- pint.Parameters(Duv(1),Duv(2),Duv(3),Duv(4));
+ if (!empty)
+ { // verifier que l on ne deborde pas les frontieres
+ pint.Parameters(Duv(1), Duv(2), Duv(3), Duv(4));
UVd[0] = ua0; //-- ThePSurfaceTool::UIntervalFirst(Caro1);
UVd[1] = va0; //-- ThePSurfaceTool::VIntervalFirst(Caro1);
UVf[2] = ub1; //-- ThePSurfaceTool::UIntervalLast(Caro2);
UVf[3] = vb1; //-- ThePSurfaceTool::VIntervalLast(Caro2);
- Standard_Integer Nc,Iiso;
- if (Duv(1) <= UVd[0]-Epsuv[0]) {
+ Standard_Integer Nc, Iiso;
+ if (Duv(1) <= UVd[0] - Epsuv[0])
+ {
Duv(1) = UVd[0];
- Nc =0;
- Iiso=0;
+ Nc = 0;
+ Iiso = 0;
}
- else if (Duv(1) >= UVf[0]+ Epsuv[0]) {
+ else if (Duv(1) >= UVf[0] + Epsuv[0])
+ {
Duv(1) = UVf[0];
- Nc =0;
- Iiso=0;
+ Nc = 0;
+ Iiso = 0;
}
- else if (Duv(2) <= UVd[1] -Epsuv[1]) {
+ else if (Duv(2) <= UVd[1] - Epsuv[1])
+ {
Duv(2) = UVd[1];
- Nc =0;
- Iiso=1;
+ Nc = 0;
+ Iiso = 1;
}
- else if (Duv(2) >= UVf[1]+Epsuv[1]) {
+ else if (Duv(2) >= UVf[1] + Epsuv[1])
+ {
Duv(2) = UVf[1];
- Nc =0;
- Iiso=1;
+ Nc = 0;
+ Iiso = 1;
}
- else if (Duv(3) <= UVd[2]-Epsuv[2]) {
+ else if (Duv(3) <= UVd[2] - Epsuv[2])
+ {
Duv(3) = UVd[2];
- Nc =2;
- Iiso = 2;
+ Nc = 2;
+ Iiso = 2;
}
- else if (Duv(3) >= UVf[2]+Epsuv[2]) {
+ else if (Duv(3) >= UVf[2] + Epsuv[2])
+ {
Duv(3) = UVf[2];
- Nc =2;
- Iiso = 2;
+ Nc = 2;
+ Iiso = 2;
}
- else if (Duv(4) <= UVd[3]-Epsuv[3]) {
+ else if (Duv(4) <= UVd[3] - Epsuv[3])
+ {
Duv(4) = UVd[3];
- Nc =2;
- Iiso = 3;
+ Nc = 2;
+ Iiso = 3;
}
- else if (Duv(4) >= UVf[3]+Epsuv[3]) {
+ else if (Duv(4) >= UVf[3] + Epsuv[3])
+ {
Duv(4) = UVf[3];
- Nc =2;
- Iiso =3;
+ Nc = 2;
+ Iiso = 3;
}
- else return BestChoix; // on a gagne
- empty = Standard_True;
- BestChoix = ChoixRef(Iiso); //en attendant
- BestChoix = Perform(Duv,Rsnld,BestChoix);
- if (!empty) { // verification si l on ne deborde pas sur le carreau
+ else
+ return BestChoix; // on a gagne
+ empty = Standard_True;
+ BestChoix = ChoixRef(Iiso); // en attendant
+ BestChoix = Perform(Duv, Rsnld, BestChoix);
+ if (!empty)
+ { // verification si l on ne deborde pas sur le carreau
// reciproque
- Nc =3-Nc;
- if (Duv(Nc) <= UVd[Nc-1]-Epsuv[Nc-1])
- Duv(Nc)=UVd[Nc-1];
- else if (Duv(Nc) >=UVf[Nc-1]+Epsuv[Nc-1])
- Duv(Nc)=UVf[Nc-1];
- else if (Duv(Nc+1) <= UVd[Nc])
+ Nc = 3 - Nc;
+ if (Duv(Nc) <= UVd[Nc - 1] - Epsuv[Nc - 1])
+ Duv(Nc) = UVd[Nc - 1];
+ else if (Duv(Nc) >= UVf[Nc - 1] + Epsuv[Nc - 1])
+ Duv(Nc) = UVf[Nc - 1];
+ else if (Duv(Nc + 1) <= UVd[Nc])
{
- Nc = Nc + 1;
- Duv(Nc)=UVd[Nc-1];
+ Nc = Nc + 1;
+ Duv(Nc) = UVd[Nc - 1];
}
- else if (Duv(Nc+1) >=UVf[Nc])
+ else if (Duv(Nc + 1) >= UVf[Nc])
{
- Nc = Nc + 1;
- Duv(Nc)=UVf[Nc-1];
- }
+ Nc = Nc + 1;
+ Duv(Nc) = UVf[Nc - 1];
+ }
else
return BestChoix;
-
+
empty = Standard_True;
-
- if(Nc == 4)
+
+ if (Nc == 4)
Nc = 0;
-
- BestChoix = ChoixRef(Nc); //en attendant
- BestChoix = Perform(Duv,Rsnld,BestChoix);
+
+ BestChoix = ChoixRef(Nc); // en attendant
+ BestChoix = Perform(Duv, Rsnld, BestChoix);
}
}
- return BestChoix;
+ return BestChoix;
}
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
#include <StdFail_NotDone.hxx>
#include <Standard_DomainError.hxx>
#include <IntImp_ComputeTangence.hxx>
#include <Precision.hxx>
IntImp_IntCS::IntImp_IntCS(const Standard_Real U,
- const Standard_Real V,
- const Standard_Real W,
- const TheFunction& F,
- const Standard_Real TolTangency,
- const Standard_Real MarginCoef) :
- done(Standard_True),
- empty(Standard_True),
- myFunction(F),
- w(0.0),
- u(0.0),
- v(0.0),
- tol(TolTangency*TolTangency)
+ const Standard_Real V,
+ const Standard_Real W,
+ const TheFunction& F,
+ const Standard_Real TolTangency,
+ const Standard_Real MarginCoef)
+ : done(Standard_True),
+ empty(Standard_True),
+ myFunction(F),
+ w(0.0),
+ u(0.0),
+ v(0.0),
+ tol(TolTangency * TolTangency)
+{
+ if (tol < 1e-13)
{
- if(tol<1e-13) { tol=1e-13; }
- math_FunctionSetRoot Rsnld(myFunction);
- Standard_Real u0,u1,v0,v1,w0,w1;
- const ThePSurface& S = myFunction.AuxillarSurface();
- const TheCurve& C = myFunction.AuxillarCurve();
-
- w0 = TheCurveTool::FirstParameter(C);
- w1 = TheCurveTool::LastParameter(C);
-
- u0 = ThePSurfaceTool::FirstUParameter(S);
- v0 = ThePSurfaceTool::FirstVParameter(S);
- u1 = ThePSurfaceTool::LastUParameter(S);
- v1 = ThePSurfaceTool::LastVParameter(S);
-
- if (MarginCoef > 0.) {
- if (!Precision::IsInfinite(u0) && !Precision::IsInfinite(u1)) {
- Standard_Real marg = (u1-u0)*MarginCoef;
- if (u0 > u1) marg = -marg;
- u0 -= marg; u1 += marg;
- }
- if (!Precision::IsInfinite(v0) && !Precision::IsInfinite(v1)) {
- Standard_Real marg = (v1-v0)*MarginCoef;
- if (v0 > v1) marg = -marg;
- v0 -= marg; v1 += marg;
- }
+ tol = 1e-13;
+ }
+ math_FunctionSetRoot Rsnld(myFunction);
+ Standard_Real u0, u1, v0, v1, w0, w1;
+ const ThePSurface& S = myFunction.AuxillarSurface();
+ const TheCurve& C = myFunction.AuxillarCurve();
+
+ w0 = TheCurveTool::FirstParameter(C);
+ w1 = TheCurveTool::LastParameter(C);
+
+ u0 = ThePSurfaceTool::FirstUParameter(S);
+ v0 = ThePSurfaceTool::FirstVParameter(S);
+ u1 = ThePSurfaceTool::LastUParameter(S);
+ v1 = ThePSurfaceTool::LastVParameter(S);
+
+ if (MarginCoef > 0.)
+ {
+ if (!Precision::IsInfinite(u0) && !Precision::IsInfinite(u1))
+ {
+ Standard_Real marg = (u1 - u0) * MarginCoef;
+ if (u0 > u1)
+ marg = -marg;
+ u0 -= marg;
+ u1 += marg;
+ }
+ if (!Precision::IsInfinite(v0) && !Precision::IsInfinite(v1))
+ {
+ Standard_Real marg = (v1 - v0) * MarginCoef;
+ if (v0 > v1)
+ marg = -marg;
+ v0 -= marg;
+ v1 += marg;
}
-
- Perform(U,V,W,Rsnld,u0,u1,v0,v1,w0,w1);
}
-IntImp_IntCS::IntImp_IntCS(const TheFunction& F,
- const Standard_Real TolTangency) :
- done(Standard_True),
- empty(Standard_True),
- myFunction(F),
- tol(TolTangency*TolTangency)
+ Perform(U, V, W, Rsnld, u0, u1, v0, v1, w0, w1);
+}
+
+IntImp_IntCS::IntImp_IntCS(const TheFunction& F, const Standard_Real TolTangency)
+ : done(Standard_True),
+ empty(Standard_True),
+ myFunction(F),
+ tol(TolTangency * TolTangency)
{
}
-void IntImp_IntCS::Perform(const Standard_Real U,
- const Standard_Real V,
- const Standard_Real W,
- math_FunctionSetRoot& Rsnld,
- const Standard_Real u0,
- const Standard_Real u1,
- const Standard_Real v0,
- const Standard_Real v1,
- const Standard_Real w0,
- const Standard_Real w1) {
+void IntImp_IntCS::Perform(const Standard_Real U,
+ const Standard_Real V,
+ const Standard_Real W,
+ math_FunctionSetRoot& Rsnld,
+ const Standard_Real u0,
+ const Standard_Real u1,
+ const Standard_Real v0,
+ const Standard_Real v1,
+ const Standard_Real w0,
+ const Standard_Real w1)
+{
done = Standard_True;
Standard_Real BornInfBuf[3], BornSupBuf[3], ToleranceBuf[3], UVapBuf[3];
- math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3), Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3);
- UVap(1) = U;
- UVap(2) = V;
- UVap(3) = W;
+ math_Vector BornInf(BornInfBuf, 1, 3), BornSup(BornSupBuf, 1, 3), Tolerance(ToleranceBuf, 1, 3),
+ UVap(UVapBuf, 1, 3);
+ UVap(1) = U;
+ UVap(2) = V;
+ UVap(3) = W;
const ThePSurface& S = myFunction.AuxillarSurface();
const TheCurve& C = myFunction.AuxillarCurve();
- BornInf(1) = u0; BornInf(2) = v0;
- BornSup(1) = u1; BornSup(2) = v1;
+ BornInf(1) = u0;
+ BornInf(2) = v0;
+ BornSup(1) = u1;
+ BornSup(2) = v1;
- BornInf(3) = w0; BornSup(3) = w1;
+ BornInf(3) = w0;
+ BornSup(3) = w1;
- Tolerance(1) = ThePSurfaceTool::UResolution(S,Precision::Confusion());
- Tolerance(2) = ThePSurfaceTool::VResolution(S,Precision::Confusion());
- Tolerance(3) = TheCurveTool::Resolution(C,Precision::Confusion());
+ Tolerance(1) = ThePSurfaceTool::UResolution(S, Precision::Confusion());
+ Tolerance(2) = ThePSurfaceTool::VResolution(S, Precision::Confusion());
+ Tolerance(3) = TheCurveTool::Resolution(C, Precision::Confusion());
Rsnld.SetTolerance(Tolerance);
- Standard_Integer autretentative=0;
- done=Standard_False;
- do {
- if(autretentative==1) {
- UVap(3)=w0;
+ Standard_Integer autretentative = 0;
+ done = Standard_False;
+ do
+ {
+ if (autretentative == 1)
+ {
+ UVap(3) = w0;
}
- else if(autretentative==2) {
- UVap(3)=w1;
+ else if (autretentative == 2)
+ {
+ UVap(3) = w1;
}
autretentative++;
- Rsnld.Perform(myFunction,UVap,BornInf,BornSup);
- if (Rsnld.IsDone()) {
+ Rsnld.Perform(myFunction, UVap, BornInf, BornSup);
+ if (Rsnld.IsDone())
+ {
Standard_Real AbsmyFunctionRoot = Abs(myFunction.Root());
- if (AbsmyFunctionRoot <= tol) {
- Rsnld.Root(UVap);
- u = UVap(1);
- v = UVap(2);
- w = UVap(3);
- empty = Standard_False;
- done=Standard_True;
+ if (AbsmyFunctionRoot <= tol)
+ {
+ Rsnld.Root(UVap);
+ u = UVap(1);
+ v = UVap(2);
+ w = UVap(3);
+ empty = Standard_False;
+ done = Standard_True;
}
}
- }
- while(done==Standard_False && autretentative<3);
+ } while (done == Standard_False && autretentative < 3);
}
-Standard_Boolean IntImp_IntCS::IsDone() const { return done;}
+Standard_Boolean IntImp_IntCS::IsDone() const
+{
+ return done;
+}
-Standard_Boolean IntImp_IntCS::IsEmpty()const {
- if (!done) throw StdFail_NotDone();
+Standard_Boolean IntImp_IntCS::IsEmpty() const
+{
+ if (!done)
+ throw StdFail_NotDone();
return empty;
}
const gp_Pnt& IntImp_IntCS::Point() const
-{
- if (!done) throw StdFail_NotDone();
- if (empty) throw Standard_DomainError();
+{
+ if (!done)
+ throw StdFail_NotDone();
+ if (empty)
+ throw Standard_DomainError();
return myFunction.Point();
}
-void IntImp_IntCS::ParameterOnSurface(Standard_Real& U,
- Standard_Real& V) const
-{
- if (!done) throw StdFail_NotDone();
- if (empty) throw Standard_DomainError();
- U=u;
- V=v;
+void IntImp_IntCS::ParameterOnSurface(Standard_Real& U, Standard_Real& V) const
+{
+ if (!done)
+ throw StdFail_NotDone();
+ if (empty)
+ throw Standard_DomainError();
+ U = u;
+ V = v;
}
-Standard_Real IntImp_IntCS::ParameterOnCurve() const
-{
- if (!done) throw StdFail_NotDone();
- if (empty) throw Standard_DomainError();
+
+Standard_Real IntImp_IntCS::ParameterOnCurve() const
+{
+ if (!done)
+ throw StdFail_NotDone();
+ if (empty)
+ throw Standard_DomainError();
return w;
}
-TheFunction& IntImp_IntCS::Function() {return myFunction;}
+TheFunction& IntImp_IntCS::Function()
+{
+ return myFunction;
+}
#include <gp_Vec.hxx>
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
-IntImp_ZerCSParFunc::IntImp_ZerCSParFunc(const ThePSurface& S,
- const TheCurve& C) {
+IntImp_ZerCSParFunc::IntImp_ZerCSParFunc(const ThePSurface& S, const TheCurve& C)
+{
surface = S;
- curve = C;
- p = gp_Pnt(0.0,0.0,0.0);
- f = 0.0;
+ curve = C;
+ p = gp_Pnt(0.0, 0.0, 0.0);
+ f = 0.0;
}
-Standard_Integer IntImp_ZerCSParFunc::NbVariables()const { return 3;}
+Standard_Integer IntImp_ZerCSParFunc::NbVariables() const
+{
+ return 3;
+}
-Standard_Integer IntImp_ZerCSParFunc::NbEquations()const { return 3;}
+Standard_Integer IntImp_ZerCSParFunc::NbEquations() const
+{
+ return 3;
+}
-Standard_Boolean IntImp_ZerCSParFunc::Value(const math_Vector& X,
- math_Vector& F){
+Standard_Boolean IntImp_ZerCSParFunc::Value(const math_Vector& X, math_Vector& F)
+{
- gp_Pnt Psurf = ThePSurfaceTool::Value(surface,X(1),X(2));
- gp_Pnt Pcurv = TheCurveTool::Value(curve,X(3));
- Standard_Real f1,f2,f3;
- F(1) = f1 = Psurf.X()-Pcurv.X();
- F(2) = f2 = Psurf.Y()-Pcurv.Y();
- F(3) = f3 = Psurf.Z()-Pcurv.Z();
- f = f1*f1 + f2*f2 + f3*f3;
- p = gp_Pnt((Psurf.XYZ()+Pcurv.XYZ())*0.5);
+ gp_Pnt Psurf = ThePSurfaceTool::Value(surface, X(1), X(2));
+ gp_Pnt Pcurv = TheCurveTool::Value(curve, X(3));
+ Standard_Real f1, f2, f3;
+ F(1) = f1 = Psurf.X() - Pcurv.X();
+ F(2) = f2 = Psurf.Y() - Pcurv.Y();
+ F(3) = f3 = Psurf.Z() - Pcurv.Z();
+ f = f1 * f1 + f2 * f2 + f3 * f3;
+ p = gp_Pnt((Psurf.XYZ() + Pcurv.XYZ()) * 0.5);
return Standard_True;
}
-Standard_Boolean IntImp_ZerCSParFunc::Derivatives ( const math_Vector& X,
- math_Matrix& D) {
- gp_Pnt Psurf,Pcurv;
- gp_Vec D1u,D1v,D1w;
- ThePSurfaceTool::D1(surface,X(1),X(2),Psurf,D1u,D1v);
- TheCurveTool::D1(curve,X(3),Pcurv,D1w);
- D(1,1) = D1u.X();
- D(1,2) = D1v.X();
- D(1,3) = -D1w.X();
- D(2,1) = D1u.Y();
- D(2,2) = D1v.Y();
- D(2,3) = -D1w.Y();
- D(3,1) = D1u.Z();
- D(3,2) = D1v.Z();
- D(3,3) = -D1w.Z();
+Standard_Boolean IntImp_ZerCSParFunc::Derivatives(const math_Vector& X, math_Matrix& D)
+{
+ gp_Pnt Psurf, Pcurv;
+ gp_Vec D1u, D1v, D1w;
+ ThePSurfaceTool::D1(surface, X(1), X(2), Psurf, D1u, D1v);
+ TheCurveTool::D1(curve, X(3), Pcurv, D1w);
+ D(1, 1) = D1u.X();
+ D(1, 2) = D1v.X();
+ D(1, 3) = -D1w.X();
+ D(2, 1) = D1u.Y();
+ D(2, 2) = D1v.Y();
+ D(2, 3) = -D1w.Y();
+ D(3, 1) = D1u.Z();
+ D(3, 2) = D1v.Z();
+ D(3, 3) = -D1w.Z();
return Standard_True;
-}
+}
-Standard_Boolean IntImp_ZerCSParFunc::Values( const math_Vector& X,
- math_Vector& F,
- math_Matrix& D) {
- gp_Pnt Psurf,Pcurv;
- gp_Vec D1u,D1v,D1w;
- ThePSurfaceTool::D1(surface,X(1),X(2),Psurf,D1u,D1v);
- TheCurveTool::D1(curve,X(3),Pcurv,D1w);
- D(1,1) = D1u.X();
- D(1,2) = D1v.X();
- D(1,3) = -D1w.X();
- D(2,1) = D1u.Y();
- D(2,2) = D1v.Y();
- D(2,3) = -D1w.Y();
- D(3,1) = D1u.Z();
- D(3,2) = D1v.Z();
- D(3,3) = -D1w.Z();
+Standard_Boolean IntImp_ZerCSParFunc::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
+{
+ gp_Pnt Psurf, Pcurv;
+ gp_Vec D1u, D1v, D1w;
+ ThePSurfaceTool::D1(surface, X(1), X(2), Psurf, D1u, D1v);
+ TheCurveTool::D1(curve, X(3), Pcurv, D1w);
+ D(1, 1) = D1u.X();
+ D(1, 2) = D1v.X();
+ D(1, 3) = -D1w.X();
+ D(2, 1) = D1u.Y();
+ D(2, 2) = D1v.Y();
+ D(2, 3) = -D1w.Y();
+ D(3, 1) = D1u.Z();
+ D(3, 2) = D1v.Z();
+ D(3, 3) = -D1w.Z();
- Standard_Real f1,f2,f3;
- F(1) = f1 = Psurf.X()-Pcurv.X();
- F(2) = f2 = Psurf.Y()-Pcurv.Y();
- F(3) = f3 = Psurf.Z()-Pcurv.Z();
- f = f1*f1 + f2*f2 + f3*f3;
- p = gp_Pnt((Psurf.XYZ()+Pcurv.XYZ())*0.5);
+ Standard_Real f1, f2, f3;
+ F(1) = f1 = Psurf.X() - Pcurv.X();
+ F(2) = f2 = Psurf.Y() - Pcurv.Y();
+ F(3) = f3 = Psurf.Z() - Pcurv.Z();
+ f = f1 * f1 + f2 * f2 + f3 * f3;
+ p = gp_Pnt((Psurf.XYZ() + Pcurv.XYZ()) * 0.5);
return Standard_True;
}
-const gp_Pnt& IntImp_ZerCSParFunc::Point() const { return p;}
+const gp_Pnt& IntImp_ZerCSParFunc::Point() const
+{
+ return p;
+}
-Standard_Real IntImp_ZerCSParFunc::Root() const { return f;}
+Standard_Real IntImp_ZerCSParFunc::Root() const
+{
+ return f;
+}
-const ThePSurface& IntImp_ZerCSParFunc::AuxillarSurface() const {
- return surface;}
+const ThePSurface& IntImp_ZerCSParFunc::AuxillarSurface() const
+{
+ return surface;
+}
-const TheCurve& IntImp_ZerCSParFunc::AuxillarCurve() const {
- return curve;}
+const TheCurve& IntImp_ZerCSParFunc::AuxillarCurve() const
+{
+ return curve;
+}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#define EpsAng 1.e-8
+#define EpsAng 1.e-8
#define EpsAng2 1.e-16
#define Tolpetit 1.e-16
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-#define SURF (*((ThePSurface *)(surf)))
-#define FUNC (*((TheISurface *)(func)))
+#define SURF (*((ThePSurface*)(surf)))
+#define FUNC (*((TheISurface*)(func)))
-
-IntImp_ZerImpFunc::IntImp_ZerImpFunc() :
- surf(NULL),
- func(NULL),
- u(0.0),
- v(0.0),
- tol(0.0),
- valf(0.0),
- computed(Standard_False),
- tangent(Standard_False),
- tgdu(0.0),
- tgdv(0.0),
- derived(Standard_False)
-{
+IntImp_ZerImpFunc::IntImp_ZerImpFunc()
+ : surf(NULL),
+ func(NULL),
+ u(0.0),
+ v(0.0),
+ tol(0.0),
+ valf(0.0),
+ computed(Standard_False),
+ tangent(Standard_False),
+ tgdu(0.0),
+ tgdv(0.0),
+ derived(Standard_False)
+{
}
-IntImp_ZerImpFunc::IntImp_ZerImpFunc(const ThePSurface& PS ,
- const TheISurface& IS) :
- u(0.0),
- v(0.0),
- tol(0.0),
- valf(0.0),
- computed(Standard_False),
- tangent(Standard_False),
- tgdu(0.0),
- tgdv(0.0),
- derived(Standard_False)
-{
+IntImp_ZerImpFunc::IntImp_ZerImpFunc(const ThePSurface& PS, const TheISurface& IS)
+ : u(0.0),
+ v(0.0),
+ tol(0.0),
+ valf(0.0),
+ computed(Standard_False),
+ tangent(Standard_False),
+ tgdu(0.0),
+ tgdv(0.0),
+ derived(Standard_False)
+{
surf = (Standard_Address)(&PS);
func = (Standard_Address)(&IS);
}
-IntImp_ZerImpFunc::IntImp_ZerImpFunc(const TheISurface& IS) :
- surf(NULL),
- u(0.0),
- v(0.0),
- tol(0.0),
- valf(0.0),
- computed(Standard_False),
- tangent(Standard_False),
- tgdu(0.0),
- tgdv(0.0),
- derived(Standard_False)
-{
+IntImp_ZerImpFunc::IntImp_ZerImpFunc(const TheISurface& IS)
+ : surf(NULL),
+ u(0.0),
+ v(0.0),
+ tol(0.0),
+ valf(0.0),
+ computed(Standard_False),
+ tangent(Standard_False),
+ tgdu(0.0),
+ tgdv(0.0),
+ derived(Standard_False)
+{
func = (Standard_Address)(&IS);
}
Standard_Integer IntImp_ZerImpFunc::NbVariables() const
-{
+{
return 2;
}
-Standard_Integer IntImp_ZerImpFunc::NbEquations() const
+Standard_Integer IntImp_ZerImpFunc::NbEquations() const
{
return 1;
}
-Standard_Boolean IntImp_ZerImpFunc::Value(const math_Vector& X,
- math_Vector& F)
+Standard_Boolean IntImp_ZerImpFunc::Value(const math_Vector& X, math_Vector& F)
{
- u = X(1);
- v = X(2);
- pntsol = ThePSurfaceTool::Value(SURF, u, v);
- valf = TheISurfaceTool::Value(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z());
- F(1) = valf;
+ u = X(1);
+ v = X(2);
+ pntsol = ThePSurfaceTool::Value(SURF, u, v);
+ valf = TheISurfaceTool::Value(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z());
+ F(1) = valf;
computed = Standard_False;
- derived = Standard_False;
+ derived = Standard_False;
return Standard_True;
}
-Standard_Boolean IntImp_ZerImpFunc::Derivatives(const math_Vector& X,
- math_Matrix& D)
+Standard_Boolean IntImp_ZerImpFunc::Derivatives(const math_Vector& X, math_Matrix& D)
{
u = X(1);
v = X(2);
ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v);
- TheISurfaceTool::Gradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(),gradient);
- D(1,1) = d1u.Dot(gradient);
- D(1,2) = d1v.Dot(gradient);
+ TheISurfaceTool::Gradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(), gradient);
+ D(1, 1) = d1u.Dot(gradient);
+ D(1, 2) = d1v.Dot(gradient);
computed = Standard_False;
- derived = Standard_True;
+ derived = Standard_True;
return Standard_True;
}
-Standard_Boolean IntImp_ZerImpFunc::Values(const math_Vector& X,
- math_Vector& F,
- math_Matrix& D)
+Standard_Boolean IntImp_ZerImpFunc::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
{
u = X(1);
v = X(2);
ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v);
- TheISurfaceTool::ValueAndGradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(),
- valf, gradient);
- F(1) = valf;
- D(1,1) = d1u.Dot(gradient);
- D(1,2) = d1v.Dot(gradient);
+ TheISurfaceTool::ValueAndGradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(), valf, gradient);
+ F(1) = valf;
+ D(1, 1) = d1u.Dot(gradient);
+ D(1, 2) = d1v.Dot(gradient);
computed = Standard_False;
- derived = Standard_True;
+ derived = Standard_True;
return Standard_True;
}
Standard_Boolean IntImp_ZerImpFunc::IsTangent()
{
- if (!computed) {
+ if (!computed)
+ {
computed = Standard_True;
- if(!derived) {
+ if (!derived)
+ {
ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v);
derived = Standard_True;
}
- tgdu = gradient.Dot(d1v);
- tgdv = -gradient.Dot(d1u);
- Standard_Real N2grad = gradient.SquareMagnitude();
+ tgdu = gradient.Dot(d1v);
+ tgdv = -gradient.Dot(d1u);
+ Standard_Real N2grad = gradient.SquareMagnitude();
Standard_Real N2grad_EpsAng2 = N2grad * EpsAng2;
- Standard_Real N2d1u = d1u.SquareMagnitude();
- Standard_Real N2d1v = d1v.SquareMagnitude();
- tangent =(tgdu * tgdu <= N2grad_EpsAng2 * N2d1v) &&
- (tgdv * tgdv <= N2grad_EpsAng2 * N2d1u);
- if(!tangent) {
- d3d.SetLinearForm(tgdu,d1u,tgdv,d1v);
+ Standard_Real N2d1u = d1u.SquareMagnitude();
+ Standard_Real N2d1v = d1v.SquareMagnitude();
+ tangent = (tgdu * tgdu <= N2grad_EpsAng2 * N2d1v) && (tgdv * tgdv <= N2grad_EpsAng2 * N2d1u);
+ if (!tangent)
+ {
+ d3d.SetLinearForm(tgdu, d1u, tgdv, d1v);
d2d = gp_Dir2d(tgdu, tgdv);
- if (d3d.Magnitude() <= Tolpetit) { // jag
+ if (d3d.Magnitude() <= Tolpetit)
+ { // jag
tangent = Standard_True;
}
- }
+ }
}
return tangent;
}
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
#include <IntImp_ComputeTangence.hxx>
#include <Standard_ConstructionError.hxx>
#include <Precision.hxx>
-#define SURF1 (*((ThePSurface *)(surf1)))
-#define SURF2 (*((ThePSurface *)(surf2)))
-
+#define SURF1 (*((ThePSurface*)(surf1)))
+#define SURF2 (*((ThePSurface*)(surf2)))
-IntImp_ZerParFunc::IntImp_ZerParFunc(const ThePSurface& S1 ,
- const ThePSurface& S2)
-: compute(Standard_False),
- tangent(Standard_False),
- paramConst(0.0)
+IntImp_ZerParFunc::IntImp_ZerParFunc(const ThePSurface& S1, const ThePSurface& S2)
+ : compute(Standard_False),
+ tangent(Standard_False),
+ paramConst(0.0)
{
- surf1 = (Standard_Address)(&S1);
- surf2 = (Standard_Address)(&S2);
-
- ua0 = ThePSurfaceTool::FirstUParameter(SURF1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
- va0 = ThePSurfaceTool::FirstVParameter(SURF1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
- ua1 = ThePSurfaceTool::LastUParameter(SURF1); //-- ThePSurfaceTool::UIntervalLast(surf1);
- va1 = ThePSurfaceTool::LastVParameter(SURF1); //-- ThePSurfaceTool::VIntervalLast(surf1);
-
- ub0 = ThePSurfaceTool::FirstUParameter(SURF2); //-- ThePSurfaceTool::UIntervalFirst(SURF2);
- vb0 = ThePSurfaceTool::FirstVParameter(SURF2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
- ub1 = ThePSurfaceTool::LastUParameter(SURF2); //-- ThePSurfaceTool::UIntervalLast(surf2);
- vb1 = ThePSurfaceTool::LastVParameter(SURF2); //-- ThePSurfaceTool::VIntervalLast(surf2);
-
- ures1 = ThePSurfaceTool::UResolution(SURF1,Precision::Confusion());
- vres1 = ThePSurfaceTool::VResolution(SURF1,Precision::Confusion());
-
- ures2 = ThePSurfaceTool::UResolution(SURF2,Precision::Confusion());
- vres2 = ThePSurfaceTool::VResolution(SURF2,Precision::Confusion());
- memset (f, 0, sizeof (f));
- compute = Standard_False;
- tangent = Standard_False;
+ surf1 = (Standard_Address)(&S1);
+ surf2 = (Standard_Address)(&S2);
+
+ ua0 = ThePSurfaceTool::FirstUParameter(SURF1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
+ va0 = ThePSurfaceTool::FirstVParameter(SURF1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
+ ua1 = ThePSurfaceTool::LastUParameter(SURF1); //-- ThePSurfaceTool::UIntervalLast(surf1);
+ va1 = ThePSurfaceTool::LastVParameter(SURF1); //-- ThePSurfaceTool::VIntervalLast(surf1);
+
+ ub0 = ThePSurfaceTool::FirstUParameter(SURF2); //-- ThePSurfaceTool::UIntervalFirst(SURF2);
+ vb0 = ThePSurfaceTool::FirstVParameter(SURF2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
+ ub1 = ThePSurfaceTool::LastUParameter(SURF2); //-- ThePSurfaceTool::UIntervalLast(surf2);
+ vb1 = ThePSurfaceTool::LastVParameter(SURF2); //-- ThePSurfaceTool::VIntervalLast(surf2);
+
+ ures1 = ThePSurfaceTool::UResolution(SURF1, Precision::Confusion());
+ vres1 = ThePSurfaceTool::VResolution(SURF1, Precision::Confusion());
+
+ ures2 = ThePSurfaceTool::UResolution(SURF2, Precision::Confusion());
+ vres2 = ThePSurfaceTool::VResolution(SURF2, Precision::Confusion());
+ memset(f, 0, sizeof(f));
+ compute = Standard_False;
+ tangent = Standard_False;
}
-Standard_Integer IntImp_ZerParFunc::NbVariables() const { return 3;}
+Standard_Integer IntImp_ZerParFunc::NbVariables() const
+{
+ return 3;
+}
-Standard_Integer IntImp_ZerParFunc::NbEquations() const { return 3;}
+Standard_Integer IntImp_ZerParFunc::NbEquations() const
+{
+ return 3;
+}
-Standard_Boolean IntImp_ZerParFunc::Value(const math_Vector& X,
- math_Vector& F) {
+Standard_Boolean IntImp_ZerParFunc::Value(const math_Vector& X, math_Vector& F)
+{
- switch (chxIso) {
- case IntImp_UIsoparametricOnCaro1:
- {
- pntsol1= ThePSurfaceTool::Value(SURF1,paramConst,X(1));
- pntsol2= ThePSurfaceTool::Value(SURF2,X(2),X(3));
+ switch (chxIso)
+ {
+ case IntImp_UIsoparametricOnCaro1: {
+ pntsol1 = ThePSurfaceTool::Value(SURF1, paramConst, X(1));
+ pntsol2 = ThePSurfaceTool::Value(SURF2, X(2), X(3));
}
break;
- case IntImp_VIsoparametricOnCaro1:
- {
- pntsol1= ThePSurfaceTool::Value(SURF1,X(1),paramConst);
- pntsol2= ThePSurfaceTool::Value(SURF2,X(2),X(3));
+ case IntImp_VIsoparametricOnCaro1: {
+ pntsol1 = ThePSurfaceTool::Value(SURF1, X(1), paramConst);
+ pntsol2 = ThePSurfaceTool::Value(SURF2, X(2), X(3));
}
break;
- case IntImp_UIsoparametricOnCaro2:
- {
- pntsol1= ThePSurfaceTool::Value(SURF1,X(1),X(2));
- pntsol2= ThePSurfaceTool::Value(SURF2,paramConst,X(3));
+ case IntImp_UIsoparametricOnCaro2: {
+ pntsol1 = ThePSurfaceTool::Value(SURF1, X(1), X(2));
+ pntsol2 = ThePSurfaceTool::Value(SURF2, paramConst, X(3));
}
break;
- case IntImp_VIsoparametricOnCaro2:
- {
- pntsol1= ThePSurfaceTool::Value(SURF1,X(1),X(2));
- pntsol2= ThePSurfaceTool::Value(SURF2,X(3),paramConst);
+ case IntImp_VIsoparametricOnCaro2: {
+ pntsol1 = ThePSurfaceTool::Value(SURF1, X(1), X(2));
+ pntsol2 = ThePSurfaceTool::Value(SURF2, X(3), paramConst);
}
break;
}
return Standard_True;
}
-Standard_Boolean IntImp_ZerParFunc::Derivatives (const math_Vector& X,
- math_Matrix& D) {
-
- switch (chxIso) {
- case IntImp_UIsoparametricOnCaro1:
- {
- ThePSurfaceTool::D1(SURF1,paramConst,X(1),pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[1].X();
- D(1,2) =-dpuv[2].X();
- D(1,3) =-dpuv[3].X();
- D(2,1) = dpuv[1].Y();
- D(2,2) =-dpuv[2].Y();
- D(2,3) =-dpuv[3].Y();
- D(3,1) = dpuv[1].Z();
- D(3,2) =-dpuv[2].Z();
- D(3,3) =-dpuv[3].Z();
+Standard_Boolean IntImp_ZerParFunc::Derivatives(const math_Vector& X, math_Matrix& D)
+{
+
+ switch (chxIso)
+ {
+ case IntImp_UIsoparametricOnCaro1: {
+ ThePSurfaceTool::D1(SURF1, paramConst, X(1), pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, X(2), X(3), pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[1].X();
+ D(1, 2) = -dpuv[2].X();
+ D(1, 3) = -dpuv[3].X();
+ D(2, 1) = dpuv[1].Y();
+ D(2, 2) = -dpuv[2].Y();
+ D(2, 3) = -dpuv[3].Y();
+ D(3, 1) = dpuv[1].Z();
+ D(3, 2) = -dpuv[2].Z();
+ D(3, 3) = -dpuv[3].Z();
}
break;
- case IntImp_VIsoparametricOnCaro1:
- {
- ThePSurfaceTool::D1(SURF1,X(1),paramConst,pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[0].X();
- D(1,2) =-dpuv[2].X();
- D(1,3) =-dpuv[3].X();
- D(2,1) = dpuv[0].Y();
- D(2,2) =-dpuv[2].Y();
- D(2,3) =-dpuv[3].Y();
- D(3,1) = dpuv[0].Z();
- D(3,2) =-dpuv[2].Z();
- D(3,3) =-dpuv[3].Z();
+ case IntImp_VIsoparametricOnCaro1: {
+ ThePSurfaceTool::D1(SURF1, X(1), paramConst, pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, X(2), X(3), pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[0].X();
+ D(1, 2) = -dpuv[2].X();
+ D(1, 3) = -dpuv[3].X();
+ D(2, 1) = dpuv[0].Y();
+ D(2, 2) = -dpuv[2].Y();
+ D(2, 3) = -dpuv[3].Y();
+ D(3, 1) = dpuv[0].Z();
+ D(3, 2) = -dpuv[2].Z();
+ D(3, 3) = -dpuv[3].Z();
}
break;
- case IntImp_UIsoparametricOnCaro2:
- {
- ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,paramConst,X(3),pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[0].X();
- D(1,2) = dpuv[1].X();
- D(1,3) =-dpuv[3].X();
- D(2,1) = dpuv[0].Y();
- D(2,2) = dpuv[1].Y();
- D(2,3) =-dpuv[3].Y();
- D(3,1) = dpuv[0].Z();
- D(3,2) = dpuv[1].Z();
- D(3,3) =-dpuv[3].Z();
+ case IntImp_UIsoparametricOnCaro2: {
+ ThePSurfaceTool::D1(SURF1, X(1), X(2), pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, paramConst, X(3), pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[0].X();
+ D(1, 2) = dpuv[1].X();
+ D(1, 3) = -dpuv[3].X();
+ D(2, 1) = dpuv[0].Y();
+ D(2, 2) = dpuv[1].Y();
+ D(2, 3) = -dpuv[3].Y();
+ D(3, 1) = dpuv[0].Z();
+ D(3, 2) = dpuv[1].Z();
+ D(3, 3) = -dpuv[3].Z();
}
break;
- case IntImp_VIsoparametricOnCaro2:
- {
- ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,X(3),paramConst,pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[0].X();
- D(1,2) = dpuv[1].X();
- D(1,3) =-dpuv[2].X();
- D(2,1) = dpuv[0].Y();
- D(2,2) = dpuv[1].Y();
- D(2,3) =-dpuv[2].Y();
- D(3,1) = dpuv[0].Z();
- D(3,2) = dpuv[1].Z();
- D(3,3) =-dpuv[2].Z();
+ case IntImp_VIsoparametricOnCaro2: {
+ ThePSurfaceTool::D1(SURF1, X(1), X(2), pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, X(3), paramConst, pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[0].X();
+ D(1, 2) = dpuv[1].X();
+ D(1, 3) = -dpuv[2].X();
+ D(2, 1) = dpuv[0].Y();
+ D(2, 2) = dpuv[1].Y();
+ D(2, 3) = -dpuv[2].Y();
+ D(3, 1) = dpuv[0].Z();
+ D(3, 2) = dpuv[1].Z();
+ D(3, 3) = -dpuv[2].Z();
}
break;
}
return Standard_True;
}
-Standard_Boolean IntImp_ZerParFunc::Values( const math_Vector& X,
- math_Vector& F,
- math_Matrix& D) {
-
- switch (chxIso) {
- case IntImp_UIsoparametricOnCaro1:
- {
- ThePSurfaceTool::D1(SURF1,paramConst,X(1),pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[1].X();
- D(1,2) =-dpuv[2].X();
- D(1,3) =-dpuv[3].X();
- D(2,1) = dpuv[1].Y();
- D(2,2) =-dpuv[2].Y();
- D(2,3) =-dpuv[3].Y();
- D(3,1) = dpuv[1].Z();
- D(3,2) =-dpuv[2].Z();
- D(3,3) =-dpuv[3].Z();
+Standard_Boolean IntImp_ZerParFunc::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
+{
+
+ switch (chxIso)
+ {
+ case IntImp_UIsoparametricOnCaro1: {
+ ThePSurfaceTool::D1(SURF1, paramConst, X(1), pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, X(2), X(3), pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[1].X();
+ D(1, 2) = -dpuv[2].X();
+ D(1, 3) = -dpuv[3].X();
+ D(2, 1) = dpuv[1].Y();
+ D(2, 2) = -dpuv[2].Y();
+ D(2, 3) = -dpuv[3].Y();
+ D(3, 1) = dpuv[1].Z();
+ D(3, 2) = -dpuv[2].Z();
+ D(3, 3) = -dpuv[3].Z();
}
break;
- case IntImp_VIsoparametricOnCaro1:
- {
- ThePSurfaceTool::D1(SURF1,X(1),paramConst,pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[0].X();
- D(1,2) =-dpuv[2].X();
- D(1,3) =-dpuv[3].X();
- D(2,1) = dpuv[0].Y();
- D(2,2) =-dpuv[2].Y();
- D(2,3) =-dpuv[3].Y();
- D(3,1) = dpuv[0].Z();
- D(3,2) =-dpuv[2].Z();
- D(3,3) =-dpuv[3].Z();
+ case IntImp_VIsoparametricOnCaro1: {
+ ThePSurfaceTool::D1(SURF1, X(1), paramConst, pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, X(2), X(3), pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[0].X();
+ D(1, 2) = -dpuv[2].X();
+ D(1, 3) = -dpuv[3].X();
+ D(2, 1) = dpuv[0].Y();
+ D(2, 2) = -dpuv[2].Y();
+ D(2, 3) = -dpuv[3].Y();
+ D(3, 1) = dpuv[0].Z();
+ D(3, 2) = -dpuv[2].Z();
+ D(3, 3) = -dpuv[3].Z();
}
break;
- case IntImp_UIsoparametricOnCaro2:
- {
- ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,paramConst,X(3),pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[0].X();
- D(1,2) = dpuv[1].X();
- D(1,3) =-dpuv[3].X();
- D(2,1) = dpuv[0].Y();
- D(2,2) = dpuv[1].Y();
- D(2,3) =-dpuv[3].Y();
- D(3,1) = dpuv[0].Z();
- D(3,2) = dpuv[1].Z();
- D(3,3) =-dpuv[3].Z();
+ case IntImp_UIsoparametricOnCaro2: {
+ ThePSurfaceTool::D1(SURF1, X(1), X(2), pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, paramConst, X(3), pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[0].X();
+ D(1, 2) = dpuv[1].X();
+ D(1, 3) = -dpuv[3].X();
+ D(2, 1) = dpuv[0].Y();
+ D(2, 2) = dpuv[1].Y();
+ D(2, 3) = -dpuv[3].Y();
+ D(3, 1) = dpuv[0].Z();
+ D(3, 2) = dpuv[1].Z();
+ D(3, 3) = -dpuv[3].Z();
}
break;
- case IntImp_VIsoparametricOnCaro2:
- {
- ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
- ThePSurfaceTool::D1(SURF2,X(3),paramConst,pntsol2,dpuv[2],dpuv[3]);
- D(1,1) = dpuv[0].X();
- D(1,2) = dpuv[1].X();
- D(1,3) =-dpuv[2].X();
- D(2,1) = dpuv[0].Y();
- D(2,2) = dpuv[1].Y();
- D(2,3) =-dpuv[2].Y();
- D(3,1) = dpuv[0].Z();
- D(3,2) = dpuv[1].Z();
- D(3,3) =-dpuv[2].Z();
+ case IntImp_VIsoparametricOnCaro2: {
+ ThePSurfaceTool::D1(SURF1, X(1), X(2), pntsol1, dpuv[0], dpuv[1]);
+ ThePSurfaceTool::D1(SURF2, X(3), paramConst, pntsol2, dpuv[2], dpuv[3]);
+ D(1, 1) = dpuv[0].X();
+ D(1, 2) = dpuv[1].X();
+ D(1, 3) = -dpuv[2].X();
+ D(2, 1) = dpuv[0].Y();
+ D(2, 2) = dpuv[1].Y();
+ D(2, 3) = -dpuv[2].Y();
+ D(3, 1) = dpuv[0].Z();
+ D(3, 2) = dpuv[1].Z();
+ D(3, 3) = -dpuv[2].Z();
}
break;
}
return Standard_True;
}
-void IntImp_ZerParFunc::ComputeParameters(
- const IntImp_ConstIsoparametric ChoixIso,
- const TColStd_Array1OfReal& Param,
- math_Vector& UVap,
- math_Vector& BornInf,
- math_Vector& BornSup,
- math_Vector& Tolerance ) {
+void IntImp_ZerParFunc::ComputeParameters(const IntImp_ConstIsoparametric ChoixIso,
+ const TColStd_Array1OfReal& Param,
+ math_Vector& UVap,
+ math_Vector& BornInf,
+ math_Vector& BornSup,
+ math_Vector& Tolerance)
+{
chxIso = ChoixIso;
- switch (chxIso) {
- case IntImp_UIsoparametricOnCaro1:
- {
+ switch (chxIso)
+ {
+ case IntImp_UIsoparametricOnCaro1: {
paramConst = Param(1);
- UVap(1) = Param(2);
- UVap(2) = Param(3);
- UVap(3) = Param(4);
-
+ UVap(1) = Param(2);
+ UVap(2) = Param(3);
+ UVap(3) = Param(4);
+
BornInf(1) = va0;
BornSup(1) = va1;
-
+
BornInf(2) = ub0;
BornInf(3) = vb0;
BornSup(2) = ub1;
BornSup(3) = vb1;
-
- Tolerance(1)= vres1;
- Tolerance(2)= ures2;
- Tolerance(3)= vres2;
+
+ Tolerance(1) = vres1;
+ Tolerance(2) = ures2;
+ Tolerance(3) = vres2;
}
break;
- case IntImp_VIsoparametricOnCaro1:
- {
+ case IntImp_VIsoparametricOnCaro1: {
paramConst = Param(2);
- UVap(1) = Param(1);
- UVap(2) = Param(3);
- UVap(3) = Param(4);
+ UVap(1) = Param(1);
+ UVap(2) = Param(3);
+ UVap(3) = Param(4);
BornInf(1) = ua0;
BornSup(1) = ua1;
-
+
BornInf(2) = ub0;
BornSup(2) = ub1;
BornInf(3) = vb0;
BornSup(3) = vb1;
- Tolerance(1)= ures1;
- Tolerance(2)= ures2;
- Tolerance(3)= vres2;
+ Tolerance(1) = ures1;
+ Tolerance(2) = ures2;
+ Tolerance(3) = vres2;
}
break;
- case IntImp_UIsoparametricOnCaro2:
- {
- paramConst = Param(3);
- UVap(1) = Param(1);
- UVap(2) = Param(2);
- UVap(3) = Param(4);
-
+ case IntImp_UIsoparametricOnCaro2: {
+ paramConst = Param(3);
+ UVap(1) = Param(1);
+ UVap(2) = Param(2);
+ UVap(3) = Param(4);
+
BornInf(1) = ua0;
BornSup(1) = ua1;
BornInf(2) = va0;
BornSup(2) = va1;
-
+
BornInf(3) = vb0;
BornSup(3) = vb1;
- Tolerance(1)= ures1;
- Tolerance(2)= vres1;
- Tolerance(3)= vres2;
+ Tolerance(1) = ures1;
+ Tolerance(2) = vres1;
+ Tolerance(3) = vres2;
}
break;
- case IntImp_VIsoparametricOnCaro2:
- {
- paramConst = Param(4);
- UVap(1) = Param(1);
- UVap(2) = Param(2);
- UVap(3) = Param(3);
-
+ case IntImp_VIsoparametricOnCaro2: {
+ paramConst = Param(4);
+ UVap(1) = Param(1);
+ UVap(2) = Param(2);
+ UVap(3) = Param(3);
+
BornInf(1) = ua0;
BornSup(1) = ua1;
BornInf(2) = va0;
BornInf(3) = ub0;
BornSup(3) = ub1;
- Tolerance(1)= ures1;
- Tolerance(2)= vres1;
- Tolerance(3)= ures2;
+ Tolerance(1) = ures1;
+ Tolerance(2) = vres1;
+ Tolerance(3) = ures2;
}
break;
}
- Standard_Real Incr1 = (BornSup(1)-BornInf(1))*0.01;
- Standard_Real Incr2 = (BornSup(2)-BornInf(2))*0.01;
- Standard_Real Incr3 = (BornSup(3)-BornInf(3))*0.01;
+ Standard_Real Incr1 = (BornSup(1) - BornInf(1)) * 0.01;
+ Standard_Real Incr2 = (BornSup(2) - BornInf(2)) * 0.01;
+ Standard_Real Incr3 = (BornSup(3) - BornInf(3)) * 0.01;
BornInf(1) -= Incr1;
BornSup(1) += Incr1;
BornInf(2) -= Incr2;
BornSup(2) += Incr2;
BornInf(3) -= Incr3;
BornSup(3) += Incr3;
-}
-
+}
-Standard_Boolean IntImp_ZerParFunc::IsTangent(
- const math_Vector& UVap,
- TColStd_Array1OfReal& Param,
- IntImp_ConstIsoparametric& BestChoix)
+Standard_Boolean IntImp_ZerParFunc::IsTangent(const math_Vector& UVap,
+ TColStd_Array1OfReal& Param,
+ IntImp_ConstIsoparametric& BestChoix)
{
- switch (chxIso) {
- case IntImp_UIsoparametricOnCaro1:
- {
+ switch (chxIso)
+ {
+ case IntImp_UIsoparametricOnCaro1: {
Param(1) = paramConst;
- Param(2) = UVap(1) ;
- Param(3) = UVap(2) ;
- Param(4) = UVap(3) ;
+ Param(2) = UVap(1);
+ Param(3) = UVap(2);
+ Param(4) = UVap(3);
}
break;
- case IntImp_VIsoparametricOnCaro1:
- {
+ case IntImp_VIsoparametricOnCaro1: {
Param(2) = paramConst;
- Param(1) = UVap(1) ;
- Param(3) = UVap(2) ;
- Param(4) = UVap(3) ;
+ Param(1) = UVap(1);
+ Param(3) = UVap(2);
+ Param(4) = UVap(3);
}
break;
- case IntImp_UIsoparametricOnCaro2:
- {
+ case IntImp_UIsoparametricOnCaro2: {
Param(3) = paramConst;
- Param(1) = UVap(1) ;
- Param(2) = UVap(2) ;
- Param(4) = UVap(3) ;
+ Param(1) = UVap(1);
+ Param(2) = UVap(2);
+ Param(4) = UVap(3);
}
break;
- case IntImp_VIsoparametricOnCaro2:
- {
+ case IntImp_VIsoparametricOnCaro2: {
Param(4) = paramConst;
- Param(1) = UVap(1) ;
- Param(2) = UVap(2) ;
- Param(3) = UVap(3) ;
+ Param(1) = UVap(1);
+ Param(2) = UVap(2);
+ Param(3) = UVap(3);
}
break;
}
IntImp_ConstIsoparametric TabIso[4];
- Standard_Real EpsUV[4];
+ Standard_Real EpsUV[4];
EpsUV[0] = ures1;
EpsUV[1] = vres1;
-
+
EpsUV[2] = ures2;
EpsUV[3] = vres2;
-
- tangent = IntImp_ComputeTangence(dpuv,EpsUV,tgduv,TabIso);
- if (!tangent)
+ tangent = IntImp_ComputeTangence(dpuv, EpsUV, tgduv, TabIso);
+ if (!tangent)
chxIso = TabIso[0];
BestChoix = chxIso;
return tangent;
}
-
#undef SURF1
#undef SURF2
-
-
-
-
-
-
-
#include <gp_Vec2d.hxx>
-
-
-IntImpParGen_ImpParTool::IntImpParGen_ImpParTool(const ImpTool& ITool,
- const ParCurve& PC):
- TheImpTool(ITool)
-{
+IntImpParGen_ImpParTool::IntImpParGen_ImpParTool(const ImpTool& ITool, const ParCurve& PC)
+ : TheImpTool(ITool)
+{
TheParCurve = (Standard_Address)(&PC);
}
-
Standard_Boolean IntImpParGen_ImpParTool::Value(const Standard_Real Param,
- Standard_Real& ApproxDistance) {
-
- ApproxDistance = TheImpTool.Distance(ParTool::Value((*((ParCurve *)(TheParCurve))),Param));
- return(Standard_True);
+ Standard_Real& ApproxDistance)
+{
+
+ ApproxDistance = TheImpTool.Distance(ParTool::Value((*((ParCurve*)(TheParCurve))), Param));
+ return (Standard_True);
}
Standard_Boolean IntImpParGen_ImpParTool::Derivative(const Standard_Real Param,
- Standard_Real& D_ApproxDistance_DV) {
-
+ Standard_Real& D_ApproxDistance_DV)
+{
+
gp_Pnt2d Pt;
gp_Vec2d TanParCurve;
- gp_Vec2d Grad=TheImpTool.GradDistance(ParTool::Value((*((ParCurve *)(TheParCurve))),Param));
- ParTool::D1((*((ParCurve *)(TheParCurve))),Param,Pt,TanParCurve);
+ gp_Vec2d Grad = TheImpTool.GradDistance(ParTool::Value((*((ParCurve*)(TheParCurve))), Param));
+ ParTool::D1((*((ParCurve*)(TheParCurve))), Param, Pt, TanParCurve);
D_ApproxDistance_DV = Grad.Dot(TanParCurve);
- return(Standard_True);
+ return (Standard_True);
}
-
Standard_Boolean IntImpParGen_ImpParTool::Values(const Standard_Real Param,
- Standard_Real& ApproxDistance,
- Standard_Real& Deriv) {
-
- this->Value(Param,ApproxDistance);
- this->Derivative(Param,Deriv);
- return(Standard_True);
-}
-
-
+ Standard_Real& ApproxDistance,
+ Standard_Real& Deriv)
+{
+ this->Value(Param, ApproxDistance);
+ this->Derivative(Param, Deriv);
+ return (Standard_True);
+}
//======================================================================
#define EPSDIST Tol
-#define EPSNUL TolConf
-#define EPSX ParTool::EpsX(TheParCurve)
-#define NB_ECHANTILLONS
+#define EPSNUL TolConf
+#define EPSX ParTool::EpsX(TheParCurve)
+#define NB_ECHANTILLONS
+//=================================================================================================
-
-
-//======================================================================
-void IntImpParGen_Intersector::And_Domaine_Objet1_Intersections(const ImpTool& TheImpTool,
- const ParCurve& TheParCurve,
+void IntImpParGen_Intersector::And_Domaine_Objet1_Intersections(
+ const ImpTool& TheImpTool,
+ const ParCurve& TheParCurve,
const IntRes2d_Domain& TheImpCurveDomain,
const IntRes2d_Domain& TheParCurveDomain,
- Standard_Integer& NbResultats,
- TColStd_Array1OfReal& Inter2_And_Domain2,
- TColStd_Array1OfReal& Inter1,
- TColStd_Array1OfReal& Resultat1,
- TColStd_Array1OfReal& Resultat2,
- const Standard_Real EpsNul) const {
-
+ Standard_Integer& NbResultats,
+ TColStd_Array1OfReal& Inter2_And_Domain2,
+ TColStd_Array1OfReal& Inter1,
+ TColStd_Array1OfReal& Resultat1,
+ TColStd_Array1OfReal& Resultat2,
+ const Standard_Real EpsNul) const
+{
Standard_Integer Nb_Bornes_Intersection = NbResultats;
- NbResultats = 0;
+ NbResultats = 0;
- for (Standard_Integer i = 1; i <= Nb_Bornes_Intersection; i += 2) {
+ for (Standard_Integer i = 1; i <= Nb_Bornes_Intersection; i += 2)
+ {
Standard_Real param1 = Inter1.Value(i);
Standard_Real param2 = Inter1.Value(i + 1);
Standard_Integer indice_1 = i;
Standard_Integer indice_2 = i + 1;
- if (param1>param2) {
- Standard_Real t = param1; param1 = param2; param2 = t;
- indice_1 = i + 1;
- indice_2 = i;
+ if (param1 > param2)
+ {
+ Standard_Real t = param1;
+ param1 = param2;
+ param2 = t;
+ indice_1 = i + 1;
+ indice_2 = i;
}
gp_Pnt2d Pt1 = TheImpTool.Value(param1);
Standard_Boolean IsOnTheImpCurveDomain2 = Standard_True;
//--------------------------------------------------------------------
- if (TheImpCurveDomain.HasFirstPoint()) {
- if (param1<TheImpCurveDomain.FirstParameter()) {
- if (Pt1.Distance(TheImpCurveDomain.FirstPoint())
- > TheImpCurveDomain.FirstTolerance()) {
+ if (TheImpCurveDomain.HasFirstPoint())
+ {
+ if (param1 < TheImpCurveDomain.FirstParameter())
+ {
+ if (Pt1.Distance(TheImpCurveDomain.FirstPoint()) > TheImpCurveDomain.FirstTolerance())
+ {
IsOnTheImpCurveDomain1 = Standard_False;
}
}
}
- if (IsOnTheImpCurveDomain1 && TheImpCurveDomain.HasLastPoint()) {
- if (param1>TheImpCurveDomain.LastParameter()) {
- if (Pt1.Distance(TheImpCurveDomain.LastPoint())
- > TheImpCurveDomain.FirstTolerance()) {
+ if (IsOnTheImpCurveDomain1 && TheImpCurveDomain.HasLastPoint())
+ {
+ if (param1 > TheImpCurveDomain.LastParameter())
+ {
+ if (Pt1.Distance(TheImpCurveDomain.LastPoint()) > TheImpCurveDomain.FirstTolerance())
+ {
IsOnTheImpCurveDomain1 = Standard_False;
}
}
}
//--------------------------------------------------------------------
- if (TheImpCurveDomain.HasFirstPoint()) {
- if (param2<TheImpCurveDomain.FirstParameter()) {
- if (Pt2.Distance(TheImpCurveDomain.FirstPoint())
- > TheImpCurveDomain.FirstTolerance()) {
+ if (TheImpCurveDomain.HasFirstPoint())
+ {
+ if (param2 < TheImpCurveDomain.FirstParameter())
+ {
+ if (Pt2.Distance(TheImpCurveDomain.FirstPoint()) > TheImpCurveDomain.FirstTolerance())
+ {
IsOnTheImpCurveDomain2 = Standard_False;
}
}
}
- if (IsOnTheImpCurveDomain2 && TheImpCurveDomain.HasLastPoint()) {
- if (param2>TheImpCurveDomain.LastParameter()) {
- if (Pt2.Distance(TheImpCurveDomain.LastPoint())
- > TheImpCurveDomain.FirstTolerance()) {
+ if (IsOnTheImpCurveDomain2 && TheImpCurveDomain.HasLastPoint())
+ {
+ if (param2 > TheImpCurveDomain.LastParameter())
+ {
+ if (Pt2.Distance(TheImpCurveDomain.LastPoint()) > TheImpCurveDomain.FirstTolerance())
+ {
IsOnTheImpCurveDomain2 = Standard_False;
}
}
}
- if (IsOnTheImpCurveDomain1) {
+ if (IsOnTheImpCurveDomain1)
+ {
//------------------------------------------------------------------
//--- la borne 1 est sur le domaine --
NbResultats++;
Resultat1.SetValue(NbResultats, Inter1.Value(indice_1));
Resultat2.SetValue(NbResultats, Inter2_And_Domain2.Value(indice_1));
//--- la borne2 est aussi sur le domaine ---
- if (IsOnTheImpCurveDomain2) {
+ if (IsOnTheImpCurveDomain2)
+ {
NbResultats++;
Resultat1.SetValue(NbResultats, Inter1.Value(indice_2));
Resultat2.SetValue(NbResultats, Inter2_And_Domain2.Value(indice_2));
}
- else {
+ else
+ {
//--- Borne1 sur domaine et Borne 2 Hors Domaine ---
Standard_Real t;
NbResultats++;
// Inter2_And_Domain2.Value(indice_1),
// Inter2_And_Domain2.Value(indice_2),
// EpsNul);
- //
+ //
// Resultat2.SetValue(NbResultats,popResult);
Resultat2.SetValue(NbResultats,
- IntImpParGen_Intersector::FindV(t, Pt, TheImpTool, TheParCurve,
- TheParCurveDomain,
- Inter2_And_Domain2.Value(indice_1),
- Inter2_And_Domain2.Value(indice_2),
- EpsNul));
+ IntImpParGen_Intersector::FindV(t,
+ Pt,
+ TheImpTool,
+ TheParCurve,
+ TheParCurveDomain,
+ Inter2_And_Domain2.Value(indice_1),
+ Inter2_And_Domain2.Value(indice_2),
+ EpsNul));
}
}
- else { //======= la borne1 n est pas sur le domaine ========
- if (IsOnTheImpCurveDomain2) {
+ else
+ { //======= la borne1 n est pas sur le domaine ========
+ if (IsOnTheImpCurveDomain2)
+ {
Standard_Real t;
NbResultats++;
t = TheImpCurveDomain.FirstParameter();
Resultat1.SetValue(NbResultats, t);
Resultat2.SetValue(NbResultats,
- IntImpParGen_Intersector::FindV(t, Pt, TheImpTool, TheParCurve,
- TheParCurveDomain,
- Inter2_And_Domain2.Value(indice_1),
- Inter2_And_Domain2.Value(indice_2),
- EpsNul));
+ IntImpParGen_Intersector::FindV(t,
+ Pt,
+ TheImpTool,
+ TheParCurve,
+ TheParCurveDomain,
+ Inter2_And_Domain2.Value(indice_1),
+ Inter2_And_Domain2.Value(indice_2),
+ EpsNul));
NbResultats++;
Resultat1.SetValue(NbResultats, Inter1.Value(indice_2));
Resultat2.SetValue(NbResultats, Inter2_And_Domain2.Value(indice_2));
}
- else { //====== la borne2 et la borne1 sont hors domaine =====
- if (param1<TheImpCurveDomain.FirstParameter()
- && param2>TheImpCurveDomain.LastParameter()) {
+ else
+ { //====== la borne2 et la borne1 sont hors domaine =====
+ if (param1 < TheImpCurveDomain.FirstParameter()
+ && param2 > TheImpCurveDomain.LastParameter())
+ {
Standard_Real t;
NbResultats++;
t = TheImpCurveDomain.FirstParameter();
Resultat1.SetValue(NbResultats, t);
Resultat2.SetValue(NbResultats,
- IntImpParGen_Intersector::FindV(t, Pt, TheImpTool, TheParCurve,
- TheParCurveDomain,
- Inter2_And_Domain2.Value(indice_1),
- Inter2_And_Domain2.Value(indice_2),
- EpsNul));
-
-
+ IntImpParGen_Intersector::FindV(t,
+ Pt,
+ TheImpTool,
+ TheParCurve,
+ TheParCurveDomain,
+ Inter2_And_Domain2.Value(indice_1),
+ Inter2_And_Domain2.Value(indice_2),
+ EpsNul));
NbResultats++;
t = TheImpCurveDomain.LastParameter();
Resultat1.SetValue(NbResultats, t);
Resultat2.SetValue(NbResultats,
- IntImpParGen_Intersector::FindV(t, Pt, TheImpTool, TheParCurve,
- TheParCurveDomain,
- Inter2_And_Domain2.Value(indice_1),
- Inter2_And_Domain2.Value(indice_2),
- EpsNul));
-
+ IntImpParGen_Intersector::FindV(t,
+ Pt,
+ TheImpTool,
+ TheParCurve,
+ TheParCurveDomain,
+ Inter2_And_Domain2.Value(indice_1),
+ Inter2_And_Domain2.Value(indice_2),
+ EpsNul));
}
}
}
}
}
+
//======================================================================
-//-- C o n s t r u c t e u r s e t P e r f o r m
-IntImpParGen_Intersector::IntImpParGen_Intersector() {
+//-- C o n s t r u c t e u r s e t P e r f o r m
+IntImpParGen_Intersector::IntImpParGen_Intersector()
+{
done = Standard_False;
}
+
//----------------------------------------------------------------------
//--
-IntImpParGen_Intersector::IntImpParGen_Intersector(const ImpTool& TheImpTool,
- const IntRes2d_Domain& TheImpCurveDomain,
- const ParCurve& TheParCurve,
- const IntRes2d_Domain& TheParCurveDomain,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
+IntImpParGen_Intersector::IntImpParGen_Intersector(const ImpTool& TheImpTool,
+ const IntRes2d_Domain& TheImpCurveDomain,
+ const ParCurve& TheParCurve,
+ const IntRes2d_Domain& TheParCurveDomain,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
Perform(TheImpTool, TheImpCurveDomain, TheParCurve, TheParCurveDomain, TolConf, Tol);
}
+
//----------------------------------------------------------------------
//--
-void IntImpParGen_Intersector::Perform(const ImpTool& TheImpTool,
- const IntRes2d_Domain& TheImpCurveDomain,
- const ParCurve& TheParCurve,
- const IntRes2d_Domain& TheParCurveDomain,
- const Standard_Real TolConf,
- const Standard_Real Tol) {
-
+void IntImpParGen_Intersector::Perform(const ImpTool& TheImpTool,
+ const IntRes2d_Domain& TheImpCurveDomain,
+ const ParCurve& TheParCurve,
+ const IntRes2d_Domain& TheParCurveDomain,
+ const Standard_Real TolConf,
+ const Standard_Real Tol)
+{
Standard_Integer i, nb_segments_solution, nb_points_solution;
- Standard_Real param1, param2, EpsX, EpsNul, EpsDist;
+ Standard_Real param1, param2, EpsX, EpsNul, EpsDist;
IntRes2d_Transition Trans1, Trans2;
- gp_Pnt2d pt1, pt2;
- gp_Vec2d Tan1, Tan2, Norm1, Norm2;
- IntRes2d_Position Pos1, Pos2;
-
+ gp_Pnt2d pt1, pt2;
+ gp_Vec2d Tan1, Tan2, Norm1, Norm2;
+ IntRes2d_Position Pos1, Pos2;
//----------------------------------------------
- //-- On teste apres appel aux maths si les bornes
+ //-- On teste apres appel aux maths si les bornes
//-- des domaines sont des solutions
- //--
+ //--
Standard_Boolean HeadOnImp = Standard_False;
Standard_Boolean HeadOnPar = Standard_False;
- Standard_Boolean EndOnImp = Standard_False;
- Standard_Boolean EndOnPar = Standard_False;
+ Standard_Boolean EndOnImp = Standard_False;
+ Standard_Boolean EndOnPar = Standard_False;
this->ResetFields();
IntImpParGen_MyImpParTool TheImpParTool(TheImpTool, TheParCurve);
- if (!(TheParCurveDomain.HasFirstPoint() &&
- TheParCurveDomain.HasLastPoint())) {
+ if (!(TheParCurveDomain.HasFirstPoint() && TheParCurveDomain.HasLastPoint()))
+ {
throw Standard_ConstructionError("Domaine sur courbe incorrect");
}
Standard_Integer nb_echantillons = ParTool::NbSamples(TheParCurve,
- TheParCurveDomain.FirstParameter(),
- TheParCurveDomain.LastParameter());
+ TheParCurveDomain.FirstParameter(),
+ TheParCurveDomain.LastParameter());
EpsX = EPSX;
- if (EpsX>1.0e-10) EpsX = 1.0e-10;
- EpsNul = (TolConf <= 1.0e-10) ? 1.0e-10 : TolConf;
+ if (EpsX > 1.0e-10)
+ EpsX = 1.0e-10;
+ EpsNul = (TolConf <= 1.0e-10) ? 1.0e-10 : TolConf;
EpsDist = (Tol <= 1.0e-10) ? 1.0e-10 : Tol;
Standard_Real Tolerance_Angulaire = EpsDist;
-
-
- if ((TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter()) < 100.0*EpsX) {
- EpsX = (TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter())*0.01;
+ if ((TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter()) < 100.0 * EpsX)
+ {
+ EpsX = (TheParCurveDomain.LastParameter() - TheParCurveDomain.FirstParameter()) * 0.01;
}
math_FunctionSample Sample2(TheParCurveDomain.FirstParameter(),
- TheParCurveDomain.LastParameter(),
- nb_echantillons);
+ TheParCurveDomain.LastParameter(),
+ nb_echantillons);
- math_FunctionAllRoots Sol(TheImpParTool,
- Sample2,
- EpsX,
- EpsDist,
- EpsNul);
+ math_FunctionAllRoots Sol(TheImpParTool, Sample2, EpsX, EpsDist, EpsNul);
- if (!Sol.IsDone()) { done = Standard_False; return; }
+ if (!Sol.IsDone())
+ {
+ done = Standard_False;
+ return;
+ }
nb_segments_solution = Sol.NbIntervals();
- nb_points_solution = Sol.NbPoints();
+ nb_points_solution = Sol.NbPoints();
//--------------------------------------------------------------------
//-- T r a i t e m e n t d e s P o i n t s S o l u t i o n s
- for (i = 1; i <= nb_points_solution; i++) {
+ for (i = 1; i <= nb_points_solution; i++)
+ {
gp_Pnt2d Pt;
param2 = Sol.GetPoint(i);
param1 = FindU(param2, Pt, TheParCurve, TheImpTool);
- if (TheImpCurveDomain.IsClosed()) {
- param1 = IntImpParGen::NormalizeOnDomain(param1
- , TheImpCurveDomain);
+ if (TheImpCurveDomain.IsClosed())
+ {
+ param1 = IntImpParGen::NormalizeOnDomain(param1, TheImpCurveDomain);
}
Standard_Boolean IsOnTheImpCurveDomain = Standard_True;
- if (TheImpCurveDomain.HasFirstPoint()) {
- if (param1<TheImpCurveDomain.FirstParameter()) {
- if (Pt.Distance(TheImpCurveDomain.FirstPoint())
- > TheImpCurveDomain.FirstTolerance()) {
+ if (TheImpCurveDomain.HasFirstPoint())
+ {
+ if (param1 < TheImpCurveDomain.FirstParameter())
+ {
+ if (Pt.Distance(TheImpCurveDomain.FirstPoint()) > TheImpCurveDomain.FirstTolerance())
+ {
IsOnTheImpCurveDomain = Standard_False;
}
}
}
- if (IsOnTheImpCurveDomain && TheImpCurveDomain.HasLastPoint()) {
- if (param1>TheImpCurveDomain.LastParameter()) {
- if (Pt.Distance(TheImpCurveDomain.LastPoint())
- > TheImpCurveDomain.FirstTolerance()) {
+ if (IsOnTheImpCurveDomain && TheImpCurveDomain.HasLastPoint())
+ {
+ if (param1 > TheImpCurveDomain.LastParameter())
+ {
+ if (Pt.Distance(TheImpCurveDomain.LastPoint()) > TheImpCurveDomain.FirstTolerance())
+ {
IsOnTheImpCurveDomain = Standard_False;
}
}
}
- if (IsOnTheImpCurveDomain) {
+ if (IsOnTheImpCurveDomain)
+ {
TheImpTool.D2(param1, pt1, Tan1, Norm1);
ParTool::D2(TheParCurve, param2, pt2, Tan2, Norm2);
IntImpParGen::DeterminePosition(Pos1, TheImpCurveDomain, pt1, param1);
IntImpParGen::DeterminePosition(Pos2, TheParCurveDomain, pt2, param2);
- if (Pos1 == IntRes2d_End) EndOnImp = Standard_True;
- else if (Pos1 == IntRes2d_Head) HeadOnImp = Standard_True;
- if (Pos2 == IntRes2d_End) EndOnPar = Standard_True;
- else if (Pos2 == IntRes2d_Head) HeadOnPar = Standard_True;
-
- IntImpParGen::DetermineTransition(Pos1, Tan1, Norm1, Trans1,
- Pos2, Tan2, Norm2, Trans2,
- Tolerance_Angulaire);
-
- IntRes2d_IntersectionPoint IP(pt1, param1, param2
- , Trans1, Trans2
- , ReversedParameters());
+ if (Pos1 == IntRes2d_End)
+ EndOnImp = Standard_True;
+ else if (Pos1 == IntRes2d_Head)
+ HeadOnImp = Standard_True;
+ if (Pos2 == IntRes2d_End)
+ EndOnPar = Standard_True;
+ else if (Pos2 == IntRes2d_Head)
+ HeadOnPar = Standard_True;
+
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ Tolerance_Angulaire);
+
+ IntRes2d_IntersectionPoint IP(pt1, param1, param2, Trans1, Trans2, ReversedParameters());
Insert(IP);
}
}
//-- F i n d u T r a i t e m e n t d e s P t s S o l.
-
//--------------------------------------------------------------------
//-- T r a i t e m e n t D e s S e g m e n t s ---
//--------------------------------------------------------------------
//-- On a N segments solution sur le domaine de V soit au pire :
- //-- --> N segments solution sur le domaine de U
+ //-- --> N segments solution sur le domaine de U
//-- -->2N segments si la courbe en U est fermee
- //--
+ //--
TColStd_Array1OfReal Inter2_and_Domaine2(1, 2 + 8 * nb_segments_solution);
TColStd_Array1OfReal Inter1(1, 2 + 8 * nb_segments_solution);
Standard_Integer nb_segments_crees = 0;
- for (Standard_Integer j2 = 1, j = 1; j <= nb_segments_solution; j++, j2 += 2) {
+ for (Standard_Integer j2 = 1, j = 1; j <= nb_segments_solution; j++, j2 += 2)
+ {
Standard_Real param2_inf, param2_sup;
Standard_Real param1_inf, param1_sup;
- gp_Pnt2d Ptemp;
+ gp_Pnt2d Ptemp;
Sol.GetInterval(j, param2_inf, param2_sup);
- param1_inf=FindU(param2_inf,Ptemp,TheParCurve,TheImpTool);
- param1_sup=FindU(param2_sup,Ptemp,TheParCurve,TheImpTool);
+ param1_inf = FindU(param2_inf, Ptemp, TheParCurve, TheImpTool);
+ param1_sup = FindU(param2_sup, Ptemp, TheParCurve, TheImpTool);
//----------------------------------------------------------------------
- //-- C o u r b e I m p l i c i t e F e r m e e
+ //-- C o u r b e I m p l i c i t e F e r m e e
- if (TheImpCurveDomain.IsClosed()) {
+ if (TheImpCurveDomain.IsClosed())
+ {
- gp_Vec2d T1, T2, N1, N2;
+ gp_Vec2d T1, T2, N1, N2;
Standard_Real param1_origine, param1_fin;
TheImpCurveDomain.EquivalentParameters(param1_origine, param1_fin);
Standard_Real Periode = param1_fin - param1_origine;
- while (param1_inf<param1_origine) { param1_inf += Periode; }
- while (param1_sup<param1_origine) { param1_sup += Periode; }
+ while (param1_inf < param1_origine)
+ {
+ param1_inf += Periode;
+ }
+ while (param1_sup < param1_origine)
+ {
+ param1_sup += Periode;
+ }
- ParTool::D2(TheParCurve,param2_inf,Ptemp,T2,N2);
- TheImpTool.D2(param1_inf,Ptemp,T1,N1);
- if (T1.Magnitude() <= gp::Resolution()) T1 = N1;
- if (T2.Magnitude() <= gp::Resolution()) T2 = N2;
+ ParTool::D2(TheParCurve, param2_inf, Ptemp, T2, N2);
+ TheImpTool.D2(param1_inf, Ptemp, T1, N1);
+ if (T1.Magnitude() <= gp::Resolution())
+ T1 = N1;
+ if (T2.Magnitude() <= gp::Resolution())
+ T2 = N2;
- if (T1.Dot(T2) >= 0.0) {
+ if (T1.Dot(T2) >= 0.0)
+ {
//--- param1_inf designe un point entrant (et T1 est vers la matiere)
- if (param1_inf >= param1_sup) { param1_sup += Periode; }
+ if (param1_inf >= param1_sup)
+ {
+ param1_sup += Periode;
+ }
}
- else { //--- param1_inf : point sortant (et T1 est Hors matiere)
- if (param1_inf <= param1_sup) { param1_inf += Periode; }
+ else
+ { //--- param1_inf : point sortant (et T1 est Hors matiere)
+ if (param1_inf <= param1_sup)
+ {
+ param1_inf += Periode;
+ }
}
//--- On cree un nouveau segment decale de Periode
//-- Exemple de Pb : Domaine PI/4 PI/2 et intervalle 0,PI
//-- Domaine 1.5PI 2.5PI et intervalle 0,PI
- //-- -2pi 0 2pi
+ //-- -2pi 0 2pi
//-- ------|--------------------|-----------------|-----------
//-- [----------------------------] Domaine
//-- [~~~~~~~~~~~~~~~~~] Inters.
//--
- //-- On cree un nouvel intervalle
+ //-- On cree un nouvel intervalle
//-- interv decale
//-- [a~~~~~~~~~~~~b] [a~~~~~~~~~~~~~~~b] et [a~~~]
//--
//
if (TheImpCurveDomain.LastParameter()
- > ((param1_inf>param1_sup) ? (param1_sup + Periode) :
- (param1_inf + Periode))) {
+ > ((param1_inf > param1_sup) ? (param1_sup + Periode) : (param1_inf + Periode)))
+ {
Inter2_and_Domaine2.SetValue(j2, param2_inf);
Inter1.SetValue(j2, param1_inf + Periode);
}
if (TheImpCurveDomain.FirstParameter()
- <((param1_inf<param1_sup) ? (param1_sup - Periode) : (param1_inf - Periode))) {
+ < ((param1_inf < param1_sup) ? (param1_sup - Periode) : (param1_inf - Periode)))
+ {
Inter2_and_Domaine2.SetValue(j2, param2_inf);
Inter1.SetValue(j2, param1_inf - Periode);
nb_segments_crees++;
}
}
- //-- F i n C o u r b e I m p l i c i t e F e r m e e
+ //-- F i n C o u r b e I m p l i c i t e F e r m e e
//----------------------------------------------------------------------
-
Inter2_and_Domaine2.SetValue(j2, param2_inf);
Inter1.SetValue(j2, param1_inf);
//------------------------------------------------------------------
//-- INTER2_DOMAINE2 : Intersection AND CurveDomain : Function of PARAM2
//-- INTER1 : Intersection AND CurveDomain : Function of PARAM1
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
//--
TColStd_Array1OfReal Resultat1(1, 2 + (1 + nb_segments_solution) * 2);
TColStd_Array1OfReal Resultat2(1, 2 + (1 + nb_segments_solution) * 2);
Standard_Integer NbResultats = nb_segments_solution * 2;
And_Domaine_Objet1_Intersections(TheImpTool,
- TheParCurve,
- TheImpCurveDomain,
- TheParCurveDomain,
- NbResultats,
- Inter2_and_Domaine2, Inter1,
- Resultat1, Resultat2, EpsNul);
+ TheParCurve,
+ TheImpCurveDomain,
+ TheParCurveDomain,
+ NbResultats,
+ Inter2_and_Domaine2,
+ Inter1,
+ Resultat1,
+ Resultat2,
+ EpsNul);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //Calcule_Toutes_Transitions(NbResultats,
+ // Calcule_Toutes_Transitions(NbResultats,
// Resultat1,Resultat2,
// TheImpTool,
// TheImpCurveDomain,
// TheParCurve,
- // TheParCurveDomain);
+ // TheParCurveDomain);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~ Fonction Calcule_Toutes_Transitions Repportee ici pour cause ~~~~~
//~~~~~ D acces aux methodes Protected APPEND
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
- gp_Pnt2d Pt1_on1, Pt2_on1, Pt1_on2, Pt2_on2;
+ gp_Pnt2d Pt1_on1, Pt2_on1, Pt1_on2, Pt2_on2;
Standard_Real Param1_on1, Param2_on1, Param1_on2, Param2_on2;
- Standard_Real Dist_Mini_ImpCurve = EPSNUL;
+ Standard_Real Dist_Mini_ImpCurve = EPSNUL;
Standard_Real ToleranceAngulaireDistMini = Dist_Mini_ImpCurve;
-
- for (Standard_Integer k = 1; k <= NbResultats; k += 2) {
- Standard_Integer ip1 = k + 1;
+ for (Standard_Integer k = 1; k <= NbResultats; k += 2)
+ {
+ Standard_Integer ip1 = k + 1;
Standard_Boolean OnlyOnePoint = Standard_False;
Param1_on1 = Resultat1.Value(k);
Pt1_on2 = ParTool::Value(TheParCurve, Param1_on2);
Pt2_on2 = ParTool::Value(TheParCurve, Param2_on2);
- if (!TheImpCurveDomain.IsClosed()) {
- if (Pt1_on1.Distance(Pt2_on1) <= Dist_Mini_ImpCurve) {
- if (Pt1_on2.Distance(Pt2_on2) <= Dist_Mini_ImpCurve) {
+ if (!TheImpCurveDomain.IsClosed())
+ {
+ if (Pt1_on1.Distance(Pt2_on1) <= Dist_Mini_ImpCurve)
+ {
+ if (Pt1_on2.Distance(Pt2_on2) <= Dist_Mini_ImpCurve)
+ {
OnlyOnePoint = Standard_True;
}
}
Param1_on1 = IntImpParGen::NormalizeOnDomain(Param1_on1, TheImpCurveDomain);
Param1_on2 = IntImpParGen::NormalizeOnDomain(Param1_on2, TheParCurveDomain);
- TheImpTool.D2(Param1_on1,Pt1_on1,Tan1,Norm1);
- ParTool::D2(TheParCurve,Param1_on2,Pt1_on2,Tan2,Norm2);
-
- IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,Pt1_on1,Param1_on1);
- IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,Pt1_on2,Param1_on2);
-
- if(Pos1==IntRes2d_End) EndOnImp = Standard_True;
- else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True;
- if(Pos2==IntRes2d_End) EndOnPar = Standard_True;
- else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True;
-
-
- IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
- Pos2,Tan2,Norm2,Trans2,
- ToleranceAngulaireDistMini);
+ TheImpTool.D2(Param1_on1, Pt1_on1, Tan1, Norm1);
+ ParTool::D2(TheParCurve, Param1_on2, Pt1_on2, Tan2, Norm2);
+
+ IntImpParGen::DeterminePosition(Pos1, TheImpCurveDomain, Pt1_on1, Param1_on1);
+ IntImpParGen::DeterminePosition(Pos2, TheParCurveDomain, Pt1_on2, Param1_on2);
+
+ if (Pos1 == IntRes2d_End)
+ EndOnImp = Standard_True;
+ else if (Pos1 == IntRes2d_Head)
+ HeadOnImp = Standard_True;
+ if (Pos2 == IntRes2d_End)
+ EndOnPar = Standard_True;
+ else if (Pos2 == IntRes2d_Head)
+ HeadOnPar = Standard_True;
+
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ ToleranceAngulaireDistMini);
//============== Detection du cas : L intersection est en bout
//============== sur les 2 domaines
- if(Pos1!=IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
- Standard_Real m = 0.5*(Pt1_on1.X() + Pt1_on2.X());
+ if (Pos1 != IntRes2d_Middle && Pos2 != IntRes2d_Middle)
+ {
+ Standard_Real m = 0.5 * (Pt1_on1.X() + Pt1_on2.X());
Pt1_on1.SetX(m);
- m = 0.5*(Pt1_on1.Y() + Pt1_on2.Y());
+ m = 0.5 * (Pt1_on1.Y() + Pt1_on2.Y());
Pt1_on1.SetY(m);
}
- IntRes2d_IntersectionPoint new_p1(Pt1_on1
- ,Param1_on1,Param1_on2
- ,Trans1,Trans2
- ,ReversedParameters());
- if(!OnlyOnePoint) {
+ IntRes2d_IntersectionPoint new_p1(Pt1_on1,
+ Param1_on1,
+ Param1_on2,
+ Trans1,
+ Trans2,
+ ReversedParameters());
+ if (!OnlyOnePoint)
+ {
IntRes2d_IntersectionPoint new_p2;
Param2_on1 = IntImpParGen::NormalizeOnDomain(Param2_on1, TheImpCurveDomain);
Param2_on2 = IntImpParGen::NormalizeOnDomain(Param2_on2, TheParCurveDomain);
- TheImpTool.D2(Param2_on1,Pt2_on1,Tan1,Norm1);
- ParTool::D2(TheParCurve,Param2_on2,Pt2_on2,Tan2,Norm2);
-
- IntImpParGen::DeterminePosition(Pos1,TheImpCurveDomain,Pt2_on1,Param2_on1);
- IntImpParGen::DeterminePosition(Pos2,TheParCurveDomain,Pt2_on2,Param2_on2);
-
- if(Pos1==IntRes2d_End) EndOnImp = Standard_True;
- else if(Pos1==IntRes2d_Head) HeadOnImp = Standard_True;
- if(Pos2==IntRes2d_End) EndOnPar = Standard_True;
- else if(Pos2==IntRes2d_Head) HeadOnPar = Standard_True;
-
- IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
- Pos2,Tan2,Norm2,Trans2,
- ToleranceAngulaireDistMini);
-
+ TheImpTool.D2(Param2_on1, Pt2_on1, Tan1, Norm1);
+ ParTool::D2(TheParCurve, Param2_on2, Pt2_on2, Tan2, Norm2);
+
+ IntImpParGen::DeterminePosition(Pos1, TheImpCurveDomain, Pt2_on1, Param2_on1);
+ IntImpParGen::DeterminePosition(Pos2, TheParCurveDomain, Pt2_on2, Param2_on2);
+
+ if (Pos1 == IntRes2d_End)
+ EndOnImp = Standard_True;
+ else if (Pos1 == IntRes2d_Head)
+ HeadOnImp = Standard_True;
+ if (Pos2 == IntRes2d_End)
+ EndOnPar = Standard_True;
+ else if (Pos2 == IntRes2d_Head)
+ HeadOnPar = Standard_True;
+
+ IntImpParGen::DetermineTransition(Pos1,
+ Tan1,
+ Norm1,
+ Trans1,
+ Pos2,
+ Tan2,
+ Norm2,
+ Trans2,
+ ToleranceAngulaireDistMini);
//============== Detection du cas : L intersection est en bout
- //============== sur les 2 domaines
+ //============== sur les 2 domaines
- if(Pos1!=IntRes2d_Middle && Pos2!=IntRes2d_Middle) {
- Standard_Real m = 0.5*(Pt2_on1.X() + Pt2_on2.X());
+ if (Pos1 != IntRes2d_Middle && Pos2 != IntRes2d_Middle)
+ {
+ Standard_Real m = 0.5 * (Pt2_on1.X() + Pt2_on2.X());
Pt2_on1.SetX(m);
- m = 0.5*(Pt2_on1.Y() + Pt2_on2.Y());
+ m = 0.5 * (Pt2_on1.Y() + Pt2_on2.Y());
Pt2_on1.SetY(m);
}
- new_p2.SetValues(Pt2_on1, Param2_on1, Param2_on2
- ,Trans1,Trans2
- ,ReversedParameters());
+ new_p2.SetValues(Pt2_on1, Param2_on1, Param2_on2, Trans1, Trans2, ReversedParameters());
- Standard_Boolean segopposite=((Tan1.Dot(Tan2) < 0.0)?
- Standard_True : Standard_False);
+ Standard_Boolean segopposite = ((Tan1.Dot(Tan2) < 0.0) ? Standard_True : Standard_False);
- IntRes2d_IntersectionSegment new_seg(new_p1, new_p2
- , segopposite
- , ReversedParameters());
+ IntRes2d_IntersectionSegment new_seg(new_p1, new_p2, segopposite, ReversedParameters());
Append(new_seg);
}
- else {
+ else
+ {
Insert(new_p1);
}
}
} //~~~~~~~~~~~~ Fin du corps de la fonction Calc...Transitions~~~~~~~~~~
- //-------------------------------------------
- //-- On teste les points en bouts solutions
- //--
- if (!HeadOnImp && TheImpCurveDomain.HasFirstPoint()) {
- if (!HeadOnPar) {
+ //-------------------------------------------
+ //-- On teste les points en bouts solutions
+ //--
+ if (!HeadOnImp && TheImpCurveDomain.HasFirstPoint())
+ {
+ if (!HeadOnPar)
+ {
if (TheImpCurveDomain.FirstPoint().Distance(TheParCurveDomain.FirstPoint())
- <= Max(TheImpCurveDomain.FirstTolerance(), TheParCurveDomain.FirstTolerance())) {
+ <= Max(TheImpCurveDomain.FirstTolerance(), TheParCurveDomain.FirstTolerance()))
+ {
param1 = TheImpCurveDomain.FirstParameter();
param2 = TheParCurveDomain.FirstParameter();
TheImpTool.D2(param1, pt1, Tan1, Norm1);
ParTool::D2(TheParCurve, param2, pt2, Tan2, Norm2);
- IntImpParGen::DetermineTransition(IntRes2d_Head, Tan1, Norm1, Trans1,
- IntRes2d_Head, Tan2, Norm2, Trans2,
- Tolerance_Angulaire);
+ IntImpParGen::DetermineTransition(IntRes2d_Head,
+ Tan1,
+ Norm1,
+ Trans1,
+ IntRes2d_Head,
+ Tan2,
+ Norm2,
+ Trans2,
+ Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.FirstPoint(),
- param1, param2,
- Trans1, Trans2,
- ReversedParameters());
+ param1,
+ param2,
+ Trans1,
+ Trans2,
+ ReversedParameters());
Insert(IP);
}
}
- if (!EndOnPar) {
+ if (!EndOnPar)
+ {
if (TheImpCurveDomain.FirstPoint().Distance(TheParCurveDomain.LastPoint())
- <= Max(TheImpCurveDomain.FirstTolerance(), TheParCurveDomain.LastTolerance())) {
+ <= Max(TheImpCurveDomain.FirstTolerance(), TheParCurveDomain.LastTolerance()))
+ {
param1 = TheImpCurveDomain.FirstParameter();
param2 = TheParCurveDomain.LastParameter();
TheImpTool.D2(param1, pt1, Tan1, Norm1);
ParTool::D2(TheParCurve, param2, pt2, Tan2, Norm2);
- IntImpParGen::DetermineTransition(IntRes2d_Head, Tan1, Norm1, Trans1,
- IntRes2d_End, Tan2, Norm2, Trans2,
- Tolerance_Angulaire);
+ IntImpParGen::DetermineTransition(IntRes2d_Head,
+ Tan1,
+ Norm1,
+ Trans1,
+ IntRes2d_End,
+ Tan2,
+ Norm2,
+ Trans2,
+ Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.FirstPoint(),
- param1, param2,
- Trans1, Trans2,
- ReversedParameters());
+ param1,
+ param2,
+ Trans1,
+ Trans2,
+ ReversedParameters());
Insert(IP);
}
}
}
- if (!EndOnImp && TheImpCurveDomain.HasLastPoint()) {
- if (!HeadOnPar) {
+ if (!EndOnImp && TheImpCurveDomain.HasLastPoint())
+ {
+ if (!HeadOnPar)
+ {
if (TheImpCurveDomain.LastPoint().Distance(TheParCurveDomain.FirstPoint())
- <= Max(TheImpCurveDomain.LastTolerance(), TheParCurveDomain.FirstTolerance())) {
+ <= Max(TheImpCurveDomain.LastTolerance(), TheParCurveDomain.FirstTolerance()))
+ {
param1 = TheImpCurveDomain.LastParameter();
param2 = TheParCurveDomain.FirstParameter();
TheImpTool.D2(param1, pt1, Tan1, Norm1);
ParTool::D2(TheParCurve, param2, pt2, Tan2, Norm2);
- IntImpParGen::DetermineTransition(IntRes2d_End, Tan1, Norm1, Trans1,
- IntRes2d_Head, Tan2, Norm2, Trans2,
- Tolerance_Angulaire);
+ IntImpParGen::DetermineTransition(IntRes2d_End,
+ Tan1,
+ Norm1,
+ Trans1,
+ IntRes2d_Head,
+ Tan2,
+ Norm2,
+ Trans2,
+ Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.LastPoint(),
- param1, param2,
- Trans1, Trans2,
- ReversedParameters());
+ param1,
+ param2,
+ Trans1,
+ Trans2,
+ ReversedParameters());
Insert(IP);
}
}
- if (!EndOnPar) {
+ if (!EndOnPar)
+ {
if (TheImpCurveDomain.LastPoint().Distance(TheParCurveDomain.LastPoint())
- <= Max(TheImpCurveDomain.LastTolerance(), TheParCurveDomain.LastTolerance())) {
+ <= Max(TheImpCurveDomain.LastTolerance(), TheParCurveDomain.LastTolerance()))
+ {
param1 = TheImpCurveDomain.LastParameter();
param2 = TheParCurveDomain.LastParameter();
TheImpTool.D2(param1, pt1, Tan1, Norm1);
ParTool::D2(TheParCurve, param2, pt2, Tan2, Norm2);
- IntImpParGen::DetermineTransition(IntRes2d_End, Tan1, Norm1, Trans1,
- IntRes2d_End, Tan2, Norm2, Trans2,
- Tolerance_Angulaire);
+ IntImpParGen::DetermineTransition(IntRes2d_End,
+ Tan1,
+ Norm1,
+ Trans1,
+ IntRes2d_End,
+ Tan2,
+ Norm2,
+ Trans2,
+ Tolerance_Angulaire);
IntRes2d_IntersectionPoint IP(TheImpCurveDomain.LastPoint(),
- param1, param2,
- Trans1, Trans2,
- ReversedParameters());
+ param1,
+ param2,
+ Trans1,
+ Trans2,
+ ReversedParameters());
Insert(IP);
}
}
done = Standard_True;
}
-
-
-
-
-
-Standard_Real IntImpParGen_Intersector::FindU(const Standard_Real parameter
- , gp_Pnt2d& point
- , const ParCurve& TheParCurve
- , const ImpTool& TheImpTool) const
+Standard_Real IntImpParGen_Intersector::FindU(const Standard_Real parameter,
+ gp_Pnt2d& point,
+ const ParCurve& TheParCurve,
+ const ImpTool& TheImpTool) const
{
point = ParTool::Value(TheParCurve, parameter);
- return(TheImpTool.FindParameter(point));
+ return (TheImpTool.FindParameter(point));
}
-Standard_Real IntImpParGen_Intersector::FindV(const Standard_Real parameter
- , gp_Pnt2d& point
- , const ImpTool& TheImpTool
- , const ParCurve& TheParCurve
- , const IntRes2d_Domain& TheParCurveDomain
- , const Standard_Real V0
- , const Standard_Real V1
- , const Standard_Real Tolerance) const
+Standard_Real IntImpParGen_Intersector::FindV(const Standard_Real parameter,
+ gp_Pnt2d& point,
+ const ImpTool& TheImpTool,
+ const ParCurve& TheParCurve,
+ const IntRes2d_Domain& TheParCurveDomain,
+ const Standard_Real V0,
+ const Standard_Real V1,
+ const Standard_Real Tolerance) const
{
point = TheImpTool.Value(parameter);
- if (TheParCurveDomain.IsClosed()) {
- Standard_Real V = ProjectOnPCurveTool::FindParameter(TheParCurve,
- point,
- Tolerance);
- return(IntImpParGen::NormalizeOnDomain(V, TheParCurveDomain));
+ if (TheParCurveDomain.IsClosed())
+ {
+ Standard_Real V = ProjectOnPCurveTool::FindParameter(TheParCurve, point, Tolerance);
+ return (IntImpParGen::NormalizeOnDomain(V, TheParCurveDomain));
}
- else {
+ else
+ {
Standard_Real VV0 = V0;
Standard_Real VV1 = V1;
- if (V1<V0) { VV0 = V1; VV1 = V0; }
+ if (V1 < V0)
+ {
+ VV0 = V1;
+ VV1 = V0;
+ }
//-- ??????????????????????????????????????????????????????????????????????
- //-- Modif le 15 Septembre 1992 : On Teste le parametre retourne
+ //-- Modif le 15 Septembre 1992 : On Teste le parametre retourne
//--??????????????????????????????????????????????????????????????????????
- Standard_Real X = ProjectOnPCurveTool::FindParameter(TheParCurve,
- point,
- VV0, VV1, Tolerance);
- if (X>VV1) X = VV1; else if (X<VV0) X = VV0;
- return(X);
+ Standard_Real X = ProjectOnPCurveTool::FindParameter(TheParCurve, point, VV0, VV1, Tolerance);
+ if (X > VV1)
+ X = VV1;
+ else if (X < VV0)
+ X = VV0;
+ return (X);
}
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-IntStart_PathPoint::IntStart_PathPoint ()
-: tol(0.0),
- isnew(Standard_True),
- param(0.0)
+IntStart_PathPoint::IntStart_PathPoint()
+ : tol(0.0),
+ isnew(Standard_True),
+ param(0.0)
{
}
-IntStart_PathPoint::IntStart_PathPoint (const gp_Pnt& P,
- const Standard_Real Tol,
- const TheVertex& V,
- const TheArc& A,
- const Standard_Real Parameter):
+IntStart_PathPoint::IntStart_PathPoint(const gp_Pnt& P,
+ const Standard_Real Tol,
+ const TheVertex& V,
+ const TheArc& A,
+ const Standard_Real Parameter)
+ :
- point(P),tol(Tol),isnew(Standard_False),vtx(V),arc(A),param(Parameter)
-{}
-
-IntStart_PathPoint::IntStart_PathPoint (const gp_Pnt& P,
- const Standard_Real Tol,
- const TheArc& A,
- const Standard_Real Parameter):
+ point(P),
+ tol(Tol),
+ isnew(Standard_False),
+ vtx(V),
+ arc(A),
+ param(Parameter)
+{
+}
- point(P),tol(Tol),isnew(Standard_True),arc(A),param(Parameter)
-{}
+IntStart_PathPoint::IntStart_PathPoint(const gp_Pnt& P,
+ const Standard_Real Tol,
+ const TheArc& A,
+ const Standard_Real Parameter)
+ :
+ point(P),
+ tol(Tol),
+ isnew(Standard_True),
+ arc(A),
+ param(Parameter)
+{
+}
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
-#define No_Standard_RangeError
-#define No_Standard_OutOfRange
+ #define No_Standard_RangeError
+ #define No_Standard_OutOfRange
#endif
-
-
#include <math_FunctionSetRoot.hxx>
#include <Precision.hxx>
#include <gp_Pnt2d.hxx>
#include <TopAbs_State.hxx>
-IntStart_SearchInside::IntStart_SearchInside (): done(Standard_False)
-{}
+IntStart_SearchInside::IntStart_SearchInside()
+ : done(Standard_False)
+{
+}
-IntStart_SearchInside::IntStart_SearchInside (TheFunction& Func,
- const ThePSurface& PS,
- const Handle(TheTopolTool)& T,
- const Standard_Real Epsilon) {
+IntStart_SearchInside::IntStart_SearchInside(TheFunction& Func,
+ const ThePSurface& PS,
+ const Handle(TheTopolTool)& T,
+ const Standard_Real Epsilon)
+{
- Perform(Func,PS,T,Epsilon);
+ Perform(Func, PS, T, Epsilon);
}
-
//=======================================================================
-//function : Perform
-//purpose : Search all inside points
+// function : Perform
+// purpose : Search all inside points
//=======================================================================
-void IntStart_SearchInside::Perform (TheFunction& Func,
- const ThePSurface& PS,
- const Handle(TheTopolTool)& T,
- const Standard_Real Epsilon) {
+void IntStart_SearchInside::Perform(TheFunction& Func,
+ const ThePSurface& PS,
+ const Handle(TheTopolTool)& T,
+ const Standard_Real Epsilon)
+{
done = Standard_False;
list.Clear();
- Standard_Real aBinf[2], aBsup[2], aUVap[2], atoler[2];
- math_Vector Binf(aBinf,1,2), Bsup(aBsup,1,2), UVap(aUVap,1,2), toler(atoler,1,2);
- gp_Pnt psol;
+ Standard_Real aBinf[2], aBsup[2], aUVap[2], atoler[2];
+ math_Vector Binf(aBinf, 1, 2), Bsup(aBsup, 1, 2), UVap(aUVap, 1, 2), toler(atoler, 1, 2);
+ gp_Pnt psol;
Standard_Boolean testpnt;
- Standard_Integer i,j,nbpt;
- TopAbs_State situ;
- Standard_Real umin,umax,vmin,vmax;
+ Standard_Integer i, j, nbpt;
+ TopAbs_State situ;
+ Standard_Real umin, umax, vmin, vmax;
Binf(1) = umin = ThePSurfaceTool::FirstUParameter(PS);
Binf(2) = vmin = ThePSurfaceTool::FirstVParameter(PS);
Bsup(1) = umax = ThePSurfaceTool::LastUParameter(PS);
Bsup(2) = vmax = ThePSurfaceTool::LastVParameter(PS);
-
- Standard_Integer NbsampleU= T->NbSamplesU();
- Standard_Integer NbsampleV= T->NbSamplesV();
- Standard_Integer Nbsample = T->NbSamples();
-
- Standard_Real du = Bsup(1)-Binf(1);
- Standard_Real dv = Bsup(2)-Binf(2);
- du/=(Standard_Real)NbsampleU*0.5;
- dv/=(Standard_Real)NbsampleV*0.5;
-
- Standard_Real toler1 = toler(1) = ThePSurfaceTool::UResolution(PS,Precision::Confusion());
- Standard_Real toler2 = toler(2) = ThePSurfaceTool::VResolution(PS,Precision::Confusion());
- Standard_Real Maxtoler1toler2 = toler1;
- if(toler2>Maxtoler1toler2) Maxtoler1toler2 = toler2;
+
+ Standard_Integer NbsampleU = T->NbSamplesU();
+ Standard_Integer NbsampleV = T->NbSamplesV();
+ Standard_Integer Nbsample = T->NbSamples();
+
+ Standard_Real du = Bsup(1) - Binf(1);
+ Standard_Real dv = Bsup(2) - Binf(2);
+ du /= (Standard_Real)NbsampleU * 0.5;
+ dv /= (Standard_Real)NbsampleV * 0.5;
+
+ Standard_Real toler1 = toler(1) = ThePSurfaceTool::UResolution(PS, Precision::Confusion());
+ Standard_Real toler2 = toler(2) = ThePSurfaceTool::VResolution(PS, Precision::Confusion());
+ Standard_Real Maxtoler1toler2 = toler1;
+ if (toler2 > Maxtoler1toler2)
+ Maxtoler1toler2 = toler2;
//-- lbr le 15 mai 97
- //-- on interdit aux points d'etre trop prets des restrictions
- Maxtoler1toler2*=1000;
- if(Maxtoler1toler2>du*0.001) Maxtoler1toler2=du*0.001;
- if(Maxtoler1toler2>dv*0.001) Maxtoler1toler2=dv*0.001;
-
-
+ //-- on interdit aux points d'etre trop prets des restrictions
+ Maxtoler1toler2 *= 1000;
+ if (Maxtoler1toler2 > du * 0.001)
+ Maxtoler1toler2 = du * 0.001;
+ if (Maxtoler1toler2 > dv * 0.001)
+ Maxtoler1toler2 = dv * 0.001;
+
Func.Set(PS);
Standard_Real Tol = Func.Tolerance();
- math_FunctionSetRoot Rsnld(Func,toler);
+ math_FunctionSetRoot Rsnld(Func, toler);
- //-- lbr le 15 mai 97
- umin+=du*0.01;
- vmin+=dv*0.01;
- umax-=du*0.01;
- vmax-=dv*0.01;
+ //-- lbr le 15 mai 97
+ umin += du * 0.01;
+ vmin += dv * 0.01;
+ umax -= du * 0.01;
+ vmax -= dv * 0.01;
- //-- lbr le 30 octobre 97 :
+ //-- lbr le 30 octobre 97 :
//-- Si une surface vient tangenter 2 edges proche d un coin
- //-- il faut faire attention qu un point de depart soit trouve au
+ //-- il faut faire attention qu un point de depart soit trouve au
//-- voisinage du coin. Car ds le cas contraire, le cheminement ne
- //-- pourra pas passer au travers des frontieres :
+ //-- pourra pas passer au travers des frontieres :
//--
//-- typiquement I est un cylindre (conge)
//--
//-- P I
//-- PI
//-- * I
- //-- PI I
+ //-- PI I
//-- P I I I I I I I I
//--
-
- for (i=1; i <= Nbsample+12; i++) {
- gp_Pnt2d s2d;
- gp_Pnt s3d;
- Standard_Boolean nepastester=Standard_False;
- if(i<=Nbsample) {
- T->SamplePoint(i,s2d,s3d);
- UVap(1)=s2d.X(); UVap(2)=s2d.Y();
-
- Standard_Real u1,v1,u2,v2;
- u1 = Binf(1) = Max(umin,UVap(1)-du);
- v1 = Binf(2) = Max(vmin,UVap(2)-dv);
- u2 = Bsup(1) = Min(umax,UVap(1)+du);
- v2 = Bsup(2) = Min(vmax,UVap(2)+dv);
-
-
+ for (i = 1; i <= Nbsample + 12; i++)
+ {
+ gp_Pnt2d s2d;
+ gp_Pnt s3d;
+ Standard_Boolean nepastester = Standard_False;
+ if (i <= Nbsample)
+ {
+ T->SamplePoint(i, s2d, s3d);
+ UVap(1) = s2d.X();
+ UVap(2) = s2d.Y();
+
+ Standard_Real u1, v1, u2, v2;
+ u1 = Binf(1) = Max(umin, UVap(1) - du);
+ v1 = Binf(2) = Max(vmin, UVap(2) - dv);
+ u2 = Bsup(1) = Min(umax, UVap(1) + du);
+ v2 = Bsup(2) = Min(vmax, UVap(2) + dv);
+
//-- gp_Pnt Pmilieu = ThePSurfaceTool::Value(PS,0.5*(u1+u2),0.5*(v1+v2));
- gp_Pnt Pextrm1 = ThePSurfaceTool::Value(PS,u1,v1);
- gp_Pnt Pextrm2 = ThePSurfaceTool::Value(PS,u2,v2);
+ gp_Pnt Pextrm1 = ThePSurfaceTool::Value(PS, u1, v1);
+ gp_Pnt Pextrm2 = ThePSurfaceTool::Value(PS, u2, v2);
Standard_Real aValf[1];
- math_Vector Valf(aValf,1,1);
- Func.Value(UVap,Valf);
- Standard_Real rvalf = Valf(1);
+ math_Vector Valf(aValf, 1, 1);
+ Func.Value(UVap, Valf);
+ Standard_Real rvalf = Valf(1);
Standard_Real DistPP = Pextrm1.SquareDistance(Pextrm2);
- if(rvalf*rvalf > 3.0*DistPP) {
- nepastester=Standard_True;
- }
+ if (rvalf * rvalf > 3.0 * DistPP)
+ {
+ nepastester = Standard_True;
+ }
}
- else {
- if(i==Nbsample+1) { s2d.SetCoord(umin+du*0.02,vmin+dv*0.02); }
- else if(i==Nbsample+2) { s2d.SetCoord(umax-du*0.02,vmin+dv*0.02); }
- else if(i==Nbsample+3) { s2d.SetCoord(umin+du*0.02,vmax-dv*0.02); }
- else if(i==Nbsample+4) { s2d.SetCoord(umax-du*0.02,vmax-dv*0.02); }
-
- else if(i==Nbsample+5) { s2d.SetCoord(umin+du*0.02,vmin+dv*0.02); }
- else if(i==Nbsample+6) { s2d.SetCoord(umax-du*0.02,vmin+dv*0.02); }
- else if(i==Nbsample+7) { s2d.SetCoord(umin+du*0.02,vmax-dv*0.02); }
- else if(i==Nbsample+8) { s2d.SetCoord(umax-du*0.02,vmax-dv*0.02); }
-
- else if(i==Nbsample+9) { s2d.SetCoord(umin+du*0.005,vmin+dv*0.005); }
- else if(i==Nbsample+10){ s2d.SetCoord(umax-du*0.005,vmin+dv*0.005); }
- else if(i==Nbsample+11){ s2d.SetCoord(umin+du*0.005,vmax-dv*0.005); }
- else { s2d.SetCoord(umax-du*0.005,vmax-dv*0.005); }
-
- UVap(1)=s2d.X(); UVap(2)=s2d.Y();
-
- Binf(1) = Max(umin,UVap(1)-du);
- Binf(2) = Max(vmin,UVap(2)-dv);
- Bsup(1) = Min(umax,UVap(1)+du);
- Bsup(2) = Min(vmax,UVap(2)+dv);
+ else
+ {
+ if (i == Nbsample + 1)
+ {
+ s2d.SetCoord(umin + du * 0.02, vmin + dv * 0.02);
+ }
+ else if (i == Nbsample + 2)
+ {
+ s2d.SetCoord(umax - du * 0.02, vmin + dv * 0.02);
+ }
+ else if (i == Nbsample + 3)
+ {
+ s2d.SetCoord(umin + du * 0.02, vmax - dv * 0.02);
+ }
+ else if (i == Nbsample + 4)
+ {
+ s2d.SetCoord(umax - du * 0.02, vmax - dv * 0.02);
+ }
+
+ else if (i == Nbsample + 5)
+ {
+ s2d.SetCoord(umin + du * 0.02, vmin + dv * 0.02);
+ }
+ else if (i == Nbsample + 6)
+ {
+ s2d.SetCoord(umax - du * 0.02, vmin + dv * 0.02);
+ }
+ else if (i == Nbsample + 7)
+ {
+ s2d.SetCoord(umin + du * 0.02, vmax - dv * 0.02);
+ }
+ else if (i == Nbsample + 8)
+ {
+ s2d.SetCoord(umax - du * 0.02, vmax - dv * 0.02);
+ }
+
+ else if (i == Nbsample + 9)
+ {
+ s2d.SetCoord(umin + du * 0.005, vmin + dv * 0.005);
+ }
+ else if (i == Nbsample + 10)
+ {
+ s2d.SetCoord(umax - du * 0.005, vmin + dv * 0.005);
+ }
+ else if (i == Nbsample + 11)
+ {
+ s2d.SetCoord(umin + du * 0.005, vmax - dv * 0.005);
+ }
+ else
+ {
+ s2d.SetCoord(umax - du * 0.005, vmax - dv * 0.005);
+ }
+
+ UVap(1) = s2d.X();
+ UVap(2) = s2d.Y();
+
+ Binf(1) = Max(umin, UVap(1) - du);
+ Binf(2) = Max(vmin, UVap(2) - dv);
+ Bsup(1) = Min(umax, UVap(1) + du);
+ Bsup(2) = Min(vmax, UVap(2) + dv);
}
-
-
- if(nepastester==Standard_False) {
- Rsnld.Perform(Func,UVap,Binf,Bsup);
- if (Rsnld.IsDone()) {
- if (Abs(Func.Root()) <= Tol) {
- if (!Func.IsTangent()) {
- psol = Func.Point();
- Rsnld.Root(UVap);
- // On regarde si le point trouve est bien un nouveau point.
- j = 1;
- nbpt = list.Length();
- testpnt = (j <= nbpt);
-
- while (testpnt) {
- const IntSurf_InteriorPoint& IPj = list(j);
- const gp_Pnt& Pj = IPj.Value();
- if ( (Abs(Pj.X()-psol.X()) <= Epsilon)
- && (Abs(Pj.Y()-psol.Y()) <= Epsilon)
- && (Abs(Pj.Z()-psol.Z()) <= Epsilon)
- && (Abs(UVap(1)-IPj.UParameter()) <= toler1)
- && (Abs(UVap(2)-IPj.VParameter()) <= toler2) ) {
- testpnt = Standard_False;
- }
- else {
- j = j+1;
- testpnt = (j <= nbpt);
- }
- }
- if (j > nbpt) {
- // situ = TheSITool::Classify(PS,UVap(1),UVap(2));
- situ = T->Classify(gp_Pnt2d(UVap(1),UVap(2)),
- Maxtoler1toler2,Standard_False); //-- ,Standard_False pour ne pas recadrer on Periodic
- if (situ == TopAbs_IN) {
- list.Append(IntSurf_InteriorPoint(psol,UVap(1),UVap(2),
- Func.Direction3d(),
- Func.Direction2d()));
- }
- }
- }
- }
+
+ if (nepastester == Standard_False)
+ {
+ Rsnld.Perform(Func, UVap, Binf, Bsup);
+ if (Rsnld.IsDone())
+ {
+ if (Abs(Func.Root()) <= Tol)
+ {
+ if (!Func.IsTangent())
+ {
+ psol = Func.Point();
+ Rsnld.Root(UVap);
+ // On regarde si le point trouve est bien un nouveau point.
+ j = 1;
+ nbpt = list.Length();
+ testpnt = (j <= nbpt);
+
+ while (testpnt)
+ {
+ const IntSurf_InteriorPoint& IPj = list(j);
+ const gp_Pnt& Pj = IPj.Value();
+ if ((Abs(Pj.X() - psol.X()) <= Epsilon) && (Abs(Pj.Y() - psol.Y()) <= Epsilon)
+ && (Abs(Pj.Z() - psol.Z()) <= Epsilon)
+ && (Abs(UVap(1) - IPj.UParameter()) <= toler1)
+ && (Abs(UVap(2) - IPj.VParameter()) <= toler2))
+ {
+ testpnt = Standard_False;
+ }
+ else
+ {
+ j = j + 1;
+ testpnt = (j <= nbpt);
+ }
+ }
+ if (j > nbpt)
+ {
+ // situ = TheSITool::Classify(PS,UVap(1),UVap(2));
+ situ =
+ T->Classify(gp_Pnt2d(UVap(1), UVap(2)),
+ Maxtoler1toler2,
+ Standard_False); //-- ,Standard_False pour ne pas recadrer on Periodic
+ if (situ == TopAbs_IN)
+ {
+ list.Append(IntSurf_InteriorPoint(psol,
+ UVap(1),
+ UVap(2),
+ Func.Direction3d(),
+ Func.Direction2d()));
+ }
+ }
+ }
+ }
}
}
}
- //-- printf("\n Total : %d Rejet : %d RatioPointCalc : %g nbpt =%d\n",REJET_OK+REJET_KO,REJET_OK,(double)(REJET_KO)/(double)(REJET_OK+REJET_KO),list.Length());
+ //-- printf("\n Total : %d Rejet : %d RatioPointCalc : %g nbpt
+ //=%d\n",REJET_OK+REJET_KO,REJET_OK,(double)(REJET_KO)/(double)(REJET_OK+REJET_KO),list.Length());
done = Standard_True;
}
-
//=======================================================================
-//function : Perform
-//purpose : Test the given inside point
+// function : Perform
+// purpose : Test the given inside point
//=======================================================================
-void IntStart_SearchInside::Perform (TheFunction& Func,
- const ThePSurface& PS,
- const Standard_Real UStart,
- const Standard_Real VStart)
+void IntStart_SearchInside::Perform(TheFunction& Func,
+ const ThePSurface& PS,
+ const Standard_Real UStart,
+ const Standard_Real VStart)
{
done = Standard_False;
list.Clear();
- math_Vector Binf(1,2), Bsup(1,2), toler(1,2);
+ math_Vector Binf(1, 2), Bsup(1, 2), toler(1, 2);
Binf(1) = ThePSurfaceTool::FirstUParameter(PS);
Binf(2) = ThePSurfaceTool::FirstVParameter(PS);
Bsup(1) = ThePSurfaceTool::LastUParameter(PS);
Bsup(2) = ThePSurfaceTool::LastVParameter(PS);
- toler(1) = ThePSurfaceTool::UResolution(PS,Precision::Confusion());
- toler(2) = ThePSurfaceTool::VResolution(PS,Precision::Confusion());
+ toler(1) = ThePSurfaceTool::UResolution(PS, Precision::Confusion());
+ toler(2) = ThePSurfaceTool::VResolution(PS, Precision::Confusion());
- if (UStart-Binf(1) > -toler(1) && UStart-Bsup(1) < toler(1) &&
- VStart-Binf(2) > -toler(2) && VStart-Bsup(2) < toler(2)) {
+ if (UStart - Binf(1) > -toler(1) && UStart - Bsup(1) < toler(1) && VStart - Binf(2) > -toler(2)
+ && VStart - Bsup(2) < toler(2))
+ {
Func.Set(PS);
- math_Vector UVap(1,2);
- UVap(1)=UStart; UVap(2)=VStart;
+ math_Vector UVap(1, 2);
+ UVap(1) = UStart;
+ UVap(2) = VStart;
- math_FunctionSetRoot Rsnld(Func,toler);
- Rsnld.Perform(Func,UVap,Binf,Bsup);
- if (Rsnld.IsDone()) {
- Standard_Real tol = Func.Tolerance();
+ math_FunctionSetRoot Rsnld(Func, toler);
+ Rsnld.Perform(Func, UVap, Binf, Bsup);
+ if (Rsnld.IsDone())
+ {
+ Standard_Real tol = Func.Tolerance();
Standard_Real valf = Func.Root();
- if (Abs(valf) <= tol && !Func.IsTangent()) {
- const gp_Pnt& psol = Func.Point();
- Rsnld.Root(UVap);
- IntSurf_InteriorPoint intp (psol,UVap(1),UVap(2),
- Func.Direction3d(),Func.Direction2d());
- list.Append(intp);
+ if (Abs(valf) <= tol && !Func.IsTangent())
+ {
+ const gp_Pnt& psol = Func.Point();
+ Rsnld.Root(UVap);
+ IntSurf_InteriorPoint intp(psol, UVap(1), UVap(2), Func.Direction3d(), Func.Direction2d());
+ list.Append(intp);
}
}
}
#include <GeomAdaptor_Surface.hxx>
#include <Precision.hxx>
#include <Extrema_ExtCC.hxx>
-//#include <Extrema_ExtCS.hxx>
+// #include <Extrema_ExtCS.hxx>
#include <Extrema_POnCurv.hxx>
#include <IntCurveSurface_HInter.hxx>
#include <NCollection_Array1.hxx>
#ifdef OCCT_DEBUG
-#include <Geom_Circle.hxx>
-#include <Geom_Ellipse.hxx>
-#include <Geom_Hyperbola.hxx>
-#include <Geom_Parabola.hxx>
-#include <Geom_BezierCurve.hxx>
-#include <Geom_BSplineCurve.hxx>
-#include <GeomLib.hxx>
+ #include <Geom_Circle.hxx>
+ #include <Geom_Ellipse.hxx>
+ #include <Geom_Hyperbola.hxx>
+ #include <Geom_Parabola.hxx>
+ #include <Geom_BezierCurve.hxx>
+ #include <Geom_BSplineCurve.hxx>
+ #include <GeomLib.hxx>
#endif
-
static Standard_Boolean IsDegenerated(const Handle(Adaptor3d_CurveOnSurface)& theCurve);
static Standard_Boolean IsDegenerated(const IntSurf_Quadric& theQuadric);
-static void FindVertex (const TheArc&,
- const Handle(TheTopolTool)&,
- TheFunction&,
- IntStart_SequenceOfPathPoint&,
- const Standard_Real);
-
-
-static void BoundedArc (const TheArc& A,
- const Handle(TheTopolTool)& Domain,
- const Standard_Real Pdeb,
- const Standard_Real Pfin,
- TheFunction& Func,
- IntStart_SequenceOfPathPoint& pnt,
- IntStart_SequenceOfSegment& seg,
- const Standard_Real TolBoundary,
- const Standard_Real TolTangency,
- Standard_Boolean& Arcsol,
- const Standard_Boolean RecheckOnRegularity);
-
-static void PointProcess (const gp_Pnt&,
- const Standard_Real,
- const TheArc&,
- const Handle(TheTopolTool)&,
- IntStart_SequenceOfPathPoint&,
- const Standard_Real,
- Standard_Integer&);
-
-static Standard_Integer TreatLC (const TheArc& A,
- const Handle(TheTopolTool)& aDomain,
- const IntSurf_Quadric& aQuadric,
- const Standard_Real TolBoundary,
- IntStart_SequenceOfPathPoint& pnt);
-
-static Standard_Boolean IsRegularity(const TheArc& A,
- const Handle(TheTopolTool)& aDomain);
+static void FindVertex(const TheArc&,
+ const Handle(TheTopolTool)&,
+ TheFunction&,
+ IntStart_SequenceOfPathPoint&,
+ const Standard_Real);
+
+static void BoundedArc(const TheArc& A,
+ const Handle(TheTopolTool)& Domain,
+ const Standard_Real Pdeb,
+ const Standard_Real Pfin,
+ TheFunction& Func,
+ IntStart_SequenceOfPathPoint& pnt,
+ IntStart_SequenceOfSegment& seg,
+ const Standard_Real TolBoundary,
+ const Standard_Real TolTangency,
+ Standard_Boolean& Arcsol,
+ const Standard_Boolean RecheckOnRegularity);
+
+static void PointProcess(const gp_Pnt&,
+ const Standard_Real,
+ const TheArc&,
+ const Handle(TheTopolTool)&,
+ IntStart_SequenceOfPathPoint&,
+ const Standard_Real,
+ Standard_Integer&);
+
+static Standard_Integer TreatLC(const TheArc& A,
+ const Handle(TheTopolTool)& aDomain,
+ const IntSurf_Quadric& aQuadric,
+ const Standard_Real TolBoundary,
+ IntStart_SequenceOfPathPoint& pnt);
+
+static Standard_Boolean IsRegularity(const TheArc& A, const Handle(TheTopolTool)& aDomain);
class MinFunction : public math_Function
{
public:
- MinFunction(TheFunction &theFunc) : myFunc(&theFunc) {};
+ MinFunction(TheFunction& theFunc)
+ : myFunc(&theFunc) {};
- //returns value of the one-dimension-function when parameter
- //is equal to theX
- virtual Standard_Boolean Value(const Standard_Real theX,
- Standard_Real& theFVal)
+ // returns value of the one-dimension-function when parameter
+ // is equal to theX
+ virtual Standard_Boolean Value(const Standard_Real theX, Standard_Real& theFVal)
{
- if(!myFunc->Value(theX, theFVal))
+ if (!myFunc->Value(theX, theFVal))
return Standard_False;
theFVal *= theFVal;
return Standard_True;
}
- //see analogical method for abstract owner class math_Function
- virtual Standard_Integer GetStateNumber()
- {
- return 0;
- }
+ // see analogical method for abstract owner class math_Function
+ virtual Standard_Integer GetStateNumber() { return 0; }
private:
- TheFunction *myFunc;
+ TheFunction* myFunc;
};
-
//=================================================================================================
-void FindVertex (const TheArc& A,
- const Handle(TheTopolTool)& Domain,
- TheFunction& Func,
- IntStart_SequenceOfPathPoint& pnt,
- const Standard_Real Toler)
+void FindVertex(const TheArc& A,
+ const Handle(TheTopolTool)& Domain,
+ TheFunction& Func,
+ IntStart_SequenceOfPathPoint& pnt,
+ const Standard_Real Toler)
{
-// Find the vertex of the arc A restriction solutions. It stores
-// Vertex in the list solutions pnt.
-
+ // Find the vertex of the arc A restriction solutions. It stores
+ // Vertex in the list solutions pnt.
- TheVertex vtx;
- Standard_Real param,valf;
+ TheVertex vtx;
+ Standard_Real param, valf;
Standard_Integer itemp;
Domain->Initialize(A);
Domain->InitVertexIterator();
- while (Domain->MoreVertex()) {
- vtx = Domain->Vertex();
- param = TheSOBTool::Parameter(vtx,A);
+ while (Domain->MoreVertex())
+ {
+ vtx = Domain->Vertex();
+ param = TheSOBTool::Parameter(vtx, A);
// Evaluate the function and look compared to tolerance of the
// Vertex. If distance <= tolerance then add a vertex to the list of solutions.
// The arc is already assumed in the load function.
- Func.Value(param,valf);
- if (Abs(valf) <= Toler) {
+ Func.Value(param, valf);
+ if (Abs(valf) <= Toler)
+ {
itemp = Func.GetStateNumber();
- pnt.Append(IntStart_ThePathPoint(Func.Valpoint(itemp),Toler, vtx,A,param));
+ pnt.Append(IntStart_ThePathPoint(Func.Valpoint(itemp), Toler, vtx, A, param));
// Solution is added
}
Domain->NextVertex();
GeomAbs_SurfaceType TypeQuad = theQuadric.TypeQuadric();
if (TypeQuad == GeomAbs_Cone)
{
- gp_Cone aCone = theQuadric.Cone();
+ gp_Cone aCone = theQuadric.Cone();
Standard_Real aSemiAngle = Abs(aCone.SemiAngle());
if (aSemiAngle < 0.02 || aSemiAngle > 1.55)
return Standard_True;
class SolInfo
{
public:
- SolInfo() : myMathIndex(-1), myValue(RealLast())
+ SolInfo()
+ : myMathIndex(-1),
+ myValue(RealLast())
{
}
void Init(const math_FunctionAllRoots& theSolution, const Standard_Integer theIndex)
{
myMathIndex = theIndex;
- myValue = theSolution.GetPoint(theIndex);
+ myValue = theSolution.GetPoint(theIndex);
}
void Init(const IntCurveSurface_HInter& theSolution, const Standard_Integer theIndex)
{
myMathIndex = theIndex;
- myValue = theSolution.Point(theIndex).W();
+ myValue = theSolution.Point(theIndex).W();
}
- Standard_Real Value() const
- {
- return myValue;
- }
+ Standard_Real Value() const { return myValue; }
- Standard_Integer Index() const
- {
- return myMathIndex;
- }
+ Standard_Integer Index() const { return myMathIndex; }
- bool operator>(const SolInfo& theOther) const
- {
- return myValue > theOther.myValue;
- }
+ bool operator>(const SolInfo& theOther) const { return myValue > theOther.myValue; }
- bool operator<(const SolInfo& theOther) const
- {
- return myValue < theOther.myValue;
- }
+ bool operator<(const SolInfo& theOther) const { return myValue < theOther.myValue; }
- bool operator==(const SolInfo& theOther) const
- {
- return myValue == theOther.myValue;
- }
+ bool operator==(const SolInfo& theOther) const { return myValue == theOther.myValue; }
- Standard_Real& ChangeValue()
- {
- return myValue;
- }
+ Standard_Real& ChangeValue() { return myValue; }
private:
Standard_Integer myMathIndex;
- Standard_Real myValue;
+ Standard_Real myValue;
};
-static
-void BoundedArc (const TheArc& A,
- const Handle(TheTopolTool)& Domain,
- const Standard_Real Pdeb,
- const Standard_Real Pfin,
- TheFunction& Func,
- IntStart_SequenceOfPathPoint& pnt,
- IntStart_SequenceOfSegment& seg,
- const Standard_Real TolBoundary,
- const Standard_Real TolTangency,
- Standard_Boolean& Arcsol,
- const Standard_Boolean RecheckOnRegularity)
+static void BoundedArc(const TheArc& A,
+ const Handle(TheTopolTool)& Domain,
+ const Standard_Real Pdeb,
+ const Standard_Real Pfin,
+ TheFunction& Func,
+ IntStart_SequenceOfPathPoint& pnt,
+ IntStart_SequenceOfSegment& seg,
+ const Standard_Real TolBoundary,
+ const Standard_Real TolTangency,
+ Standard_Boolean& Arcsol,
+ const Standard_Boolean RecheckOnRegularity)
{
// Recherche des points solutions et des bouts d arc solution sur un arc donne.
// On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour
Standard_Integer i, Nbi = 0, Nbp = 0;
- gp_Pnt ptdeb,ptfin;
- Standard_Real pardeb = 0., parfin = 0.;
- Standard_Integer ideb,ifin,range,ranged,rangef;
+ gp_Pnt ptdeb, ptfin;
+ Standard_Real pardeb = 0., parfin = 0.;
+ Standard_Integer ideb, ifin, range, ranged, rangef;
// Creer l echantillonage (math_FunctionSample ou classe heritant)
// Appel a math_FunctionAllRoots
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@ La Tolerance est asociee a l arc ( Incoherence avec le cheminement )
//@@@ ( EpsX ~ 1e-5 et ResolutionU et V ~ 1e-9 )
- //@@@ le vertex trouve ici n'est pas retrouve comme point d arret d une
+ //@@@ le vertex trouve ici n'est pas retrouve comme point d arret d une
//@@@ ligne de cheminement
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Standard_Real EpsX = 1.e-10;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- // Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A);
- Standard_Integer NbEchant = Func.NbSamples();
- if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96
- //-- Toujours des pbs
-
+ // Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A);
+ Standard_Integer NbEchant = Func.NbSamples();
+ if (NbEchant < 100)
+ NbEchant = 100; //-- lbr le 22 Avril 96
+ //-- Toujours des pbs
+
//-- Modif 24 Aout 93 -----------------------------
Standard_Real nTolTangency = TolTangency;
- if((Pfin - Pdeb) < (TolTangency*10.0)) {
- nTolTangency=(Pfin-Pdeb)*0.1;
- }
- if(EpsX>(nTolTangency+nTolTangency)) {
- EpsX = nTolTangency * 0.1;
+ if ((Pfin - Pdeb) < (TolTangency * 10.0))
+ {
+ nTolTangency = (Pfin - Pdeb) * 0.1;
+ }
+ if (EpsX > (nTolTangency + nTolTangency))
+ {
+ EpsX = nTolTangency * 0.1;
}
//--------------------------------------------------
- //-- Plante avec un edge avec 2 Samples
- //-- dont les extremites son solutions (f=0)
- //-- et ou la derivee est nulle
+ //-- Plante avec un edge avec 2 Samples
+ //-- dont les extremites son solutions (f=0)
+ //-- et ou la derivee est nulle
//-- Exemple : un segment diametre d une sphere
//-- if(NbEchant<3) NbEchant = 3; //-- lbr le 19 Avril 95
//--------------------------------------------------
- Standard_Real para=0,dist,maxdist;
-
- //-------------------------------------------------------------- REJECTIONS le 15 oct 98
- Standard_Boolean Rejection=Standard_True;
- Standard_Real maxdr,maxr,minr,ur,dur;
- minr=RealLast();
- maxr=-minr;
- maxdr=-minr;
- dur=(Pfin-Pdeb)*0.2;
- for(i=1,ur=Pdeb;i<=6;i++) {
- Standard_Real F,D;
- if(Func.Values(ur,F,D)) {
- Standard_Real lminr,lmaxr;
- if(D<0.0) D=-D;
- D*=dur+dur;
- if(D>maxdr) maxdr=D;
- lminr=F-D;
- lmaxr=F+D;
- if(lminr<minr) minr=lminr;
- if(lmaxr>maxr) maxr=lmaxr;
- if(minr<0.0 && maxr>0.0) {
- Rejection=Standard_False;
+ Standard_Real para = 0, dist, maxdist;
+
+ //-------------------------------------------------------------- REJECTIONS le 15 oct 98
+ Standard_Boolean Rejection = Standard_True;
+ Standard_Real maxdr, maxr, minr, ur, dur;
+ minr = RealLast();
+ maxr = -minr;
+ maxdr = -minr;
+ dur = (Pfin - Pdeb) * 0.2;
+ for (i = 1, ur = Pdeb; i <= 6; i++)
+ {
+ Standard_Real F, D;
+ if (Func.Values(ur, F, D))
+ {
+ Standard_Real lminr, lmaxr;
+ if (D < 0.0)
+ D = -D;
+ D *= dur + dur;
+ if (D > maxdr)
+ maxdr = D;
+ lminr = F - D;
+ lmaxr = F + D;
+ if (lminr < minr)
+ minr = lminr;
+ if (lmaxr > maxr)
+ maxr = lmaxr;
+ if (minr < 0.0 && maxr > 0.0)
+ {
+ Rejection = Standard_False;
break;
}
}
- ur+=dur;
+ ur += dur;
}
- if(Rejection)
+ if (Rejection)
{
- dur=0.001+maxdr+(maxr-minr)*0.1;
- minr-=dur;
- maxr+=dur;
- if(minr<0.0 && maxr>0.0) {
- Rejection=Standard_False;
+ dur = 0.001 + maxdr + (maxr - minr) * 0.1;
+ minr -= dur;
+ maxr += dur;
+ if (minr < 0.0 && maxr > 0.0)
+ {
+ Rejection = Standard_False;
}
}
- Arcsol=Standard_False;
+ Arcsol = Standard_False;
- if(Rejection==Standard_False)
+ if (Rejection == Standard_False)
{
const IntSurf_Quadric& aQuadric = Func.Quadric();
- GeomAbs_SurfaceType TypeQuad = aQuadric.TypeQuadric();
- GeomAbs_CurveType TypeConS = GeomAbs_OtherCurve;
-
+ GeomAbs_SurfaceType TypeQuad = aQuadric.TypeQuadric();
+ GeomAbs_CurveType TypeConS = GeomAbs_OtherCurve;
+
IntCurveSurface_HInter IntCS;
- Standard_Boolean IsIntCSdone = Standard_False;
+ Standard_Boolean IsIntCSdone = Standard_False;
TColStd_SequenceOfReal Params;
-
+
std::unique_ptr<math_FunctionAllRoots> pSol;
-
- math_FunctionSample Echant(Pdeb,Pfin,NbEchant);
- Standard_Boolean aelargir=Standard_True;
- //modified by NIZNHY-PKV Thu Apr 12 09:25:19 2001 f
+ math_FunctionSample Echant(Pdeb, Pfin, NbEchant);
+
+ Standard_Boolean aelargir = Standard_True;
+ // modified by NIZNHY-PKV Thu Apr 12 09:25:19 2001 f
//
- //maxdist = 100.0*TolBoundary;
- maxdist = TolBoundary+TolTangency;
+ // maxdist = 100.0*TolBoundary;
+ maxdist = TolBoundary + TolTangency;
//
- //modified by NIZNHY-PKV Thu Apr 12 09:25:23 2001 t
- for(i=1; i<=NbEchant && aelargir;i++) {
+ // modified by NIZNHY-PKV Thu Apr 12 09:25:23 2001 t
+ for (i = 1; i <= NbEchant && aelargir; i++)
+ {
Standard_Real u = Echant.GetParameter(i);
- if(Func.Value(u,dist)) {
- if(dist>maxdist || -dist>maxdist) {
- aelargir=Standard_False;
+ if (Func.Value(u, dist))
+ {
+ if (dist > maxdist || -dist > maxdist)
+ {
+ aelargir = Standard_False;
}
}
}
- if(!(aelargir && maxdist<0.01)) {
+ if (!(aelargir && maxdist < 0.01))
+ {
maxdist = TolBoundary;
}
- if (TypeQuad != GeomAbs_OtherSurface) //intersection of boundary curve and quadric surface
+ if (TypeQuad != GeomAbs_OtherSurface) // intersection of boundary curve and quadric surface
{
- //Exact solution
+ // Exact solution
Handle(Adaptor3d_Surface) aSurf = Func.Surface();
- Adaptor3d_CurveOnSurface ConS(A, aSurf);
+ Adaptor3d_CurveOnSurface ConS(A, aSurf);
TypeConS = ConS.GetType();
#ifdef OCCT_DEBUG
Handle(Geom_Curve) CurveConS;
- switch(TypeConS)
+ switch (TypeConS)
{
- case GeomAbs_Line:
- {
+ case GeomAbs_Line: {
CurveConS = new Geom_Line(ConS.Line());
break;
}
- case GeomAbs_Circle:
- {
+ case GeomAbs_Circle: {
CurveConS = new Geom_Circle(ConS.Circle());
break;
}
- case GeomAbs_Ellipse:
- {
+ case GeomAbs_Ellipse: {
CurveConS = new Geom_Ellipse(ConS.Ellipse());
break;
}
- case GeomAbs_Hyperbola:
- {
+ case GeomAbs_Hyperbola: {
CurveConS = new Geom_Hyperbola(ConS.Hyperbola());
break;
}
- case GeomAbs_Parabola:
- {
+ case GeomAbs_Parabola: {
CurveConS = new Geom_Parabola(ConS.Parabola());
break;
}
- case GeomAbs_BezierCurve:
- {
+ case GeomAbs_BezierCurve: {
CurveConS = ConS.Bezier();
break;
}
- case GeomAbs_BSplineCurve:
- {
+ case GeomAbs_BSplineCurve: {
CurveConS = ConS.BSpline();
break;
}
- default:
- {
+ default: {
Standard_Real MaxDeviation, AverageDeviation;
- GeomLib::BuildCurve3d(1.e-5, ConS, ConS.FirstParameter(), ConS.LastParameter(),
- CurveConS, MaxDeviation, AverageDeviation);
+ GeomLib::BuildCurve3d(1.e-5,
+ ConS,
+ ConS.FirstParameter(),
+ ConS.LastParameter(),
+ CurveConS,
+ MaxDeviation,
+ AverageDeviation);
break;
}
}
#endif
Handle(Adaptor3d_CurveOnSurface) HConS = new Adaptor3d_CurveOnSurface(ConS);
- Handle(Geom_Surface) QuadSurf;
+ Handle(Geom_Surface) QuadSurf;
switch (TypeQuad)
{
- case GeomAbs_Plane:
- {
+ case GeomAbs_Plane: {
QuadSurf = new Geom_Plane(aQuadric.Plane());
break;
}
- case GeomAbs_Cylinder:
- {
+ case GeomAbs_Cylinder: {
QuadSurf = new Geom_CylindricalSurface(aQuadric.Cylinder());
break;
}
- case GeomAbs_Cone:
- {
+ case GeomAbs_Cone: {
QuadSurf = new Geom_ConicalSurface(aQuadric.Cone());
break;
}
- case GeomAbs_Sphere:
- {
+ case GeomAbs_Sphere: {
QuadSurf = new Geom_SphericalSurface(aQuadric.Sphere());
break;
}
- case GeomAbs_Torus:
- {
+ case GeomAbs_Torus: {
QuadSurf = new Geom_ToroidalSurface(aQuadric.Torus());
break;
}
- default:
- break;
+ default:
+ break;
}
Handle(GeomAdaptor_Surface) GAHsurf = new GeomAdaptor_Surface(QuadSurf);
-
- if ((TypeConS == GeomAbs_Line ||
- TypeConS == GeomAbs_Circle ||
- TypeConS == GeomAbs_Ellipse ||
- TypeConS == GeomAbs_Parabola ||
- TypeConS == GeomAbs_Hyperbola) &&
- TypeQuad != GeomAbs_Torus &&
- !IsDegenerated(HConS) &&
- !IsDegenerated(aQuadric))
+
+ if ((TypeConS == GeomAbs_Line || TypeConS == GeomAbs_Circle || TypeConS == GeomAbs_Ellipse
+ || TypeConS == GeomAbs_Parabola || TypeConS == GeomAbs_Hyperbola)
+ && TypeQuad != GeomAbs_Torus && !IsDegenerated(HConS) && !IsDegenerated(aQuadric))
{
- //exact intersection for only canonic curves and real quadric surfaces
+ // exact intersection for only canonic curves and real quadric surfaces
IntCS.Perform(HConS, GAHsurf);
}
-
+
IsIntCSdone = IntCS.IsDone();
if (IsIntCSdone)
{
Nbp = IntCS.NbPoints();
Nbi = IntCS.NbSegments();
}
- //If we have not got intersection, it may be touch with some tolerance,
- //need to be checked
+ // If we have not got intersection, it may be touch with some tolerance,
+ // need to be checked
if (Nbp == 0 && Nbi == 0)
IsIntCSdone = Standard_False;
- } //if (TypeQuad != GeomAbs_OtherSurface) - intersection of boundary curve and quadric surface
-
+ } // if (TypeQuad != GeomAbs_OtherSurface) - intersection of boundary curve and quadric surface
+
if (!IsIntCSdone)
{
- pSol.reset(new math_FunctionAllRoots(Func,Echant,EpsX,maxdist,maxdist)); //-- TolBoundary,nTolTangency);
-
- if (!pSol->IsDone()) {throw Standard_Failure();}
-
- Nbp=pSol->NbPoints();
+ pSol.reset(new math_FunctionAllRoots(Func,
+ Echant,
+ EpsX,
+ maxdist,
+ maxdist)); //-- TolBoundary,nTolTangency);
+
+ if (!pSol->IsDone())
+ {
+ throw Standard_Failure();
+ }
+
+ Nbp = pSol->NbPoints();
}
//
- //jgv: build solution on the whole boundary
+ // jgv: build solution on the whole boundary
if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain))
{
- //Standard_Real theTol = Domain->MaxTolerance(A);
- //theTol += theTol;
- Standard_Real theTol = 5.e-4;
- math_FunctionAllRoots SolAgain(Func,Echant,EpsX,theTol,theTol); //-- TolBoundary,nTolTangency);
-
- if (!SolAgain.IsDone()) {throw Standard_Failure();}
+ // Standard_Real theTol = Domain->MaxTolerance(A);
+ // theTol += theTol;
+ Standard_Real theTol = 5.e-4;
+ math_FunctionAllRoots SolAgain(Func,
+ Echant,
+ EpsX,
+ theTol,
+ theTol); //-- TolBoundary,nTolTangency);
+
+ if (!SolAgain.IsDone())
+ {
+ throw Standard_Failure();
+ }
Standard_Integer Nbi_again = SolAgain.NbIntervals();
if (Nbi_again > 0)
{
- Standard_Integer NbSamples = 10;
- Standard_Real delta = (Pfin - Pdeb)/NbSamples;
- Standard_Real GlobalTol = theTol*10;
+ Standard_Integer NbSamples = 10;
+ Standard_Real delta = (Pfin - Pdeb) / NbSamples;
+ Standard_Real GlobalTol = theTol * 10;
Standard_Boolean SolOnBoundary = Standard_True;
for (i = 0; i <= NbSamples; i++)
{
- Standard_Real aParam = Pdeb + i*delta;
+ Standard_Real aParam = Pdeb + i * delta;
Standard_Real aValue;
Func.Value(aParam, aValue);
if (Abs(aValue) > GlobalTol)
IntStart_TheSegment newseg;
newseg.SetValue(A);
// Recuperer point debut et fin, et leur parametre.
- SolAgain.GetInterval(i,pardeb,parfin);
+ SolAgain.GetInterval(i, pardeb, parfin);
if (Abs(pardeb - Pdeb) <= Precision::PConfusion())
pardeb = Pdeb;
if (Abs(parfin - Pfin) <= Precision::PConfusion())
parfin = Pfin;
- SolAgain.GetIntervalState(i,ideb,ifin);
+ SolAgain.GetIntervalState(i, ideb, ifin);
- //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<" ParFin:"<<parfin<<endl;
+ //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<"
+ // ParFin:"<<parfin<<endl;
- ptdeb=Func.Valpoint(ideb);
- ptfin=Func.Valpoint(ifin);
+ ptdeb = Func.Valpoint(ideb);
+ ptfin = Func.Valpoint(ifin);
- PointProcess(ptdeb,pardeb,A,Domain,pnt,theTol,ranged);
- newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
- PointProcess(ptfin,parfin,A,Domain,pnt,theTol,rangef);
- newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
+ PointProcess(ptdeb, pardeb, A, Domain, pnt, theTol, ranged);
+ newseg.SetLimitPoint(pnt.Value(ranged), Standard_True);
+ PointProcess(ptfin, parfin, A, Domain, pnt, theTol, rangef);
+ newseg.SetLimitPoint(pnt.Value(rangef), Standard_False);
seg.Append(newseg);
}
- Arcsol=Standard_True;
+ Arcsol = Standard_True;
return;
}
}
- } //if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain))
+ } // if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain))
////////////////////////////////////////////
- //-- detection du cas ou la fonction est quasi tangente et que les
- //-- zeros sont quasi confondus.
+ //-- detection du cas ou la fonction est quasi tangente et que les
+ //-- zeros sont quasi confondus.
//-- Dans ce cas on prend le point "milieu"
- //-- On suppose que les solutions sont triees.
+ //-- On suppose que les solutions sont triees.
- if(Nbp) {
+ if (Nbp)
+ {
NCollection_Array1<SolInfo> aSI(1, Nbp);
- for(i=1;i<=Nbp;i++)
+ for (i = 1; i <= Nbp; i++)
{
if (IsIntCSdone)
aSI(i).Init(IntCS, i);
std::sort(aSI.begin(), aSI.end());
- //modified by NIZNHY-PKV Wed Mar 21 18:34:18 2001 f
+ // modified by NIZNHY-PKV Wed Mar 21 18:34:18 2001 f
//////////////////////////////////////////////////////////
- // The treatment of the situation when line(arc) that is
- // tangent to cylinder(domain).
+ // The treatment of the situation when line(arc) that is
+ // tangent to cylinder(domain).
// We should have only one solution i.e Nbp=1. Ok?
// But we have 2,3,.. solutions. That is wrong ersult.
// The TreatLC(...) function is dedicated to solve the pb.
// PKV Fri Mar 23 12:17:29 2001
- Standard_Integer ip = TreatLC (A, Domain, aQuadric, TolBoundary, pnt);
- if (ip) {
+ Standard_Integer ip = TreatLC(A, Domain, aQuadric, TolBoundary, pnt);
+ if (ip)
+ {
//////////////////////////////////////////////////////////
- //modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t
- //
- // Using of old usual way proposed by Laurent
+ // modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t
+ //
+ // Using of old usual way proposed by Laurent
//
- for(i=1;i<Nbp;i++) {
+ for (i = 1; i < Nbp; i++)
+ {
Standard_Real parap1 = aSI(i + 1).Value();
- para = aSI(i).Value();
+ para = aSI(i).Value();
- Standard_Real param=(para+parap1)*0.5;
- Standard_Real yf = 0.0;
- Standard_Real ym = 0.0;
- Standard_Real yl = 0.0;
- if(Func.Value(param,ym) && Abs(ym) < maxdist) {
- Standard_Real sm = Sign(1., ym);
- Standard_Boolean aTang = Func.Value(para,yf) && Func.Value(parap1,yl);
- if (aTang) {
- //Line can be tangent surface if all distances less then maxdist
+ Standard_Real param = (para + parap1) * 0.5;
+ Standard_Real yf = 0.0;
+ Standard_Real ym = 0.0;
+ Standard_Real yl = 0.0;
+ if (Func.Value(param, ym) && Abs(ym) < maxdist)
+ {
+ Standard_Real sm = Sign(1., ym);
+ Standard_Boolean aTang = Func.Value(para, yf) && Func.Value(parap1, yl);
+ if (aTang)
+ {
+ // Line can be tangent surface if all distances less then maxdist
aTang = aTang && Abs(yf) < maxdist && Abs(yl) < maxdist;
}
- if (aTang && IsIntCSdone && TypeConS == GeomAbs_Line) {
- //Interval is got by exact intersection
- //Line can be tangent if all points are on the same side of surface
- //it means that signs of all distances are the same
+ if (aTang && IsIntCSdone && TypeConS == GeomAbs_Line)
+ {
+ // Interval is got by exact intersection
+ // Line can be tangent if all points are on the same side of surface
+ // it means that signs of all distances are the same
Standard_Real sf = Sign(1., yf), sl = Sign(1., yl);
aTang = aTang && (sm == sf) && (sm == sl);
}
- if(aTang) {
+ if (aTang)
+ {
// Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 Begin
// Consider this interval as tangent one. Treat it to find
// parameter with the lowest function value.
// Compute the number of nodes.
- Standard_Real aTol = TolBoundary*1000.0;
- if(aTol > 0.001)
+ Standard_Real aTol = TolBoundary * 1000.0;
+ if (aTol > 0.001)
aTol = 0.001;
// fix floating point exception 569, chl-922-e9
parap1 = (Abs(parap1) < 1.e9) ? parap1 : ((parap1 >= 0.) ? 1.e9 : -1.e9);
para = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9);
- Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol));
+ Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para) / aTol));
- Standard_Real aVal = RealLast();
+ Standard_Real aVal = RealLast();
Standard_Real aValMax = 0.;
- //Standard_Integer aNbNodes = 23;
- Standard_Real aDelta = (parap1 - para)/(aNbNodes + 1.);
+ // Standard_Integer aNbNodes = 23;
+ Standard_Real aDelta = (parap1 - para) / (aNbNodes + 1.);
Standard_Integer ii;
Standard_Real aCurPar;
Standard_Real aCurVal;
- for (ii = 0; ii <= aNbNodes + 1; ii++) {
- aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1;
+ for (ii = 0; ii <= aNbNodes + 1; ii++)
+ {
+ aCurPar = (ii < aNbNodes + 1) ? para + ii * aDelta : parap1;
- if (Func.Value(aCurPar, aCurVal)) {
+ if (Func.Value(aCurPar, aCurVal))
+ {
Standard_Real anAbsVal = Abs(aCurVal);
- if (anAbsVal < aVal) {
+ if (anAbsVal < aVal)
+ {
aVal = anAbsVal;
param = aCurPar;
}
// At last, interval got by exact intersection can be considered as tangent if
// minimal distance is inside interval and
// minimal and maximal values are almost the same
- if (IsIntCSdone && aNbNodes > 1) {
- aTang = Abs(param - para) > EpsX && Abs(parap1 - param) > EpsX &&
- 0.01*aValMax <= aVal;
+ if (IsIntCSdone && aNbNodes > 1)
+ {
+ aTang =
+ Abs(param - para) > EpsX && Abs(parap1 - param) > EpsX && 0.01 * aValMax <= aVal;
}
if (aTang)
{
- aSI(i).ChangeValue() = Pdeb - 1;
+ aSI(i).ChangeValue() = Pdeb - 1;
aSI(i + 1).ChangeValue() = param;
}
}
}
}
- for (i=1; i<=Nbp; i++) {
+ for (i = 1; i <= Nbp; i++)
+ {
para = aSI(i).Value();
- if((para-Pdeb)<EpsX || (Pfin-para)<EpsX)
+ if ((para - Pdeb) < EpsX || (Pfin - para) < EpsX)
continue;
- if(!Func.Value(para,dist))
+ if (!Func.Value(para, dist))
continue;
dist = Abs(dist);
Standard_Integer anIndx = -1;
- //const Standard_Real aParam = Sol->GetPoint(aSI(i).Index());
+ // const Standard_Real aParam = Sol->GetPoint(aSI(i).Index());
const Standard_Real aParam = aSI(i).Value();
if (dist < maxdist)
{
- if (!IsIntCSdone &&
- (Abs(aParam - Pdeb) <= Precision::PConfusion() || Abs(aParam - Pfin) <= Precision::PConfusion()))
+ if (!IsIntCSdone
+ && (Abs(aParam - Pdeb) <= Precision::PConfusion()
+ || Abs(aParam - Pfin) <= Precision::PConfusion()))
{
anIndx = pSol->GetPointState(aSI(i).Index());
}
gp_Pnt aPnt(anIndx < 0 ? Func.LastComputedPoint() : Func.Valpoint(anIndx));
- if (dist > 0.1*Precision::Confusion())
+ if (dist > 0.1 * Precision::Confusion())
{
- //Precise found points. It results in following:
- // 1. Make the vertex nearer to the intersection line
- // (see description to issue #27252 in order to
- // understand necessity).
- // 2. Merge two near vertices to single point.
-
- //All members in TabSol array has already been sorted in increase order.
- //Now, we limit precise boundaries in order to avoid changing this order.
+ // Precise found points. It results in following:
+ // 1. Make the vertex nearer to the intersection line
+ // (see description to issue #27252 in order to
+ // understand necessity).
+ // 2. Merge two near vertices to single point.
+
+ // All members in TabSol array has already been sorted in increase order.
+ // Now, we limit precise boundaries in order to avoid changing this order.
const Standard_Real aFPar = (i == 1) ? Pdeb : (para + aSI(i - 1).Value()) / 2.0;
const Standard_Real aLPar = (i == Nbp) ? Pfin : (para + aSI(i + 1).Value()) / 2.0;
- MinFunction aNewFunc(Func);
+ MinFunction aNewFunc(Func);
math_BrentMinimum aMin(Precision::Confusion());
aMin.Perform(aNewFunc, aFPar, para, aLPar);
- if(aMin.IsDone())
+ if (aMin.IsDone())
{
para = aMin.Location();
const gp_Pnt2d aP2d(A->Value(para));
PointProcess(aPnt, para, A, Domain, pnt, TolBoundary, range);
}
- }// end of if(ip)
- } // end of if(Nbp)
+ } // end of if(ip)
+ } // end of if(Nbp)
// Pour chaque intervalle trouve faire
// Traiter les extremites comme des points
if (!IsIntCSdone)
Nbi = pSol->NbIntervals();
- if (!RecheckOnRegularity && Nbp) {
+ if (!RecheckOnRegularity && Nbp)
+ {
//--cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx :Nbp>0 0 <- Nbi "<<Nbi<<endl;
- Nbi=0;
+ Nbi = 0;
}
//-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : Nbi : "<<Nbi<<endl;
- for (i=1; i<=Nbi; i++) {
+ for (i = 1; i <= Nbi; i++)
+ {
IntStart_TheSegment newseg;
newseg.SetValue(A);
// Recuperer point debut et fin, et leur parametre.
if (IsIntCSdone)
{
IntCurveSurface_IntersectionSegment IntSeg = IntCS.Segment(i);
- IntCurveSurface_IntersectionPoint End1 = IntSeg.FirstPoint();
- IntCurveSurface_IntersectionPoint End2 = IntSeg.SecondPoint();
- pardeb = End1.W();
- parfin = End2.W();
- ptdeb = End1.Pnt();
- ptfin = End2.Pnt();
+ IntCurveSurface_IntersectionPoint End1 = IntSeg.FirstPoint();
+ IntCurveSurface_IntersectionPoint End2 = IntSeg.SecondPoint();
+ pardeb = End1.W();
+ parfin = End2.W();
+ ptdeb = End1.Pnt();
+ ptfin = End2.Pnt();
}
else
{
- pSol->GetInterval(i,pardeb,parfin);
- pSol->GetIntervalState(i,ideb,ifin);
+ pSol->GetInterval(i, pardeb, parfin);
+ pSol->GetIntervalState(i, ideb, ifin);
+
+ //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<"
+ // ParFin:"<<parfin<<endl;
- //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<" ParFin:"<<parfin<<endl;
-
- ptdeb=Func.Valpoint(ideb);
- ptfin=Func.Valpoint(ifin);
+ ptdeb = Func.Valpoint(ideb);
+ ptfin = Func.Valpoint(ifin);
}
- PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged);
- newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
- PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef);
- newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
+ PointProcess(ptdeb, pardeb, A, Domain, pnt, TolBoundary, ranged);
+ newseg.SetLimitPoint(pnt.Value(ranged), Standard_True);
+ PointProcess(ptfin, parfin, A, Domain, pnt, TolBoundary, rangef);
+ newseg.SetLimitPoint(pnt.Value(rangef), Standard_False);
seg.Append(newseg);
}
- if (Nbi==1) {
- if((Abs(pardeb - Pdeb) < Precision::PConfusion()) &&
- (Abs(parfin - Pfin) < Precision::PConfusion()))
+ if (Nbi == 1)
+ {
+ if ((Abs(pardeb - Pdeb) < Precision::PConfusion())
+ && (Abs(parfin - Pfin) < Precision::PConfusion()))
{
- Arcsol=Standard_True;
+ Arcsol = Standard_True;
}
}
}
// - PROVISIONAL - TEMPORARY - NOT GOOD - NYI - TO DO
// - Temporary - temporary - not good - nyi - to do
-void ComputeBoundsfromInfinite(TheFunction& Func,
- Standard_Real& PDeb,
- Standard_Real& PFin,
- Standard_Integer& NbEchant)
-{
-
+void ComputeBoundsfromInfinite(TheFunction& Func,
+ Standard_Real& PDeb,
+ Standard_Real& PFin,
+ Standard_Integer& NbEchant)
+{
+
// - We are looking for parameters for start and end of the arc (2d curve)
// - Infinity, a way to intersect the quadric with a portion of arc
// - Finished.
NbEchant = 100;
- Standard_Real U0 = 0.0;
- Standard_Real dU = 0.001;
- Standard_Real Dist0,Dist1;
+ Standard_Real U0 = 0.0;
+ Standard_Real dU = 0.001;
+ Standard_Real Dist0, Dist1;
- Func.Value(U0 , Dist0);
- Func.Value(U0+dU, Dist1);
+ Func.Value(U0, Dist0);
+ Func.Value(U0 + dU, Dist1);
Standard_Real dDist = Dist1 - Dist0;
- if(dDist) {
- U0 -= dU*Dist0 / dDist;
- PDeb = PFin = U0;
+ if (dDist)
+ {
+ U0 -= dU * Dist0 / dDist;
+ PDeb = PFin = U0;
Standard_Real Umin = U0 - 1e5;
- Func.Value(Umin , Dist0);
- Func.Value(Umin+dU, Dist1);
- dDist = Dist1-Dist0;
- if(dDist) {
- Umin -= dU*Dist0 / dDist;
+ Func.Value(Umin, Dist0);
+ Func.Value(Umin + dU, Dist1);
+ dDist = Dist1 - Dist0;
+ if (dDist)
+ {
+ Umin -= dU * Dist0 / dDist;
}
- else {
- Umin-=10.0;
+ else
+ {
+ Umin -= 10.0;
}
Standard_Real Umax = U0 + 1e8;
- Func.Value(Umax , Dist0);
- Func.Value(Umax+dU, Dist1);
- dDist = Dist1-Dist0;
- if(dDist) {
- Umax -= dU*Dist0 / dDist;
+ Func.Value(Umax, Dist0);
+ Func.Value(Umax + dU, Dist1);
+ dDist = Dist1 - Dist0;
+ if (dDist)
+ {
+ Umax -= dU * Dist0 / dDist;
}
- else {
- Umax+=10.0;
+ else
+ {
+ Umax += 10.0;
+ }
+ if (Umin > U0)
+ {
+ Umin = U0 - 10.0;
}
- if(Umin>U0) { Umin=U0-10.0; }
- if(Umax<U0) { Umax=U0+10.0; }
-
+ if (Umax < U0)
+ {
+ Umax = U0 + 10.0;
+ }
+
PFin = Umax + 10. * (Umax - Umin);
PDeb = Umin - 10. * (Umax - Umin);
}
- else {
+ else
+ {
//-- Possibilite de Arc totalement inclu ds Quad
PDeb = 1e10;
PFin = -1e10;
}
-}
+}
//=================================================================================================
-void PointProcess (const gp_Pnt& Pt,
- const Standard_Real Para,
- const TheArc& A,
- const Handle(TheTopolTool)& Domain,
- IntStart_SequenceOfPathPoint& pnt,
- const Standard_Real Tol,
- Standard_Integer& Range)
+void PointProcess(const gp_Pnt& Pt,
+ const Standard_Real Para,
+ const TheArc& A,
+ const Handle(TheTopolTool)& Domain,
+ IntStart_SequenceOfPathPoint& pnt,
+ const Standard_Real Tol,
+ Standard_Integer& Range)
{
-// Check to see if a solution point is coincident with a vertex.
-// If confused, you should find this vertex in the list of
-// Start. It then returns the position of this point in the list pnt.
-// Otherwise, add the point in the list.
-
+ // Check to see if a solution point is coincident with a vertex.
+ // If confused, you should find this vertex in the list of
+ // Start. It then returns the position of this point in the list pnt.
+ // Otherwise, add the point in the list.
+
Standard_Integer k;
- Standard_Boolean found,goon;
- Standard_Real dist,toler;
+ Standard_Boolean found, goon;
+ Standard_Real dist, toler;
- Standard_Integer Nbsol = pnt.Length();
- TheVertex vtx;
+ Standard_Integer Nbsol = pnt.Length();
+ TheVertex vtx;
IntStart_ThePathPoint ptsol;
Domain->Initialize(A);
Domain->InitVertexIterator();
found = Standard_False;
- goon = Domain->MoreVertex();
- while (goon) {
- vtx = Domain->Vertex();
- dist= Abs(Para-TheSOBTool::Parameter(vtx,A));
- toler = TheSOBTool::Tolerance(vtx,A);
+ goon = Domain->MoreVertex();
+ while (goon)
+ {
+ vtx = Domain->Vertex();
+ dist = Abs(Para - TheSOBTool::Parameter(vtx, A));
+ toler = TheSOBTool::Tolerance(vtx, A);
#ifdef OCCT_DEBUG
- if(toler>0.1) {
- std::cout<<"IntStart_SearchOnBoundaries_1.gxx : ** WARNING ** Tol Vertex="<<toler<<std::endl;
- std::cout<<" Ou Edge degenere Ou Kro pointu"<<std::endl;
- if(toler>10000) toler=1e-7;
+ if (toler > 0.1)
+ {
+ std::cout << "IntStart_SearchOnBoundaries_1.gxx : ** WARNING ** Tol Vertex=" << toler
+ << std::endl;
+ std::cout << " Ou Edge degenere Ou Kro pointu"
+ << std::endl;
+ if (toler > 10000)
+ toler = 1e-7;
}
#endif
- if (dist <= toler) {
+ if (dist <= toler)
+ {
// Locate the vertex in the list of solutions
- k=1;
- found = (k>Nbsol);
- while (!found) {
+ k = 1;
+ found = (k > Nbsol);
+ while (!found)
+ {
ptsol = pnt.Value(k);
- if (!ptsol.IsNew()) {
- //jag 940608 if (ptsol.Vertex() == vtx && ptsol.Arc() == A) {
- if (Domain->Identical(ptsol.Vertex(),vtx) &&
- ptsol.Arc() == A &&
- Abs(ptsol.Parameter()-Para) <= toler) {
- found=Standard_True;
+ if (!ptsol.IsNew())
+ {
+ // jag 940608 if (ptsol.Vertex() == vtx && ptsol.Arc() == A) {
+ if (Domain->Identical(ptsol.Vertex(), vtx) && ptsol.Arc() == A
+ && Abs(ptsol.Parameter() - Para) <= toler)
+ {
+ found = Standard_True;
}
- else {
- k=k+1;
- found=(k>Nbsol);
+ else
+ {
+ k = k + 1;
+ found = (k > Nbsol);
}
}
- else {
- k=k+1;
- found=(k>Nbsol);
+ else
+ {
+ k = k + 1;
+ found = (k > Nbsol);
}
}
- if (k<=Nbsol) { // We find the vertex
+ if (k <= Nbsol)
+ { // We find the vertex
Range = k;
}
- else { // Otherwise
- ptsol.SetValue(Pt,Tol,vtx,A,Para);
+ else
+ { // Otherwise
+ ptsol.SetValue(Pt, Tol, vtx, A, Para);
pnt.Append(ptsol);
Range = pnt.Length();
}
found = Standard_True;
- goon = Standard_False;
+ goon = Standard_False;
}
- else {
+ else
+ {
Domain->NextVertex();
goon = Domain->MoreVertex();
}
}
- if (!found) { // No one is falling on a vertex
- //jgv: do not add segment's extremities if they already exist
+ if (!found)
+ { // No one is falling on a vertex
+ // jgv: do not add segment's extremities if they already exist
Standard_Boolean found_internal = Standard_False;
for (k = 1; k <= pnt.Length(); k++)
{
ptsol = pnt.Value(k);
- if (ptsol.Arc() != A ||
- !ptsol.IsNew()) //vertex
+ if (ptsol.Arc() != A || !ptsol.IsNew()) // vertex
continue;
- if (Abs(ptsol.Parameter()-Para) <= Precision::PConfusion())
+ if (Abs(ptsol.Parameter() - Para) <= Precision::PConfusion())
{
found_internal = Standard_True;
- Range = k;
+ Range = k;
}
}
/////////////////////////////////////////////////////////////
if (!found_internal)
{
- Standard_Real TOL=Tol;
- TOL*=1000.0;
- //if(TOL>0.001) TOL=0.001;
- if(TOL>0.005) TOL=0.005; //#24643
-
- ptsol.SetValue(Pt,TOL,A,Para);
+ Standard_Real TOL = Tol;
+ TOL *= 1000.0;
+ // if(TOL>0.001) TOL=0.001;
+ if (TOL > 0.005)
+ TOL = 0.005; // #24643
+
+ ptsol.SetValue(Pt, TOL, A, Para);
pnt.Append(ptsol);
Range = pnt.Length();
}
//=================================================================================================
-Standard_Boolean IsRegularity(const TheArc& /*A*/,
- const Handle(TheTopolTool)& aDomain)
+Standard_Boolean IsRegularity(const TheArc& /*A*/, const Handle(TheTopolTool)& aDomain)
{
- Standard_Address anEAddress=aDomain->Edge();
- if (anEAddress==NULL) {
+ Standard_Address anEAddress = aDomain->Edge();
+ if (anEAddress == NULL)
+ {
return Standard_False;
}
-
- TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress;
-
+
+ TopoDS_Edge* anE = (TopoDS_Edge*)anEAddress;
+
return (BRep_Tool::HasContinuity(*anE));
}
//=================================================================================================
-Standard_Integer TreatLC (const TheArc& A,
- const Handle(TheTopolTool)& aDomain,
- const IntSurf_Quadric& aQuadric,
- const Standard_Real TolBoundary,
- IntStart_SequenceOfPathPoint& pnt)
+Standard_Integer TreatLC(const TheArc& A,
+ const Handle(TheTopolTool)& aDomain,
+ const IntSurf_Quadric& aQuadric,
+ const Standard_Real TolBoundary,
+ IntStart_SequenceOfPathPoint& pnt)
{
- Standard_Integer anExitCode=1, aNbExt;
-
- Standard_Address anEAddress=aDomain->Edge();
- if (anEAddress==NULL) {
+ Standard_Integer anExitCode = 1, aNbExt;
+
+ Standard_Address anEAddress = aDomain->Edge();
+ if (anEAddress == NULL)
+ {
return anExitCode;
}
-
- TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress;
- if (BRep_Tool::Degenerated(*anE)) {
+ TopoDS_Edge* anE = (TopoDS_Edge*)anEAddress;
+
+ if (BRep_Tool::Degenerated(*anE))
+ {
return anExitCode;
}
-
- GeomAbs_CurveType aTypeE;
+
+ GeomAbs_CurveType aTypeE;
BRepAdaptor_Curve aBAC(*anE);
- aTypeE=aBAC.GetType();
-
- if (aTypeE!=GeomAbs_Line) {
+ aTypeE = aBAC.GetType();
+
+ if (aTypeE != GeomAbs_Line)
+ {
return anExitCode;
}
-
+
GeomAbs_SurfaceType aTypeS;
- aTypeS=aQuadric.TypeQuadric();
-
- if (aTypeS!=GeomAbs_Cylinder) {
+ aTypeS = aQuadric.TypeQuadric();
+
+ if (aTypeS != GeomAbs_Cylinder)
+ {
return anExitCode;
}
-
- Standard_Real f, l, U1f, U1l, U2f, U2l, UEgde, TOL, aDist, aR, aRRel, Tol;
- Handle(Geom_Curve) aCEdge=BRep_Tool::Curve(*anE, f, l);
-
- gp_Cylinder aCyl=aQuadric.Cylinder();
- const gp_Ax1& anAx1=aCyl.Axis();
- gp_Lin aLin(anAx1);
- Handle(Geom_Line) aCAxis=new Geom_Line (aLin);
- aR=aCyl.Radius();
-
+
+ Standard_Real f, l, U1f, U1l, U2f, U2l, UEgde, TOL, aDist, aR, aRRel, Tol;
+ Handle(Geom_Curve) aCEdge = BRep_Tool::Curve(*anE, f, l);
+
+ gp_Cylinder aCyl = aQuadric.Cylinder();
+ const gp_Ax1& anAx1 = aCyl.Axis();
+ gp_Lin aLin(anAx1);
+ Handle(Geom_Line) aCAxis = new Geom_Line(aLin);
+ aR = aCyl.Radius();
+
U1f = aCAxis->FirstParameter();
U1l = aCAxis->LastParameter();
-
+
U2f = aCEdge->FirstParameter();
U2l = aCEdge->LastParameter();
-
GeomAdaptor_Curve C1, C2;
-
+
C1.Load(aCAxis);
C2.Load(aCEdge);
-
+
Tol = Precision::PConfusion();
- Extrema_ExtCC anExtCC(C1, C2, U1f, U1l, U2f, U2l, Tol, Tol);
+ Extrema_ExtCC anExtCC(C1, C2, U1f, U1l, U2f, U2l, Tol, Tol);
- aNbExt=anExtCC.NbExt();
- if (aNbExt!=1) {
+ aNbExt = anExtCC.NbExt();
+ if (aNbExt != 1)
+ {
return anExitCode;
}
- gp_Pnt P1,PEdge;
+ gp_Pnt P1, PEdge;
Extrema_POnCurv PC1, PC2;
-
+
anExtCC.Points(1, PC1, PC2);
-
- P1 =PC1.Value();
- PEdge=PC2.Value();
-
- UEgde=PC2.Parameter();
-
- aDist=PEdge.Distance(P1);
- aRRel=fabs(aDist-aR)/aR;
- if (aRRel > TolBoundary) {
+
+ P1 = PC1.Value();
+ PEdge = PC2.Value();
+
+ UEgde = PC2.Parameter();
+
+ aDist = PEdge.Distance(P1);
+ aRRel = fabs(aDist - aR) / aR;
+ if (aRRel > TolBoundary)
+ {
return anExitCode;
}
- if (UEgde < (f+TolBoundary) || UEgde > (l-TolBoundary)) {
+ if (UEgde < (f + TolBoundary) || UEgde > (l - TolBoundary))
+ {
return anExitCode;
}
//
// Do not wonder !
- // It was done as into PointProcess(...) function
- //printf("TreatLC()=> tangent line is found\n");
- TOL=1000.*TolBoundary;
- if(TOL>0.001) TOL=0.001;
-
+ // It was done as into PointProcess(...) function
+ // printf("TreatLC()=> tangent line is found\n");
+ TOL = 1000. * TolBoundary;
+ if (TOL > 0.001)
+ TOL = 0.001;
+
IntStart_ThePathPoint ptsol;
ptsol.SetValue(PEdge, TOL, A, UEgde);
pnt.Append(ptsol);
- anExitCode=0;
+ anExitCode = 0;
return anExitCode;
-
}
-
//=================================================================================================
-IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries ()
-: done(Standard_False),
- all(Standard_False)
+IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries()
+ : done(Standard_False),
+ all(Standard_False)
{
-}
+}
//=================================================================================================
- void IntStart_SearchOnBoundaries::Perform (TheFunction& Func,
- const Handle(TheTopolTool)& Domain,
- const Standard_Real TolBoundary,
- const Standard_Real TolTangency,
- const Standard_Boolean RecheckOnRegularity)
+void IntStart_SearchOnBoundaries::Perform(TheFunction& Func,
+ const Handle(TheTopolTool)& Domain,
+ const Standard_Real TolBoundary,
+ const Standard_Real TolTangency,
+ const Standard_Boolean RecheckOnRegularity)
{
-
+
done = Standard_False;
spnt.Clear();
sseg.Clear();
Standard_Boolean Arcsol;
- Standard_Real PDeb,PFin, prm, tol;
- Standard_Integer i, nbknown, nbfound,index;
- gp_Pnt pt;
-
+ Standard_Real PDeb, PFin, prm, tol;
+ Standard_Integer i, nbknown, nbfound, index;
+ gp_Pnt pt;
+
Domain->Init();
- if (Domain->More()) {
- all = Standard_True;
+ if (Domain->More())
+ {
+ all = Standard_True;
}
- else {
+ else
+ {
all = Standard_False;
}
- while (Domain->More()) {
+ while (Domain->More())
+ {
TheArc A = Domain->Value();
- if (!TheSOBTool::HasBeenSeen(A)) {
+ if (!TheSOBTool::HasBeenSeen(A))
+ {
Func.Set(A);
- FindVertex(A,Domain,Func,spnt,TolBoundary);
- TheSOBTool::Bounds(A,PDeb,PFin);
- if(Precision::IsNegativeInfinite(PDeb) ||
- Precision::IsPositiveInfinite(PFin)) {
+ FindVertex(A, Domain, Func, spnt, TolBoundary);
+ TheSOBTool::Bounds(A, PDeb, PFin);
+ if (Precision::IsNegativeInfinite(PDeb) || Precision::IsPositiveInfinite(PFin))
+ {
Standard_Integer NbEchant;
- ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant);
+ ComputeBoundsfromInfinite(Func, PDeb, PFin, NbEchant);
}
- BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol,RecheckOnRegularity);
+ BoundedArc(A,
+ Domain,
+ PDeb,
+ PFin,
+ Func,
+ spnt,
+ sseg,
+ TolBoundary,
+ TolTangency,
+ Arcsol,
+ RecheckOnRegularity);
all = (all && Arcsol);
}
-
- else {
- // as it seems we'll never be here, because
+
+ else
+ {
+ // as it seems we'll never be here, because
// TheSOBTool::HasBeenSeen(A) always returns FALSE
nbfound = spnt.Length();
// On recupere les points connus
nbknown = TheSOBTool::NbPoints(A);
- for (i=1; i<=nbknown; i++) {
- TheSOBTool::Value(A,i,pt,tol,prm);
- if (TheSOBTool::IsVertex(A,i)) {
+ for (i = 1; i <= nbknown; i++)
+ {
+ TheSOBTool::Value(A, i, pt, tol, prm);
+ if (TheSOBTool::IsVertex(A, i))
+ {
TheVertex vtx;
- TheSOBTool::Vertex(A,i,vtx);
- spnt.Append(IntStart_ThePathPoint(pt,tol,vtx,A,prm));
+ TheSOBTool::Vertex(A, i, vtx);
+ spnt.Append(IntStart_ThePathPoint(pt, tol, vtx, A, prm));
}
- else {
- spnt.Append(IntStart_ThePathPoint(pt,tol,A,prm));
+ else
+ {
+ spnt.Append(IntStart_ThePathPoint(pt, tol, A, prm));
}
}
// On recupere les arcs solutions
nbknown = TheSOBTool::NbSegments(A);
- for (i=1; i<=nbknown; i++) {
+ for (i = 1; i <= nbknown; i++)
+ {
IntStart_TheSegment newseg;
newseg.SetValue(A);
- if (TheSOBTool::HasFirstPoint(A,i,index)) {
- newseg.SetLimitPoint(spnt.Value(nbfound+index),Standard_True);
+ if (TheSOBTool::HasFirstPoint(A, i, index))
+ {
+ newseg.SetLimitPoint(spnt.Value(nbfound + index), Standard_True);
}
- if (TheSOBTool::HasLastPoint(A,i,index)) {
- newseg.SetLimitPoint(spnt.Value(nbfound+index),Standard_False);
+ if (TheSOBTool::HasLastPoint(A, i, index))
+ {
+ newseg.SetLimitPoint(spnt.Value(nbfound + index), Standard_False);
}
sseg.Append(newseg);
}
- all = (all& TheSOBTool::IsAllSolution(A));
+ all = (all & TheSOBTool::IsAllSolution(A));
}
Domain->Next();
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-IntStart_Segment::IntStart_Segment ()
-: hasfp(Standard_False),
- haslp(Standard_False)
+IntStart_Segment::IntStart_Segment()
+ : hasfp(Standard_False),
+ haslp(Standard_False)
{
}
+void IntStart_Segment::SetLimitPoint(const ThePathPoint& V, const Standard_Boolean First)
+{
-void IntStart_Segment::SetLimitPoint (const ThePathPoint& V,
- const Standard_Boolean First) {
-
- if (First) {
+ if (First)
+ {
hasfp = Standard_True;
thefp = V;
}
- else {
+ else
+ {
haslp = Standard_True;
thelp = V;
}
}
-
-
-
-
#include <IntSurf_Couple.hxx>
-IntWalk_IWLine::IntWalk_IWLine (const IntSurf_Allocator& theAllocator) :
- line (new IntSurf_LineOn2S (theAllocator)),
- closed (Standard_False),
- hasFirst (Standard_False), hasLast (Standard_False),
- firstIndex (-1), lastIndex (-1),
- indextg (-1),
- istgtbeg (Standard_False), istgtend (Standard_False)
+IntWalk_IWLine::IntWalk_IWLine(const IntSurf_Allocator& theAllocator)
+ : line(new IntSurf_LineOn2S(theAllocator)),
+ closed(Standard_False),
+ hasFirst(Standard_False),
+ hasLast(Standard_False),
+ firstIndex(-1),
+ lastIndex(-1),
+ indextg(-1),
+ istgtbeg(Standard_False),
+ istgtend(Standard_False)
{
}
void IntWalk_IWLine::Reverse()
{
line->Reverse();
- Standard_Integer N = line->NbPoints();
+ Standard_Integer N = line->NbPoints();
Standard_Integer NbCouple = couple.Length();
- for (Standard_Integer i = 1; i <= NbCouple; i++) {
- couple(i) = IntSurf_Couple(N - couple(i).First() + 1,
- couple(i).Second());
+ for (Standard_Integer i = 1; i <= NbCouple; i++)
+ {
+ couple(i) = IntSurf_Couple(N - couple(i).First() + 1, couple(i).Second());
}
}
-
{
const Standard_Real aTol = theFunc.Tolerance();
const Standard_Integer aNbItems = 4;
- const Standard_Real aParU[aNbItems] = {Min(theU + theStepU, theUsup), Max(theU - theStepU, theUinf), theU, theU};
- const Standard_Real aParV[aNbItems] = {theV, theV, Min(theV + theStepV, theVsup), Max(theV - theStepV, theVinf)};
+ const Standard_Real aParU[aNbItems] = {Min(theU + theStepU, theUsup),
+ Max(theU - theStepU, theUinf),
+ theU,
+ theU};
+ const Standard_Real aParV[aNbItems] = {theV,
+ theV,
+ Min(theV + theStepV, theVsup),
+ Max(theV - theStepV, theVinf)};
math_Vector aX(1, 2), aVal(1, 1);
const Standard_Real Deflection,
const Standard_Real Increment,
const Standard_Boolean theToFillHoles)
-: done(Standard_False),
- fleche(Deflection),
- pas(Increment),
- tolerance(1, 2),
- epsilon(Epsilon * Epsilon),
- reversed(Standard_False),
- wd1(IntWalk_VectorOfWalkingData::allocator_type(new NCollection_IncAllocator)),
- wd2(wd1.get_allocator()),
- nbMultiplicities(wd1.get_allocator()),
- Um(0.0),
- UM(0.0),
- Vm(0.0),
- VM(0.0),
- ToFillHoles(theToFillHoles)
-{}
+ : done(Standard_False),
+ fleche(Deflection),
+ pas(Increment),
+ tolerance(1, 2),
+ epsilon(Epsilon * Epsilon),
+ reversed(Standard_False),
+ wd1(IntWalk_VectorOfWalkingData::allocator_type(new NCollection_IncAllocator)),
+ wd2(wd1.get_allocator()),
+ nbMultiplicities(wd1.get_allocator()),
+ Um(0.0),
+ UM(0.0),
+ Vm(0.0),
+ VM(0.0),
+ ToFillHoles(theToFillHoles)
+{
+}
//=======================================================================
-//function : Reset
-//purpose : Clears NCollection_Vector-based containers and adds
+// function : Reset
+// purpose : Clears NCollection_Vector-based containers and adds
// dummy data to maintain start index of 1 and consistent with
// previous TCollection_Sequence-based implementation and other
// used TCollection-based containers
Clear();
reversed = Reversed;
- Um = ThePSurfaceTool::FirstUParameter(Caro);
- Vm = ThePSurfaceTool::FirstVParameter(Caro);
- UM = ThePSurfaceTool::LastUParameter(Caro);
- VM = ThePSurfaceTool::LastVParameter(Caro);
+ Um = ThePSurfaceTool::FirstUParameter(Caro);
+ Vm = ThePSurfaceTool::FirstVParameter(Caro);
+ UM = ThePSurfaceTool::LastUParameter(Caro);
+ VM = ThePSurfaceTool::LastVParameter(Caro);
if (UM < Um)
{
tolerance(1) = ThePSurfaceTool::UResolution(Caro, Precision::Confusion());
tolerance(2) = ThePSurfaceTool::VResolution(Caro, Precision::Confusion());
- Um = ThePSurfaceTool::FirstUParameter(Caro);
- Vm = ThePSurfaceTool::FirstVParameter(Caro);
- UM = ThePSurfaceTool::LastUParameter(Caro);
- VM = ThePSurfaceTool::LastVParameter(Caro);
+ Um = ThePSurfaceTool::FirstUParameter(Caro);
+ Vm = ThePSurfaceTool::FirstVParameter(Caro);
+ UM = ThePSurfaceTool::LastUParameter(Caro);
+ VM = ThePSurfaceTool::LastVParameter(Caro);
if (UM < Um)
{
previousPoint.ParametersOnS1(UVap(1), UVap(2));
}
- Standard_Real U1 = UVap(1) + Step * Duvx * StepSign;
- Standard_Real V1 = UVap(2) + Step * Duvy * StepSign;
+ Standard_Real U1 = UVap(1) + Step * Duvx * StepSign;
+ Standard_Real V1 = UVap(2) + Step * Duvy * StepSign;
Standard_Boolean infu = (U1 <= BornInf(1) + Precision::PConfusion());
Standard_Boolean supu = (U1 >= BornSup(1) - Precision::PConfusion());
{
Standard_Real Up, Vp, Du, Dv, Dup, Dvp, Utest, Vtest;
Standard_Integer j, N, ind;
- Standard_Real tolu = tolerance(1);
- Standard_Real tolv = tolerance(2);
- Standard_Real tolu2 = 10. * tolerance(1);
- Standard_Real tolv2 = 10. * tolerance(2);
+ Standard_Real tolu = tolerance(1);
+ Standard_Real tolv = tolerance(2);
+ Standard_Real tolu2 = 10. * tolerance(1);
+ Standard_Real tolv2 = 10. * tolerance(2);
Standard_Boolean Arrive = Standard_False;
Utest = wd2[i].ustart;
Vtest = wd2[i].vstart;
- Du = UV(1) - Utest;
- Dv = UV(2) - Vtest;
- Dup = Up - Utest;
- Dvp = Vp - Vtest;
+ Du = UV(1) - Utest;
+ Dv = UV(2) - Vtest;
+ Dup = Up - Utest;
+ Dvp = Vp - Vtest;
//-- lbr le 30 oct 97
- //IFV for OCC20285
+ // IFV for OCC20285
if ((Abs(Du) < tolu2 && Abs(Dv) < tolv2) || (Abs(Dup) < tolu2 && Abs(Dvp) < tolv2))
{
{
Standard_Real UV1mUtest = UV(1) - Utest;
Standard_Real UV2mVtest = UV(2) - Vtest;
- if (((Dup * UV1mUtest + Dvp * UV2mVtest) < 0) || (Abs(UV1mUtest) < tolu && Abs(UV2mVtest) < tolv))
+ if (((Dup * UV1mUtest + Dvp * UV2mVtest) < 0)
+ || (Abs(UV1mUtest) < tolu && Abs(UV2mVtest) < tolv))
{
i_candidates.Append((Standard_Integer)i);
SqDist_candidates.Append(Dup * Dup + Dvp * Dvp);
/*
- Irang=i;
- Arrive = Standard_True;
- UV(1) = Utest;
- UV(2) = Vtest;
- */
+ Irang=i;
+ Arrive = Standard_True;
+ UV(1) = Utest;
+ UV(2) = Vtest;
+ */
}
else if (nbMultiplicities[i] > 0 && i_candidates.IsEmpty())
{
}
}
}
- } //end of for (i = 1; i < wd1.size(); i++)
+ } // end of for (i = 1; i < wd1.size(); i++)
if (!i_candidates.IsEmpty())
{
Standard_Real MinSqDist = RealLast();
UV(1) = wd1[Irang].ustart;
UV(2) = wd1[Irang].vstart;
}
- } //end of for (l = 1; l <= 2 && !Arrive; l++)
+ } // end of for (l = 1; l <= 2 && !Arrive; l++)
return Arrive;
}
previousPoint.ParametersOnS1(Up, Vp);
}
- Standard_Real UV1 = UV(1);
- Standard_Real UV2 = UV(2);
+ Standard_Real UV1 = UV(1);
+ Standard_Real UV2 = UV(2);
- //Normalizing factor. If it is less than 1.0 then the range will be expanded.
- //This is no good for computation. Therefore, it is limited.
- //Do not limit this factor in case of highly anisotropic parametrization
+ // Normalizing factor. If it is less than 1.0 then the range will be expanded.
+ // This is no good for computation. Therefore, it is limited.
+ // Do not limit this factor in case of highly anisotropic parametrization
//(parametric space is considerably larger in one direction than another).
const Standard_Boolean isHighlyAnisotropic = Max(tolu, tolv) > 1000. * Min(tolu, tolv);
- const Standard_Real deltau = mySRangeU.IsVoid() ? UM - Um
- : (isHighlyAnisotropic ? mySRangeU.Delta() : Max(mySRangeU.Delta(), 1.0));
- const Standard_Real deltav = mySRangeV.IsVoid() ? VM - Vm
- : (isHighlyAnisotropic ? mySRangeV.Delta() : Max(mySRangeV.Delta(), 1.0));
+ const Standard_Real deltau =
+ mySRangeU.IsVoid() ? UM - Um
+ : (isHighlyAnisotropic ? mySRangeU.Delta() : Max(mySRangeU.Delta(), 1.0));
+ const Standard_Real deltav =
+ mySRangeV.IsVoid() ? VM - Vm
+ : (isHighlyAnisotropic ? mySRangeV.Delta() : Max(mySRangeV.Delta(), 1.0));
Up /= deltau;
UV1 /= deltau;
tolu /= deltau;
tolv /= deltav;
- Standard_Real tolu2 = tolu + tolu;
- Standard_Real tolv2 = tolv + tolv;
+ Standard_Real tolu2 = tolu + tolu;
+ Standard_Real tolv2 = tolv + tolv;
Standard_Real dPreviousCurrent = (Up - UV1) * (Up - UV1) + (Vp - UV2) * (Vp - UV2);
for (k = 1; k < (int)wd2.size(); k++)
Standard_Real dPreviousStart = (UpmUtest) * (UpmUtest) + (VpmVtest) * (VpmVtest);
Standard_Real dCurrentStart = UV1mUtest * UV1mUtest + UV2mVtest * UV2mVtest;
- Scal = (UpmUtest) * (UV1mUtest) + (VpmVtest) * (UV2mVtest);
+ Scal = (UpmUtest) * (UV1mUtest) + (VpmVtest) * (UV2mVtest);
if ((Abs(UpmUtest) < tolu && Abs(VpmVtest) < tolv))
{
if (Index != k)
for (i = 1; i < (int)wd1.size(); i++)
{
if (wd1[i].etat > 0 && wd1[i].etat < 11)
- { //test of crossing points
+ { // test of crossing points
Utest = wd1[i].ustart;
Vtest = wd1[i].vstart;
Utest /= deltau;
if (((Up - U1) * (UV(1) - U1) + (Vp - V1) * (UV(2) - V1)) < 0
|| (Abs(UV(1) - U1) < tolerance(1) && Abs(UV(2) - V1) < tolerance(2)))
{
- //jag 940615 Irang= -Abs(Irang);
+ // jag 940615 Irang= -Abs(Irang);
Arrive = Standard_True;
UV(1) = U1;
UV(2) = V1;
MinIndex = j;
}
}
- //processing points from Irang1 and MinRang
+ // processing points from Irang1 and MinRang
if (MinRang == 0)
{
SeqToRemove.Append(Irang1);
BadSolutions.Clear();
continue;
}
- //Ends of same line
+ // Ends of same line
if (Abs(Irang1) == Abs(MinRang) && lines.Value(Abs(Irang1))->NbPoints() == 2)
{
SeqToRemove.Append(Irang1);
P2d2 = PointAlone2.ValueOnSurface(reversed);
Standard_Real MinSqDist3d = Pnt1.SquareDistance(Pnt2);
if (MinSqDist3d <= epsilon
- || (Abs(P2d1.X() - P2d2.X()) <= tolerance(1) && Abs(P2d1.Y() - P2d2.Y()) <= tolerance(2))) //close points
+ || (Abs(P2d1.X() - P2d2.X()) <= tolerance(1)
+ && Abs(P2d1.Y() - P2d2.Y()) <= tolerance(2))) // close points
ToRemove = Standard_True;
- else //real curve
+ else // real curve
{
math_Vector UVap(1, 2), UV(1, 2);
UVap(1) = (P2d1.X() + P2d2.X()) / 2;
gp_Vec2d P2Pmid(P2d2, Pmid);
Standard_Real ScalProd1 = P1P2 * P1Pmid;
Standard_Real ScalProd2 = P1P2 * P2Pmid;
- Standard_Boolean IsPmidValid = (ScalProd1 > 0. && ScalProd2 < 0); //Pmid is in the middle
+ Standard_Boolean IsPmidValid = (ScalProd1 > 0. && ScalProd2 < 0); // Pmid is in the middle
if (IsPmidValid)
{
for (Standard_Integer iline = 1; iline <= lines.Length(); iline++)
}
if (IsPmidValid)
{
- IntSurf_InteriorPoint aPoint(sp.Point(), UV(1), UV(2), sp.Direction3d(), sp.Direction2d());
+ IntSurf_InteriorPoint aPoint(sp.Point(),
+ UV(1),
+ UV(2),
+ sp.Direction3d(),
+ sp.Direction2d());
PntsInHoles.Append(aPoint);
TColStd_ListOfInteger LineLine;
LineLine.Append(Irang1);
Standard_Integer N;
Standard_Boolean Found = Standard_False;
- Irang = 0;
+ Irang = 0;
for (Standard_Integer i = 1; i < (int)wd1.size(); i++)
{
if (wd1[i].etat < 0)
Line->Value(j).ParametersOnS1(Uc, Vc);
}
- gp_Vec2d aVec1(Up - wd1[i].ustart, Vp - wd1[i].vstart), aVec2(Uc - wd1[i].ustart, Vc - wd1[i].vstart);
+ gp_Vec2d aVec1(Up - wd1[i].ustart, Vp - wd1[i].vstart),
+ aVec2(Uc - wd1[i].ustart, Vc - wd1[i].vstart);
CutVectorByTolerances(aVec1, tolerance);
CutVectorByTolerances(aVec2, tolerance);
{
for (Standard_Integer k = N + 1; k <= N + nbMultiplicities[i]; k++)
{
- aVec1.SetCoord(Up - Umult(k), Vp - Vmult(k)), aVec2.SetCoord(Uc - Umult(k), Vc - Vmult(k));
+ aVec1.SetCoord(Up - Umult(k), Vp - Vmult(k)),
+ aVec2.SetCoord(Uc - Umult(k), Vc - Vmult(k));
CutVectorByTolerances(aVec1, tolerance);
CutVectorByTolerances(aVec2, tolerance);
// now the last point of the line and the last calculated point are compated.
// there will be no need to "Cut"
- gp_Vec2d aVec1(Up - wd1[i].ustart, Vp - wd1[i].vstart), aVec2(UV(1) - wd1[i].ustart, UV(2) - wd1[i].vstart);
+ gp_Vec2d aVec1(Up - wd1[i].ustart, Vp - wd1[i].vstart),
+ aVec2(UV(1) - wd1[i].ustart, UV(2) - wd1[i].vstart);
CutVectorByTolerances(aVec1, tolerance);
CutVectorByTolerances(aVec2, tolerance);
UV(2) = wd1[Irang].vstart;
Found = Standard_True;
}
- else if (Abs(UV(1) - wd1[i].ustart) < tolerance(1) && Abs(UV(2) - wd1[i].vstart) < tolerance(2))
+ else if (Abs(UV(1) - wd1[i].ustart) < tolerance(1)
+ && Abs(UV(2) - wd1[i].vstart) < tolerance(2))
{
Irang = i;
UV(1) = wd1[Irang].ustart;
//-- IntWalk_IWalking_3.gxx
// modified by NIZHNY-MKK Thu Nov 2 15:07:26 2000.BEGIN
-static Standard_Boolean TestPassedSolutionWithNegativeState(const IntWalk_VectorOfWalkingData& wd,
- const TColStd_SequenceOfReal& Umult,
- const TColStd_SequenceOfReal& Vmult,
- const Standard_Real& prevUp,
- const Standard_Real& prevVp,
- const IntWalk_VectorOfInteger& nbMultiplicities,
- const math_Vector& tolerance,
- TheIWFunction& sp,
- math_Vector& UV,
- Standard_Integer& Irang);
+static Standard_Boolean TestPassedSolutionWithNegativeState(
+ const IntWalk_VectorOfWalkingData& wd,
+ const TColStd_SequenceOfReal& Umult,
+ const TColStd_SequenceOfReal& Vmult,
+ const Standard_Real& prevUp,
+ const Standard_Real& prevVp,
+ const IntWalk_VectorOfInteger& nbMultiplicities,
+ const math_Vector& tolerance,
+ TheIWFunction& sp,
+ math_Vector& UV,
+ Standard_Integer& Irang);
// modified by NIZHNY-MKK Thu Nov 2 15:07:39 2000.END
void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult,
Standard_Real PasC = 0.0, PasCu = 0.0, PasCv = 0.0;
Standard_Boolean Arrive = false; // shows if the line ends
Standard_Boolean Cadre = false; // shows if one is on border of the domain
- Standard_Boolean ArretAjout = false; //shows if one is on added point
+ Standard_Boolean ArretAjout = false; // shows if one is on added point
IntSurf_PntOn2S Psol;
Handle(IntWalk_TheIWLine) CurrentLine; // line under construction
Standard_Boolean Tgtend = false;
Standard_Integer NbDivision = 0;
// number of divisions of step for each section
- Standard_Integer StepSign = 0;
+ Standard_Integer StepSign = 0;
ThePointOfPath PathPnt;
for (I = 1; I <= nbPath; I++)
{
- //start point of the progression
- // if (wd1[I].etat > 11) {
- // modified by NIZHNY-MKK Fri Oct 27 12:33:37 2000.BEGIN
+ // start point of the progression
+ // if (wd1[I].etat > 11) {
+ // modified by NIZHNY-MKK Fri Oct 27 12:33:37 2000.BEGIN
if ((wd1[I].etat > 11) || ((wd1[I].etat < -11) && (movementdirectioninfo[I] != 0)))
{
// modified by NIZHNY-MKK Fri Oct 27 12:33:43 2000.END
if (IsPointOnLine(previousPoint, BornInf, BornSup, Rsnld, aFuncForDuplicate))
{
- wd1[I].etat = -Abs(wd1[I].etat); //mark point as processed
+ wd1[I].etat = -Abs(wd1[I].etat); // mark point as processed
continue;
}
movementdirectioninfo[I] = (movementdirectioninfo[I] == 0) ? StepSign : 0;
// Modified by Sergey KHROMOV - Tue Nov 20 10:41:56 2001 End
// first step of advancement
- Standard_Real d2dx = Abs(previousd2d.X());
- Standard_Real d2dy = Abs(previousd2d.Y());
+ Standard_Real d2dx = Abs(previousd2d.X());
+ Standard_Real d2dy = Abs(previousd2d.Y());
if (d2dx < tolerance(1))
{
PasC = pas * (VM - Vm) / d2dy;
PasC = pas * Min((UM - Um) / d2dx, (VM - Vm) / d2dy);
}
- Arrive = Standard_False;
- ArretAjout = Standard_False;
- NbDivision = 0;
- StatusPrecedent = IntWalk_OK;
+ Arrive = Standard_False;
+ ArretAjout = Standard_False;
+ NbDivision = 0;
+ StatusPrecedent = IntWalk_OK;
// modified by NIZHNY-MKK Fri Oct 27 12:39:37 2000
Standard_Integer IndexOfPathPointDoNotCheck = 0;
Standard_Integer aNbIter = 10;
if (Arrive)
{
Cadre = Standard_False;
- //in case if there is a frame and arrive at the same time
+ // in case if there is a frame and arrive at the same time
}
else
{
}
}
}
- aStatus = TestDeflection(Func, Arrive, UVap, StatusPrecedent, NbDivision, PasC, StepSign);
+ aStatus =
+ TestDeflection(Func, Arrive, UVap, StatusPrecedent, NbDivision, PasC, StepSign);
StatusPrecedent = aStatus;
if (aStatus == IntWalk_PasTropGrand)
{
{
Arrive = Standard_True;
CurrentLine->AddStatusLast(Standard_False);
- //if (aStatus != IntWalk_ArretSurPointPrecedent)
+ // if (aStatus != IntWalk_ArretSurPointPrecedent)
CurrentLine->AddPoint(Psol);
- //Remove <SaveN> from <seqAlone>
+ // Remove <SaveN> from <seqAlone>
for (Standard_Integer iseq = 1; iseq <= seqAlone.Length(); iseq++)
if (seqAlone(iseq) == SaveN)
{
else if (aStatus == IntWalk_ArretSurPointPrecedent)
{
if (CurrentLine->NbPoints() == 1)
- { //cancel the line
+ { // cancel the line
Arrive = Standard_False;
break;
}
Arrive = Standard_True;
Rajout = Standard_True;
- //AddAlonePoint();
+ // AddAlonePoint();
seqAlone.Append(lines.Length() + 1);
seqAjout.Append(lines.Length() + 1);
CurrentLine->AddStatusLast(Standard_False);
}
// necessarily N > 0 jag 940617
// point of stop given at input
- PathPnt = Pnts1.Value(N);
+ PathPnt = Pnts1.Value(N);
Standard_Integer etat1N = wd1[N].etat;
// modified by NIZHNY-MKK Thu Nov 2 15:09:51 2000.BEGIN
// modified by NIZHNY-MKK Fri Oct 27 13:00:22 2000.BEGIN
// if (wd1[av].etat > 11) {
if ((wd1[av].etat > 11)
- || ((av != I) && (av != IndexOfPathPointDoNotCheck) && (wd1[av].etat < -11) && (movementdirectioninfo[av] != 0)))
+ || ((av != I) && (av != IndexOfPathPointDoNotCheck) && (wd1[av].etat < -11)
+ && (movementdirectioninfo[av] != 0)))
{
// modified by NIZHNY-MKK Fri Oct 27 13:00:26 2000.END
Standard_Real Uav = wd1[av].ustart;
}
}
}
- } //end of point processing
- } //end of all points
+ } // end of point processing
+ } // end of all points
}
// modified by NIZHNY-MKK Thu Nov 2 15:07:53 2000.BEGIN
-static Standard_Boolean TestPassedSolutionWithNegativeState(const IntWalk_VectorOfWalkingData& wd,
- const TColStd_SequenceOfReal& Umult,
- const TColStd_SequenceOfReal& Vmult,
- const Standard_Real& prevUp,
- const Standard_Real& prevVp,
- const IntWalk_VectorOfInteger& nbMultiplicities,
- const math_Vector& tolerance,
- TheIWFunction& sp,
- math_Vector& UV,
- Standard_Integer& Irang)
+static Standard_Boolean TestPassedSolutionWithNegativeState(
+ const IntWalk_VectorOfWalkingData& wd,
+ const TColStd_SequenceOfReal& Umult,
+ const TColStd_SequenceOfReal& Vmult,
+ const Standard_Real& prevUp,
+ const Standard_Real& prevVp,
+ const IntWalk_VectorOfInteger& nbMultiplicities,
+ const math_Vector& tolerance,
+ TheIWFunction& sp,
+ math_Vector& UV,
+ Standard_Integer& Irang)
{
Standard_Boolean Arrive = Standard_False;
Standard_Real Dup, Dvp, Utest, Vtest;
{
Standard_Real UV1mUtest = UV(1) - Utest;
Standard_Real UV2mVtest = UV(2) - Vtest;
- if (((Dup * UV1mUtest + Dvp * UV2mVtest) < 0) || (Abs(UV1mUtest) < tolu && Abs(UV2mVtest) < tolv))
+ if (((Dup * UV1mUtest + Dvp * UV2mVtest) < 0)
+ || (Abs(UV1mUtest) < tolu && Abs(UV2mVtest) < tolv))
{
Irang = i;
Arrive = Standard_True;
}
for (j = N + 1; j <= N + nbMultiplicities[i]; j++)
{
- if (((prevUp - Umult(j)) * (UV(1) - Umult(j)) + (prevVp - Vmult(j)) * (UV(2) - Vmult(j)) < 0)
+ if (((prevUp - Umult(j)) * (UV(1) - Umult(j)) + (prevVp - Vmult(j)) * (UV(2) - Vmult(j))
+ < 0)
|| (Abs(UV(1) - Umult(j)) < tolu && Abs(UV(2) - Vmult(j)) < tolv))
{
Irang = i;
Standard_Boolean Cadre = false; // show if on border of the domains
Standard_Boolean ArretAjout = false; // show if on the added point
IntSurf_PntOn2S Psol;
- Handle(IntWalk_TheIWLine) CurrentLine; //line under construction
+ Handle(IntWalk_TheIWLine) CurrentLine; // line under construction
ThePointOfPath PathPnt;
ThePointOfLoop LoopPnt;
Standard_Boolean Tgtbeg = false, Tgtend = false;
- Standard_Integer StepSign = 0;
+ Standard_Integer StepSign = 0;
IntWalk_StatusDeflection aStatus = IntWalk_OK, StatusPrecedent;
Standard_Integer NbDivision = 0; // number of divisions of step
// during calculation of 1 section
- Standard_Integer Ipass = 0;
- //index in the iterator of points on edge of point of passage
+ Standard_Integer Ipass = 0;
+ // index in the iterator of points on edge of point of passage
- BornInf(1) = Um;
- BornSup(1) = UM;
- BornInf(2) = Vm;
- BornSup(2) = VM;
+ BornInf(1) = Um;
+ BornSup(1) = UM;
+ BornInf(2) = Vm;
+ BornSup(2) = VM;
math_FunctionSetRoot Rsnld(Func, tolerance);
Standard_Integer nbLoop = Pnts2.Length();
if (wd2[I].etat > 12)
{ // start point of closed line
LoopPnt = Pnts2.Value(I);
- previousPoint.SetValue(ThePointOfLoopTool::Value3d(LoopPnt), reversed, wd2[I].ustart, wd2[I].vstart);
+ previousPoint.SetValue(ThePointOfLoopTool::Value3d(LoopPnt),
+ reversed,
+ wd2[I].ustart,
+ wd2[I].vstart);
if (IsPointOnLine(previousPoint, BornInf, BornSup, Rsnld, aFuncForDuplicate))
{
- wd2[I].etat = -wd2[I].etat; //mark point as processed
+ wd2[I].etat = -wd2[I].etat; // mark point as processed
continue;
}
CurrentLine = new IntWalk_TheIWLine(new NCollection_IncAllocator());
CurrentLine->AddPoint(previousPoint);
CurrentLine->SetTangentVector(previousd3d, 1);
- Tgtbeg = Standard_False;
- Tgtend = Standard_False;
- Uvap(1) = wd2[I].ustart;
- Uvap(2) = wd2[I].vstart;
+ Tgtbeg = Standard_False;
+ Tgtend = Standard_False;
+ Uvap(1) = wd2[I].ustart;
+ Uvap(2) = wd2[I].vstart;
- StepSign = 1;
+ StepSign = 1;
// first step of advancement
PasC = pas * Min((UM - Um) / d2dx, (VM - Vm) / d2dy);
}
- PasSav = PasC;
+ PasSav = PasC;
Arrive = Standard_False;
ArretAjout = Standard_False;
if (CurrentLine->NbPoints() == 1)
{
RemoveTwoEndPoints(I);
- break; //cancel the line
+ break; // cancel the line
}
if (wd2[I].etat > 12)
- { //the line should become open
- wd2[I].etat = 12; //declare it open
+ { // the line should become open
+ wd2[I].etat = 12; // declare it open
ArretAjout = Standard_False;
OpenLine(0, Psol, Pnts1, Func, CurrentLine);
StepSign = -1;
seqAjout.Append(lines.Length() + 1);
Tgtend = Standard_True;
}
- /*
+ /*
Arrive = Standard_True;
CurrentLine->AddStatusFirstLast(Standard_False,
Standard_False,Standard_False);
Standard_Real uvprev[2], uv[2];
if (!reversed)
{
- CurrentLine->Value(CurrentLine->NbPoints() - 1).ParametersOnS2(uvprev[0], uvprev[1]);
+ CurrentLine->Value(CurrentLine->NbPoints() - 1)
+ .ParametersOnS2(uvprev[0], uvprev[1]);
CurrentLine->Value(CurrentLine->NbPoints()).ParametersOnS2(uv[0], uv[1]);
}
else
{
- CurrentLine->Value(CurrentLine->NbPoints() - 1).ParametersOnS1(uvprev[0], uvprev[1]);
+ CurrentLine->Value(CurrentLine->NbPoints() - 1)
+ .ParametersOnS1(uvprev[0], uvprev[1]);
CurrentLine->Value(CurrentLine->NbPoints()).ParametersOnS1(uv[0], uv[1]);
}
{
// Make linear extrapolation.
if (Abs(uv[aCoordIdx - 1] - uvprev[aCoordIdx - 1]) > gp::Resolution())
- aScaleCoeff = Abs((Uvap(aCoordIdx) - uv[aCoordIdx - 1]) / (uv[aCoordIdx - 1] - uvprev[aCoordIdx - 1]));
+ aScaleCoeff = Abs((Uvap(aCoordIdx) - uv[aCoordIdx - 1])
+ / (uv[aCoordIdx - 1] - uvprev[aCoordIdx - 1]));
Standard_Integer aFixIdx = aCoordIdx == 1 ? 2 : 1; // Fixing index;
- Uvap(aFixIdx) = uv[aFixIdx - 1] + (uv[aFixIdx - 1] - uvprev[aFixIdx - 1]) * aScaleCoeff;
- isOnDegeneratedBorder = Standard_True;
+ Uvap(aFixIdx) =
+ uv[aFixIdx - 1] + (uv[aFixIdx - 1] - uvprev[aFixIdx - 1]) * aScaleCoeff;
+ isOnDegeneratedBorder = Standard_True;
}
}
}
Arrive = TestArretPassage(Umult, Vmult, Uvap, I, Ipass);
if (Arrive)
- { //reset proper parameter to test the arrow.
+ { // reset proper parameter to test the arrow.
Psol = CurrentLine->Value(1);
if (!reversed)
{
Psol.ParametersOnS1(Uvap(1), Uvap(2));
}
Cadre = Standard_False;
- //in case if there is a frame and arrival at the same time
+ // in case if there is a frame and arrival at the same time
}
else
{ // modif jag 940615
Arrive = (wd2[I].etat == 12); // the line is open
}
}
- aStatus = TestDeflection(Func, Arrive, Uvap, StatusPrecedent, NbDivision, PasC, StepSign);
+ aStatus =
+ TestDeflection(Func, Arrive, Uvap, StatusPrecedent, NbDivision, PasC, StepSign);
if (isOnDegeneratedBorder && Tgtend)
aStatus = IntWalk_ArretSurPoint;
if (Arrive)
{ // line s is open
CurrentLine->AddStatusLast(Standard_False);
- //if (aStatus != IntWalk_ArretSurPointPrecedent)
+ // if (aStatus != IntWalk_ArretSurPointPrecedent)
CurrentLine->AddPoint(Psol);
- //Remove <SaveN> from <seqAlone> and, if it is first found point,
- //from <seqAjout> too
+ // Remove <SaveN> from <seqAlone> and, if it is first found point,
+ // from <seqAjout> too
if (IsValidEndPoint(I, SaveN))
{
for (Standard_Integer iseq = 1; iseq <= seqAlone.Length(); iseq++)
}
RemoveTwoEndPoints(I);
Arrive = Standard_False;
- break; //cancel the line
+ break; // cancel the line
}
if (Cadre && N == 0)
{
Rajout = Standard_True;
- //seqAlone.Append(lines.Length()+1);
+ // seqAlone.Append(lines.Length()+1);
seqAjout.Append(lines.Length() + 1);
}
}
StepSign = -1;
StatusPrecedent = IntWalk_OK;
PasC = PasSav;
- //Check if <Psol> has been really updated
+ // Check if <Psol> has been really updated
if (Arrive || Rajout || (!ArretAjout && Cadre && SaveN <= 0))
{
if (aStatus == IntWalk_ArretSurPointPrecedent)
OpenLine(-lines.Length() - 1, Psol, Pnts1, Func, CurrentLine);
}
}
- //Remove <SaveN> from <seqAlone> and, if it is first found point,
- //from <seqAjout> too
+ // Remove <SaveN> from <seqAlone> and, if it is first found point,
+ // from <seqAjout> too
if (IsValidEndPoint(I, SaveN))
{
for (Standard_Integer iseq = 1; iseq <= seqAlone.Length(); iseq++)
else
{
RemoveTwoEndPoints(I);
- break; //cancel the line
+ break; // cancel the line
}
if (Cadre && N == 0)
else if (aStatus == IntWalk_ArretSurPointPrecedent)
{
if (CurrentLine->NbPoints() == 1)
- { //cancel the line
+ { // cancel the line
Arrive = Standard_False;
RemoveTwoEndPoints(I);
break;
}
if (wd2[I].etat > 12)
- { //the line should become open
- wd2[I].etat = 12; //declare it open
+ { // the line should become open
+ wd2[I].etat = 12; // declare it open
ArretAjout = Standard_False;
OpenLine(0, Psol, Pnts1, Func, CurrentLine);
StepSign = -1;
else if (Arrive)
{
if (wd2[I].etat > 12)
- { //line closed good case
+ { // line closed good case
CurrentLine->AddStatusFirstLast(Standard_True, Standard_False, Standard_False);
CurrentLine->AddPoint(CurrentLine->Value(1));
}
else if ((N > 0) && (Pnts1.Length() >= N))
{
- //point of stop given at input
+ // point of stop given at input
PathPnt = Pnts1.Value(N);
CurrentLine->AddStatusLast(Standard_True, N, PathPnt);
AddPointInCurrentLine(N, PathPnt, CurrentLine);
else if (aStatus == IntWalk_ArretSurPoint)
{
if (wd2[I].etat > 12)
- { //line should become open
- wd2[I].etat = 12; //declare it open
+ { // line should become open
+ wd2[I].etat = 12; // declare it open
Tgtbeg = Standard_True;
Tgtend = Standard_False;
N = -lines.Length() - 1;
{
Arrive = Standard_True;
if (Ipass != 0)
- { //point of passage, point of stop
+ { // point of passage, point of stop
PathPnt = Pnts1.Value(Ipass);
CurrentLine->AddStatusLast(Standard_True, Ipass, PathPnt);
AddPointInCurrentLine(Ipass, PathPnt, CurrentLine);
}
}
else
- { //no numerical solution NotDone
+ { // no numerical solution NotDone
PasC = PasC / 2.;
PasCu = Abs(PasC * previousd2d.X());
PasCv = Abs(PasC * previousd2d.Y());
break; // cancel the line
}
if (wd2[I].etat > 12)
- { //the line should become open
- wd2[I].etat = 12; //declare it open
+ { // the line should become open
+ wd2[I].etat = 12; // declare it open
ArretAjout = Standard_False;
OpenLine(0, Psol, Pnts1, Func, CurrentLine);
StepSign = -1;
CurrentLine->SetTangencyAtEnd(Tgtend);
lines.Append(CurrentLine);
- wd2[I].etat = -wd2[I].etat; //mark point as processed
+ wd2[I].etat = -wd2[I].etat; // mark point as processed
}
- } //end of processing of start point
- } //end of all start points
+ } // end of processing of start point
+ } // end of all start points
}
//-- IntWalk_IWalking_5.gxx
namespace
{
- static const Standard_Real CosRef3D = 0.98; // rule by tests in U4
- // correspond to 11.478 d
- static const Standard_Real CosRef2D = 0.88; // correspond to 25 d
- static const Standard_Integer MaxDivision = 60; // max number of step division
- // because the angle is too great in 2d (U4)
-}
-
-IntWalk_StatusDeflection IntWalk_IWalking::TestDeflection(TheIWFunction& sp,
- const Standard_Boolean Finished,
- const math_Vector& UV,
- const IntWalk_StatusDeflection StatusPrecedent,
- Standard_Integer& NbDivision,
- Standard_Real& Step,
- const Standard_Integer StepSign)
+static const Standard_Real CosRef3D = 0.98; // rule by tests in U4
+ // correspond to 11.478 d
+static const Standard_Real CosRef2D = 0.88; // correspond to 25 d
+static const Standard_Integer MaxDivision = 60; // max number of step division
+ // because the angle is too great in 2d (U4)
+} // namespace
+
+IntWalk_StatusDeflection IntWalk_IWalking::TestDeflection(
+ TheIWFunction& sp,
+ const Standard_Boolean Finished,
+ const math_Vector& UV,
+ const IntWalk_StatusDeflection StatusPrecedent,
+ Standard_Integer& NbDivision,
+ Standard_Real& Step,
+ const Standard_Integer StepSign)
{
// Check the step of advancement, AND recalculate this step :
//
// angle3d = angle ((previous point, calculated point),
// new tangent)
// 9) test angle 2d too great
- //10) test change of side (pass the tangent point not knowing it)
- //11) calculate the step of advancement depending on the vector
- //12) adjust the step depending on the previous steps
+ // 10) test change of side (pass the tangent point not knowing it)
+ // 11) calculate the step of advancement depending on the vector
+ // 12) adjust the step depending on the previous steps
IntWalk_StatusDeflection aStatus = IntWalk_OK;
Cosi2 = Cosi * Cosi / aDiv;
}
if (Cosi2 < CosRef3D)
- { //angle 3d too great
+ { // angle 3d too great
Step = Step / 2.0;
Standard_Real StepU = Abs(Step * previousd2d.X()), StepV = Abs(Step * previousd2d.Y());
if (StepU < tolerance(1) && StepV < tolerance(2))
}
}
- const Standard_Real aMinTolU = 0.1 * Abs(Step * previousd2d.X()), aMinTolV = 0.1 * Abs(Step * previousd2d.Y());
- const Standard_Real aTolU = (aMinTolU > 0.0) ? Min(tolerance(1), aMinTolU) : tolerance(1),
- aTolV = (aMinTolV > 0.0) ? Min(tolerance(2), aMinTolV) : tolerance(2);
+ const Standard_Real aMinTolU = 0.1 * Abs(Step * previousd2d.X()),
+ aMinTolV = 0.1 * Abs(Step * previousd2d.Y());
+ const Standard_Real aTolU = (aMinTolU > 0.0) ? Min(tolerance(1), aMinTolU) : tolerance(1),
+ aTolV = (aMinTolV > 0.0) ? Min(tolerance(2), aMinTolV) : tolerance(2);
- //If aMinTolU==0.0 then (Abs(Du) < aMinTolU) is equivalent of (Abs(Du) < 0.0).
- //It is impossible. Therefore, this case should be processed separately.
- //Analogically for aMinTolV.
+ // If aMinTolU==0.0 then (Abs(Du) < aMinTolU) is equivalent of (Abs(Du) < 0.0).
+ // It is impossible. Therefore, this case should be processed separately.
+ // Analogically for aMinTolV.
if ((Abs(Du) < aTolU) && (Abs(Dv) < aTolV))
{
- //Thin shapes (for which Ulast-Ufirst or/and Vlast-Vfirst is quite small)
- //exists (see bug #25820). In this case, step is quite small too.
- //Nevertheless, it not always means that we mark time. Therefore, Du and Dv
- //must consider step (aMinTolU and aMinTolV parameters).
+ // Thin shapes (for which Ulast-Ufirst or/and Vlast-Vfirst is quite small)
+ // exists (see bug #25820). In this case, step is quite small too.
+ // Nevertheless, it not always means that we mark time. Therefore, Du and Dv
+ // must consider step (aMinTolU and aMinTolV parameters).
- return IntWalk_ArretSurPointPrecedent; //confused point 2d
+ return IntWalk_ArretSurPointPrecedent; // confused point 2d
}
Standard_Real Cosi = StepSign * (Du * previousd2d.X() + Dv * previousd2d.Y());
if (sp.IsTangent())
return IntWalk_ArretSurPoint;
- //if during routing one has subdivided more than MaxDivision for each
- //previous step, bug on the square; do nothing (experience U4)
+ // if during routing one has subdivided more than MaxDivision for each
+ // previous step, bug on the square; do nothing (experience U4)
- if ((NbDivision < MaxDivision) && (aStatus != IntWalk_PointConfondu) && (StatusPrecedent != IntWalk_PointConfondu))
+ if ((NbDivision < MaxDivision) && (aStatus != IntWalk_PointConfondu)
+ && (StatusPrecedent != IntWalk_PointConfondu))
{
Standard_Real Cosi2 = Cosi * Cosi / Duv;
if (Cosi2 < CosRef2D || Cosi < 0)
Cosi = Corde * sp.Direction3d();
Cosi2 = Cosi * Cosi / sp.Direction3d().SquareMagnitude() / Norme;
if (Cosi2 < CosRef3D)
- { //angle 3d too great
+ { // angle 3d too great
Step = Step / 2.;
Standard_Real StepU = Abs(Step * previousd2d.X()), StepV = Abs(Step * previousd2d.Y());
if (StepU < tolerance(1) && StepV < tolerance(2))
Cosi2 = Cosi * Cosi / Duv;
if (Cosi2 < CosRef2D || sp.Direction2d() * previousd2d < 0)
{
- //angle 2d too great or change the side
+ // angle 2d too great or change the side
Step = Step / 2.;
Standard_Real StepU = Abs(Step * previousd2d.X()), StepV = Abs(Step * previousd2d.Y());
if (StepU < tolerance(1) && StepV < tolerance(2))
{
if (aStatus == IntWalk_PointConfondu)
{
- Standard_Real StepU = Min(Abs(1.5 * Du), pas * (UM - Um)), StepV = Min(Abs(1.5 * Dv), pas * (VM - Vm));
+ Standard_Real StepU = Min(Abs(1.5 * Du), pas * (UM - Um)),
+ StepV = Min(Abs(1.5 * Dv), pas * (VM - Vm));
Standard_Real d2dx = Abs(previousd2d.X());
Standard_Real d2dy = Abs(previousd2d.Y());
gp_Pnt POnCurv,Milieu;
Poles(1) = previousPoint.Value();
Poles(4) = sp.Point();
- Poles(2) = Poles(1).XYZ() +
+ Poles(2) = Poles(1).XYZ() +
StepSign * Dist* previousd3d.Normalized().XYZ();
- Poles(3) = Poles(4).XYZ() -
+ Poles(3) = Poles(4).XYZ() -
StepSign * Dist*sp.Direction3d().Normalized().XYZ();
BzCLib::PntPole(0.5,Poles,POnCurv);
Milieu = (Poles(1).XYZ() + Poles(4).XYZ())*0.5;
// which produces, taking the square :
// Norme * (d1-d4).SquareMagnitude()/64.
- Standard_Real FlecheCourante = (previousd3d.Normalized().XYZ() - sp.Direction3d().Normalized().XYZ()).SquareModulus()
- * Norme / 64.;
+ Standard_Real FlecheCourante =
+ (previousd3d.Normalized().XYZ() - sp.Direction3d().Normalized().XYZ()).SquareModulus()
+ * Norme / 64.;
// if (FlecheCourante <= 0.5*fleche) {
if (FlecheCourante <= 0.25 * fleche * fleche)
{
- Standard_Real d2dx = Abs(sp.Direction2d().X());
- Standard_Real d2dy = Abs(sp.Direction2d().Y());
+ Standard_Real d2dx = Abs(sp.Direction2d().X());
+ Standard_Real d2dy = Abs(sp.Direction2d().Y());
- Standard_Real StepU = Min(Abs(1.5 * Du), pas * (UM - Um)), StepV = Min(Abs(1.5 * Dv), pas * (VM - Vm));
+ Standard_Real StepU = Min(Abs(1.5 * Du), pas * (UM - Um)),
+ StepV = Min(Abs(1.5 * Dv), pas * (VM - Vm));
if (d2dx < tolerance(1))
{
}
else
{
- //if (FlecheCourante > fleche) { // step too great
+ // if (FlecheCourante > fleche) { // step too great
if (FlecheCourante > fleche * fleche)
{ // step too great
Step = Step / 2.;
}
else
{
- Standard_Real d2dx = Abs(sp.Direction2d().X());
- Standard_Real d2dy = Abs(sp.Direction2d().Y());
+ Standard_Real d2dx = Abs(sp.Direction2d().X());
+ Standard_Real d2dy = Abs(sp.Direction2d().Y());
- Standard_Real StepU = Min(Abs(1.5 * Du), pas * (UM - Um)), StepV = Min(Abs(1.5 * Dv), pas * (VM - Vm));
+ Standard_Real StepU = Min(Abs(1.5 * Du), pas * (UM - Um)),
+ StepV = Min(Abs(1.5 * Dv), pas * (VM - Vm));
if (d2dx < tolerance(1))
{
previousd2d = sp.Direction2d();
if (N > 0)
- { //departure point given at input
+ { // departure point given at input
PathPnt = Pnts1.Value(N);
- //mark the line as open with a given stop point
+ // mark the line as open with a given stop point
Line->AddStatusFirst(Standard_False, Standard_True, N, PathPnt);
AddPointInCurrentLine(N, PathPnt, Line);
if (N < 0)
Line->AddPoint(Psol);
Line->AddStatusFirst(Standard_False, Standard_False);
- //mark the line as open without given stop point
+ // mark the line as open without given stop point
}
- Line->Reverse(); //inverser la ligne
+ Line->Reverse(); // inverser la ligne
Line->SetTangentVector(previousd3d.Reversed(), Line->NbPoints());
}
-Standard_Boolean IntWalk_IWalking::IsValidEndPoint(const Standard_Integer IndOfPoint, const Standard_Integer IndOfLine)
+Standard_Boolean IntWalk_IWalking::IsValidEndPoint(const Standard_Integer IndOfPoint,
+ const Standard_Integer IndOfLine)
{
if (PointLineLine.IsEmpty())
return Standard_True;
}
}
-Standard_Boolean IntWalk_IWalking::IsPointOnLine(const gp_Pnt2d& theP2d, const Standard_Integer Irang)
+Standard_Boolean IntWalk_IWalking::IsPointOnLine(const gp_Pnt2d& theP2d,
+ const Standard_Integer Irang)
{
const Handle(IntWalk_TheIWLine)& aLine = lines.Value(Abs(Irang));
for (Standard_Integer i = 1; i <= aLine->NbPoints(); i++)
}
//==================================================================================
-//function : IsPointOnLine
-//purpose : Projects thePOn2S on the nearest segment of the already computed line.
+// function : IsPointOnLine
+// purpose : Projects thePOn2S on the nearest segment of the already computed line.
// The retrieved projection point (aPa) is refined using theSolver.
// After the refinement, we will obtain a point aPb.
// If thePOn2S is quite far from aPb then thePOn2S is not
if (aL->IsOutBox(aP3d))
continue;
- //Look for the nearest segment
+ // Look for the nearest segment
Standard_Real aUMin = 0.0, aVMin = 0.0;
Standard_Real aMinSqDist = RealLast();
for (Standard_Integer aPtIdx = 1; aPtIdx < aL->NbPoints(); aPtIdx++)
const Standard_Real aDP = aP1P.Dot(aP1P2);
- Standard_Real aSqD = RealLast();
+ Standard_Real aSqD = RealLast();
if (aDP < 0.0)
{
continue;
if (aSqD < aMinSqDist)
{
- aMinSqDist = aSqD;
+ aMinSqDist = aSqD;
const Standard_Real aL1 = aDP / aSq12;
const Standard_Real aL2 = 1.0 - aL1;
theSolver.Root(aVecPrms);
- const gp_Pnt aPa(theFunc.PSurface()->Value(aUMin, aVMin)), aPb(theFunc.PSurface()->Value(aVecPrms(1), aVecPrms(2)));
+ const gp_Pnt aPa(theFunc.PSurface()->Value(aUMin, aVMin)),
+ aPb(theFunc.PSurface()->Value(aVecPrms(1), aVecPrms(2)));
const Standard_Real aSqD1 = aPb.SquareDistance(aP3d);
const Standard_Real aSqD2 = aPa.SquareDistance(aPb);
static const int Pourcent3[4] = {0, 1, 2, 0};
-static Standard_Boolean IsInSegment(const gp_Vec& P1P2,
- const gp_Vec& P1P,
- const Standard_Real NP1P2,
- Standard_Real &Param,
- const Standard_Real Tolerance) {
+static Standard_Boolean IsInSegment(const gp_Vec& P1P2,
+ const gp_Vec& P1P,
+ const Standard_Real NP1P2,
+ Standard_Real& Param,
+ const Standard_Real Tolerance)
+{
Param = P1P2.Dot(P1P);
- Param/= NP1P2;
- if(Param > (NP1P2+Tolerance))
- return(Standard_False);
- if(Param < (-Tolerance))
- return(Standard_False);
- Param/=NP1P2;
- if(Param<0.0) Param=0.0;
- if(Param>1.0) Param=1.0;
- return(Standard_True);
+ Param /= NP1P2;
+ if (Param > (NP1P2 + Tolerance))
+ return (Standard_False);
+ if (Param < (-Tolerance))
+ return (Standard_False);
+ Param /= NP1P2;
+ if (Param < 0.0)
+ Param = 0.0;
+ if (Param > 1.0)
+ Param = 1.0;
+ return (Standard_True);
}
-
//=================================================================================================
-
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron()
-: Intf_Interference (Standard_False),
- BeginOfClosedPolygon (Standard_False),
- iLin (0)
-{}
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron()
+ : Intf_Interference(Standard_False),
+ BeginOfClosedPolygon(Standard_False),
+ iLin(0)
+{
+}
//=======================================================================
-//function : Intf_InterferencePolygonPolyhedron
-//purpose : Construct and compute an interference between a Polygon3d
+// function : Intf_InterferencePolygonPolyhedron
+// purpose : Construct and compute an interference between a Polygon3d
// and a Polyhedron.
//=======================================================================
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
- (const Polygon3d& thePolyg, const Polyhedron& thePolyh)
-: Intf_Interference (Standard_False),
- BeginOfClosedPolygon (Standard_False),
- iLin (0)
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron(const Polygon3d& thePolyg,
+ const Polyhedron& thePolyh)
+ : Intf_Interference(Standard_False),
+ BeginOfClosedPolygon(Standard_False),
+ iLin(0)
{
- Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolygon3d::DeflectionOverEstimation(thePolyg)
+ + ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- if (!ToolPolygon3d::Bounding(thePolyg).IsOut(ToolPolyh::Bounding(thePolyh))) {
+ if (!ToolPolygon3d::Bounding(thePolyg).IsOut(ToolPolyh::Bounding(thePolyh)))
+ {
Interference(thePolyg, thePolyh);
}
-}
-
+}
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
- (const Polygon3d& thePolyg, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
-: Intf_Interference (Standard_False),
- BeginOfClosedPolygon (Standard_False),
- iLin (0)
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron(const Polygon3d& thePolyg,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
+ : Intf_Interference(Standard_False),
+ BeginOfClosedPolygon(Standard_False),
+ iLin(0)
{
- Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolygon3d::DeflectionOverEstimation(thePolyg)
+ + ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- if (!ToolPolygon3d::Bounding(thePolyg).IsOut(ToolPolyh::Bounding(thePolyh))) {
- Interference(thePolyg, thePolyh,PolyhGrid);
+ if (!ToolPolygon3d::Bounding(thePolyg).IsOut(ToolPolyh::Bounding(thePolyh)))
+ {
+ Interference(thePolyg, thePolyh, PolyhGrid);
}
-}
+}
//=======================================================================
-//function : Intf_InterferencePolygonPolyhedron
-//purpose : Construct and compute an interference between a Straight
+// function : Intf_InterferencePolygonPolyhedron
+// purpose : Construct and compute an interference between a Straight
// Line and a Polyhedron.
//=======================================================================
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
- (const gp_Lin& theLin, const Polyhedron& thePolyh)
-: Intf_Interference (Standard_False),
- BeginOfClosedPolygon (Standard_False),
- iLin (0)
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron(const gp_Lin& theLin,
+ const Polyhedron& thePolyh)
+ : Intf_Interference(Standard_False),
+ BeginOfClosedPolygon(Standard_False),
+ iLin(0)
{
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Bnd_BoundSortBox PolyhGrid;
- PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh), ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
- iLin=0;
+ iLin = 0;
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool btoo;
btoo.LinBox(theLin, ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger iCl(PolyhGrid.Compare(bofLin));
- while (iCl.More()) {
- indTri=iCl.Value();
- Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ while (iCl.More())
+ {
+ indTri = iCl.Value();
+ Intersect(theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
iCl.Next();
}
}
-
//=======================================================================
-//function : Intf_InterferencePolygonPolyhedron
-//purpose : Construct and compute an interference between the Straights
+// function : Intf_InterferencePolygonPolyhedron
+// purpose : Construct and compute an interference between the Straights
// Lines in <Obje> and the Polyhedron <thePolyh>.
//=======================================================================
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
- (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh)
-: Intf_Interference (Standard_False),
- BeginOfClosedPolygon (Standard_False),
- iLin (0)
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron(
+ const Intf_Array1OfLin& theLins,
+ const Polyhedron& thePolyh)
+ : Intf_Interference(Standard_False),
+ BeginOfClosedPolygon(Standard_False),
+ iLin(0)
{
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool bToo;
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Bnd_BoundSortBox PolyhGrid;
- PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh), ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
- for (iLin=1; iLin<=theLins.Length(); iLin++) {
-
+ for (iLin = 1; iLin <= theLins.Length(); iLin++)
+ {
bToo.LinBox(theLins(iLin), ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger ilC(PolyhGrid.Compare(bofLin));
- while (ilC.More()) {
- indTri=ilC.Value();
- Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ while (ilC.More())
+ {
+ indTri = ilC.Value();
+ Intersect(theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
ilC.Next();
}
}
}
-
//=================================================================================================
-
-void Intf_InterferencePolygonPolyhedron::Perform
- (const Polygon3d& thePolyg, const Polyhedron& thePolyh)
+void Intf_InterferencePolygonPolyhedron::Perform(const Polygon3d& thePolyg,
+ const Polyhedron& thePolyh)
{
SelfInterference(Standard_False);
- Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolygon3d::DeflectionOverEstimation(thePolyg)
+ + ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- if (!ToolPolygon3d::Bounding(thePolyg).IsOut
- (ToolPolyh::Bounding(thePolyh))) {
+ if (!ToolPolygon3d::Bounding(thePolyg).IsOut(ToolPolyh::Bounding(thePolyh)))
+ {
Interference(thePolyg, thePolyh);
}
-}
-
+}
//=================================================================================================
-
-void Intf_InterferencePolygonPolyhedron::Perform
- (const gp_Lin& theLin, const Polyhedron& thePolyh)
+void Intf_InterferencePolygonPolyhedron::Perform(const gp_Lin& theLin, const Polyhedron& thePolyh)
{
SelfInterference(Standard_False);
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Bnd_BoundSortBox PolyhGrid;
- PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh), ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
- iLin=0;
+ iLin = 0;
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool btoo;
btoo.LinBox(theLin, ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger lCi(PolyhGrid.Compare(bofLin));
- while (lCi.More()) {
- indTri=lCi.Value();
- Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ while (lCi.More())
+ {
+ indTri = lCi.Value();
+ Intersect(theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
lCi.Next();
}
}
-
//=======================================================================
-//function : Perform
-//purpose : Compute an interference between the Straights
+// function : Perform
+// purpose : Compute an interference between the Straights
// Lines in <Obje> and the Polyhedron <thePolyh>.
//=======================================================================
-void Intf_InterferencePolygonPolyhedron::Perform
- (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh)
+void Intf_InterferencePolygonPolyhedron::Perform(const Intf_Array1OfLin& theLins,
+ const Polyhedron& thePolyh)
{
SelfInterference(Standard_False);
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool Btoo;
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Bnd_BoundSortBox PolyhGrid;
- PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh), ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
- for (iLin=1; iLin<=theLins.Length(); iLin++) {
+ for (iLin = 1; iLin <= theLins.Length(); iLin++)
+ {
Btoo.LinBox(theLins(iLin), ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger tlC(PolyhGrid.Compare(bofLin));
- while (tlC.More()) {
- indTri=tlC.Value();
- Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ while (tlC.More())
+ {
+ indTri = tlC.Value();
+ Intersect(theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
tlC.Next();
}
}
}
-
//=======================================================================
-//function : Interference
-//purpose : Compare the boundings between the segment of <Obje>
+// function : Interference
+// purpose : Compare the boundings between the segment of <Obje>
// and the facets of <thePolyh>.
//=======================================================================
-void Intf_InterferencePolygonPolyhedron::Interference
- (const Polygon3d& thePolyg, const Polyhedron& thePolyh)
+void Intf_InterferencePolygonPolyhedron::Interference(const Polygon3d& thePolyg,
+ const Polyhedron& thePolyh)
{
Bnd_Box bofSeg;
Bnd_BoundSortBox PolyhGrid;
- PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
- ToolPolyh::ComponentsBounding(thePolyh));
+ PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh), ToolPolyh::ComponentsBounding(thePolyh));
Standard_Integer indTri;
- BeginOfClosedPolygon=ToolPolygon3d::Closed(thePolyg);
+ BeginOfClosedPolygon = ToolPolygon3d::Closed(thePolyg);
Standard_Real defPh = ToolPolyh::DeflectionOverEstimation(thePolyh);
- for (iLin=1; iLin<=ToolPolygon3d::NbSegments(thePolyg); iLin++) {
+ for (iLin = 1; iLin <= ToolPolygon3d::NbSegments(thePolyg); iLin++)
+ {
bofSeg.SetVoid();
bofSeg.Add(ToolPolygon3d::BeginOfSeg(thePolyg, iLin));
TColStd_ListOfInteger maliste;
maliste = PolyhGrid.Compare(bofSeg);
TColStd_ListIteratorOfListOfInteger clt(maliste);
- for (; clt.More(); clt.Next()) {
- indTri=clt.Value();
- gp_Pnt p1 = ToolPolygon3d::BeginOfSeg(thePolyg, iLin);
- gp_Pnt p2 = ToolPolygon3d::EndOfSeg(thePolyg, iLin);
+ for (; clt.More(); clt.Next())
+ {
+ indTri = clt.Value();
+ gp_Pnt p1 = ToolPolygon3d::BeginOfSeg(thePolyg, iLin);
+ gp_Pnt p2 = ToolPolygon3d::EndOfSeg(thePolyg, iLin);
Standard_Integer pTri0, pTri1, pTri2;
ToolPolyh::Triangle(thePolyh, indTri, pTri0, pTri1, pTri2);
- gp_Pnt Pa=ToolPolyh::Point(thePolyh, pTri0);
- gp_Pnt Pb=ToolPolyh::Point(thePolyh, pTri1);
- gp_Pnt Pc=ToolPolyh::Point(thePolyh, pTri2);
- gp_Vec PaPb(Pa,Pb);
- gp_Vec PaPc(Pa,Pc);
- gp_Vec Normale = PaPb.Crossed(PaPc);
- Standard_Real Norm_Normale=Normale.Magnitude();
- if(Norm_Normale<1e-14)
- continue;
- Normale.Multiply(defPh/Norm_Normale);
+ gp_Pnt Pa = ToolPolyh::Point(thePolyh, pTri0);
+ gp_Pnt Pb = ToolPolyh::Point(thePolyh, pTri1);
+ gp_Pnt Pc = ToolPolyh::Point(thePolyh, pTri2);
+ gp_Vec PaPb(Pa, Pb);
+ gp_Vec PaPc(Pa, Pc);
+ gp_Vec Normale = PaPb.Crossed(PaPc);
+ Standard_Real Norm_Normale = Normale.Magnitude();
+ if (Norm_Normale < 1e-14)
+ continue;
+ Normale.Multiply(defPh / Norm_Normale);
gp_Pnt p1m = p1.Translated(-Normale);
- gp_Pnt p1p = p1.Translated( Normale);
+ gp_Pnt p1p = p1.Translated(Normale);
gp_Pnt p2m = p2.Translated(-Normale);
- gp_Pnt p2p = p2.Translated( Normale);
- Intersect(p1m,
- p2p,
- Standard_False, indTri, thePolyh);
- Intersect(p1p,
- p2m,
- Standard_False, indTri, thePolyh);
-// Intersect(ToolPolygon3d::BeginOfSeg(thePolyg, iLin),
-// ToolPolygon3d::EndOfSeg(thePolyg, iLin),
-// Standard_False, indTri, thePolyh);
+ gp_Pnt p2p = p2.Translated(Normale);
+ Intersect(p1m, p2p, Standard_False, indTri, thePolyh);
+ Intersect(p1p, p2m, Standard_False, indTri, thePolyh);
+ // Intersect(ToolPolygon3d::BeginOfSeg(thePolyg, iLin),
+ // ToolPolygon3d::EndOfSeg(thePolyg, iLin),
+ // Standard_False, indTri, thePolyh);
}
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
//=======================================================================
-//function : Intf_InterferencePolygonPolyhedron
-//purpose : Construct and compute an interference between a Straight
+// function : Intf_InterferencePolygonPolyhedron
+// purpose : Construct and compute an interference between a Straight
// Line and a Polyhedron.
//=======================================================================
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
- (const gp_Lin& theLin, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
-: Intf_Interference(Standard_False)
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron(const gp_Lin& theLin,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
+ : Intf_Interference(Standard_False)
{
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Standard_Integer indTri;
- iLin=0;
+ iLin = 0;
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool btoo;
btoo.LinBox(theLin, ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger iCl(PolyhGrid.Compare(bofLin));
- while (iCl.More()) {
- indTri=iCl.Value();
- Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ while (iCl.More())
+ {
+ indTri = iCl.Value();
+ Intersect(theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
iCl.Next();
}
}
-
//=======================================================================
-//function : Intf_InterferencePolygonPolyhedron
-//purpose : Construct and compute an interference between the Straights
+// function : Intf_InterferencePolygonPolyhedron
+// purpose : Construct and compute an interference between the Straights
// Lines in <Obje> and the Polyhedron <thePolyh>.
//=======================================================================
-Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
- (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
-: Intf_Interference(Standard_False)
+Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron(
+ const Intf_Array1OfLin& theLins,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
+ : Intf_Interference(Standard_False)
{
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool bToo;
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Standard_Integer indTri;
- for (iLin=1; iLin<=theLins.Length(); iLin++) {
-
+ for (iLin = 1; iLin <= theLins.Length(); iLin++)
+ {
bToo.LinBox(theLins(iLin), ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger ilC(PolyhGrid.Compare(bofLin));
- while (ilC.More()) {
- indTri=ilC.Value();
- Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ while (ilC.More())
+ {
+ indTri = ilC.Value();
+ Intersect(theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
ilC.Next();
}
}
}
-
//=================================================================================================
-
-void Intf_InterferencePolygonPolyhedron::Perform
- (const Polygon3d& thePolyg, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+void Intf_InterferencePolygonPolyhedron::Perform(const Polygon3d& thePolyg,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
{
SelfInterference(Standard_False);
- Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
- ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
-
- if (!ToolPolygon3d::Bounding(thePolyg).IsOut
- (ToolPolyh::Bounding(thePolyh))) {
- Interference(thePolyg, thePolyh,PolyhGrid);
- }
-}
+ Tolerance = ToolPolygon3d::DeflectionOverEstimation(thePolyg)
+ + ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
+ if (!ToolPolygon3d::Bounding(thePolyg).IsOut(ToolPolyh::Bounding(thePolyh)))
+ {
+ Interference(thePolyg, thePolyh, PolyhGrid);
+ }
+}
//=================================================================================================
-
-void Intf_InterferencePolygonPolyhedron::Perform
- (const gp_Lin& theLin, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+void Intf_InterferencePolygonPolyhedron::Perform(const gp_Lin& theLin,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
{
SelfInterference(Standard_False);
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Standard_Integer indTri;
- iLin=0;
+ iLin = 0;
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool btoo;
btoo.LinBox(theLin, ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger lCi(PolyhGrid.Compare(bofLin));
- while (lCi.More()) {
- indTri=lCi.Value();
- Intersect
- (theLin.Location(),
- theLin.Location().Translated(gp_Vec(theLin.Direction())),
- Standard_True, indTri, thePolyh);
+ while (lCi.More())
+ {
+ indTri = lCi.Value();
+ Intersect(theLin.Location(),
+ theLin.Location().Translated(gp_Vec(theLin.Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
lCi.Next();
}
}
-
//=======================================================================
-//function : Perform
-//purpose : Compute an interference between the Straights
+// function : Perform
+// purpose : Compute an interference between the Straights
// Lines in <Obje> and the Polyhedron <thePolyh>.
//=======================================================================
-void Intf_InterferencePolygonPolyhedron::Perform
- (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+void Intf_InterferencePolygonPolyhedron::Perform(const Intf_Array1OfLin& theLins,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
{
SelfInterference(Standard_False);
- Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
+ Tolerance = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ if (Tolerance == 0.)
+ Tolerance = Epsilon(1000.);
- Bnd_Box bofLin;
+ Bnd_Box bofLin;
Intf_Tool Btoo;
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
Standard_Integer indTri;
- for (iLin=1; iLin<=theLins.Length(); iLin++) {
+ for (iLin = 1; iLin <= theLins.Length(); iLin++)
+ {
Btoo.LinBox(theLins(iLin), ToolPolyh::Bounding(thePolyh), bofLin);
TColStd_ListIteratorOfListOfInteger tlC(PolyhGrid.Compare(bofLin));
- while (tlC.More()) {
- indTri=tlC.Value();
- Intersect
- (theLins(iLin).Location(),
- theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
- Standard_True, indTri, thePolyh);
+ while (tlC.More())
+ {
+ indTri = tlC.Value();
+ Intersect(theLins(iLin).Location(),
+ theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+ Standard_True,
+ indTri,
+ thePolyh);
tlC.Next();
}
}
}
-
-
//=======================================================================
-//function : Interference
-//purpose : Compare the boundings between the segment of <Obje>
+// function : Interference
+// purpose : Compare the boundings between the segment of <Obje>
// and the facets of <thePolyh>.
//=======================================================================
-void Intf_InterferencePolygonPolyhedron::Interference
- (const Polygon3d& thePolyg, const Polyhedron& thePolyh,
- Bnd_BoundSortBox &PolyhGrid)
+void Intf_InterferencePolygonPolyhedron::Interference(const Polygon3d& thePolyg,
+ const Polyhedron& thePolyh,
+ Bnd_BoundSortBox& PolyhGrid)
{
Bnd_Box bofSeg;
Standard_Integer indTri;
- BeginOfClosedPolygon=ToolPolygon3d::Closed(thePolyg);
+ BeginOfClosedPolygon = ToolPolygon3d::Closed(thePolyg);
- for (iLin=1; iLin<=ToolPolygon3d::NbSegments(thePolyg); iLin++) {
+ for (iLin = 1; iLin <= ToolPolygon3d::NbSegments(thePolyg); iLin++)
+ {
bofSeg.SetVoid();
bofSeg.Add(ToolPolygon3d::BeginOfSeg(thePolyg, iLin));
bofSeg.Enlarge(ToolPolygon3d::DeflectionOverEstimation(thePolyg));
// Modified by MKK - Thu Oct 25 12:40:11 2007
- Standard_Real defPh = ToolPolyh::DeflectionOverEstimation(thePolyh);
+ Standard_Real defPh = ToolPolyh::DeflectionOverEstimation(thePolyh);
TColStd_ListOfInteger maliste;
maliste = PolyhGrid.Compare(bofSeg);
TColStd_ListIteratorOfListOfInteger clt(maliste);
// Modified by MKK - Thu Oct 25 12:40:11 2007 Begin
gp_Pnt p1, Beg0;
gp_Pnt p2, End0;
- if ( !maliste.IsEmpty() ) {
- p1 = ToolPolygon3d::BeginOfSeg(thePolyg, iLin);
- p2 = ToolPolygon3d::EndOfSeg(thePolyg, iLin);
+ if (!maliste.IsEmpty())
+ {
+ p1 = ToolPolygon3d::BeginOfSeg(thePolyg, iLin);
+ p2 = ToolPolygon3d::EndOfSeg(thePolyg, iLin);
Beg0 = p1;
End0 = p2;
}
// Modified by MKK - Thu Oct 25 12:40:11 2007 End
- while (clt.More()) {
- indTri=clt.Value();
+ while (clt.More())
+ {
+ indTri = clt.Value();
// Modified by MKK - Thu Oct 25 12:40:11 2007 Begin
Standard_Integer pTri[3];
ToolPolyh::Triangle(thePolyh, indTri, pTri[0], pTri[1], pTri[2]);
- gp_XYZ triNor; // Vecteur normal.
- Standard_Real triDp = 0.; // Distance polaire.
-
+ gp_XYZ triNor; // Vecteur normal.
+ Standard_Real triDp = 0.; // Distance polaire.
+
Intf::PlaneEquation(ToolPolyh::Point(thePolyh, pTri[0]),
- ToolPolyh::Point(thePolyh, pTri[1]),
- ToolPolyh::Point(thePolyh, pTri[2]),
- triNor, triDp);
+ ToolPolyh::Point(thePolyh, pTri[1]),
+ ToolPolyh::Point(thePolyh, pTri[2]),
+ triNor,
+ triDp);
// enlarge boundary segment
- if ( iLin == 1 ) {
- gp_XYZ dif = p1.XYZ() - p2.XYZ();
- Standard_Real dist = dif.Modulus();
- if ( dist > gp::Resolution() ) {
- dif /= dist;
- Standard_Real aCos = dif * triNor;
- aCos = fabs(aCos);
- if ( aCos > gp::Resolution() ) {
- Standard_Real shift = defPh / aCos;
- Beg0.SetXYZ( p1.XYZ() + dif * shift );
- }
- }
+ if (iLin == 1)
+ {
+ gp_XYZ dif = p1.XYZ() - p2.XYZ();
+ Standard_Real dist = dif.Modulus();
+ if (dist > gp::Resolution())
+ {
+ dif /= dist;
+ Standard_Real aCos = dif * triNor;
+ aCos = fabs(aCos);
+ if (aCos > gp::Resolution())
+ {
+ Standard_Real shift = defPh / aCos;
+ Beg0.SetXYZ(p1.XYZ() + dif * shift);
+ }
+ }
}
- else if ( iLin == ToolPolygon3d::NbSegments(thePolyg) ) {
- gp_XYZ dif = p2.XYZ() - p1.XYZ();
- Standard_Real dist = dif.Modulus();
- if ( dist > gp::Resolution() ) {
- dif /= dist;
- Standard_Real aCos = dif * triNor;
- aCos = fabs(aCos);
- if ( aCos > gp::Resolution() ) {
- Standard_Real shift = defPh / aCos;
- End0.SetXYZ( p2.XYZ() + dif * shift );
- }
- }
+ else if (iLin == ToolPolygon3d::NbSegments(thePolyg))
+ {
+ gp_XYZ dif = p2.XYZ() - p1.XYZ();
+ Standard_Real dist = dif.Modulus();
+ if (dist > gp::Resolution())
+ {
+ dif /= dist;
+ Standard_Real aCos = dif * triNor;
+ aCos = fabs(aCos);
+ if (aCos > gp::Resolution())
+ {
+ Standard_Real shift = defPh / aCos;
+ End0.SetXYZ(p2.XYZ() + dif * shift);
+ }
+ }
}
- Standard_Real dBegTri=(triNor*Beg0.XYZ())-triDp; // Distance <p1> plane
- Standard_Real dEndTri=(triNor*End0.XYZ())-triDp; // Distance <p2> plane
+ Standard_Real dBegTri = (triNor * Beg0.XYZ()) - triDp; // Distance <p1> plane
+ Standard_Real dEndTri = (triNor * End0.XYZ()) - triDp; // Distance <p2> plane
Intersect(Beg0, End0, Standard_False, indTri, thePolyh, triNor, triDp, dBegTri, dEndTri);
// Modified by MKK - Thu Oct 25 12:40:11 2007 End
clt.Next();
}
- BeginOfClosedPolygon=Standard_False;
+ BeginOfClosedPolygon = Standard_False;
}
}
-
//=======================================================================
-//function : Intersect
-//purpose : Compute the intersection between the segment or the line
+// function : Intersect
+// purpose : Compute the intersection between the segment or the line
// and the triangle <TTri>.
//=======================================================================
#if 0
TTri, 0, 0.,1.);
mySPoins.Append(SP);
}
-#else
-void Intf_InterferencePolygonPolyhedron::Intersect
- (const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
- const Standard_Integer TTri, const Polyhedron& thePolyh)
+#else
+void Intf_InterferencePolygonPolyhedron::Intersect(const gp_Pnt& BegO,
+ const gp_Pnt& EndO,
+ const Standard_Boolean Infinite,
+ const Standard_Integer TTri,
+ const Polyhedron& thePolyh)
{
- Intf_PIType typOnG=Intf_EDGE;
- Standard_Real t;
+ Intf_PIType typOnG = Intf_EDGE;
+ Standard_Real t;
Standard_Integer pTri[3];
ToolPolyh::Triangle(thePolyh, TTri, pTri[0], pTri[1], pTri[2]);
- gp_XYZ triNor; // Vecteur normal.
- Standard_Real triDp; // Distance polaire.
+ gp_XYZ triNor; // Vecteur normal.
+ Standard_Real triDp; // Distance polaire.
Intf::PlaneEquation(ToolPolyh::Point(thePolyh, pTri[0]),
- ToolPolyh::Point(thePolyh, pTri[1]),
- ToolPolyh::Point(thePolyh, pTri[2]),
- triNor, triDp);
-
-
- Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
- Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
- gp_XYZ segO=EndO.XYZ()-BegO.XYZ();
+ ToolPolyh::Point(thePolyh, pTri[1]),
+ ToolPolyh::Point(thePolyh, pTri[2]),
+ triNor,
+ triDp);
+
+ Standard_Real dBegTri = (triNor * BegO.XYZ()) - triDp; // Distance <BegO> plan
+ Standard_Real dEndTri = (triNor * EndO.XYZ()) - triDp; // Distance <EndO> plan
+ gp_XYZ segO = EndO.XYZ() - BegO.XYZ();
segO.Normalize();
Standard_Boolean NoIntersectionWithTriangle = Standard_False;
Standard_Real param;
- t = dBegTri-dEndTri;
- if (t >= 1.e-16 || t<=-1.e-16)
- param = dBegTri/t;
- else param = dBegTri;
- Standard_Real floatgap=Epsilon(1000.);
-
- if (!Infinite) {
- if (dBegTri<=floatgap && dBegTri>=-floatgap ) {
- param=0.;typOnG=Intf_VERTEX;
- if (BeginOfClosedPolygon)
- NoIntersectionWithTriangle = Standard_False;
+ t = dBegTri - dEndTri;
+ if (t >= 1.e-16 || t <= -1.e-16)
+ param = dBegTri / t;
+ else
+ param = dBegTri;
+ Standard_Real floatgap = Epsilon(1000.);
+
+ if (!Infinite)
+ {
+ if (dBegTri <= floatgap && dBegTri >= -floatgap)
+ {
+ param = 0.;
+ typOnG = Intf_VERTEX;
+ if (BeginOfClosedPolygon)
+ NoIntersectionWithTriangle = Standard_False;
}
- else if (dEndTri<=floatgap && dEndTri>=-floatgap) {
- param=1.;typOnG=Intf_VERTEX;
+ else if (dEndTri <= floatgap && dEndTri >= -floatgap)
+ {
+ param = 1.;
+ typOnG = Intf_VERTEX;
NoIntersectionWithTriangle = Standard_False;
}
- if (param<0. || param>1.) {
+ if (param < 0. || param > 1.)
+ {
NoIntersectionWithTriangle = Standard_True;
}
}
- if(NoIntersectionWithTriangle == Standard_False) {
- gp_XYZ spLieu=BegO.XYZ()+((EndO.XYZ()-BegO.XYZ())*param);
- Standard_Real dPiE[3] = { 0.0, 0.0, 0.0 }, dPtPi[3], sigd;
- Standard_Integer is = 0;
- Standard_Integer sEdge=-1;
- Standard_Integer sVertex=-1;
- Standard_Integer tbreak=0;
+ if (NoIntersectionWithTriangle == Standard_False)
+ {
+ gp_XYZ spLieu = BegO.XYZ() + ((EndO.XYZ() - BegO.XYZ()) * param);
+ Standard_Real dPiE[3] = {0.0, 0.0, 0.0}, dPtPi[3], sigd;
+ Standard_Integer is = 0;
+ Standard_Integer sEdge = -1;
+ Standard_Integer sVertex = -1;
+ Standard_Integer tbreak = 0;
{ //-- is = 0
- gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
- gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
- dPtPi[0]=vecP.Modulus();
- if (dPtPi[0]<=floatgap) {
- sVertex=0;
- is=0;
- tbreak=1;
+ gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()
+ - ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+ gp_XYZ vecP(spLieu - ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+ dPtPi[0] = vecP.Modulus();
+ if (dPtPi[0] <= floatgap)
+ {
+ sVertex = 0;
+ is = 0;
+ tbreak = 1;
}
- else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
- sEdge=0;
- is=0;
- tbreak=1;
- }
+ else
+ {
+ gp_XYZ segT_x_vecP(segT ^ vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP * triNor;
+ if (sigd > floatgap)
+ sigd = 1.0;
+ else if (sigd < -floatgap)
+ sigd = -1.0;
+ else
+ {
+ sigd = 0.0;
+ }
+ dPiE[0] = sigd * (Modulus_segT_x_vecP / segT.Modulus());
+ if (dPiE[0] <= floatgap && dPiE[0] >= -floatgap)
+ {
+ sEdge = 0;
+ is = 0;
+ tbreak = 1;
+ }
}
}
- if(tbreak==0) { //-- is = 1
- gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
- gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
- dPtPi[1]=vecP.Modulus();
- if (dPtPi[1]<=floatgap) {
- sVertex=1;
- is=1;
- tbreak=1;
+ if (tbreak == 0)
+ { //-- is = 1
+ gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()
+ - ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+ gp_XYZ vecP(spLieu - ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+ dPtPi[1] = vecP.Modulus();
+ if (dPtPi[1] <= floatgap)
+ {
+ sVertex = 1;
+ is = 1;
+ tbreak = 1;
}
- else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
- sEdge=1;
- is=1;
- tbreak=1;
- }
+ else
+ {
+ gp_XYZ segT_x_vecP(segT ^ vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP * triNor;
+ if (sigd > floatgap)
+ sigd = 1.0;
+ else if (sigd < -floatgap)
+ sigd = -1.0;
+ else
+ {
+ sigd = 0.0;
+ }
+ dPiE[1] = sigd * (Modulus_segT_x_vecP / segT.Modulus());
+ if (dPiE[1] <= floatgap && dPiE[1] >= -floatgap)
+ {
+ sEdge = 1;
+ is = 1;
+ tbreak = 1;
+ }
}
}
- if(tbreak==0) { //-- is = 2
- gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
- gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
- dPtPi[2]=vecP.Modulus();
- if (dPtPi[2]<=floatgap) {
- sVertex=2;
- is=2;
+ if (tbreak == 0)
+ { //-- is = 2
+ gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()
+ - ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+ gp_XYZ vecP(spLieu - ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+ dPtPi[2] = vecP.Modulus();
+ if (dPtPi[2] <= floatgap)
+ {
+ sVertex = 2;
+ is = 2;
}
- gp_XYZ segT_x_vecP(segT^vecP);
+ gp_XYZ segT_x_vecP(segT ^ vecP);
Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
+ sigd = segT_x_vecP * triNor;
+ if (sigd > floatgap)
+ sigd = 1.0;
+ else if (sigd < -floatgap)
+ sigd = -1.0;
+ else
+ {
+ sigd = 0.0;
}
- dPiE[2]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[2]<=floatgap && dPiE[2]>=-floatgap) {
- sEdge=2;
- is=2;
+ dPiE[2] = sigd * (Modulus_segT_x_vecP / segT.Modulus());
+ if (dPiE[2] <= floatgap && dPiE[2] >= -floatgap)
+ {
+ sEdge = 2;
+ is = 2;
}
}
//-- fin for i=0 to 2
// !!cout<<endl;
-
+
Standard_Integer triCon, pedg;
- if (sVertex>-1) {
- triCon=TTri;
- pedg=pTri[Pourcent3[sVertex+1]];
-//-- while (triCon!=0) {
-//-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
-//-- //-- if (triCon<TTri) return;
-//-- if (triCon==TTri) break;
-//-- }
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_VERTEX, pTri[is], 0, 0.,
- 1.);
+ if (sVertex > -1)
+ {
+ triCon = TTri;
+ pedg = pTri[Pourcent3[sVertex + 1]];
+ //-- while (triCon!=0) {
+ //-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
+ //-- //-- if (triCon<TTri) return;
+ //-- if (triCon==TTri) break;
+ //-- }
+ Intf_SectionPoint SP(spLieu, typOnG, 0, iLin, param, Intf_VERTEX, pTri[is], 0, 0., 1.);
mySPoins.Append(SP);
}
- else if (sEdge>-1) {
- ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge+1]],
- triCon, pedg);
- //-- if (triCon<=TTri) return; ???????????????????? LBR
+ else if (sEdge > -1)
+ {
+ ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge + 1]], triCon, pedg);
+ //-- if (triCon<=TTri) return; ???????????????????? LBR
// !!cout<<" sEdge "<<endl;
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
- Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
- 1.);
+ typOnG,
+ 0,
+ iLin,
+ param,
+ Intf_EDGE,
+ Min(pTri[sEdge], pTri[Pourcent3[sEdge + 1]]),
+ Max(pTri[sEdge], pTri[Pourcent3[sEdge + 1]]),
+ 0.,
+ 1.);
mySPoins.Append(SP);
}
- else if (dPiE[0]>0. && dPiE[1]>0. && dPiE[2]>0.) {
+ else if (dPiE[0] > 0. && dPiE[1] > 0. && dPiE[2] > 0.)
+ {
// !!cout<<" 3 Positifs "<<endl;
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
+ Intf_SectionPoint SP(spLieu, typOnG, 0, iLin, param, Intf_FACE, TTri, 0, 0., 1.);
mySPoins.Append(SP);
}
-// Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
+ // Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
// Sometimes triangulation doesn't cover whole the face. In this
// case it is necessary to take into account the deflection between boundary
// isolines of the surface and boundary trianles. Computed value of this
// deflection is contained in thePolyh.
- else {
+ else
+ {
Standard_Integer i;
- for (i = 1; i <= 3; i++) {
- Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
- Standard_Integer indP2 = pTri[i - 1];
-
- if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
- // For boundary line it is necessary to check the border deflection.
- Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
- const gp_Pnt &BegP = ToolPolyh::Point(thePolyh, indP1);
- const gp_Pnt &EndP = ToolPolyh::Point(thePolyh, indP2);
- gp_Vec VecTri(BegP,EndP);
- gp_Dir DirTri(VecTri);
- gp_Lin LinTri(BegP,DirTri);
- gp_Pnt aPOnE(spLieu);
- Standard_Real aDist = LinTri.Distance(aPOnE);
-
- if (aDist <= Deflection) {
- gp_Vec aVLocPOnE(BegP, aPOnE);
- gp_Vec aVecDirTri(DirTri);
- Standard_Real aPar = aVLocPOnE*aVecDirTri;
- Standard_Real aMaxPar = VecTri.Magnitude();
-
- if (aPar >= 0 && aPar <= aMaxPar) {
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
+ for (i = 1; i <= 3; i++)
+ {
+ Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
+ Standard_Integer indP2 = pTri[i - 1];
+
+ if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2))
+ {
+ // For boundary line it is necessary to check the border deflection.
+ Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
+ const gp_Pnt& BegP = ToolPolyh::Point(thePolyh, indP1);
+ const gp_Pnt& EndP = ToolPolyh::Point(thePolyh, indP2);
+ gp_Vec VecTri(BegP, EndP);
+ gp_Dir DirTri(VecTri);
+ gp_Lin LinTri(BegP, DirTri);
+ gp_Pnt aPOnE(spLieu);
+ Standard_Real aDist = LinTri.Distance(aPOnE);
+
+ if (aDist <= Deflection)
+ {
+ gp_Vec aVLocPOnE(BegP, aPOnE);
+ gp_Vec aVecDirTri(DirTri);
+ Standard_Real aPar = aVLocPOnE * aVecDirTri;
+ Standard_Real aMaxPar = VecTri.Magnitude();
+
+ if (aPar >= 0 && aPar <= aMaxPar)
+ {
+ Intf_SectionPoint SP(spLieu, typOnG, 0, iLin, param, Intf_FACE, TTri, 0, 0., 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
}
}
-// Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
+ // Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
} //---- if(NoIntersectionWithTriangle == Standard_False)
-
+
//---------------------------------------------------------------------------
- //-- On teste la distance entre les cotes du triangle et le polygone
- //--
+ //-- On teste la distance entre les cotes du triangle et le polygone
+ //--
//-- Si cette distance est inferieure a Tolerance, on cree un SP.
- //--
- //-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
-// if(Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
+ //--
+ //-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g
+ // Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
+ // if(Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
{
- gp_Vec VecPol(BegO,EndO);
+ gp_Vec VecPol(BegO, EndO);
Standard_Real NVecPol = VecPol.Magnitude();
- gp_Dir DirPol(VecPol);
- gp_Lin LinPol(BegO,DirPol);
- Standard_Real dist2,ParamOnO,ParamOnT;
-
- for (Standard_Integer i=0; i<3; i++) {
- Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i+1]];
+ gp_Dir DirPol(VecPol);
+ gp_Lin LinPol(BegO, DirPol);
+ Standard_Real dist2, ParamOnO, ParamOnT;
+
+ for (Standard_Integer i = 0; i < 3; i++)
+ {
+ Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i + 1]];
Standard_Integer pTri_i = pTri[i];
- const gp_Pnt& BegT = ToolPolyh::Point(thePolyh, pTri_ip1pc3);
- const gp_Pnt& EndT = ToolPolyh::Point(thePolyh, pTri_i);
- gp_Vec VecTri(BegT,EndT);
- Standard_Real NVecTri = VecTri.Magnitude();
- gp_Dir DirTri(VecTri);
- gp_Lin LinTri(BegT,DirTri);
- Extrema_ExtElC Extrema(LinPol,LinTri,0.00000001);
- if(Extrema.IsDone()) {
- if(Extrema.IsParallel() == Standard_False) {
- if(Extrema.NbExt()) {
- dist2 = Extrema.SquareDistance();
- if(dist2<=Tolerance * Tolerance) {
- Extrema_POnCurv POnC1,POnC2;
- Extrema.Points(1,POnC1,POnC2);
- const gp_Pnt& PO = POnC1.Value();
- const gp_Pnt& PT = POnC2.Value();
- //--cout<<" ** Nouveau "<<dist2<<endl;
- if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
- if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
- //-- cout<<" * "<<endl;
- gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
- Standard_Integer tmin,tmax;
- if(pTri_i>pTri_ip1pc3) {
- tmin=pTri_ip1pc3; tmax=pTri_i;
- }
- else {
- tmax=pTri_ip1pc3; tmin=pTri_i;
- }
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, ParamOnO,
- Intf_EDGE,
- tmin,
- tmax, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
- }
- }
+ const gp_Pnt& BegT = ToolPolyh::Point(thePolyh, pTri_ip1pc3);
+ const gp_Pnt& EndT = ToolPolyh::Point(thePolyh, pTri_i);
+ gp_Vec VecTri(BegT, EndT);
+ Standard_Real NVecTri = VecTri.Magnitude();
+ gp_Dir DirTri(VecTri);
+ gp_Lin LinTri(BegT, DirTri);
+ Extrema_ExtElC Extrema(LinPol, LinTri, 0.00000001);
+ if (Extrema.IsDone())
+ {
+ if (Extrema.IsParallel() == Standard_False)
+ {
+ if (Extrema.NbExt())
+ {
+ dist2 = Extrema.SquareDistance();
+ if (dist2 <= Tolerance * Tolerance)
+ {
+ Extrema_POnCurv POnC1, POnC2;
+ Extrema.Points(1, POnC1, POnC2);
+ const gp_Pnt& PO = POnC1.Value();
+ const gp_Pnt& PT = POnC2.Value();
+ //--cout<<" ** Nouveau "<<dist2<<endl;
+ if (IsInSegment(VecPol, gp_Vec(BegO, PO), NVecPol, ParamOnO, Tolerance))
+ {
+ if (IsInSegment(VecTri, gp_Vec(BegT, PT), NVecTri, ParamOnT, Tolerance))
+ {
+ //-- cout<<" * "<<endl;
+ gp_XYZ spLieu = BegT.XYZ() + ((EndT.XYZ() - BegT.XYZ()) * param);
+ Standard_Integer tmin, tmax;
+ if (pTri_i > pTri_ip1pc3)
+ {
+ tmin = pTri_ip1pc3;
+ tmax = pTri_i;
+ }
+ else
+ {
+ tmax = pTri_ip1pc3;
+ tmin = pTri_i;
+ }
+ Intf_SectionPoint
+ SP(spLieu, typOnG, 0, iLin, ParamOnO, Intf_EDGE, tmin, tmax, 0., 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
+ }
+ }
}
}
- }
+ }
}
#endif
-void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
- const gp_Pnt& EndO,
- const Standard_Boolean Infinite,
- const Standard_Integer TTri,
- const Polyhedron& thePolyh,
- const gp_XYZ& TriNormal,
- const Standard_Real /*TriDp*/,
- const Standard_Real dBegTri,
- const Standard_Real dEndTri)
+void Intf_InterferencePolygonPolyhedron::Intersect(const gp_Pnt& BegO,
+ const gp_Pnt& EndO,
+ const Standard_Boolean Infinite,
+ const Standard_Integer TTri,
+ const Polyhedron& thePolyh,
+ const gp_XYZ& TriNormal,
+ const Standard_Real /*TriDp*/,
+ const Standard_Real dBegTri,
+ const Standard_Real dEndTri)
{
- Intf_PIType typOnG=Intf_EDGE;
- Standard_Real t;
+ Intf_PIType typOnG = Intf_EDGE;
+ Standard_Real t;
Standard_Integer pTri[3];
ToolPolyh::Triangle(thePolyh, TTri, pTri[0], pTri[1], pTri[2]);
- gp_XYZ triNor = TriNormal; // Vecteur normal.
- //Standard_Real triDp = TriDp; // Distance polaire.
+ gp_XYZ triNor = TriNormal; // Vecteur normal.
+ // Standard_Real triDp = TriDp; // Distance polaire.
-
-// Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
-// Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
+ // Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
+ // Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
Standard_Boolean NoIntersectionWithTriangle = Standard_False;
Standard_Real param;
- t = dBegTri-dEndTri;
- if (t >= 1.e-16 || t<=-1.e-16)
- param = dBegTri/t;
- else param = dBegTri;
- Standard_Real floatgap=Epsilon(1000.);
-
- if (!Infinite) {
- if (dBegTri<=floatgap && dBegTri>=-floatgap ) {
- param=0.;typOnG=Intf_VERTEX;
- if (BeginOfClosedPolygon)
- NoIntersectionWithTriangle = Standard_False;
+ t = dBegTri - dEndTri;
+ if (t >= 1.e-16 || t <= -1.e-16)
+ param = dBegTri / t;
+ else
+ param = dBegTri;
+ Standard_Real floatgap = Epsilon(1000.);
+
+ if (!Infinite)
+ {
+ if (dBegTri <= floatgap && dBegTri >= -floatgap)
+ {
+ param = 0.;
+ typOnG = Intf_VERTEX;
+ if (BeginOfClosedPolygon)
+ NoIntersectionWithTriangle = Standard_False;
}
- else if (dEndTri<=floatgap && dEndTri>=-floatgap) {
- param=1.;typOnG=Intf_VERTEX;
+ else if (dEndTri <= floatgap && dEndTri >= -floatgap)
+ {
+ param = 1.;
+ typOnG = Intf_VERTEX;
NoIntersectionWithTriangle = Standard_False;
}
- if (param<0. || param>1.) {
+ if (param < 0. || param > 1.)
+ {
NoIntersectionWithTriangle = Standard_True;
}
}
- if(NoIntersectionWithTriangle == Standard_False) {
- gp_XYZ spLieu=BegO.XYZ()+((EndO.XYZ()-BegO.XYZ())*param);
- Standard_Real dPiE[3] = { 0.0, 0.0, 0.0 }, dPtPi[3], sigd;
- Standard_Integer is = 0;
- Standard_Integer sEdge=-1;
- Standard_Integer sVertex=-1;
- Standard_Integer tbreak=0;
+ if (NoIntersectionWithTriangle == Standard_False)
+ {
+ gp_XYZ spLieu = BegO.XYZ() + ((EndO.XYZ() - BegO.XYZ()) * param);
+ Standard_Real dPiE[3] = {0.0, 0.0, 0.0}, dPtPi[3], sigd;
+ Standard_Integer is = 0;
+ Standard_Integer sEdge = -1;
+ Standard_Integer sVertex = -1;
+ Standard_Integer tbreak = 0;
{ //-- is = 0
- gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
- gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
- dPtPi[0]=vecP.Modulus();
- if (dPtPi[0]<=floatgap) {
- sVertex=0;
- is=0;
- tbreak=1;
+ gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()
+ - ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+ gp_XYZ vecP(spLieu - ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+ dPtPi[0] = vecP.Modulus();
+ if (dPtPi[0] <= floatgap)
+ {
+ sVertex = 0;
+ is = 0;
+ tbreak = 1;
}
- else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
- sEdge=0;
- is=0;
- tbreak=1;
- }
+ else
+ {
+ gp_XYZ segT_x_vecP(segT ^ vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP * triNor;
+ if (sigd > floatgap)
+ sigd = 1.0;
+ else if (sigd < -floatgap)
+ sigd = -1.0;
+ else
+ {
+ sigd = 0.0;
+ }
+ dPiE[0] = sigd * (Modulus_segT_x_vecP / segT.Modulus());
+ if (dPiE[0] <= floatgap && dPiE[0] >= -floatgap)
+ {
+ sEdge = 0;
+ is = 0;
+ tbreak = 1;
+ }
}
}
-
- if(tbreak==0) { //-- is = 1
- gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
- gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
- dPtPi[1]=vecP.Modulus();
- if (dPtPi[1]<=floatgap) {
- sVertex=1;
- is=1;
- tbreak=1;
+
+ if (tbreak == 0)
+ { //-- is = 1
+ gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()
+ - ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+ gp_XYZ vecP(spLieu - ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+ dPtPi[1] = vecP.Modulus();
+ if (dPtPi[1] <= floatgap)
+ {
+ sVertex = 1;
+ is = 1;
+ tbreak = 1;
}
- else {
- gp_XYZ segT_x_vecP(segT^vecP);
- Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
- }
- dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
- sEdge=1;
- is=1;
- tbreak=1;
- }
+ else
+ {
+ gp_XYZ segT_x_vecP(segT ^ vecP);
+ Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+ sigd = segT_x_vecP * triNor;
+ if (sigd > floatgap)
+ sigd = 1.0;
+ else if (sigd < -floatgap)
+ sigd = -1.0;
+ else
+ {
+ sigd = 0.0;
+ }
+ dPiE[1] = sigd * (Modulus_segT_x_vecP / segT.Modulus());
+ if (dPiE[1] <= floatgap && dPiE[1] >= -floatgap)
+ {
+ sEdge = 1;
+ is = 1;
+ tbreak = 1;
+ }
}
}
- if(tbreak==0) { //-- is = 2
- gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()-
- ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
- gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
- dPtPi[2]=vecP.Modulus();
- if (dPtPi[2]<=floatgap) {
- sVertex=2;
- is=2;
+ if (tbreak == 0)
+ { //-- is = 2
+ gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()
+ - ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+ gp_XYZ vecP(spLieu - ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+ dPtPi[2] = vecP.Modulus();
+ if (dPtPi[2] <= floatgap)
+ {
+ sVertex = 2;
+ is = 2;
}
- gp_XYZ segT_x_vecP(segT^vecP);
+ gp_XYZ segT_x_vecP(segT ^ vecP);
Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
- sigd = segT_x_vecP*triNor;
- if(sigd>floatgap)
- sigd = 1.0;
- else if(sigd<-floatgap)
- sigd = -1.0;
- else {
- sigd = 0.0;
+ sigd = segT_x_vecP * triNor;
+ if (sigd > floatgap)
+ sigd = 1.0;
+ else if (sigd < -floatgap)
+ sigd = -1.0;
+ else
+ {
+ sigd = 0.0;
}
- dPiE[2]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
- if (dPiE[2]<=floatgap && dPiE[2]>=-floatgap) {
- sEdge=2;
- is=2;
+ dPiE[2] = sigd * (Modulus_segT_x_vecP / segT.Modulus());
+ if (dPiE[2] <= floatgap && dPiE[2] >= -floatgap)
+ {
+ sEdge = 2;
+ is = 2;
}
}
//-- fin for i=0 to 2
// !!cout<<endl;
-
+
Standard_Integer triCon, pedg;
- if (sVertex>-1) {
- triCon=TTri;
- pedg=pTri[Pourcent3[sVertex+1]];
-//-- while (triCon!=0) {
-//-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
-//-- //-- if (triCon<TTri) return;
-//-- if (triCon==TTri) break;
-//-- }
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_VERTEX, pTri[is], 0, 0.,
- 1.);
+ if (sVertex > -1)
+ {
+ triCon = TTri;
+ pedg = pTri[Pourcent3[sVertex + 1]];
+ //-- while (triCon!=0) {
+ //-- ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
+ //-- //-- if (triCon<TTri) return;
+ //-- if (triCon==TTri) break;
+ //-- }
+ Intf_SectionPoint SP(spLieu, typOnG, 0, iLin, param, Intf_VERTEX, pTri[is], 0, 0., 1.);
mySPoins.Append(SP);
}
- else if (sEdge>-1) {
- ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge+1]],
- triCon, pedg);
- //-- if (triCon<=TTri) return; ???????????????????? LBR
+ else if (sEdge > -1)
+ {
+ ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge + 1]], triCon, pedg);
+ //-- if (triCon<=TTri) return; ???????????????????? LBR
// !!cout<<" sEdge "<<endl;
Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
- Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
- 1.);
+ typOnG,
+ 0,
+ iLin,
+ param,
+ Intf_EDGE,
+ Min(pTri[sEdge], pTri[Pourcent3[sEdge + 1]]),
+ Max(pTri[sEdge], pTri[Pourcent3[sEdge + 1]]),
+ 0.,
+ 1.);
mySPoins.Append(SP);
}
- else if (dPiE[0]>0. && dPiE[1]>0. && dPiE[2]>0.) {
+ else if (dPiE[0] > 0. && dPiE[1] > 0. && dPiE[2] > 0.)
+ {
// !!cout<<" 3 Positifs "<<endl;
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
+ Intf_SectionPoint SP(spLieu, typOnG, 0, iLin, param, Intf_FACE, TTri, 0, 0., 1.);
mySPoins.Append(SP);
}
-// Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
+ // Modified by Sergey KHROMOV - Fri Dec 7 14:40:11 2001 Begin
// Sometimes triangulation doesn't cover whole the face. In this
// case it is necessary to take into account the deflection between boundary
// isolines of the surface and boundary trianles. Computed value of this
// deflection is contained in thePolyh.
- else {
+ else
+ {
Standard_Integer i;
- for (i = 1; i <= 3; i++) {
- Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
- Standard_Integer indP2 = pTri[i - 1];
-
- if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
- // For boundary line it is necessary to check the border deflection.
- Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
- const gp_Pnt &BegP = ToolPolyh::Point(thePolyh, indP1);
- const gp_Pnt &EndP = ToolPolyh::Point(thePolyh, indP2);
- gp_Vec VecTri(BegP,EndP);
- gp_Dir DirTri(VecTri);
- gp_Lin LinTri(BegP,DirTri);
- gp_Pnt aPOnE(spLieu);
- Standard_Real aDist = LinTri.Distance(aPOnE);
-
- if (aDist <= Deflection) {
- gp_Vec aVLocPOnE(BegP, aPOnE);
- gp_Vec aVecDirTri(DirTri);
- Standard_Real aPar = aVLocPOnE*aVecDirTri;
- Standard_Real aMaxPar = VecTri.Magnitude();
-
- if (aPar >= 0 && aPar <= aMaxPar) {
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, param,
- Intf_FACE, TTri, 0, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
+ for (i = 1; i <= 3; i++)
+ {
+ Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
+ Standard_Integer indP2 = pTri[i - 1];
+
+ if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2))
+ {
+ // For boundary line it is necessary to check the border deflection.
+ Standard_Real Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
+ const gp_Pnt& BegP = ToolPolyh::Point(thePolyh, indP1);
+ const gp_Pnt& EndP = ToolPolyh::Point(thePolyh, indP2);
+ gp_Vec VecTri(BegP, EndP);
+ gp_Dir DirTri(VecTri);
+ gp_Lin LinTri(BegP, DirTri);
+ gp_Pnt aPOnE(spLieu);
+ Standard_Real aDist = LinTri.Distance(aPOnE);
+
+ if (aDist <= Deflection)
+ {
+ gp_Vec aVLocPOnE(BegP, aPOnE);
+ gp_Vec aVecDirTri(DirTri);
+ Standard_Real aPar = aVLocPOnE * aVecDirTri;
+ Standard_Real aMaxPar = VecTri.Magnitude();
+
+ if (aPar >= 0 && aPar <= aMaxPar)
+ {
+ Intf_SectionPoint SP(spLieu, typOnG, 0, iLin, param, Intf_FACE, TTri, 0, 0., 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
}
}
-// Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
+ // Modified by Sergey KHROMOV - Fri Dec 7 14:40:29 2001 End
} //---- if(NoIntersectionWithTriangle == Standard_False)
-
+
//---------------------------------------------------------------------------
- //-- On teste la distance entre les cotes du triangle et le polygone
- //--
+ //-- On teste la distance entre les cotes du triangle et le polygone
+ //--
//-- Si cette distance est inferieure a Tolerance, on cree un SP.
- //--
- //-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
-// if (Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
+ //--
+ //-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g
+ // Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
+ // if (Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
{
- gp_Vec VecPol(BegO,EndO);
+ gp_Vec VecPol(BegO, EndO);
Standard_Real NVecPol = VecPol.Magnitude();
- gp_Dir DirPol(VecPol);
- gp_Lin LinPol(BegO,DirPol);
- Standard_Real dist2,ParamOnO,ParamOnT;
-
- for (Standard_Integer i=0; i<3; i++) {
- Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i+1]];
+ gp_Dir DirPol(VecPol);
+ gp_Lin LinPol(BegO, DirPol);
+ Standard_Real dist2, ParamOnO, ParamOnT;
+
+ for (Standard_Integer i = 0; i < 3; i++)
+ {
+ Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i + 1]];
Standard_Integer pTri_i = pTri[i];
- const gp_Pnt& BegT = ToolPolyh::Point(thePolyh, pTri_ip1pc3);
- const gp_Pnt& EndT = ToolPolyh::Point(thePolyh, pTri_i);
- gp_Vec VecTri(BegT,EndT);
- Standard_Real NVecTri = VecTri.Magnitude();
- gp_Dir DirTri(VecTri);
- gp_Lin LinTri(BegT,DirTri);
- Extrema_ExtElC Extrema(LinPol,LinTri,0.00000001);
- if(Extrema.IsDone()) {
- if(Extrema.IsParallel() == Standard_False) {
- if(Extrema.NbExt()) {
- dist2 = Extrema.SquareDistance();
- if(dist2<=Tolerance * Tolerance) {
- Extrema_POnCurv POnC1,POnC2;
- Extrema.Points(1,POnC1,POnC2);
- const gp_Pnt& PO = POnC1.Value();
- const gp_Pnt& PT = POnC2.Value();
- //--cout<<" ** Nouveau "<<dist2<<endl;
- if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
- if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
- //-- cout<<" * "<<endl;
- gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
- Standard_Integer tmin,tmax;
- if(pTri_i>pTri_ip1pc3) {
- tmin=pTri_ip1pc3; tmax=pTri_i;
- }
- else {
- tmax=pTri_ip1pc3; tmin=pTri_i;
- }
- Intf_SectionPoint SP(spLieu,
- typOnG, 0, iLin, ParamOnO,
- Intf_EDGE,
- tmin,
- tmax, 0.,
- 1.);
- mySPoins.Append(SP);
- }
- }
- }
- }
- }
+ const gp_Pnt& BegT = ToolPolyh::Point(thePolyh, pTri_ip1pc3);
+ const gp_Pnt& EndT = ToolPolyh::Point(thePolyh, pTri_i);
+ gp_Vec VecTri(BegT, EndT);
+ Standard_Real NVecTri = VecTri.Magnitude();
+ gp_Dir DirTri(VecTri);
+ gp_Lin LinTri(BegT, DirTri);
+ Extrema_ExtElC Extrema(LinPol, LinTri, 0.00000001);
+ if (Extrema.IsDone())
+ {
+ if (Extrema.IsParallel() == Standard_False)
+ {
+ if (Extrema.NbExt())
+ {
+ dist2 = Extrema.SquareDistance();
+ if (dist2 <= Tolerance * Tolerance)
+ {
+ Extrema_POnCurv POnC1, POnC2;
+ Extrema.Points(1, POnC1, POnC2);
+ const gp_Pnt& PO = POnC1.Value();
+ const gp_Pnt& PT = POnC2.Value();
+ //--cout<<" ** Nouveau "<<dist2<<endl;
+ if (IsInSegment(VecPol, gp_Vec(BegO, PO), NVecPol, ParamOnO, Tolerance))
+ {
+ if (IsInSegment(VecTri, gp_Vec(BegT, PT), NVecTri, ParamOnT, Tolerance))
+ {
+ //-- cout<<" * "<<endl;
+ gp_XYZ spLieu = BegT.XYZ() + ((EndT.XYZ() - BegT.XYZ()) * param);
+ Standard_Integer tmin, tmax;
+ if (pTri_i > pTri_ip1pc3)
+ {
+ tmin = pTri_ip1pc3;
+ tmax = pTri_i;
+ }
+ else
+ {
+ tmax = pTri_ip1pc3;
+ tmin = pTri_i;
+ }
+ Intf_SectionPoint
+ SP(spLieu, typOnG, 0, iLin, ParamOnO, Intf_EDGE, tmin, tmax, 0., 1.);
+ mySPoins.Append(SP);
+ }
+ }
+ }
+ }
+ }
}
}
- }
+ }
}
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627
-
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <gp_Vec2d.hxx>
//=================================================================================================
-
-TopClass_Classifier2d::TopClass_Classifier2d() :
- myIsSet(Standard_False),
- myFirstCompare(Standard_True),
- myFirstTrans(Standard_True),
- myParam(0.0),
- myTolerance(0.0),
- myClosest(0),
- myState(TopAbs_UNKNOWN), // skv OCC12627
- myIsHeadOrEnd(Standard_False) // skv OCC12627
+TopClass_Classifier2d::TopClass_Classifier2d()
+ : myIsSet(Standard_False),
+ myFirstCompare(Standard_True),
+ myFirstTrans(Standard_True),
+ myParam(0.0),
+ myTolerance(0.0),
+ myClosest(0),
+ myState(TopAbs_UNKNOWN), // skv OCC12627
+ myIsHeadOrEnd(Standard_False) // skv OCC12627
{
}
//=================================================================================================
-
-void TopClass_Classifier2d::Reset(const gp_Lin2d& L,
- const Standard_Real P,
- const Standard_Real Tol)
+void TopClass_Classifier2d::Reset(const gp_Lin2d& L, const Standard_Real P, const Standard_Real Tol)
{
- myLin = L;
- myParam = P;
- myTolerance = Tol;
- myState = TopAbs_UNKNOWN;
+ myLin = L;
+ myParam = P;
+ myTolerance = Tol;
+ myState = TopAbs_UNKNOWN;
myFirstCompare = Standard_True;
- myFirstTrans = Standard_True;
- myClosest = 0;
- myIsSet = Standard_True;
-// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
+ myFirstTrans = Standard_True;
+ myClosest = 0;
+ myIsSet = Standard_True;
+ // Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
myIsHeadOrEnd = Standard_False;
-// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
+ // Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
}
//=================================================================================================
-
-void TopClass_Classifier2d::Compare(const TheEdge& E,
- const TopAbs_Orientation Or)
+void TopClass_Classifier2d::Compare(const TheEdge& E, const TopAbs_Orientation Or)
{
// intersect the edge and the segment
myClosest = 0;
- myIntersector.Perform(myLin,myParam,myTolerance,E);
- if (!myIntersector.IsDone()) return;
- if ((myIntersector.NbPoints() == 0)&&
- (myIntersector.NbSegments() == 0)) return;
+ myIntersector.Perform(myLin, myParam, myTolerance, E);
+ if (!myIntersector.IsDone())
+ return;
+ if ((myIntersector.NbPoints() == 0) && (myIntersector.NbSegments() == 0))
+ return;
// find the closest point
Standard_Integer iPoint, iSegment, nbPoints, nbSegments;
- const IntRes2d_IntersectionPoint *PClosest = NULL;
+ const IntRes2d_IntersectionPoint* PClosest = NULL;
Standard_Real dMin = RealLast();
- nbPoints = myIntersector.NbPoints();
- for (iPoint = 1; iPoint <= nbPoints; iPoint++) {
+ nbPoints = myIntersector.NbPoints();
+ for (iPoint = 1; iPoint <= nbPoints; iPoint++)
+ {
const IntRes2d_IntersectionPoint& PInter = myIntersector.Point(iPoint);
// test for ON
- if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head) {
+ if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head)
+ {
myClosest = iPoint;
- myState = TopAbs_ON;
+ myState = TopAbs_ON;
return;
}
Standard_Real paramfirst = PInter.ParamOnFirst();
- if (paramfirst < dMin) {
+ if (paramfirst < dMin)
+ {
myClosest = iPoint;
- PClosest = &PInter;
- dMin = paramfirst;
+ PClosest = &PInter;
+ dMin = paramfirst;
}
}
// for the segments we only test the first point
nbSegments = myIntersector.NbSegments();
- for (iSegment = 1; iSegment <= nbSegments; iSegment++) {
- const IntRes2d_IntersectionSegment& SegInter =
- myIntersector.Segment(iSegment);
- const IntRes2d_IntersectionPoint& PInter = SegInter.FirstPoint();
- if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head) {
- myClosest = nbPoints + iSegment+ iSegment - 1;
- myState = TopAbs_ON;
+ for (iSegment = 1; iSegment <= nbSegments; iSegment++)
+ {
+ const IntRes2d_IntersectionSegment& SegInter = myIntersector.Segment(iSegment);
+ const IntRes2d_IntersectionPoint& PInter = SegInter.FirstPoint();
+ if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head)
+ {
+ myClosest = nbPoints + iSegment + iSegment - 1;
+ myState = TopAbs_ON;
return;
}
Standard_Real paramfirst = PInter.ParamOnFirst();
- if (paramfirst < dMin) {
- myClosest = nbPoints + iSegment+iSegment - 1;
- PClosest = &PInter;
- dMin = paramfirst;
+ if (paramfirst < dMin)
+ {
+ myClosest = nbPoints + iSegment + iSegment - 1;
+ PClosest = &PInter;
+ dMin = paramfirst;
}
}
// if no point was found return
- if (myClosest == 0) return;
+ if (myClosest == 0)
+ return;
// if the Edge is INTERNAL or EXTERNAL, no problem
- if (Or == TopAbs_INTERNAL) {
+ if (Or == TopAbs_INTERNAL)
+ {
myState = TopAbs_IN;
return;
}
- else if (Or == TopAbs_EXTERNAL) {
+ else if (Or == TopAbs_EXTERNAL)
+ {
myState = TopAbs_OUT;
return;
}
-
- if ( ! myFirstCompare ) {
+ if (!myFirstCompare)
+ {
Standard_Boolean b = (dMin > myParam);
- if (b) {
+ if (b)
+ {
// dMin > myParam : le point le plus proche (dMin) trouve dans CETTE
// intersection ligne,arete n'est pas le plus proche
// de TOUS les points d'intersection avec les autres aretes (myParam).
return;
}
}
-
+
// process the closest point PClosest, found at dMin on line.
myFirstCompare = Standard_False;
- if(myParam > dMin) { //-- lbr le 13 mai 96
- myFirstTrans = Standard_True;
- }
-
- myParam = dMin;
+ if (myParam > dMin)
+ { //-- lbr le 13 mai 96
+ myFirstTrans = Standard_True;
+ }
+
+ myParam = dMin;
const IntRes2d_Transition& T2 = PClosest->TransitionOfSecond();
-// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
-// Standard_Boolean isHeadorEnd = (T2.PositionOnCurve() == IntRes2d_Head) ||
-// (T2.PositionOnCurve() == IntRes2d_End);
- myIsHeadOrEnd = (T2.PositionOnCurve() == IntRes2d_Head) ||
- (T2.PositionOnCurve() == IntRes2d_End);
-// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
-
+ // Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
+ // Standard_Boolean isHeadorEnd = (T2.PositionOnCurve() == IntRes2d_Head) ||
+ // (T2.PositionOnCurve() == IntRes2d_End);
+ myIsHeadOrEnd = (T2.PositionOnCurve() == IntRes2d_Head) || (T2.PositionOnCurve() == IntRes2d_End);
+ // Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
+
// transition on the segment
TopAbs_Orientation SegTrans = TopAbs_FORWARD;
const IntRes2d_Transition& T1 = PClosest->TransitionOfFirst();
- switch (T1.TransitionType()) {
- case IntRes2d_In :
- if (Or == TopAbs_REVERSED) SegTrans = TopAbs_REVERSED;
- else SegTrans = TopAbs_FORWARD;
- break;
- case IntRes2d_Out :
- if (Or == TopAbs_REVERSED) SegTrans = TopAbs_FORWARD;
- else SegTrans = TopAbs_REVERSED;
- break;
- case IntRes2d_Touch :
- switch (T1.Situation()) {
- case IntRes2d_Inside :
- if (Or == TopAbs_REVERSED) SegTrans = TopAbs_EXTERNAL;
- else SegTrans = TopAbs_INTERNAL;
+ switch (T1.TransitionType())
+ {
+ case IntRes2d_In:
+ if (Or == TopAbs_REVERSED)
+ SegTrans = TopAbs_REVERSED;
+ else
+ SegTrans = TopAbs_FORWARD;
break;
- case IntRes2d_Outside :
- if (Or == TopAbs_REVERSED) SegTrans = TopAbs_INTERNAL;
- else SegTrans = TopAbs_EXTERNAL;
+ case IntRes2d_Out:
+ if (Or == TopAbs_REVERSED)
+ SegTrans = TopAbs_FORWARD;
+ else
+ SegTrans = TopAbs_REVERSED;
break;
- case IntRes2d_Unknown : return;
- }
- break;
- case IntRes2d_Undecided : return;
+ case IntRes2d_Touch:
+ switch (T1.Situation())
+ {
+ case IntRes2d_Inside:
+ if (Or == TopAbs_REVERSED)
+ SegTrans = TopAbs_EXTERNAL;
+ else
+ SegTrans = TopAbs_INTERNAL;
+ break;
+ case IntRes2d_Outside:
+ if (Or == TopAbs_REVERSED)
+ SegTrans = TopAbs_INTERNAL;
+ else
+ SegTrans = TopAbs_EXTERNAL;
+ break;
+ case IntRes2d_Unknown:
+ return;
+ }
+ break;
+ case IntRes2d_Undecided:
+ return;
}
// are we inside the Edge ?
// const IntRes2d_Transition& T2 = PClosest->TransitionOfSecond();
- if ( ! myIsHeadOrEnd ) {
+ if (!myIsHeadOrEnd)
+ {
// PClosest is inside the edge
- switch (SegTrans) {
-
- case TopAbs_FORWARD :
- case TopAbs_EXTERNAL :
- myState = TopAbs_OUT;
- break;
-
- case TopAbs_REVERSED :
- case TopAbs_INTERNAL :
- myState = TopAbs_IN;
- break;
+ switch (SegTrans)
+ {
+
+ case TopAbs_FORWARD:
+ case TopAbs_EXTERNAL:
+ myState = TopAbs_OUT;
+ break;
+
+ case TopAbs_REVERSED:
+ case TopAbs_INTERNAL:
+ myState = TopAbs_IN;
+ break;
}
}
- else {
+ else
+ {
// PClosest is Head or End of the edge : update the complex transition
- gp_Dir2d Tang2d,Norm2d;
+ gp_Dir2d Tang2d, Norm2d;
Standard_Real Curv;
- myIntersector.LocalGeometry
- (E,PClosest->ParamOnSecond(),Tang2d,Norm2d,Curv);
- gp_Dir Tang(Tang2d.X(),Tang2d.Y(),0.);
- gp_Dir Norm(Norm2d.X(),Norm2d.Y(),0.);
- if (myFirstTrans) {
- gp_Dir D(myLin.Direction().X(),myLin.Direction().Y(),0.);
+ myIntersector.LocalGeometry(E, PClosest->ParamOnSecond(), Tang2d, Norm2d, Curv);
+ gp_Dir Tang(Tang2d.X(), Tang2d.Y(), 0.);
+ gp_Dir Norm(Norm2d.X(), Norm2d.Y(), 0.);
+ if (myFirstTrans)
+ {
+ gp_Dir D(myLin.Direction().X(), myLin.Direction().Y(), 0.);
myTrans.Reset(D);
myFirstTrans = Standard_False;
}
-
+
TopAbs_Orientation Ort;
- if (T2.PositionOnCurve() == IntRes2d_Head) Ort = TopAbs_FORWARD;
- else Ort = TopAbs_REVERSED;
- myTrans.Compare(RealEpsilon(), Tang, Norm, Curv, SegTrans, Ort);
+ if (T2.PositionOnCurve() == IntRes2d_Head)
+ Ort = TopAbs_FORWARD;
+ else
+ Ort = TopAbs_REVERSED;
+ myTrans.Compare(RealEpsilon(), Tang, Norm, Curv, SegTrans, Ort);
myState = myTrans.StateBefore();
}
}
//=================================================================================================
-
-TopClass_FaceClassifier::TopClass_FaceClassifier() :
-myEdgeParameter(0.0),
-rejected(Standard_False),
-nowires(Standard_True)
+TopClass_FaceClassifier::TopClass_FaceClassifier()
+ : myEdgeParameter(0.0),
+ rejected(Standard_False),
+ nowires(Standard_True)
{
}
//=================================================================================================
-
-TopClass_FaceClassifier::TopClass_FaceClassifier(TheFaceExplorer& FExp,
- const gp_Pnt2d& P,
- const Standard_Real Tol) :
-myEdgeParameter(0.0),
-rejected(Standard_False),
-nowires(Standard_True)
+TopClass_FaceClassifier::TopClass_FaceClassifier(TheFaceExplorer& FExp,
+ const gp_Pnt2d& P,
+ const Standard_Real Tol)
+ : myEdgeParameter(0.0),
+ rejected(Standard_False),
+ nowires(Standard_True)
{
- Perform(FExp,P,Tol);
+ Perform(FExp, P, Tol);
}
//=================================================================================================
-
-void TopClass_FaceClassifier::Perform(TheFaceExplorer& Fexp,
- const gp_Pnt2d& P,
- const Standard_Real Tol)
+void TopClass_FaceClassifier::Perform(TheFaceExplorer& Fexp,
+ const gp_Pnt2d& P,
+ const Standard_Real Tol)
{
- gp_Pnt2d aPoint(P);
+ gp_Pnt2d aPoint(P);
Standard_Boolean aResOfPointCheck = Standard_False;
while (aResOfPointCheck == Standard_False)
{
nowires = Standard_True;
- while (IsValidSegment) {
+ while (IsValidSegment)
+ {
myClassifier.Reset(aLine, aParam, Tol);
- for (Fexp.InitWires(); Fexp.MoreWires(); Fexp.NextWire()) {
+ for (Fexp.InitWires(); Fexp.MoreWires(); Fexp.NextWire())
+ {
nowires = Standard_False;
IsWReject = Fexp.RejectWire(aLine, myClassifier.Parameter());
- if (!IsWReject) {
- // test this wire
- for (Fexp.InitEdges(); Fexp.MoreEdges(); Fexp.NextEdge()) {
- IsEReject = Fexp.RejectEdge(aLine, myClassifier.Parameter());
-
- if (!IsEReject) {
- // test this edge
- Fexp.CurrentEdge(anEdge, anEdgeOri);
-
- if (anEdgeOri == TopAbs_FORWARD || anEdgeOri == TopAbs_REVERSED) {
- myClassifier.Compare(anEdge, anEdgeOri);
- aClosestInd = myClassifier.ClosestIntersection();
-
- if (aClosestInd != 0) {
- // save the closest edge
- TheIntersection2d &anIntersector = myClassifier.Intersector();
- Standard_Integer aNbPnts = anIntersector.NbPoints();
-
- myEdge = anEdge;
-
- if (aClosestInd <= aNbPnts) {
- aPInter = anIntersector.Point(aClosestInd);
- } else {
- aClosestInd -= aNbPnts;
-
- if (aClosestInd&1) {
- aPInter = anIntersector.
- Segment((aClosestInd + 1)/2).FirstPoint();
- } else {
- aPInter = anIntersector.
- Segment((aClosestInd + 1)/2).LastPoint();
- }
- }
-
- myPosition = aPInter.
- TransitionOfSecond().PositionOnCurve();
- myEdgeParameter = aPInter.ParamOnSecond();
- }
- // if we are ON, we stop
- aState = myClassifier.State();
-
- if (aState == TopAbs_ON)
- return;
- }
- }
- }
-
- // if we are out of the wire we stop
- aState = myClassifier.State();
-
- if (aState == TopAbs_OUT)
- return;
+ if (!IsWReject)
+ {
+ // test this wire
+ for (Fexp.InitEdges(); Fexp.MoreEdges(); Fexp.NextEdge())
+ {
+ IsEReject = Fexp.RejectEdge(aLine, myClassifier.Parameter());
+
+ if (!IsEReject)
+ {
+ // test this edge
+ Fexp.CurrentEdge(anEdge, anEdgeOri);
+
+ if (anEdgeOri == TopAbs_FORWARD || anEdgeOri == TopAbs_REVERSED)
+ {
+ myClassifier.Compare(anEdge, anEdgeOri);
+ aClosestInd = myClassifier.ClosestIntersection();
+
+ if (aClosestInd != 0)
+ {
+ // save the closest edge
+ TheIntersection2d& anIntersector = myClassifier.Intersector();
+ Standard_Integer aNbPnts = anIntersector.NbPoints();
+
+ myEdge = anEdge;
+
+ if (aClosestInd <= aNbPnts)
+ {
+ aPInter = anIntersector.Point(aClosestInd);
+ }
+ else
+ {
+ aClosestInd -= aNbPnts;
+
+ if (aClosestInd & 1)
+ {
+ aPInter = anIntersector.Segment((aClosestInd + 1) / 2).FirstPoint();
+ }
+ else
+ {
+ aPInter = anIntersector.Segment((aClosestInd + 1) / 2).LastPoint();
+ }
+ }
+
+ myPosition = aPInter.TransitionOfSecond().PositionOnCurve();
+ myEdgeParameter = aPInter.ParamOnSecond();
+ }
+ // if we are ON, we stop
+ aState = myClassifier.State();
+
+ if (aState == TopAbs_ON)
+ return;
+ }
+ }
+ }
+
+ // if we are out of the wire we stop
+ aState = myClassifier.State();
+
+ if (aState == TopAbs_OUT)
+ return;
}
}
//=================================================================================================
-
TopAbs_State TopClass_FaceClassifier::State() const
{
- if (rejected) return TopAbs_OUT;
- else if (nowires) return TopAbs_IN;
- else return myClassifier.State();
+ if (rejected)
+ return TopAbs_OUT;
+ else if (nowires)
+ return TopAbs_IN;
+ else
+ return myClassifier.State();
}
//=================================================================================================
-
const TheEdge& TopClass_FaceClassifier::Edge() const
{
- Standard_DomainError_Raise_if(rejected,
- "TopClass_FaceClassifier::Edge:rejected");
+ Standard_DomainError_Raise_if(rejected, "TopClass_FaceClassifier::Edge:rejected");
return myEdge;
}
-
//=================================================================================================
-
Standard_Real TopClass_FaceClassifier::EdgeParameter() const
{
- Standard_DomainError_Raise_if(rejected,
- "TopClass_FaceClassifier::EdgeParameter:rejected");
+ Standard_DomainError_Raise_if(rejected, "TopClass_FaceClassifier::EdgeParameter:rejected");
return myEdgeParameter;
}
-
//=================================================================================================
-
-TopBas_Interference::TopBas_Interference()
-{
-}
+TopBas_Interference::TopBas_Interference() {}
//=================================================================================================
-
-TopBas_Interference::TopBas_Interference(const TheSubShape& Inters,
- const TheShape& Bound,
- const TopAbs_Orientation Orient,
- const TopAbs_Orientation Trans,
- const TopAbs_Orientation BTrans) :
- myIntersection(Inters),
- myBoundary(Bound),
- myOrientation(Orient),
- myTransition(Trans),
- myBTransition(BTrans)
+TopBas_Interference::TopBas_Interference(const TheSubShape& Inters,
+ const TheShape& Bound,
+ const TopAbs_Orientation Orient,
+ const TopAbs_Orientation Trans,
+ const TopAbs_Orientation BTrans)
+ : myIntersection(Inters),
+ myBoundary(Bound),
+ myOrientation(Orient),
+ myTransition(Trans),
+ myBTransition(BTrans)
{
}
//=================================================================================================
-
MAT_TList::MAT_TList()
{
thecurrentindex = 0;
//=================================================================================================
-
void MAT_TList::First()
{
- thecurrentnode = thefirstnode;
+ thecurrentnode = thefirstnode;
thecurrentindex = 1;
}
//=================================================================================================
-
void MAT_TList::Last()
{
- thecurrentnode = thelastnode;
+ thecurrentnode = thelastnode;
thecurrentindex = thenumberofitems;
}
//=================================================================================================
-
void MAT_TList::Init(const Item& anitem)
{
First();
- while(More())
- {
- if(anitem == thecurrentnode->GetItem()) break;
- Next();
- }
+ while (More())
+ {
+ if (anitem == thecurrentnode->GetItem())
+ break;
+ Next();
+ }
}
//=================================================================================================
-
void MAT_TList::Next()
{
- if(!IsEmpty())
- {
- thecurrentnode = thecurrentnode->Next();
- thecurrentindex = (thecurrentindex % thenumberofitems) + 1;
- }
+ if (!IsEmpty())
+ {
+ thecurrentnode = thecurrentnode->Next();
+ thecurrentindex = (thecurrentindex % thenumberofitems) + 1;
+ }
}
//=================================================================================================
-
void MAT_TList::Previous()
{
- if(!IsEmpty())
- {
- thecurrentnode = thecurrentnode->Previous();
- thecurrentindex = ((thecurrentindex+thenumberofitems-2)%thenumberofitems)+1;
- }
+ if (!IsEmpty())
+ {
+ thecurrentnode = thecurrentnode->Previous();
+ thecurrentindex = ((thecurrentindex + thenumberofitems - 2) % thenumberofitems) + 1;
+ }
}
//=================================================================================================
-
Standard_Boolean MAT_TList::More() const
{
return (!thecurrentnode.IsNull());
//=================================================================================================
-
Item MAT_TList::Current() const
{
return thecurrentnode->GetItem();
//=================================================================================================
-
void MAT_TList::Current(const Item& anitem) const
{
thecurrentnode->SetItem(anitem);
//=================================================================================================
-
Item MAT_TList::FirstItem() const
{
return thefirstnode->GetItem();
//=================================================================================================
-
Item MAT_TList::LastItem() const
{
return thelastnode->GetItem();
//=================================================================================================
-
Item MAT_TList::PreviousItem() const
{
return thecurrentnode->Previous()->GetItem();
//=================================================================================================
-
Item MAT_TList::NextItem() const
{
return thecurrentnode->Next()->GetItem();
//=================================================================================================
-
-Item MAT_TList::Brackets (const Standard_Integer anindex)
+Item MAT_TList::Brackets(const Standard_Integer anindex)
{
- if(thecurrentindex > anindex)
+ if (thecurrentindex > anindex)
+ {
+ while (thecurrentindex != anindex)
{
- while(thecurrentindex != anindex)
- {
- thecurrentindex--;
- thecurrentnode = thecurrentnode->Previous();
- }
+ thecurrentindex--;
+ thecurrentnode = thecurrentnode->Previous();
}
- else if(thecurrentindex < anindex)
+ }
+ else if (thecurrentindex < anindex)
+ {
+ while (thecurrentindex != anindex)
{
- while(thecurrentindex != anindex)
- {
- thecurrentindex++;
- thecurrentnode = thecurrentnode->Next();
- }
+ thecurrentindex++;
+ thecurrentnode = thecurrentnode->Next();
}
+ }
return thecurrentnode->GetItem();
}
//=================================================================================================
-
void MAT_TList::Unlink()
{
Standard_Boolean previousisnull = thecurrentnode->Previous().IsNull();
- Standard_Boolean nextisnull = thecurrentnode->Next().IsNull();
+ Standard_Boolean nextisnull = thecurrentnode->Next().IsNull();
- if(thecurrentindex)
+ if (thecurrentindex)
{
- if(!nextisnull)
+ if (!nextisnull)
{
thecurrentnode->Next()->Previous(thecurrentnode->Previous());
}
thecurrentnode->Previous()->Next(thecurrentnode->Next());
}
- if(thecurrentindex == 1)
+ if (thecurrentindex == 1)
{
thefirstnode = thecurrentnode->Next();
}
- else if(thecurrentindex == thenumberofitems)
+ else if (thecurrentindex == thenumberofitems)
{
thelastnode = thecurrentnode->Previous();
}
//=================================================================================================
-
void MAT_TList::LinkBefore(const Item& anitem)
{
thenumberofitems++;
- if(thecurrentindex)thecurrentindex++;
+ if (thecurrentindex)
+ thecurrentindex++;
Handle(MAT_TListNode) previous;
Handle(MAT_TListNode) node = new MAT_TListNode(anitem);
- if(!(thecurrentnode->Previous()).IsNull())
- {
- previous = thecurrentnode->Previous();
- previous->Next(node);
- node->Previous(previous);
- }
+ if (!(thecurrentnode->Previous()).IsNull())
+ {
+ previous = thecurrentnode->Previous();
+ previous->Next(node);
+ node->Previous(previous);
+ }
- if(thecurrentindex == 2)
- {
- thefirstnode = node;
- }
+ if (thecurrentindex == 2)
+ {
+ thefirstnode = node;
+ }
thecurrentnode->Previous(node);
node->Next(thecurrentnode);
//=================================================================================================
-
void MAT_TList::LinkAfter(const Item& anitem)
{
thenumberofitems++;
Handle(MAT_TListNode) node = new MAT_TListNode(anitem);
- if(!(thecurrentnode->Next()).IsNull())
- {
- next = thecurrentnode->Next();
- next->Previous(node);
- node->Next(next);
- }
+ if (!(thecurrentnode->Next()).IsNull())
+ {
+ next = thecurrentnode->Next();
+ next->Previous(node);
+ node->Next(next);
+ }
- if(thecurrentindex+1 ==thenumberofitems)
- {
- thelastnode = node;
- }
+ if (thecurrentindex + 1 == thenumberofitems)
+ {
+ thelastnode = node;
+ }
thecurrentnode->Next(node);
node->Previous(thecurrentnode);
//=================================================================================================
-
void MAT_TList::FrontAdd(const Item& anitem)
{
thenumberofitems++;
- if(thecurrentindex)thecurrentindex++;
+ if (thecurrentindex)
+ thecurrentindex++;
Handle(MAT_TListNode) node = new MAT_TListNode(anitem);
- if(!thefirstnode.IsNull())
- {
- thefirstnode->Previous(node);
- node->Next(thefirstnode);
- }
+ if (!thefirstnode.IsNull())
+ {
+ thefirstnode->Previous(node);
+ node->Next(thefirstnode);
+ }
else
- {
- thelastnode = node;
- }
+ {
+ thelastnode = node;
+ }
thefirstnode = node;
}
//=================================================================================================
-
void MAT_TList::BackAdd(const Item& anitem)
{
thenumberofitems++;
Handle(MAT_TListNode) node = new MAT_TListNode(anitem);
- if(!thelastnode.IsNull())
- {
- thelastnode->Next(node);
- node->Previous(thelastnode);
- }
+ if (!thelastnode.IsNull())
+ {
+ thelastnode->Next(node);
+ node->Previous(thelastnode);
+ }
else
- {
- thefirstnode = node;
- }
+ {
+ thefirstnode = node;
+ }
thelastnode = node;
}
//=================================================================================================
-
void MAT_TList::Permute()
{
Handle(MAT_TListNode) previous = thecurrentnode->Previous();
Handle(MAT_TListNode) nextnext = next->Next();
Handle(MAT_TListNode) null;
- if(!previous.IsNull())
- {
- previous->Next(next);
- next->Previous(previous);
- }
+ if (!previous.IsNull())
+ {
+ previous->Next(next);
+ next->Previous(previous);
+ }
else
- {
- next->Previous(null);
- }
+ {
+ next->Previous(null);
+ }
next->Next(current);
current->Previous(next);
- if(!nextnext.IsNull())
- {
- current->Next(nextnext);
- nextnext->Previous(current);
- }
+ if (!nextnext.IsNull())
+ {
+ current->Next(nextnext);
+ nextnext->Previous(current);
+ }
else
- {
- current->Next(null);
- }
- if(thefirstnode == current) thefirstnode = next;
- if(thelastnode == next) thelastnode = current;
+ {
+ current->Next(null);
+ }
+ if (thefirstnode == current)
+ thefirstnode = next;
+ if (thelastnode == next)
+ thelastnode = current;
thecurrentindex++;
}
//=================================================================================================
-
void MAT_TList::Loop() const
{
thelastnode->Next(thefirstnode);
//=================================================================================================
-
-void MAT_TList::Dump(const Standard_Integer ashift,
- const Standard_Integer alevel)
+void MAT_TList::Dump(const Standard_Integer ashift, const Standard_Integer alevel)
{
- for(First(); More(); Next()) Current()->Dump(ashift,alevel);
+ for (First(); More(); Next())
+ Current()->Dump(ashift, alevel);
}
//=======================================================================
-//function : ~MAT_TList
-//purpose :
+// function : ~MAT_TList
+// purpose :
//=======================================================================
MAT_TList::~MAT_TList()
while (!aNode.IsNull())
{
Handle(MAT_TListNode) aNext = aNode->Next();
- aNode->Next (NULL);
- aNode->Previous (NULL);
+ aNode->Next(NULL);
+ aNode->Previous(NULL);
aNode = aNext;
}
thecurrentnode.Nullify();
//=================================================================================================
-
-void MAT_TListNode::Dummy()const {}
+void MAT_TListNode::Dummy() const {}
#include <LProp_NotDefined.hxx>
#include <Standard_OutOfRange.hxx>
-static const Standard_Real MinStep = 1.0e-7;
-
-
-
-LProp_CLProps::LProp_CLProps (const Curve& C,
- const Standard_Real U,
- const Standard_Integer N,
- const Standard_Real Resolution)
- : myCurve(C), myDerOrder(N), myCN(4),
- myLinTol(Resolution), myTangentStatus (LProp_Undecided)
+static const Standard_Real MinStep = 1.0e-7;
+
+LProp_CLProps::LProp_CLProps(const Curve& C,
+ const Standard_Real U,
+ const Standard_Integer N,
+ const Standard_Real Resolution)
+ : myCurve(C),
+ myDerOrder(N),
+ myCN(4),
+ myLinTol(Resolution),
+ myTangentStatus(LProp_Undecided)
{
- Standard_OutOfRange_Raise_if (N < 0 || N > 3,
- "LProp_CLProps::LProp_CLProps()");
+ Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp_CLProps::LProp_CLProps()");
SetParameter(U);
}
-LProp_CLProps::LProp_CLProps (const Curve& C, const Standard_Integer N,
- const Standard_Real Resolution)
- : myCurve(C), myU(RealLast()), myDerOrder(N), myCN(4),
- myLinTol(Resolution), myTangentStatus (LProp_Undecided)
+LProp_CLProps::LProp_CLProps(const Curve& C,
+ const Standard_Integer N,
+ const Standard_Real Resolution)
+ : myCurve(C),
+ myU(RealLast()),
+ myDerOrder(N),
+ myCN(4),
+ myLinTol(Resolution),
+ myTangentStatus(LProp_Undecided)
{
- Standard_OutOfRange_Raise_if (N < 0 || N > 3,
- "LProp_CLProps::LProp_CLProps()");
+ Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp_CLProps::LProp_CLProps()");
}
-LProp_CLProps::LProp_CLProps (const Standard_Integer N,
- const Standard_Real Resolution)
- : myU(RealLast()), myDerOrder(N), myCN(0), myLinTol(Resolution),
- myTangentStatus (LProp_Undecided)
+LProp_CLProps::LProp_CLProps(const Standard_Integer N, const Standard_Real Resolution)
+ : myU(RealLast()),
+ myDerOrder(N),
+ myCN(0),
+ myLinTol(Resolution),
+ myTangentStatus(LProp_Undecided)
{
- Standard_OutOfRange_Raise_if (N < 0 || N > 3, "LProp_CLProps() - invalid input");
+ Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp_CLProps() - invalid input");
}
void LProp_CLProps::SetParameter(const Standard_Real U)
myU = U;
switch (myDerOrder)
{
- case 0:
- Tool::Value(myCurve, myU, myPnt);
- break;
- case 1:
- Tool::D1(myCurve, myU, myPnt, myDerivArr[0]);
- break;
- case 2:
- Tool::D2(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1]);
- break;
- case 3:
- Tool::D3(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1], myDerivArr[2]);
- break;
+ case 0:
+ Tool::Value(myCurve, myU, myPnt);
+ break;
+ case 1:
+ Tool::D1(myCurve, myU, myPnt, myDerivArr[0]);
+ break;
+ case 2:
+ Tool::D2(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1]);
+ break;
+ case 3:
+ Tool::D3(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1], myDerivArr[2]);
+ break;
}
myTangentStatus = LProp_Undecided;
void LProp_CLProps::SetCurve(const Curve& C)
{
- myCurve = C ;
- myCN = 4; // Tool::Continuity(C); RLE
+ myCurve = C;
+ myCN = 4; // Tool::Continuity(C); RLE
}
-const Pnt& LProp_CLProps::Value () const
+const Pnt& LProp_CLProps::Value() const
{
return myPnt;
}
-const Vec& LProp_CLProps::D1 ()
+const Vec& LProp_CLProps::D1()
{
if (myDerOrder < 1)
{
return myDerivArr[0];
}
-const Vec& LProp_CLProps::D2 ()
+const Vec& LProp_CLProps::D2()
{
if (myDerOrder < 2)
{
return myDerivArr[1];
}
-const Vec& LProp_CLProps::D3 ()
+const Vec& LProp_CLProps::D3()
{
if (myDerOrder < 3)
{
return myDerivArr[2];
}
-Standard_Boolean LProp_CLProps::IsTangentDefined ()
+Standard_Boolean LProp_CLProps::IsTangentDefined()
{
if (myTangentStatus == LProp_Undefined)
return Standard_False;
else if (myTangentStatus >= LProp_Defined)
return Standard_True;
- // tangentStatus == Lprop_Undecided
+ // tangentStatus == Lprop_Undecided
// we have to calculate the first non null derivative
const Standard_Real Tol = myLinTol * myLinTol;
-
+
Vec V;
-
+
Standard_Integer Order = 0;
while (Order++ < 4)
{
- if(myCN >= Order)
+ if (myCN >= Order)
{
- switch(Order)
+ switch (Order)
{
- case 1:
- V = D1();
- break;
- case 2:
- V = D2();
- break;
- case 3:
- V = D3();
- break;
- }//switch(Order)
-
- if(V.SquareMagnitude() > Tol)
+ case 1:
+ V = D1();
+ break;
+ case 2:
+ V = D2();
+ break;
+ case 3:
+ V = D3();
+ break;
+ } // switch(Order)
+
+ if (V.SquareMagnitude() > Tol)
{
mySignificantFirstDerivativeOrder = Order;
- myTangentStatus = LProp_Defined;
+ myTangentStatus = LProp_Defined;
return Standard_True;
- }//if(V.SquareMagnitude() > Tol)
- }//if(cn >= Order)
+ } // if(V.SquareMagnitude() > Tol)
+ } // if(cn >= Order)
else
{
myTangentStatus = LProp_Undefined;
return Standard_False;
- }// else of "if(cn >= Order)" condition
- }//while (Order < 4)
+ } // else of "if(cn >= Order)" condition
+ } // while (Order < 4)
return Standard_False;
}
-void LProp_CLProps::Tangent (Dir& D)
+void LProp_CLProps::Tangent(Dir& D)
{
- if(!IsTangentDefined())
+ if (!IsTangentDefined())
throw LProp_NotDefined();
-
- if(mySignificantFirstDerivativeOrder == 1)
+
+ if (mySignificantFirstDerivativeOrder == 1)
D = Dir(myDerivArr[0]);
else if (mySignificantFirstDerivativeOrder > 1)
{
const Standard_Real DivisionFactor = 1.e-3;
- const Standard_Real anUsupremum = Tool::LastParameter(myCurve),
- anUinfium = Tool::FirstParameter(myCurve);
-
+ const Standard_Real anUsupremum = Tool::LastParameter(myCurve),
+ anUinfium = Tool::FirstParameter(myCurve);
+
Standard_Real du;
- if((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
+ if ((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
du = 0.0;
else
- du = anUsupremum-anUinfium;
-
- const Standard_Real aDelta = Max(du*DivisionFactor,MinStep);
+ du = anUsupremum - anUinfium;
+
+ const Standard_Real aDelta = Max(du * DivisionFactor, MinStep);
Vec V = myDerivArr[mySignificantFirstDerivativeOrder - 1];
-
+
Standard_Real u;
-
- if(myU-anUinfium < aDelta)
- u = myU+aDelta;
+
+ if (myU - anUinfium < aDelta)
+ u = myU + aDelta;
else
- u = myU-aDelta;
-
+ u = myU - aDelta;
+
Pnt P1, P2;
- Tool::Value(myCurve, Min(myU, u),P1);
- Tool::Value(myCurve, Max(myU, u),P2);
-
- Vec V1(P1,P2);
+ Tool::Value(myCurve, Min(myU, u), P1);
+ Tool::Value(myCurve, Max(myU, u), P2);
+
+ Vec V1(P1, P2);
Standard_Real aDirFactor = V.Dot(V1);
-
- if(aDirFactor < 0.0)
+
+ if (aDirFactor < 0.0)
V = -V;
-
+
D = Dir(V);
- }//else if (mySignificantFirstDerivativeOrder > 1)
+ } // else if (mySignificantFirstDerivativeOrder > 1)
}
-Standard_Real LProp_CLProps::Curvature ()
+Standard_Real LProp_CLProps::Curvature()
{
Standard_Boolean isDefined = IsTangentDefined();
- (void)isDefined; // trick to avoid compiler warning on variable unised in Release mode; note that IsTangentDefined() must be called always
- LProp_NotDefined_Raise_if(!isDefined,
- "LProp_CLProps::CurvatureNotDefined()");
+ (void)isDefined; // trick to avoid compiler warning on variable unised in Release mode; note that
+ // IsTangentDefined() must be called always
+ LProp_NotDefined_Raise_if(!isDefined, "LProp_CLProps::CurvatureNotDefined()");
// if the first derivative is null the curvature is infinite.
- if(mySignificantFirstDerivativeOrder > 1)
+ if (mySignificantFirstDerivativeOrder > 1)
return RealLast();
Standard_Real Tol = myLinTol * myLinTol;
Standard_Real DD1 = myDerivArr[0].SquareMagnitude();
Standard_Real DD2 = myDerivArr[1].SquareMagnitude();
-
+
// if the second derivative is null the curvature is null.
if (DD2 <= Tol)
{
{
Standard_Real N = myDerivArr[0].CrossSquareMagnitude(myDerivArr[1]);
// if d[0] and d[1] are colinear the curvature is null.
- //Standard_Real t = N/(DD1*DD2);
+ // Standard_Real t = N/(DD1*DD2);
Standard_Real t = N / DD1 / DD2;
- if (t<=Tol)
+ if (t <= Tol)
{
myCurvature = 0.0;
}
return myCurvature;
}
-void LProp_CLProps::Normal (Dir& D)
+void LProp_CLProps::Normal(Dir& D)
{
Standard_Real c = Curvature();
- if(c==RealLast() || Abs(c) <= myLinTol)
+ if (c == RealLast() || Abs(c) <= myLinTol)
{
throw LProp_NotDefined("LProp_CLProps::Normal(...):"
- "Curvature is null or infinity");
+ "Curvature is null or infinity");
}
- // we used here the following vector relation
+ // we used here the following vector relation
// a ^ (b ^ c) = b(ac) - c(ab)
// Norm = d[0] ^ (d[1] ^ d[0])
-
- Vec Norm = myDerivArr[1] * (myDerivArr[0] * myDerivArr[0]) - myDerivArr[0] * (myDerivArr[0] * myDerivArr[1]);
+
+ Vec Norm = myDerivArr[1] * (myDerivArr[0] * myDerivArr[0])
+ - myDerivArr[0] * (myDerivArr[0] * myDerivArr[1]);
D = Dir(Norm);
}
-void LProp_CLProps::CentreOfCurvature (Pnt& P)
+void LProp_CLProps::CentreOfCurvature(Pnt& P)
{
- if(Abs(Curvature()) <= myLinTol)
+ if (Abs(Curvature()) <= myLinTol)
{
throw LProp_NotDefined();
}
- // we used here the following vector relation
+ // we used here the following vector relation
// a ^ (b ^ c) = b(ac) - c(ab)
// Norm = d[0] ^ (d[1] ^ d[0])
- Vec Norm = myDerivArr[1] * (myDerivArr[0] * myDerivArr[0]) - myDerivArr[0] * (myDerivArr[0] * myDerivArr[1]);
+ Vec Norm = myDerivArr[1] * (myDerivArr[0] * myDerivArr[0])
+ - myDerivArr[0] * (myDerivArr[0] * myDerivArr[1]);
Norm.Normalize();
Norm.Divide(myCurvature);
- P= myPnt.Translated(Norm);
+ P = myPnt.Translated(Norm);
}
#include <TColgp_Array2OfVec.hxx>
#include <math_DirectPolynomialRoots.hxx>
-static const Standard_Real MinStep = 1.0e-7;
-
-static Standard_Boolean IsTangentDefined (LProp_SLProps& SProp,
- const Standard_Integer cn,
- const Standard_Real linTol,
- const Standard_Integer Derivative,
- Standard_Integer& Order,
- LProp_Status& theStatus)
+static const Standard_Real MinStep = 1.0e-7;
+
+static Standard_Boolean IsTangentDefined(LProp_SLProps& SProp,
+ const Standard_Integer cn,
+ const Standard_Real linTol,
+ const Standard_Integer Derivative,
+ Standard_Integer& Order,
+ LProp_Status& theStatus)
{
Standard_Real Tol = linTol * linTol;
- gp_Vec V[2];
+ gp_Vec V[2];
Order = 0;
while (Order < 3)
{
Order++;
- if(cn >= Order)
+ if (cn >= Order)
{
- switch(Order)
+ switch (Order)
{
- case 1:
- V[0] = SProp.D1U();
- V[1] = SProp.D1V();
- break;
- case 2:
- V[0] = SProp.D2U();
- V[1] = SProp.D2V();
- break;
- }//switch(Order)
-
- if(V[Derivative].SquareMagnitude() > Tol)
+ case 1:
+ V[0] = SProp.D1U();
+ V[1] = SProp.D1V();
+ break;
+ case 2:
+ V[0] = SProp.D2U();
+ V[1] = SProp.D2V();
+ break;
+ } // switch(Order)
+
+ if (V[Derivative].SquareMagnitude() > Tol)
{
theStatus = LProp_Defined;
return Standard_True;
}
- }//if(cn >= Order)
+ } // if(cn >= Order)
else
{
theStatus = LProp_Undefined;
return Standard_False;
}
-LProp_SLProps::LProp_SLProps (const Surface& S,
- const Standard_Real U,
- const Standard_Real V,
- const Standard_Integer N,
- const Standard_Real Resolution)
- : mySurf(S),myDerOrder(N), myCN(4), // (Tool::Continuity(S)),
- myLinTol(Resolution)
+LProp_SLProps::LProp_SLProps(const Surface& S,
+ const Standard_Real U,
+ const Standard_Real V,
+ const Standard_Integer N,
+ const Standard_Real Resolution)
+ : mySurf(S),
+ myDerOrder(N),
+ myCN(4), // (Tool::Continuity(S)),
+ myLinTol(Resolution)
{
- Standard_OutOfRange_Raise_if(N < 0 || N > 2,
- "LProp_SLProps::LProp_SLProps()");
+ Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp_SLProps::LProp_SLProps()");
SetParameters(U, V);
}
-LProp_SLProps::LProp_SLProps (const Surface& S,
- const Standard_Integer N,
- const Standard_Real Resolution)
- : mySurf(S), myU(RealLast()), myV(RealLast()), myDerOrder(N),
- myCN(4), // (Tool::Continuity(S))
- myLinTol(Resolution),
- myUTangentStatus (LProp_Undecided),
- myVTangentStatus (LProp_Undecided),
- myNormalStatus (LProp_Undecided),
- myCurvatureStatus(LProp_Undecided)
+LProp_SLProps::LProp_SLProps(const Surface& S,
+ const Standard_Integer N,
+ const Standard_Real Resolution)
+ : mySurf(S),
+ myU(RealLast()),
+ myV(RealLast()),
+ myDerOrder(N),
+ myCN(4), // (Tool::Continuity(S))
+ myLinTol(Resolution),
+ myUTangentStatus(LProp_Undecided),
+ myVTangentStatus(LProp_Undecided),
+ myNormalStatus(LProp_Undecided),
+ myCurvatureStatus(LProp_Undecided)
{
- Standard_OutOfRange_Raise_if(N < 0 || N > 2,
- "LProp_SLProps::LProp_SLProps()");
+ Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp_SLProps::LProp_SLProps()");
}
-LProp_SLProps::LProp_SLProps (const Standard_Integer N,
- const Standard_Real Resolution)
- : myU(RealLast()), myV(RealLast()), myDerOrder(N), myCN(0),
- myLinTol(Resolution),
- myUTangentStatus (LProp_Undecided),
- myVTangentStatus (LProp_Undecided),
- myNormalStatus (LProp_Undecided),
- myCurvatureStatus(LProp_Undecided)
+LProp_SLProps::LProp_SLProps(const Standard_Integer N, const Standard_Real Resolution)
+ : myU(RealLast()),
+ myV(RealLast()),
+ myDerOrder(N),
+ myCN(0),
+ myLinTol(Resolution),
+ myUTangentStatus(LProp_Undecided),
+ myVTangentStatus(LProp_Undecided),
+ myNormalStatus(LProp_Undecided),
+ myCurvatureStatus(LProp_Undecided)
{
- Standard_OutOfRange_Raise_if(N < 0 || N > 2,
- "LProp_SLProps::LProp_SLProps() bad level");
+ Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp_SLProps::LProp_SLProps() bad level");
}
-void LProp_SLProps::SetSurface (const Surface& S )
+void LProp_SLProps::SetSurface(const Surface& S)
{
mySurf = S;
- myCN = 4; // =Tool::Continuity(S);
+ myCN = 4; // =Tool::Continuity(S);
}
-void LProp_SLProps::SetParameters (const Standard_Real U,
- const Standard_Real V)
+void LProp_SLProps::SetParameters(const Standard_Real U, const Standard_Real V)
{
myU = U;
myV = V;
switch (myDerOrder)
{
- case 0:
- Tool::Value(mySurf, myU, myV, myPnt);
- break;
- case 1:
- Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
- break;
- case 2:
- Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
- break;
+ case 0:
+ Tool::Value(mySurf, myU, myV, myPnt);
+ break;
+ case 1:
+ Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
+ break;
+ case 2:
+ Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
+ break;
}
myUTangentStatus = LProp_Undecided;
{
if (myDerOrder < 1)
{
- myDerOrder =1;
- Tool::D1(mySurf,myU,myV,myPnt,myD1u,myD1v);
+ myDerOrder = 1;
+ Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
}
return myD1u;
{
if (myDerOrder < 1)
{
- myDerOrder =1;
- Tool::D1(mySurf,myU,myV,myPnt,myD1u,myD1v);
+ myDerOrder = 1;
+ Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
}
return myD1v;
const gp_Vec& LProp_SLProps::D2U()
{
- if (myDerOrder < 2)
+ if (myDerOrder < 2)
{
- myDerOrder =2;
- Tool::D2(mySurf,myU,myV,myPnt,myD1u,myD1v,myD2u,myD2v,myDuv);
+ myDerOrder = 2;
+ Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
}
return myD2u;
const gp_Vec& LProp_SLProps::D2V()
{
- if (myDerOrder < 2)
+ if (myDerOrder < 2)
{
- myDerOrder =2;
- Tool::D2(mySurf,myU,myV,myPnt,myD1u,myD1v,myD2u,myD2v,myDuv);
+ myDerOrder = 2;
+ Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
}
return myD2v;
const gp_Vec& LProp_SLProps::DUV()
{
- if (myDerOrder < 2)
+ if (myDerOrder < 2)
{
- myDerOrder =2;
- Tool::D2(mySurf,myU,myV,myPnt,myD1u,myD1v,myD2u,myD2v,myDuv);
+ myDerOrder = 2;
+ Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
}
return myDuv;
}
-Standard_Boolean LProp_SLProps::IsTangentUDefined ()
+Standard_Boolean LProp_SLProps::IsTangentUDefined()
{
if (myUTangentStatus == LProp_Undefined)
return Standard_False;
else if (myUTangentStatus >= LProp_Defined)
- return Standard_True;
+ return Standard_True;
- // uTangentStatus == Lprop_Undecided
+ // uTangentStatus == Lprop_Undecided
// we have to calculate the first non null U derivative
- return IsTangentDefined(*this, myCN, myLinTol, 0,
- mySignificantFirstDerivativeOrderU, myUTangentStatus);
+ return IsTangentDefined(*this,
+ myCN,
+ myLinTol,
+ 0,
+ mySignificantFirstDerivativeOrderU,
+ myUTangentStatus);
}
-void LProp_SLProps::TangentU (gp_Dir& D)
+void LProp_SLProps::TangentU(gp_Dir& D)
{
- if(!IsTangentUDefined())
+ if (!IsTangentUDefined())
throw LProp_NotDefined();
- if(mySignificantFirstDerivativeOrderU == 1)
+ if (mySignificantFirstDerivativeOrderU == 1)
D = gp_Dir(myD1u);
else
{
const Standard_Real DivisionFactor = 1.e-3;
- Standard_Real anUsupremum, anUinfium;
- Standard_Real anVsupremum, anVinfium;
- Tool::Bounds(mySurf,anUinfium,anVinfium,anUsupremum,anVsupremum);
+ Standard_Real anUsupremum, anUinfium;
+ Standard_Real anVsupremum, anVinfium;
+ Tool::Bounds(mySurf, anUinfium, anVinfium, anUsupremum, anVsupremum);
Standard_Real du;
- if((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
+ if ((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
du = 0.0;
else
- du = anUsupremum-anUinfium;
-
- const Standard_Real aDeltaU = Max(du*DivisionFactor,MinStep);
+ du = anUsupremum - anUinfium;
+
+ const Standard_Real aDeltaU = Max(du * DivisionFactor, MinStep);
gp_Vec V = myD2u;
-
+
Standard_Real u;
-
- if(myU-anUinfium < aDeltaU)
- u = myU+aDeltaU;
+
+ if (myU - anUinfium < aDeltaU)
+ u = myU + aDeltaU;
else
- u = myU-aDeltaU;
-
+ u = myU - aDeltaU;
+
gp_Pnt P1, P2;
- Tool::Value(mySurf, Min(myU, u),myV,P1);
- Tool::Value(mySurf, Max(myU, u),myV,P2);
-
- gp_Vec V1(P1,P2);
+ Tool::Value(mySurf, Min(myU, u), myV, P1);
+ Tool::Value(mySurf, Max(myU, u), myV, P2);
+
+ gp_Vec V1(P1, P2);
Standard_Real aDirFactor = V.Dot(V1);
-
- if(aDirFactor < 0.0)
+
+ if (aDirFactor < 0.0)
V = -V;
-
+
D = gp_Dir(V);
}
}
-Standard_Boolean LProp_SLProps::IsTangentVDefined ()
+Standard_Boolean LProp_SLProps::IsTangentVDefined()
{
if (myVTangentStatus == LProp_Undefined)
return Standard_False;
else if (myVTangentStatus >= LProp_Defined)
- return Standard_True;
+ return Standard_True;
- // vTangentStatus == Lprop_Undecided
+ // vTangentStatus == Lprop_Undecided
// we have to calculate the first non null V derivative
- return IsTangentDefined(*this, myCN, myLinTol, 1,
- mySignificantFirstDerivativeOrderV, myVTangentStatus);
+ return IsTangentDefined(*this,
+ myCN,
+ myLinTol,
+ 1,
+ mySignificantFirstDerivativeOrderV,
+ myVTangentStatus);
}
-void LProp_SLProps::TangentV (gp_Dir& D)
+void LProp_SLProps::TangentV(gp_Dir& D)
{
- if(!IsTangentVDefined())
+ if (!IsTangentVDefined())
throw LProp_NotDefined();
-
- if(mySignificantFirstDerivativeOrderV == 1)
+
+ if (mySignificantFirstDerivativeOrderV == 1)
D = gp_Dir(myD1v);
else
{
const Standard_Real DivisionFactor = 1.e-3;
- Standard_Real anUsupremum, anUinfium;
- Standard_Real anVsupremum, anVinfium;
- Tool::Bounds(mySurf,anUinfium,anVinfium,anUsupremum,anVsupremum);
-
+ Standard_Real anUsupremum, anUinfium;
+ Standard_Real anVsupremum, anVinfium;
+ Tool::Bounds(mySurf, anUinfium, anVinfium, anUsupremum, anVsupremum);
+
Standard_Real dv;
- if((anVsupremum >= RealLast()) || (anVinfium <= RealFirst()))
+ if ((anVsupremum >= RealLast()) || (anVinfium <= RealFirst()))
dv = 0.0;
else
- dv = anVsupremum-anVinfium;
-
- const Standard_Real aDeltaV = Max(dv*DivisionFactor,MinStep);
+ dv = anVsupremum - anVinfium;
+
+ const Standard_Real aDeltaV = Max(dv * DivisionFactor, MinStep);
gp_Vec V = myD2v;
-
+
Standard_Real v;
-
- if(myV-anVinfium < aDeltaV)
- v = myV+aDeltaV;
+
+ if (myV - anVinfium < aDeltaV)
+ v = myV + aDeltaV;
else
- v = myV-aDeltaV;
-
+ v = myV - aDeltaV;
+
gp_Pnt P1, P2;
- Tool::Value(mySurf, myU, Min(myV, v),P1);
- Tool::Value(mySurf, myU, Max(myV, v),P2);
-
- gp_Vec V1(P1,P2);
+ Tool::Value(mySurf, myU, Min(myV, v), P1);
+ Tool::Value(mySurf, myU, Max(myV, v), P2);
+
+ gp_Vec V1(P1, P2);
Standard_Real aDirFactor = V.Dot(V1);
-
- if(aDirFactor < 0.0)
+
+ if (aDirFactor < 0.0)
V = -V;
-
+
D = gp_Dir(V);
}
}
else if (myNormalStatus >= LProp_Defined)
return Standard_True;
- // status = UnDecided
+ // status = UnDecided
// first try the standard computation of the normal.
CSLib_DerivativeStatus aStatus = CSLib_Done;
CSLib::Normal(myD1u, myD1v, myLinTol, aStatus, myNormal);
return Standard_False;
}
-const gp_Dir& LProp_SLProps::Normal ()
+const gp_Dir& LProp_SLProps::Normal()
{
- if(!IsNormalDefined())
+ if (!IsNormalDefined())
{
throw LProp_NotDefined();
}
return myNormal;
}
-
-Standard_Boolean LProp_SLProps::IsCurvatureDefined ()
+Standard_Boolean LProp_SLProps::IsCurvatureDefined()
{
if (myCurvatureStatus == LProp_Undefined)
return Standard_False;
else if (myCurvatureStatus >= LProp_Defined)
return Standard_True;
-
- if(myCN < 2)
+
+ if (myCN < 2)
{
myCurvatureStatus = LProp_Undefined;
return Standard_False;
}
- // status = UnDecided
+ // status = UnDecided
if (!IsNormalDefined())
{
myCurvatureStatus = LProp_Undefined;
// pour eviter un plantage dans le cas du caro pointu
// en fait on doit pouvoir calculer les courbure
// avoir
- if(!IsTangentUDefined() || !IsTangentVDefined())
+ if (!IsTangentUDefined() || !IsTangentVDefined())
{
myCurvatureStatus = LProp_Undefined;
return Standard_False;
// here we compute the curvature features of the surface
- gp_Vec Norm (myNormal);
+ gp_Vec Norm(myNormal);
Standard_Real E = myD1u.SquareMagnitude();
Standard_Real F = myD1u.Dot(myD1v);
Standard_Real G = myD1v.SquareMagnitude();
- if(myDerOrder < 2)
+ if (myDerOrder < 2)
this->D2U();
Standard_Real L = Norm.Dot(myD2u);
Standard_Real B = E * N - G * L;
Standard_Real C = F * N - G * M;
- Standard_Real MaxABC = Max(Max(Abs(A),Abs(B)),Abs(C));
- if (MaxABC < RealEpsilon()) // ombilic
+ Standard_Real MaxABC = Max(Max(Abs(A), Abs(B)), Abs(C));
+ if (MaxABC < RealEpsilon()) // ombilic
{
- myMinCurv = N / G;
- myMaxCurv = myMinCurv;
- myDirMinCurv = gp_Dir (myD1u);
- myDirMaxCurv = gp_Dir (myD1u.Crossed(Norm));
- myMeanCurv = myMinCurv; // (Cmin + Cmax) / 2.
- myGausCurv = myMinCurv * myMinCurv; // (Cmin * Cmax)
+ myMinCurv = N / G;
+ myMaxCurv = myMinCurv;
+ myDirMinCurv = gp_Dir(myD1u);
+ myDirMaxCurv = gp_Dir(myD1u.Crossed(Norm));
+ myMeanCurv = myMinCurv; // (Cmin + Cmax) / 2.
+ myGausCurv = myMinCurv * myMinCurv; // (Cmin * Cmax)
myCurvatureStatus = LProp_Computed;
return Standard_True;
}
B = B / MaxABC;
C = C / MaxABC;
Standard_Real Curv1, Curv2, Root1, Root2;
- gp_Vec VectCurv1, VectCurv2;
+ gp_Vec VectCurv1, VectCurv2;
if (Abs(A) > RealEpsilon())
{
- math_DirectPolynomialRoots Root (A, B, C);
- if(Root.NbSolutions() != 2)
+ math_DirectPolynomialRoots Root(A, B, C);
+ if (Root.NbSolutions() != 2)
{
myCurvatureStatus = LProp_Undefined;
return Standard_False;
}
else
{
- Root1 = Root.Value(1);
- Root2 = Root.Value(2);
- Curv1 = ((L * Root1 + 2. * M) * Root1 + N) /
- ((E * Root1 + 2. * F) * Root1 + G);
- Curv2 = ((L * Root2 + 2. * M) * Root2 + N) /
- ((E * Root2 + 2. * F) * Root2 + G);
+ Root1 = Root.Value(1);
+ Root2 = Root.Value(2);
+ Curv1 = ((L * Root1 + 2. * M) * Root1 + N) / ((E * Root1 + 2. * F) * Root1 + G);
+ Curv2 = ((L * Root2 + 2. * M) * Root2 + N) / ((E * Root2 + 2. * F) * Root2 + G);
VectCurv1 = Root1 * myD1u + myD1v;
VectCurv2 = Root2 * myD1u + myD1v;
}
{
math_DirectPolynomialRoots Root(C, B, A);
- if((Root.NbSolutions() != 2))
+ if ((Root.NbSolutions() != 2))
{
myCurvatureStatus = LProp_Undefined;
return Standard_False;
}
else
{
- Root1 = Root.Value(1);
- Root2 = Root.Value(2);
- Curv1 = ((N * Root1 + 2. * M) * Root1 + L) /
- ((G * Root1 + 2. * F) * Root1 + E);
- Curv2 = ((N * Root2 + 2. * M) * Root2 + L) /
- ((G * Root2 + 2. * F) * Root2 + E);
+ Root1 = Root.Value(1);
+ Root2 = Root.Value(2);
+ Curv1 = ((N * Root1 + 2. * M) * Root1 + L) / ((G * Root1 + 2. * F) * Root1 + E);
+ Curv2 = ((N * Root2 + 2. * M) * Root2 + L) / ((G * Root2 + 2. * F) * Root2 + E);
VectCurv1 = myD1u + Root1 * myD1v;
VectCurv2 = myD1u + Root2 * myD1v;
}
}
else
{
- Curv1 = L / E;
- Curv2 = N / G;
+ Curv1 = L / E;
+ Curv2 = N / G;
VectCurv1 = myD1u;
VectCurv2 = myD1v;
}
if (Curv1 < Curv2)
{
- myMinCurv = Curv1;
- myMaxCurv = Curv2;
- myDirMinCurv = gp_Dir (VectCurv1);
- myDirMaxCurv = gp_Dir (VectCurv2);
+ myMinCurv = Curv1;
+ myMaxCurv = Curv2;
+ myDirMinCurv = gp_Dir(VectCurv1);
+ myDirMaxCurv = gp_Dir(VectCurv2);
}
else
{
- myMinCurv = Curv2;
- myMaxCurv = Curv1;
- myDirMinCurv = gp_Dir (VectCurv2);
- myDirMaxCurv = gp_Dir (VectCurv1);
+ myMinCurv = Curv2;
+ myMaxCurv = Curv1;
+ myDirMinCurv = gp_Dir(VectCurv2);
+ myDirMaxCurv = gp_Dir(VectCurv1);
}
myMeanCurv = ((N * E) - (2. * M * F) + (L * G)) // voir Farin p.282
/ (2. * ((E * G) - (F * F)));
- myGausCurv = ((L * N) - (M * M))
- / ((E * G) - (F * F));
+ myGausCurv = ((L * N) - (M * M)) / ((E * G) - (F * F));
myCurvatureStatus = LProp_Computed;
return Standard_True;
}
-Standard_Boolean LProp_SLProps::IsUmbilic ()
+Standard_Boolean LProp_SLProps::IsUmbilic()
{
- if(!IsCurvatureDefined())
+ if (!IsCurvatureDefined())
throw LProp_NotDefined();
-
+
return Abs(myMaxCurv - myMinCurv) < Abs(Epsilon(myMaxCurv));
}
-Standard_Real LProp_SLProps::MaxCurvature ()
+Standard_Real LProp_SLProps::MaxCurvature()
{
- if(!IsCurvatureDefined())
+ if (!IsCurvatureDefined())
throw LProp_NotDefined();
return myMaxCurv;
}
-Standard_Real LProp_SLProps::MinCurvature ()
+Standard_Real LProp_SLProps::MinCurvature()
{
- if(!IsCurvatureDefined())
+ if (!IsCurvatureDefined())
throw LProp_NotDefined();
-
+
return myMinCurv;
}
void LProp_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
{
- if(!IsCurvatureDefined())
+ if (!IsCurvatureDefined())
throw LProp_NotDefined();
Max = myDirMaxCurv;
Min = myDirMinCurv;
}
-Standard_Real LProp_SLProps::MeanCurvature ()
+Standard_Real LProp_SLProps::MeanCurvature()
{
- if(!IsCurvatureDefined())
+ if (!IsCurvatureDefined())
throw LProp_NotDefined();
return myMeanCurv;
}
-Standard_Real LProp_SLProps::GaussianCurvature ()
+Standard_Real LProp_SLProps::GaussianCurvature()
{
- if(!IsCurvatureDefined())
+ if (!IsCurvatureDefined())
throw LProp_NotDefined();
return myGausCurv;
#include <AppParCurves_ConstraintCouple.hxx>
#include <AppParCurves_HArray1OfConstraintCouple.hxx>
-
-AppParCurves_BSpFunction::
- AppParCurves_BSpFunction(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const math_Vector& Parameters,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Standard_Integer NbPol) :
- MyMultiLine(SSP),
- MyMultiBSpCurve(NbPol),
- myParameters(Parameters.Lower(), Parameters.Upper()),
- ValGrad_F(FirstPoint, LastPoint),
- MyF(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- PTLX(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- PTLY(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- PTLZ(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- A(FirstPoint, LastPoint, 1, NbPol),
- DA(FirstPoint, LastPoint, 1, NbPol),
- MyLeastSquare(SSP, Knots, Mults, FirstPoint, LastPoint,
- FirstConstraint(TheConstraints, FirstPoint),
- LastConstraint(TheConstraints, LastPoint), NbPol)
+AppParCurves_BSpFunction::AppParCurves_BSpFunction(
+ const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const math_Vector& Parameters,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Standard_Integer NbPol)
+ : MyMultiLine(SSP),
+ MyMultiBSpCurve(NbPol),
+ myParameters(Parameters.Lower(), Parameters.Upper()),
+ ValGrad_F(FirstPoint, LastPoint),
+ MyF(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ PTLX(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ PTLY(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ PTLZ(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ A(FirstPoint, LastPoint, 1, NbPol),
+ DA(FirstPoint, LastPoint, 1, NbPol),
+ MyLeastSquare(SSP,
+ Knots,
+ Mults,
+ FirstPoint,
+ LastPoint,
+ FirstConstraint(TheConstraints, FirstPoint),
+ LastConstraint(TheConstraints, LastPoint),
+ NbPol)
{
- Standard_Integer i;
+ Standard_Integer i;
for (i = Parameters.Lower(); i <= Parameters.Upper(); i++)
myParameters(i) = Parameters(i);
- FirstP = FirstPoint;
- LastP = LastPoint;
+ FirstP = FirstPoint;
+ LastP = LastPoint;
myConstraints = TheConstraints;
- NbP = LastP-FirstP+1;
- Adeb = FirstP;
- Afin = LastP;
- nbpoles = NbPol;
+ NbP = LastP - FirstP + 1;
+ Adeb = FirstP;
+ Afin = LastP;
+ nbpoles = NbPol;
MyMultiBSpCurve.SetKnots(Knots);
MyMultiBSpCurve.SetMultiplicities(Mults);
Contraintes = Standard_False;
- Standard_Integer myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons;
+ AppParCurves_Constraint Cons;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == FirstP) {
- if (Cons >= 1) Adeb = Adeb+1;
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == FirstP)
+ {
+ if (Cons >= 1)
+ Adeb = Adeb + 1;
}
- else if (myindex == LastP) {
- if (Cons >= 1) Afin = Afin-1;
+ else if (myindex == LastP)
+ {
+ if (Cons >= 1)
+ Afin = Afin - 1;
}
- else {
- if (Cons >= 1) Contraintes = Standard_True;
+ else
+ {
+ if (Cons >= 1)
+ Contraintes = Standard_True;
}
}
- Standard_Integer nb3d = ToolLine::NbP3d(SSP);
- Standard_Integer nb2d = ToolLine::NbP2d(SSP);
- Standard_Integer mynb3d= nb3d, mynb2d=nb2d;
- if (nb3d == 0) mynb3d = 1;
- if (nb2d == 0) mynb2d = 1;
-
- NbCu = nb3d+nb2d;
- tabdim = new TColStd_HArray1OfInteger(0, NbCu-1);
-
- if (Contraintes) {
- for (i = 1; i <= NbCu; i++) {
- if (i <= nb3d) tabdim->SetValue(i-1, 3);
- else tabdim->SetValue(i-1, 2);
+ Standard_Integer nb3d = ToolLine::NbP3d(SSP);
+ Standard_Integer nb2d = ToolLine::NbP2d(SSP);
+ Standard_Integer mynb3d = nb3d, mynb2d = nb2d;
+ if (nb3d == 0)
+ mynb3d = 1;
+ if (nb2d == 0)
+ mynb2d = 1;
+
+ NbCu = nb3d + nb2d;
+ tabdim = new TColStd_HArray1OfInteger(0, NbCu - 1);
+
+ if (Contraintes)
+ {
+ for (i = 1; i <= NbCu; i++)
+ {
+ if (i <= nb3d)
+ tabdim->SetValue(i - 1, 3);
+ else
+ tabdim->SetValue(i - 1, 2);
}
- TColgp_Array1OfPnt TabP(1, mynb3d);
+ TColgp_Array1OfPnt TabP(1, mynb3d);
TColgp_Array1OfPnt2d TabP2d(1, mynb2d);
-
- for ( i = FirstP; i <= LastP; i++) {
- if (nb3d != 0 && nb2d != 0) ToolLine::Value(SSP, i, TabP, TabP2d);
- else if (nb3d != 0) ToolLine::Value(SSP, i, TabP);
- else ToolLine::Value(SSP, i, TabP2d);
- for (Standard_Integer j = 1; j <= NbCu; j++) {
- if (tabdim->Value(j-1) == 3) {
- TabP(j).Coord(PTLX(i, j), PTLY(i, j),PTLZ(i, j));
- }
- else {
- TabP2d(j).Coord(PTLX(i, j), PTLY(i, j));
- }
+
+ for (i = FirstP; i <= LastP; i++)
+ {
+ if (nb3d != 0 && nb2d != 0)
+ ToolLine::Value(SSP, i, TabP, TabP2d);
+ else if (nb3d != 0)
+ ToolLine::Value(SSP, i, TabP);
+ else
+ ToolLine::Value(SSP, i, TabP2d);
+ for (Standard_Integer j = 1; j <= NbCu; j++)
+ {
+ if (tabdim->Value(j - 1) == 3)
+ {
+ TabP(j).Coord(PTLX(i, j), PTLY(i, j), PTLZ(i, j));
+ }
+ else
+ {
+ TabP2d(j).Coord(PTLX(i, j), PTLY(i, j));
+ }
}
}
}
}
-
-AppParCurves_Constraint AppParCurves_BSpFunction::FirstConstraint
- (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const Standard_Integer FirstPoint) const
+AppParCurves_Constraint AppParCurves_BSpFunction::FirstConstraint(
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const Standard_Integer FirstPoint) const
{
- Standard_Integer i, myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer i, myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == FirstPoint) {
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == FirstPoint)
+ {
break;
}
}
return Cons;
}
-
-AppParCurves_Constraint AppParCurves_BSpFunction::LastConstraint
- (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const Standard_Integer LastPoint) const
+AppParCurves_Constraint AppParCurves_BSpFunction::LastConstraint(
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const Standard_Integer LastPoint) const
{
- Standard_Integer i, myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer i, myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == LastPoint) {
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == LastPoint)
+ {
break;
}
}
return Cons;
}
-
-
-
-Standard_Boolean AppParCurves_BSpFunction::Value (const math_Vector& X,
- Standard_Real& F) {
+Standard_Boolean AppParCurves_BSpFunction::Value(const math_Vector& X, Standard_Real& F)
+{
myParameters = X;
// Resolution moindres carres:
// ===========================
MyLeastSquare.Perform(myParameters, mylambda1, mylambda2);
- if (!(MyLeastSquare.IsDone())) {
+ if (!(MyLeastSquare.IsDone()))
+ {
Done = Standard_False;
return Standard_False;
}
- if (!Contraintes) {
+ if (!Contraintes)
+ {
MyLeastSquare.Error(FVal, ERR3d, ERR2d);
F = FVal;
}
// Resolution avec contraintes:
// ============================
- else {
- }
+ else
+ {
+ }
return Standard_True;
}
-
-
-
-void AppParCurves_BSpFunction::Perform(const math_Vector& X) {
+void AppParCurves_BSpFunction::Perform(const math_Vector& X)
+{
Standard_Integer j;
myParameters = X;
// ===========================
MyLeastSquare.Perform(myParameters, mylambda1, mylambda2);
- if (!(MyLeastSquare.IsDone())) {
+ if (!(MyLeastSquare.IsDone()))
+ {
Done = Standard_False;
return;
}
- for(j = myParameters.Lower(); j <= myParameters.Upper(); j++) {
+ for (j = myParameters.Lower(); j <= myParameters.Upper(); j++)
+ {
ValGrad_F(j) = 0.0;
}
- if (!Contraintes) {
+ if (!Contraintes)
+ {
MyLeastSquare.ErrorGradient(ValGrad_F, FVal, ERR3d, ERR2d);
}
- else {
+ else
+ {
}
}
-
-
void AppParCurves_BSpFunction::SetFirstLambda(const Standard_Real l1)
{
mylambda1 = l1;
mylambda2 = l2;
}
-
-
-Standard_Integer AppParCurves_BSpFunction::NbVariables() const{
+Standard_Integer AppParCurves_BSpFunction::NbVariables() const
+{
return NbP;
}
-
-Standard_Boolean AppParCurves_BSpFunction::Gradient (const math_Vector& X,
- math_Vector& G) {
+Standard_Boolean AppParCurves_BSpFunction::Gradient(const math_Vector& X, math_Vector& G)
+{
Perform(X);
G = ValGrad_F;
return Standard_True;
}
-
-Standard_Boolean AppParCurves_BSpFunction::Values (const math_Vector& X,
- Standard_Real& F,
- math_Vector& G) {
-
+Standard_Boolean AppParCurves_BSpFunction::Values(const math_Vector& X,
+ Standard_Real& F,
+ math_Vector& G)
+{
Perform(X);
F = FVal;
G = ValGrad_F;
-/*
- math_Vector mygradient = G;
- math_Vector myx = X;
- Standard_Real myf = FVal;
- Standard_Real F2 = FVal;
- math_Vector G2 = ValGrad_F;
- for (Standard_Integer i = 1; i <= X.Length(); i++) {
- myx = X;
- myx(i) = X(i) + 1.0e-10;
- Value(myx, F2);
- mygradient(i) = (F2 - myf)/(1.0e-10);
- }
+ /*
+ math_Vector mygradient = G;
+ math_Vector myx = X;
+ Standard_Real myf = FVal;
+ Standard_Real F2 = FVal;
+ math_Vector G2 = ValGrad_F;
+ for (Standard_Integer i = 1; i <= X.Length(); i++) {
+ myx = X;
+ myx(i) = X(i) + 1.0e-10;
+ Value(myx, F2);
+ mygradient(i) = (F2 - myf)/(1.0e-10);
+ }
-cout << " Gradient calcule : " << G2 << endl;
-cout << " Gradient interpole : " << mygradient << endl;
-*/
+ cout << " Gradient calcule : " << G2 << endl;
+ cout << " Gradient interpole : " << mygradient << endl;
+ */
return Standard_True;
}
-
-AppParCurves_MultiBSpCurve AppParCurves_BSpFunction::CurveValue() {
- if (!Contraintes) MyMultiBSpCurve = MyLeastSquare.BSplineValue();
+AppParCurves_MultiBSpCurve AppParCurves_BSpFunction::CurveValue()
+{
+ if (!Contraintes)
+ MyMultiBSpCurve = MyLeastSquare.BSplineValue();
return MyMultiBSpCurve;
}
-
Standard_Real AppParCurves_BSpFunction::Error(const Standard_Integer IPoint,
- const Standard_Integer CurveIndex) {
+ const Standard_Integer CurveIndex)
+{
const math_Matrix& DD = MyLeastSquare.Distance();
- Standard_Real d = DD.Value(IPoint, CurveIndex);
- if (!Contraintes) return d;
- else return Sqrt(MyF(IPoint, CurveIndex));
+ Standard_Real d = DD.Value(IPoint, CurveIndex);
+ if (!Contraintes)
+ return d;
+ else
+ return Sqrt(MyF(IPoint, CurveIndex));
}
Standard_Real AppParCurves_BSpFunction::MaxError3d() const
return ERR2d;
}
-
-
const math_Vector& AppParCurves_BSpFunction::NewParameters() const
{
return myParameters;
}
-
const math_Matrix& AppParCurves_BSpFunction::FunctionMatrix() const
{
return MyLeastSquare.FunctionMatrix();
return MyLeastSquare.DerivativeFunctionMatrix();
}
-
const math_IntegerVector& AppParCurves_BSpFunction::Index() const
{
return MyLeastSquare.KIndex();
// lpa, le 11/09/91
-
-// Application de la methode du gradient corrige pour minimiser
+// Application de la methode du gradient corrige pour minimiser
// F = somme(||C(ui, Poles(ui)) - ptli||2.
-// La methode de gradient conjugue est programmee dans la bibliotheque
+// La methode de gradient conjugue est programmee dans la bibliotheque
// mathematique: math_BFGS.
-
#define No_Standard_RangeError
#define No_Standard_OutOfRange
#include <TColgp_Array1OfVec.hxx>
#include <TColgp_Array1OfVec2d.hxx>
-static AppParCurves_Constraint FirstConstraint
- (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const Standard_Integer FirstPoint)
+static AppParCurves_Constraint FirstConstraint(
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const Standard_Integer FirstPoint)
{
- Standard_Integer i, myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer i, myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == FirstPoint) {
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == FirstPoint)
+ {
break;
}
}
return Cons;
}
-
-static AppParCurves_Constraint LastConstraint
- (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const Standard_Integer LastPoint)
+static AppParCurves_Constraint LastConstraint(
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const Standard_Integer LastPoint)
{
- Standard_Integer i, myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer i, myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == LastPoint) {
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == LastPoint)
+ {
break;
}
}
return Cons;
}
-
-
-
-
-AppParCurves_BSpGradient::
- AppParCurves_BSpGradient(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- math_Vector& Parameters,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Standard_Integer Deg,
- const Standard_Real Tol3d,
- const Standard_Real Tol2d,
- const Standard_Integer NbIterations):
- ParError(FirstPoint, LastPoint,0.0),
- mylambda1(0.0),
- mylambda2(0.0),
- myIsLambdaDefined(Standard_False)
+AppParCurves_BSpGradient::AppParCurves_BSpGradient(
+ const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ math_Vector& Parameters,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Standard_Integer Deg,
+ const Standard_Real Tol3d,
+ const Standard_Real Tol2d,
+ const Standard_Integer NbIterations)
+ : ParError(FirstPoint, LastPoint, 0.0),
+ mylambda1(0.0),
+ mylambda2(0.0),
+ myIsLambdaDefined(Standard_False)
{
- Perform(SSP, FirstPoint, LastPoint, TheConstraints, Parameters,
- Knots, Mults, Deg, Tol3d, Tol2d, NbIterations);
+ Perform(SSP,
+ FirstPoint,
+ LastPoint,
+ TheConstraints,
+ Parameters,
+ Knots,
+ Mults,
+ Deg,
+ Tol3d,
+ Tol2d,
+ NbIterations);
}
-
-AppParCurves_BSpGradient::
- AppParCurves_BSpGradient(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- math_Vector& Parameters,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Standard_Integer Deg,
- const Standard_Real Tol3d,
- const Standard_Real Tol2d,
- const Standard_Integer NbIterations,
- const Standard_Real lambda1,
- const Standard_Real lambda2):
- ParError(FirstPoint, LastPoint,0.0),
- mylambda1(lambda1),
- mylambda2(lambda2),
- myIsLambdaDefined(Standard_True)
+AppParCurves_BSpGradient::AppParCurves_BSpGradient(
+ const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ math_Vector& Parameters,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Standard_Integer Deg,
+ const Standard_Real Tol3d,
+ const Standard_Real Tol2d,
+ const Standard_Integer NbIterations,
+ const Standard_Real lambda1,
+ const Standard_Real lambda2)
+ : ParError(FirstPoint, LastPoint, 0.0),
+ mylambda1(lambda1),
+ mylambda2(lambda2),
+ myIsLambdaDefined(Standard_True)
{
- Perform(SSP, FirstPoint, LastPoint, TheConstraints, Parameters,
- Knots, Mults, Deg, Tol3d, Tol2d, NbIterations);
+ Perform(SSP,
+ FirstPoint,
+ LastPoint,
+ TheConstraints,
+ Parameters,
+ Knots,
+ Mults,
+ Deg,
+ Tol3d,
+ Tol2d,
+ NbIterations);
}
-
-
-
-
-
-
-void AppParCurves_BSpGradient::
- Perform(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- math_Vector& Parameters,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Standard_Integer Deg,
- const Standard_Real Tol3d,
- const Standard_Real Tol2d,
- const Standard_Integer NbIterations)
+void AppParCurves_BSpGradient::Perform(
+ const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ math_Vector& Parameters,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Standard_Integer Deg,
+ const Standard_Real Tol3d,
+ const Standard_Real Tol2d,
+ const Standard_Integer NbIterations)
{
-// Standard_Boolean grad = Standard_True;
+ // Standard_Boolean grad = Standard_True;
Standard_Integer i, j, k, i2, l;
- Standard_Real UF, DU, Fval = 0.0, FU, DFU;
- Standard_Integer nbP3d = ToolLine::NbP3d(SSP);
- Standard_Integer nbP2d = ToolLine::NbP2d(SSP);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
+ Standard_Real UF, DU, Fval = 0.0, FU, DFU;
+ Standard_Integer nbP3d = ToolLine::NbP3d(SSP);
+ Standard_Integer nbP2d = ToolLine::NbP2d(SSP);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
Standard_Integer nbP = nbP3d + nbP2d;
-// gp_Pnt Pt, P1, P2;
+ // gp_Pnt Pt, P1, P2;
gp_Pnt Pt;
-// gp_Pnt2d Pt2d, P12d, P22d;
+ // gp_Pnt2d Pt2d, P12d, P22d;
gp_Pnt2d Pt2d;
-// gp_Vec V1, V2, MyV;
+ // gp_Vec V1, V2, MyV;
gp_Vec V1, MyV;
-// gp_Vec2d V12d, V22d, MyV2d;
+ // gp_Vec2d V12d, V22d, MyV2d;
gp_Vec2d V12d, MyV2d;
Done = Standard_False;
-
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- TColgp_Array1OfPnt TabP(1, mynbP3d);
+
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ TColgp_Array1OfPnt TabP(1, mynbP3d);
TColgp_Array1OfPnt2d TabP2d(1, mynbP2d);
- TColgp_Array1OfVec TabV(1, mynbP3d);
+ TColgp_Array1OfVec TabV(1, mynbP3d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
// Calcul de la fonction F= somme(||C(ui)-Ptli||2):
// pour calculer F et grad_F.
// ================================================================
- Standard_Integer nbpoles = -Deg -1;
- for (i = Mults.Lower() ;i <= Mults.Upper(); i++) {
+ Standard_Integer nbpoles = -Deg - 1;
+ for (i = Mults.Lower(); i <= Mults.Upper(); i++)
+ {
nbpoles += Mults(i);
}
TColgp_Array1OfPnt TabPole(1, nbpoles);
TColgp_Array1OfPnt2d TabPole2d(1, nbpoles);
- TColgp_Array1OfPnt ThePoles(1, (nbpoles)*mynbP3d);
- TColgp_Array1OfPnt2d ThePoles2d(1, (nbpoles)*mynbP2d);
-
-
- AppParCurves_Constraint
- FirstCons = FirstConstraint(TheConstraints, FirstPoint),
- LastCons = LastConstraint(TheConstraints, LastPoint);
-
-
- AppParCurves_BSpParFunction MyF(SSP, FirstPoint,LastPoint, TheConstraints,
- Parameters, Knots, Mults, nbpoles);
-
-
-
- if (FirstCons >= AppParCurves_TangencyPoint ||
- LastCons >= AppParCurves_TangencyPoint) {
-
- if (!myIsLambdaDefined) {
- AppParCurves_BSpParLeastSquare thefitt(SSP, Knots, Mults, FirstPoint,
- LastPoint, FirstCons, LastCons,
- Parameters, nbpoles);
- if (FirstCons >= AppParCurves_TangencyPoint) {
- mylambda1 = thefitt.FirstLambda();
- MyF.SetFirstLambda(mylambda1);
+ TColgp_Array1OfPnt ThePoles(1, (nbpoles)*mynbP3d);
+ TColgp_Array1OfPnt2d ThePoles2d(1, (nbpoles)*mynbP2d);
+
+ AppParCurves_Constraint FirstCons = FirstConstraint(TheConstraints, FirstPoint),
+ LastCons = LastConstraint(TheConstraints, LastPoint);
+
+ AppParCurves_BSpParFunction
+ MyF(SSP, FirstPoint, LastPoint, TheConstraints, Parameters, Knots, Mults, nbpoles);
+
+ if (FirstCons >= AppParCurves_TangencyPoint || LastCons >= AppParCurves_TangencyPoint)
+ {
+
+ if (!myIsLambdaDefined)
+ {
+ AppParCurves_BSpParLeastSquare
+ thefitt(SSP, Knots, Mults, FirstPoint, LastPoint, FirstCons, LastCons, Parameters, nbpoles);
+ if (FirstCons >= AppParCurves_TangencyPoint)
+ {
+ mylambda1 = thefitt.FirstLambda();
+ MyF.SetFirstLambda(mylambda1);
}
- if (LastCons >= AppParCurves_TangencyPoint) {
- mylambda2 = thefitt.LastLambda();
- MyF.SetLastLambda(mylambda2);
+ if (LastCons >= AppParCurves_TangencyPoint)
+ {
+ mylambda2 = thefitt.LastLambda();
+ MyF.SetLastLambda(mylambda2);
}
}
- else {
+ else
+ {
MyF.SetFirstLambda(mylambda1);
MyF.SetLastLambda(mylambda2);
}
}
-
MyF.Value(Parameters, Fval);
MError3d = MyF.MaxError3d();
MError2d = MyF.MaxError2d();
- SCU = MyF.CurveValue();
+ SCU = MyF.CurveValue();
- if (MError3d > Tol3d || MError2d > Tol2d) {
+ if (MError3d > Tol3d || MError2d > Tol2d)
+ {
// Stockage des Poles des courbes pour projeter:
// ============================================
i2 = 0;
- for (k = 1; k <= nbP3d; k++) {
+ for (k = 1; k <= nbP3d; k++)
+ {
SCU.Curve(k, TabPole);
- for (j=1; j<=nbpoles; j++) ThePoles(j+i2) = TabPole(j);
+ for (j = 1; j <= nbpoles; j++)
+ ThePoles(j + i2) = TabPole(j);
i2 += nbpoles;
}
i2 = 0;
- for (k = 1; k <= nbP2d; k++) {
- SCU.Curve(nbP3d+k, TabPole2d);
- for (j=1; j<=nbpoles; j++) ThePoles2d(j+i2) = TabPole2d(j);
+ for (k = 1; k <= nbP2d; k++)
+ {
+ SCU.Curve(nbP3d + k, TabPole2d);
+ for (j = 1; j <= nbpoles; j++)
+ ThePoles2d(j + i2) = TabPole2d(j);
i2 += nbpoles;
}
-
- // Une iteration rapide de projection est faite par la methode de
+
+ // Une iteration rapide de projection est faite par la methode de
// Rogers & Fog 89, methode equivalente a Hoschek 88 qui ne necessite pas
// le calcul de D2.
-
- const math_Matrix& A = MyF.FunctionMatrix();
- const math_Matrix& DA = MyF.DerivativeFunctionMatrix();
+
+ const math_Matrix& A = MyF.FunctionMatrix();
+ const math_Matrix& DA = MyF.DerivativeFunctionMatrix();
const math_IntegerVector& Index = MyF.Index();
- Standard_Real aa, da, a, b, c, d , e , f, px, py, pz;
- Standard_Integer indexdeb, indexfin;
+ Standard_Real aa, da, a, b, c, d, e, f, px, py, pz;
+ Standard_Integer indexdeb, indexfin;
+
+ for (j = FirstPoint + 1; j <= LastPoint - 1; j++)
+ {
- for (j = FirstPoint+1; j <= LastPoint-1; j++) {
-
UF = Parameters(j);
- if (nbP3d != 0 && nbP2d != 0) ToolLine::Value(SSP, j, TabP, TabP2d);
- else if (nbP2d != 0) ToolLine::Value(SSP, j, TabP2d);
- else ToolLine::Value(SSP, j, TabP);
-
- FU = 0.0;
+ if (nbP3d != 0 && nbP2d != 0)
+ ToolLine::Value(SSP, j, TabP, TabP2d);
+ else if (nbP2d != 0)
+ ToolLine::Value(SSP, j, TabP2d);
+ else
+ ToolLine::Value(SSP, j, TabP);
+
+ FU = 0.0;
DFU = 0.0;
- i2 = 0;
-
+ i2 = 0;
+
indexdeb = Index(j) + 1;
indexfin = indexdeb + Deg;
- for (k = 1; k <= nbP3d; k++) {
- a = b = c = d = e = f = 0.0;
- for (l = indexdeb; l <= indexfin; l++) {
- Pt = ThePoles(l+i2);
- px = Pt.X(); py = Pt.Y(); pz = Pt.Z();
- aa = A(j, l); da = DA(j, l);
- a += aa* px; d += da* px;
- b += aa* py; e += da* py;
- c += aa* pz; f += da* pz;
- }
- Pt.SetCoord(a, b, c);
- V1.SetCoord(d, e, f);
- i2 += nbpoles;
-
- MyV = gp_Vec(Pt, TabP(k));
- FU += MyV*V1;
- DFU += V1.SquareMagnitude();
+ for (k = 1; k <= nbP3d; k++)
+ {
+ a = b = c = d = e = f = 0.0;
+ for (l = indexdeb; l <= indexfin; l++)
+ {
+ Pt = ThePoles(l + i2);
+ px = Pt.X();
+ py = Pt.Y();
+ pz = Pt.Z();
+ aa = A(j, l);
+ da = DA(j, l);
+ a += aa * px;
+ d += da * px;
+ b += aa * py;
+ e += da * py;
+ c += aa * pz;
+ f += da * pz;
+ }
+ Pt.SetCoord(a, b, c);
+ V1.SetCoord(d, e, f);
+ i2 += nbpoles;
+
+ MyV = gp_Vec(Pt, TabP(k));
+ FU += MyV * V1;
+ DFU += V1.SquareMagnitude();
}
i2 = 0;
- for (k = 1; k <= nbP2d; k++) {
- a = b = d = e = 0.0;
- for (l = indexdeb; l <= indexfin; l++) {
- Pt2d = ThePoles2d(l+i2);
- px = Pt2d.X(); py = Pt2d.Y();
- aa = A(j, l); da = DA(j, l);
- a += aa* px; d += da* px;
- b += aa* py; e += da* py;
- }
- Pt2d.SetCoord(a, b);
- V12d.SetCoord(d, e);
- i2 += nbpoles;
-
- MyV2d = gp_Vec2d(Pt2d, TabP2d(k));
- FU += MyV2d*V12d;
- DFU += V12d.SquareMagnitude();
+ for (k = 1; k <= nbP2d; k++)
+ {
+ a = b = d = e = 0.0;
+ for (l = indexdeb; l <= indexfin; l++)
+ {
+ Pt2d = ThePoles2d(l + i2);
+ px = Pt2d.X();
+ py = Pt2d.Y();
+ aa = A(j, l);
+ da = DA(j, l);
+ a += aa * px;
+ d += da * px;
+ b += aa * py;
+ e += da * py;
+ }
+ Pt2d.SetCoord(a, b);
+ V12d.SetCoord(d, e);
+ i2 += nbpoles;
+
+ MyV2d = gp_Vec2d(Pt2d, TabP2d(k));
+ FU += MyV2d * V12d;
+ DFU += V12d.SquareMagnitude();
}
-
- if (DFU >= RealEpsilon()) {
- DU = FU/DFU;
- DU = Sign(Min(5.e-02, Abs(DU)), DU);
- UF += DU;
- Parameters(j) = UF;
+
+ if (DFU >= RealEpsilon())
+ {
+ DU = FU / DFU;
+ DU = Sign(Min(5.e-02, Abs(DU)), DU);
+ UF += DU;
+ Parameters(j) = UF;
}
}
-
+
MyF.Value(Parameters, Fval);
MError3d = MyF.MaxError3d();
MError2d = MyF.MaxError2d();
}
-
- if (MError3d<= Tol3d && MError2d <= Tol2d) {
+ if (MError3d <= Tol3d && MError2d <= Tol2d)
+ {
Done = Standard_True;
}
- else if (NbIterations != 0) {
+ else if (NbIterations != 0)
+ {
// NbIterations de gradient conjugue:
// =================================
- Standard_Real Eps = 1.e-07;
- AppParCurves_BSpGradient_BFGS FResol(MyF, Parameters, Tol3d,
- Tol2d, Eps, NbIterations);
+ Standard_Real Eps = 1.e-07;
+ AppParCurves_BSpGradient_BFGS FResol(MyF, Parameters, Tol3d, Tol2d, Eps, NbIterations);
}
SCU = MyF.CurveValue();
-
AvError = 0.;
- for (j = FirstPoint; j <= LastPoint; j++) {
+ for (j = FirstPoint; j <= LastPoint; j++)
+ {
Parameters(j) = MyF.NewParameters()(j);
// Recherche des erreurs maxi et moyenne a un index donne:
- for (k = 1; k <= nbP; k++) {
+ for (k = 1; k <= nbP; k++)
+ {
ParError(j) = Max(ParError(j), MyF.Error(j, k));
}
AvError += ParError(j);
}
- AvError = AvError/(LastPoint-FirstPoint+1);
-
+ AvError = AvError / (LastPoint - FirstPoint + 1);
MError3d = MyF.MaxError3d();
MError2d = MyF.MaxError2d();
- if (MError3d <= Tol3d && MError2d <= Tol2d) {
+ if (MError3d <= Tol3d && MError2d <= Tol2d)
+ {
Done = Standard_True;
}
-
}
-
-
-AppParCurves_MultiBSpCurve AppParCurves_BSpGradient::Value() const {
+AppParCurves_MultiBSpCurve AppParCurves_BSpGradient::Value() const
+{
return SCU;
}
-
-Standard_Boolean AppParCurves_BSpGradient::IsDone() const {
+Standard_Boolean AppParCurves_BSpGradient::IsDone() const
+{
return Done;
}
-
-Standard_Real AppParCurves_BSpGradient::Error(const Standard_Integer Index) const {
+Standard_Real AppParCurves_BSpGradient::Error(const Standard_Integer Index) const
+{
return ParError(Index);
}
-Standard_Real AppParCurves_BSpGradient::AverageError() const {
+Standard_Real AppParCurves_BSpGradient::AverageError() const
+{
return AvError;
}
-Standard_Real AppParCurves_BSpGradient::MaxError3d() const {
+Standard_Real AppParCurves_BSpGradient::MaxError3d() const
+{
return MError3d;
}
-Standard_Real AppParCurves_BSpGradient::MaxError2d() const {
+Standard_Real AppParCurves_BSpGradient::MaxError2d() const
+{
return MError2d;
}
-
-
// Redefinition de math_BFGS:
// ==========================
-AppParCurves_BSpGradient_BFGS::AppParCurves_BSpGradient_BFGS(math_MultipleVarFunctionWithGradient& F,
- const math_Vector& StartingPoint,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Real Eps,
- const Standard_Integer NbIterations):
- math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
- myTol3d(Tolerance3d),
- myTol2d(Tolerance2d)
+AppParCurves_BSpGradient_BFGS::AppParCurves_BSpGradient_BFGS(
+ math_MultipleVarFunctionWithGradient& F,
+ const math_Vector& StartingPoint,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Real Eps,
+ const Standard_Integer NbIterations)
+ : math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
+ myTol3d(Tolerance3d),
+ myTol2d(Tolerance2d)
{
-
+
Perform(F, StartingPoint);
}
-Standard_Boolean AppParCurves_BSpGradient_BFGS::IsSolutionReached(math_MultipleVarFunctionWithGradient& F) const {
- Standard_Boolean Result, Result2;
- AppParCurves_BSpParFunction *F1 = (AppParCurves_BSpParFunction*) &F;
-
- Result = (2.0 * fabs(TheMinimum - PreviousMinimum) <=
- 1.e-10 * (fabs(TheMinimum) + fabs(PreviousMinimum))+1.e-12) ;
+Standard_Boolean AppParCurves_BSpGradient_BFGS::IsSolutionReached(
+ math_MultipleVarFunctionWithGradient& F) const
+{
+ Standard_Boolean Result, Result2;
+ AppParCurves_BSpParFunction* F1 = (AppParCurves_BSpParFunction*)&F;
+
+ Result = (2.0 * fabs(TheMinimum - PreviousMinimum)
+ <= 1.e-10 * (fabs(TheMinimum) + fabs(PreviousMinimum)) + 1.e-12);
Standard_Real MErr3d = F1->MaxError3d();
- Standard_Real MErr2d = F1->MaxError2d();
- Result2 = ((MErr3d <= myTol3d) && (MErr2d <= myTol2d));
-
+ Standard_Real MErr2d = F1->MaxError2d();
+ Result2 = ((MErr3d <= myTol3d) && (MErr2d <= myTol2d));
+
return (Result || Result2);
}
-
-
-
// Lpa, le 20/09/91
-
// Calcul de la valeur de F et grad_F, connaissant le parametrage.
-// Cette fonction, appelee par le gradient conjugue, calcul F et
-// DF(ui, Poles(ui)) ce qui implique un calcul des nouveaux poles
+// Cette fonction, appelee par le gradient conjugue, calcul F et
+// DF(ui, Poles(ui)) ce qui implique un calcul des nouveaux poles
// a chaque appel.
#define No_Standard_RangeError
#define No_Standard_OutOfRange
-
-
#include <AppParCurves_MultiCurve.hxx>
#include <AppParCurves_MultiPoint.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <AppParCurves_ConstraintCouple.hxx>
-AppParCurves_Function::
- AppParCurves_Function(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const math_Vector& Parameters,
- const Standard_Integer Deg) :
- MyMultiLine(SSP),
- MyMultiCurve(Deg+1),
- myParameters(Parameters.Lower(), Parameters.Upper()),
- ValGrad_F(FirstPoint, LastPoint),
- MyF(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- PTLX(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- PTLY(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- PTLZ(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- A(FirstPoint, LastPoint, 1, Deg+1),
- DA(FirstPoint, LastPoint, 1, Deg+1),
- MyLeastSquare(SSP, FirstPoint, LastPoint,
- FirstConstraint(TheConstraints, FirstPoint),
- LastConstraint(TheConstraints, LastPoint), Deg+1)
+AppParCurves_Function::AppParCurves_Function(
+ const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const math_Vector& Parameters,
+ const Standard_Integer Deg)
+ : MyMultiLine(SSP),
+ MyMultiCurve(Deg + 1),
+ myParameters(Parameters.Lower(), Parameters.Upper()),
+ ValGrad_F(FirstPoint, LastPoint),
+ MyF(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ PTLX(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ PTLY(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ PTLZ(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ A(FirstPoint, LastPoint, 1, Deg + 1),
+ DA(FirstPoint, LastPoint, 1, Deg + 1),
+ MyLeastSquare(SSP,
+ FirstPoint,
+ LastPoint,
+ FirstConstraint(TheConstraints, FirstPoint),
+ LastConstraint(TheConstraints, LastPoint),
+ Deg + 1)
{
Standard_Integer i;
- for (i=Parameters.Lower(); i<=Parameters.Upper();i++)
- myParameters(i)=Parameters(i);
- FirstP = FirstPoint;
- LastP = LastPoint;
+ for (i = Parameters.Lower(); i <= Parameters.Upper(); i++)
+ myParameters(i) = Parameters(i);
+ FirstP = FirstPoint;
+ LastP = LastPoint;
myConstraints = TheConstraints;
- NbP = LastP-FirstP+1;
- Adeb = FirstP;
- Afin = LastP;
- Degre = Deg;
- Contraintes = Standard_False;
- Standard_Integer myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ NbP = LastP - FirstP + 1;
+ Adeb = FirstP;
+ Afin = LastP;
+ Degre = Deg;
+ Contraintes = Standard_False;
+ Standard_Integer myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons;
+ AppParCurves_Constraint Cons;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == FirstP) {
- if (Cons >= 1) Adeb = Adeb+1;
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == FirstP)
+ {
+ if (Cons >= 1)
+ Adeb = Adeb + 1;
}
- else if (myindex == LastP) {
- if (Cons >= 1) Afin = Afin-1;
+ else if (myindex == LastP)
+ {
+ if (Cons >= 1)
+ Afin = Afin - 1;
}
- else {
- if (Cons >= 1) Contraintes = Standard_True;
+ else
+ {
+ if (Cons >= 1)
+ Contraintes = Standard_True;
}
}
- Standard_Integer nb3d = ToolLine::NbP3d(SSP);
- Standard_Integer nb2d = ToolLine::NbP2d(SSP);
- Standard_Integer mynb3d= nb3d, mynb2d=nb2d;
- if (nb3d == 0) mynb3d = 1;
- if (nb2d == 0) mynb2d = 1;
-
- NbCu = nb3d+nb2d;
- tabdim = new TColStd_HArray1OfInteger(0, NbCu-1);
-
- if (Contraintes) {
- for (i = 1; i <= NbCu; i++) {
- if (i <= nb3d) tabdim->SetValue(i-1, 3);
- else tabdim->SetValue(i-1, 2);
+ Standard_Integer nb3d = ToolLine::NbP3d(SSP);
+ Standard_Integer nb2d = ToolLine::NbP2d(SSP);
+ Standard_Integer mynb3d = nb3d, mynb2d = nb2d;
+ if (nb3d == 0)
+ mynb3d = 1;
+ if (nb2d == 0)
+ mynb2d = 1;
+
+ NbCu = nb3d + nb2d;
+ tabdim = new TColStd_HArray1OfInteger(0, NbCu - 1);
+
+ if (Contraintes)
+ {
+ for (i = 1; i <= NbCu; i++)
+ {
+ if (i <= nb3d)
+ tabdim->SetValue(i - 1, 3);
+ else
+ tabdim->SetValue(i - 1, 2);
}
- TColgp_Array1OfPnt TabP(1, mynb3d);
+ TColgp_Array1OfPnt TabP(1, mynb3d);
TColgp_Array1OfPnt2d TabP2d(1, mynb2d);
-
- for ( i = FirstP; i <= LastP; i++) {
- if (nb3d != 0 && nb2d != 0) ToolLine::Value(SSP, i, TabP, TabP2d);
- else if (nb3d != 0) ToolLine::Value(SSP, i, TabP);
- else ToolLine::Value(SSP, i, TabP2d);
- for (Standard_Integer j = 1; j <= NbCu; j++) {
- if (tabdim->Value(j-1) == 3) {
- TabP(j).Coord(PTLX(i, j), PTLY(i, j),PTLZ(i, j));
- }
- else {
- TabP2d(j).Coord(PTLX(i, j), PTLY(i, j));
- }
+
+ for (i = FirstP; i <= LastP; i++)
+ {
+ if (nb3d != 0 && nb2d != 0)
+ ToolLine::Value(SSP, i, TabP, TabP2d);
+ else if (nb3d != 0)
+ ToolLine::Value(SSP, i, TabP);
+ else
+ ToolLine::Value(SSP, i, TabP2d);
+ for (Standard_Integer j = 1; j <= NbCu; j++)
+ {
+ if (tabdim->Value(j - 1) == 3)
+ {
+ TabP(j).Coord(PTLX(i, j), PTLY(i, j), PTLZ(i, j));
+ }
+ else
+ {
+ TabP2d(j).Coord(PTLX(i, j), PTLY(i, j));
+ }
}
}
}
}
-
-AppParCurves_Constraint AppParCurves_Function::FirstConstraint
- (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const Standard_Integer FirstPoint) const
+AppParCurves_Constraint AppParCurves_Function::FirstConstraint(
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const Standard_Integer FirstPoint) const
{
- Standard_Integer i, myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer i, myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == FirstPoint) {
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == FirstPoint)
+ {
break;
}
}
return Cons;
}
-
-AppParCurves_Constraint AppParCurves_Function::LastConstraint
- (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const Standard_Integer LastPoint) const
+AppParCurves_Constraint AppParCurves_Function::LastConstraint(
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const Standard_Integer LastPoint) const
{
- Standard_Integer i, myindex;
- Standard_Integer low = TheConstraints->Lower(), upp= TheConstraints->Upper();
+ Standard_Integer i, myindex;
+ Standard_Integer low = TheConstraints->Lower(), upp = TheConstraints->Upper();
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
- for (i = low; i <= upp; i++) {
+ for (i = low; i <= upp; i++)
+ {
mycouple = TheConstraints->Value(i);
- Cons = mycouple.Constraint();
- myindex = mycouple.Index();
- if (myindex == LastPoint) {
+ Cons = mycouple.Constraint();
+ myindex = mycouple.Index();
+ if (myindex == LastPoint)
+ {
break;
}
}
return Cons;
}
-
-
-
-Standard_Boolean AppParCurves_Function::Value (const math_Vector& X,
- Standard_Real& F) {
+Standard_Boolean AppParCurves_Function::Value(const math_Vector& X, Standard_Real& F)
+{
myParameters = X;
// Resolution moindres carres:
// ===========================
MyLeastSquare.Perform(myParameters);
- if (!(MyLeastSquare.IsDone())) {
+ if (!(MyLeastSquare.IsDone()))
+ {
Done = Standard_False;
return Standard_False;
}
- if (!Contraintes) {
+ if (!Contraintes)
+ {
MyLeastSquare.Error(FVal, ERR3d, ERR2d);
F = FVal;
}
// Resolution avec contraintes:
// ============================
- else {
- Standard_Integer Npol = Degre+1;
-// Standard_Boolean Ext = Standard_True;
+ else
+ {
+ Standard_Integer Npol = Degre + 1;
+ // Standard_Boolean Ext = Standard_True;
Standard_Integer Ci, i, j, dimen;
- Standard_Real AA, BB, CC, AIJ, FX, FY, FZ, Fi;
- math_Vector PTCXCI(1, Npol), PTCYCI(1, Npol), PTCZCI(1, Npol);
+ Standard_Real AA, BB, CC, AIJ, FX, FY, FZ, Fi;
+ math_Vector PTCXCI(1, Npol), PTCYCI(1, Npol), PTCZCI(1, Npol);
ERR3d = ERR2d = 0.0;
-
+
MyMultiCurve = MyLeastSquare.BezierValue();
A = MyLeastSquare.FunctionMatrix();
- ResolCons Resol(MyMultiLine, MyMultiCurve, FirstP, LastP, myConstraints,
- A, MyLeastSquare.DerivativeFunctionMatrix());
- if (!Resol.IsDone()) {
+ ResolCons Resol(MyMultiLine,
+ MyMultiCurve,
+ FirstP,
+ LastP,
+ myConstraints,
+ A,
+ MyLeastSquare.DerivativeFunctionMatrix());
+ if (!Resol.IsDone())
+ {
Done = Standard_False;
return Standard_False;
}
// Calcul de F = Sum||C(ui)-Ptli||2 sur toutes les courbes :
// ========================================================================
FVal = 0.0;
-
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- for (j = 1; j <= Npol; j++) {
- if (dimen == 3){
- MyMultiCurve.Value(j).Point(Ci).Coord(PTCXCI(j),PTCYCI(j),PTCZCI(j));
- }
- else{
- MyMultiCurve.Value(j).Point2d(Ci).Coord(PTCXCI(j), PTCYCI(j));
- }
+
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ for (j = 1; j <= Npol; j++)
+ {
+ if (dimen == 3)
+ {
+ MyMultiCurve.Value(j).Point(Ci).Coord(PTCXCI(j), PTCYCI(j), PTCZCI(j));
+ }
+ else
+ {
+ MyMultiCurve.Value(j).Point2d(Ci).Coord(PTCXCI(j), PTCYCI(j));
+ }
}
-
+
// Calcul de F:
// ============
- for (i = Adeb; i <= Afin; i++) {
- AA = 0.0; BB = 0.0; CC = 0.0;
- for (j = 1; j <= Npol; j++) {
- AIJ = A(i, j);
- AA += AIJ*PTCXCI(j);
- BB += AIJ*PTCYCI(j);
- if (dimen == 3) {
- CC += AIJ*PTCZCI(j);
- }
- }
- FX = AA-PTLX(i, Ci);
- FY = BB-PTLY(i, Ci);
- MyF(i,Ci) = FX*FX + FY*FY;
- if (dimen == 3) {
- FZ = CC-PTLZ(i,Ci);
- MyF(i, Ci) += FZ*FZ;
- Fi = MyF(i, Ci);
- if (Sqrt(Fi) > ERR3d) ERR3d = Sqrt(Fi);
- }
- else {
- Fi = MyF(i, Ci);
- if (Sqrt(Fi) > ERR2d) ERR2d = Sqrt(Fi);
- }
- FVal += Fi;
+ for (i = Adeb; i <= Afin; i++)
+ {
+ AA = 0.0;
+ BB = 0.0;
+ CC = 0.0;
+ for (j = 1; j <= Npol; j++)
+ {
+ AIJ = A(i, j);
+ AA += AIJ * PTCXCI(j);
+ BB += AIJ * PTCYCI(j);
+ if (dimen == 3)
+ {
+ CC += AIJ * PTCZCI(j);
+ }
+ }
+ FX = AA - PTLX(i, Ci);
+ FY = BB - PTLY(i, Ci);
+ MyF(i, Ci) = FX * FX + FY * FY;
+ if (dimen == 3)
+ {
+ FZ = CC - PTLZ(i, Ci);
+ MyF(i, Ci) += FZ * FZ;
+ Fi = MyF(i, Ci);
+ if (Sqrt(Fi) > ERR3d)
+ ERR3d = Sqrt(Fi);
+ }
+ else
+ {
+ Fi = MyF(i, Ci);
+ if (Sqrt(Fi) > ERR2d)
+ ERR2d = Sqrt(Fi);
+ }
+ FVal += Fi;
}
}
F = FVal;
- }
+ }
return Standard_True;
}
-
-
-
-void AppParCurves_Function::Perform(const math_Vector& X) {
+void AppParCurves_Function::Perform(const math_Vector& X)
+{
Standard_Integer j;
myParameters = X;
// ===========================
MyLeastSquare.Perform(myParameters);
- if (!(MyLeastSquare.IsDone())) {
+ if (!(MyLeastSquare.IsDone()))
+ {
Done = Standard_False;
return;
}
- for(j = myParameters.Lower(); j <= myParameters.Upper(); j++) {
+ for (j = myParameters.Lower(); j <= myParameters.Upper(); j++)
+ {
ValGrad_F(j) = 0.0;
}
- if (!Contraintes) {
+ if (!Contraintes)
+ {
MyLeastSquare.ErrorGradient(ValGrad_F, FVal, ERR3d, ERR2d);
}
- else {
- Standard_Integer Pi, Ci, i, k, dimen;
- Standard_Integer Npol = Degre+1;
- Standard_Real Scal, AA, BB, CC, DAA, DBB, DCC;
- Standard_Real FX, FY, FZ, AIJ, DAIJ, px, py, pz, Fi;
- AppParCurves_Constraint Cons=AppParCurves_NoConstraint;
- math_Matrix Grad_F(FirstP, LastP, 1, NbCu, 0.0);
- math_Vector PTCXCI(1, Npol), PTCYCI(1, Npol), PTCZCI(1, Npol);
- math_Vector PTCOXCI(1, Npol), PTCOYCI(1, Npol), PTCOZCI(1, Npol);
-// Standard_Boolean Ext = Standard_True;
+ else
+ {
+ Standard_Integer Pi, Ci, i, k, dimen;
+ Standard_Integer Npol = Degre + 1;
+ Standard_Real Scal, AA, BB, CC, DAA, DBB, DCC;
+ Standard_Real FX, FY, FZ, AIJ, DAIJ, px, py, pz, Fi;
+ AppParCurves_Constraint Cons = AppParCurves_NoConstraint;
+ math_Matrix Grad_F(FirstP, LastP, 1, NbCu, 0.0);
+ math_Vector PTCXCI(1, Npol), PTCYCI(1, Npol), PTCZCI(1, Npol);
+ math_Vector PTCOXCI(1, Npol), PTCOYCI(1, Npol), PTCOZCI(1, Npol);
+ // Standard_Boolean Ext = Standard_True;
ERR3d = ERR2d = 0.0;
- math_Matrix PTCOX(1, Npol, 1, NbCu), PTCOY(1, Npol, 1, NbCu),
- PTCOZ(1, Npol,1, NbCu);
- math_Matrix PTCX(1, Npol, 1, NbCu), PTCY(1, Npol, 1, NbCu),
- PTCZ(1, Npol,1, NbCu);
+ math_Matrix PTCOX(1, Npol, 1, NbCu), PTCOY(1, Npol, 1, NbCu), PTCOZ(1, Npol, 1, NbCu);
+ math_Matrix PTCX(1, Npol, 1, NbCu), PTCY(1, Npol, 1, NbCu), PTCZ(1, Npol, 1, NbCu);
Standard_Integer Inc;
MyMultiCurve = MyLeastSquare.BezierValue();
- for (Ci =1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- for (j = 1; j <= Npol; j++) {
- if (dimen == 3){
- MyMultiCurve.Value(j).Point(Ci).Coord(PTCOX(j, Ci),
- PTCOY(j, Ci),
- PTCOZ(j, Ci));
- }
- else{
- MyMultiCurve.Value(j).Point2d(Ci).Coord(PTCOX(j, Ci), PTCOY(j, Ci));
- PTCOZ(j, Ci) = 0.0;
- }
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ for (j = 1; j <= Npol; j++)
+ {
+ if (dimen == 3)
+ {
+ MyMultiCurve.Value(j).Point(Ci).Coord(PTCOX(j, Ci), PTCOY(j, Ci), PTCOZ(j, Ci));
+ }
+ else
+ {
+ MyMultiCurve.Value(j).Point2d(Ci).Coord(PTCOX(j, Ci), PTCOY(j, Ci));
+ PTCOZ(j, Ci) = 0.0;
+ }
}
}
- A = MyLeastSquare.FunctionMatrix();
+ A = MyLeastSquare.FunctionMatrix();
DA = MyLeastSquare.DerivativeFunctionMatrix();
-
+
// Resolution avec contraintes:
// ============================
-
- ResolCons Resol(MyMultiLine, MyMultiCurve, FirstP, LastP,
- myConstraints, A, DA);
- if (!Resol.IsDone()) {
+
+ ResolCons Resol(MyMultiLine, MyMultiCurve, FirstP, LastP, myConstraints, A, DA);
+ if (!Resol.IsDone())
+ {
Done = Standard_False;
return;
}
-
-
+
// Calcul de F = Sum||C(ui)-Ptli||2 et du gradient non contraint de F pour
// chaque point PointIndex.
// ========================================================================
FVal = 0.0;
- for(j = FirstP; j <= LastP; j++) {
+ for (j = FirstP; j <= LastP; j++)
+ {
ValGrad_F(j) = 0.0;
}
math_Matrix TrDA(DA.LowerCol(), DA.UpperCol(), DA.LowerRow(), DA.UpperRow());
math_Matrix RESTM(A.LowerCol(), A.UpperCol(), A.LowerCol(), A.UpperCol());
- const math_Matrix& K = Resol.ConstraintMatrix();
+ const math_Matrix& K = Resol.ConstraintMatrix();
const math_Matrix& DK = Resol.ConstraintDerivative(MyMultiLine, X, Degre, DA);
- math_Matrix TK(K.LowerCol(), K.UpperCol(), K.LowerRow(), K.UpperRow());
- TK = K.Transposed();
+ math_Matrix TK(K.LowerCol(), K.UpperCol(), K.LowerRow(), K.UpperRow());
+ TK = K.Transposed();
const math_Vector& Vardua = Resol.Duale();
- math_Matrix KK(K.LowerCol(), K.UpperCol(), Vardua.Lower(), Vardua.Upper());
- KK = (K.Transposed())*(Resol.InverseMatrix());
+ math_Matrix KK(K.LowerCol(), K.UpperCol(), Vardua.Lower(), Vardua.Upper());
+ KK = (K.Transposed()) * (Resol.InverseMatrix());
math_Matrix DTK(DK.LowerCol(), DK.UpperCol(), DK.LowerRow(), DK.UpperRow());
- DTK = DK.Transposed();
- TrA = A.Transposed();
- TrDA = DA.Transposed();
- RESTM = ((A.Transposed()*A).Inverse());
+ DTK = DK.Transposed();
+ TrA = A.Transposed();
+ TrDA = DA.Transposed();
+ RESTM = ((A.Transposed() * A).Inverse());
math_Vector DPTCO(1, K.ColNumber());
math_Matrix DPTCO1(FirstP, LastP, 1, K.ColNumber());
math_Vector DKPTC(1, K.RowNumber());
-
-
-
FVal = 0.0;
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- for (j = 1; j <= Npol; j++) {
- if (dimen == 3){
- MyMultiCurve.Value(j).Point(Ci).Coord(PTCX(j, Ci),
- PTCY(j, Ci),
- PTCZ(j, Ci));
- }
- else{
- MyMultiCurve.Value(j).Point2d(Ci).Coord(PTCX(j, Ci), PTCY(j,Ci));
- PTCZ(j, Ci) = 0.0;
- }
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ for (j = 1; j <= Npol; j++)
+ {
+ if (dimen == 3)
+ {
+ MyMultiCurve.Value(j).Point(Ci).Coord(PTCX(j, Ci), PTCY(j, Ci), PTCZ(j, Ci));
+ }
+ else
+ {
+ MyMultiCurve.Value(j).Point2d(Ci).Coord(PTCX(j, Ci), PTCY(j, Ci));
+ PTCZ(j, Ci) = 0.0;
+ }
}
}
-
// Calcul du gradient sans contraintes:
// ====================================
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- for (i = Adeb; i <= Afin; i++) {
- AA = 0.0; BB = 0.0; CC = 0.0; DAA = 0.0; DBB = 0.0; DCC = 0.0;
- for (j = 1; j <= Npol; j++) {
- AIJ = A(i, j); DAIJ = DA(i, j);
- px = PTCX(j, Ci); py = PTCY(j, Ci);
- AA += AIJ*px; BB += AIJ*py;
- DAA += DAIJ*px; DBB += DAIJ*py;
- if (dimen == 3) {
- pz = PTCZ(j, Ci);
- CC += AIJ*pz; DCC += DAIJ*pz;
- }
- }
- FX = AA-PTLX(i, Ci);
- FY = BB-PTLY(i, Ci);
- MyF(i,Ci) = FX*FX + FY*FY;
- Grad_F(i, Ci) = 2.0*(DAA*FX + DBB*FY);
- if (dimen == 3) {
- FZ = CC-PTLZ(i,Ci);
- MyF(i, Ci) += FZ*FZ;
- Grad_F(i, Ci) += 2.0*DCC*FZ;
- Fi = MyF(i, Ci);
- if (Sqrt(Fi) > ERR3d) ERR3d = Sqrt(Fi);
- }
- else {
- Fi = MyF(i, Ci);
- if (Sqrt(Fi) > ERR2d) ERR2d = Sqrt(Fi);
- }
- FVal += Fi;
- ValGrad_F(i) += Grad_F(i, Ci);
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ for (i = Adeb; i <= Afin; i++)
+ {
+ AA = 0.0;
+ BB = 0.0;
+ CC = 0.0;
+ DAA = 0.0;
+ DBB = 0.0;
+ DCC = 0.0;
+ for (j = 1; j <= Npol; j++)
+ {
+ AIJ = A(i, j);
+ DAIJ = DA(i, j);
+ px = PTCX(j, Ci);
+ py = PTCY(j, Ci);
+ AA += AIJ * px;
+ BB += AIJ * py;
+ DAA += DAIJ * px;
+ DBB += DAIJ * py;
+ if (dimen == 3)
+ {
+ pz = PTCZ(j, Ci);
+ CC += AIJ * pz;
+ DCC += DAIJ * pz;
+ }
+ }
+ FX = AA - PTLX(i, Ci);
+ FY = BB - PTLY(i, Ci);
+ MyF(i, Ci) = FX * FX + FY * FY;
+ Grad_F(i, Ci) = 2.0 * (DAA * FX + DBB * FY);
+ if (dimen == 3)
+ {
+ FZ = CC - PTLZ(i, Ci);
+ MyF(i, Ci) += FZ * FZ;
+ Grad_F(i, Ci) += 2.0 * DCC * FZ;
+ Fi = MyF(i, Ci);
+ if (Sqrt(Fi) > ERR3d)
+ ERR3d = Sqrt(Fi);
+ }
+ else
+ {
+ Fi = MyF(i, Ci);
+ if (Sqrt(Fi) > ERR2d)
+ ERR2d = Sqrt(Fi);
+ }
+ FVal += Fi;
+ ValGrad_F(i) += Grad_F(i, Ci);
}
}
-
// Calcul de DK*PTC:
// =================
- for (i = 1; i <= K.RowNumber(); i++) {
+ for (i = 1; i <= K.RowNumber(); i++)
+ {
Inc = 0;
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- DKPTC(i) = 0.0;
- for (j = 1; j <= Npol; j++) {
- DKPTC(i) += DK(i, j+Inc)*PTCX(j, Ci)+ DK(i, j+Inc+Npol)*PTCY(j, Ci);
- if (dimen == 3) {
- DKPTC(i) += DK(i, j+Inc+2*Npol)*PTCZ(j, Ci);
- }
- }
- if (dimen == 3) Inc = Inc +3*Npol;
- else Inc = Inc +2*Npol;
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ DKPTC(i) = 0.0;
+ for (j = 1; j <= Npol; j++)
+ {
+ DKPTC(i) += DK(i, j + Inc) * PTCX(j, Ci) + DK(i, j + Inc + Npol) * PTCY(j, Ci);
+ if (dimen == 3)
+ {
+ DKPTC(i) += DK(i, j + Inc + 2 * Npol) * PTCZ(j, Ci);
+ }
+ }
+ if (dimen == 3)
+ Inc = Inc + 3 * Npol;
+ else
+ Inc = Inc + 2 * Npol;
}
}
-
+
math_Vector DERR(DTK.LowerRow(), DTK.UpperRow());
- DERR = (DTK)*Vardua-KK* ((DKPTC) + K*(DTK)*Vardua);
+ DERR = (DTK)*Vardua - KK * ((DKPTC) + K * (DTK)*Vardua);
// rajout du gradient avec contraintes:
// ====================================
// dPTCO1/duk = [d(TA)/duk*[A*PTCO-PTL] + TA*dA/duk*PTCO]
-
Inc = 0;
math_Vector Errx(A.LowerRow(), A.UpperRow());
math_Vector TrDAPI(TrDA.LowerRow(), TrDA.UpperRow());
math_Vector TrAPI(TrA.LowerRow(), TrA.UpperRow());
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
PTCOXCI = PTCOX.Col(Ci);
PTCOYCI = PTCOY.Col(Ci);
PTCOZCI = PTCOZ.Col(Ci);
- PTCXCI = PTCX.Col(Ci);
- PTCYCI = PTCY.Col(Ci);
- PTCZCI = PTCZ.Col(Ci);
-
-
- Errx = (A*PTCOXCI - PTLX.Col(Ci));
- Erry = (A*PTCOYCI - PTLY.Col(Ci));
- Errz = (A*PTCOZCI - PTLZ.Col(Ci));
- Scalx = (DA*PTCOXCI); // Scal = DA * PTCO
- Scaly = (DA*PTCOYCI);
- Scalz = (DA*PTCOZCI);
+ PTCXCI = PTCX.Col(Ci);
+ PTCYCI = PTCY.Col(Ci);
+ PTCZCI = PTCZ.Col(Ci);
+
+ Errx = (A * PTCOXCI - PTLX.Col(Ci));
+ Erry = (A * PTCOYCI - PTLY.Col(Ci));
+ Errz = (A * PTCOZCI - PTLZ.Col(Ci));
+ Scalx = (DA * PTCOXCI); // Scal = DA * PTCO
+ Scaly = (DA * PTCOYCI);
+ Scalz = (DA * PTCOZCI);
Erruzax = (PTCXCI - PTCOXCI);
Erruzay = (PTCYCI - PTCOYCI);
Erruzaz = (PTCZCI - PTCOZCI);
-
- for (Pi = FirstP; Pi <= LastP; Pi++) {
- TrDAPI = (TrDA.Col(Pi));
- TrAPI = (TrA.Col(Pi));
- Standard_Real Taa = TrAPI*A.Row(Pi);
- Scal = 0.0;
- for (j = 1; j <= Npol; j++) {
- DPTCO1(Pi, j + Inc) = (TrDAPI*Errx(Pi)+TrAPI*Scalx(Pi))(j);
- DPTCO1(Pi, j + Inc+ Npol) = (TrDAPI*Erry(Pi)+TrAPI*Scaly(Pi))(j);
- Scal += DPTCO1(Pi, j+Inc)* Taa*Erruzax(j) + DPTCO1(Pi, j+Inc+Npol)*Taa*Erruzay(j);
- if (dimen == 3) {
- DPTCO1(Pi, j + Inc+ 2*Npol) = (TrDAPI*Errz(Pi)+TrAPI*Scalz(Pi))(j);
- Scal += DPTCO1(Pi, j+Inc+2*Npol)*Taa*Erruzaz(j);
- }
- }
- ValGrad_F(Pi) = ValGrad_F(Pi) - 2*Scal;
+
+ for (Pi = FirstP; Pi <= LastP; Pi++)
+ {
+ TrDAPI = (TrDA.Col(Pi));
+ TrAPI = (TrA.Col(Pi));
+ Standard_Real Taa = TrAPI * A.Row(Pi);
+ Scal = 0.0;
+ for (j = 1; j <= Npol; j++)
+ {
+ DPTCO1(Pi, j + Inc) = (TrDAPI * Errx(Pi) + TrAPI * Scalx(Pi))(j);
+ DPTCO1(Pi, j + Inc + Npol) = (TrDAPI * Erry(Pi) + TrAPI * Scaly(Pi))(j);
+ Scal +=
+ DPTCO1(Pi, j + Inc) * Taa * Erruzax(j) + DPTCO1(Pi, j + Inc + Npol) * Taa * Erruzay(j);
+ if (dimen == 3)
+ {
+ DPTCO1(Pi, j + Inc + 2 * Npol) = (TrDAPI * Errz(Pi) + TrAPI * Scalz(Pi))(j);
+ Scal += DPTCO1(Pi, j + Inc + 2 * Npol) * Taa * Erruzaz(j);
+ }
+ }
+ ValGrad_F(Pi) = ValGrad_F(Pi) - 2 * Scal;
}
- if (dimen == 3) Inc = Inc + 3*Npol;
- else Inc = Inc +2*Npol;
+ if (dimen == 3)
+ Inc = Inc + 3 * Npol;
+ else
+ Inc = Inc + 2 * Npol;
}
-
// on calcule DPTCO = - RESTM * DPTCO1:
-
+
// Calcul de DPTCO/duk:
// dPTCO/duk = -Inv(T(A)*A)*[d(TA)/duk*[A*PTCO-PTL] + TA*dA/duk*PTCO]
- Standard_Integer low=myConstraints->Lower(), upp=myConstraints->Upper();
+ Standard_Integer low = myConstraints->Lower(), upp = myConstraints->Upper();
Inc = 0;
- for (Pi = FirstP; Pi <= LastP; Pi++) {
- for (i = low; i <= upp; i++) {
- if (myConstraints->Value(i).Index() == Pi) {
- Cons = myConstraints->Value(i).Constraint();
- break;
- }
+ for (Pi = FirstP; Pi <= LastP; Pi++)
+ {
+ for (i = low; i <= upp; i++)
+ {
+ if (myConstraints->Value(i).Index() == Pi)
+ {
+ Cons = myConstraints->Value(i).Constraint();
+ break;
+ }
}
- if (Cons >= 1) {
- Inc = 0;
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- for (j = 1; j <= Npol; j++) {
- DPTCO(j+Inc) = 0.0;
- DPTCO(j+Inc+Npol) = 0.0;
- if (dimen == 3) DPTCO(j+Inc+2*Npol) = 0.0;
- for (k = 1; k <= Npol; k++) {
- DPTCO(j+Inc) = DPTCO(j+Inc) -RESTM(j, k) * DPTCO1(Pi, j+Inc);
- DPTCO(j+Inc+Npol)=DPTCO(j+Inc+Npol)-RESTM(j, k)*DPTCO1(Pi,j+Inc+Npol);
- if (dimen == 3) {
- DPTCO(j+Inc+2*Npol) = DPTCO(j+Inc+2*Npol)
- -RESTM(j, k) * DPTCO1(Pi, j+Inc+2*Npol);
- }
- }
- }
- if (dimen == 3) Inc += 3*Npol;
- else Inc += 2*Npol;
- }
-
- DERR = DERR-KK*K*DPTCO;
-
- Inc = 0;
- for (Ci = 1; Ci <= NbCu; Ci++) {
- dimen = tabdim->Value(Ci-1);
- PTCOXCI = PTCOX.Col(Ci);
- PTCOYCI = PTCOY.Col(Ci);
- PTCOZCI = PTCOZ.Col(Ci);
- PTCXCI = PTCX.Col(Ci);
- PTCYCI = PTCY.Col(Ci);
- PTCZCI = PTCZ.Col(Ci);
- Erruzax = (PTCXCI - PTCOXCI);
- Erruzay = (PTCYCI - PTCOYCI);
- Erruzaz = (PTCZCI - PTCOZCI);
- Scal = 0.0;
-
- for (j = 1; j <= Npol ; j++) {
- Scal = (A(Pi, j)*Erruzax(j)) * (A(Pi, j)*DERR(j+Inc)) +
- (A(Pi, j)*Erruzay(j)) * (A(Pi, j)*DERR(j+Inc+Npol));
- if (dimen == 3) {
- Scal += (A(Pi, j)*Erruzax(j)) * (A(Pi, j)*DERR(j+Inc+2*Npol));
- }
- }
-
- ValGrad_F(Pi) = ValGrad_F(Pi) + 2*Scal;
- if (dimen == 3) Inc = Inc +3*Npol;
- else Inc = Inc + 2*Npol;
- }
+ if (Cons >= 1)
+ {
+ Inc = 0;
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ for (j = 1; j <= Npol; j++)
+ {
+ DPTCO(j + Inc) = 0.0;
+ DPTCO(j + Inc + Npol) = 0.0;
+ if (dimen == 3)
+ DPTCO(j + Inc + 2 * Npol) = 0.0;
+ for (k = 1; k <= Npol; k++)
+ {
+ DPTCO(j + Inc) = DPTCO(j + Inc) - RESTM(j, k) * DPTCO1(Pi, j + Inc);
+ DPTCO(j + Inc + Npol) =
+ DPTCO(j + Inc + Npol) - RESTM(j, k) * DPTCO1(Pi, j + Inc + Npol);
+ if (dimen == 3)
+ {
+ DPTCO(j + Inc + 2 * Npol) =
+ DPTCO(j + Inc + 2 * Npol) - RESTM(j, k) * DPTCO1(Pi, j + Inc + 2 * Npol);
+ }
+ }
+ }
+ if (dimen == 3)
+ Inc += 3 * Npol;
+ else
+ Inc += 2 * Npol;
+ }
+
+ DERR = DERR - KK * K * DPTCO;
+
+ Inc = 0;
+ for (Ci = 1; Ci <= NbCu; Ci++)
+ {
+ dimen = tabdim->Value(Ci - 1);
+ PTCOXCI = PTCOX.Col(Ci);
+ PTCOYCI = PTCOY.Col(Ci);
+ PTCOZCI = PTCOZ.Col(Ci);
+ PTCXCI = PTCX.Col(Ci);
+ PTCYCI = PTCY.Col(Ci);
+ PTCZCI = PTCZ.Col(Ci);
+ Erruzax = (PTCXCI - PTCOXCI);
+ Erruzay = (PTCYCI - PTCOYCI);
+ Erruzaz = (PTCZCI - PTCOZCI);
+ Scal = 0.0;
+
+ for (j = 1; j <= Npol; j++)
+ {
+ Scal = (A(Pi, j) * Erruzax(j)) * (A(Pi, j) * DERR(j + Inc))
+ + (A(Pi, j) * Erruzay(j)) * (A(Pi, j) * DERR(j + Inc + Npol));
+ if (dimen == 3)
+ {
+ Scal += (A(Pi, j) * Erruzax(j)) * (A(Pi, j) * DERR(j + Inc + 2 * Npol));
+ }
+ }
+
+ ValGrad_F(Pi) = ValGrad_F(Pi) + 2 * Scal;
+ if (dimen == 3)
+ Inc = Inc + 3 * Npol;
+ else
+ Inc = Inc + 2 * Npol;
+ }
}
}
-
}
}
-
-Standard_Integer AppParCurves_Function::NbVariables() const{
+Standard_Integer AppParCurves_Function::NbVariables() const
+{
return NbP;
}
-
-Standard_Boolean AppParCurves_Function::Gradient (const math_Vector& X,
- math_Vector& G) {
+Standard_Boolean AppParCurves_Function::Gradient(const math_Vector& X, math_Vector& G)
+{
Perform(X);
G = ValGrad_F;
return Standard_True;
}
-
-Standard_Boolean AppParCurves_Function::Values (const math_Vector& X,
- Standard_Real& F,
- math_Vector& G) {
-
+Standard_Boolean AppParCurves_Function::Values(const math_Vector& X,
+ Standard_Real& F,
+ math_Vector& G)
+{
Perform(X);
F = FVal;
return Standard_True;
}
-
-const AppParCurves_MultiCurve& AppParCurves_Function::CurveValue() {
- if (!Contraintes) MyMultiCurve = MyLeastSquare.BezierValue();
+const AppParCurves_MultiCurve& AppParCurves_Function::CurveValue()
+{
+ if (!Contraintes)
+ MyMultiCurve = MyLeastSquare.BezierValue();
return MyMultiCurve;
}
-
Standard_Real AppParCurves_Function::Error(const Standard_Integer IPoint,
- const Standard_Integer CurveIndex) const {
+ const Standard_Integer CurveIndex) const
+{
return Sqrt(MyF(IPoint, CurveIndex));
}
return ERR2d;
}
-
-
const math_Vector& AppParCurves_Function::NewParameters() const
{
return myParameters;
// lpa, le 11/09/91
-
-// Application de la methode du gradient corrige pour minimiser
+// Application de la methode du gradient corrige pour minimiser
// F = somme(||C(ui, Poles(ui)) - ptli||2.
-// La methode de gradient conjugue est programmee dans la bibliotheque
+// La methode de gradient conjugue est programmee dans la bibliotheque
// mathematique: math_BFGS.
-// cet algorithme doit etre appele uniquement lorsque on a affaire a un set
-// de points contraints (ailleurs qu aux extremites). En effet, l appel de la
+// cet algorithme doit etre appele uniquement lorsque on a affaire a un set
+// de points contraints (ailleurs qu aux extremites). En effet, l appel de la
// fonction F a minimiser implique un appel a ParLeastSquare et ResConstraint.
-// Si ce n est pas le cas, l appel a ResConstraint est equivalent a une
+// Si ce n est pas le cas, l appel a ResConstraint est equivalent a une
// seconde resolution par les moindres carres donc beaucoup de temps perdu.
-
#define No_Standard_RangeError
#define No_Standard_OutOfRange
// #define AppParCurves_Gradient_BFGS BFGS_/**/AppParCurves_Gradient
-
-
-AppParCurves_Gradient::
- AppParCurves_Gradient(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- math_Vector& Parameters,
- const Standard_Integer Deg,
- const Standard_Real Tol3d,
- const Standard_Real Tol2d,
- const Standard_Integer NbIterations):
- ParError(FirstPoint, LastPoint,0.0),
- AvError(0.0),
- MError3d(0.0),
- MError2d(0.0)
+AppParCurves_Gradient::AppParCurves_Gradient(
+ const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ math_Vector& Parameters,
+ const Standard_Integer Deg,
+ const Standard_Real Tol3d,
+ const Standard_Real Tol2d,
+ const Standard_Integer NbIterations)
+ : ParError(FirstPoint, LastPoint, 0.0),
+ AvError(0.0),
+ MError3d(0.0),
+ MError2d(0.0)
{
-// Standard_Boolean grad = Standard_True;
+ // Standard_Boolean grad = Standard_True;
Standard_Integer j, k, i2, l;
- Standard_Real UF, DU, Fval = 0.0, FU, DFU;
- Standard_Integer nbP3d = ToolLine::NbP3d(SSP);
- Standard_Integer nbP2d = ToolLine::NbP2d(SSP);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
+ Standard_Real UF, DU, Fval = 0.0, FU, DFU;
+ Standard_Integer nbP3d = ToolLine::NbP3d(SSP);
+ Standard_Integer nbP2d = ToolLine::NbP2d(SSP);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
Standard_Integer nbP = nbP3d + nbP2d;
-// gp_Pnt Pt, P1, P2;
+ // gp_Pnt Pt, P1, P2;
gp_Pnt Pt;
-// gp_Pnt2d Pt2d, P12d, P22d;
+ // gp_Pnt2d Pt2d, P12d, P22d;
gp_Pnt2d Pt2d;
-// gp_Vec V1, V2, MyV;
+ // gp_Vec V1, V2, MyV;
gp_Vec V1, MyV;
-// gp_Vec2d V12d, V22d, MyV2d;
+ // gp_Vec2d V12d, V22d, MyV2d;
gp_Vec2d V12d, MyV2d;
Done = Standard_False;
-
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- TColgp_Array1OfPnt TabP(1, mynbP3d);
+
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ TColgp_Array1OfPnt TabP(1, mynbP3d);
TColgp_Array1OfPnt2d TabP2d(1, mynbP2d);
- TColgp_Array1OfVec TabV(1, mynbP3d);
+ TColgp_Array1OfVec TabV(1, mynbP3d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
// Calcul de la fonction F= somme(||C(ui)-Ptli||2):
// pour calculer F et grad_F.
// ================================================================
- AppParCurves_ParFunction MyF(SSP, FirstPoint,LastPoint, TheConstraints, Parameters, Deg);
-
+ AppParCurves_ParFunction MyF(SSP, FirstPoint, LastPoint, TheConstraints, Parameters, Deg);
- if (!MyF.Value(Parameters, Fval)) {
+ if (!MyF.Value(Parameters, Fval))
+ {
Done = Standard_False;
return;
}
- SCU = MyF.CurveValue();
- Standard_Integer deg = SCU.NbPoles()-1;
- TColgp_Array1OfPnt TabPole(1, deg+1), TabCoef(1, deg+1);
- TColgp_Array1OfPnt2d TabPole2d(1, deg+1), TabCoef2d(1, deg+1);
- TColgp_Array1OfPnt TheCoef(1, (deg+1)*mynbP3d);
- TColgp_Array1OfPnt2d TheCoef2d(1, (deg+1)*mynbP2d);
+ SCU = MyF.CurveValue();
+ Standard_Integer deg = SCU.NbPoles() - 1;
+ TColgp_Array1OfPnt TabPole(1, deg + 1), TabCoef(1, deg + 1);
+ TColgp_Array1OfPnt2d TabPole2d(1, deg + 1), TabCoef2d(1, deg + 1);
+ TColgp_Array1OfPnt TheCoef(1, (deg + 1) * mynbP3d);
+ TColgp_Array1OfPnt2d TheCoef2d(1, (deg + 1) * mynbP2d);
-
// Stockage des Poles des courbes pour projeter:
// ============================================
i2 = 0;
- for (k = 1; k <= nbP3d; k++) {
+ for (k = 1; k <= nbP3d; k++)
+ {
SCU.Curve(k, TabPole);
- BSplCLib::PolesCoefficients(TabPole, PLib::NoWeights(),
- TabCoef, PLib::NoWeights());
- for (j=1; j<=deg+1; j++) TheCoef(j+i2) = TabCoef(j);
- i2 += deg+1;
+ BSplCLib::PolesCoefficients(TabPole, PLib::NoWeights(), TabCoef, PLib::NoWeights());
+ for (j = 1; j <= deg + 1; j++)
+ TheCoef(j + i2) = TabCoef(j);
+ i2 += deg + 1;
}
i2 = 0;
- for (k = 1; k <= nbP2d; k++) {
- SCU.Curve(nbP3d+k, TabPole2d);
- BSplCLib::PolesCoefficients(TabPole2d, PLib::NoWeights(),
- TabCoef2d, PLib::NoWeights());
- for (j=1; j<=deg+1; j++) TheCoef2d(j+i2) = TabCoef2d(j);
- i2 += deg+1;
+ for (k = 1; k <= nbP2d; k++)
+ {
+ SCU.Curve(nbP3d + k, TabPole2d);
+ BSplCLib::PolesCoefficients(TabPole2d, PLib::NoWeights(), TabCoef2d, PLib::NoWeights());
+ for (j = 1; j <= deg + 1; j++)
+ TheCoef2d(j + i2) = TabCoef2d(j);
+ i2 += deg + 1;
}
- // Une iteration rapide de projection est faite par la methode de
+ // Une iteration rapide de projection est faite par la methode de
// Rogers & Fog 89, methode equivalente a Hoschek 88 qui ne necessite pas
// le calcul de D2.
-
// Iteration de Projection:
// =======================
- for (j = FirstPoint+1; j <= LastPoint-1; j++) {
+ for (j = FirstPoint + 1; j <= LastPoint - 1; j++)
+ {
UF = Parameters(j);
- if (nbP != 0 && nbP2d != 0) ToolLine::Value(SSP, j, TabP, TabP2d);
- else if (nbP2d != 0) ToolLine::Value(SSP, j, TabP2d);
- else ToolLine::Value(SSP, j, TabP);
-
- FU = 0.0;
+ if (nbP != 0 && nbP2d != 0)
+ ToolLine::Value(SSP, j, TabP, TabP2d);
+ else if (nbP2d != 0)
+ ToolLine::Value(SSP, j, TabP2d);
+ else
+ ToolLine::Value(SSP, j, TabP);
+
+ FU = 0.0;
DFU = 0.0;
- i2 = 0;
- for (k = 1; k <= nbP3d; k++) {
- for (l=1; l<=deg+1; l++) TabCoef(l) = TheCoef(l+i2);
- i2 += deg+1;
+ i2 = 0;
+ for (k = 1; k <= nbP3d; k++)
+ {
+ for (l = 1; l <= deg + 1; l++)
+ TabCoef(l) = TheCoef(l + i2);
+ i2 += deg + 1;
BSplCLib::CoefsD1(UF, TabCoef, BSplCLib::NoWeights(), Pt, V1);
MyV = gp_Vec(Pt, TabP(k));
- FU += MyV*V1;
+ FU += MyV * V1;
DFU += V1.SquareMagnitude();
}
i2 = 0;
- for (k = 1; k <= nbP2d; k++) {
- for (l=1; l<=deg+1; l++) TabCoef2d(l) = TheCoef2d(l+i2);
- i2 += deg+1;
+ for (k = 1; k <= nbP2d; k++)
+ {
+ for (l = 1; l <= deg + 1; l++)
+ TabCoef2d(l) = TheCoef2d(l + i2);
+ i2 += deg + 1;
BSplCLib::CoefsD1(UF, TabCoef2d, BSplCLib::NoWeights(), Pt2d, V12d);
MyV2d = gp_Vec2d(Pt2d, TabP2d(k));
- FU += MyV2d*V12d;
+ FU += MyV2d * V12d;
DFU += V12d.SquareMagnitude();
}
-
- if (DFU >= RealEpsilon()) {
- DU = FU/DFU;
+
+ if (DFU >= RealEpsilon())
+ {
+ DU = FU / DFU;
DU = Sign(Min(5.e-02, Abs(DU)), DU);
UF += DU;
Parameters(j) = UF;
}
}
-
- if (!MyF.Value(Parameters, Fval)) {
- SCU = AppParCurves_MultiCurve();
+ if (!MyF.Value(Parameters, Fval))
+ {
+ SCU = AppParCurves_MultiCurve();
Done = Standard_False;
return;
}
MError3d = MyF.MaxError3d();
MError2d = MyF.MaxError2d();
-
- if (MError3d<= Tol3d && MError2d <= Tol2d) {
+
+ if (MError3d <= Tol3d && MError2d <= Tol2d)
+ {
Done = Standard_True;
- SCU = MyF.CurveValue();
+ SCU = MyF.CurveValue();
}
- else if (NbIterations != 0) {
+ else if (NbIterations != 0)
+ {
// NbIterations de gradient conjugue:
// =================================
- Standard_Real Eps = 1.e-07;
+ Standard_Real Eps = 1.e-07;
AppParCurves_Gradient_BFGS FResol(MyF, Parameters, Tol3d, Tol2d, Eps, NbIterations);
Parameters = MyF.NewParameters();
- SCU = MyF.CurveValue();
+ SCU = MyF.CurveValue();
}
-
AvError = 0.;
- for (j = FirstPoint; j <= LastPoint; j++) {
+ for (j = FirstPoint; j <= LastPoint; j++)
+ {
// Recherche des erreurs maxi et moyenne a un index donne:
- for (k = 1; k <= nbP; k++) {
+ for (k = 1; k <= nbP; k++)
+ {
ParError(j) = Max(ParError(j), MyF.Error(j, k));
}
AvError += ParError(j);
}
- AvError = AvError/(LastPoint-FirstPoint+1);
-
+ AvError = AvError / (LastPoint - FirstPoint + 1);
MError3d = MyF.MaxError3d();
MError2d = MyF.MaxError2d();
- if (MError3d <= Tol3d && MError2d <= Tol2d) {
+ if (MError3d <= Tol3d && MError2d <= Tol2d)
+ {
Done = Standard_True;
}
-
}
-
-
-AppParCurves_MultiCurve AppParCurves_Gradient::Value() const {
+AppParCurves_MultiCurve AppParCurves_Gradient::Value() const
+{
return SCU;
}
-
-Standard_Boolean AppParCurves_Gradient::IsDone() const {
+Standard_Boolean AppParCurves_Gradient::IsDone() const
+{
return Done;
}
-
-Standard_Real AppParCurves_Gradient::Error(const Standard_Integer Index) const {
+Standard_Real AppParCurves_Gradient::Error(const Standard_Integer Index) const
+{
return ParError(Index);
}
-Standard_Real AppParCurves_Gradient::AverageError() const {
+Standard_Real AppParCurves_Gradient::AverageError() const
+{
return AvError;
}
-Standard_Real AppParCurves_Gradient::MaxError3d() const {
+Standard_Real AppParCurves_Gradient::MaxError3d() const
+{
return MError3d;
}
-Standard_Real AppParCurves_Gradient::MaxError2d() const {
+Standard_Real AppParCurves_Gradient::MaxError2d() const
+{
return MError2d;
}
-
-
// Redefinition de math_BFGS:
// ==========================
-
AppParCurves_Gradient_BFGS::AppParCurves_Gradient_BFGS(math_MultipleVarFunctionWithGradient& F,
- const math_Vector& StartingPoint,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Real Eps,
- const Standard_Integer NbIterations ):
- math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
- myTol3d(Tolerance3d),
- myTol2d(Tolerance2d)
+ const math_Vector& StartingPoint,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Real Eps,
+ const Standard_Integer NbIterations)
+ : math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
+ myTol3d(Tolerance3d),
+ myTol2d(Tolerance2d)
{
Perform(F, StartingPoint);
}
-Standard_Boolean AppParCurves_Gradient_BFGS::IsSolutionReached(math_MultipleVarFunctionWithGradient& F) const
+Standard_Boolean AppParCurves_Gradient_BFGS::IsSolutionReached(
+ math_MultipleVarFunctionWithGradient& F) const
{
- AppParCurves_ParFunction *F1 = (AppParCurves_ParFunction*) &F;
- Standard_Boolean Result, Result2;
-
- Result = (2.0 * fabs(TheMinimum - PreviousMinimum) <=
- 1.e-10 * (fabs(TheMinimum) + fabs(PreviousMinimum))+1.e-12);
- Standard_Real MErr3d = F1->MaxError3d();
- Standard_Real MErr2d = F1->MaxError2d();
-
- Result2 = ((MErr3d <= myTol3d) && (MErr2d <= myTol2d));
- return (Result || Result2);
- }
+ AppParCurves_ParFunction* F1 = (AppParCurves_ParFunction*)&F;
+ Standard_Boolean Result, Result2;
+ Result = (2.0 * fabs(TheMinimum - PreviousMinimum)
+ <= 1.e-10 * (fabs(TheMinimum) + fabs(PreviousMinimum)) + 1.e-12);
+ Standard_Real MErr3d = F1->MaxError3d();
+ Standard_Real MErr2d = F1->MaxError2d();
+ Result2 = ((MErr3d <= myTol3d) && (MErr2d <= myTol2d));
+ return (Result || Result2);
+}
// Ce programme utilise les moindres carres pour le cas suivant:
// passage et tangences aux extremites.
-
#define No_Standard_RangeError
#define No_Standard_OutOfRange
#define No_Standard_DimensionError
#include <math_Recipes.hxx>
#include <math_Crout.hxx>
+static int FlatLength(const TColStd_Array1OfInteger& Mults)
+{
-
-static int FlatLength(const TColStd_Array1OfInteger& Mults) {
-
Standard_Integer sum = 0;
- for (Standard_Integer i = Mults.Lower(); i <= Mults.Upper(); i++) {
+ for (Standard_Integer i = Mults.Lower(); i <= Mults.Upper(); i++)
+ {
sum += Mults.Value(i);
}
return sum;
}
//=======================================================================
-//function : CheckTangents
-//purpose : Checks if theArrTg3d and theArrTg2d have direction
+// function : CheckTangents
+// purpose : Checks if theArrTg3d and theArrTg2d have direction
// corresponded to the direction between theArrPt1 and theArrPt2.
// If it is not then reverses tangent vectors.
// theArrPt1 (as same as theArrPt2) is sub-set of all 3D-points in
// one multy-point (multy-point is union of sets of 2D- and 3D-points).
//
-//ATTENTION!!!
+// ATTENTION!!!
// The property of correlation between Tg3d and Tg2d is used here.
// Therefore, only 3D-coinciding is checked.
//=======================================================================
static void CheckTangents(const TColgp_Array1OfPnt& theArrPt1,
const TColgp_Array1OfPnt& theArrPt2,
- TColgp_Array1OfVec& theArrTg3d,
- TColgp_Array1OfVec2d& theArrTg2d)
+ TColgp_Array1OfVec& theArrTg3d,
+ TColgp_Array1OfVec2d& theArrTg2d)
{
- if(theArrPt1.Lower() != theArrPt2.Lower())
+ if (theArrPt1.Lower() != theArrPt2.Lower())
return;
- if(theArrPt1.Upper() != theArrPt2.Upper())
+ if (theArrPt1.Upper() != theArrPt2.Upper())
return;
- if(theArrTg3d.Length() != theArrPt1.Length())
+ if (theArrTg3d.Length() != theArrPt1.Length())
return;
Standard_Boolean isToChangeDir = Standard_False;
- for(Standard_Integer i = theArrPt1.Lower(); i <= theArrPt1.Upper(); i++)
+ for (Standard_Integer i = theArrPt1.Lower(); i <= theArrPt1.Upper(); i++)
{
- const gp_Vec aV1(theArrPt1(i), theArrPt2(i));
+ const gp_Vec aV1(theArrPt1(i), theArrPt2(i));
const gp_Vec& aV2 = theArrTg3d(i);
- if(aV1.Dot(aV2) < 0.0)
+ if (aV1.Dot(aV2) < 0.0)
{
isToChangeDir = Standard_True;
break;
}
}
- if(!isToChangeDir)
+ if (!isToChangeDir)
return;
- //Change directions for every 2D- and 3D-tangents
+ // Change directions for every 2D- and 3D-tangents
- for(Standard_Integer i = theArrTg3d.Lower(); i <= theArrTg3d.Upper(); i++)
+ for (Standard_Integer i = theArrTg3d.Lower(); i <= theArrTg3d.Upper(); i++)
{
theArrTg3d(i).Reverse();
}
- for(Standard_Integer i = theArrTg2d.Lower(); i <= theArrTg2d.Upper(); i++)
+ for (Standard_Integer i = theArrTg2d.Lower(); i <= theArrTg2d.Upper(); i++)
{
theArrTg2d(i).Reverse();
}
}
//=======================================================================
-//function : CheckTangents
-//purpose : Checks if theArrTg2d have direction
+// function : CheckTangents
+// purpose : Checks if theArrTg2d have direction
// corresponded to the direction between theArrPt1 and theArrPt2.
// If it is not then reverses tangent vector.
// theArrPt1 (as same as theArrPt2) is sub-set of all 2D-points in
//=======================================================================
static void CheckTangents(const TColgp_Array1OfPnt2d& theArrPt1,
const TColgp_Array1OfPnt2d& theArrPt2,
- TColgp_Array1OfVec2d& theArrTg2d)
+ TColgp_Array1OfVec2d& theArrTg2d)
{
- if(theArrPt1.Lower() != theArrPt2.Lower())
+ if (theArrPt1.Lower() != theArrPt2.Lower())
return;
- if(theArrPt1.Upper() != theArrPt2.Upper())
+ if (theArrPt1.Upper() != theArrPt2.Upper())
return;
- for(Standard_Integer i = theArrPt1.Lower(); i <= theArrPt1.Upper(); i++)
+ for (Standard_Integer i = theArrPt1.Lower(); i <= theArrPt1.Upper(); i++)
{
const gp_Vec2d aV1(theArrPt1(i), theArrPt2(i));
const gp_Vec2d& aV2 = theArrTg2d(i);
- if(aV1.Dot(aV2) < 0.0)
+ if (aV1.Dot(aV2) < 0.0)
{
theArrTg2d(i).Reverse();
}
}
}
-
-AppParCurves_LeastSquare::
- AppParCurves_LeastSquare(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const AppParCurves_Constraint FirstCons,
- const AppParCurves_Constraint LastCons,
- const math_Vector& Parameters,
- const Standard_Integer NbPol):
- SCU(NbPol),
- mypoles(1, NbPol,
- 1, NbBColumns(SSP)),
- A(FirstPoint, LastPoint, 1, NbPol),
- DA(FirstPoint, LastPoint, 1, NbPol),
- B2(TheFirstPoint(FirstCons, FirstPoint),
- Max(TheFirstPoint(FirstCons, FirstPoint),
- TheLastPoint(LastCons, LastPoint)),
- 1, NbBColumns(SSP)),
- mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
- Vflatknots(1, 1),
- Vec1t(1, NbBColumns(SSP)),
- Vec1c(1, NbBColumns(SSP)),
- Vec2t(1, NbBColumns(SSP)),
- Vec2c(1, NbBColumns(SSP)),
- theError(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- myindex(FirstPoint, LastPoint, 0),
- nbpoles(NbPol)
+AppParCurves_LeastSquare::AppParCurves_LeastSquare(const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const AppParCurves_Constraint FirstCons,
+ const AppParCurves_Constraint LastCons,
+ const math_Vector& Parameters,
+ const Standard_Integer NbPol)
+ : SCU(NbPol),
+ mypoles(1, NbPol, 1, NbBColumns(SSP)),
+ A(FirstPoint, LastPoint, 1, NbPol),
+ DA(FirstPoint, LastPoint, 1, NbPol),
+ B2(TheFirstPoint(FirstCons, FirstPoint),
+ Max(TheFirstPoint(FirstCons, FirstPoint), TheLastPoint(LastCons, LastPoint)),
+ 1,
+ NbBColumns(SSP)),
+ mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
+ Vflatknots(1, 1),
+ Vec1t(1, NbBColumns(SSP)),
+ Vec1c(1, NbBColumns(SSP)),
+ Vec2t(1, NbBColumns(SSP)),
+ Vec2c(1, NbBColumns(SSP)),
+ theError(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ myindex(FirstPoint, LastPoint, 0),
+ nbpoles(NbPol)
{
- FirstConstraint = FirstCons;
+ FirstConstraint = FirstCons;
LastConstraint = LastCons;
Init(SSP, FirstPoint, LastPoint);
- Perform(Parameters);
+ Perform(Parameters);
}
-
-
-AppParCurves_LeastSquare::
- AppParCurves_LeastSquare(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const AppParCurves_Constraint FirstCons,
- const AppParCurves_Constraint LastCons,
- const Standard_Integer NbPol):
- SCU(NbPol),
- mypoles(1, NbPol,
- 1, NbBColumns(SSP)),
- A(FirstPoint, LastPoint, 1, NbPol),
- DA(FirstPoint, LastPoint, 1, NbPol),
- B2(TheFirstPoint(FirstCons, FirstPoint),
- Max(TheFirstPoint(FirstCons, FirstPoint),
- TheLastPoint(LastCons, LastPoint)),
- 1, NbBColumns(SSP)),
- mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
- Vflatknots(1, 1),
- Vec1t(1, NbBColumns(SSP)),
- Vec1c(1, NbBColumns(SSP)),
- Vec2t(1, NbBColumns(SSP)),
- Vec2c(1, NbBColumns(SSP)),
- theError(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- myindex(FirstPoint, LastPoint, 0),
- nbpoles(NbPol)
+AppParCurves_LeastSquare::AppParCurves_LeastSquare(const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const AppParCurves_Constraint FirstCons,
+ const AppParCurves_Constraint LastCons,
+ const Standard_Integer NbPol)
+ : SCU(NbPol),
+ mypoles(1, NbPol, 1, NbBColumns(SSP)),
+ A(FirstPoint, LastPoint, 1, NbPol),
+ DA(FirstPoint, LastPoint, 1, NbPol),
+ B2(TheFirstPoint(FirstCons, FirstPoint),
+ Max(TheFirstPoint(FirstCons, FirstPoint), TheLastPoint(LastCons, LastPoint)),
+ 1,
+ NbBColumns(SSP)),
+ mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
+ Vflatknots(1, 1),
+ Vec1t(1, NbBColumns(SSP)),
+ Vec1c(1, NbBColumns(SSP)),
+ Vec2t(1, NbBColumns(SSP)),
+ Vec2c(1, NbBColumns(SSP)),
+ theError(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ myindex(FirstPoint, LastPoint, 0),
+ nbpoles(NbPol)
{
- FirstConstraint = FirstCons;
+ FirstConstraint = FirstCons;
LastConstraint = LastCons;
Init(SSP, FirstPoint, LastPoint);
}
-
-AppParCurves_LeastSquare::
- AppParCurves_LeastSquare(const MultiLine& SSP,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const AppParCurves_Constraint FirstCons,
- const AppParCurves_Constraint LastCons,
- const math_Vector& Parameters,
- const Standard_Integer NbPol):
- SCU(NbPol),
- mypoles(1, NbPol,
- 1, NbBColumns(SSP)),
- A(FirstPoint, LastPoint, 1, NbPol),
- DA(FirstPoint, LastPoint, 1, NbPol),
- B2(TheFirstPoint(FirstCons, FirstPoint),
- Max(TheFirstPoint(FirstCons, FirstPoint),
- TheLastPoint(LastCons, LastPoint)),
- 1, NbBColumns(SSP)),
- mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
- Vflatknots(1, FlatLength(Mults)),
- Vec1t(1, NbBColumns(SSP)),
- Vec1c(1, NbBColumns(SSP)),
- Vec2t(1, NbBColumns(SSP)),
- Vec2c(1, NbBColumns(SSP)),
- theError(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- myindex(FirstPoint, LastPoint, 0),
- nbpoles(NbPol)
+AppParCurves_LeastSquare::AppParCurves_LeastSquare(const MultiLine& SSP,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const AppParCurves_Constraint FirstCons,
+ const AppParCurves_Constraint LastCons,
+ const math_Vector& Parameters,
+ const Standard_Integer NbPol)
+ : SCU(NbPol),
+ mypoles(1, NbPol, 1, NbBColumns(SSP)),
+ A(FirstPoint, LastPoint, 1, NbPol),
+ DA(FirstPoint, LastPoint, 1, NbPol),
+ B2(TheFirstPoint(FirstCons, FirstPoint),
+ Max(TheFirstPoint(FirstCons, FirstPoint), TheLastPoint(LastCons, LastPoint)),
+ 1,
+ NbBColumns(SSP)),
+ mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
+ Vflatknots(1, FlatLength(Mults)),
+ Vec1t(1, NbBColumns(SSP)),
+ Vec1c(1, NbBColumns(SSP)),
+ Vec2t(1, NbBColumns(SSP)),
+ Vec2c(1, NbBColumns(SSP)),
+ theError(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ myindex(FirstPoint, LastPoint, 0),
+ nbpoles(NbPol)
{
- FirstConstraint = FirstCons;
- LastConstraint = LastCons;
- myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
+ FirstConstraint = FirstCons;
+ LastConstraint = LastCons;
+ myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
myknots->ChangeArray1() = Knots;
- mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
+ mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
mymults->ChangeArray1() = Mults;
SCU.SetKnots(Knots);
SCU.SetMultiplicities(Mults);
Init(SSP, FirstPoint, LastPoint);
- Perform(Parameters);
+ Perform(Parameters);
}
-
-
-AppParCurves_LeastSquare::
- AppParCurves_LeastSquare(const MultiLine& SSP,
- const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const AppParCurves_Constraint FirstCons,
- const AppParCurves_Constraint LastCons,
- const Standard_Integer NbPol):
- SCU(NbPol),
- mypoles(1, NbPol,
- 1, NbBColumns(SSP)),
- A(FirstPoint, LastPoint, 1, NbPol),
- DA(FirstPoint, LastPoint, 1, NbPol),
- B2(TheFirstPoint(FirstCons, FirstPoint),
- Max(TheFirstPoint(FirstCons, FirstPoint),
- TheLastPoint(LastCons, LastPoint)),
- 1, NbBColumns(SSP)),
- mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
- Vflatknots(1, FlatLength(Mults)),
- Vec1t(1, NbBColumns(SSP)),
- Vec1c(1, NbBColumns(SSP)),
- Vec2t(1, NbBColumns(SSP)),
- Vec2c(1, NbBColumns(SSP)),
- theError(FirstPoint, LastPoint,
- 1, ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP), 0.0),
- myindex(FirstPoint, LastPoint, 0),
- nbpoles(NbPol)
+AppParCurves_LeastSquare::AppParCurves_LeastSquare(const MultiLine& SSP,
+ const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const AppParCurves_Constraint FirstCons,
+ const AppParCurves_Constraint LastCons,
+ const Standard_Integer NbPol)
+ : SCU(NbPol),
+ mypoles(1, NbPol, 1, NbBColumns(SSP)),
+ A(FirstPoint, LastPoint, 1, NbPol),
+ DA(FirstPoint, LastPoint, 1, NbPol),
+ B2(TheFirstPoint(FirstCons, FirstPoint),
+ Max(TheFirstPoint(FirstCons, FirstPoint), TheLastPoint(LastCons, LastPoint)),
+ 1,
+ NbBColumns(SSP)),
+ mypoints(FirstPoint, LastPoint, 1, NbBColumns(SSP)),
+ Vflatknots(1, FlatLength(Mults)),
+ Vec1t(1, NbBColumns(SSP)),
+ Vec1c(1, NbBColumns(SSP)),
+ Vec2t(1, NbBColumns(SSP)),
+ Vec2c(1, NbBColumns(SSP)),
+ theError(FirstPoint, LastPoint, 1, ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP), 0.0),
+ myindex(FirstPoint, LastPoint, 0),
+ nbpoles(NbPol)
{
- myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
+ myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
myknots->ChangeArray1() = Knots;
- mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
+ mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
mymults->ChangeArray1() = Mults;
SCU.SetKnots(Knots);
SCU.SetMultiplicities(Mults);
- FirstConstraint = FirstCons;
+ FirstConstraint = FirstCons;
LastConstraint = LastCons;
Init(SSP, FirstPoint, LastPoint);
}
-
-
-void AppParCurves_LeastSquare::Init(const MultiLine& SSP,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint)
+void AppParCurves_LeastSquare::Init(const MultiLine& SSP,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint)
{
// Variable de controle
iscalculated = Standard_False;
- isready = Standard_True;
+ isready = Standard_True;
myfirstp = FirstPoint;
- mylastp = LastPoint;
- FirstP = TheFirstPoint(FirstConstraint, myfirstp);
- LastP = TheLastPoint(LastConstraint, mylastp);
+ mylastp = LastPoint;
+ FirstP = TheFirstPoint(FirstConstraint, myfirstp);
+ LastP = TheLastPoint(LastConstraint, mylastp);
// Reperage des contraintes aux extremites:
// ========================================
nbP2d = ToolLine::NbP2d(SSP);
nbP = ToolLine::NbP3d(SSP);
- gp_Pnt Poi;
+ gp_Pnt Poi;
gp_Pnt2d Poi2d;
-// gp_Vec V3d;
-// gp_Vec2d V2d;
+ // gp_Vec V3d;
+ // gp_Vec2d V2d;
Standard_Integer mynbP2d = nbP2d, mynbP = nbP;
- if (nbP2d == 0) mynbP2d = 1;
- if (nbP == 0) mynbP = 1;
- TColgp_Array1OfPnt TabP(1, mynbP);
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ if (nbP == 0)
+ mynbP = 1;
+ TColgp_Array1OfPnt TabP(1, mynbP);
TColgp_Array1OfPnt2d TabP2d(1, mynbP2d);
- TColgp_Array1OfVec TabV(1, mynbP);
+ TColgp_Array1OfVec TabV(1, mynbP);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
+ deg = nbpoles - 1;
- deg = nbpoles-1;
-
- if (!mymults.IsNull()) {
+ if (!mymults.IsNull())
+ {
Standard_Integer sum = 0;
- for (i = mymults->Lower(); i <= mymults->Upper(); i++) {
+ for (i = mymults->Lower(); i <= mymults->Upper(); i++)
+ {
sum += mymults->Value(i);
}
- deg = sum -nbpoles-1;
- k = 1;
+ deg = sum - nbpoles - 1;
+ k = 1;
Standard_Real val;
- for (i = myknots->Lower(); i <= myknots->Upper(); i++) {
- for (j = 1; j <= mymults->Value(i); j++) {
- val = myknots->Value(i);
- Vflatknots(k) = val;
- k++;
+ for (i = myknots->Lower(); i <= myknots->Upper(); i++)
+ {
+ for (j = 1; j <= mymults->Value(i); j++)
+ {
+ val = myknots->Value(i);
+ Vflatknots(k) = val;
+ k++;
}
}
}
-
Affect(SSP, FirstPoint, FirstConstraint, Vec1t, Vec1c);
Affect(SSP, LastPoint, LastConstraint, Vec2t, Vec2c);
- for (j = myfirstp; j <= mylastp; j++) {
+ for (j = myfirstp; j <= mylastp; j++)
+ {
i2 = 1;
- if (nbP != 0 && nbP2d != 0) ToolLine::Value(SSP, j, TabP,TabP2d);
- else if (nbP2d != 0) ToolLine::Value(SSP, j, TabP2d);
- else ToolLine::Value(SSP, j, TabP);
- for (i = 1; i <= nbP; i++) {
- (TabP(i)).Coord(mypoints(j,i2),mypoints(j,i2+1),mypoints(j,i2+2));
+ if (nbP != 0 && nbP2d != 0)
+ ToolLine::Value(SSP, j, TabP, TabP2d);
+ else if (nbP2d != 0)
+ ToolLine::Value(SSP, j, TabP2d);
+ else
+ ToolLine::Value(SSP, j, TabP);
+ for (i = 1; i <= nbP; i++)
+ {
+ (TabP(i)).Coord(mypoints(j, i2), mypoints(j, i2 + 1), mypoints(j, i2 + 2));
i2 += 3;
}
- for (i = 1;i <= nbP2d; i++) {
- (TabP2d(i)).Coord(mypoints(j, i2), mypoints(j, i2+1));
+ for (i = 1; i <= nbP2d; i++)
+ {
+ (TabP2d(i)).Coord(mypoints(j, i2), mypoints(j, i2 + 1));
i2 += 2;
}
}
AppParCurves_MultiPoint Pole1(nbP, nbP2d), PoleN(nbP, nbP2d);
- if (FirstConstraint == AppParCurves_PassPoint ||
- FirstConstraint == AppParCurves_TangencyPoint ||
- FirstConstraint == AppParCurves_CurvaturePoint) {
+ if (FirstConstraint == AppParCurves_PassPoint || FirstConstraint == AppParCurves_TangencyPoint
+ || FirstConstraint == AppParCurves_CurvaturePoint)
+ {
i2 = 1;
- for (i = 1; i <= nbP; i++) {
- Poi.SetCoord(mypoints(myfirstp, i2),
- mypoints(myfirstp, i2+1),
- mypoints(myfirstp, i2+2));
+ for (i = 1; i <= nbP; i++)
+ {
+ Poi.SetCoord(mypoints(myfirstp, i2), mypoints(myfirstp, i2 + 1), mypoints(myfirstp, i2 + 2));
Pole1.SetPoint(i, Poi);
i2 += 3;
}
- for (i = 1; i <= nbP2d; i++) {
- Poi2d.SetCoord(mypoints(myfirstp, i2), mypoints(myfirstp, i2+1));
- Pole1.SetPoint2d(i+nbP, Poi2d);
+ for (i = 1; i <= nbP2d; i++)
+ {
+ Poi2d.SetCoord(mypoints(myfirstp, i2), mypoints(myfirstp, i2 + 1));
+ Pole1.SetPoint2d(i + nbP, Poi2d);
i2 += 2;
}
for (i = 1; i <= mypoles.ColNumber(); i++)
mypoles(1, i) = mypoints(myfirstp, i);
}
-
-
- if (LastConstraint == AppParCurves_PassPoint ||
- LastConstraint == AppParCurves_TangencyPoint ||
- FirstConstraint == AppParCurves_CurvaturePoint) {
+ if (LastConstraint == AppParCurves_PassPoint || LastConstraint == AppParCurves_TangencyPoint
+ || FirstConstraint == AppParCurves_CurvaturePoint)
+ {
i2 = 1;
- for (i = 1; i <= nbP; i++) {
- Poi.SetCoord(mypoints(mylastp, i2),
- mypoints(mylastp, i2+1),
- mypoints(mylastp, i2+2));
+ for (i = 1; i <= nbP; i++)
+ {
+ Poi.SetCoord(mypoints(mylastp, i2), mypoints(mylastp, i2 + 1), mypoints(mylastp, i2 + 2));
PoleN.SetPoint(i, Poi);
i2 += 3;
}
- for (i = 1; i <= nbP2d; i++) {
- Poi2d.SetCoord(mypoints(mylastp, i2),
- mypoints(mylastp, i2+1));
- PoleN.SetPoint2d(i+nbP, Poi2d);
+ for (i = 1; i <= nbP2d; i++)
+ {
+ Poi2d.SetCoord(mypoints(mylastp, i2), mypoints(mylastp, i2 + 1));
+ PoleN.SetPoint2d(i + nbP, Poi2d);
i2 += 2;
}
-
+
for (i = 1; i <= mypoles.ColNumber(); i++)
mypoles(nbpoles, i) = mypoints(mylastp, i);
}
-
- if (FirstConstraint == AppParCurves_NoConstraint) {
+ if (FirstConstraint == AppParCurves_NoConstraint)
+ {
resinit = 1;
SCU.SetValue(1, Pole1);
- if (LastConstraint == AppParCurves_NoConstraint) {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
resfin = nbpoles;
}
- else if (LastConstraint == AppParCurves_PassPoint) {
- resfin = nbpoles-1;
+ else if (LastConstraint == AppParCurves_PassPoint)
+ {
+ resfin = nbpoles - 1;
SCU.SetValue(nbpoles, PoleN);
}
- else if (LastConstraint == AppParCurves_TangencyPoint) {
- resfin = nbpoles-2;
+ else if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ resfin = nbpoles - 2;
SCU.SetValue(nbpoles, PoleN);
}
- else if (LastConstraint == AppParCurves_CurvaturePoint) {
- resfin = nbpoles-3;
+ else if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ resfin = nbpoles - 3;
SCU.SetValue(nbpoles, PoleN);
}
}
- else if (FirstConstraint == AppParCurves_PassPoint) {
+ else if (FirstConstraint == AppParCurves_PassPoint)
+ {
resinit = 2;
SCU.SetValue(1, Pole1);
- if (LastConstraint == AppParCurves_NoConstraint) {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
resfin = nbpoles;
}
- else if (LastConstraint == AppParCurves_PassPoint) {
- resfin = nbpoles-1;
+ else if (LastConstraint == AppParCurves_PassPoint)
+ {
+ resfin = nbpoles - 1;
SCU.SetValue(nbpoles, PoleN);
}
- else if (LastConstraint == AppParCurves_TangencyPoint) {
- resfin = nbpoles-2;
+ else if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ resfin = nbpoles - 2;
SCU.SetValue(nbpoles, PoleN);
}
- else if (LastConstraint == AppParCurves_CurvaturePoint) {
- resfin = nbpoles-3;
+ else if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ resfin = nbpoles - 3;
SCU.SetValue(nbpoles, PoleN);
}
}
- else if (FirstConstraint == AppParCurves_TangencyPoint) {
+ else if (FirstConstraint == AppParCurves_TangencyPoint)
+ {
resinit = 3;
SCU.SetValue(1, Pole1);
- if (LastConstraint == AppParCurves_NoConstraint) {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
resfin = nbpoles;
}
- if (LastConstraint == AppParCurves_PassPoint) {
- resfin = nbpoles-1;
+ if (LastConstraint == AppParCurves_PassPoint)
+ {
+ resfin = nbpoles - 1;
SCU.SetValue(nbpoles, PoleN);
}
- if (LastConstraint == AppParCurves_TangencyPoint) {
- resfin = nbpoles-2;
+ if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ resfin = nbpoles - 2;
SCU.SetValue(nbpoles, PoleN);
}
- else if (LastConstraint == AppParCurves_CurvaturePoint) {
- resfin = nbpoles-3;
+ else if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ resfin = nbpoles - 3;
SCU.SetValue(nbpoles, PoleN);
}
}
- else if (FirstConstraint == AppParCurves_CurvaturePoint) {
+ else if (FirstConstraint == AppParCurves_CurvaturePoint)
+ {
resinit = 4;
SCU.SetValue(1, Pole1);
- if (LastConstraint == AppParCurves_NoConstraint) {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
resfin = nbpoles;
}
- if (LastConstraint == AppParCurves_PassPoint) {
- resfin = nbpoles-1;
+ if (LastConstraint == AppParCurves_PassPoint)
+ {
+ resfin = nbpoles - 1;
SCU.SetValue(nbpoles, PoleN);
}
- if (LastConstraint == AppParCurves_TangencyPoint) {
- resfin = nbpoles-2;
+ if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ resfin = nbpoles - 2;
SCU.SetValue(nbpoles, PoleN);
}
- else if (LastConstraint == AppParCurves_CurvaturePoint) {
- resfin = nbpoles-3;
+ else if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ resfin = nbpoles - 3;
SCU.SetValue(nbpoles, PoleN);
}
}
- Standard_Integer Nincx = resfin-resinit+1;
- if (Nincx<1) { //Impossible d'aller plus loin
+ Standard_Integer Nincx = resfin - resinit + 1;
+ if (Nincx < 1)
+ { // Impossible d'aller plus loin
isready = Standard_False;
return;
- }
- Standard_Integer Neq = LastP-FirstP+1;
-
- NA = 3*nbP+2*nbP2d;
- Nlignes = NA*Neq;
- Ninc = NA*Nincx;
- if (FirstConstraint >= AppParCurves_TangencyPoint) Ninc++;
- if (LastConstraint >= AppParCurves_TangencyPoint) Ninc++;
+ }
+ Standard_Integer Neq = LastP - FirstP + 1;
+
+ NA = 3 * nbP + 2 * nbP2d;
+ Nlignes = NA * Neq;
+ Ninc = NA * Nincx;
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ Ninc++;
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ Ninc++;
}
-
-
-
-void AppParCurves_LeastSquare::Perform(const math_Vector& Parameters) {
+void AppParCurves_LeastSquare::Perform(const math_Vector& Parameters)
+{
done = Standard_False;
- if (!isready) {
+ if (!isready)
+ {
return;
}
Standard_Integer i, j, k, Ci, i2, k1, k2;
- Standard_Integer nbpol1 = nbpoles-1, Ninc1 = Ninc-1;
- Standard_Real AD1, A0;
-// gp_Pnt Pt;
-// gp_Pnt2d Pt2d;
+ Standard_Integer nbpol1 = nbpoles - 1, Ninc1 = Ninc - 1;
+ Standard_Real AD1, A0;
+ // gp_Pnt Pt;
+ // gp_Pnt2d Pt2d;
iscalculated = Standard_False;
// calcul de la matrice A et DA des fonctions d approximation:
ComputeFunction(Parameters);
- if (FirstConstraint != AppParCurves_TangencyPoint &&
- LastConstraint != AppParCurves_TangencyPoint) {
- if (FirstConstraint == AppParCurves_NoConstraint) {
- if (LastConstraint == AppParCurves_NoConstraint ) {
-
- math_Householder HouResol(A, mypoints);
- if (!(HouResol.IsDone())) {
- done = Standard_False;
- return;
- }
- done = Standard_True;
- mypoles = HouResol.AllValues();
- return;
-
+ if (FirstConstraint != AppParCurves_TangencyPoint && LastConstraint != AppParCurves_TangencyPoint)
+ {
+ if (FirstConstraint == AppParCurves_NoConstraint)
+ {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
+
+ math_Householder HouResol(A, mypoints);
+ if (!(HouResol.IsDone()))
+ {
+ done = Standard_False;
+ return;
+ }
+ done = Standard_True;
+ mypoles = HouResol.AllValues();
+ return;
}
- else {
- for (j = FirstP; j <= LastP; j++) {
- AD1 = A(j, nbpoles);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j,i) - AD1*mypoles(nbpoles, i);
- }
- }
+ else
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ AD1 = A(j, nbpoles);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - AD1 * mypoles(nbpoles, i);
+ }
+ }
}
}
- else if (FirstConstraint == AppParCurves_PassPoint) {
- if (LastConstraint == AppParCurves_NoConstraint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i)- A0*mypoles(1, i);
- }
- }
+ else if (FirstConstraint == AppParCurves_PassPoint)
+ {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i);
+ }
+ }
}
- else if (LastConstraint == AppParCurves_PassPoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1);
- AD1 = A(j, nbpoles);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - AD1* mypoles(nbpoles, i);
- }
- }
+ else if (LastConstraint == AppParCurves_PassPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ AD1 = A(j, nbpoles);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - AD1 * mypoles(nbpoles, i);
+ }
+ }
}
}
// resolution:
- Standard_Integer Nincx = resfin-resinit+1;
- if (Nincx < 1) {
+ Standard_Integer Nincx = resfin - resinit + 1;
+ if (Nincx < 1)
+ {
done = Standard_True;
return;
}
math_IntegerVector Index(1, Nincx);
SearchIndex(Index);
- math_Matrix mytab(resinit, resfin, 1, B2.ColNumber(),0.0);
+ math_Matrix mytab(resinit, resfin, 1, B2.ColNumber(), 0.0);
math_Vector TheAA(1, Index(Nincx), 0.0);
math_Vector myTABB(1, Nincx, 0.0);
-
+
MakeTAA(TheAA, mytab);
DACTCL_Decompose(TheAA, Index);
-
+
Standard_Integer kk2;
- for (j = 1; j <= B2.ColNumber(); j++) {
+ for (j = 1; j <= B2.ColNumber(); j++)
+ {
kk2 = 1;
- for (i = resinit; i <= resfin; i++) {
- myTABB(kk2) = mytab(i, j);
- kk2++;
+ for (i = resinit; i <= resfin; i++)
+ {
+ myTABB(kk2) = mytab(i, j);
+ kk2++;
}
DACTCL_Solve(TheAA, myTABB, Index);
-
+
i2 = 1;
- for (k = resinit; k <= resfin; k++) {
- mypoles(k, j) = myTABB.Value(i2);
- i2++;
+ for (k = resinit; k <= resfin; k++)
+ {
+ mypoles(k, j) = myTABB.Value(i2);
+ i2++;
}
}
done = Standard_True;
// cas de tangence:
// ===========================================================
- Standard_Integer Nincx = resfin-resinit+1;
- Standard_Integer deport = 0, Nincx2 = 2*Nincx;
-
+ Standard_Integer Nincx = resfin - resinit + 1;
+ Standard_Integer deport = 0, Nincx2 = 2 * Nincx;
+
math_IntegerVector InternalIndex(1, Nincx);
SearchIndex(InternalIndex);
math_IntegerVector Index(1, Ninc);
-
+
Standard_Integer l = 1;
- if (resinit <= resfin) {
- for (j = 0; j <= NA-1; j++) {
- deport = j*InternalIndex(Nincx);
- for (i = 1; i <= Nincx; i++) {
- Index(l) = InternalIndex(i) + deport;
- l++;
+ if (resinit <= resfin)
+ {
+ for (j = 0; j <= NA - 1; j++)
+ {
+ deport = j * InternalIndex(Nincx);
+ for (i = 1; i <= Nincx; i++)
+ {
+ Index(l) = InternalIndex(i) + deport;
+ l++;
}
}
}
-
- if (resinit > resfin) Index(1) = 1;
- if (Ninc1 > 1) {
- if (FirstConstraint >= AppParCurves_TangencyPoint &&
- LastConstraint >= AppParCurves_TangencyPoint)
+
+ if (resinit > resfin)
+ Index(1) = 1;
+ if (Ninc1 > 1)
+ {
+ if (FirstConstraint >= AppParCurves_TangencyPoint
+ && LastConstraint >= AppParCurves_TangencyPoint)
Index(Ninc1) = Index(Ninc1 - 1) + Ninc1;
}
- if (FirstConstraint >= AppParCurves_TangencyPoint ||
- LastConstraint >= AppParCurves_TangencyPoint)
- Index(Ninc) = Index(Ninc-1) + Ninc;
-
+ if (FirstConstraint >= AppParCurves_TangencyPoint || LastConstraint >= AppParCurves_TangencyPoint)
+ Index(Ninc) = Index(Ninc - 1) + Ninc;
math_Vector TheA(1, Index(Ninc), 0.0);
math_Vector myTAB(1, Ninc, 0.0);
-
+
MakeTAA(TheA, myTAB);
-
+
Standard_Integer Error = DACTCL_Decompose(TheA, Index);
- Error = DACTCL_Solve(TheA, myTAB, Index);
-
- if (!Error) done = Standard_True;
-
- if (FirstConstraint >= AppParCurves_TangencyPoint &&
- LastConstraint >= AppParCurves_TangencyPoint) {
+ Error = DACTCL_Solve(TheA, myTAB, Index);
+
+ if (!Error)
+ done = Standard_True;
+
+ if (FirstConstraint >= AppParCurves_TangencyPoint && LastConstraint >= AppParCurves_TangencyPoint)
+ {
lambda1 = myTAB.Value(Ninc1);
lambda2 = myTAB.Value(Ninc);
}
else if (LastConstraint >= AppParCurves_TangencyPoint)
lambda2 = myTAB.Value(Ninc);
-
-
// Les resultats sont stockes dans mypoles.
//=========================================
- k = 1;
+ k = 1;
i2 = 1;
- for (Ci = 1; Ci <= nbP; Ci++) {
- k1 = k+1; k2 = k+2;
- for (j = resinit; j <= resfin; j++) {
+ for (Ci = 1; Ci <= nbP; Ci++)
+ {
+ k1 = k + 1;
+ k2 = k + 2;
+ for (j = resinit; j <= resfin; j++)
+ {
mypoles(j, k) = myTAB.Value(i2);
- mypoles(j, k1) = myTAB.Value(i2+Nincx);
- mypoles(j, k2) = myTAB.Value(i2+Nincx2);
+ mypoles(j, k1) = myTAB.Value(i2 + Nincx);
+ mypoles(j, k2) = myTAB.Value(i2 + Nincx2);
i2++;
}
-
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
- mypoles(2, k) = mypoints(myfirstp, k) + lambda1*Vec1t(k);
- mypoles(2, k1) = mypoints(myfirstp, k1) + lambda1*Vec1t(k1);
- mypoles(2, k2) = mypoints(myfirstp, k2) + lambda1*Vec1t(k2);
+
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
+ mypoles(2, k) = mypoints(myfirstp, k) + lambda1 * Vec1t(k);
+ mypoles(2, k1) = mypoints(myfirstp, k1) + lambda1 * Vec1t(k1);
+ mypoles(2, k2) = mypoints(myfirstp, k2) + lambda1 * Vec1t(k2);
}
- if (LastConstraint >= AppParCurves_TangencyPoint) {
- mypoles(nbpol1, k) = mypoints(mylastp, k) - lambda2*Vec2t(k);
- mypoles(nbpol1, k1) = mypoints(mylastp, k1) - lambda2*Vec2t(k1);
- mypoles(nbpol1, k2) = mypoints(mylastp, k2) - lambda2*Vec2t(k2);
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ mypoles(nbpol1, k) = mypoints(mylastp, k) - lambda2 * Vec2t(k);
+ mypoles(nbpol1, k1) = mypoints(mylastp, k1) - lambda2 * Vec2t(k1);
+ mypoles(nbpol1, k2) = mypoints(mylastp, k2) - lambda2 * Vec2t(k2);
}
- k += 3; i2 += Nincx2;
+ k += 3;
+ i2 += Nincx2;
}
- for (Ci = 1; Ci <= nbP2d; Ci++) {
- k1 = k+1; k2 = k+2;
- for (j = resinit; j <= resfin; j++) {
+ for (Ci = 1; Ci <= nbP2d; Ci++)
+ {
+ k1 = k + 1;
+ k2 = k + 2;
+ for (j = resinit; j <= resfin; j++)
+ {
mypoles(j, k) = myTAB.Value(i2);
- mypoles(j, k1) = myTAB.Value(i2+Nincx);
+ mypoles(j, k1) = myTAB.Value(i2 + Nincx);
i2++;
}
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
- mypoles(2, k) = mypoints(myfirstp, k) + lambda1*Vec1t(k);
- mypoles(2, k1) = mypoints(myfirstp, k1) + lambda1*Vec1t(k1);
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
+ mypoles(2, k) = mypoints(myfirstp, k) + lambda1 * Vec1t(k);
+ mypoles(2, k1) = mypoints(myfirstp, k1) + lambda1 * Vec1t(k1);
}
- if (LastConstraint >= AppParCurves_TangencyPoint) {
- mypoles(nbpol1, k) = mypoints(mylastp, k) - lambda2*Vec2t(k);
- mypoles(nbpol1, k1) = mypoints(mylastp, k1) - lambda2*Vec2t(k1);
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ mypoles(nbpol1, k) = mypoints(mylastp, k) - lambda2 * Vec2t(k);
+ mypoles(nbpol1, k1) = mypoints(mylastp, k1) - lambda2 * Vec2t(k1);
}
- k += 2; i2 += Nincx;
+ k += 2;
+ i2 += Nincx;
}
-
}
void AppParCurves_LeastSquare::Perform(const math_Vector& Parameters,
- const math_Vector& V1t,
- const math_Vector& V2t,
- const Standard_Real l1,
- const Standard_Real l2)
+ const math_Vector& V1t,
+ const math_Vector& V2t,
+ const Standard_Real l1,
+ const Standard_Real l2)
{
done = Standard_False;
- if (!isready) {
+ if (!isready)
+ {
return;
}
Standard_Integer i, lower1 = V1t.Lower(), lower2 = V2t.Lower();
- resinit = 3; resfin = nbpoles-2;
- Standard_Integer Nincx = resfin-resinit+1;
- Ninc = NA*Nincx + 2;
- FirstConstraint = AppParCurves_TangencyPoint;
- LastConstraint = AppParCurves_TangencyPoint;
- for (i = 1; i <= Vec1t.Upper(); i++) {
- Vec1t(i) = V1t(i+lower1-1);
- Vec2t(i) = V2t(i+lower2-1);
- }
- Perform (Parameters, l1, l2);
+ resinit = 3;
+ resfin = nbpoles - 2;
+ Standard_Integer Nincx = resfin - resinit + 1;
+ Ninc = NA * Nincx + 2;
+ FirstConstraint = AppParCurves_TangencyPoint;
+ LastConstraint = AppParCurves_TangencyPoint;
+ for (i = 1; i <= Vec1t.Upper(); i++)
+ {
+ Vec1t(i) = V1t(i + lower1 - 1);
+ Vec2t(i) = V2t(i + lower2 - 1);
+ }
+ Perform(Parameters, l1, l2);
}
-
void AppParCurves_LeastSquare::Perform(const math_Vector& Parameters,
- const math_Vector& V1t,
- const math_Vector& V2t,
- const math_Vector& V1c,
- const math_Vector& V2c,
- const Standard_Real l1,
- const Standard_Real l2) {
+ const math_Vector& V1t,
+ const math_Vector& V2t,
+ const math_Vector& V1c,
+ const math_Vector& V2c,
+ const Standard_Real l1,
+ const Standard_Real l2)
+{
done = Standard_False;
- if (!isready) {
+ if (!isready)
+ {
return;
}
Standard_Integer i, lower1 = V1t.Lower(), lower2 = V2t.Lower();
Standard_Integer lowc1 = V1c.Lower(), lowc2 = V2c.Lower();
- resinit = 4; resfin = nbpoles-3;
- Standard_Integer Nincx = resfin-resinit+1;
- Ninc = NA*Nincx + 2;
- FirstConstraint = AppParCurves_CurvaturePoint;
- LastConstraint = AppParCurves_CurvaturePoint;
-
- for (i = 1; i <= Vec1t.Upper(); i++) {
- Vec1t(i) = V1t(i+lower1-1);
- Vec2t(i) = V2t(i+lower2-1);
- Vec1c(i) = V1c(i+lowc1-1);
- Vec2c(i) = V2c(i+lowc2-1);
- }
- Perform (Parameters, l1, l2);
+ resinit = 4;
+ resfin = nbpoles - 3;
+ Standard_Integer Nincx = resfin - resinit + 1;
+ Ninc = NA * Nincx + 2;
+ FirstConstraint = AppParCurves_CurvaturePoint;
+ LastConstraint = AppParCurves_CurvaturePoint;
+
+ for (i = 1; i <= Vec1t.Upper(); i++)
+ {
+ Vec1t(i) = V1t(i + lower1 - 1);
+ Vec2t(i) = V2t(i + lower2 - 1);
+ Vec1c(i) = V1c(i + lowc1 - 1);
+ Vec2c(i) = V2c(i + lowc2 - 1);
+ }
+ Perform(Parameters, l1, l2);
}
-
-
void AppParCurves_LeastSquare::Perform(const math_Vector& Parameters,
- const Standard_Real l1,
- const Standard_Real l2) {
+ const Standard_Real l1,
+ const Standard_Real l2)
+{
done = Standard_False;
- if (!isready) {
+ if (!isready)
+ {
return;
}
- if (FirstConstraint < AppParCurves_TangencyPoint &&
- LastConstraint < AppParCurves_TangencyPoint) {
+ if (FirstConstraint < AppParCurves_TangencyPoint && LastConstraint < AppParCurves_TangencyPoint)
+ {
Perform(Parameters);
return;
}
lambda1 = l1;
lambda2 = l2;
Standard_Integer i, j, k, i2;
- Standard_Real AD0, AD1, AD2, A0, A1, A2;
-// gp_Pnt Pt, P1, P2;
-// gp_Pnt2d Pt2d, P12d, P22d;
- Standard_Real l11 = deg*l1, l22 = deg*l2;
+ Standard_Real AD0, AD1, AD2, A0, A1, A2;
+ // gp_Pnt Pt, P1, P2;
+ // gp_Pnt2d Pt2d, P12d, P22d;
+ Standard_Real l11 = deg * l1, l22 = deg * l2;
ComputeFunction(Parameters);
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
for (i = 1; i <= mypoles.ColNumber(); i++)
- mypoles(2, i) = mypoints(myfirstp, i) + l1*Vec1t(i);
+ mypoles(2, i) = mypoints(myfirstp, i) + l1 * Vec1t(i);
}
-
- if (FirstConstraint == AppParCurves_CurvaturePoint) {
+ if (FirstConstraint == AppParCurves_CurvaturePoint)
+ {
for (i = 1; i <= mypoles.ColNumber(); i++)
- mypoles(3, i) = 2*mypoles(2, i)-mypoles(1, i)
- + l11*l11*Vec1c(i)/(deg*(deg-1));
+ mypoles(3, i) = 2 * mypoles(2, i) - mypoles(1, i) + l11 * l11 * Vec1c(i) / (deg * (deg - 1));
}
-
- if (LastConstraint >= AppParCurves_TangencyPoint) {
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
for (i = 1; i <= mypoles.ColNumber(); i++)
- mypoles(nbpoles-1, i) = mypoints(mylastp, i) - l2*Vec2t(i);
+ mypoles(nbpoles - 1, i) = mypoints(mylastp, i) - l2 * Vec2t(i);
}
-
- if (LastConstraint == AppParCurves_CurvaturePoint) {
+ if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
for (i = 1; i <= mypoles.ColNumber(); i++)
- mypoles(nbpoles-2, i) = 2*mypoles(nbpoles-1, i) - mypoles(nbpoles, i)
- + l22*l22*Vec2c(i)/(deg*(deg-1));
+ mypoles(nbpoles - 2, i) = 2 * mypoles(nbpoles - 1, i) - mypoles(nbpoles, i)
+ + l22 * l22 * Vec2c(i) / (deg * (deg - 1));
}
- if (resinit > resfin) {
+ if (resinit > resfin)
+ {
done = Standard_True;
return;
}
- if (FirstConstraint == AppParCurves_NoConstraint) {
- if (LastConstraint == AppParCurves_TangencyPoint) {
- for (j = FirstP; j <= LastP; j++) {
- AD0 = A(j, nbpoles); AD1 = A(j, nbpoles-1);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - AD0 * mypoles(nbpoles, i)
- - AD1 * mypoles(nbpoles-1, i);
- }
+ if (FirstConstraint == AppParCurves_NoConstraint)
+ {
+ if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ AD0 = A(j, nbpoles);
+ AD1 = A(j, nbpoles - 1);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - AD0 * mypoles(nbpoles, i) - AD1 * mypoles(nbpoles - 1, i);
+ }
}
}
- if (LastConstraint == AppParCurves_CurvaturePoint) {
- for (j = FirstP; j <= LastP; j++) {
- AD0 = A(j, nbpoles); AD1 = A(j, nbpoles-1); AD2 = A(j, nbpoles-2);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - AD0 * mypoles(nbpoles, i)
- - AD1 * mypoles(nbpoles-1, i)
- - AD2 * mypoles(nbpoles-2, i);
- }
+ if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ AD0 = A(j, nbpoles);
+ AD1 = A(j, nbpoles - 1);
+ AD2 = A(j, nbpoles - 2);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - AD0 * mypoles(nbpoles, i) - AD1 * mypoles(nbpoles - 1, i)
+ - AD2 * mypoles(nbpoles - 2, i);
+ }
}
}
}
- else if (FirstConstraint == AppParCurves_PassPoint) {
- if (LastConstraint == AppParCurves_TangencyPoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1);
- AD0 = A(j, nbpoles); AD1 = A(j, nbpoles-1);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - AD0 * mypoles(nbpoles, i)
- - AD1 * mypoles(nbpoles-1, i);
- }
+ else if (FirstConstraint == AppParCurves_PassPoint)
+ {
+ if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ AD0 = A(j, nbpoles);
+ AD1 = A(j, nbpoles - 1);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - AD0 * mypoles(nbpoles, i)
+ - AD1 * mypoles(nbpoles - 1, i);
+ }
}
}
- if (LastConstraint == AppParCurves_CurvaturePoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1);
- AD0 = A(j, nbpoles); AD1 = A(j, nbpoles-1); AD2 = A(j, nbpoles-2);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - AD0 * mypoles(nbpoles, i)
- - AD1 * mypoles(nbpoles-1, i)
- - AD2 * mypoles(nbpoles-2, i);
- }
+ if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ AD0 = A(j, nbpoles);
+ AD1 = A(j, nbpoles - 1);
+ AD2 = A(j, nbpoles - 2);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - AD0 * mypoles(nbpoles, i)
+ - AD1 * mypoles(nbpoles - 1, i) - AD2 * mypoles(nbpoles - 2, i);
+ }
}
}
}
- else if (FirstConstraint == AppParCurves_TangencyPoint) {
- if (LastConstraint == AppParCurves_NoConstraint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); A1 = A(j, 2);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - A1 * mypoles(2, i);
- }
+ else if (FirstConstraint == AppParCurves_TangencyPoint)
+ {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ A1 = A(j, 2);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - A1 * mypoles(2, i);
+ }
}
}
- else if (LastConstraint == AppParCurves_PassPoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); AD0 = A(j, nbpoles); A1 = A(j, 2);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - AD0 * mypoles(nbpoles, i)
- - A1 * mypoles(2, i);
- }
+ else if (LastConstraint == AppParCurves_PassPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ AD0 = A(j, nbpoles);
+ A1 = A(j, 2);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) =
+ mypoints(j, i) - A0 * mypoles(1, i) - AD0 * mypoles(nbpoles, i) - A1 * mypoles(2, i);
+ }
}
}
- else if (LastConstraint == AppParCurves_TangencyPoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); AD0 = A(j, nbpoles); A1 = A(j, 2); AD1 = A(j, nbpoles-1);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - AD0 * mypoles(nbpoles, i)
- - A1 * mypoles(2, i)
- - AD1 * mypoles(nbpoles-1, i);
- }
+ else if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ AD0 = A(j, nbpoles);
+ A1 = A(j, 2);
+ AD1 = A(j, nbpoles - 1);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - AD0 * mypoles(nbpoles, i)
+ - A1 * mypoles(2, i) - AD1 * mypoles(nbpoles - 1, i);
+ }
}
}
}
- else if (FirstConstraint == AppParCurves_CurvaturePoint) {
- if (LastConstraint == AppParCurves_NoConstraint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); A1 = A(j, 2); A2 = A(j, 3);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - A1 * mypoles(2, i)
- - A2 * mypoles(3, i);
- }
+ else if (FirstConstraint == AppParCurves_CurvaturePoint)
+ {
+ if (LastConstraint == AppParCurves_NoConstraint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ A1 = A(j, 2);
+ A2 = A(j, 3);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - A1 * mypoles(2, i) - A2 * mypoles(3, i);
+ }
}
}
- else if (LastConstraint == AppParCurves_PassPoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); A1 = A(j, 2); A2 = A(j, 3); AD0 = A(j, nbpoles);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - A1 * mypoles(2, i)
- - A2 * mypoles(3, i)
- - AD0 * mypoles(nbpoles, i);
- }
+ else if (LastConstraint == AppParCurves_PassPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ A1 = A(j, 2);
+ A2 = A(j, 3);
+ AD0 = A(j, nbpoles);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - A1 * mypoles(2, i) - A2 * mypoles(3, i)
+ - AD0 * mypoles(nbpoles, i);
+ }
}
}
- else if (LastConstraint == AppParCurves_TangencyPoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); A1 = A(j, 2); A2 = A(j, 3);
- AD0 = A(j, nbpoles); AD1 = A(j, nbpoles-1);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - A1 * mypoles(2, i)
- - A2 * mypoles(3, i)
- - AD0 * mypoles(nbpoles, i)
- - AD1 * mypoles(nbpoles-1, i);
- }
+ else if (LastConstraint == AppParCurves_TangencyPoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ A1 = A(j, 2);
+ A2 = A(j, 3);
+ AD0 = A(j, nbpoles);
+ AD1 = A(j, nbpoles - 1);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - A1 * mypoles(2, i) - A2 * mypoles(3, i)
+ - AD0 * mypoles(nbpoles, i) - AD1 * mypoles(nbpoles - 1, i);
+ }
}
}
- else if (LastConstraint == AppParCurves_CurvaturePoint) {
- for (j = FirstP; j <= LastP; j++) {
- A0 = A(j, 1); A1 = A(j, 2); A2 = A(j, 3);
- AD0 = A(j, nbpoles); AD1 = A(j, nbpoles-1); AD2 = A(j, nbpoles-2);
- for (i = 1; i <= B2.ColNumber(); i++) {
- B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i)
- - A1 * mypoles(2, i)
- - A2 * mypoles(3, i)
- - AD0 * mypoles(nbpoles, i)
- - AD1 * mypoles(nbpoles-1, i)
- - AD2 * mypoles(nbpoles-2, i);
- }
+ else if (LastConstraint == AppParCurves_CurvaturePoint)
+ {
+ for (j = FirstP; j <= LastP; j++)
+ {
+ A0 = A(j, 1);
+ A1 = A(j, 2);
+ A2 = A(j, 3);
+ AD0 = A(j, nbpoles);
+ AD1 = A(j, nbpoles - 1);
+ AD2 = A(j, nbpoles - 2);
+ for (i = 1; i <= B2.ColNumber(); i++)
+ {
+ B2(j, i) = mypoints(j, i) - A0 * mypoles(1, i) - A1 * mypoles(2, i) - A2 * mypoles(3, i)
+ - AD0 * mypoles(nbpoles, i) - AD1 * mypoles(nbpoles - 1, i)
+ - AD2 * mypoles(nbpoles - 2, i);
+ }
}
}
}
-
- Standard_Integer Nincx = resfin-resinit+1;
- math_Matrix mytab(resinit, resfin, 1, B2.ColNumber(),0.0);
+ Standard_Integer Nincx = resfin - resinit + 1;
+
+ math_Matrix mytab(resinit, resfin, 1, B2.ColNumber(), 0.0);
math_IntegerVector Index(1, Nincx);
SearchIndex(Index);
math_Vector AA(1, Index(Nincx), 0.0);
math_Vector myTABB(1, Nincx, 0.0);
DACTCL_Decompose(AA, Index);
-
+
Standard_Integer kk2;
- for (j = 1; j <= B2.ColNumber(); j++) {
+ for (j = 1; j <= B2.ColNumber(); j++)
+ {
kk2 = 1;
- for (i = resinit; i <= resfin; i++) {
+ for (i = resinit; i <= resfin; i++)
+ {
myTABB(kk2) = mytab(i, j);
kk2++;
}
-
+
DACTCL_Solve(AA, myTABB, Index);
-
+
i2 = 1;
- for (k = resinit; k <= resfin; k++) {
- mypoles(k, j) = myTABB.Value(i2);
+ for (k = resinit; k <= resfin; k++)
+ {
+ mypoles(k, j) = myTABB.Value(i2);
i2++;
}
-
}
-
- done = Standard_True;
+ done = Standard_True;
}
-
-
//=======================================================================
-//function : Affect
-//purpose : Index is an ID of the point in MultiLine. Every point is set of
+// function : Affect
+// purpose : Index is an ID of the point in MultiLine. Every point is set of
// several 3D- and 2D-points. E.g. every points of Walking-line,
// obtained in intersection algorithm, is set of one 3D points
// (nbP == 1) and two 2D-points (nbP2d == 2).
//=======================================================================
-void AppParCurves_LeastSquare::Affect(const MultiLine& SSP,
- const Standard_Integer Index,
- AppParCurves_Constraint& Cons,
- math_Vector& Vt,
- math_Vector& Vc)
+void AppParCurves_LeastSquare::Affect(const MultiLine& SSP,
+ const Standard_Integer Index,
+ AppParCurves_Constraint& Cons,
+ math_Vector& Vt,
+ math_Vector& Vc)
{
// Vt: vector of tangent, Vc: vector of curvature.
- if (Cons >= AppParCurves_TangencyPoint) {
+ if (Cons >= AppParCurves_TangencyPoint)
+ {
Standard_Integer i, i2 = 1;
Standard_Boolean Ok;
Standard_Integer mynbP2d = nbP2d, mynbP = nbP;
- if (nbP2d == 0) mynbP2d = 1;
- if (nbP == 0) mynbP = 1;
- TColgp_Array1OfVec TabV(1, mynbP);
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ if (nbP == 0)
+ mynbP = 1;
+ TColgp_Array1OfVec TabV(1, mynbP);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
-
+
if (Cons == AppParCurves_CurvaturePoint)
{
if (nbP != 0 && nbP2d != 0)
{
- Ok = ToolLine::Curvature(SSP, Index,TabV,TabV2d);
- if (!Ok) { Cons = AppParCurves_TangencyPoint;}
+ Ok = ToolLine::Curvature(SSP, Index, TabV, TabV2d);
+ if (!Ok)
+ {
+ Cons = AppParCurves_TangencyPoint;
+ }
}
else if (nbP2d != 0)
{
Ok = ToolLine::Curvature(SSP, Index, TabV2d);
- if (!Ok) { Cons = AppParCurves_TangencyPoint;}
+ if (!Ok)
+ {
+ Cons = AppParCurves_TangencyPoint;
+ }
}
- else {
+ else
+ {
Ok = ToolLine::Curvature(SSP, Index, TabV);
- if (!Ok) { Cons = AppParCurves_TangencyPoint;}
+ if (!Ok)
+ {
+ Cons = AppParCurves_TangencyPoint;
+ }
}
- if (Ok) {
- for (i = 1; i <= nbP; i++) {
- (TabV(i)).Coord(Vc(i2), Vc(i2+1), Vc(i2+2));
+ if (Ok)
+ {
+ for (i = 1; i <= nbP; i++)
+ {
+ (TabV(i)).Coord(Vc(i2), Vc(i2 + 1), Vc(i2 + 2));
i2 += 3;
}
- for (i = 1; i <= nbP2d; i++) {
- (TabV2d(i)).Coord(Vc(i2), Vc(i2+1));
+ for (i = 1; i <= nbP2d; i++)
+ {
+ (TabV2d(i)).Coord(Vc(i2), Vc(i2 + 1));
i2 += 2;
}
}
}
i2 = 1;
- if (Cons >= AppParCurves_TangencyPoint) {
- if (nbP != 0 && nbP2d != 0) {
+ if (Cons >= AppParCurves_TangencyPoint)
+ {
+ if (nbP != 0 && nbP2d != 0)
+ {
Ok = ToolLine::Tangency(SSP, Index, TabV, TabV2d);
- if (!Ok) { Cons = AppParCurves_PassPoint;}
+ if (!Ok)
+ {
+ Cons = AppParCurves_PassPoint;
+ }
}
- else if (nbP2d != 0) {
+ else if (nbP2d != 0)
+ {
Ok = ToolLine::Tangency(SSP, Index, TabV2d);
- if (!Ok) { Cons = AppParCurves_PassPoint;}
+ if (!Ok)
+ {
+ Cons = AppParCurves_PassPoint;
+ }
}
- else {
+ else
+ {
Ok = ToolLine::Tangency(SSP, Index, TabV);
- if (!Ok) { Cons = AppParCurves_PassPoint;}
+ if (!Ok)
+ {
+ Cons = AppParCurves_PassPoint;
+ }
}
if (Ok)
{
TColgp_Array1OfPnt anArrPts3d1(1, mynbP), anArrPts3d2(1, mynbP);
- if(nbP != 0)
+ if (nbP != 0)
{
- if(Index < ToolLine::LastPoint(SSP))
+ if (Index < ToolLine::LastPoint(SSP))
{
ToolLine::Value(SSP, Index, anArrPts3d1);
- ToolLine::Value(SSP, Index+1, anArrPts3d2);
+ ToolLine::Value(SSP, Index + 1, anArrPts3d2);
}
else
- {// (Index == ToolLine::LastPoint(theML))
- ToolLine::Value(SSP, Index-1, anArrPts3d1);
+ { // (Index == ToolLine::LastPoint(theML))
+ ToolLine::Value(SSP, Index - 1, anArrPts3d1);
ToolLine::Value(SSP, Index, anArrPts3d2);
}
CheckTangents(anArrPts3d1, anArrPts3d2, TabV, TabV2d);
}
- else if(nbP2d != 0)
+ else if (nbP2d != 0)
{
TColgp_Array1OfPnt2d anArrPts2d1(1, mynbP2d), anArrPts2d2(1, mynbP2d);
- if(Index < ToolLine::LastPoint(SSP))
+ if (Index < ToolLine::LastPoint(SSP))
{
ToolLine::Value(SSP, Index, anArrPts3d1, anArrPts2d1);
- ToolLine::Value(SSP, Index+1, anArrPts3d2, anArrPts2d2);
+ ToolLine::Value(SSP, Index + 1, anArrPts3d2, anArrPts2d2);
}
else
- {// (Index == ToolLine::LastPoint(theML))
- ToolLine::Value(SSP, Index-1, anArrPts3d1, anArrPts2d1);
+ { // (Index == ToolLine::LastPoint(theML))
+ ToolLine::Value(SSP, Index - 1, anArrPts3d1, anArrPts2d1);
ToolLine::Value(SSP, Index, anArrPts3d2, anArrPts2d2);
}
CheckTangents(anArrPts2d1, anArrPts2d2, TabV2d);
}
- for (i = 1; i <= nbP; i++) {
- (TabV(i)).Coord(Vt(i2), Vt(i2+1), Vt(i2+2));
+ for (i = 1; i <= nbP; i++)
+ {
+ (TabV(i)).Coord(Vt(i2), Vt(i2 + 1), Vt(i2 + 2));
i2 += 3;
}
- for (i = 1; i <= nbP2d; i++) {
- (TabV2d(i)).Coord(Vt(i2), Vt(i2+1));
+ for (i = 1; i <= nbP2d; i++)
+ {
+ (TabV2d(i)).Coord(Vt(i2), Vt(i2 + 1));
i2 += 2;
}
}
}
}
-
-
-Standard_Integer AppParCurves_LeastSquare::NbBColumns(
- const MultiLine& SSP) const
+Standard_Integer AppParCurves_LeastSquare::NbBColumns(const MultiLine& SSP) const
{
Standard_Integer BCol;
- BCol = (ToolLine::NbP3d(SSP))*3 +
- (ToolLine::NbP2d(SSP))*2;
+ BCol = (ToolLine::NbP3d(SSP)) * 3 + (ToolLine::NbP2d(SSP)) * 2;
return BCol;
}
-
-void AppParCurves_LeastSquare::Error(Standard_Real& F,
- Standard_Real& MaxE3d,
- Standard_Real& MaxE2d)
+void AppParCurves_LeastSquare::Error(Standard_Real& F, Standard_Real& MaxE3d, Standard_Real& MaxE2d)
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
Standard_Integer i, j, k, i2, indexdeb, indexfin;
Standard_Integer i21, i22;
- Standard_Real AA, BB, CC, Fi, FX, FY, FZ, AIJ;
+ Standard_Real AA, BB, CC, Fi, FX, FY, FZ, AIJ;
MaxE3d = MaxE2d = 0.0;
- F = 0.0;
- i2 = 1;
+ F = 0.0;
+ i2 = 1;
math_Vector Px(1, nbpoles), Py(1, nbpoles), Pz(1, nbpoles);
- for (k = 1 ; k <= nbP+nbP2d; k++) {
- i21 = i2+1; i22 = i2+2;
- for (i = 1; i <= nbpoles; i++) {
+ for (k = 1; k <= nbP + nbP2d; k++)
+ {
+ i21 = i2 + 1;
+ i22 = i2 + 2;
+ for (i = 1; i <= nbpoles; i++)
+ {
Px(i) = mypoles(i, i2);
Py(i) = mypoles(i, i21);
- if (k <= nbP) Pz(i) = mypoles(i, i22);
+ if (k <= nbP)
+ Pz(i) = mypoles(i, i22);
}
- for (i = FirstP; i <= LastP; i++) {
- AA = 0.0; BB = 0.0; CC = 0.0;
+ for (i = FirstP; i <= LastP; i++)
+ {
+ AA = 0.0;
+ BB = 0.0;
+ CC = 0.0;
indexdeb = myindex(i) + 1;
indexfin = indexdeb + deg;
- for (j = indexdeb; j <= indexfin; j++) {
- AIJ = A(i, j);
- AA += AIJ*Px(j);
- BB += AIJ*Py(j);
- if (k <= nbP) CC += AIJ*Pz(j);
+ for (j = indexdeb; j <= indexfin; j++)
+ {
+ AIJ = A(i, j);
+ AA += AIJ * Px(j);
+ BB += AIJ * Py(j);
+ if (k <= nbP)
+ CC += AIJ * Pz(j);
}
- FX = AA-mypoints(i, i2);
- FY = BB-mypoints(i, i21);
- Fi= FX*FX + FY*FY;
- if (k <= nbP) {
- FZ = CC-mypoints(i, i22);
- Fi += FZ*FZ;
- if (Fi > MaxE3d) MaxE3d = Fi;
+ FX = AA - mypoints(i, i2);
+ FY = BB - mypoints(i, i21);
+ Fi = FX * FX + FY * FY;
+ if (k <= nbP)
+ {
+ FZ = CC - mypoints(i, i22);
+ Fi += FZ * FZ;
+ if (Fi > MaxE3d)
+ MaxE3d = Fi;
}
- else {
- if (Fi > MaxE2d) MaxE2d = Fi;
+ else
+ {
+ if (Fi > MaxE2d)
+ MaxE2d = Fi;
}
theError(i, k) = Fi;
F += Fi;
}
- if (k <= nbP) i2 += 3;
- else i2 += 2;
+ if (k <= nbP)
+ i2 += 3;
+ else
+ i2 += 2;
}
MaxE3d = Sqrt(MaxE3d);
MaxE2d = Sqrt(MaxE2d);
}
-
-void AppParCurves_LeastSquare::ErrorGradient(math_Vector& Grad,
- Standard_Real& F,
- Standard_Real& MaxE3d,
- Standard_Real& MaxE2d)
+void AppParCurves_LeastSquare::ErrorGradient(math_Vector& Grad,
+ Standard_Real& F,
+ Standard_Real& MaxE3d,
+ Standard_Real& MaxE2d)
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
Standard_Integer i, j, k, i2, indexdeb, indexfin;
- Standard_Real AA, BB, CC, Fi, FX, FY, FZ, AIJ;
-// Standard_Real DAIJ, DAA, DBB, DCC, Gr, gr1= 0.0, gr2= 0.0;
+ Standard_Real AA, BB, CC, Fi, FX, FY, FZ, AIJ;
+ // Standard_Real DAIJ, DAA, DBB, DCC, Gr, gr1= 0.0, gr2= 0.0;
Standard_Real DAIJ, DAA, DBB, DCC, Gr;
MaxE3d = MaxE2d = 0.0;
-// Standard_Integer i21, i22, diff = (deg-1);
+ // Standard_Integer i21, i22, diff = (deg-1);
Standard_Integer i21, i22;
- F = 0.0;
+ F = 0.0;
i2 = 1;
math_Vector Px(1, nbpoles), Py(1, nbpoles), Pz(1, nbpoles);
- for (k = Grad.Lower(); k <= Grad.Upper(); k++) Grad(k) = 0.0;
+ for (k = Grad.Lower(); k <= Grad.Upper(); k++)
+ Grad(k) = 0.0;
- for (k = 1 ; k <= nbP+nbP2d; k++) {
- i21 = i2+1; i22 = i2+2;
- for (i = 1; i <= nbpoles; i++) {
+ for (k = 1; k <= nbP + nbP2d; k++)
+ {
+ i21 = i2 + 1;
+ i22 = i2 + 2;
+ for (i = 1; i <= nbpoles; i++)
+ {
Px(i) = mypoles(i, i2);
Py(i) = mypoles(i, i21);
- if (k <= nbP) Pz(i) = mypoles(i, i22);
+ if (k <= nbP)
+ Pz(i) = mypoles(i, i22);
}
- for (i = FirstP; i <= LastP; i++) {
- AA = 0.0; BB = 0.0; CC = 0.0; DAA = 0.0; DBB = 0.0; DCC = 0.0;
+ for (i = FirstP; i <= LastP; i++)
+ {
+ AA = 0.0;
+ BB = 0.0;
+ CC = 0.0;
+ DAA = 0.0;
+ DBB = 0.0;
+ DCC = 0.0;
indexdeb = myindex(i) + 1;
indexfin = indexdeb + deg;
- for (j = indexdeb; j <= indexfin; j++) {
- AIJ = A(i, j); DAIJ = DA(i, j);
- AA += AIJ*Px(j); DAA += DAIJ*Px(j);
- BB += AIJ*Py(j); DBB += DAIJ*Py(j);
- if (k <= nbP) {
- CC += AIJ*Pz(j);
- DCC += DAIJ*Pz(j);
- }
+ for (j = indexdeb; j <= indexfin; j++)
+ {
+ AIJ = A(i, j);
+ DAIJ = DA(i, j);
+ AA += AIJ * Px(j);
+ DAA += DAIJ * Px(j);
+ BB += AIJ * Py(j);
+ DBB += DAIJ * Py(j);
+ if (k <= nbP)
+ {
+ CC += AIJ * Pz(j);
+ DCC += DAIJ * Pz(j);
+ }
}
- FX = AA-mypoints(i, i2);
- FY = BB-mypoints(i, i2+1);
- Fi = FX*FX + FY*FY;
- Gr = 2.0*(DAA*FX + DBB*FY);
-
- if (k <= nbP) {
- FZ = CC-mypoints(i, i2+2);
- Fi += FZ*FZ;
- Gr += 2.0*DCC*FZ;
- if (Fi > MaxE3d) MaxE3d = Fi;
+ FX = AA - mypoints(i, i2);
+ FY = BB - mypoints(i, i2 + 1);
+ Fi = FX * FX + FY * FY;
+ Gr = 2.0 * (DAA * FX + DBB * FY);
+
+ if (k <= nbP)
+ {
+ FZ = CC - mypoints(i, i2 + 2);
+ Fi += FZ * FZ;
+ Gr += 2.0 * DCC * FZ;
+ if (Fi > MaxE3d)
+ MaxE3d = Fi;
}
- else {
- if (Fi > MaxE2d) MaxE2d = Fi;
+ else
+ {
+ if (Fi > MaxE2d)
+ MaxE2d = Fi;
}
theError(i, k) = Fi;
Grad(i) += Gr;
F += Fi;
}
- if (k <= nbP) i2 += 3;
- else i2 += 2;
+ if (k <= nbP)
+ i2 += 3;
+ else
+ i2 += 2;
}
MaxE3d = Sqrt(MaxE3d);
MaxE2d = Sqrt(MaxE2d);
-
}
-
const math_Matrix& AppParCurves_LeastSquare::Distance()
{
- if (!iscalculated) {
- for (Standard_Integer i = myfirstp; i <= mylastp; i++) {
- for (Standard_Integer j = 1; j <= nbP+nbP2d; j++) {
- theError(i, j) = Sqrt(theError(i, j));
+ if (!iscalculated)
+ {
+ for (Standard_Integer i = myfirstp; i <= mylastp; i++)
+ {
+ for (Standard_Integer j = 1; j <= nbP + nbP2d; j++)
+ {
+ theError(i, j) = Sqrt(theError(i, j));
}
}
iscalculated = Standard_True;
return theError;
}
-
Standard_Real AppParCurves_LeastSquare::FirstLambda() const
{
return lambda1;
return lambda2;
}
-
-
Standard_Boolean AppParCurves_LeastSquare::IsDone() const
{
return done;
}
-
-AppParCurves_MultiCurve AppParCurves_LeastSquare::BezierValue()
+AppParCurves_MultiCurve AppParCurves_LeastSquare::BezierValue()
{
- if (!myknots.IsNull()) throw Standard_NoSuchObject();
+ if (!myknots.IsNull())
+ throw Standard_NoSuchObject();
return (AppParCurves_MultiCurve)(BSplineValue());
}
-
-const AppParCurves_MultiBSpCurve& AppParCurves_LeastSquare::BSplineValue()
+const AppParCurves_MultiBSpCurve& AppParCurves_LeastSquare::BSplineValue()
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
- Standard_Integer i, j, j2, npoints = nbP+nbP2d;
- gp_Pnt Pt;
- gp_Pnt2d Pt2d;
+ Standard_Integer i, j, j2, npoints = nbP + nbP2d;
+ gp_Pnt Pt;
+ gp_Pnt2d Pt2d;
Standard_Integer ideb = resinit, ifin = resfin;
- if (ideb >= 2) ideb = 2;
- if (ifin <= nbpoles-1) ifin = nbpoles-1;
+ if (ideb >= 2)
+ ideb = 2;
+ if (ifin <= nbpoles - 1)
+ ifin = nbpoles - 1;
// On met le resultat dans les curves correspondantes
- for (i = ideb; i <= ifin; i++) {
+ for (i = ideb; i <= ifin; i++)
+ {
j2 = 1;
AppParCurves_MultiPoint MPole(nbP, nbP2d);
- for (j = 1; j <= nbP; j++) {
- Pt.SetCoord(mypoles(i, j2), mypoles(i, j2+1), mypoles(i,j2+2));
+ for (j = 1; j <= nbP; j++)
+ {
+ Pt.SetCoord(mypoles(i, j2), mypoles(i, j2 + 1), mypoles(i, j2 + 2));
MPole.SetPoint(j, Pt);
j2 += 3;
}
- for (j = nbP+1;j <= npoints; j++) {
- Pt2d.SetCoord(mypoles(i, j2), mypoles(i, j2+1));
+ for (j = nbP + 1; j <= npoints; j++)
+ {
+ Pt2d.SetCoord(mypoles(i, j2), mypoles(i, j2 + 1));
MPole.SetPoint2d(j, Pt2d);
j2 += 2;
}
return SCU;
}
-
-
const math_Matrix& AppParCurves_LeastSquare::FunctionMatrix() const
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
return A;
}
-
const math_Matrix& AppParCurves_LeastSquare::DerivativeFunctionMatrix() const
{
- if (!done) {throw StdFail_NotDone();}
+ if (!done)
+ {
+ throw StdFail_NotDone();
+ }
return DA;
}
-
-
-
-Standard_Integer AppParCurves_LeastSquare::
- TheFirstPoint(const AppParCurves_Constraint FirstCons,
- const Standard_Integer FirstPoint) const
+Standard_Integer AppParCurves_LeastSquare::TheFirstPoint(const AppParCurves_Constraint FirstCons,
+ const Standard_Integer FirstPoint) const
{
- if (FirstCons == AppParCurves_NoConstraint)
+ if (FirstCons == AppParCurves_NoConstraint)
return FirstPoint;
- else
+ else
return FirstPoint + 1;
}
-
-
-Standard_Integer AppParCurves_LeastSquare::
- TheLastPoint(const AppParCurves_Constraint LastCons,
- const Standard_Integer LastPoint) const
+Standard_Integer AppParCurves_LeastSquare::TheLastPoint(const AppParCurves_Constraint LastCons,
+ const Standard_Integer LastPoint) const
{
if (LastCons == AppParCurves_NoConstraint)
return LastPoint;
- else
+ else
return LastPoint - 1;
}
-
-void AppParCurves_LeastSquare::ComputeFunction(const math_Vector& Parameters)
+void AppParCurves_LeastSquare::ComputeFunction(const math_Vector& Parameters)
{
- if (myknots.IsNull()) {
- AppParCurves::Bernstein(nbpoles, Parameters, A, DA);
+ if (myknots.IsNull())
+ {
+ AppParCurves::Bernstein(nbpoles, Parameters, A, DA);
}
- else {
- AppParCurves::SplineFunction(nbpoles, deg, Parameters,
- Vflatknots, A, DA, myindex);
+ else
+ {
+ AppParCurves::SplineFunction(nbpoles, deg, Parameters, Vflatknots, A, DA, myindex);
}
}
-
-
const math_Matrix& AppParCurves_LeastSquare::Points() const
{
return mypoints;
return mypoles;
}
-
-
const math_IntegerVector& AppParCurves_LeastSquare::KIndex() const
{
return myindex;
}
-
-
-
-void AppParCurves_LeastSquare::MakeTAA(math_Vector& TheA,
- math_Vector& myTAB)
+void AppParCurves_LeastSquare::MakeTAA(math_Vector& TheA, math_Vector& myTAB)
{
Standard_Integer i, j, k, Ci, i2, i21, i22;
- Standard_Real xx = 0.0, yy = 0.0;
+ Standard_Real xx = 0.0, yy = 0.0;
- Standard_Integer Nincx = resfin-resinit+1;
- Standard_Integer Nrow, Neq = LastP-FirstP+1;
+ Standard_Integer Nincx = resfin - resinit + 1;
+ Standard_Integer Nrow, Neq = LastP - FirstP + 1;
Standard_Integer Ninc1;
- if (FirstConstraint >= AppParCurves_TangencyPoint &&
- LastConstraint >= AppParCurves_TangencyPoint) {
- Ninc1 = Ninc-1;
+ if (FirstConstraint >= AppParCurves_TangencyPoint && LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ Ninc1 = Ninc - 1;
}
- else Ninc1 = Ninc;
+ else
+ Ninc1 = Ninc;
Standard_Integer myfirst = A.LowerRow();
Standard_Integer ix, iy, iz;
- Standard_Integer mylast = myfirst+Nlignes-1;
+ Standard_Integer mylast = myfirst + Nlignes - 1;
Standard_Integer k1;
- Standard_Real taf1 = 0.0, taf2 = 0.0, taf3 = 0.0,
- tab1 = 0.0, tab2 = 0.0;
+ Standard_Real taf1 = 0.0, taf2 = 0.0, taf3 = 0.0, tab1 = 0.0, tab2 = 0.0;
Standard_Integer nb, inc, jinit, jfin, u;
Standard_Integer indexdeb, indexfin;
- Standard_Integer NA1 = NA-1;
- Standard_Real v1=0, v2=0, b;
- Standard_Real Ai2, Aid, Akj;
- math_Vector myB(myfirst, mylast, 0.0),
- myV1(myfirst, mylast, 0.0),
- myV2(myfirst, mylast, 0.0);
+ Standard_Integer NA1 = NA - 1;
+ Standard_Real v1 = 0, v2 = 0, b;
+ Standard_Real Ai2, Aid, Akj;
+ math_Vector myB(myfirst, mylast, 0.0), myV1(myfirst, mylast, 0.0), myV2(myfirst, mylast, 0.0);
math_Vector TheV1(1, Ninc, 0.0), TheV2(1, Ninc, 0.0);
-
- for (i = FirstP; i <= LastP; i++) {
+ for (i = FirstP; i <= LastP; i++)
+ {
Ai2 = A(i, 2);
- Aid = A(i, nbpoles-1);
- if (FirstConstraint >= AppParCurves_PassPoint) xx = A(i, 1);
- if (FirstConstraint >= AppParCurves_TangencyPoint) xx += Ai2;
- if (LastConstraint >= AppParCurves_PassPoint) yy = A(i, nbpoles);
- if (LastConstraint >= AppParCurves_TangencyPoint) yy += Aid;
- i2 = 1;
- Nrow = myfirst-FirstP;
- for (Ci = 1; Ci <= nbP; Ci++) {
- i21 = i2+1; i22 = i2+2;
- ix = i+Nrow; iy = ix+Neq; iz = iy+Neq;
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
- myV1(ix) = Ai2*Vec1t(i2);
- myV1(iy) = Ai2*Vec1t(i21);
- myV1(iz) = Ai2*Vec1t(i22);
+ Aid = A(i, nbpoles - 1);
+ if (FirstConstraint >= AppParCurves_PassPoint)
+ xx = A(i, 1);
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ xx += Ai2;
+ if (LastConstraint >= AppParCurves_PassPoint)
+ yy = A(i, nbpoles);
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ yy += Aid;
+ i2 = 1;
+ Nrow = myfirst - FirstP;
+ for (Ci = 1; Ci <= nbP; Ci++)
+ {
+ i21 = i2 + 1;
+ i22 = i2 + 2;
+ ix = i + Nrow;
+ iy = ix + Neq;
+ iz = iy + Neq;
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
+ myV1(ix) = Ai2 * Vec1t(i2);
+ myV1(iy) = Ai2 * Vec1t(i21);
+ myV1(iz) = Ai2 * Vec1t(i22);
}
- if (LastConstraint >= AppParCurves_TangencyPoint) {
- myV2(ix) = -Aid*Vec2t(i2);
- myV2(iy) = -Aid*Vec2t(i21);
- myV2(iz) = -Aid*Vec2t(i22);
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ myV2(ix) = -Aid * Vec2t(i2);
+ myV2(iy) = -Aid * Vec2t(i21);
+ myV2(iz) = -Aid * Vec2t(i22);
}
- myB(ix) = mypoints(i, i2) - xx*mypoints(myfirstp, i2)
- - yy*mypoints(mylastp, i2);
- myB(iy) = mypoints(i, i21) - xx*mypoints(myfirstp, i21)
- - yy*mypoints(mylastp, i21);
- myB(iz) = mypoints(i, i22) - xx*mypoints(myfirstp, i22)
- - yy*mypoints(mylastp, i22);
+ myB(ix) = mypoints(i, i2) - xx * mypoints(myfirstp, i2) - yy * mypoints(mylastp, i2);
+ myB(iy) = mypoints(i, i21) - xx * mypoints(myfirstp, i21) - yy * mypoints(mylastp, i21);
+ myB(iz) = mypoints(i, i22) - xx * mypoints(myfirstp, i22) - yy * mypoints(mylastp, i22);
i2 += 3;
- Nrow = Nrow + 3*Neq;
- }
-
- for (Ci = 1; Ci <= nbP2d; Ci++) {
- i21 = i2+1; i22 = i2+2;
- ix = i+Nrow; iy = ix+Neq;
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
- myV1(ix) = Ai2*Vec1t(i2);
- myV1(iy) = Ai2*Vec1t(i21);
+ Nrow = Nrow + 3 * Neq;
+ }
+
+ for (Ci = 1; Ci <= nbP2d; Ci++)
+ {
+ i21 = i2 + 1;
+ i22 = i2 + 2;
+ ix = i + Nrow;
+ iy = ix + Neq;
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
+ myV1(ix) = Ai2 * Vec1t(i2);
+ myV1(iy) = Ai2 * Vec1t(i21);
}
- if (LastConstraint >= AppParCurves_TangencyPoint) {
- myV2(ix) = -Aid*Vec2t(i2);
- myV2(iy) = -Aid*Vec2t(i21);
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ myV2(ix) = -Aid * Vec2t(i2);
+ myV2(iy) = -Aid * Vec2t(i21);
}
- myB(ix) = mypoints(i, i2) - xx*mypoints(myfirstp, i2)
- - yy*mypoints(mylastp, i2);
- myB(iy) = mypoints(i, i21) - xx*mypoints(myfirstp, i21)
- - yy*mypoints(mylastp, i21);
- Nrow = Nrow + 2*Neq;
+ myB(ix) = mypoints(i, i2) - xx * mypoints(myfirstp, i2) - yy * mypoints(mylastp, i2);
+ myB(iy) = mypoints(i, i21) - xx * mypoints(myfirstp, i21) - yy * mypoints(mylastp, i21);
+ Nrow = Nrow + 2 * Neq;
i2 += 2;
}
- }
-
-
-
+ }
+
// Construction de TA*A et TA*B:
-
- for (k = FirstP; k <= LastP; k++) {
- indexdeb = myindex(k)+1;
- indexfin = indexdeb + deg;
- jinit = Max(resinit, indexdeb);
- jfin = Min(resfin, indexfin);
- k1 = k + myfirst - FirstP;
- for (i = 0; i <= NA1; i++) {
- nb = i*Neq + k1;
+
+ for (k = FirstP; k <= LastP; k++)
+ {
+ indexdeb = myindex(k) + 1;
+ indexfin = indexdeb + deg;
+ jinit = Max(resinit, indexdeb);
+ jfin = Min(resfin, indexfin);
+ k1 = k + myfirst - FirstP;
+ for (i = 0; i <= NA1; i++)
+ {
+ nb = i * Neq + k1;
if (FirstConstraint >= AppParCurves_TangencyPoint)
- v1 = myV1(nb);
+ v1 = myV1(nb);
if (LastConstraint >= AppParCurves_TangencyPoint)
- v2 = myV2(nb);
- b = myB(nb);
- inc = i*Nincx-resinit+1;
- for (j = jinit; j <= jfin; j++) {
- Akj = A(k, j);
- u = j+inc;
- if (FirstConstraint >= AppParCurves_TangencyPoint)
- TheV1(u) += Akj*v1;
- if (LastConstraint >= AppParCurves_TangencyPoint)
- TheV2(u) += Akj*v2;
- myTAB(u) += Akj*b;
+ v2 = myV2(nb);
+ b = myB(nb);
+ inc = i * Nincx - resinit + 1;
+ for (j = jinit; j <= jfin; j++)
+ {
+ Akj = A(k, j);
+ u = j + inc;
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ TheV1(u) += Akj * v1;
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ TheV2(u) += Akj * v2;
+ myTAB(u) += Akj * b;
}
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
- taf1 += v1*v1;
- tab1 += v1*b;
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
+ taf1 += v1 * v1;
+ tab1 += v1 * b;
}
- if (LastConstraint >= AppParCurves_TangencyPoint) {
- taf2 += v2*v2;
- tab2 += v2*b;
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ taf2 += v2 * v2;
+ tab2 += v2 * b;
}
- if (FirstConstraint >= AppParCurves_TangencyPoint &&
- LastConstraint >= AppParCurves_TangencyPoint) {
- taf3 += v1*v2;
+ if (FirstConstraint >= AppParCurves_TangencyPoint
+ && LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ taf3 += v1 * v2;
}
}
}
-
- if (FirstConstraint >= AppParCurves_TangencyPoint) {
+ if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
TheV1(Ninc1) = taf1;
myTAB(Ninc1) = tab1;
}
- if (LastConstraint >= AppParCurves_TangencyPoint) {
- TheV2(Ninc) = taf2;
- myTAB(Ninc) = tab2;
+ if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ TheV2(Ninc) = taf2;
+ myTAB(Ninc) = tab2;
}
- if (FirstConstraint >= AppParCurves_TangencyPoint &&
- LastConstraint >= AppParCurves_TangencyPoint) {
+ if (FirstConstraint >= AppParCurves_TangencyPoint && LastConstraint >= AppParCurves_TangencyPoint)
+ {
TheV2(Ninc1) = taf3;
}
-
- if (resinit <= resfin) {
+ if (resinit <= resfin)
+ {
math_IntegerVector Index(1, Nincx);
SearchIndex(Index);
math_Vector AA(1, Index(Nincx));
MakeTAA(AA);
-
+
Standard_Integer kk = 1;
- for (k = 1; k <= NA; k++) {
- for(i = 1; i <= AA.Length(); i++) {
- TheA(kk) = AA(i);
- kk++;
+ for (k = 1; k <= NA; k++)
+ {
+ for (i = 1; i <= AA.Length(); i++)
+ {
+ TheA(kk) = AA(i);
+ kk++;
}
}
}
-
+
Standard_Integer length = TheA.Length();
-
- if (FirstConstraint >= AppParCurves_TangencyPoint &&
- LastConstraint >= AppParCurves_TangencyPoint) {
- for (j = 1; j <= Ninc1; j++)
- TheA(length- 2*Ninc+j+1) = TheV1(j);
- for (j = 1; j <= Ninc; j++)
- TheA(length- Ninc+j) = TheV2(j);
- }
+ if (FirstConstraint >= AppParCurves_TangencyPoint && LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ for (j = 1; j <= Ninc1; j++)
+ TheA(length - 2 * Ninc + j + 1) = TheV1(j);
+ for (j = 1; j <= Ninc; j++)
+ TheA(length - Ninc + j) = TheV2(j);
+ }
- else if (FirstConstraint >= AppParCurves_TangencyPoint) {
- for (j = 1; j <= Ninc; j++)
- TheA(length- Ninc+j) = TheV1(j);
+ else if (FirstConstraint >= AppParCurves_TangencyPoint)
+ {
+ for (j = 1; j <= Ninc; j++)
+ TheA(length - Ninc + j) = TheV1(j);
}
- else if (LastConstraint >= AppParCurves_TangencyPoint) {
- for (j = 1; j <= Ninc; j++)
- TheA(length- Ninc+j) = TheV2(j);
+ else if (LastConstraint >= AppParCurves_TangencyPoint)
+ {
+ for (j = 1; j <= Ninc; j++)
+ TheA(length - Ninc + j) = TheV2(j);
}
}
-
-
-
-void AppParCurves_LeastSquare::MakeTAA(math_Vector& AA,
- math_Matrix& myTAB)
+void AppParCurves_LeastSquare::MakeTAA(math_Vector& AA, math_Matrix& myTAB)
{
Standard_Integer i, j, k;
Standard_Integer indexdeb, indexfin, jinit, jfin;
Standard_Integer iinit, ifin;
- Standard_Real Akj;
- math_Matrix TheA(resinit, resfin, resinit, resfin);
+ Standard_Real Akj;
+ math_Matrix TheA(resinit, resfin, resinit, resfin);
TheA.Init(0.0);
- for (k = FirstP ; k <= LastP; k++) {
- indexdeb = myindex(k)+1;
+ for (k = FirstP; k <= LastP; k++)
+ {
+ indexdeb = myindex(k) + 1;
indexfin = indexdeb + deg;
- jinit = Max(resinit, indexdeb);
- jfin = Min(resfin, indexfin);
- for (i = jinit; i <= jfin; i++) {
+ jinit = Max(resinit, indexdeb);
+ jfin = Min(resfin, indexfin);
+ for (i = jinit; i <= jfin; i++)
+ {
Akj = A(k, i);
- for (j = jinit; j <= i; j++) {
- TheA(i, j) += A(k, j) * Akj;
+ for (j = jinit; j <= i; j++)
+ {
+ TheA(i, j) += A(k, j) * Akj;
}
- for (j = 1; j <= B2.ColNumber(); j++) {
- myTAB(i, j) += Akj*B2(k, j);
+ for (j = 1; j <= B2.ColNumber(); j++)
+ {
+ myTAB(i, j) += Akj * B2(k, j);
}
}
}
Standard_Integer len;
- if (!myknots.IsNull()) len = myknots->Length();
- else len = 2;
+ if (!myknots.IsNull())
+ len = myknots->Length();
+ else
+ len = 2;
Standard_Integer d, i2 = 1;
iinit = resinit;
jinit = resinit;
- ifin = Min(resfin, deg+1);
- for (k = 2; k <= len; k++) {
- for (i = iinit; i <= ifin; i++) {
- for (j = jinit; j <= i; j++) {
- AA(i2) = TheA(i, j);
- i2++;
+ ifin = Min(resfin, deg + 1);
+ for (k = 2; k <= len; k++)
+ {
+ for (i = iinit; i <= ifin; i++)
+ {
+ for (j = jinit; j <= i; j++)
+ {
+ AA(i2) = TheA(i, j);
+ i2++;
}
}
- if (!mymults.IsNull()) {
- iinit = ifin+1;
- d = ifin + mymults->Value(k);
- ifin = Min(d, resfin);
+ if (!mymults.IsNull())
+ {
+ iinit = ifin + 1;
+ d = ifin + mymults->Value(k);
+ ifin = Min(d, resfin);
jinit = Max(resinit, d - deg);
}
}
}
-
void AppParCurves_LeastSquare::MakeTAA(math_Vector& AA)
{
Standard_Integer i, j, k;
Standard_Integer indexdeb, indexfin, jinit, jfin;
Standard_Integer iinit, ifin;
- Standard_Real Akj;
- math_Matrix TheA(resinit, resfin, resinit, resfin, 0.0);
-
+ Standard_Real Akj;
+ math_Matrix TheA(resinit, resfin, resinit, resfin, 0.0);
- for (k = FirstP ; k <= LastP; k++) {
- indexdeb = myindex(k)+1;
+ for (k = FirstP; k <= LastP; k++)
+ {
+ indexdeb = myindex(k) + 1;
indexfin = indexdeb + deg;
- jinit = Max(resinit, indexdeb);
- jfin = Min(resfin, indexfin);
- for (i = jinit; i <= jfin; i++) {
+ jinit = Max(resinit, indexdeb);
+ jfin = Min(resfin, indexfin);
+ for (i = jinit; i <= jfin; i++)
+ {
Akj = A(k, i);
- for (j = jinit; j <= i; j++) {
- TheA(i, j) += A(k, j) * Akj;
+ for (j = jinit; j <= i; j++)
+ {
+ TheA(i, j) += A(k, j) * Akj;
}
}
}
-
Standard_Integer i2 = 1;
- iinit = resinit;
- jinit = resinit;
- ifin = Min(resfin, deg+1);
+ iinit = resinit;
+ jinit = resinit;
+ ifin = Min(resfin, deg + 1);
Standard_Integer len, d;
- if (!myknots.IsNull()) len = myknots->Length();
- else len = 2;
- for (k = 2; k <= len; k++) {
- for (i = iinit; i <= ifin; i++) {
- for (j = jinit; j <= i; j++) {
- AA(i2) = TheA(i, j);
- i2++;
+ if (!myknots.IsNull())
+ len = myknots->Length();
+ else
+ len = 2;
+ for (k = 2; k <= len; k++)
+ {
+ for (i = iinit; i <= ifin; i++)
+ {
+ for (j = jinit; j <= i; j++)
+ {
+ AA(i2) = TheA(i, j);
+ i2++;
}
}
- if (!mymults.IsNull()) {
- iinit = ifin+1;
- d = ifin + mymults->Value(k);
- ifin = Min(d, resfin);
+ if (!mymults.IsNull())
+ {
+ iinit = ifin + 1;
+ d = ifin + mymults->Value(k);
+ ifin = Min(d, resfin);
jinit = Max(resinit, d - deg);
}
}
-
}
-
-
void AppParCurves_LeastSquare::SearchIndex(math_IntegerVector& Index)
{
Standard_Integer iinit, jinit, ifin;
Standard_Integer i, j, k, d, i2 = 1;
Standard_Integer len;
- Standard_Integer Nincx = resfin-resinit+1;
- Index(1) = 1;
+ Standard_Integer Nincx = resfin - resinit + 1;
+ Index(1) = 1;
- if (myknots.IsNull()) {
- if (resinit <= resfin) {
+ if (myknots.IsNull())
+ {
+ if (resinit <= resfin)
+ {
Standard_Integer l = 1;
- for (i = 2; i <= Nincx; i++) {
- l++;
- Index(l) = Index(l-1)+i;
+ for (i = 2; i <= Nincx; i++)
+ {
+ l++;
+ Index(l) = Index(l - 1) + i;
}
}
-
}
- else {
+ else
+ {
iinit = resinit;
jinit = resinit;
- ifin = Min(resfin, deg+1);
- len = myknots->Length();
-
- for (k = 2; k <= len; k++) {
- for (i = iinit; i <= ifin; i++) {
- for (j = jinit; j <= i; j++) {
- if (i2 != 1)
- Index(i2) = Index(i2-1) + i-jinit+1;
- }
- i2++;
+ ifin = Min(resfin, deg + 1);
+ len = myknots->Length();
+
+ for (k = 2; k <= len; k++)
+ {
+ for (i = iinit; i <= ifin; i++)
+ {
+ for (j = jinit; j <= i; j++)
+ {
+ if (i2 != 1)
+ Index(i2) = Index(i2 - 1) + i - jinit + 1;
+ }
+ i2++;
}
- iinit = ifin+1;
- d = ifin + mymults->Value(k);
- ifin = Min(d, resfin);
+ iinit = ifin + 1;
+ d = ifin + mymults->Value(k);
+ ifin = Min(d, resfin);
jinit = Max(resinit, d - deg);
}
}
// lpa, le 11/09/91
-
-// Approximation d un ensemble de points contraints (MultiLine) avec une
-// solution approchee (MultiCurve). L algorithme utilise est l algorithme
+// Approximation d un ensemble de points contraints (MultiLine) avec une
+// solution approchee (MultiCurve). L algorithme utilise est l algorithme
// d Uzawa du package mathematique.
#define No_Standard_RangeError
#include <TColgp_Array1OfVec.hxx>
#include <TColgp_Array1OfVec2d.hxx>
-
-AppParCurves_ResolConstraint::
- AppParCurves_ResolConstraint(const MultiLine& SSP,
- AppParCurves_MultiCurve& SCurv,
- const Standard_Integer FirstPoint,
- const Standard_Integer LastPoint,
- const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
- const math_Matrix& Bern,
- const math_Matrix& DerivativeBern,
- const Standard_Real Tolerance):
- Cont(1, NbConstraints(SSP, FirstPoint,
- LastPoint, TheConstraints),
- 1, NbColumns(SSP, SCurv.NbPoles()-1), 0.0),
- DeCont(1, NbConstraints(SSP, FirstPoint,
- LastPoint, TheConstraints),
- 1, NbColumns(SSP, SCurv.NbPoles()-1), 0.0),
- Secont(1, NbConstraints(SSP, FirstPoint,
- LastPoint, TheConstraints), 0.0),
- CTCinv(1, NbConstraints(SSP, FirstPoint,
- LastPoint, TheConstraints),
- 1, NbConstraints(SSP, FirstPoint,
- LastPoint, TheConstraints)),
- Vardua(1, NbConstraints(SSP, FirstPoint,
- LastPoint, TheConstraints)),
- IPas(1, LastPoint-FirstPoint+1),
- ITan(1, LastPoint-FirstPoint+1),
- ICurv(1, LastPoint-FirstPoint+1)
- {
- Standard_Integer i, j, k, NbCu= SCurv.NbCurves();
- Standard_Integer Npt;
- Standard_Integer Inc3, IncSec, IncCol, IP = 0, CCol;
- Standard_Integer myindex, Def = SCurv.NbPoles()-1;
- Standard_Integer nb3d, nb2d, Npol= Def+1, Npol2 = 2*Npol;
- Standard_Real T1 = 0., T2 = 0., T3, Tmax, Daij;
- gp_Vec V;
- gp_Vec2d V2d;
- gp_Pnt Poi;
- gp_Pnt2d Poi2d;
+AppParCurves_ResolConstraint::AppParCurves_ResolConstraint(
+ const MultiLine& SSP,
+ AppParCurves_MultiCurve& SCurv,
+ const Standard_Integer FirstPoint,
+ const Standard_Integer LastPoint,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
+ const math_Matrix& Bern,
+ const math_Matrix& DerivativeBern,
+ const Standard_Real Tolerance)
+ : Cont(1,
+ NbConstraints(SSP, FirstPoint, LastPoint, TheConstraints),
+ 1,
+ NbColumns(SSP, SCurv.NbPoles() - 1),
+ 0.0),
+ DeCont(1,
+ NbConstraints(SSP, FirstPoint, LastPoint, TheConstraints),
+ 1,
+ NbColumns(SSP, SCurv.NbPoles() - 1),
+ 0.0),
+ Secont(1, NbConstraints(SSP, FirstPoint, LastPoint, TheConstraints), 0.0),
+ CTCinv(1,
+ NbConstraints(SSP, FirstPoint, LastPoint, TheConstraints),
+ 1,
+ NbConstraints(SSP, FirstPoint, LastPoint, TheConstraints)),
+ Vardua(1, NbConstraints(SSP, FirstPoint, LastPoint, TheConstraints)),
+ IPas(1, LastPoint - FirstPoint + 1),
+ ITan(1, LastPoint - FirstPoint + 1),
+ ICurv(1, LastPoint - FirstPoint + 1)
+{
+ Standard_Integer i, j, k, NbCu = SCurv.NbCurves();
+ Standard_Integer Npt;
+ Standard_Integer Inc3, IncSec, IncCol, IP = 0, CCol;
+ Standard_Integer myindex, Def = SCurv.NbPoles() - 1;
+ Standard_Integer nb3d, nb2d, Npol = Def + 1, Npol2 = 2 * Npol;
+ Standard_Real T1 = 0., T2 = 0., T3, Tmax, Daij;
+ gp_Vec V;
+ gp_Vec2d V2d;
+ gp_Pnt Poi;
+ gp_Pnt2d Poi2d;
AppParCurves_ConstraintCouple mycouple;
- AppParCurves_Constraint FC = AppParCurves_NoConstraint,
- LC = AppParCurves_NoConstraint, Cons;
-
-
+ AppParCurves_Constraint FC = AppParCurves_NoConstraint, LC = AppParCurves_NoConstraint, Cons;
- // Boucle de calcul du nombre de points de passage afin de dimensionner
+ // Boucle de calcul du nombre de points de passage afin de dimensionner
// les matrices.
IncPass = 0;
- IncTan = 0;
+ IncTan = 0;
IncCurv = 0;
- for (i = TheConstraints->Lower(); i <= TheConstraints->Upper(); i++) {
+ for (i = TheConstraints->Lower(); i <= TheConstraints->Upper(); i++)
+ {
mycouple = TheConstraints->Value(i);
- myindex = mycouple.Index();
- Cons = mycouple.Constraint();
- if (myindex == FirstPoint) FC = Cons;
- if (myindex == LastPoint) LC = Cons;
- if (Cons >= 1) {
- IncPass++; // IncPass = nbre de points de passage.
+ myindex = mycouple.Index();
+ Cons = mycouple.Constraint();
+ if (myindex == FirstPoint)
+ FC = Cons;
+ if (myindex == LastPoint)
+ LC = Cons;
+ if (Cons >= 1)
+ {
+ IncPass++; // IncPass = nbre de points de passage.
IPas(IncPass) = myindex;
}
- if (Cons >= 2) {
- IncTan++; // IncTan= nbre de points de tangence.
+ if (Cons >= 2)
+ {
+ IncTan++; // IncTan= nbre de points de tangence.
ITan(IncTan) = myindex;
}
- if (Cons == 3) {
- IncCurv++; // IncCurv = nbre de pts de courbure.
+ if (Cons == 3)
+ {
+ IncCurv++; // IncCurv = nbre de pts de courbure.
ICurv(IncCurv) = myindex;
}
}
-
- if (IncPass == 0) {
+ if (IncPass == 0)
+ {
Done = Standard_True;
return;
}
- nb3d = ToolLine::NbP3d(SSP);
- nb2d = ToolLine::NbP2d(SSP);
- Standard_Integer mynb3d=nb3d, mynb2d=nb2d;
- if (nb3d == 0) mynb3d = 1;
- if (nb2d == 0) mynb2d = 1;
- CCol = nb3d* 3 + nb2d* 2;
+ nb3d = ToolLine::NbP3d(SSP);
+ nb2d = ToolLine::NbP2d(SSP);
+ Standard_Integer mynb3d = nb3d, mynb2d = nb2d;
+ if (nb3d == 0)
+ mynb3d = 1;
+ if (nb2d == 0)
+ mynb2d = 1;
+ CCol = nb3d * 3 + nb2d * 2;
-
// Declaration et initialisation des matrices et vecteurs de contraintes:
- math_Matrix ContInit(1, IncPass, 1, Npol);
- math_Vector Start(1, CCol*Npol);
+ math_Matrix ContInit(1, IncPass, 1, Npol);
+ math_Vector Start(1, CCol * Npol);
TColStd_Array2OfInteger Ibont(1, NbCu, 1, IncTan);
-
// Remplissage de Cont pour les points de passage:
// =================================================
- for (i =1; i <= IncPass; i++) { // Cette partie ne depend que de Bernstein
+ for (i = 1; i <= IncPass; i++)
+ { // Cette partie ne depend que de Bernstein
Npt = IPas(i);
- for (j = 1; j <= Npol; j++) {
+ for (j = 1; j <= Npol; j++)
+ {
ContInit(i, j) = Bern(Npt, j);
}
}
- for (i = 1; i <= CCol; i++) {
- Cont.Set(IncPass*(i-1)+1, IncPass*i, Npol*(i-1)+1, Npol*i, ContInit);
+ for (i = 1; i <= CCol; i++)
+ {
+ Cont.Set(IncPass * (i - 1) + 1, IncPass * i, Npol * (i - 1) + 1, Npol * i, ContInit);
}
+ // recuperation des vecteurs de depart pour Uzawa. Ce vecteur represente les
+ // poles de SCurv.
+ // Remplissage de secont et resolution.
-// recuperation des vecteurs de depart pour Uzawa. Ce vecteur represente les
-// poles de SCurv.
-// Remplissage de secont et resolution.
-
- TColgp_Array1OfVec tabV(1, mynb3d);
+ TColgp_Array1OfVec tabV(1, mynb3d);
TColgp_Array1OfVec2d tabV2d(1, mynb2d);
- TColgp_Array1OfPnt tabP(1, mynb3d);
+ TColgp_Array1OfPnt tabP(1, mynb3d);
TColgp_Array1OfPnt2d tabP2d(1, mynb2d);
- Inc3 = CCol*IncPass +1;
+ Inc3 = CCol * IncPass + 1;
IncCol = 0;
IncSec = 0;
- for (k = 1; k <= NbCu; k++) {
- if (k <= nb3d) {
- for (i = 1; i <= IncTan; i++) {
- Npt = ITan(i);
- // choix du maximum de tangence pour exprimer la colinearite:
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- V.Coord(T1, T2, T3);
- Tmax = Abs(T1);
- Ibont(k, i) = 1;
- if (Abs(T2) > Tmax) {
- Tmax = Abs(T2);
- Ibont(k, i) = 2;
- }
- if (Abs(T3) > Tmax) {
- Tmax = Abs(T3);
- Ibont(k, i) = 3;
- }
- if (Ibont(k, i) == 3) {
- for (j = 1; j <= Npol; j++) {
- Daij = DerivativeBern(Npt, j);
- Cont(Inc3, j+ Npol + IncCol) = Daij*T3/Tmax;
- Cont(Inc3, j + Npol2 + IncCol) = -Daij *T2/Tmax;
- Cont(Inc3+1, j+ IncCol) = Daij* T3/Tmax;
- Cont(Inc3+1, j+ Npol2 + IncCol) = -Daij*T1/Tmax;
- }
- }
- else if (Ibont(k, i) == 1) {
- for (j = 1; j <= Npol; j++) {
- Daij = DerivativeBern(Npt, j);
- Cont(Inc3, j + IncCol) = Daij*T3/Tmax;
- Cont(Inc3, j + Npol2 + IncCol) = -Daij *T1/Tmax;
- Cont(Inc3+1, j+ IncCol) = Daij* T2/Tmax;
- Cont(Inc3+1, j+ Npol +IncCol) = -Daij*T1/Tmax;
- }
- }
- else if (Ibont(k, i) == 2) {
- for (j = 1; j <= Def+1; j++) {
- Daij = DerivativeBern(Npt, j);
- Cont(Inc3, j+ Npol + IncCol) = Daij*T3/Tmax;
- Cont(Inc3, j + Npol2 + IncCol) = -Daij *T2/Tmax;
- Cont(Inc3+1, j+ IncCol) = Daij* T2/Tmax;
- Cont(Inc3+1, j+ Npol + IncCol) = -Daij*T1/Tmax;
- }
- }
- Inc3 = Inc3 + 2;
+ for (k = 1; k <= NbCu; k++)
+ {
+ if (k <= nb3d)
+ {
+ for (i = 1; i <= IncTan; i++)
+ {
+ Npt = ITan(i);
+ // choix du maximum de tangence pour exprimer la colinearite:
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k);
+ V.Coord(T1, T2, T3);
+ Tmax = Abs(T1);
+ Ibont(k, i) = 1;
+ if (Abs(T2) > Tmax)
+ {
+ Tmax = Abs(T2);
+ Ibont(k, i) = 2;
+ }
+ if (Abs(T3) > Tmax)
+ {
+ Tmax = Abs(T3);
+ Ibont(k, i) = 3;
+ }
+ if (Ibont(k, i) == 3)
+ {
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DerivativeBern(Npt, j);
+ Cont(Inc3, j + Npol + IncCol) = Daij * T3 / Tmax;
+ Cont(Inc3, j + Npol2 + IncCol) = -Daij * T2 / Tmax;
+ Cont(Inc3 + 1, j + IncCol) = Daij * T3 / Tmax;
+ Cont(Inc3 + 1, j + Npol2 + IncCol) = -Daij * T1 / Tmax;
+ }
+ }
+ else if (Ibont(k, i) == 1)
+ {
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DerivativeBern(Npt, j);
+ Cont(Inc3, j + IncCol) = Daij * T3 / Tmax;
+ Cont(Inc3, j + Npol2 + IncCol) = -Daij * T1 / Tmax;
+ Cont(Inc3 + 1, j + IncCol) = Daij * T2 / Tmax;
+ Cont(Inc3 + 1, j + Npol + IncCol) = -Daij * T1 / Tmax;
+ }
+ }
+ else if (Ibont(k, i) == 2)
+ {
+ for (j = 1; j <= Def + 1; j++)
+ {
+ Daij = DerivativeBern(Npt, j);
+ Cont(Inc3, j + Npol + IncCol) = Daij * T3 / Tmax;
+ Cont(Inc3, j + Npol2 + IncCol) = -Daij * T2 / Tmax;
+ Cont(Inc3 + 1, j + IncCol) = Daij * T2 / Tmax;
+ Cont(Inc3 + 1, j + Npol + IncCol) = -Daij * T1 / Tmax;
+ }
+ }
+ Inc3 = Inc3 + 2;
}
// Remplissage du second membre:
- for (i = 1; i <= IncPass; i++) {
- ToolLine::Value(SSP, IPas(i), tabP);
- Poi = tabP(k);
- Secont(i + IncSec) = Poi.X();
- Secont(i + IncPass + IncSec) = Poi.Y();
- Secont(i + 2*IncPass + IncSec) = Poi.Z();
+ for (i = 1; i <= IncPass; i++)
+ {
+ ToolLine::Value(SSP, IPas(i), tabP);
+ Poi = tabP(k);
+ Secont(i + IncSec) = Poi.X();
+ Secont(i + IncPass + IncSec) = Poi.Y();
+ Secont(i + 2 * IncPass + IncSec) = Poi.Z();
}
- IncSec = IncSec + 3*IncPass;
+ IncSec = IncSec + 3 * IncPass;
// Vecteur de depart:
- for (j =1; j <= Npol; j++) {
- Poi = SCurv.Value(j).Point(k);
- Start(j + IncCol) = Poi.X();
- Start(j+ Npol + IncCol) = Poi.Y();
- Start(j + Npol2 + IncCol) = Poi.Z();
+ for (j = 1; j <= Npol; j++)
+ {
+ Poi = SCurv.Value(j).Point(k);
+ Start(j + IncCol) = Poi.X();
+ Start(j + Npol + IncCol) = Poi.Y();
+ Start(j + Npol2 + IncCol) = Poi.Z();
}
- IncCol = IncCol + 3*Npol;
+ IncCol = IncCol + 3 * Npol;
}
-
- else {
- for (i = 1; i <= IncTan; i++) {
- Npt = ITan(i);
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k-nb3d);
- T1 = V2d.X();
- T2 = V2d.Y();
- Tmax = Abs(T1);
- Ibont(k, i) = 1;
- if (Abs(T2) > Tmax) {
- Tmax = Abs(T2);
- Ibont(k, i) = 2;
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DerivativeBern(Npt, j);
- Cont(Inc3, j + IncCol) = Daij*T2;
- Cont(Inc3, j + Npol + IncCol) = -Daij*T1;
- }
- Inc3 = Inc3 +1;
+ else
+ {
+ for (i = 1; i <= IncTan; i++)
+ {
+ Npt = ITan(i);
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k - nb3d);
+ T1 = V2d.X();
+ T2 = V2d.Y();
+ Tmax = Abs(T1);
+ Ibont(k, i) = 1;
+ if (Abs(T2) > Tmax)
+ {
+ Tmax = Abs(T2);
+ Ibont(k, i) = 2;
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DerivativeBern(Npt, j);
+ Cont(Inc3, j + IncCol) = Daij * T2;
+ Cont(Inc3, j + Npol + IncCol) = -Daij * T1;
+ }
+ Inc3 = Inc3 + 1;
}
// Remplissage du second membre:
- for (i = 1; i <= IncPass; i++) {
- ToolLine::Value(SSP, IPas(i), tabP2d);
- Poi2d = tabP2d(i-nb3d);
- Secont(i + IncSec) = Poi2d.X();
- Secont(i + IncPass + IncSec) = Poi2d.Y();
+ for (i = 1; i <= IncPass; i++)
+ {
+ ToolLine::Value(SSP, IPas(i), tabP2d);
+ Poi2d = tabP2d(i - nb3d);
+ Secont(i + IncSec) = Poi2d.X();
+ Secont(i + IncPass + IncSec) = Poi2d.Y();
}
- IncSec = IncSec + 2*IncPass;
+ IncSec = IncSec + 2 * IncPass;
// Remplissage du vecteur de depart:
- for (j = 1; j <= Npol; j++) {
- Poi2d = SCurv.Value(j).Point2d(k);
- Start(j + IncCol) = Poi2d.X();
- Start(j + Npol + IncCol) = Poi2d.Y();
+ for (j = 1; j <= Npol; j++)
+ {
+ Poi2d = SCurv.Value(j).Point2d(k);
+ Start(j + IncCol) = Poi2d.X();
+ Start(j + Npol + IncCol) = Poi2d.Y();
}
IncCol = IncCol + Npol2;
}
// On prend les coordonnees les plus significatives.
--Inc3;
- for (i = 1; i <= IncTan; ++i) {
+ for (i = 1; i <= IncTan; ++i)
+ {
IncCol = 0;
- Npt = ITan(i);
- for (k = 1; k <= NbCu-1; ++k) {
+ Npt = ITan(i);
+ for (k = 1; k <= NbCu - 1; ++k)
+ {
++Inc3;
-// Initialize first relation variable (T1)
+ // Initialize first relation variable (T1)
Standard_Integer addIndex_1 = 0, aVal = Ibont(k, i);
switch (aVal)
{
- case 1: //T1 ~ T1x
- {
- if (k <= nb3d) {
+ case 1: // T1 ~ T1x
+ {
+ if (k <= nb3d)
+ {
ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- T1 = V.X();
+ V = tabV(k);
+ T1 = V.X();
IP = 3 * Npol;
}
- else {
+ else
+ {
ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k-nb3d);
- T1 = V2d.X();
- IP = 2 * Npol;
+ V2d = tabV2d(k - nb3d);
+ T1 = V2d.X();
+ IP = 2 * Npol;
}
- addIndex_1 = 0;
+ addIndex_1 = 0;
break;
}
- case 2: //T1 ~ T1y
+ case 2: // T1 ~ T1y
{
- if (k <= nb3d) {
+ if (k <= nb3d)
+ {
ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
+ V = tabV(k);
IP = 3 * Npol;
}
- else {
+ else
+ {
ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k-nb3d);
- T1 = V2d.Y();
- IP = 2 * Npol;
+ V2d = tabV2d(k - nb3d);
+ T1 = V2d.Y();
+ IP = 2 * Npol;
}
- addIndex_1 = Npol;
+ addIndex_1 = Npol;
break;
}
- case 3: //T1 ~ T1z
+ case 3: // T1 ~ T1z
{
ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- T1 = V.Z();
- IP = 3 * Npol;
- addIndex_1 = 2 * Npol;
+ V = tabV(k);
+ T1 = V.Z();
+ IP = 3 * Npol;
+ addIndex_1 = 2 * Npol;
break;
}
}
Standard_Integer addIndex_2 = 0, aNextVal = Ibont(k + 1, i);
switch (aNextVal)
{
- case 1: //T2 ~ T2x
+ case 1: // T2 ~ T2x
{
- if ((k+1) <= nb3d) {
+ if ((k + 1) <= nb3d)
+ {
ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
+ V = tabV(k + 1);
T2 = V.X();
}
- else {
+ else
+ {
ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1-nb3d);
- T2 = V2d.X();
+ V2d = tabV2d(k + 1 - nb3d);
+ T2 = V2d.X();
}
- addIndex_2 = 0;
+ addIndex_2 = 0;
break;
}
- case 2: //T2 ~ T2y
+ case 2: // T2 ~ T2y
{
- if ((k+1) <= nb3d) {
+ if ((k + 1) <= nb3d)
+ {
ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
+ V = tabV(k + 1);
T2 = V.Y();
}
- else {
+ else
+ {
ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1-nb3d);
- T2 = V2d.Y();
+ V2d = tabV2d(k + 1 - nb3d);
+ T2 = V2d.Y();
}
- addIndex_2 = Npol;
+ addIndex_2 = Npol;
break;
}
- case 3: //T2 ~ T2z
+ case 3: // T2 ~ T2z
{
ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Z();
+ V = tabV(k + 1);
+ T2 = V.Z();
addIndex_2 = 2 * Npol;
break;
}
}
-
+
// Relations between T1 and T2:
- for (j = 1; j <= Npol; j++) {
- Daij = DerivativeBern(Npt, j);
- Cont(Inc3, j + IncCol + addIndex_1) = Daij*T2;
- Cont(Inc3, j + IP + IncCol + addIndex_2) = -Daij*T1;
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DerivativeBern(Npt, j);
+ Cont(Inc3, j + IncCol + addIndex_1) = Daij * T2;
+ Cont(Inc3, j + IP + IncCol + addIndex_2) = -Daij * T1;
}
IncCol += IP;
}
}
-
-
// Equations concernant la courbure:
-
-/* Inc3 = Inc3 +1;
- IncCol = 0;
- for (k = 1; k <= NbCu; k++) {
- for (i = 1; i <= IncCurv; i++) {
- Npt = ICurv(i);
- AppDef_MultiPointConstraint MP = SSP.Value(Npt);
- DDA = SecondDerivativeBern(Parameters(Npt));
- if (SSP.Value(1).Dimension(k) == 3) {
- C1 = MP.Curv(k).X();
- C2 = MP.Curv(k).Y();
- C3 = MP.Curv(k).Z();
- for (j = 1; j <= Npol; j++) {
- Daij = DerivativeBern(Npt, j);
- D2Aij = DDA(j);
- Cont(Inc3, j + IncCol) = D2Aij;
- Cont(Inc3, j + Npol2 + IncCol) = -C2*Daij;
- Cont(Inc3, j + Npol + IncCol) = C3*Daij;
-
- Cont(Inc3+1, j + Npol + IncCol) = D2Aij;
- Cont(Inc3+1, j +IncCol) = -C3*Daij;
- Cont(Inc3+1, j + Npol2 + IncCol) = C1*Daij;
-
- Cont(Inc3+2, j + Npol2+IncCol) = D2Aij;
- Cont(Inc3+2, j + Npol+IncCol) = -C1*Daij;
- Cont(Inc3+2, j + IncCol) = C2*Daij;
- }
- Inc3 = Inc3 + 3;
+ /* Inc3 = Inc3 +1;
+ IncCol = 0;
+ for (k = 1; k <= NbCu; k++) {
+ for (i = 1; i <= IncCurv; i++) {
+ Npt = ICurv(i);
+ AppDef_MultiPointConstraint MP = SSP.Value(Npt);
+ DDA = SecondDerivativeBern(Parameters(Npt));
+ if (SSP.Value(1).Dimension(k) == 3) {
+ C1 = MP.Curv(k).X();
+ C2 = MP.Curv(k).Y();
+ C3 = MP.Curv(k).Z();
+ for (j = 1; j <= Npol; j++) {
+ Daij = DerivativeBern(Npt, j);
+ D2Aij = DDA(j);
+ Cont(Inc3, j + IncCol) = D2Aij;
+ Cont(Inc3, j + Npol2 + IncCol) = -C2*Daij;
+ Cont(Inc3, j + Npol + IncCol) = C3*Daij;
+
+ Cont(Inc3+1, j + Npol + IncCol) = D2Aij;
+ Cont(Inc3+1, j +IncCol) = -C3*Daij;
+ Cont(Inc3+1, j + Npol2 + IncCol) = C1*Daij;
+
+ Cont(Inc3+2, j + Npol2+IncCol) = D2Aij;
+ Cont(Inc3+2, j + Npol+IncCol) = -C1*Daij;
+ Cont(Inc3+2, j + IncCol) = C2*Daij;
+ }
+ Inc3 = Inc3 + 3;
+ }
+ else { // Dimension 2:
+ C1 = MP.Curv2d(k).X();
+ C2 = MP.Curv2d(k).Y();
+ for (j = 1; j <= Npol; j++) {
+ Daij = DerivativeBern(Npt, j);
+ D2Aij = DDA(j);
+ Cont(Inc3, j + IncCol) = D2Aij*C1;
+ Cont(Inc3+1, j + Npol + IncCol) = D2Aij*C2;
}
- else { // Dimension 2:
- C1 = MP.Curv2d(k).X();
- C2 = MP.Curv2d(k).Y();
- for (j = 1; j <= Npol; j++) {
- Daij = DerivativeBern(Npt, j);
- D2Aij = DDA(j);
- Cont(Inc3, j + IncCol) = D2Aij*C1;
- Cont(Inc3+1, j + Npol + IncCol) = D2Aij*C2;
- }
- Inc3 = Inc3 + 2;
+ Inc3 = Inc3 + 2;
+ }
}
}
- }
-*/
+ */
// Resolution par Uzawa:
math_Uzawa UzaResol(Cont, Secont, Start, Tolerance);
- if (!(UzaResol.IsDone())) {
+ if (!(UzaResol.IsDone()))
+ {
Done = Standard_False;
return;
}
CTCinv = UzaResol.InverseCont();
UzaResol.Duale(Vardua);
- for (i = 1; i <= CTCinv.RowNumber(); i++) {
- for (j = i; j <= CTCinv.RowNumber(); j++) {
+ for (i = 1; i <= CTCinv.RowNumber(); i++)
+ {
+ for (j = i; j <= CTCinv.RowNumber(); j++)
+ {
CTCinv(i, j) = CTCinv(j, i);
}
}
Done = Standard_True;
- math_Vector VecPoles (1, CCol*Npol);
+ math_Vector VecPoles(1, CCol * Npol);
VecPoles = UzaResol.Value();
- Standard_Integer polinit = 1, polfin=Npol;
- if (FC >= 1) polinit = 2;
- if (LC >= 1) polfin = Npol-1;
+ Standard_Integer polinit = 1, polfin = Npol;
+ if (FC >= 1)
+ polinit = 2;
+ if (LC >= 1)
+ polfin = Npol - 1;
- for (i = polinit; i <= polfin; i++) {
+ for (i = polinit; i <= polfin; i++)
+ {
IncCol = 0;
AppParCurves_MultiPoint MPol(nb3d, nb2d);
- for (k = 1; k <= NbCu; k++) {
- if (k <= nb3d) {
- gp_Pnt Pol(VecPoles(IncCol + i),
- VecPoles(IncCol + Npol +i),
- VecPoles(IncCol + 2*Npol + i));
- MPol.SetPoint(k, Pol);
- IncCol = IncCol + 3*Npol;
+ for (k = 1; k <= NbCu; k++)
+ {
+ if (k <= nb3d)
+ {
+ gp_Pnt Pol(VecPoles(IncCol + i),
+ VecPoles(IncCol + Npol + i),
+ VecPoles(IncCol + 2 * Npol + i));
+ MPol.SetPoint(k, Pol);
+ IncCol = IncCol + 3 * Npol;
}
- else {
- gp_Pnt2d Pol2d(VecPoles(IncCol + i),
- VecPoles(IncCol + Npol + i));
- MPol.SetPoint2d(k, Pol2d);
- IncCol = IncCol + 2*Npol;
+ else
+ {
+ gp_Pnt2d Pol2d(VecPoles(IncCol + i), VecPoles(IncCol + Npol + i));
+ MPol.SetPoint2d(k, Pol2d);
+ IncCol = IncCol + 2 * Npol;
}
}
SCurv.SetValue(i, MPol);
}
-
}
-
-
-Standard_Boolean AppParCurves_ResolConstraint::IsDone () const {
+Standard_Boolean AppParCurves_ResolConstraint::IsDone() const
+{
return Done;
}
-
-Standard_Integer AppParCurves_ResolConstraint::
- NbConstraints(const MultiLine& SSP,
- const Standard_Integer,
- const Standard_Integer,
- const Handle(AppParCurves_HArray1OfConstraintCouple)&
- TheConstraints)
-const
+Standard_Integer AppParCurves_ResolConstraint::NbConstraints(
+ const MultiLine& SSP,
+ const Standard_Integer,
+ const Standard_Integer,
+ const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints) const
{
- // Boucle de calcul du nombre de points de passage afin de dimensionner
+ // Boucle de calcul du nombre de points de passage afin de dimensionner
// les matrices.
- Standard_Integer aIncPass, aIncTan, aIncCurv, aCCol;
- Standard_Integer i;
+ Standard_Integer aIncPass, aIncTan, aIncCurv, aCCol;
+ Standard_Integer i;
AppParCurves_Constraint Cons;
aIncPass = 0;
- aIncTan = 0;
+ aIncTan = 0;
aIncCurv = 0;
- for (i = TheConstraints->Lower(); i <= TheConstraints->Upper(); i++) {
+ for (i = TheConstraints->Lower(); i <= TheConstraints->Upper(); i++)
+ {
Cons = (TheConstraints->Value(i)).Constraint();
- if (Cons >= 1) {
- aIncPass++; // IncPass = nbre de points de passage.
+ if (Cons >= 1)
+ {
+ aIncPass++; // IncPass = nbre de points de passage.
}
- if (Cons >= 2) {
- aIncTan++; // IncTan= nbre de points de tangence.
+ if (Cons >= 2)
+ {
+ aIncTan++; // IncTan= nbre de points de tangence.
}
- if (Cons == 3) {
- aIncCurv++; // IncCurv = nbre de pts de courbure.
+ if (Cons == 3)
+ {
+ aIncCurv++; // IncCurv = nbre de pts de courbure.
}
}
Standard_Integer nb3d = ToolLine::NbP3d(SSP);
Standard_Integer nb2d = ToolLine::NbP2d(SSP);
- aCCol = nb3d* 3 + nb2d* 2;
-
- return aCCol*aIncPass + aIncTan*(aCCol-1) + 3*aIncCurv;
+ aCCol = nb3d * 3 + nb2d * 2;
+ return aCCol * aIncPass + aIncTan * (aCCol - 1) + 3 * aIncCurv;
}
-
-Standard_Integer AppParCurves_ResolConstraint::NbColumns(const MultiLine& SSP,
- const Standard_Integer Deg)
-const
+Standard_Integer AppParCurves_ResolConstraint::NbColumns(const MultiLine& SSP,
+ const Standard_Integer Deg) const
{
Standard_Integer nb3d = ToolLine::NbP3d(SSP);
Standard_Integer nb2d = ToolLine::NbP2d(SSP);
- Standard_Integer CCol = nb3d* 3 + nb2d* 2;
+ Standard_Integer CCol = nb3d * 3 + nb2d * 2;
- return CCol*(Deg+1);
+ return CCol * (Deg + 1);
}
const math_Matrix& AppParCurves_ResolConstraint::ConstraintMatrix() const
return CTCinv;
}
-
const math_Vector& AppParCurves_ResolConstraint::Duale() const
{
return Vardua;
}
-
-
-const math_Matrix& AppParCurves_ResolConstraint::
- ConstraintDerivative(const MultiLine& SSP,
- const math_Vector& Parameters,
- const Standard_Integer Deg,
- const math_Matrix& DA)
+const math_Matrix& AppParCurves_ResolConstraint::ConstraintDerivative(const MultiLine& SSP,
+ const math_Vector& Parameters,
+ const Standard_Integer Deg,
+ const math_Matrix& DA)
{
Standard_Integer i, j, k, nb2d, nb3d, CCol, Inc3, IncCol, Npt;
- Standard_Integer Npol, Npol2, NbCu =ToolLine::NbP3d(SSP)+ToolLine::NbP2d(SSP);
+ Standard_Integer Npol, Npol2, NbCu = ToolLine::NbP3d(SSP) + ToolLine::NbP2d(SSP);
Standard_Integer IP;
- Standard_Real Daij;
- Npol = Deg+1; Npol2 = 2*Npol;
+ Standard_Real Daij;
+ Npol = Deg + 1;
+ Npol2 = 2 * Npol;
TColStd_Array2OfInteger Ibont(1, NbCu, 1, IncTan);
- math_Matrix DeCInit(1, IncPass, 1, Npol);
- math_Vector DDA(1, Npol);
- gp_Vec V;
- gp_Vec2d V2d;
- Standard_Real T1, T2, T3, Tmax, DDaij;
-// Standard_Integer FirstP = IPas(1);
- nb3d = ToolLine::NbP3d(SSP);
- nb2d = ToolLine::NbP2d(SSP);
+ math_Matrix DeCInit(1, IncPass, 1, Npol);
+ math_Vector DDA(1, Npol);
+ gp_Vec V;
+ gp_Vec2d V2d;
+ Standard_Real T1, T2, T3, Tmax, DDaij;
+ // Standard_Integer FirstP = IPas(1);
+ nb3d = ToolLine::NbP3d(SSP);
+ nb2d = ToolLine::NbP2d(SSP);
Standard_Integer mynb3d = nb3d, mynb2d = nb2d;
- if (nb3d == 0) mynb3d = 1;
- if (nb2d == 0) mynb2d = 1;
- CCol = nb3d* 3 + nb2d* 2;
+ if (nb3d == 0)
+ mynb3d = 1;
+ if (nb2d == 0)
+ mynb2d = 1;
+ CCol = nb3d * 3 + nb2d * 2;
- TColgp_Array1OfVec tabV(1, mynb3d);
+ TColgp_Array1OfVec tabV(1, mynb3d);
TColgp_Array1OfVec2d tabV2d(1, mynb2d);
- TColgp_Array1OfPnt tabP(1, mynb3d);
+ TColgp_Array1OfPnt tabP(1, mynb3d);
TColgp_Array1OfPnt2d tabP2d(1, mynb2d);
for (i = 1; i <= DeCont.RowNumber(); i++)
for (j = 1; j <= DeCont.ColNumber(); j++)
DeCont(i, j) = 0.0;
-
// Remplissage de DK pour les points de passages:
-
- for (i =1; i <= IncPass; i++) {
+
+ for (i = 1; i <= IncPass; i++)
+ {
Npt = IPas(i);
- for (j = 1; j <= Npol; j++) DeCInit(i, j) = DA(Npt, j);
+ for (j = 1; j <= Npol; j++)
+ DeCInit(i, j) = DA(Npt, j);
}
- for (i = 1; i <= CCol; i++) {
- DeCont.Set(IncPass*(i-1)+1, IncPass*i, Npol*(i-1)+1, Npol*i, DeCInit);
+ for (i = 1; i <= CCol; i++)
+ {
+ DeCont.Set(IncPass * (i - 1) + 1, IncPass * i, Npol * (i - 1) + 1, Npol * i, DeCInit);
}
-
-
+
// Pour les points de tangence:
- Inc3 = CCol*IncPass +1;
+ Inc3 = CCol * IncPass + 1;
IncCol = 0;
- for (k = 1; k <= NbCu; k++) {
- if (k <= nb3d) {
- for (i = 1; i <= IncTan; i++) {
- Npt = ITan(i);
-// MultiPoint MPoint = ToolLine::Value(SSP, Npt);
- // choix du maximum de tangence pour exprimer la colinearite:
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- V.Coord(T1, T2, T3);
- Tmax = Abs(T1);
- Ibont(k, i) = 1;
- if (Abs(T2) > Tmax) {
- Tmax = Abs(T2);
- Ibont(k, i) = 2;
- }
- if (Abs(T3) > Tmax) {
- Tmax = Abs(T3);
- Ibont(k, i) = 3;
- }
+ for (k = 1; k <= NbCu; k++)
+ {
+ if (k <= nb3d)
+ {
+ for (i = 1; i <= IncTan; i++)
+ {
+ Npt = ITan(i);
+ // MultiPoint MPoint = ToolLine::Value(SSP, Npt);
+ // choix du maximum de tangence pour exprimer la colinearite:
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k);
+ V.Coord(T1, T2, T3);
+ Tmax = Abs(T1);
+ Ibont(k, i) = 1;
+ if (Abs(T2) > Tmax)
+ {
+ Tmax = Abs(T2);
+ Ibont(k, i) = 2;
+ }
+ if (Abs(T3) > Tmax)
+ {
+ Tmax = Abs(T3);
+ Ibont(k, i) = 3;
+ }
AppParCurves::SecondDerivativeBernstein(Parameters(Npt), DDA);
- if (Ibont(k, i) == 3) {
- for (j = 1; j <= Npol; j++) {
- DDaij = DDA(j);
- DeCont(Inc3, j+ Npol + IncCol) = DDaij*T3/Tmax;
- DeCont(Inc3, j + Npol2 + IncCol) = -DDaij *T2/Tmax;
- DeCont(Inc3+1, j+ IncCol) = DDaij* T3/Tmax;
- DeCont(Inc3+1, j+ Npol2 + IncCol) = -DDaij*T1/Tmax;
- }
- }
- else if (Ibont(k, i) == 1) {
- for (j = 1; j <= Npol; j++) {
- DDaij = DDA(j);
- DeCont(Inc3, j + IncCol) = DDaij*T3/Tmax;
- DeCont(Inc3, j + Npol2 + IncCol) = -DDaij *T1/Tmax;
- DeCont(Inc3+1, j+ IncCol) = DDaij* T2/Tmax;
- DeCont(Inc3+1, j+ Npol +IncCol) = -DDaij*T1/Tmax;
- }
- }
- else if (Ibont(k, i) == 2) {
- for (j = 1; j <= Npol; j++) {
- DDaij = DDA(j);
- DeCont(Inc3, j+ Npol + IncCol) = DDaij*T3/Tmax;
- DeCont(Inc3, j + Npol2 + IncCol) = -DDaij *T2/Tmax;
- DeCont(Inc3+1, j+ IncCol) = DDaij* T2/Tmax;
- DeCont(Inc3+1, j+ Npol + IncCol) = -DDaij*T1/Tmax;
- }
- }
- Inc3 = Inc3 + 2;
+ if (Ibont(k, i) == 3)
+ {
+ for (j = 1; j <= Npol; j++)
+ {
+ DDaij = DDA(j);
+ DeCont(Inc3, j + Npol + IncCol) = DDaij * T3 / Tmax;
+ DeCont(Inc3, j + Npol2 + IncCol) = -DDaij * T2 / Tmax;
+ DeCont(Inc3 + 1, j + IncCol) = DDaij * T3 / Tmax;
+ DeCont(Inc3 + 1, j + Npol2 + IncCol) = -DDaij * T1 / Tmax;
+ }
+ }
+ else if (Ibont(k, i) == 1)
+ {
+ for (j = 1; j <= Npol; j++)
+ {
+ DDaij = DDA(j);
+ DeCont(Inc3, j + IncCol) = DDaij * T3 / Tmax;
+ DeCont(Inc3, j + Npol2 + IncCol) = -DDaij * T1 / Tmax;
+ DeCont(Inc3 + 1, j + IncCol) = DDaij * T2 / Tmax;
+ DeCont(Inc3 + 1, j + Npol + IncCol) = -DDaij * T1 / Tmax;
+ }
+ }
+ else if (Ibont(k, i) == 2)
+ {
+ for (j = 1; j <= Npol; j++)
+ {
+ DDaij = DDA(j);
+ DeCont(Inc3, j + Npol + IncCol) = DDaij * T3 / Tmax;
+ DeCont(Inc3, j + Npol2 + IncCol) = -DDaij * T2 / Tmax;
+ DeCont(Inc3 + 1, j + IncCol) = DDaij * T2 / Tmax;
+ DeCont(Inc3 + 1, j + Npol + IncCol) = -DDaij * T1 / Tmax;
+ }
+ }
+ Inc3 = Inc3 + 2;
}
- IncCol = IncCol + 3*Npol;
+ IncCol = IncCol + 3 * Npol;
}
- else {
- for (i = 1; i <= IncTan; i++) {
- Npt = ITan(i);
- AppParCurves::SecondDerivativeBernstein(Parameters(Npt), DDA);
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k);
- V2d.Coord(T1, T2);
- Tmax = Abs(T1);
- Ibont(k, i) = 1;
- if (Abs(T2) > Tmax) {
- Tmax = Abs(T2);
- Ibont(k, i) = 2;
- }
- for (j = 1; j <= Npol; j++) {
- DDaij = DDA(j);
- DeCont(Inc3, j + IncCol) = DDaij*T2;
- DeCont(Inc3, j + Npol + IncCol) = -DDaij*T1;
- }
- Inc3 = Inc3 +1;
+ else
+ {
+ for (i = 1; i <= IncTan; i++)
+ {
+ Npt = ITan(i);
+ AppParCurves::SecondDerivativeBernstein(Parameters(Npt), DDA);
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k);
+ V2d.Coord(T1, T2);
+ Tmax = Abs(T1);
+ Ibont(k, i) = 1;
+ if (Abs(T2) > Tmax)
+ {
+ Tmax = Abs(T2);
+ Ibont(k, i) = 2;
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ DDaij = DDA(j);
+ DeCont(Inc3, j + IncCol) = DDaij * T2;
+ DeCont(Inc3, j + Npol + IncCol) = -DDaij * T1;
+ }
+ Inc3 = Inc3 + 1;
}
}
}
// Equations exprimant le meme rapport de tangence sur chaque courbe:
// On prend les coordonnees les plus significatives.
- Inc3 = Inc3 -1;
- for (i =1; i <= IncTan; i++) {
+ Inc3 = Inc3 - 1;
+ for (i = 1; i <= IncTan; i++)
+ {
IncCol = 0;
- Npt = ITan(i);
+ Npt = ITan(i);
AppParCurves::SecondDerivativeBernstein(Parameters(Npt), DDA);
-// MultiPoint MP = ToolLine::Value(SSP, Npt);
- for (k = 1; k <= NbCu-1; k++) {
+ // MultiPoint MP = ToolLine::Value(SSP, Npt);
+ for (k = 1; k <= NbCu - 1; k++)
+ {
Inc3 = Inc3 + 1;
- if (Ibont(k, i) == 1) {
- if (k <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- T1 = V.X();
- IP = 3*Npol;
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k);
- T1 = V2d.X();
- IP = 2*Npol;
- }
- if (Ibont(k+1, i) == 1) { // Relations entre T1x et T2x:
- if ((k+1) <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.X();
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1);
- T2 = V2d.X();
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + IncCol) = Daij*T2;
- Cont(Inc3, j + IP + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
- else if (Ibont(k+1, i) == 2) { // Relations entre T1x et T2y:
- if ((k+1) <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Y();
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1);
- T2 = V2d.Y();
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + IncCol) = Daij*T2;
- Cont(Inc3, j + IP + Npol + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
- else if (Ibont(k+1,i) == 3) { // Relations entre T1x et T2z:
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Z();
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + IncCol) = Daij*T2;
- Cont(Inc3, j + IP + 2*Npol + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
+ if (Ibont(k, i) == 1)
+ {
+ if (k <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k);
+ T1 = V.X();
+ IP = 3 * Npol;
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k);
+ T1 = V2d.X();
+ IP = 2 * Npol;
+ }
+ if (Ibont(k + 1, i) == 1)
+ { // Relations entre T1x et T2x:
+ if ((k + 1) <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.X();
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k + 1);
+ T2 = V2d.X();
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
+ else if (Ibont(k + 1, i) == 2)
+ { // Relations entre T1x et T2y:
+ if ((k + 1) <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.Y();
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k + 1);
+ T2 = V2d.Y();
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + Npol + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
+ else if (Ibont(k + 1, i) == 3)
+ { // Relations entre T1x et T2z:
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.Z();
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + 2 * Npol + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
}
- else if (Ibont(k,i) == 2) {
- if (k <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- T1 = V.Y();
- IP = 3*Npol;
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k);
- T1 = V2d.Y();
- IP = 2*Npol;
- }
- if (Ibont(k+1, i) == 1) { // Relations entre T1y et T2x:
- if ((k+1) <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.X();
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1);
- T2 = V2d.X();
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DDA( j);
- Cont(Inc3, j + Npol + IncCol) = Daij*T2;
- Cont(Inc3, j + IP + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
-
- }
- else if (Ibont(k+1, i) == 2) { // Relations entre T1y et T2y:
- if ((k+1) <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Y();
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1);
- T2 = V2d.Y();
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + Npol + IncCol) = Daij*T2;
- Cont(Inc3, j + IP + Npol + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
-
- }
- else if (Ibont(k+1,i)== 3) { // Relations entre T1y et T2z:
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Z();
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + Npol +IncCol) = Daij*T2;
- Cont(Inc3, j + IP + 2*Npol + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
+ else if (Ibont(k, i) == 2)
+ {
+ if (k <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k);
+ T1 = V.Y();
+ IP = 3 * Npol;
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k);
+ T1 = V2d.Y();
+ IP = 2 * Npol;
+ }
+ if (Ibont(k + 1, i) == 1)
+ { // Relations entre T1y et T2x:
+ if ((k + 1) <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.X();
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k + 1);
+ T2 = V2d.X();
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + Npol + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
+ else if (Ibont(k + 1, i) == 2)
+ { // Relations entre T1y et T2y:
+ if ((k + 1) <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.Y();
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k + 1);
+ T2 = V2d.Y();
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + Npol + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + Npol + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
+ else if (Ibont(k + 1, i) == 3)
+ { // Relations entre T1y et T2z:
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.Z();
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + Npol + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + 2 * Npol + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
}
- else {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k);
- T1 = V.Z();
- IP = 3*Npol;
- if (Ibont(k+1, i) == 1) { // Relations entre T1z et T2x:
- if ((k+1) <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.X();
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1);
- T2 = V2d.X();
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + 2*Npol +IncCol) = Daij*T2;
- Cont(Inc3, j + IP + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
-
- else if (Ibont(k+1, i) == 2) { // Relations entre T1z et T2y:
- if ((k+1) <= nb3d) {
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Y();
- }
- else {
- ToolLine::Tangency(SSP, Npt, tabV2d);
- V2d = tabV2d(k+1);
- T2 = V2d.Y();
- }
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + 2*Npol +IncCol) = Daij*T2;
- Cont(Inc3, j + IP + Npol + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
-
- else if (Ibont(k+1,i)==3) { // Relations entre T1z et T2z:
- ToolLine::Tangency(SSP, Npt, tabV);
- V = tabV(k+1);
- T2 = V.Z();
- for (j = 1; j <= Npol; j++) {
- Daij = DDA(j);
- Cont(Inc3, j + 2*Npol + IncCol) = Daij*T2;
- Cont(Inc3, j + IP + 2*Npol + IncCol) = -Daij*T1;
- }
- IncCol = IncCol + IP;
- }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k);
+ T1 = V.Z();
+ IP = 3 * Npol;
+ if (Ibont(k + 1, i) == 1)
+ { // Relations entre T1z et T2x:
+ if ((k + 1) <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.X();
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k + 1);
+ T2 = V2d.X();
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + 2 * Npol + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
+
+ else if (Ibont(k + 1, i) == 2)
+ { // Relations entre T1z et T2y:
+ if ((k + 1) <= nb3d)
+ {
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.Y();
+ }
+ else
+ {
+ ToolLine::Tangency(SSP, Npt, tabV2d);
+ V2d = tabV2d(k + 1);
+ T2 = V2d.Y();
+ }
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + 2 * Npol + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + Npol + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
+
+ else if (Ibont(k + 1, i) == 3)
+ { // Relations entre T1z et T2z:
+ ToolLine::Tangency(SSP, Npt, tabV);
+ V = tabV(k + 1);
+ T2 = V.Z();
+ for (j = 1; j <= Npol; j++)
+ {
+ Daij = DDA(j);
+ Cont(Inc3, j + 2 * Npol + IncCol) = Daij * T2;
+ Cont(Inc3, j + IP + 2 * Npol + IncCol) = -Daij * T1;
+ }
+ IncCol = IncCol + IP;
+ }
}
}
}
#include <AppParCurves_ConstraintCouple.hxx>
#include Approx_BSpParLeastSquareOfMyBSplGradient_hxx
-#if defined(OCCT_DEBUG) && defined( DRAW ) && !defined( WNT )
+#if defined(OCCT_DEBUG) && defined(DRAW) && !defined(WNT)
static Standard_Boolean mydebug = Standard_False;
-#include <Draw.hxx>
-#include <Draw_Appli.hxx>
-#include <DrawTrSurf.hxx>
-#include <Draw_Text2D.hxx>
-#include <Draw_Text3D.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <Geom_BSplineCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-#include <Geom_Line.hxx>
-#include <Geom2d_Line.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-
+ #include <Draw.hxx>
+ #include <Draw_Appli.hxx>
+ #include <DrawTrSurf.hxx>
+ #include <Draw_Text2D.hxx>
+ #include <Draw_Text3D.hxx>
+ #include <TColStd_Array1OfInteger.hxx>
+ #include <Geom_BSplineCurve.hxx>
+ #include <Geom2d_BSplineCurve.hxx>
+ #include <Geom_Line.hxx>
+ #include <Geom2d_Line.hxx>
+ #include <Geom_TrimmedCurve.hxx>
+ #include <Geom2d_TrimmedCurve.hxx>
static void DUMP(const MultiLine& Line)
{
Standard_Integer i, j, nbP2d, nbP3d, firstP, lastP;
firstP = LineTool::FirstPoint(Line);
- lastP = LineTool::LastPoint(Line);
+ lastP = LineTool::LastPoint(Line);
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
-
- TColgp_Array1OfPnt tabP(1, mynbP3d);
- TColgp_Array1OfPnt2d tabP2d(1, mynbP2d);
- TColgp_Array1OfVec TabV(1, mynbP3d);
- TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
- Standard_Boolean Ok;
- Handle(Geom_Line) L3d;
- Handle(Geom2d_Line) L2d;
- Handle(Geom_TrimmedCurve) L3dt;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+
+ TColgp_Array1OfPnt tabP(1, mynbP3d);
+ TColgp_Array1OfPnt2d tabP2d(1, mynbP2d);
+ TColgp_Array1OfVec TabV(1, mynbP3d);
+ TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
+ Standard_Boolean Ok;
+ Handle(Geom_Line) L3d;
+ Handle(Geom2d_Line) L2d;
+ Handle(Geom_TrimmedCurve) L3dt;
Handle(Geom2d_TrimmedCurve) L2dt;
- Handle(Draw_Text2D) T2D;
- Handle(Draw_Text3D) T3D;
+ Handle(Draw_Text2D) T2D;
+ Handle(Draw_Text3D) T3D;
char solname[100];
char mytext[10];
- for (i = firstP; i <= lastP; i++) {
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, i, tabP, tabP2d);
- else if (nbP2d != 0) LineTool::Value(Line, i, tabP2d);
- else if (nbP3d != 0) LineTool::Value(Line, i, tabP);
+ for (i = firstP; i <= lastP; i++)
+ {
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, i, tabP, tabP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, i, tabP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, i, tabP);
- for (j = 1; j <= nbP3d; j++) {
+ for (j = 1; j <= nbP3d; j++)
+ {
Sprintf(solname, "%s%i%s_%i", "p", j, "3d", i);
char* Temp = solname;
DrawTrSurf::Set(Temp, tabP(j));
// DrawTrSurf::Set(solname, tabP(j));
- if (i == firstP || i == lastP) {
+ if (i == firstP || i == lastP)
+ {
Sprintf(mytext, "%s%i", " ", i);
T3D = new Draw_Text3D(tabP(j), mytext, Draw_vert);
dout << T3D;
}
}
- for (j = 1; j <= nbP2d; j++) {
+ for (j = 1; j <= nbP2d; j++)
+ {
Sprintf(solname, "%s%i%s_%i", "p", j, "2d", i);
char* Temp = solname;
DrawTrSurf::Set(Temp, tabP2d(j));
// DrawTrSurf::Set(solname, tabP2d(j));
- if (i == firstP || i == lastP) {
+ if (i == firstP || i == lastP)
+ {
Sprintf(mytext, "%s%i", " ", i);
T2D = new Draw_Text2D(tabP2d(j), mytext, Draw_vert);
dout << T2D;
}
// le cas des tangentes aux extremites:
- if (i == firstP || i == lastP) {
+ if (i == firstP || i == lastP)
+ {
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, i, TabV, TabV2d);
else if (nbP2d != 0)
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, i, TabV);
- if (Ok) {
- for (j = 1; j <= nbP3d; j++) {
+ if (Ok)
+ {
+ for (j = 1; j <= nbP3d; j++)
+ {
Sprintf(solname, "%s%i%s_%i", "t", j, "3d", i);
- L3d = new Geom_Line(tabP(j), gp_Dir(TabV(j)));
- L3dt = new Geom_TrimmedCurve(L3d, 0.0, 0.3);
+ L3d = new Geom_Line(tabP(j), gp_Dir(TabV(j)));
+ L3dt = new Geom_TrimmedCurve(L3d, 0.0, 0.3);
char* Temp = solname;
DrawTrSurf::Set(Temp, L3dt);
// DrawTrSurf::Set(solname, L3dt);
}
- for (j = 1; j <= nbP2d; j++) {
+ for (j = 1; j <= nbP2d; j++)
+ {
Sprintf(solname, "%s%i%s_%i", "t", j, "2d", i);
- L2d = new Geom2d_Line(tabP2d(j), gp_Dir2d(TabV2d(j)));
- L2dt = new Geom2d_TrimmedCurve(L2d, 0.0, 0.3);
+ L2d = new Geom2d_Line(tabP2d(j), gp_Dir2d(TabV2d(j)));
+ L2dt = new Geom2d_TrimmedCurve(L2d, 0.0, 0.3);
char* Temp = solname;
DrawTrSurf::Set(Temp, L2dt);
// DrawTrSurf::Set(solname, L2dt);
dout.Flush();
}
-
static void DUMP(const AppParCurves_MultiBSpCurve& C)
{
- static Standard_Integer nbappel = 0;
- Standard_Integer i, j, nbP2d, nbP3d;
- Standard_Integer nbpoles = C.NbPoles();
- Standard_Integer deg = C.Degree();
- const TColStd_Array1OfReal& Knots = C.Knots();
- const TColStd_Array1OfInteger& Mults = C.Multiplicities();
-
- Handle(Geom_BSplineCurve) BSp;
+ static Standard_Integer nbappel = 0;
+ Standard_Integer i, j, nbP2d, nbP3d;
+ Standard_Integer nbpoles = C.NbPoles();
+ Standard_Integer deg = C.Degree();
+ const TColStd_Array1OfReal& Knots = C.Knots();
+ const TColStd_Array1OfInteger& Mults = C.Multiplicities();
+
+ Handle(Geom_BSplineCurve) BSp;
Handle(Geom2d_BSplineCurve) BSp2d;
- TColgp_Array1OfPnt tabPoles(1, nbpoles);
+ TColgp_Array1OfPnt tabPoles(1, nbpoles);
TColgp_Array1OfPnt2d tabPoles2d(1, nbpoles);
- char solname[100];
+ char solname[100];
nbappel++;
- for (i = 1; i <= C.NbCurves(); i++) {
- if (C.Dimension(i) == 3) {
+ for (i = 1; i <= C.NbCurves(); i++)
+ {
+ if (C.Dimension(i) == 3)
+ {
C.Curve(i, tabPoles);
BSp = new Geom_BSplineCurve(tabPoles, Knots, Mults, deg);
Sprintf(solname, "%s%i%s_%i", "c", i, "3d", nbappel);
DrawTrSurf::Set(Temp, BSp);
// DrawTrSurf::Set(solname, BSp);
}
- else {
+ else
+ {
C.Curve(i, tabPoles2d);
BSp2d = new Geom2d_BSplineCurve(tabPoles2d, Knots, Mults, deg);
Sprintf(solname, "%s%i%s_%i", "c", i, "2d", nbappel);
dout.Flush();
}
-
#endif
-
-
-
//=================================================================================================
-void Approx_BSplComputeLine::FirstTangencyVector(const MultiLine& Line,
- const Standard_Integer index,
- math_Vector& V)
- const {
+void Approx_BSplComputeLine::FirstTangencyVector(const MultiLine& Line,
+ const Standard_Integer index,
+ math_Vector& V) const
+{
Standard_Integer i, j, nbP2d, nbP3d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- Standard_Boolean Ok = Standard_False;
- TColgp_Array1OfVec TabV(1, mynbP3d);
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ Standard_Boolean Ok = Standard_False;
+ TColgp_Array1OfVec TabV(1, mynbP3d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
if (nbP3d != 0 && nbP2d != 0)
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, index, TabV);
- if (Ok) {
- if (nbP3d != 0) {
+ if (Ok)
+ {
+ if (nbP3d != 0)
+ {
j = 1;
- for (i = TabV.Lower(); i <= TabV.Upper(); i++) {
- V(j) = TabV(i).X();
+ for (i = TabV.Lower(); i <= TabV.Upper(); i++)
+ {
+ V(j) = TabV(i).X();
V(j + 1) = TabV(i).Y();
V(j + 2) = TabV(i).Z();
j += 3;
}
}
- if (nbP2d != 0) {
+ if (nbP2d != 0)
+ {
j = nbP3d * 3 + 1;
- for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++) {
- V(j) = TabV2d(i).X();
+ for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++)
+ {
+ V(j) = TabV2d(i).X();
V(j + 1) = TabV2d(i).Y();
j += 2;
}
}
}
- else {
+ else
+ {
// recherche d un vecteur tangent par construction d une parabole:
AppParCurves_Constraint firstC, lastC;
- firstC = lastC = AppParCurves_PassPoint;
+ firstC = lastC = AppParCurves_PassPoint;
Standard_Integer nbpoles = 3;
- math_Vector mypar(index, index + 2);
+ math_Vector mypar(index, index + 2);
Parameters(Line, index, index + 2, mypar);
Approx_BSpParLeastSquareOfMyBSplGradient
- LSQ(Line, index, index + 2, firstC, lastC, mypar, nbpoles);
+ LSQ(Line, index, index + 2, firstC, lastC, mypar, nbpoles);
AppParCurves_MultiCurve C = LSQ.BezierValue();
- gp_Pnt myP;
- gp_Vec myV;
+ gp_Pnt myP;
+ gp_Vec myV;
gp_Pnt2d myP2d;
gp_Vec2d myV2d;
j = 1;
- for (i = 1; i <= nbP3d; i++) {
+ for (i = 1; i <= nbP3d; i++)
+ {
C.D1(i, 0.0, myP, myV);
- V(j) = myV.X();
+ V(j) = myV.X();
V(j + 1) = myV.Y();
V(j + 2) = myV.Z();
j += 3;
}
j = nbP3d * 3 + 1;
- for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++) {
+ for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++)
+ {
C.D1(i, 0.0, myP2d, myV2d);
- V(j) = myV2d.X();
+ V(j) = myV2d.X();
V(j + 1) = myV2d.Y();
j += 2;
}
}
-
}
-
//=================================================================================================
void Approx_BSplComputeLine::LastTangencyVector(const MultiLine& Line,
- const Standard_Integer index,
- math_Vector& V)
- const {
+ const Standard_Integer index,
+ math_Vector& V) const
+{
Standard_Integer i, j, nbP2d, nbP3d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- Standard_Boolean Ok = Standard_False;
- TColgp_Array1OfVec TabV(1, mynbP3d);
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ Standard_Boolean Ok = Standard_False;
+ TColgp_Array1OfVec TabV(1, mynbP3d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
-
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, index, TabV, TabV2d);
else if (nbP2d != 0)
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, index, TabV);
- if (Ok) {
- if (nbP3d != 0) {
+ if (Ok)
+ {
+ if (nbP3d != 0)
+ {
j = 1;
- for (i = TabV.Lower(); i <= TabV.Upper(); i++) {
- V(j) = TabV(i).X();
+ for (i = TabV.Lower(); i <= TabV.Upper(); i++)
+ {
+ V(j) = TabV(i).X();
V(j + 1) = TabV(i).Y();
V(j + 2) = TabV(i).Z();
j += 3;
}
}
- if (nbP2d != 0) {
+ if (nbP2d != 0)
+ {
j = nbP3d * 3 + 1;
- for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++) {
- V(j) = TabV2d(i).X();
+ for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++)
+ {
+ V(j) = TabV2d(i).X();
V(j + 1) = TabV2d(i).Y();
j += 2;
}
}
}
- else {
+ else
+ {
// recherche d un vecteur tangent par construction d une parabole:
AppParCurves_Constraint firstC, lastC;
- firstC = lastC = AppParCurves_PassPoint;
+ firstC = lastC = AppParCurves_PassPoint;
Standard_Integer nbpoles = 3;
- math_Vector mypar(index - 2, index);
+ math_Vector mypar(index - 2, index);
Parameters(Line, index - 2, index, mypar);
Approx_BSpParLeastSquareOfMyBSplGradient
- LSQ(Line, index - 2, index, firstC, lastC, mypar, nbpoles);
+ LSQ(Line, index - 2, index, firstC, lastC, mypar, nbpoles);
AppParCurves_MultiCurve C = LSQ.BezierValue();
- gp_Pnt myP;
- gp_Vec myV;
+ gp_Pnt myP;
+ gp_Vec myV;
gp_Pnt2d myP2d;
gp_Vec2d myV2d;
j = 1;
- for (i = 1; i <= nbP3d; i++) {
+ for (i = 1; i <= nbP3d; i++)
+ {
C.D1(i, 1.0, myP, myV);
- V(j) = myV.X();
+ V(j) = myV.X();
V(j + 1) = myV.Y();
V(j + 2) = myV.Z();
j += 3;
}
j = nbP3d * 3 + 1;
- for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++) {
+ for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++)
+ {
C.D1(i, 1.0, myP2d, myV2d);
- V(j) = myV2d.X();
+ V(j) = myV2d.X();
V(j + 1) = myV2d.Y();
j += 2;
}
}
-
}
-
-
//=================================================================================================
-Standard_Real Approx_BSplComputeLine::
-SearchFirstLambda(const MultiLine& Line,
- const math_Vector& aPar,
- const TColStd_Array1OfReal& Theknots,
- const math_Vector& V,
- const Standard_Integer index) const {
+Standard_Real Approx_BSplComputeLine::SearchFirstLambda(const MultiLine& Line,
+ const math_Vector& aPar,
+ const TColStd_Array1OfReal& Theknots,
+ const math_Vector& V,
+ const Standard_Integer index) const
+{
// dq/dw = lambda* V = (p2-p1)/(u2-u1)
Standard_Integer nbP2d, nbP3d;
- gp_Pnt P1, P2;
- gp_Pnt2d P12d, P22d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ gp_Pnt P1, P2;
+ gp_Pnt2d P12d, P22d;
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- TColgp_Array1OfPnt tabP1(1, mynbP3d), tabP2(1, mynbP3d);
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ TColgp_Array1OfPnt tabP1(1, mynbP3d), tabP2(1, mynbP3d);
TColgp_Array1OfPnt2d tabP12d(1, mynbP2d), tabP22d(1, mynbP2d);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index, tabP1, tabP12d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index, tabP12d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index, tabP1);
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index, tabP1, tabP12d);
- else if (nbP2d != 0) LineTool::Value(Line, index, tabP12d);
- else if (nbP3d != 0) LineTool::Value(Line, index, tabP1);
-
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index + 1, tabP2, tabP22d);
- else if (nbP2d != 0) LineTool::Value(Line, index + 1, tabP22d);
- else if (nbP3d != 0) LineTool::Value(Line, index + 1, tabP2);
-
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index + 1, tabP2, tabP22d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index + 1, tabP22d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index + 1, tabP2);
- Standard_Real U1 = aPar(index), U2 = aPar(index + 1);
- Standard_Real lambda, S;
- Standard_Integer low = V.Lower();
+ Standard_Real U1 = aPar(index), U2 = aPar(index + 1);
+ Standard_Real lambda, S;
+ Standard_Integer low = V.Lower();
Standard_Integer nbknots = Theknots.Length();
- if (nbP3d != 0) {
+ if (nbP3d != 0)
+ {
P1 = tabP1(1);
P2 = tabP2(1);
gp_Vec P1P2(P1, P2), myV;
myV.SetCoord(V(low), V(low + 1), V(low + 2));
- lambda = (P1P2.Magnitude()) / (myV.Magnitude()*(U2 - U1));
- S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- else {
+ else
+ {
P12d = tabP12d(1);
P22d = tabP22d(1);
gp_Vec2d P1P2(P12d, P22d), myV;
myV.SetCoord(V(low), V(low + 1));
- lambda = (P1P2.Magnitude()) / (myV.Magnitude()*(U2 - U1));
- S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- return ((S*lambda)*(Theknots(2) - Theknots(1)) / (Theknots(nbknots) - Theknots(1)));
-
+ return ((S * lambda) * (Theknots(2) - Theknots(1)) / (Theknots(nbknots) - Theknots(1)));
}
-
//=================================================================================================
-Standard_Real Approx_BSplComputeLine::
-SearchLastLambda(const MultiLine& Line,
- const math_Vector& aPar,
- const TColStd_Array1OfReal& Theknots,
- const math_Vector& V,
- const Standard_Integer index) const
+Standard_Real Approx_BSplComputeLine::SearchLastLambda(const MultiLine& Line,
+ const math_Vector& aPar,
+ const TColStd_Array1OfReal& Theknots,
+ const math_Vector& V,
+ const Standard_Integer index) const
{
// dq/dw = lambda* V = (p2-p1)/(u2-u1)
Standard_Integer nbP2d, nbP3d;
- gp_Pnt P1, P2;
- gp_Pnt2d P12d, P22d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ gp_Pnt P1, P2;
+ gp_Pnt2d P12d, P22d;
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- TColgp_Array1OfPnt tabP(1, mynbP3d), tabP2(1, mynbP3d);
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ TColgp_Array1OfPnt tabP(1, mynbP3d), tabP2(1, mynbP3d);
TColgp_Array1OfPnt2d tabP2d(1, mynbP2d), tabP22d(1, mynbP2d);
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index - 1, tabP, tabP2d);
- else if (nbP2d != 0) LineTool::Value(Line, index - 1, tabP2d);
- else if (nbP3d != 0) LineTool::Value(Line, index - 1, tabP);
-
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index, tabP2, tabP22d);
- else if (nbP2d != 0) LineTool::Value(Line, index, tabP22d);
- else if (nbP3d != 0) LineTool::Value(Line, index, tabP2);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index - 1, tabP, tabP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index - 1, tabP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index - 1, tabP);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index, tabP2, tabP22d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index, tabP22d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index, tabP2);
- Standard_Real U1 = aPar(index - 1), U2 = aPar(index);
- Standard_Real lambda, S;
- Standard_Integer low = V.Lower();
+ Standard_Real U1 = aPar(index - 1), U2 = aPar(index);
+ Standard_Real lambda, S;
+ Standard_Integer low = V.Lower();
Standard_Integer nbknots = Theknots.Length();
- if (nbP3d != 0) {
+ if (nbP3d != 0)
+ {
P1 = tabP(1);
P2 = tabP2(1);
gp_Vec P1P2(P1, P2), myV;
myV.SetCoord(V(low), V(low + 1), V(low + 2));
- lambda = (P1P2.Magnitude()) / (myV.Magnitude()*(U2 - U1));
- S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- else {
+ else
+ {
P12d = tabP2d(1);
P22d = tabP22d(1);
gp_Vec2d P1P2(P12d, P22d), myV;
myV.SetCoord(V(low), V(low + 1));
- lambda = (P1P2.Magnitude()) / (myV.Magnitude()*(U2 - U1));
- S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- return ((S*lambda)*(Theknots(nbknots) - Theknots(nbknots - 1))
- / (Theknots(nbknots) - Theknots(1)));
+ return ((S * lambda) * (Theknots(nbknots) - Theknots(nbknots - 1))
+ / (Theknots(nbknots) - Theknots(1)));
}
-
-
//=================================================================================================
-Approx_BSplComputeLine::Approx_BSplComputeLine
-(const MultiLine& Line,
- const math_Vector& Parameters,
- const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Standard_Boolean Squares)
+Approx_BSplComputeLine::Approx_BSplComputeLine(const MultiLine& Line,
+ const math_Vector& Parameters,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Standard_Boolean Squares)
{
- myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(),
- Parameters.Upper());
- for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++) {
+ myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(), Parameters.Upper());
+ for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++)
+ {
myfirstParam->SetValue(i, Parameters(i));
}
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- Par = Approx_IsoParametric;
- myPeriodic = Standard_False;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- alldone = Standard_False;
- mycont = -1;
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
- myhasknots = Standard_False;
- myhasmults = Standard_False;
+ Par = Approx_IsoParametric;
+ myPeriodic = Standard_False;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ alldone = Standard_False;
+ mycont = -1;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
+ myhasknots = Standard_False;
+ myhasmults = Standard_False;
currenttol3d = currenttol2d = RealLast();
- tolreached = Standard_False;
+ tolreached = Standard_False;
Perform(Line);
}
-
//=================================================================================================
-Approx_BSplComputeLine::Approx_BSplComputeLine
-(const math_Vector& Parameters,
- const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Standard_Boolean Squares)
+Approx_BSplComputeLine::Approx_BSplComputeLine(const math_Vector& Parameters,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Standard_Boolean Squares)
{
- myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(),
- Parameters.Upper());
- for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++) {
+ myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(), Parameters.Upper());
+ for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++)
+ {
myfirstParam->SetValue(i, Parameters(i));
}
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- Par = Approx_IsoParametric;
- myPeriodic = Standard_False;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- alldone = Standard_False;
- myhasknots = Standard_False;
- myhasmults = Standard_False;
- mycont = -1;
+ Par = Approx_IsoParametric;
+ myPeriodic = Standard_False;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ alldone = Standard_False;
+ myhasknots = Standard_False;
+ myhasmults = Standard_False;
+ mycont = -1;
currenttol3d = currenttol2d = RealLast();
- tolreached = Standard_False;
+ tolreached = Standard_False;
}
//=================================================================================================
-Approx_BSplComputeLine::Approx_BSplComputeLine
-(const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Approx_ParametrizationType parametrization,
- const Standard_Boolean Squares)
+Approx_BSplComputeLine::Approx_BSplComputeLine(const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Approx_ParametrizationType parametrization,
+ const Standard_Boolean Squares)
{
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- Par = parametrization;
- myPeriodic = Standard_False;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
- alldone = Standard_False;
- myhasknots = Standard_False;
- myhasmults = Standard_False;
- mycont = -1;
+ Par = parametrization;
+ myPeriodic = Standard_False;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
+ alldone = Standard_False;
+ myhasknots = Standard_False;
+ myhasmults = Standard_False;
+ mycont = -1;
currenttol3d = currenttol2d = RealLast();
- tolreached = Standard_False;
+ tolreached = Standard_False;
}
-
//=================================================================================================
-Approx_BSplComputeLine::Approx_BSplComputeLine
-(const MultiLine& Line,
- const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Approx_ParametrizationType parametrization,
- const Standard_Boolean Squares)
+Approx_BSplComputeLine::Approx_BSplComputeLine(const MultiLine& Line,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Approx_ParametrizationType parametrization,
+ const Standard_Boolean Squares)
{
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- alldone = Standard_False;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- Par = parametrization;
- myPeriodic = Standard_False;
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
- myhasknots = Standard_False;
- myhasmults = Standard_False;
- mycont = -1;
+ alldone = Standard_False;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ Par = parametrization;
+ myPeriodic = Standard_False;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
+ myhasknots = Standard_False;
+ myhasmults = Standard_False;
+ mycont = -1;
currenttol3d = currenttol2d = RealLast();
- tolreached = Standard_False;
+ tolreached = Standard_False;
Perform(Line);
}
-
-
//=================================================================================================
void Approx_BSplComputeLine::Perform(const MultiLine& Line)
{
-#if defined(OCCT_DEBUG) && defined( DRAW ) && !defined( WNT )
- if (mydebug) DUMP(Line);
+#if defined(OCCT_DEBUG) && defined(DRAW) && !defined(WNT)
+ if (mydebug)
+ DUMP(Line);
#endif
Standard_Integer i, Thefirstpt, Thelastpt;
// recherche des vraies contraintes donnees par la Line:
FindRealConstraints(Line);
- Thefirstpt = LineTool::FirstPoint(Line);
- Thelastpt = LineTool::LastPoint(Line);
+ Thefirstpt = LineTool::FirstPoint(Line);
+ Thelastpt = LineTool::LastPoint(Line);
Standard_Integer myfirstpt = Thefirstpt;
- Standard_Integer mylastpt = Thelastpt;
+ Standard_Integer mylastpt = Thelastpt;
AppParCurves_ConstraintCouple myCouple1(myfirstpt, realfirstC);
AppParCurves_ConstraintCouple myCouple2(mylastpt, reallastC);
myConstraints->SetValue(2, myCouple2);
math_Vector TheParam(Thefirstpt, Thelastpt, 0.0);
- if (myfirstParam.IsNull()) {
+ if (myfirstParam.IsNull())
+ {
Parameters(Line, Thefirstpt, Thelastpt, TheParam);
}
- else {
- for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++) {
+ else
+ {
+ for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++)
+ {
TheParam(i + Thefirstpt - 1) = myfirstParam->Value(i);
}
}
myParameters = new TColStd_HArray1OfReal(TheParam.Lower(), TheParam.Upper());
- for (i = TheParam.Lower(); i <= TheParam.Upper(); i++) {
+ for (i = TheParam.Lower(); i <= TheParam.Upper(); i++)
+ {
myParameters->SetValue(i, TheParam(i));
}
Standard_Integer nbknots = 2;
- Standard_Real l;
+ Standard_Real l;
alldone = Standard_False;
- if (!mycut) {
+ if (!mycut)
+ {
// cas ou on ne desire pas de noeuds supplementaires.
// ==================================================
- if (!myhasknots) {
- TColStd_Array1OfReal theknots(1, 2);
+ if (!myhasknots)
+ {
+ TColStd_Array1OfReal theknots(1, 2);
TColStd_Array1OfInteger themults(1, 2);
theknots(1) = 0.0;
theknots(2) = 1.0;
- alldone = Compute(Line, myfirstpt, mylastpt, TheParam, theknots, themults);
+ alldone = Compute(Line, myfirstpt, mylastpt, TheParam, theknots, themults);
}
- else {
- if (!myhasmults) {
+ else
+ {
+ if (!myhasmults)
+ {
TColStd_Array1OfInteger themults(1, myknots->Length());
- alldone = Compute(Line, myfirstpt, mylastpt, TheParam,
- myknots->Array1(), themults);
+ alldone = Compute(Line, myfirstpt, mylastpt, TheParam, myknots->Array1(), themults);
}
- else {
- alldone = Compute(Line, myfirstpt, mylastpt, TheParam,
- myknots->Array1(), mymults->ChangeArray1());
+ else
+ {
+ alldone =
+ Compute(Line, myfirstpt, mylastpt, TheParam, myknots->Array1(), mymults->ChangeArray1());
}
}
}
- else {
+ else
+ {
- // cas ou on va iterer a partir de noeuds donnes par l''utilisateur
+ // cas ou on va iterer a partir de noeuds donnes par l''utilisateur
// ou a partir d''une bezier.
// ================================================================
- while (!Finish) {
+ while (!Finish)
+ {
currenttol3d = currenttol2d = RealLast();
- if (myhasknots && begin) {
+ if (myhasknots && begin)
+ {
- if (!myhasmults) {
+ if (!myhasmults)
+ {
// 1er cas: l''utilisateur donne des noeuds de depart mais
- // a nous de fixer les multiplicites en fonction de la
+ // a nous de fixer les multiplicites en fonction de la
// continuite desiree.
// ========================================================
TColStd_Array1OfInteger TheMults(1, myknots->Length());
- alldone = Compute(Line, myfirstpt, mylastpt, TheParam,
- myknots->Array1(), TheMults);
+ alldone = Compute(Line, myfirstpt, mylastpt, TheParam, myknots->Array1(), TheMults);
}
- else {
+ else
+ {
- // 2eme cas: l''utilisateur donne des noeuds de depart
+ // 2eme cas: l''utilisateur donne des noeuds de depart
// avec leurs multiplicites.
// ===================================================
- alldone = Compute(Line, myfirstpt, mylastpt, TheParam,
- myknots->Array1(), mymults->ChangeArray1());
+ alldone = Compute(Line,
+ myfirstpt,
+ mylastpt,
+ TheParam,
+ myknots->Array1(),
+ mymults->ChangeArray1());
}
begin = Standard_False;
}
- else {
+ else
+ {
// 3eme cas: l''utilisateur ne donne aucun noeuds de depart
// ========================================================
- TColStd_Array1OfReal Theknots(1, nbknots);
+ TColStd_Array1OfReal Theknots(1, nbknots);
TColStd_Array1OfInteger TheMults(1, nbknots);
- Theknots(1) = 0.0;
+ Theknots(1) = 0.0;
Theknots(nbknots) = 1.0;
- for (i = 2; i <= nbknots - 1; i++) {
+ for (i = 2; i <= nbknots - 1; i++)
+ {
- l = (mylastpt - myfirstpt)*Standard_Real(i - 1)
- / Standard_Real(nbknots - 1);
+ l = (mylastpt - myfirstpt) * Standard_Real(i - 1) / Standard_Real(nbknots - 1);
Standard_Integer ll = (Standard_Integer)(l);
- Standard_Real a = l - ll;
- Standard_Real p1 = TheParam(ll + myfirstpt);
- Standard_Real p2 = TheParam(ll + 1 + myfirstpt);
- Theknots(i) = (1. - a)*p1 + a*p2;
+ Standard_Real a = l - ll;
+ Standard_Real p1 = TheParam(ll + myfirstpt);
+ Standard_Real p2 = TheParam(ll + 1 + myfirstpt);
+ Theknots(i) = (1. - a) * p1 + a * p2;
}
alldone = Compute(Line, myfirstpt, mylastpt, TheParam, Theknots, TheMults);
-
}
- if (!alldone) nbknots++;
- else Finish = Standard_True;
+ if (!alldone)
+ nbknots++;
+ else
+ Finish = Standard_True;
}
}
-#if defined(OCCT_DEBUG) && defined( DRAW ) && !defined( WNT )
- if (mydebug) DUMP(TheMultiBSpCurve);
+#if defined(OCCT_DEBUG) && defined(DRAW) && !defined(WNT)
+ if (mydebug)
+ DUMP(TheMultiBSpCurve);
#endif
-
}
-
-
-
//=================================================================================================
const TColStd_Array1OfReal& Approx_BSplComputeLine::Parameters() const
return myParameters->Array1();
}
-
-
//=================================================================================================
const AppParCurves_MultiBSpCurve& Approx_BSplComputeLine::Value() const
//=================================================================================================
-
-void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
- const Standard_Integer firstP,
- const Standard_Integer lastP,
- math_Vector& TheParameters) const
+void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
+ const Standard_Integer firstP,
+ const Standard_Integer lastP,
+ math_Vector& TheParameters) const
{
- Standard_Integer i, j, nbP2d, nbP3d;
- Standard_Real dist;
+ Standard_Integer i, j, nbP2d, nbP3d;
+ Standard_Real dist;
const Standard_Integer aNbp = lastP - firstP + 1;
-
// The first parameter should always be zero according to all the logic below,
// so division by any value will give zero anyway, so it should never be scaled
// to avoid case when there is only one parameter in the array thus division by zero happens.
TheParameters(firstP) = 0.0;
- if (aNbp == 2) {
+ if (aNbp == 2)
+ {
TheParameters(lastP) = 1.0;
}
else if (Par == Approx_ChordLength || Par == Approx_Centripetal)
{
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
dist = 0.0;
- TColgp_Array1OfPnt tabP(1, mynbP3d);
- TColgp_Array1OfPnt tabPP(1, mynbP3d);
+ TColgp_Array1OfPnt tabP(1, mynbP3d);
+ TColgp_Array1OfPnt tabPP(1, mynbP3d);
TColgp_Array1OfPnt2d tabP2d(1, mynbP2d);
TColgp_Array1OfPnt2d tabPP2d(1, mynbP2d);
for (i = firstP + 1; i <= lastP; i++)
{
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, i - 1, tabP, tabP2d);
- else if (nbP2d != 0) LineTool::Value(Line, i - 1, tabP2d);
- else if (nbP3d != 0) LineTool::Value(Line, i - 1, tabP);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, i - 1, tabP, tabP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, i - 1, tabP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, i - 1, tabP);
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, i, tabPP, tabPP2d);
- else if (nbP2d != 0) LineTool::Value(Line, i, tabPP2d);
- else if (nbP3d != 0) LineTool::Value(Line, i, tabPP);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, i, tabPP, tabPP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, i, tabPP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, i, tabPP);
dist = 0.0;
for (j = 1; j <= nbP3d; j++)
{
- const gp_Pnt &aP1 = tabP(j),
- &aP2 = tabPP(j);
+ const gp_Pnt &aP1 = tabP(j), &aP2 = tabPP(j);
dist += aP2.SquareDistance(aP1);
}
for (j = 1; j <= nbP2d; j++)
{
- const gp_Pnt2d &aP12d = tabP2d(j),
- &aP22d = tabPP2d(j);
+ const gp_Pnt2d &aP12d = tabP2d(j), &aP22d = tabPP2d(j);
dist += aP22d.SquareDistance(aP12d);
}
TheParameters(i) = TheParameters(i - 1) + dist;
}
else
- {// Par == Approx_Centripetal
+ { // Par == Approx_Centripetal
TheParameters(i) = TheParameters(i - 1) + Sqrt(dist);
}
}
- for (i = firstP + 1; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
+ for (i = firstP + 1; i <= lastP; i++)
+ TheParameters(i) /= TheParameters(lastP);
}
- else {
- for (i = firstP + 1; i <= lastP; i++) {
- TheParameters(i) = (Standard_Real(i) - firstP) /
- (Standard_Real(lastP - Standard_Real(firstP)));
+ else
+ {
+ for (i = firstP + 1; i <= lastP; i++)
+ {
+ TheParameters(i) =
+ (Standard_Real(i) - firstP) / (Standard_Real(lastP - Standard_Real(firstP)));
}
}
}
-
//=================================================================================================
-Standard_Boolean Approx_BSplComputeLine::Compute(const MultiLine& Line,
- const Standard_Integer fpt,
- const Standard_Integer lpt,
- math_Vector& Para,
- const TColStd_Array1OfReal& Knots,
- TColStd_Array1OfInteger& Mults)
+Standard_Boolean Approx_BSplComputeLine::Compute(const MultiLine& Line,
+ const Standard_Integer fpt,
+ const Standard_Integer lpt,
+ math_Vector& Para,
+ const TColStd_Array1OfReal& Knots,
+ TColStd_Array1OfInteger& Mults)
{
Standard_Integer i, deg, nbpoles, multinter;
Standard_Boolean mydone;
- Standard_Real Fv, TheTol3d, TheTol2d, l1, l2;
+ Standard_Real Fv, TheTol3d, TheTol2d, l1, l2;
Standard_Integer nbp = lpt - fpt + 1;
- mylambda1 = 0.0;
- mylambda2 = 0.0;
+ mylambda1 = 0.0;
+ mylambda2 = 0.0;
math_Vector aParams(Para.Lower(), Para.Upper());
- for (deg = mydegremin; deg <= mydegremax; deg++) {
+ for (deg = mydegremin; deg <= mydegremax; deg++)
+ {
aParams = Para;
- if (!myhasmults) {
+ if (!myhasmults)
+ {
Mults(Mults.Lower()) = deg + 1;
Mults(Mults.Upper()) = deg + 1;
- nbpoles = deg + 1;
- if (mycont == -1) multinter = 1;
- else multinter = Max(1, deg - mycont);
- for (i = Mults.Lower() + 1; i <= Mults.Upper() - 1; i++) {
+ nbpoles = deg + 1;
+ if (mycont == -1)
+ multinter = 1;
+ else
+ multinter = Max(1, deg - mycont);
+ for (i = Mults.Lower() + 1; i <= Mults.Upper() - 1; i++)
+ {
Mults(i) = multinter;
nbpoles += multinter;
}
}
- else {
+ else
+ {
nbpoles = -deg - 1;
- for (i = Mults.Lower(); i <= Mults.Upper(); i++) {
+ for (i = Mults.Lower(); i <= Mults.Upper(); i++)
+ {
nbpoles += Mults.Value(i);
}
}
Standard_Integer nbpolestocompare = nbpoles;
- if (realfirstC == AppParCurves_TangencyPoint) nbpolestocompare++;
- if (reallastC == AppParCurves_TangencyPoint) nbpolestocompare++;
- if (realfirstC == AppParCurves_CurvaturePoint) nbpolestocompare++;
- if (reallastC == AppParCurves_CurvaturePoint) nbpolestocompare++;
- if (nbpolestocompare > nbp) {
+ if (realfirstC == AppParCurves_TangencyPoint)
+ nbpolestocompare++;
+ if (reallastC == AppParCurves_TangencyPoint)
+ nbpolestocompare++;
+ if (realfirstC == AppParCurves_CurvaturePoint)
+ nbpolestocompare++;
+ if (reallastC == AppParCurves_CurvaturePoint)
+ nbpolestocompare++;
+ if (nbpolestocompare > nbp)
+ {
Interpol(Line);
tolreached = Standard_True;
return Standard_True;
AppParCurves_MultiBSpCurve mySCU(nbpoles);
- if (mysquares) {
- Approx_BSpParLeastSquareOfMyBSplGradient SQ(Line, Knots, Mults, fpt, lpt,
- realfirstC, reallastC, aParams, nbpoles);
+ if (mysquares)
+ {
+ Approx_BSpParLeastSquareOfMyBSplGradient
+ SQ(Line, Knots, Mults, fpt, lpt, realfirstC, reallastC, aParams, nbpoles);
mydone = SQ.IsDone();
- if (mydone) {
+ if (mydone)
+ {
mySCU = SQ.BSplineValue();
SQ.Error(Fv, TheTol3d, TheTol2d);
}
- else continue;
+ else
+ continue;
}
- else {
- if (nbpoles != deg + 1) {
+ else
+ {
+ if (nbpoles != deg + 1)
+ {
- if (deg == mydegremin && (realfirstC >= AppParCurves_TangencyPoint ||
- reallastC >= AppParCurves_TangencyPoint)) {
+ if (deg == mydegremin
+ && (realfirstC >= AppParCurves_TangencyPoint
+ || reallastC >= AppParCurves_TangencyPoint))
+ {
Approx_BSpParLeastSquareOfMyBSplGradient
thefitt(Line, Knots, Mults, fpt, lpt, realfirstC, reallastC, aParams, nbpoles);
- mylambda1 = thefitt.FirstLambda()*deg;
- mylambda2 = thefitt.LastLambda()*deg;
-
+ mylambda1 = thefitt.FirstLambda() * deg;
+ mylambda2 = thefitt.LastLambda() * deg;
}
l1 = mylambda1 / deg;
l2 = mylambda2 / deg;
- Approx_MyBSplGradient GRAD(Line, fpt, lpt, myConstraints,
- aParams, Knots, Mults, deg, mytol3d,
- mytol2d, myitermax, l1, l2);
+ Approx_MyBSplGradient GRAD(Line,
+ fpt,
+ lpt,
+ myConstraints,
+ aParams,
+ Knots,
+ Mults,
+ deg,
+ mytol3d,
+ mytol2d,
+ myitermax,
+ l1,
+ l2);
mydone = GRAD.IsDone();
- if (mydone) {
- mySCU = GRAD.Value();
+ if (mydone)
+ {
+ mySCU = GRAD.Value();
TheTol3d = GRAD.MaxError3d();
TheTol2d = GRAD.MaxError2d();
}
- else continue;
+ else
+ continue;
}
- else {
- Approx_MyGradientbis GRAD2(Line, fpt, lpt, myConstraints,
- aParams, deg, mytol3d,
- mytol2d, myitermax);
+ else
+ {
+ Approx_MyGradientbis
+ GRAD2(Line, fpt, lpt, myConstraints, aParams, deg, mytol3d, mytol2d, myitermax);
mydone = GRAD2.IsDone();
- if (mydone) {
+ if (mydone)
+ {
if (GRAD2.Value().NbCurves() == 0)
continue;
- mySCU = AppParCurves_MultiBSpCurve(GRAD2.Value(), Knots, Mults);
+ mySCU = AppParCurves_MultiBSpCurve(GRAD2.Value(), Knots, Mults);
TheTol3d = GRAD2.MaxError3d();
TheTol2d = GRAD2.MaxError2d();
}
- else continue;
+ else
+ continue;
}
}
Standard_Boolean save = Standard_True;
- for (i = aParams.Lower(); i <= aParams.Upper(); i++) {
- if (aParams(i) <= -0.000001 || aParams(i) >= 1.000001) {
+ for (i = aParams.Lower(); i <= aParams.Upper(); i++)
+ {
+ if (aParams(i) <= -0.000001 || aParams(i) >= 1.000001)
+ {
save = Standard_False;
break;
}
}
- if (mydone) {
- if (TheTol3d <= mytol3d && TheTol2d <= mytol2d) {
+ if (mydone)
+ {
+ if (TheTol3d <= mytol3d && TheTol2d <= mytol2d)
+ {
// Stockage de la multicurve approximee.
- tolreached = Standard_True;
+ tolreached = Standard_True;
TheMultiBSpCurve = mySCU;
- currenttol3d = TheTol3d;
- currenttol2d = TheTol2d;
- if (save) {
- for (i = aParams.Lower(); i <= aParams.Upper(); i++) {
+ currenttol3d = TheTol3d;
+ currenttol2d = TheTol2d;
+ if (save)
+ {
+ for (i = aParams.Lower(); i <= aParams.Upper(); i++)
+ {
myParameters->SetValue(i, aParams(i));
}
}
}
}
- if (TheTol3d <= currenttol3d && TheTol2d <= currenttol2d) {
+ if (TheTol3d <= currenttol3d && TheTol2d <= currenttol2d)
+ {
TheMultiBSpCurve = mySCU;
- currenttol3d = TheTol3d;
- currenttol2d = TheTol2d;
- if (save) {
- for (i = aParams.Lower(); i <= aParams.Upper(); i++) {
+ currenttol3d = TheTol3d;
+ currenttol2d = TheTol2d;
+ if (save)
+ {
+ for (i = aParams.Lower(); i <= aParams.Upper(); i++)
+ {
myParameters->SetValue(i, aParams(i));
}
}
}
-
}
return Standard_False;
}
-
-
//=================================================================================================
void Approx_BSplComputeLine::SetParameters(const math_Vector& ThePar)
{
- myfirstParam = new TColStd_HArray1OfReal(ThePar.Lower(),
- ThePar.Upper());
- for (Standard_Integer i = ThePar.Lower(); i <= ThePar.Upper(); i++) {
+ myfirstParam = new TColStd_HArray1OfReal(ThePar.Lower(), ThePar.Upper());
+ for (Standard_Integer i = ThePar.Lower(); i <= ThePar.Upper(); i++)
+ {
myfirstParam->SetValue(i, ThePar(i));
}
}
-
//=================================================================================================
void Approx_BSplComputeLine::SetKnots(const TColStd_Array1OfReal& Knots)
{
myhasknots = Standard_True;
- myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
- for (Standard_Integer i = Knots.Lower(); i <= Knots.Upper(); i++) {
+ myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
+ for (Standard_Integer i = Knots.Lower(); i <= Knots.Upper(); i++)
+ {
myknots->SetValue(i, Knots(i));
}
}
-
//=================================================================================================
-void Approx_BSplComputeLine::SetKnotsAndMultiplicities
-(const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults)
+void Approx_BSplComputeLine::SetKnotsAndMultiplicities(const TColStd_Array1OfReal& Knots,
+ const TColStd_Array1OfInteger& Mults)
{
myhasknots = Standard_True;
myhasmults = Standard_True;
Standard_Integer i;
myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
- for (i = Knots.Lower(); i <= Knots.Upper(); i++) {
+ for (i = Knots.Lower(); i <= Knots.Upper(); i++)
+ {
myknots->SetValue(i, Knots(i));
}
mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
- for (i = Mults.Lower(); i <= Mults.Upper(); i++) {
+ for (i = Mults.Lower(); i <= Mults.Upper(); i++)
+ {
mymults->SetValue(i, Mults(i));
}
}
//=================================================================================================
-void Approx_BSplComputeLine::Init(const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Approx_ParametrizationType parametrization,
- const Standard_Boolean Squares)
+void Approx_BSplComputeLine::Init(const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Approx_ParametrizationType parametrization,
+ const Standard_Boolean Squares)
{
mydegremin = degreemin;
mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- Par = parametrization;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ Par = parametrization;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
}
-
-
//=================================================================================================
void Approx_BSplComputeLine::SetDegrees(const Standard_Integer degreemin,
- const Standard_Integer degreemax)
+ const Standard_Integer degreemax)
{
mydegremin = degreemin;
mydegremax = degreemax;
}
-
//=================================================================================================
void Approx_BSplComputeLine::SetTolerances(const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d)
+ const Standard_Real Tolerance2d)
{
mytol3d = Tolerance3d;
mytol2d = Tolerance2d;
}
-
//=================================================================================================
void Approx_BSplComputeLine::SetConstraints(const AppParCurves_Constraint FirstC,
- const AppParCurves_Constraint LastC)
+ const AppParCurves_Constraint LastC)
{
myfirstC = FirstC;
- mylastC = LastC;
+ mylastC = LastC;
}
//=================================================================================================
myPeriodic = thePeriodic;
}
-
//=================================================================================================
Standard_Boolean Approx_BSplComputeLine::IsAllApproximated() const
//=================================================================================================
-void Approx_BSplComputeLine::Error(Standard_Real& tol3d,
- Standard_Real& tol2d) const
+void Approx_BSplComputeLine::Error(Standard_Real& tol3d, Standard_Real& tol2d) const
{
tol3d = currenttol3d;
tol2d = currenttol2d;
}
-
-
//=================================================================================================
void Approx_BSplComputeLine::SetContinuity(const Standard_Integer C)
mycont = C;
}
-
-
//=================================================================================================
void Approx_BSplComputeLine::FindRealConstraints(const MultiLine& Line)
{
realfirstC = myfirstC;
- reallastC = mylastC;
+ reallastC = mylastC;
Standard_Integer nbP2d, nbP3d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
- Standard_Boolean Ok = Standard_False;
- TColgp_Array1OfVec TabV(1, Max(1, nbP3d));
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
+ Standard_Boolean Ok = Standard_False;
+ TColgp_Array1OfVec TabV(1, Max(1, nbP3d));
TColgp_Array1OfVec2d TabV2d(1, Max(1, nbP2d));
- Standard_Integer Thefirstpt = LineTool::FirstPoint(Line);
- Standard_Integer Thelastpt = LineTool::LastPoint(Line);
+ Standard_Integer Thefirstpt = LineTool::FirstPoint(Line);
+ Standard_Integer Thelastpt = LineTool::LastPoint(Line);
- if (myfirstC >= AppParCurves_TangencyPoint) {
+ if (myfirstC >= AppParCurves_TangencyPoint)
+ {
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, Thefirstpt, TabV, TabV2d);
Ok = LineTool::Tangency(Line, Thefirstpt, TabV);
realfirstC = AppParCurves_PassPoint;
- if (Ok) {
+ if (Ok)
+ {
realfirstC = AppParCurves_TangencyPoint;
- if (myfirstC == AppParCurves_CurvaturePoint) {
+ if (myfirstC == AppParCurves_CurvaturePoint)
+ {
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, Thefirstpt, TabV, TabV2d);
else if (nbP2d != 0)
Ok = LineTool::Tangency(Line, Thefirstpt, TabV2d);
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, Thefirstpt, TabV);
- if (Ok) {
+ if (Ok)
+ {
realfirstC = AppParCurves_CurvaturePoint;
}
}
}
}
-
- if (mylastC >= AppParCurves_TangencyPoint) {
+ if (mylastC >= AppParCurves_TangencyPoint)
+ {
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, Thelastpt, TabV, TabV2d);
Ok = LineTool::Tangency(Line, Thelastpt, TabV);
reallastC = AppParCurves_PassPoint;
- if (Ok) {
+ if (Ok)
+ {
reallastC = AppParCurves_TangencyPoint;
- if (mylastC == AppParCurves_CurvaturePoint) {
+ if (mylastC == AppParCurves_CurvaturePoint)
+ {
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, Thelastpt, TabV, TabV2d);
else if (nbP2d != 0)
Ok = LineTool::Tangency(Line, Thelastpt, TabV2d);
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, Thelastpt, TabV);
- if (Ok) {
+ if (Ok)
+ {
reallastC = AppParCurves_CurvaturePoint;
}
}
}
}
-
}
-
-
-
//=================================================================================================
void Approx_BSplComputeLine::Interpol(const MultiLine& Line)
{
Standard_Integer i, Thefirstpt, Thelastpt, deg = 3;
- mycont = 2;
+ mycont = 2;
Thefirstpt = LineTool::FirstPoint(Line);
- Thelastpt = LineTool::LastPoint(Line);
+ Thelastpt = LineTool::LastPoint(Line);
math_Vector TheParam(Thefirstpt, Thelastpt, 0.0);
- //Par = Approx_ChordLength;
- if (myfirstParam.IsNull()) {
+ // Par = Approx_ChordLength;
+ if (myfirstParam.IsNull())
+ {
Parameters(Line, Thefirstpt, Thelastpt, TheParam);
}
- else {
- for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++) {
+ else
+ {
+ for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++)
+ {
TheParam(i + Thefirstpt - 1) = myfirstParam->Value(i);
}
}
AppParCurves_Constraint Cons = AppParCurves_TangencyPoint;
- Standard_Real lambda1, lambda2;
- Standard_Real Fv;
+ Standard_Real lambda1, lambda2;
+ Standard_Real Fv;
// Recherche du nombre de noeuds.
Standard_Integer nbknots, nbpoles, nbpoints;
nbpoints = Thelastpt - Thefirstpt + 1;
- if (nbpoints == 2) {
- Cons = AppParCurves_NoConstraint;
+ if (nbpoints == 2)
+ {
+ Cons = AppParCurves_NoConstraint;
Standard_Integer mydeg = 1;
Approx_BSpParLeastSquareOfMyBSplGradient
LSQ(Line, Thefirstpt, Thelastpt, Cons, Cons, TheParam, mydeg + 1);
alldone = LSQ.IsDone();
- TColStd_Array1OfReal TheKnots(1, 2);
+ TColStd_Array1OfReal TheKnots(1, 2);
TColStd_Array1OfInteger TheMults(1, 2);
- TheKnots(1) = TheParam(Thefirstpt); TheKnots(2) = TheParam(Thelastpt);
+ TheKnots(1) = TheParam(Thefirstpt);
+ TheKnots(2) = TheParam(Thelastpt);
TheMults(1) = TheMults(2) = mydeg + 1;
- TheMultiBSpCurve =
- AppParCurves_MultiBSpCurve(LSQ.BezierValue(), TheKnots, TheMults);
+ TheMultiBSpCurve = AppParCurves_MultiBSpCurve(LSQ.BezierValue(), TheKnots, TheMults);
LSQ.Error(Fv, currenttol3d, currenttol2d);
-
}
- else {
+ else
+ {
nbpoles = nbpoints + 2;
nbknots = nbpoints;
// Resolution:
TColStd_Array1OfReal Theknots(1, nbknots);
- Theknots(1) = TheParam(Thefirstpt);
+ Theknots(1) = TheParam(Thefirstpt);
Theknots(nbknots) = TheParam(Thelastpt);
TColStd_Array1OfInteger TheMults(1, nbknots);
- TheMults(1) = deg + 1;
+ TheMults(1) = deg + 1;
TheMults(nbknots) = deg + 1;
Standard_Integer low = TheParam.Lower();
- for (i = 2; i <= nbknots - 1; i++) {
+ for (i = 2; i <= nbknots - 1; i++)
+ {
Theknots(i) = TheParam(i + low - 1);
TheMults(i) = 1;
}
-
Standard_Integer nbP = 3 * LineTool::NbP3d(Line) + 2 * LineTool::NbP2d(Line);
- math_Vector V1(1, nbP), V2(1, nbP);
+ math_Vector V1(1, nbP), V2(1, nbP);
- if (nbpoints == 3 || nbpoints == 4) {
+ if (nbpoints == 3 || nbpoints == 4)
+ {
FirstTangencyVector(Line, Thefirstpt, V1);
lambda1 = SearchFirstLambda(Line, TheParam, Theknots, V1, Thefirstpt);
lambda1 = lambda1 / deg;
lambda2 = lambda2 / deg;
}
- else {
+ else
+ {
Standard_Integer nnpol, nnp = Min(nbpoints, 9);
- nnpol = nnp;
- Standard_Integer lastp = Min(Thelastpt, Thefirstpt + nnp - 1);
- Standard_Real U;
- Approx_BSpParLeastSquareOfMyBSplGradient
- SQ1(Line, Thefirstpt, lastp, Cons, Cons, nnpol);
+ nnpol = nnp;
+ Standard_Integer lastp = Min(Thelastpt, Thefirstpt + nnp - 1);
+ Standard_Real U;
+ Approx_BSpParLeastSquareOfMyBSplGradient SQ1(Line, Thefirstpt, lastp, Cons, Cons, nnpol);
math_Vector P1(Thefirstpt, lastp);
- for (i = Thefirstpt; i <= lastp; i++) P1(i) = TheParam(i);
+ for (i = Thefirstpt; i <= lastp; i++)
+ P1(i) = TheParam(i);
SQ1.Perform(P1);
const AppParCurves_MultiCurve& C1 = SQ1.BezierValue();
- U = 0.0;
+ U = 0.0;
TangencyVector(Line, C1, U, V1);
Standard_Integer firstp = Max(Thefirstpt, Thelastpt - nnp + 1);
- if (firstp == Thefirstpt && lastp == Thelastpt) {
+ if (firstp == Thefirstpt && lastp == Thelastpt)
+ {
U = 1.0;
TangencyVector(Line, C1, U, V2);
}
- else {
- Approx_BSpParLeastSquareOfMyBSplGradient
- SQ2(Line, firstp, Thelastpt, Cons, Cons, nnpol);
+ else
+ {
+ Approx_BSpParLeastSquareOfMyBSplGradient SQ2(Line, firstp, Thelastpt, Cons, Cons, nnpol);
math_Vector P2(firstp, Thelastpt);
- for (i = firstp; i <= Thelastpt; i++) P2(i) = TheParam(i);
+ for (i = firstp; i <= Thelastpt; i++)
+ P2(i) = TheParam(i);
SQ2.Perform(P2);
const AppParCurves_MultiCurve& C2 = SQ2.BezierValue();
- U = 1.0;
+ U = 1.0;
TangencyVector(Line, C2, U, V2);
}
-
lambda1 = 1. / deg;
- lambda1 = lambda1*(Theknots(2) - Theknots(1))
- / (Theknots(nbknots) - Theknots(1));
+ lambda1 = lambda1 * (Theknots(2) - Theknots(1)) / (Theknots(nbknots) - Theknots(1));
lambda2 = 1. / deg;
- lambda2 = lambda2*(Theknots(nbknots) - Theknots(nbknots - 1))
- / (Theknots(nbknots) - Theknots(1));
-
+ lambda2 =
+ lambda2 * (Theknots(nbknots) - Theknots(nbknots - 1)) / (Theknots(nbknots) - Theknots(1));
}
if (myPeriodic)
}
Approx_BSpParLeastSquareOfMyBSplGradient
- SQ(Line, Theknots, TheMults, Thefirstpt, Thelastpt,
- Cons, Cons, nbpoles);
+ SQ(Line, Theknots, TheMults, Thefirstpt, Thelastpt, Cons, Cons, nbpoles);
SQ.Perform(TheParam, V1, V2, lambda1, lambda2);
- alldone = SQ.IsDone();
+ alldone = SQ.IsDone();
TheMultiBSpCurve = SQ.BSplineValue();
SQ.Error(Fv, currenttol3d, currenttol2d);
tolreached = Standard_True;
}
myParameters = new TColStd_HArray1OfReal(TheParam.Lower(), TheParam.Upper());
- for (i = TheParam.Lower(); i <= TheParam.Upper(); i++) {
+ for (i = TheParam.Lower(); i <= TheParam.Upper(); i++)
+ {
myParameters->SetValue(i, TheParam(i));
}
}
-
//=================================================================================================
-void Approx_BSplComputeLine::TangencyVector(
- const MultiLine& Line,
- const AppParCurves_MultiCurve& C,
- const Standard_Real U,
- math_Vector& V) const
+void Approx_BSplComputeLine::TangencyVector(const MultiLine& Line,
+ const AppParCurves_MultiCurve& C,
+ const Standard_Real U,
+ math_Vector& V) const
{
Standard_Integer i, j, nbP2d, nbP3d;
nbP3d = LineTool::NbP3d(Line);
nbP2d = LineTool::NbP2d(Line);
- gp_Pnt myP;
- gp_Vec myV;
+ gp_Pnt myP;
+ gp_Vec myV;
gp_Pnt2d myP2d;
gp_Vec2d myV2d;
j = 1;
- for (i = 1; i <= nbP3d; i++) {
+ for (i = 1; i <= nbP3d; i++)
+ {
C.D1(i, U, myP, myV);
- V(j) = myV.X();
+ V(j) = myV.X();
V(j + 1) = myV.Y();
V(j + 2) = myV.Z();
j += 3;
}
j = nbP3d * 3 + 1;
- for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++) {
+ for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++)
+ {
C.D1(i, U, myP2d, myV2d);
- V(j) = myV2d.X();
+ V(j) = myV2d.X();
V(j + 1) = myV2d.Y();
j += 2;
}
-
}
-
// -- stop cutting an interval to approximate if next decisions
// -- get worse on and on
-
-
#include <Approx_ParametrizationType.hxx>
#include <AppCont_LeastSquare.hxx>
#include <TColStd_Array1OfReal.hxx>
const static Standard_Integer MAXSEGM = 1000;
//=======================================================================
-//function : Approx_ComputeCLine
-//purpose : The MultiLine <Line> will be approximated until tolerances
+// function : Approx_ComputeCLine
+// purpose : The MultiLine <Line> will be approximated until tolerances
// will be reached.
// The approximation will be done from degreemin to degreemax
// with a cutting if the corresponding boolean is True.
//=======================================================================
-Approx_ComputeCLine::Approx_ComputeCLine
-(const MultiLine& Line,
-const Standard_Integer degreemin,
-const Standard_Integer degreemax,
-const Standard_Real Tolerance3d,
-const Standard_Real Tolerance2d,
-const Standard_Boolean cutting,
-const AppParCurves_Constraint FirstC,
-const AppParCurves_Constraint LastC)
+Approx_ComputeCLine::Approx_ComputeCLine(const MultiLine& Line,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Boolean cutting,
+ const AppParCurves_Constraint FirstC,
+ const AppParCurves_Constraint LastC)
{
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mycut = cutting;
- myfirstC = FirstC;
- mylastC = LastC;
- myMaxSegments = MAXSEGM;
- myInvOrder = Standard_True;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mycut = cutting;
+ myfirstC = FirstC;
+ mylastC = LastC;
+ myMaxSegments = MAXSEGM;
+ myInvOrder = Standard_True;
myHangChecking = Standard_True;
- alldone = Standard_False;
- tolreached = Standard_False;
- currenttol3d = 0.0;
- currenttol2d = 0.0;
+ alldone = Standard_False;
+ tolreached = Standard_False;
+ currenttol3d = 0.0;
+ currenttol2d = 0.0;
Perform(Line);
}
//=======================================================================
-//function : Approx_ComputeCLine
-//purpose : Initializes the fields of the algorithm.
+// function : Approx_ComputeCLine
+// purpose : Initializes the fields of the algorithm.
//=======================================================================
-Approx_ComputeCLine::Approx_ComputeCLine
-(const Standard_Integer degreemin,
-const Standard_Integer degreemax,
-const Standard_Real Tolerance3d,
-const Standard_Real Tolerance2d,
-const Standard_Boolean cutting,
-const AppParCurves_Constraint FirstC,
-const AppParCurves_Constraint LastC)
+Approx_ComputeCLine::Approx_ComputeCLine(const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Boolean cutting,
+ const AppParCurves_Constraint FirstC,
+ const AppParCurves_Constraint LastC)
{
- alldone = Standard_False;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mycut = cutting;
- myfirstC = FirstC;
- mylastC = LastC;
- myMaxSegments = MAXSEGM;
- myInvOrder = Standard_True;
+ alldone = Standard_False;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mycut = cutting;
+ myfirstC = FirstC;
+ mylastC = LastC;
+ myMaxSegments = MAXSEGM;
+ myInvOrder = Standard_True;
myHangChecking = Standard_True;
- tolreached = Standard_False;
- currenttol3d = 0.0;
- currenttol2d = 0.0;
+ tolreached = Standard_False;
+ currenttol3d = 0.0;
+ currenttol2d = 0.0;
}
//=======================================================================
-//function : Perform
-//purpose : runs the algorithm after having initialized the fields.
+// function : Perform
+// purpose : runs the algorithm after having initialized the fields.
//=======================================================================
void Approx_ComputeCLine::Perform(const MultiLine& Line)
{
- Standard_Real UFirst, ULast;
- Standard_Boolean Finish = Standard_False,
- begin = Standard_True, Ok = Standard_False;
- Standard_Real thetol3d = Precision::Confusion(), thetol2d = Precision::Confusion();
- UFirst = Line.FirstParameter();
- ULast = Line.LastParameter();
+ Standard_Real UFirst, ULast;
+ Standard_Boolean Finish = Standard_False, begin = Standard_True, Ok = Standard_False;
+ Standard_Real thetol3d = Precision::Confusion(), thetol2d = Precision::Confusion();
+ UFirst = Line.FirstParameter();
+ ULast = Line.LastParameter();
Standard_Real TolU = 0.;
if (myHangChecking)
{
- TolU = Max((ULast - UFirst)*1.e-03, Precision::Confusion());
+ TolU = Max((ULast - UFirst) * 1.e-03, Precision::Confusion());
}
else
{
- TolU = Max((ULast - UFirst)*1.e-05, Precision::PApproximation());
+ TolU = Max((ULast - UFirst) * 1.e-05, Precision::PApproximation());
}
- Standard_Real myfirstU = UFirst;
- Standard_Real mylastU = ULast;
- Standard_Integer aMaxSegments = 0;
+ Standard_Real myfirstU = UFirst;
+ Standard_Real mylastU = ULast;
+ Standard_Integer aMaxSegments = 0;
Standard_Integer aMaxSegments1 = myMaxSegments - 1;
Standard_Integer aNbCut = 0, aNbImp = 0, aNbComp = 10;
// previous decision to be taken if we get worse with next cut (eap)
AppParCurves_MultiCurve KeptMultiCurve;
- Standard_Real KeptUfirst = 0., KeptUlast = 0., KeptT3d = RealLast(), KeptT2d = 0.;
+ Standard_Real KeptUfirst = 0., KeptUlast = 0., KeptT3d = RealLast(), KeptT2d = 0.;
while (!Finish)
{
{
// Calcul de la partie a approximer.
myfirstU = mylastU;
- mylastU = ULast;
- aNbCut = 0;
- aNbImp = 0;
- if (Abs(ULast - myfirstU) <= RealEpsilon()
- || aMaxSegments >= myMaxSegments)
+ mylastU = ULast;
+ aNbCut = 0;
+ aNbImp = 0;
+ if (Abs(ULast - myfirstU) <= RealEpsilon() || aMaxSegments >= myMaxSegments)
{
- Finish = Standard_True;
+ Finish = Standard_True;
alldone = Standard_True;
return;
}
- KeptT3d = RealLast(); KeptT2d = 0;
+ KeptT3d = RealLast();
+ KeptT2d = 0;
KeptUfirst = myfirstU;
- KeptUlast = mylastU;
+ KeptUlast = mylastU;
}
else
{
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
{
KeptMultiCurve = TheMultiCurve;
- KeptUfirst = myfirstU;
- KeptUlast = mylastU;
- KeptT3d = thetol3d;
- KeptT2d = thetol2d;
+ KeptUfirst = myfirstU;
+ KeptUlast = mylastU;
+ KeptT3d = thetol3d;
+ KeptT2d = thetol2d;
aNbImp++;
}
aMaxSegments++;
}
- //cout << myfirstU << " - " << mylastU << " tol : " << thetol3d << " " << thetol2d << endl;
+ // cout << myfirstU << " - " << mylastU << " tol : " << thetol3d << " " << thetol2d << endl;
Standard_Boolean aStopCutting = Standard_False;
if (myHangChecking && aNbCut >= aNbComp)
{
aNbImp = 0;
}
// is new decision better?
- if (!Ok && (Abs(myfirstU - mylastU) <= TolU || aMaxSegments >= aMaxSegments1 || aStopCutting ))
+ if (!Ok && (Abs(myfirstU - mylastU) <= TolU || aMaxSegments >= aMaxSegments1 || aStopCutting))
{
Ok = Standard_True; // stop interval cutting, approx the rest part
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
{
KeptMultiCurve = TheMultiCurve;
- KeptUfirst = myfirstU;
- KeptUlast = mylastU;
- KeptT3d = thetol3d;
- KeptT2d = thetol2d;
+ KeptUfirst = myfirstU;
+ KeptUlast = mylastU;
+ KeptT3d = thetol3d;
+ KeptT2d = thetol2d;
}
mylastU = KeptUlast;
}
//=======================================================================
-//function : NbMultiCurves
-//purpose : Returns the number of MultiCurve doing the approximation
+// function : NbMultiCurves
+// purpose : Returns the number of MultiCurve doing the approximation
// of the MultiLine.
//=======================================================================
-Standard_Integer Approx_ComputeCLine::NbMultiCurves()const
+Standard_Integer Approx_ComputeCLine::NbMultiCurves() const
{
return myMultiCurves.Length();
}
//=======================================================================
-//function : Value
-//purpose : returns the approximation MultiCurve of range <Index>.
+// function : Value
+// purpose : returns the approximation MultiCurve of range <Index>.
//=======================================================================
-AppParCurves_MultiCurve Approx_ComputeCLine::Value(const Standard_Integer Index)
-const
+AppParCurves_MultiCurve Approx_ComputeCLine::Value(const Standard_Integer Index) const
{
return myMultiCurves.Value(Index);
}
//=======================================================================
-//function : Compute
-//purpose : is internally used by the algorithms.
+// function : Compute
+// purpose : is internally used by the algorithms.
//=======================================================================
-Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
- const Standard_Real Ufirst,
- const Standard_Real Ulast,
- Standard_Real& TheTol3d,
- Standard_Real& TheTol2d)
+Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
+ const Standard_Real Ufirst,
+ const Standard_Real Ulast,
+ Standard_Real& TheTol3d,
+ Standard_Real& TheTol2d)
{
-
const Standard_Integer NbPointsMax = 24;
- const Standard_Real aMinRatio = 0.05;
- const Standard_Integer aMaxDeg = 8;
+ const Standard_Real aMinRatio = 0.05;
+ const Standard_Integer aMaxDeg = 8;
//
Standard_Integer deg, NbPoints;
Standard_Boolean mydone;
- Standard_Real Fv;
+ Standard_Real Fv;
AppParCurves_MultiCurve aPrevCurve;
- Standard_Real aPrevTol3d = RealLast(), aPrevTol2d = RealLast();
- Standard_Boolean aPrevIsOk = Standard_False;
- Standard_Boolean anInvOrder = myInvOrder;
+ Standard_Real aPrevTol3d = RealLast(), aPrevTol2d = RealLast();
+ Standard_Boolean aPrevIsOk = Standard_False;
+ Standard_Boolean anInvOrder = myInvOrder;
if (anInvOrder && mydegremax > aMaxDeg)
{
if ((Ulast - Ufirst) / (Line.LastParameter() - Line.FirstParameter()) < aMinRatio)
}
if (anInvOrder)
{
- for (deg = mydegremax; deg >= mydegremin; deg--) {
+ for (deg = mydegremax; deg >= mydegremin; deg--)
+ {
NbPoints = Min(2 * deg + 1, NbPointsMax);
AppCont_LeastSquare LSquare(Line, Ufirst, Ulast, myfirstC, mylastC, deg, NbPoints);
mydone = LSquare.IsDone();
aPrevTol3d = TheTol3d;
aPrevTol2d = TheTol2d;
aPrevCurve = LSquare.Value();
- aPrevIsOk = Standard_True;
+ aPrevIsOk = Standard_True;
continue;
}
else if (aPrevIsOk)
{
// Stockage de la multicurve approximee.
tolreached = Standard_True;
- TheTol3d = aPrevTol3d;
- TheTol2d = aPrevTol2d;
+ TheTol3d = aPrevTol3d;
+ TheTol2d = aPrevTol2d;
myMultiCurves.Append(aPrevCurve);
myfirstparam.Append(Ufirst);
mylastparam.Append(Ulast);
{
// Stockage de la multicurve approximee.
tolreached = Standard_True;
- TheTol3d = aPrevTol3d;
- TheTol2d = aPrevTol2d;
+ TheTol3d = aPrevTol3d;
+ TheTol2d = aPrevTol2d;
myMultiCurves.Append(aPrevCurve);
myfirstparam.Append(Ufirst);
mylastparam.Append(Ulast);
if (!aPrevIsOk && deg == mydegremax)
{
TheMultiCurve = LSquare.Value();
- currenttol3d = TheTol3d;
- currenttol2d = TheTol2d;
- aPrevTol3d = TheTol3d;
- aPrevTol2d = TheTol2d;
- aPrevCurve = TheMultiCurve;
+ currenttol3d = TheTol3d;
+ currenttol2d = TheTol2d;
+ aPrevTol3d = TheTol3d;
+ aPrevTol2d = TheTol2d;
+ aPrevCurve = TheMultiCurve;
break;
}
}
}
else
{
- for (deg = mydegremin; deg <= mydegremax; deg++) {
+ for (deg = mydegremin; deg <= mydegremax; deg++)
+ {
NbPoints = Min(2 * deg + 1, NbPointsMax);
AppCont_LeastSquare LSquare(Line, Ufirst, Ulast, myfirstC, mylastC, deg, NbPoints);
mydone = LSquare.IsDone();
- if (mydone) {
+ if (mydone)
+ {
LSquare.Error(Fv, TheTol3d, TheTol2d);
- if (TheTol3d <= mytol3d && TheTol2d <= mytol2d) {
+ if (TheTol3d <= mytol3d && TheTol2d <= mytol2d)
+ {
// Stockage de la multicurve approximee.
tolreached = Standard_True;
myMultiCurves.Append(LSquare.Value());
return Standard_True;
}
}
- if (deg == mydegremax) {
+ if (deg == mydegremax)
+ {
TheMultiCurve = LSquare.Value();
- currenttol3d = TheTol3d;
- currenttol2d = TheTol2d;
+ currenttol3d = TheTol3d;
+ currenttol2d = TheTol2d;
}
}
}
}
//=======================================================================
-//function : Parameters
-//purpose : returns the first and last parameters of the
+// function : Parameters
+// purpose : returns the first and last parameters of the
// <Index> MultiCurve.
//=======================================================================
void Approx_ComputeCLine::Parameters(const Standard_Integer Index,
- Standard_Real& firstpar,
- Standard_Real& lastpar) const
+ Standard_Real& firstpar,
+ Standard_Real& lastpar) const
{
firstpar = myfirstparam.Value(Index);
- lastpar = mylastparam.Value(Index);
+ lastpar = mylastparam.Value(Index);
}
//=======================================================================
-//function : SetDegrees
-//purpose : changes the degrees of the approximation.
+// function : SetDegrees
+// purpose : changes the degrees of the approximation.
//=======================================================================
void Approx_ComputeCLine::SetDegrees(const Standard_Integer degreemin,
- const Standard_Integer degreemax)
+ const Standard_Integer degreemax)
{
mydegremin = degreemin;
mydegremax = degreemax;
}
//=======================================================================
-//function : SetTolerances
-//purpose : Changes the tolerances of the approximation.
+// function : SetTolerances
+// purpose : Changes the tolerances of the approximation.
//=======================================================================
void Approx_ComputeCLine::SetTolerances(const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d)
+ const Standard_Real Tolerance2d)
{
mytol3d = Tolerance3d;
mytol2d = Tolerance2d;
}
//=======================================================================
-//function : SetConstraints
-//purpose : Changes the constraints of the approximation.
+// function : SetConstraints
+// purpose : Changes the constraints of the approximation.
//=======================================================================
void Approx_ComputeCLine::SetConstraints(const AppParCurves_Constraint FirstC,
- const AppParCurves_Constraint LastC)
+ const AppParCurves_Constraint LastC)
{
myfirstC = FirstC;
- mylastC = LastC;
+ mylastC = LastC;
}
//=======================================================================
-//function : SetMaxSegments
-//purpose : Changes the max number of segments, which is allowed for cutting.
+// function : SetMaxSegments
+// purpose : Changes the max number of segments, which is allowed for cutting.
//=======================================================================
void Approx_ComputeCLine::SetMaxSegments(const Standard_Integer theMaxSegments)
}
//=======================================================================
-//function : IsAllApproximated
-//purpose : returns False if at a moment of the approximation,
+// function : IsAllApproximated
+// purpose : returns False if at a moment of the approximation,
// the status NoApproximation has been sent by the user
// when more points were needed.
//=======================================================================
-Standard_Boolean Approx_ComputeCLine::IsAllApproximated()
-const {
+Standard_Boolean Approx_ComputeCLine::IsAllApproximated() const
+{
return alldone;
}
//=======================================================================
-//function : IsToleranceReached
-//purpose : returns False if the status NoPointsAdded has been sent.
+// function : IsToleranceReached
+// purpose : returns False if the status NoPointsAdded has been sent.
//=======================================================================
-Standard_Boolean Approx_ComputeCLine::IsToleranceReached()
-const {
+Standard_Boolean Approx_ComputeCLine::IsToleranceReached() const
+{
return tolreached;
}
//=======================================================================
-//function : Error
-//purpose : returns the tolerances 2d and 3d of the <Index> MultiCurve.
+// function : Error
+// purpose : returns the tolerances 2d and 3d of the <Index> MultiCurve.
//=======================================================================
void Approx_ComputeCLine::Error(const Standard_Integer Index,
- Standard_Real& tol3d,
- Standard_Real& tol2d) const
+ Standard_Real& tol3d,
+ Standard_Real& tol2d) const
{
tol3d = Tolers3d.Value(Index);
tol2d = Tolers2d.Value(Index);
#ifdef OCCT_DEBUG
static Standard_Boolean mydebug = Standard_False;
-#include <Geom_BezierCurve.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#ifdef DRAW
-#include <DrawTrSurf.hxx>
-#include <Draw.hxx>
-#include <Draw_Appli.hxx>
-#endif
+ #include <Geom_BezierCurve.hxx>
+ #include <Geom2d_BezierCurve.hxx>
+ #ifdef DRAW
+ #include <DrawTrSurf.hxx>
+ #include <Draw.hxx>
+ #include <Draw_Appli.hxx>
+ #endif
static void DUMP(const MultiLine& Line)
{
Standard_Integer i, j, nbP2d, nbP3d, firstP, lastP;
- gp_Pnt P1;
- gp_Pnt2d P12d;
+ gp_Pnt P1;
+ gp_Pnt2d P12d;
firstP = LineTool::FirstPoint(Line);
lastP = LineTool::LastPoint(Line);
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
-
- TColgp_Array1OfPnt tabP(1, mynbP3d);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+
+ TColgp_Array1OfPnt tabP(1, mynbP3d);
TColgp_Array1OfPnt2d tabP2d(1, mynbP2d);
-
- std::cout <<"DUMP de la MultiLine entre "<<firstP <<" et "<<lastP<<": "<<std::endl;
- for (i = firstP; i <= lastP; i++) {
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, i, tabP, tabP2d);
- else if (nbP2d != 0) LineTool::Value(Line, i, tabP2d);
- else if (nbP3d != 0) LineTool::Value(Line, i, tabP);
-
- std::cout << "point "<<i<<":"<< std::endl;
- for (j = 1; j <= nbP3d; j++) {
+
+ std::cout << "DUMP de la MultiLine entre " << firstP << " et " << lastP << ": " << std::endl;
+ for (i = firstP; i <= lastP; i++)
+ {
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, i, tabP, tabP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, i, tabP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, i, tabP);
+
+ std::cout << "point " << i << ":" << std::endl;
+ for (j = 1; j <= nbP3d; j++)
+ {
P1 = tabP(j);
- std::cout <<P1.X()<<" "<<P1.Y()<<" "<<P1.Z()<<std::endl;
+ std::cout << P1.X() << " " << P1.Y() << " " << P1.Z() << std::endl;
}
- for (j = 1; j <= nbP2d; j++) {
+ for (j = 1; j <= nbP2d; j++)
+ {
P12d = tabP2d(j);
- std::cout <<P12d.X()<<" "<<P12d.Y()<<std::endl;
+ std::cout << P12d.X() << " " << P12d.Y() << std::endl;
}
}
-
}
-static void DUMP(const AppParCurves_MultiCurve& C) {
+static void DUMP(const AppParCurves_MultiCurve& C)
+{
static Standard_Integer nbappel = 0;
- Standard_Integer i;
- Standard_Integer nbpoles = C.NbPoles();
+ Standard_Integer i;
+ Standard_Integer nbpoles = C.NbPoles();
- Handle(Geom_BezierCurve) BSp;
+ Handle(Geom_BezierCurve) BSp;
Handle(Geom2d_BezierCurve) BSp2d;
- TColgp_Array1OfPnt tabPoles(1, nbpoles);
+ TColgp_Array1OfPnt tabPoles(1, nbpoles);
TColgp_Array1OfPnt2d tabPoles2d(1, nbpoles);
- char solname[100];
+ char solname[100];
nbappel++;
- for (i = 1; i <= C.NbCurves(); i++) {
- if (C.Dimension(i) == 3) {
+ for (i = 1; i <= C.NbCurves(); i++)
+ {
+ if (C.Dimension(i) == 3)
+ {
C.Curve(i, tabPoles);
BSp = new Geom_BezierCurve(tabPoles);
Sprintf(solname, "%s%i%s_%i", "c", i, "3d", nbappel);
-#ifdef DRAW
+ #ifdef DRAW
char* Temp = solname;
DrawTrSurf::Set(Temp, BSp);
-// DrawTrSurf::Set(solname, BSp);
-#endif
+ // DrawTrSurf::Set(solname, BSp);
+ #endif
}
- else {
+ else
+ {
C.Curve(i, tabPoles2d);
BSp2d = new Geom2d_BezierCurve(tabPoles2d);
Sprintf(solname, "%s%i%s_%i", "c", i, "2d", nbappel);
-#ifdef DRAW
+ #ifdef DRAW
char* Temp = solname;
DrawTrSurf::Set(Temp, BSp2d);
-// DrawTrSurf::Set(solname, BSp2d);
-#endif
+ // DrawTrSurf::Set(solname, BSp2d);
+ #endif
}
}
-#ifdef DRAW
+ #ifdef DRAW
dout.Flush();
-#endif
+ #endif
}
#endif
static Standard_Boolean CheckMultiCurve(const AppParCurves_MultiCurve& theMultiCurve,
- const MultiLine& theLine,
- const Standard_Integer theIndfirst,
- const Standard_Integer theIndlast,
- Standard_Integer& theIndbad)
+ const MultiLine& theLine,
+ const Standard_Integer theIndfirst,
+ const Standard_Integer theIndlast,
+ Standard_Integer& theIndbad)
{
const Standard_Integer nbp3d = LineTool::NbP3d(theLine);
const Standard_Integer nbp2d = LineTool::NbP2d(theLine);
- const Standard_Real coeff = 4.; //2*2
-
- if (nbp3d > 1) //only simple cases are analysed
+ const Standard_Real coeff = 4.; // 2*2
+
+ if (nbp3d > 1) // only simple cases are analysed
return Standard_True;
- const Standard_Real MinScalProd = -0.9;
- constexpr Standard_Real SqTol3d = Precision::SquareConfusion();
+ const Standard_Real MinScalProd = -0.9;
+ constexpr Standard_Real SqTol3d = Precision::SquareConfusion();
theIndbad = 0;
- Standard_Integer indbads [4];
+ Standard_Integer indbads[4];
indbads[1] = indbads[2] = indbads[3] = 0;
-
- Standard_Integer NbCur = theMultiCurve.NbCurves();
+
+ Standard_Integer NbCur = theMultiCurve.NbCurves();
Standard_Boolean LoopFound = Standard_False;
Standard_Integer aNbP3d = Max(nbp3d, 1);
Standard_Integer aNbP2d = Max(nbp2d, 1);
-
- TColgp_Array1OfPnt tabP(1, aNbP3d);
+
+ TColgp_Array1OfPnt tabP(1, aNbP3d);
TColgp_Array1OfPnt2d tabP2d(1, aNbP2d);
-
+
#ifdef DRAW
- char* name = new char[100];
+ char* name = new char[100];
Standard_Integer nbbc = 1;
Standard_Integer indc = 1;
#endif
Sprintf(name, "bc3d_%d_%d", indc, nbbc);
DrawTrSurf::Set(name, theBezier);
#endif
- gp_Vec FirstVec, SecondVec;
+ gp_Vec FirstVec, SecondVec;
Standard_Integer indp = 2;
while (indp <= aPoles.Upper())
{
- FirstVec = gp_Vec(aPoles(1), aPoles(indp++));
+ FirstVec = gp_Vec(aPoles(1), aPoles(indp++));
Standard_Real aLength = FirstVec.Magnitude();
if (aLength > gp::Resolution())
{
break;
}
}
- gp_Pnt MidPnt = aPoles(indp-1);
- //for (Standard_Integer k = 3; k <= aPoles.Upper(); k++)
+ gp_Pnt MidPnt = aPoles(indp - 1);
+ // for (Standard_Integer k = 3; k <= aPoles.Upper(); k++)
while (indp <= aPoles.Upper())
{
- SecondVec = gp_Vec(MidPnt, aPoles(indp));
+ SecondVec = gp_Vec(MidPnt, aPoles(indp));
Standard_Real aLength = SecondVec.Magnitude();
if (aLength <= gp::Resolution())
{
if (ScalProd < MinScalProd)
{
#ifdef DRAW
- std::cout<<"ScalProd("<<indp-2<<","<<indp-1<<")-("<<indp-1<<","<<indp<<") = "<<ScalProd<<std::endl;
+ std::cout << "ScalProd(" << indp - 2 << "," << indp - 1 << ")-(" << indp - 1 << "," << indp
+ << ") = " << ScalProd << std::endl;
#endif
LoopFound = Standard_True;
break;
}
FirstVec = SecondVec;
- MidPnt = aPoles(indp);
+ MidPnt = aPoles(indp);
indp++;
}
- //Check: may be it is a real loop
+ // Check: may be it is a real loop
if (LoopFound)
{
#ifdef DRAW
DrawTrSurf::Set(name, aPnt);
}
#endif
- for (Standard_Integer FirstInd = theIndfirst;
- FirstInd <= theIndlast - 2; FirstInd++)
+ for (Standard_Integer FirstInd = theIndfirst; FirstInd <= theIndlast - 2; FirstInd++)
{
LineTool::Value(theLine, FirstInd, tabP);
gp_Pnt FirstPnt = tabP(1);
- for (Standard_Integer k = FirstInd+1; k < theIndlast; k++)
+ for (Standard_Integer k = FirstInd + 1; k < theIndlast; k++)
{
LineTool::Value(theLine, k, tabP);
gp_Pnt Pnt1 = tabP(1);
- LineTool::Value(theLine, k+1, tabP);
+ LineTool::Value(theLine, k + 1, tabP);
gp_Pnt Pnt2 = tabP(1);
- if (FirstPnt.SquareDistance(Pnt1) <= SqTol3d ||
- FirstPnt.SquareDistance(Pnt2) <= SqTol3d)
+ if (FirstPnt.SquareDistance(Pnt1) <= SqTol3d || FirstPnt.SquareDistance(Pnt2) <= SqTol3d)
{
LoopFound = Standard_False;
break;
}
if (LoopFound)
{
- //search <indbad>
+ // search <indbad>
Standard_Real MaxSqDist = 0.;
Standard_Real MinSqDist = RealLast();
- for (Standard_Integer k = theIndfirst+1; k <= theIndlast; k++)
+ for (Standard_Integer k = theIndfirst + 1; k <= theIndlast; k++)
{
- LineTool::Value(theLine, k-1, tabP);
+ LineTool::Value(theLine, k - 1, tabP);
gp_Pnt PrevPnt = tabP(1);
LineTool::Value(theLine, k, tabP);
- gp_Pnt CurPnt = tabP(1);
+ gp_Pnt CurPnt = tabP(1);
Standard_Real aSqDist = PrevPnt.SquareDistance(CurPnt);
if (aSqDist > MaxSqDist)
{
- MaxSqDist = aSqDist;
+ MaxSqDist = aSqDist;
indbads[1] = k;
}
- if (aSqDist > gp::Resolution() &&
- aSqDist < MinSqDist)
+ if (aSqDist > gp::Resolution() && aSqDist < MinSqDist)
MinSqDist = aSqDist;
}
Standard_Real Relation = MaxSqDist / MinSqDist;
for (Standard_Integer indcur = 2; indcur <= NbCur; indcur++)
{
MaxSqDist = 0.;
- for (Standard_Integer k = theIndfirst+1; k <= theIndlast; k++)
+ for (Standard_Integer k = theIndfirst + 1; k <= theIndlast; k++)
{
- LineTool::Value(theLine, k-1, tabP2d);
- gp_Pnt2d PrevPnt = tabP2d(indcur-1);
+ LineTool::Value(theLine, k - 1, tabP2d);
+ gp_Pnt2d PrevPnt = tabP2d(indcur - 1);
LineTool::Value(theLine, k, tabP2d);
- gp_Pnt2d CurPnt = tabP2d(indcur-1);
+ gp_Pnt2d CurPnt = tabP2d(indcur - 1);
Standard_Real aSqDist = PrevPnt.SquareDistance(CurPnt);
if (aSqDist > MaxSqDist)
{
- MaxSqDist = aSqDist;
+ MaxSqDist = aSqDist;
indbads[indcur] = k;
}
}
}
}
- } //if (myNbP3d == 1)
- else //2d case
+ } // if (myNbP3d == 1)
+ else // 2d case
{
TColgp_Array1OfPnt2d aPoles2d(1, theMultiCurve.NbPoles());
theMultiCurve.Curve(1, aPoles2d);
Sprintf(name, "bc2d_%d_%d", indc, nbbc);
DrawTrSurf::Set(name, theBezier2d);
#endif
- const Standard_Real aSqNormToler = Epsilon(1.0)*Epsilon(1.0);
- gp_Vec2d FirstVec(aPoles2d(1), aPoles2d(2)), SecondVec;
- Standard_Real aVecSqNorm = FirstVec.SquareMagnitude();
+ const Standard_Real aSqNormToler = Epsilon(1.0) * Epsilon(1.0);
+ gp_Vec2d FirstVec(aPoles2d(1), aPoles2d(2)), SecondVec;
+ Standard_Real aVecSqNorm = FirstVec.SquareMagnitude();
if (aVecSqNorm < aSqNormToler)
{
theIndbad = theIndfirst + 1;
if (ScalProd < MinScalProd)
{
#ifdef DRAW
- std::cout<<"ScalProd("<<k-2<<","<<k-1<<")-("<<k-1<<","<<k<<") = "<<ScalProd<<std::endl;
+ std::cout << "ScalProd(" << k - 2 << "," << k - 1 << ")-(" << k - 1 << "," << k
+ << ") = " << ScalProd << std::endl;
#endif
LoopFound = Standard_True;
break;
}
FirstVec = SecondVec;
- MidPnt = aPoles2d(k);
+ MidPnt = aPoles2d(k);
}
- //Check: may be it is a real loop
+ // Check: may be it is a real loop
if (LoopFound)
{
#ifdef DRAW
DrawTrSurf::Set(name, aPnt2d);
}
#endif
- for (Standard_Integer FirstInd = theIndfirst;
- FirstInd <= theIndlast - 2; FirstInd++)
+ for (Standard_Integer FirstInd = theIndfirst; FirstInd <= theIndlast - 2; FirstInd++)
{
LineTool::Value(theLine, FirstInd, tabP2d);
gp_Pnt2d FirstPnt = tabP2d(1);
- for (Standard_Integer k = FirstInd+1; k < theIndlast; k++)
+ for (Standard_Integer k = FirstInd + 1; k < theIndlast; k++)
{
LineTool::Value(theLine, k, tabP2d);
gp_Pnt2d Pnt1 = tabP2d(1);
- LineTool::Value(theLine, k+1, tabP2d);
+ LineTool::Value(theLine, k + 1, tabP2d);
gp_Pnt2d Pnt2 = tabP2d(1);
- if (FirstPnt.SquareDistance(Pnt1) <= SqTol3d ||
- FirstPnt.SquareDistance(Pnt2) <= SqTol3d)
+ if (FirstPnt.SquareDistance(Pnt1) <= SqTol3d || FirstPnt.SquareDistance(Pnt2) <= SqTol3d)
{
LoopFound = Standard_False;
break;
}
if (LoopFound)
{
- //search <indbad>
+ // search <indbad>
for (Standard_Integer indcur = 1; indcur <= NbCur; indcur++)
{
Standard_Real MaxSqDist = 0.;
Standard_Real MinSqDist = RealLast();
- for (Standard_Integer k = theIndfirst+1; k <= theIndlast; k++)
+ for (Standard_Integer k = theIndfirst + 1; k <= theIndlast; k++)
{
- LineTool::Value(theLine, k-1, tabP2d);
+ LineTool::Value(theLine, k - 1, tabP2d);
gp_Pnt2d PrevPnt = tabP2d(indcur);
LineTool::Value(theLine, k, tabP2d);
- gp_Pnt2d CurPnt = tabP2d(indcur);
+ gp_Pnt2d CurPnt = tabP2d(indcur);
Standard_Real aSqDist = PrevPnt.SquareDistance(CurPnt);
if (aSqDist > MaxSqDist)
{
- MaxSqDist = aSqDist;
+ MaxSqDist = aSqDist;
indbads[indcur] = k;
}
- if (aSqDist > gp::Resolution() &&
- aSqDist < MinSqDist)
+ if (aSqDist > gp::Resolution() && aSqDist < MinSqDist)
MinSqDist = aSqDist;
}
Standard_Real Relation = MaxSqDist / MinSqDist;
}
}
- //Define <indbad>
+ // Define <indbad>
for (Standard_Integer i = 1; i <= 3; i++)
if (indbads[i] != 0)
{
if (!LoopFound)
theIndbad = 0;
-
+
return (!LoopFound);
}
void Approx_ComputeLine::FirstTangencyVector(const MultiLine& Line,
- const Standard_Integer index,
- math_Vector& V) const
+ const Standard_Integer index,
+ math_Vector& V) const
{
Standard_Integer i, j, nbP2d, nbP3d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- Standard_Boolean Ok=Standard_False;
- TColgp_Array1OfVec TabV(1, mynbP3d);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ Standard_Boolean Ok = Standard_False;
+ TColgp_Array1OfVec TabV(1, mynbP3d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
-
+
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, index, TabV, TabV2d);
else if (nbP2d != 0)
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, index, TabV);
- if (Ok) {
- if (nbP3d != 0) {
+ if (Ok)
+ {
+ if (nbP3d != 0)
+ {
j = 1;
- for (i = TabV.Lower(); i <= TabV.Upper(); i++) {
- V(j) = TabV(i).X();
- V(j+1) = TabV(i).Y();
- V(j+2) = TabV(i).Z();
- j += 3;
+ for (i = TabV.Lower(); i <= TabV.Upper(); i++)
+ {
+ V(j) = TabV(i).X();
+ V(j + 1) = TabV(i).Y();
+ V(j + 2) = TabV(i).Z();
+ j += 3;
}
}
- if (nbP2d != 0) {
- j = nbP3d*3+1;
- for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++) {
- V(j) = TabV2d(i).X();
- V(j+1) = TabV2d(i).Y();
- j += 2;
+ if (nbP2d != 0)
+ {
+ j = nbP3d * 3 + 1;
+ for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++)
+ {
+ V(j) = TabV2d(i).X();
+ V(j + 1) = TabV2d(i).Y();
+ j += 2;
}
}
}
- else {
+ else
+ {
// recherche d un vecteur tangent par construction d une parabole:
AppParCurves_Constraint firstC, lastC;
- firstC = lastC = AppParCurves_PassPoint;
+ firstC = lastC = AppParCurves_PassPoint;
Standard_Integer nbpoles = 3;
- math_Vector mypar(index, index+2);
- Parameters(Line, index, index+2, mypar);
- Approx_ParLeastSquareOfMyGradient
- LSQ(Line, index, index+2, firstC, lastC, mypar, nbpoles);
- AppParCurves_MultiCurve C = LSQ.BezierValue();
-
- gp_Pnt myP;
- gp_Vec myV;
+ math_Vector mypar(index, index + 2);
+ Parameters(Line, index, index + 2, mypar);
+ Approx_ParLeastSquareOfMyGradient LSQ(Line, index, index + 2, firstC, lastC, mypar, nbpoles);
+ AppParCurves_MultiCurve C = LSQ.BezierValue();
+
+ gp_Pnt myP;
+ gp_Vec myV;
gp_Pnt2d myP2d;
gp_Vec2d myV2d;
j = 1;
- for (i = 1; i <= nbP3d; i++) {
+ for (i = 1; i <= nbP3d; i++)
+ {
C.D1(i, 0.0, myP, myV);
- V(j) = myV.X();
- V(j+1) = myV.Y();
- V(j+2) = myV.Z();
+ V(j) = myV.X();
+ V(j + 1) = myV.Y();
+ V(j + 2) = myV.Z();
j += 3;
}
- j = nbP3d*3+1;
- for (i = nbP3d+1; i <= nbP3d+nbP2d; i++) {
+ j = nbP3d * 3 + 1;
+ for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++)
+ {
C.D1(i, 0.0, myP2d, myV2d);
- V(j) = myV2d.X();
- V(j+1) = myV2d.Y();
+ V(j) = myV2d.X();
+ V(j + 1) = myV2d.Y();
j += 2;
}
}
}
-
void Approx_ComputeLine::LastTangencyVector(const MultiLine& Line,
- const Standard_Integer index,
- math_Vector& V) const
+ const Standard_Integer index,
+ math_Vector& V) const
{
Standard_Integer i, j, nbP2d, nbP3d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- Standard_Boolean Ok=Standard_False;
- TColgp_Array1OfVec TabV(1, mynbP3d);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ Standard_Boolean Ok = Standard_False;
+ TColgp_Array1OfVec TabV(1, mynbP3d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
-
if (nbP3d != 0 && nbP2d != 0)
Ok = LineTool::Tangency(Line, index, TabV, TabV2d);
else if (nbP2d != 0)
else if (nbP3d != 0)
Ok = LineTool::Tangency(Line, index, TabV);
- if (Ok) {
- if (nbP3d != 0) {
+ if (Ok)
+ {
+ if (nbP3d != 0)
+ {
j = 1;
- for (i = TabV.Lower(); i <= TabV.Upper(); i++) {
- V(j) = TabV(i).X();
- V(j+1) = TabV(i).Y();
- V(j+2) = TabV(i).Z();
- j += 3;
+ for (i = TabV.Lower(); i <= TabV.Upper(); i++)
+ {
+ V(j) = TabV(i).X();
+ V(j + 1) = TabV(i).Y();
+ V(j + 2) = TabV(i).Z();
+ j += 3;
}
}
- if (nbP2d != 0) {
- j = nbP3d*3+1;
- for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++) {
- V(j) = TabV2d(i).X();
- V(j+1) = TabV2d(i).Y();
- j += 2;
+ if (nbP2d != 0)
+ {
+ j = nbP3d * 3 + 1;
+ for (i = TabV2d.Lower(); i <= TabV2d.Upper(); i++)
+ {
+ V(j) = TabV2d(i).X();
+ V(j + 1) = TabV2d(i).Y();
+ j += 2;
}
}
}
- else {
+ else
+ {
// recherche d un vecteur tangent par construction d une parabole:
AppParCurves_Constraint firstC, lastC;
- firstC = lastC = AppParCurves_PassPoint;
+ firstC = lastC = AppParCurves_PassPoint;
Standard_Integer nbpoles = 3;
- math_Vector mypar(index-2, index);
- Parameters(Line, index-2, index, mypar);
- Approx_ParLeastSquareOfMyGradient
- LSQ(Line, index-2, index, firstC, lastC, mypar, nbpoles);
- AppParCurves_MultiCurve C = LSQ.BezierValue();
-
- gp_Pnt myP;
- gp_Vec myV;
+ math_Vector mypar(index - 2, index);
+ Parameters(Line, index - 2, index, mypar);
+ Approx_ParLeastSquareOfMyGradient LSQ(Line, index - 2, index, firstC, lastC, mypar, nbpoles);
+ AppParCurves_MultiCurve C = LSQ.BezierValue();
+
+ gp_Pnt myP;
+ gp_Vec myV;
gp_Pnt2d myP2d;
gp_Vec2d myV2d;
j = 1;
- for (i = 1; i <= nbP3d; i++) {
+ for (i = 1; i <= nbP3d; i++)
+ {
C.D1(i, 1.0, myP, myV);
- V(j) = myV.X();
- V(j+1) = myV.Y();
- V(j+2) = myV.Z();
+ V(j) = myV.X();
+ V(j + 1) = myV.Y();
+ V(j + 2) = myV.Z();
j += 3;
}
- j = nbP3d*3+1;
- for (i = nbP3d+1; i <= nbP3d+nbP2d; i++) {
+ j = nbP3d * 3 + 1;
+ for (i = nbP3d + 1; i <= nbP3d + nbP2d; i++)
+ {
C.D1(i, 1.0, myP2d, myV2d);
- V(j) = myV2d.X();
- V(j+1) = myV2d.Y();
+ V(j) = myV2d.X();
+ V(j + 1) = myV2d.Y();
j += 2;
}
}
-
}
-
-
-Standard_Real Approx_ComputeLine::
- SearchFirstLambda(const MultiLine& Line,
- const math_Vector& TheParam,
- const math_Vector& V,
- const Standard_Integer index) const
+Standard_Real Approx_ComputeLine::SearchFirstLambda(const MultiLine& Line,
+ const math_Vector& TheParam,
+ const math_Vector& V,
+ const Standard_Integer index) const
{
// dq/dw = lambda* V = (p2-p1)/(u2-u1)
-
+
Standard_Integer nbP2d, nbP3d;
- gp_Pnt P1, P2;
- gp_Pnt2d P12d, P22d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- TColgp_Array1OfPnt tabP1(1, mynbP3d), tabP2(1, mynbP3d);
+ gp_Pnt P1, P2;
+ gp_Pnt2d P12d, P22d;
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ TColgp_Array1OfPnt tabP1(1, mynbP3d), tabP2(1, mynbP3d);
TColgp_Array1OfPnt2d tabP12d(1, mynbP2d), tabP22d(1, mynbP2d);
-
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index, tabP1, tabP12d);
- else if (nbP2d != 0) LineTool::Value(Line, index, tabP12d);
- else if (nbP3d != 0) LineTool::Value(Line, index, tabP1);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index, tabP1, tabP12d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index, tabP12d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index, tabP1);
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index+1, tabP2, tabP22d);
- else if (nbP2d != 0) LineTool::Value(Line, index+1, tabP22d);
- else if (nbP3d != 0) LineTool::Value(Line, index+1, tabP2);
-
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index + 1, tabP2, tabP22d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index + 1, tabP22d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index + 1, tabP2);
- Standard_Real U1 = TheParam(index), U2 = TheParam(index+1);
- Standard_Real lambda, S;
+ Standard_Real U1 = TheParam(index), U2 = TheParam(index + 1);
+ Standard_Real lambda, S;
Standard_Integer low = V.Lower();
-
- if (nbP3d != 0) {
+
+ if (nbP3d != 0)
+ {
P1 = tabP1(1);
P2 = tabP2(1);
gp_Vec P1P2(P1, P2), myV;
- myV.SetCoord(V(low), V(low+1), V(low+2));
- lambda = (P1P2.Magnitude())/(myV.Magnitude()*(U2-U1));
- S = (P1P2.Dot(myV)> 0.0) ? 1.0 : -1.0;
+ myV.SetCoord(V(low), V(low + 1), V(low + 2));
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- else {
+ else
+ {
P12d = tabP12d(1);
P22d = tabP22d(1);
gp_Vec2d P1P2(P12d, P22d), myV;
- myV.SetCoord(V(low), V(low+1));
- lambda = (P1P2.Magnitude())/(myV.Magnitude()*(U2-U1));
- S = (P1P2.Dot(myV)> 0.0) ? 1.0 : -1.0;
+ myV.SetCoord(V(low), V(low + 1));
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- return (S*lambda);
-
+ return (S * lambda);
}
-
-Standard_Real Approx_ComputeLine::
- SearchLastLambda(const MultiLine& Line,
- const math_Vector& TheParam,
- const math_Vector& V,
- const Standard_Integer index) const
+Standard_Real Approx_ComputeLine::SearchLastLambda(const MultiLine& Line,
+ const math_Vector& TheParam,
+ const math_Vector& V,
+ const Standard_Integer index) const
{
// dq/dw = lambda* V = (p2-p1)/(u2-u1)
-
+
Standard_Integer nbP2d, nbP3d;
- gp_Pnt P1, P2;
- gp_Pnt2d P12d, P22d;
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
- Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
- if (nbP3d == 0) mynbP3d = 1;
- if (nbP2d == 0) mynbP2d = 1;
- TColgp_Array1OfPnt tabP(1, mynbP3d), tabP2(1, mynbP3d);
+ gp_Pnt P1, P2;
+ gp_Pnt2d P12d, P22d;
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
+ Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
+ TColgp_Array1OfPnt tabP(1, mynbP3d), tabP2(1, mynbP3d);
TColgp_Array1OfPnt2d tabP2d(1, mynbP2d), tabP22d(1, mynbP2d);
-
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index-1, tabP, tabP2d);
- else if (nbP2d != 0) LineTool::Value(Line, index-1, tabP2d);
- else if (nbP3d != 0) LineTool::Value(Line, index-1, tabP);
- if (nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, index, tabP2, tabP22d);
- else if (nbP2d != 0) LineTool::Value(Line, index, tabP22d);
- else if (nbP3d != 0) LineTool::Value(Line, index, tabP2);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index - 1, tabP, tabP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index - 1, tabP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index - 1, tabP);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, index, tabP2, tabP22d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, index, tabP22d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, index, tabP2);
- Standard_Real U1 = TheParam(index-1), U2 = TheParam(index);
- Standard_Real lambda, S;
+ Standard_Real U1 = TheParam(index - 1), U2 = TheParam(index);
+ Standard_Real lambda, S;
Standard_Integer low = V.Lower();
- if (nbP3d != 0) {
+ if (nbP3d != 0)
+ {
P1 = tabP(1);
P2 = tabP2(1);
gp_Vec P1P2(P1, P2), myV;
- myV.SetCoord(V(low), V(low+1), V(low+2));
- lambda = (P1P2.Magnitude())/(myV.Magnitude()*(U2-U1));
- S = (P1P2.Dot(myV)> 0.0) ? 1.0 : -1.0;
+ myV.SetCoord(V(low), V(low + 1), V(low + 2));
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- else {
+ else
+ {
P12d = tabP2d(1);
P22d = tabP22d(1);
gp_Vec2d P1P2(P12d, P22d), myV;
- myV.SetCoord(V(low), V(low+1));
- lambda = (P1P2.Magnitude())/(myV.Magnitude()*(U2-U1));
- S = (P1P2.Dot(myV)> 0.0) ? 1.0 : -1.0;
+ myV.SetCoord(V(low), V(low + 1));
+ lambda = (P1P2.Magnitude()) / (myV.Magnitude() * (U2 - U1));
+ S = (P1P2.Dot(myV) > 0.0) ? 1.0 : -1.0;
}
- return (S*lambda);
+ return (S * lambda);
}
-
-
-Approx_ComputeLine::Approx_ComputeLine
- (const MultiLine& Line,
- const math_Vector& Parameters,
- const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Standard_Boolean Squares)
-: myMultiLineNb (0),
- myIsClear (Standard_False)
+Approx_ComputeLine::Approx_ComputeLine(const MultiLine& Line,
+ const math_Vector& Parameters,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Standard_Boolean Squares)
+ : myMultiLineNb(0),
+ myIsClear(Standard_False)
{
- myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(),
- Parameters.Upper());
- for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++) {
+ myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(), Parameters.Upper());
+ for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++)
+ {
myfirstParam->SetValue(i, Parameters(i));
}
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- Par = Approx_IsoParametric;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- alldone = Standard_False;
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
+ Par = Approx_IsoParametric;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ alldone = Standard_False;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
Perform(Line);
}
-
-Approx_ComputeLine::Approx_ComputeLine
- (const math_Vector& Parameters,
- const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Standard_Boolean Squares)
-: myMultiLineNb (0),
- myIsClear (Standard_False)
+Approx_ComputeLine::Approx_ComputeLine(const math_Vector& Parameters,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Standard_Boolean Squares)
+ : myMultiLineNb(0),
+ myIsClear(Standard_False)
{
- myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(),
- Parameters.Upper());
- for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++) {
+ myfirstParam = new TColStd_HArray1OfReal(Parameters.Lower(), Parameters.Upper());
+ for (Standard_Integer i = Parameters.Lower(); i <= Parameters.Upper(); i++)
+ {
myfirstParam->SetValue(i, Parameters(i));
}
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- Par = Approx_IsoParametric;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- alldone = Standard_False;
+ Par = Approx_IsoParametric;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ alldone = Standard_False;
}
-Approx_ComputeLine::Approx_ComputeLine
- (const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Approx_ParametrizationType parametrization,
- const Standard_Boolean Squares)
-: myMultiLineNb (0),
- myIsClear (Standard_False)
+Approx_ComputeLine::Approx_ComputeLine(const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Approx_ParametrizationType parametrization,
+ const Standard_Boolean Squares)
+ : myMultiLineNb(0),
+ myIsClear(Standard_False)
{
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- Par = parametrization;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
- alldone = Standard_False;
+ Par = parametrization;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
+ alldone = Standard_False;
}
-
-Approx_ComputeLine::Approx_ComputeLine
- (const MultiLine& Line,
- const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Approx_ParametrizationType parametrization,
- const Standard_Boolean Squares)
-: myMultiLineNb (0),
- myIsClear (Standard_False)
+Approx_ComputeLine::Approx_ComputeLine(const MultiLine& Line,
+ const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Approx_ParametrizationType parametrization,
+ const Standard_Boolean Squares)
+ : myMultiLineNb(0),
+ myIsClear(Standard_False)
{
myConstraints = new AppParCurves_HArray1OfConstraintCouple(1, 2);
- alldone = Standard_False;
- mydegremin = degreemin;
- mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
- Par = parametrization;
- myfirstC = AppParCurves_TangencyPoint;
- mylastC = AppParCurves_TangencyPoint;
+ alldone = Standard_False;
+ mydegremin = degreemin;
+ mydegremax = degreemax;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
+ Par = parametrization;
+ myfirstC = AppParCurves_TangencyPoint;
+ mylastC = AppParCurves_TangencyPoint;
Perform(Line);
}
-
-
void Approx_ComputeLine::Perform(const MultiLine& Line)
{
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(Line);
+ if (mydebug)
+ DUMP(Line);
#endif
if (!myIsClear)
{
Tolers2d.Clear();
myMultiLineNb = 0;
}
- else myIsClear = Standard_False;
+ else
+ myIsClear = Standard_False;
Standard_Integer i, nbp, Thefirstpt, Thelastpt, oldlastpt;
- Standard_Boolean Finish = Standard_False,
- begin = Standard_True, Ok = Standard_False,
- GoUp = Standard_False, Interpol;
+ Standard_Boolean Finish = Standard_False, begin = Standard_True, Ok = Standard_False,
+ GoUp = Standard_False, Interpol;
Standard_Real thetol3d, thetol2d;
Approx_Status MyStatus;
-// gp_Vec V13d, V23d;
-// gp_Vec2d V2d;
- Thefirstpt = LineTool::FirstPoint(Line);
- Thelastpt = LineTool::LastPoint(Line);
- Standard_Integer myfirstpt = Thefirstpt;
- Standard_Integer mylastpt = Thelastpt;
+ // gp_Vec V13d, V23d;
+ // gp_Vec2d V2d;
+ Thefirstpt = LineTool::FirstPoint(Line);
+ Thelastpt = LineTool::LastPoint(Line);
+ Standard_Integer myfirstpt = Thefirstpt;
+ Standard_Integer mylastpt = Thelastpt;
AppParCurves_ConstraintCouple myCouple1(myfirstpt, myfirstC);
AppParCurves_ConstraintCouple myCouple2(mylastpt, mylastC);
math_Vector TheParam(Thefirstpt, Thelastpt);
-
- if (!mycut) {
- if(myfirstParam.IsNull()) {
+ if (!mycut)
+ {
+ if (myfirstParam.IsNull())
+ {
Parameters(Line, Thefirstpt, Thelastpt, TheParam);
}
- else {
- for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++) {
- TheParam(i+Thefirstpt-1) = myfirstParam->Value(i);
+ else
+ {
+ for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++)
+ {
+ TheParam(i + Thefirstpt - 1) = myfirstParam->Value(i);
}
}
TheMultiCurve = AppParCurves_MultiCurve();
- MultiLine anOtherLine0;
+ MultiLine anOtherLine0;
Standard_Boolean isOtherLine0Made = Standard_False;
- Standard_Integer indbad = 0;
+ Standard_Integer indbad = 0;
alldone = Compute(Line, myfirstpt, mylastpt, TheParam, thetol3d, thetol2d, indbad);
if (indbad != 0)
{
- isOtherLine0Made = LineTool::MakeMLOneMorePoint(Line, myfirstpt, mylastpt, indbad, anOtherLine0);
+ isOtherLine0Made =
+ LineTool::MakeMLOneMorePoint(Line, myfirstpt, mylastpt, indbad, anOtherLine0);
}
if (isOtherLine0Made)
{
Perform(anOtherLine0);
alldone = Standard_True;
}
- if(!alldone && TheMultiCurve.NbCurves() > 0) {
+ if (!alldone && TheMultiCurve.NbCurves() > 0)
+ {
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(TheMultiCurve);
+ if (mydebug)
+ DUMP(TheMultiCurve);
#endif
myMultiCurves.Append(TheMultiCurve);
Tolers3d.Append(currenttol3d);
Tolers2d.Append(currenttol2d);
- Standard_Integer mylen = mylastpt-myfirstpt+1;
- Standard_Integer myParLen = myParameters->Length();
- Standard_Integer aLen = (myParLen > mylen)? myParLen : mylen;
+ Standard_Integer mylen = mylastpt - myfirstpt + 1;
+ Standard_Integer myParLen = myParameters->Length();
+ Standard_Integer aLen = (myParLen > mylen) ? myParLen : mylen;
Handle(TColStd_HArray1OfReal) ThePar =
- new TColStd_HArray1OfReal(myfirstpt, myfirstpt+aLen-1);
+ new TColStd_HArray1OfReal(myfirstpt, myfirstpt + aLen - 1);
for (i = 0; i < aLen; i++)
- ThePar->SetValue(myfirstpt+i, myParameters->Value(myParameters->Lower()+i));
+ ThePar->SetValue(myfirstpt + i, myParameters->Value(myParameters->Lower() + i));
myPar.Append(ThePar);
}
}
- else {
- while (!Finish) {
+ else
+ {
+ while (!Finish)
+ {
oldlastpt = mylastpt;
// Gestion du decoupage de la multiline pour approximer:
- if(!begin) {
- if (!GoUp) {
- if (Ok) {
- // Calcul de la partie a approximer.
- myfirstpt = mylastpt;
- mylastpt = Thelastpt;
- if (myfirstpt == Thelastpt) {
- Finish = Standard_True;
- alldone = Standard_True;
- return;
- }
- }
- else {
- nbp = mylastpt - myfirstpt + 1;
- MyStatus = LineTool::WhatStatus(Line, myfirstpt, mylastpt);
- if (MyStatus == Approx_NoPointsAdded && nbp <= mydegremax+1) {
- Interpol = ComputeCurve(Line, myfirstpt, mylastpt);
- if (Interpol) {
- if (mylastpt == Thelastpt) {
- Finish = Standard_True;
- alldone = Standard_True;
- return;
- }
- }
- }
- mylastpt = Standard_Integer((myfirstpt + mylastpt)/2);
- }
- }
- GoUp = Standard_False;
+ if (!begin)
+ {
+ if (!GoUp)
+ {
+ if (Ok)
+ {
+ // Calcul de la partie a approximer.
+ myfirstpt = mylastpt;
+ mylastpt = Thelastpt;
+ if (myfirstpt == Thelastpt)
+ {
+ Finish = Standard_True;
+ alldone = Standard_True;
+ return;
+ }
+ }
+ else
+ {
+ nbp = mylastpt - myfirstpt + 1;
+ MyStatus = LineTool::WhatStatus(Line, myfirstpt, mylastpt);
+ if (MyStatus == Approx_NoPointsAdded && nbp <= mydegremax + 1)
+ {
+ Interpol = ComputeCurve(Line, myfirstpt, mylastpt);
+ if (Interpol)
+ {
+ if (mylastpt == Thelastpt)
+ {
+ Finish = Standard_True;
+ alldone = Standard_True;
+ return;
+ }
+ }
+ }
+ mylastpt = Standard_Integer((myfirstpt + mylastpt) / 2);
+ }
+ }
+ GoUp = Standard_False;
}
-
+
// Verification du nombre de points restants par rapport au degre
// demande.
// ==============================================================
- nbp = mylastpt - myfirstpt + 1;
+ nbp = mylastpt - myfirstpt + 1;
MyStatus = LineTool::WhatStatus(Line, myfirstpt, mylastpt);
- if (nbp <= mydegremax+5 ) {
- // Rajout necessaire de points si possible.
- // ========================================
- GoUp = Standard_False;
- Ok = Standard_True;
- if (MyStatus == Approx_PointsAdded) {
- // Appel recursif du decoupage:
- GoUp = Standard_True;
-
- MultiLine anOtherLine1 = LineTool::MakeMLBetween(Line, myfirstpt, mylastpt, nbp-1);
-
- Standard_Integer nbpdsotherligne = LineTool::FirstPoint (anOtherLine1) - LineTool::LastPoint (anOtherLine1);
-
- //-- Si MakeML a echoue on retourne une ligne vide
- if ((nbpdsotherligne == 0) || myMultiLineNb >= 3)
- {
- //-- cout<<" ** ApproxComputeLine MakeML Echec ** LBR lbr "<<endl;
- if (myfirstpt == mylastpt) break; // Pour etre sur de ne pas
- // planter la station !!
- myCouple1.SetIndex(myfirstpt);
- myCouple2.SetIndex(mylastpt);
- myConstraints->SetValue(1, myCouple1);
- myConstraints->SetValue(2, myCouple2);
-
- math_Vector Param(myfirstpt, mylastpt);
- Approx_ParametrizationType SavePar = Par;
- Par = Approx_IsoParametric;
- Parameters(Line, myfirstpt, mylastpt, Param);
- TheMultiCurve = AppParCurves_MultiCurve();
- MultiLine anOtherLine2;
+ if (nbp <= mydegremax + 5)
+ {
+ // Rajout necessaire de points si possible.
+ // ========================================
+ GoUp = Standard_False;
+ Ok = Standard_True;
+ if (MyStatus == Approx_PointsAdded)
+ {
+ // Appel recursif du decoupage:
+ GoUp = Standard_True;
+
+ MultiLine anOtherLine1 = LineTool::MakeMLBetween(Line, myfirstpt, mylastpt, nbp - 1);
+
+ Standard_Integer nbpdsotherligne =
+ LineTool::FirstPoint(anOtherLine1) - LineTool::LastPoint(anOtherLine1);
+
+ //-- Si MakeML a echoue on retourne une ligne vide
+ if ((nbpdsotherligne == 0) || myMultiLineNb >= 3)
+ {
+ //-- cout<<" ** ApproxComputeLine MakeML Echec ** LBR lbr "<<endl;
+ if (myfirstpt == mylastpt)
+ break; // Pour etre sur de ne pas
+ // planter la station !!
+ myCouple1.SetIndex(myfirstpt);
+ myCouple2.SetIndex(mylastpt);
+ myConstraints->SetValue(1, myCouple1);
+ myConstraints->SetValue(2, myCouple2);
+
+ math_Vector Param(myfirstpt, mylastpt);
+ Approx_ParametrizationType SavePar = Par;
+ Par = Approx_IsoParametric;
+ Parameters(Line, myfirstpt, mylastpt, Param);
+ TheMultiCurve = AppParCurves_MultiCurve();
+ MultiLine anOtherLine2;
Standard_Boolean isOtherLine2Made = Standard_False;
- Standard_Integer indbad = 0;
- Ok = Compute(Line, myfirstpt, mylastpt, Param, thetol3d, thetol2d, indbad);
+ Standard_Integer indbad = 0;
+ Ok = Compute(Line, myfirstpt, mylastpt, Param, thetol3d, thetol2d, indbad);
if (indbad != 0)
{
- isOtherLine2Made = LineTool::MakeMLOneMorePoint(Line, myfirstpt, mylastpt, indbad, anOtherLine2);
+ isOtherLine2Made =
+ LineTool::MakeMLOneMorePoint(Line, myfirstpt, mylastpt, indbad, anOtherLine2);
}
if (isOtherLine2Made)
{
Ok = Standard_True;
}
- if (!Ok) {
- Standard_Real tt3d = currenttol3d, tt2d = currenttol2d;
- Handle(TColStd_HArray1OfReal) saveParameters = myParameters;
- AppParCurves_MultiCurve saveMultiCurve = TheMultiCurve;
+ if (!Ok)
+ {
+ Standard_Real tt3d = currenttol3d, tt2d = currenttol2d;
+ Handle(TColStd_HArray1OfReal) saveParameters = myParameters;
+ AppParCurves_MultiCurve saveMultiCurve = TheMultiCurve;
- if(SavePar != Approx_IsoParametric)
- Par = SavePar;
- else
- Par = Approx_ChordLength;
+ if (SavePar != Approx_IsoParametric)
+ Par = SavePar;
+ else
+ Par = Approx_ChordLength;
- Parameters(Line, myfirstpt, mylastpt, Param);
- isOtherLine2Made = Standard_False;
- indbad = 0;
- Ok = Compute(Line, myfirstpt, mylastpt, Param, thetol3d, thetol2d, indbad);
+ Parameters(Line, myfirstpt, mylastpt, Param);
+ isOtherLine2Made = Standard_False;
+ indbad = 0;
+ Ok = Compute(Line, myfirstpt, mylastpt, Param, thetol3d, thetol2d, indbad);
if (indbad != 0)
{
- isOtherLine2Made = LineTool::MakeMLOneMorePoint (Line, myfirstpt, mylastpt, indbad, anOtherLine2);
+ isOtherLine2Made =
+ LineTool::MakeMLOneMorePoint(Line, myfirstpt, mylastpt, indbad, anOtherLine2);
}
if (isOtherLine2Made)
{
myIsClear = Standard_True;
//++myMultiLineNb;
- Perform (anOtherLine2);
+ Perform(anOtherLine2);
Ok = Standard_True;
}
-
- if (!Ok && tt3d <= currenttol3d && tt2d <= currenttol2d) {
- currenttol3d = tt3d; currenttol2d = tt2d;
- myParameters = saveParameters;
- TheMultiCurve = saveMultiCurve;
- }
- }
- Par = SavePar;
+
+ if (!Ok && tt3d <= currenttol3d && tt2d <= currenttol2d)
+ {
+ currenttol3d = tt3d;
+ currenttol2d = tt2d;
+ myParameters = saveParameters;
+ TheMultiCurve = saveMultiCurve;
+ }
+ }
+ Par = SavePar;
if (myfirstpt == Thelastpt)
{
- Finish = Standard_True;
+ Finish = Standard_True;
alldone = Standard_True;
return;
}
- oldlastpt = mylastpt;
- if (!Ok) {
- tolreached = Standard_False;
- if (TheMultiCurve.NbCurves() == 0) {
- myMultiCurves.Clear();
- return;
- }
+ oldlastpt = mylastpt;
+ if (!Ok)
+ {
+ tolreached = Standard_False;
+ if (TheMultiCurve.NbCurves() == 0)
+ {
+ myMultiCurves.Clear();
+ return;
+ }
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(TheMultiCurve);
+ if (mydebug)
+ DUMP(TheMultiCurve);
#endif
- MultiLine anOtherLine3;
+ MultiLine anOtherLine3;
Standard_Boolean isOtherLine3Made = Standard_False;
- Standard_Integer indbad2 = 0;
- if (!CheckMultiCurve(TheMultiCurve, Line,
- myfirstpt, mylastpt,
- indbad2))
+ Standard_Integer indbad2 = 0;
+ if (!CheckMultiCurve(TheMultiCurve, Line, myfirstpt, mylastpt, indbad2))
{
- isOtherLine3Made = LineTool::MakeMLOneMorePoint (Line, myfirstpt, mylastpt, indbad2, anOtherLine3);
+ isOtherLine3Made =
+ LineTool::MakeMLOneMorePoint(Line, myfirstpt, mylastpt, indbad2, anOtherLine3);
}
if (isOtherLine3Made)
{
//++myMultiLineNb;
Perform(anOtherLine3);
myfirstpt = mylastpt;
- mylastpt = Thelastpt;
+ mylastpt = Thelastpt;
}
else
{
myMultiCurves.Append(TheMultiCurve);
Tolers3d.Append(currenttol3d);
Tolers2d.Append(currenttol2d);
- Standard_Integer mylen = oldlastpt-myfirstpt+1;
- Standard_Integer myParLen = myParameters->Length();
- Standard_Integer aLen = (myParLen > mylen)? myParLen : mylen;
+ Standard_Integer mylen = oldlastpt - myfirstpt + 1;
+ Standard_Integer myParLen = myParameters->Length();
+ Standard_Integer aLen = (myParLen > mylen) ? myParLen : mylen;
Handle(TColStd_HArray1OfReal) ThePar =
- new TColStd_HArray1OfReal(myfirstpt, myfirstpt+aLen-1);
+ new TColStd_HArray1OfReal(myfirstpt, myfirstpt + aLen - 1);
for (i = 0; i < aLen; i++)
- ThePar->SetValue(myfirstpt+i, myParameters->Value(myParameters->Lower()+i));
+ ThePar->SetValue(myfirstpt + i, myParameters->Value(myParameters->Lower() + i));
myPar.Append(ThePar);
}
- }
- myfirstpt = oldlastpt;
- mylastpt = Thelastpt;
-
- }
- else
- {
- myIsClear = Standard_True;
- ++myMultiLineNb;
- Perform(anOtherLine1);
- myfirstpt = mylastpt;
- mylastpt = Thelastpt;
- }
- }
-
- if (MyStatus == Approx_NoPointsAdded && !begin) {
- // On rend la meilleure approximation obtenue precedemment.
- // ========================================================
- GoUp = Standard_True;
- tolreached = Standard_False;
- if (TheMultiCurve.NbCurves() == 0) {
- myMultiCurves.Clear();
- return;
- }
+ }
+ myfirstpt = oldlastpt;
+ mylastpt = Thelastpt;
+ }
+ else
+ {
+ myIsClear = Standard_True;
+ ++myMultiLineNb;
+ Perform(anOtherLine1);
+ myfirstpt = mylastpt;
+ mylastpt = Thelastpt;
+ }
+ }
+
+ if (MyStatus == Approx_NoPointsAdded && !begin)
+ {
+ // On rend la meilleure approximation obtenue precedemment.
+ // ========================================================
+ GoUp = Standard_True;
+ tolreached = Standard_False;
+ if (TheMultiCurve.NbCurves() == 0)
+ {
+ myMultiCurves.Clear();
+ return;
+ }
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(TheMultiCurve);
+ if (mydebug)
+ DUMP(TheMultiCurve);
#endif
- myMultiCurves.Append(TheMultiCurve);
- Tolers3d.Append(currenttol3d);
- Tolers2d.Append(currenttol2d);
- Standard_Integer mylen = oldlastpt-myfirstpt+1;
- Standard_Integer myParLen = myParameters->Length();
- Standard_Integer aLen = (myParLen > mylen)? myParLen : mylen;
+ myMultiCurves.Append(TheMultiCurve);
+ Tolers3d.Append(currenttol3d);
+ Tolers2d.Append(currenttol2d);
+ Standard_Integer mylen = oldlastpt - myfirstpt + 1;
+ Standard_Integer myParLen = myParameters->Length();
+ Standard_Integer aLen = (myParLen > mylen) ? myParLen : mylen;
Handle(TColStd_HArray1OfReal) ThePar =
- new TColStd_HArray1OfReal(myfirstpt, myfirstpt+aLen-1);
+ new TColStd_HArray1OfReal(myfirstpt, myfirstpt + aLen - 1);
for (i = 0; i < aLen; i++)
- ThePar->SetValue(myfirstpt+i, myParameters->Value(myParameters->Lower()+i));
- myPar.Append(ThePar);
-
- myfirstpt = oldlastpt;
- mylastpt = Thelastpt;
- }
-
- else if (MyStatus == Approx_NoApproximation) {
- // On ne fait pas d approximation entre myfirstpt et mylastpt.
- // ===========================================================
- // On stocke pour pouvoir en informer l utilisateur.
- GoUp = Standard_True;
- myfirstpt = mylastpt;
- mylastpt = Thelastpt;
- }
+ ThePar->SetValue(myfirstpt + i, myParameters->Value(myParameters->Lower() + i));
+ myPar.Append(ThePar);
+
+ myfirstpt = oldlastpt;
+ mylastpt = Thelastpt;
+ }
+
+ else if (MyStatus == Approx_NoApproximation)
+ {
+ // On ne fait pas d approximation entre myfirstpt et mylastpt.
+ // ===========================================================
+ // On stocke pour pouvoir en informer l utilisateur.
+ GoUp = Standard_True;
+ myfirstpt = mylastpt;
+ mylastpt = Thelastpt;
+ }
}
-
- if (myfirstpt == Thelastpt) {
- Finish = Standard_True;
- alldone = Standard_True;
- return;
+
+ if (myfirstpt == Thelastpt)
+ {
+ Finish = Standard_True;
+ alldone = Standard_True;
+ return;
}
- if (!GoUp) {
- if (myfirstpt == mylastpt) break; // Pour etre sur de ne pas
- // planter la station !!
- myCouple1.SetIndex(myfirstpt);
- myCouple2.SetIndex(mylastpt);
- myConstraints->SetValue(1, myCouple1);
- myConstraints->SetValue(2, myCouple2);
-
- // Calcul des parametres sur ce nouvel intervalle.
- // On recupere les parametres initiaux lors du decoupage.
-
- math_Vector Param(myfirstpt, mylastpt);
- if (begin) {
- if(myfirstParam.IsNull()) {
- Parameters(Line, myfirstpt, mylastpt, Param);
- }
- else {
- for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++) {
- Param(i) = myfirstParam->Value(i);
- }
- myfirstParam.Nullify();
- }
- TheParam = Param;
- begin = Standard_False;
- }
- else {
- Standard_Real pfirst = TheParam.Value(myfirstpt);
- Standard_Real plast = TheParam.Value(mylastpt);
- for (i = myfirstpt; i <= mylastpt; i++) {
- Param(i) = (TheParam.Value(i)-pfirst)/(plast-pfirst);
- }
- }
-
- TheMultiCurve = AppParCurves_MultiCurve();
+ if (!GoUp)
+ {
+ if (myfirstpt == mylastpt)
+ break; // Pour etre sur de ne pas
+ // planter la station !!
+ myCouple1.SetIndex(myfirstpt);
+ myCouple2.SetIndex(mylastpt);
+ myConstraints->SetValue(1, myCouple1);
+ myConstraints->SetValue(2, myCouple2);
+
+ // Calcul des parametres sur ce nouvel intervalle.
+ // On recupere les parametres initiaux lors du decoupage.
+
+ math_Vector Param(myfirstpt, mylastpt);
+ if (begin)
+ {
+ if (myfirstParam.IsNull())
+ {
+ Parameters(Line, myfirstpt, mylastpt, Param);
+ }
+ else
+ {
+ for (i = myfirstParam->Lower(); i <= myfirstParam->Upper(); i++)
+ {
+ Param(i) = myfirstParam->Value(i);
+ }
+ myfirstParam.Nullify();
+ }
+ TheParam = Param;
+ begin = Standard_False;
+ }
+ else
+ {
+ Standard_Real pfirst = TheParam.Value(myfirstpt);
+ Standard_Real plast = TheParam.Value(mylastpt);
+ for (i = myfirstpt; i <= mylastpt; i++)
+ {
+ Param(i) = (TheParam.Value(i) - pfirst) / (plast - pfirst);
+ }
+ }
+
+ TheMultiCurve = AppParCurves_MultiCurve();
Standard_Integer indbad = 0;
- Ok = Compute(Line, myfirstpt, mylastpt, Param, thetol3d, thetol2d, indbad);
+ Ok = Compute(Line, myfirstpt, mylastpt, Param, thetol3d, thetol2d, indbad);
if (myfirstpt == Thelastpt)
{
- Finish = Standard_True;
+ Finish = Standard_True;
alldone = Standard_True;
return;
}
}
}
-
-
const TColStd_Array1OfReal& Approx_ComputeLine::Parameters(const Standard_Integer Index) const
{
return (myPar.Value(Index))->Array1();
}
-
-Standard_Integer Approx_ComputeLine::NbMultiCurves()const
+Standard_Integer Approx_ComputeLine::NbMultiCurves() const
{
return myMultiCurves.Length();
}
return myMultiCurves.ChangeValue(Index);
}
-
-const AppParCurves_MultiCurve& Approx_ComputeLine::Value(const Standard_Integer Index)
-const
+const AppParCurves_MultiCurve& Approx_ComputeLine::Value(const Standard_Integer Index) const
{
return myMultiCurves.Value(Index);
}
-
const AppParCurves_MultiBSpCurve& Approx_ComputeLine::SplineValue()
{
Approx_MCurvesToBSpCurve Trans;
return myspline;
}
-
-
-
-
-void Approx_ComputeLine::Parameters(const MultiLine& Line,
- const Standard_Integer firstP,
- const Standard_Integer lastP,
- math_Vector& TheParameters) const
+void Approx_ComputeLine::Parameters(const MultiLine& Line,
+ const Standard_Integer firstP,
+ const Standard_Integer lastP,
+ math_Vector& TheParameters) const
{
Standard_Integer i, j, nbP2d, nbP3d;
- Standard_Real dist;
+ Standard_Real dist;
- if(Par == Approx_ChordLength || Par == Approx_Centripetal)
+ if (Par == Approx_ChordLength || Par == Approx_Centripetal)
{
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if(nbP3d == 0) mynbP3d = 1;
- if(nbP2d == 0) mynbP2d = 1;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
TheParameters(firstP) = 0.0;
- dist = 0.0;
- TColgp_Array1OfPnt tabP(1, mynbP3d);
- TColgp_Array1OfPnt tabPP(1, mynbP3d);
+ dist = 0.0;
+ TColgp_Array1OfPnt tabP(1, mynbP3d);
+ TColgp_Array1OfPnt tabPP(1, mynbP3d);
TColgp_Array1OfPnt2d tabP2d(1, mynbP2d);
TColgp_Array1OfPnt2d tabPP2d(1, mynbP2d);
- for(i = firstP + 1; i <= lastP; i++)
+ for (i = firstP + 1; i <= lastP; i++)
{
- if(nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, i - 1, tabP, tabP2d);
- else if(nbP2d != 0) LineTool::Value(Line, i - 1, tabP2d);
- else if(nbP3d != 0) LineTool::Value(Line, i - 1, tabP);
-
- if(nbP3d != 0 && nbP2d != 0) LineTool::Value(Line, i, tabPP, tabPP2d);
- else if(nbP2d != 0) LineTool::Value(Line, i, tabPP2d);
- else if(nbP3d != 0) LineTool::Value(Line, i, tabPP);
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, i - 1, tabP, tabP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, i - 1, tabP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, i - 1, tabP);
+
+ if (nbP3d != 0 && nbP2d != 0)
+ LineTool::Value(Line, i, tabPP, tabPP2d);
+ else if (nbP2d != 0)
+ LineTool::Value(Line, i, tabPP2d);
+ else if (nbP3d != 0)
+ LineTool::Value(Line, i, tabPP);
dist = 0;
- for(j = 1; j <= nbP3d; j++)
+ for (j = 1; j <= nbP3d; j++)
{
- const gp_Pnt &aP1 = tabP(j),
- &aP2 = tabPP(j);
+ const gp_Pnt &aP1 = tabP(j), &aP2 = tabPP(j);
dist += aP2.SquareDistance(aP1);
}
- for(j = 1; j <= nbP2d; j++)
+ for (j = 1; j <= nbP2d; j++)
{
- const gp_Pnt2d &aP12d = tabP2d(j),
- &aP22d = tabPP2d(j);
+ const gp_Pnt2d &aP12d = tabP2d(j), &aP22d = tabPP2d(j);
dist += aP22d.SquareDistance(aP12d);
}
dist = Sqrt(dist);
- if(Par == Approx_ChordLength)
+ if (Par == Approx_ChordLength)
{
TheParameters(i) = TheParameters(i - 1) + dist;
}
else
- {// Par == Approx_Centripetal
+ { // Par == Approx_Centripetal
TheParameters(i) = TheParameters(i - 1) + Sqrt(dist);
}
}
- for(i = firstP; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
+ for (i = firstP; i <= lastP; i++)
+ TheParameters(i) /= TheParameters(lastP);
}
- else {
- for (i = firstP; i <= lastP; i++) {
- TheParameters(i) = (Standard_Real(i)-firstP)/
- (Standard_Real(lastP)-Standard_Real(firstP));
+ else
+ {
+ for (i = firstP; i <= lastP; i++)
+ {
+ TheParameters(i) =
+ (Standard_Real(i) - firstP) / (Standard_Real(lastP) - Standard_Real(firstP));
}
}
-}
-
+}
-Standard_Boolean Approx_ComputeLine::Compute(const MultiLine& Line,
- const Standard_Integer fpt,
- const Standard_Integer lpt,
- math_Vector& Para,
- Standard_Real& TheTol3d,
- Standard_Real& TheTol2d,
- Standard_Integer& indbad)
+Standard_Boolean Approx_ComputeLine::Compute(const MultiLine& Line,
+ const Standard_Integer fpt,
+ const Standard_Integer lpt,
+ math_Vector& Para,
+ Standard_Real& TheTol3d,
+ Standard_Real& TheTol2d,
+ Standard_Integer& indbad)
{
indbad = 0;
Standard_Integer deg, i;
Standard_Boolean mydone;
- Standard_Real Fv;
- Standard_Integer nbp = lpt-fpt+1;
+ Standard_Real Fv;
+ Standard_Integer nbp = lpt - fpt + 1;
math_Vector ParSav(Para.Lower(), Para.Upper());
- for (i = Para.Lower(); i <= Para.Upper(); i++) {
+ for (i = Para.Lower(); i <= Para.Upper(); i++)
+ {
ParSav(i) = Para(i);
}
Standard_Integer Mdegmax = mydegremax;
- if(nbp < Mdegmax+5 && mycut) {
+ if (nbp < Mdegmax + 5 && mycut)
+ {
Mdegmax = nbp - 5;
}
- if(Mdegmax < mydegremin) {
+ if (Mdegmax < mydegremin)
+ {
Mdegmax = mydegremin;
}
-
+
currenttol3d = currenttol2d = RealLast();
- for (deg = Min(nbp-1,mydegremin); deg <= Mdegmax; deg++) {
- AppParCurves_MultiCurve mySCU(deg+1);
- if (mysquares) {
- Approx_ParLeastSquareOfMyGradient SQ(Line, fpt, lpt,
- myfirstC, mylastC, Para, deg+1);
+ for (deg = Min(nbp - 1, mydegremin); deg <= Mdegmax; deg++)
+ {
+ AppParCurves_MultiCurve mySCU(deg + 1);
+ if (mysquares)
+ {
+ Approx_ParLeastSquareOfMyGradient SQ(Line, fpt, lpt, myfirstC, mylastC, Para, deg + 1);
mydone = SQ.IsDone();
- mySCU = SQ.BezierValue();
+ mySCU = SQ.BezierValue();
SQ.Error(Fv, TheTol3d, TheTol2d);
}
- else {
- Approx_MyGradient GRAD(Line, fpt, lpt, myConstraints,
- Para, deg, mytol3d, mytol2d, myitermax);
+ else
+ {
+ Approx_MyGradient GRAD(Line, fpt, lpt, myConstraints, Para, deg, mytol3d, mytol2d, myitermax);
mydone = GRAD.IsDone();
- mySCU = GRAD.Value();
+ mySCU = GRAD.Value();
if (mySCU.NbCurves() == 0)
- continue;
+ continue;
TheTol3d = GRAD.MaxError3d();
TheTol2d = GRAD.MaxError2d();
- }
- Standard_Real uu1 = Para(Para.Lower()), uu2;
+ }
+ Standard_Real uu1 = Para(Para.Lower()), uu2;
Standard_Boolean restau = Standard_False;
- for ( i = Para.Lower()+1; i <= Para.Upper(); i++) {
- uu2 = Para(i);
- if (uu2 <= uu1) {
- restau = Standard_True;
-// cout << "restau = Standard_True" << endl;
- break;
+ for (i = Para.Lower() + 1; i <= Para.Upper(); i++)
+ {
+ uu2 = Para(i);
+ if (uu2 <= uu1)
+ {
+ restau = Standard_True;
+ // cout << "restau = Standard_True" << endl;
+ break;
}
uu1 = uu2;
}
- if (restau) {
- for (i = Para.Lower(); i <= Para.Upper(); i++) {
- Para(i) = ParSav(i);
+ if (restau)
+ {
+ for (i = Para.Lower(); i <= Para.Upper(); i++)
+ {
+ Para(i) = ParSav(i);
}
}
- if (mydone) {
- if (TheTol3d <= mytol3d && TheTol2d <= mytol2d) {
- // Stockage de la multicurve approximee.
- tolreached = Standard_True;
+ if (mydone)
+ {
+ if (TheTol3d <= mytol3d && TheTol2d <= mytol2d)
+ {
+ // Stockage de la multicurve approximee.
+ tolreached = Standard_True;
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(mySCU);
+ if (mydebug)
+ DUMP(mySCU);
#endif
- if (!CheckMultiCurve(mySCU, Line,
- fpt, lpt,
- indbad))
+ if (!CheckMultiCurve(mySCU, Line, fpt, lpt, indbad))
{
return Standard_False;
}
myMultiCurves.Append(mySCU);
// Stockage des parametres de la partie de MultiLine approximee:
// A ameliorer !! (bq trop de recopies)
- Handle(TColStd_HArray1OfReal) ThePar =
+ Handle(TColStd_HArray1OfReal) ThePar =
new TColStd_HArray1OfReal(Para.Lower(), Para.Upper());
- for (i = Para.Lower(); i <= Para.Upper(); i++) {
+ for (i = Para.Lower(); i <= Para.Upper(); i++)
+ {
ThePar->SetValue(i, Para(i));
}
myPar.Append(ThePar);
}
}
- if (TheTol3d <= currenttol3d && TheTol2d <= currenttol2d) {
+ if (TheTol3d <= currenttol3d && TheTol2d <= currenttol2d)
+ {
TheMultiCurve = mySCU;
- currenttol3d = TheTol3d;
- currenttol2d = TheTol2d;
- myParameters = new TColStd_HArray1OfReal(Para.Lower(), Para.Upper());
- for (i = Para.Lower(); i <= Para.Upper(); i++) {
- myParameters->SetValue(i, Para(i));
+ currenttol3d = TheTol3d;
+ currenttol2d = TheTol2d;
+ myParameters = new TColStd_HArray1OfReal(Para.Lower(), Para.Upper());
+ for (i = Para.Lower(); i <= Para.Upper(); i++)
+ {
+ myParameters->SetValue(i, Para(i));
}
}
-
}
return Standard_False;
}
-
-
-
-Standard_Boolean Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
- const Standard_Integer firstpt,
- const Standard_Integer lastpt)
+Standard_Boolean Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
+ const Standard_Integer firstpt,
+ const Standard_Integer lastpt)
{
Standard_Integer i, j, nbP3d, nbP2d, deg;
- gp_Vec V13d, V23d;
- gp_Vec2d V12d, V22d;
- gp_Pnt P1, P2;
- gp_Pnt2d P12d, P22d;
- Standard_Boolean Tangent1, Tangent2, mydone= Standard_False;
+ gp_Vec V13d, V23d;
+ gp_Vec2d V12d, V22d;
+ gp_Pnt P1, P2;
+ gp_Pnt2d P12d, P22d;
+ Standard_Boolean Tangent1, Tangent2, mydone = Standard_False;
#ifdef OCCT_DEBUG
Standard_Boolean Parallel;
#endif
Standard_Integer myfirstpt = firstpt, mylastpt = lastpt;
- Standard_Integer nbp = lastpt-firstpt+1;
- math_Vector Para(firstpt, lastpt);
+ Standard_Integer nbp = lastpt - firstpt + 1;
+ math_Vector Para(firstpt, lastpt);
Parameters(Line, firstpt, lastpt, Para);
- nbP3d = LineTool::NbP3d(Line);
- nbP2d = LineTool::NbP2d(Line);
+ nbP3d = LineTool::NbP3d(Line);
+ nbP2d = LineTool::NbP2d(Line);
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
- if (nbP3d == 0) mynbP3d = 1 ;
- if (nbP2d == 0) mynbP2d = 1 ;
+ if (nbP3d == 0)
+ mynbP3d = 1;
+ if (nbP2d == 0)
+ mynbP2d = 1;
-
- TColgp_Array1OfVec tabV1(1, mynbP3d), tabV2(1, mynbP3d);
- TColgp_Array1OfPnt tabP1(1, mynbP3d), tabP2(1, mynbP3d), tabP(1, mynbP3d);
+ TColgp_Array1OfVec tabV1(1, mynbP3d), tabV2(1, mynbP3d);
+ TColgp_Array1OfPnt tabP1(1, mynbP3d), tabP2(1, mynbP3d), tabP(1, mynbP3d);
TColgp_Array1OfVec2d tabV12d(1, mynbP2d), tabV22d(1, mynbP2d);
TColgp_Array1OfPnt2d tabP12d(1, mynbP2d), tabP22d(1, mynbP2d), tabP2d(1, mynbP2d);
- if (nbP3d != 0 && nbP2d != 0) {
- LineTool::Value(Line, myfirstpt,tabP1,tabP12d);
- LineTool::Value(Line, mylastpt,tabP2,tabP22d);
- Tangent1 = LineTool::Tangency(Line, myfirstpt,tabV1,tabV12d);
- Tangent2 = LineTool::Tangency(Line, mylastpt,tabV2,tabV22d);
+ if (nbP3d != 0 && nbP2d != 0)
+ {
+ LineTool::Value(Line, myfirstpt, tabP1, tabP12d);
+ LineTool::Value(Line, mylastpt, tabP2, tabP22d);
+ Tangent1 = LineTool::Tangency(Line, myfirstpt, tabV1, tabV12d);
+ Tangent2 = LineTool::Tangency(Line, mylastpt, tabV2, tabV22d);
}
- else if (nbP2d != 0) {
- LineTool::Value(Line, myfirstpt,tabP12d);
- LineTool::Value(Line, mylastpt,tabP22d);
+ else if (nbP2d != 0)
+ {
+ LineTool::Value(Line, myfirstpt, tabP12d);
+ LineTool::Value(Line, mylastpt, tabP22d);
Tangent1 = LineTool::Tangency(Line, myfirstpt, tabV12d);
Tangent2 = LineTool::Tangency(Line, mylastpt, tabV22d);
}
- else {
- LineTool::Value(Line, myfirstpt,tabP1);
- LineTool::Value(Line, mylastpt,tabP2);
+ else
+ {
+ LineTool::Value(Line, myfirstpt, tabP1);
+ LineTool::Value(Line, mylastpt, tabP2);
Tangent1 = LineTool::Tangency(Line, myfirstpt, tabV1);
Tangent2 = LineTool::Tangency(Line, mylastpt, tabV2);
}
- if (nbp == 2) {
- // S il n y a que 2 points, on verifie quand meme que les tangentes sont
+ if (nbp == 2)
+ {
+ // S il n y a que 2 points, on verifie quand meme que les tangentes sont
// alignees.
#ifdef OCCT_DEBUG
Parallel = Standard_True;
#endif
- if (Tangent1) {
- for (i = 1; i <= nbP3d; i++) {
- gp_Vec PVec(tabP1(i), tabP2(i));
- V13d = tabV1(i);
- if (!PVec.IsParallel(V13d, Precision::Angular())) {
+ if (Tangent1)
+ {
+ for (i = 1; i <= nbP3d; i++)
+ {
+ gp_Vec PVec(tabP1(i), tabP2(i));
+ V13d = tabV1(i);
+ if (!PVec.IsParallel(V13d, Precision::Angular()))
+ {
#ifdef OCCT_DEBUG
- Parallel = Standard_False;
+ Parallel = Standard_False;
#endif
- break;
- }
+ break;
+ }
}
- for (i = 1; i <= nbP2d; i++) {
- gp_Vec2d PVec2d(tabP12d(i), tabP22d(i));
- V12d = tabV12d(i);
- if (!PVec2d.IsParallel(V12d, Precision::Angular())) {
+ for (i = 1; i <= nbP2d; i++)
+ {
+ gp_Vec2d PVec2d(tabP12d(i), tabP22d(i));
+ V12d = tabV12d(i);
+ if (!PVec2d.IsParallel(V12d, Precision::Angular()))
+ {
#ifdef OCCT_DEBUG
- Parallel = Standard_False;
+ Parallel = Standard_False;
#endif
- break;
- }
+ break;
+ }
}
- }
+ }
- if (Tangent2) {
- for (i = 1; i <= nbP3d; i++) {
- gp_Vec PVec(tabP1(i), tabP2(i));
- V23d = tabV2(i);
- if (!PVec.IsParallel(V23d, Precision::Angular())) {
+ if (Tangent2)
+ {
+ for (i = 1; i <= nbP3d; i++)
+ {
+ gp_Vec PVec(tabP1(i), tabP2(i));
+ V23d = tabV2(i);
+ if (!PVec.IsParallel(V23d, Precision::Angular()))
+ {
#ifdef OCCT_DEBUG
- Parallel = Standard_False;
+ Parallel = Standard_False;
#endif
- break;
- }
+ break;
+ }
}
- for (i = 1; i <= nbP2d; i++) {
- gp_Vec2d PVec2d(tabP12d(i), tabP22d(i));
- V22d = tabV22d(i);
- if (!PVec2d.IsParallel(V22d, Precision::Angular())) {
+ for (i = 1; i <= nbP2d; i++)
+ {
+ gp_Vec2d PVec2d(tabP12d(i), tabP22d(i));
+ V22d = tabV22d(i);
+ if (!PVec2d.IsParallel(V22d, Precision::Angular()))
+ {
#ifdef OCCT_DEBUG
- Parallel = Standard_False;
+ Parallel = Standard_False;
#endif
- break;
- }
+ break;
+ }
}
}
#ifdef OCCT_DEBUG
- if (!Parallel) {
- if (mydebug) std::cout <<"droite mais tangentes pas vraiment paralleles!!"<< std::endl;
+ if (!Parallel)
+ {
+ if (mydebug)
+ std::cout << "droite mais tangentes pas vraiment paralleles!!" << std::endl;
}
#endif
- AppParCurves_MultiCurve mySCU(mydegremin+1);
- if (nbP3d != 0 && nbP2d != 0) {
+ AppParCurves_MultiCurve mySCU(mydegremin + 1);
+ if (nbP3d != 0 && nbP2d != 0)
+ {
AppParCurves_MultiPoint MPole1(tabP1, tabP12d);
AppParCurves_MultiPoint MPole2(tabP2, tabP22d);
mySCU.SetValue(1, MPole1);
- mySCU.SetValue(mydegremin+1, MPole2);
- for (i = 2; i <= mydegremin; i++) {
- for (j = 1; j<= nbP3d; j++) {
- P1 = tabP1(j);
- P2 = tabP2(j);
- tabP(j).SetXYZ(P1.XYZ()+(i-1)*(P2.XYZ()-P1.XYZ())/mydegremin);
- }
- for (j = 1; j<= nbP2d; j++) {
- P12d = tabP12d(j);
- P22d = tabP22d(j);
- tabP2d(j).SetXY(P12d.XY()+(i-1)*(P22d.XY()-P12d.XY())/mydegremin);
- }
- AppParCurves_MultiPoint MPole(tabP, tabP2d);
- mySCU.SetValue(i, MPole);
+ mySCU.SetValue(mydegremin + 1, MPole2);
+ for (i = 2; i <= mydegremin; i++)
+ {
+ for (j = 1; j <= nbP3d; j++)
+ {
+ P1 = tabP1(j);
+ P2 = tabP2(j);
+ tabP(j).SetXYZ(P1.XYZ() + (i - 1) * (P2.XYZ() - P1.XYZ()) / mydegremin);
+ }
+ for (j = 1; j <= nbP2d; j++)
+ {
+ P12d = tabP12d(j);
+ P22d = tabP22d(j);
+ tabP2d(j).SetXY(P12d.XY() + (i - 1) * (P22d.XY() - P12d.XY()) / mydegremin);
+ }
+ AppParCurves_MultiPoint MPole(tabP, tabP2d);
+ mySCU.SetValue(i, MPole);
}
-
}
- else if (nbP3d != 0) {
+ else if (nbP3d != 0)
+ {
AppParCurves_MultiPoint MPole1(tabP1);
AppParCurves_MultiPoint MPole2(tabP2);
mySCU.SetValue(1, MPole1);
- mySCU.SetValue(mydegremin+1, MPole2);
- for (i = 2; i <= mydegremin; i++) {
- for (j = 1; j<= nbP3d; j++) {
- P1 = tabP1(j);
- P2 = tabP2(j);
- tabP(j).SetXYZ(P1.XYZ()+(i-1)*(P2.XYZ()-P1.XYZ())/mydegremin);
- }
- AppParCurves_MultiPoint MPole(tabP);
- mySCU.SetValue(i, MPole);
+ mySCU.SetValue(mydegremin + 1, MPole2);
+ for (i = 2; i <= mydegremin; i++)
+ {
+ for (j = 1; j <= nbP3d; j++)
+ {
+ P1 = tabP1(j);
+ P2 = tabP2(j);
+ tabP(j).SetXYZ(P1.XYZ() + (i - 1) * (P2.XYZ() - P1.XYZ()) / mydegremin);
+ }
+ AppParCurves_MultiPoint MPole(tabP);
+ mySCU.SetValue(i, MPole);
}
}
- else if (nbP2d != 0) {
+ else if (nbP2d != 0)
+ {
AppParCurves_MultiPoint MPole1(tabP12d);
AppParCurves_MultiPoint MPole2(tabP22d);
mySCU.SetValue(1, MPole1);
- mySCU.SetValue(mydegremin+1, MPole2);
- for (i = 2; i <= mydegremin; i++) {
- for (j = 1; j<= nbP2d; j++) {
- P12d = tabP12d(j);
- P22d = tabP22d(j);
- tabP2d(j).SetXY(P12d.XY()+(i-1)*(P22d.XY()-P12d.XY())/mydegremin);
- }
- AppParCurves_MultiPoint MPole(tabP2d);
- mySCU.SetValue(i, MPole);
+ mySCU.SetValue(mydegremin + 1, MPole2);
+ for (i = 2; i <= mydegremin; i++)
+ {
+ for (j = 1; j <= nbP2d; j++)
+ {
+ P12d = tabP12d(j);
+ P22d = tabP22d(j);
+ tabP2d(j).SetXY(P12d.XY() + (i - 1) * (P22d.XY() - P12d.XY()) / mydegremin);
+ }
+ AppParCurves_MultiPoint MPole(tabP2d);
+ mySCU.SetValue(i, MPole);
}
}
mydone = Standard_True;
// Stockage de la multicurve approximee.
tolreached = Standard_True;
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(mySCU);
+ if (mydebug)
+ DUMP(mySCU);
#endif
myMultiCurves.Append(mySCU);
Handle(TColStd_HArray1OfReal) ThePar = new TColStd_HArray1OfReal(Para.Lower(), Para.Upper());
- for (i = Para.Lower(); i <= Para.Upper(); i++) {
+ for (i = Para.Lower(); i <= Para.Upper(); i++)
+ {
ThePar->SetValue(i, Para(i));
}
myPar.Append(ThePar);
}
// avec les tangentes.
- deg = nbp+1;
- AppParCurves_MultiCurve mySCU(deg+1);
+ deg = nbp + 1;
+ AppParCurves_MultiCurve mySCU(deg + 1);
AppParCurves_Constraint Cons = AppParCurves_TangencyPoint;
- Standard_Real lambda1, lambda2;
- math_Vector V1(1, nbP3d*3+nbP2d*2);
- math_Vector V2(1, nbP3d*3+nbP2d*2);
+ Standard_Real lambda1, lambda2;
+ math_Vector V1(1, nbP3d * 3 + nbP2d * 2);
+ math_Vector V2(1, nbP3d * 3 + nbP2d * 2);
FirstTangencyVector(Line, myfirstpt, V1);
lambda1 = SearchFirstLambda(Line, Para, V1, myfirstpt);
-
+
LastTangencyVector(Line, mylastpt, V2);
lambda2 = SearchLastLambda(Line, Para, V2, mylastpt);
-
- Approx_ParLeastSquareOfMyGradient
- LSQ(Line, myfirstpt, mylastpt,
- Cons, Cons, Para, deg+1);
-
- lambda1 = lambda1/deg;
- lambda2 = lambda2/deg;
+
+ Approx_ParLeastSquareOfMyGradient LSQ(Line, myfirstpt, mylastpt, Cons, Cons, Para, deg + 1);
+
+ lambda1 = lambda1 / deg;
+ lambda2 = lambda2 / deg;
LSQ.Perform(Para, V1, V2, lambda1, lambda2);
mydone = LSQ.IsDone();
- mySCU = LSQ.BezierValue();
-
- if (mydone) {
+ mySCU = LSQ.BezierValue();
+
+ if (mydone)
+ {
Standard_Real Fv, TheTol3d, TheTol2d;
- LSQ.Error(Fv, TheTol3d, TheTol2d);
+ LSQ.Error(Fv, TheTol3d, TheTol2d);
// Stockage de la multicurve approximee.
tolreached = Standard_True;
#ifdef OCCT_DEBUG
- if (mydebug) DUMP(mySCU);
+ if (mydebug)
+ DUMP(mySCU);
#endif
myMultiCurves.Append(mySCU);
- Handle(TColStd_HArray1OfReal) ThePar =
- new TColStd_HArray1OfReal(Para.Lower(), Para.Upper());
- for (i = Para.Lower(); i <= Para.Upper(); i++) {
+ Handle(TColStd_HArray1OfReal) ThePar = new TColStd_HArray1OfReal(Para.Lower(), Para.Upper());
+ for (i = Para.Lower(); i <= Para.Upper(); i++)
+ {
ThePar->SetValue(i, Para(i));
}
myPar.Append(ThePar);
return mydone;
}
-
-
-void Approx_ComputeLine::Init(const Standard_Integer degreemin,
- const Standard_Integer degreemax,
- const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d,
- const Standard_Integer NbIterations,
- const Standard_Boolean cutting,
- const Approx_ParametrizationType parametrization,
- const Standard_Boolean Squares)
+void Approx_ComputeLine::Init(const Standard_Integer degreemin,
+ const Standard_Integer degreemax,
+ const Standard_Real Tolerance3d,
+ const Standard_Real Tolerance2d,
+ const Standard_Integer NbIterations,
+ const Standard_Boolean cutting,
+ const Approx_ParametrizationType parametrization,
+ const Standard_Boolean Squares)
{
mydegremin = degreemin;
mydegremax = degreemax;
- mytol3d = Tolerance3d;
- mytol2d = Tolerance2d;
- Par = parametrization;
- mysquares = Squares;
- mycut = cutting;
- myitermax = NbIterations;
+ mytol3d = Tolerance3d;
+ mytol2d = Tolerance2d;
+ Par = parametrization;
+ mysquares = Squares;
+ mycut = cutting;
+ myitermax = NbIterations;
}
-
-
void Approx_ComputeLine::SetDegrees(const Standard_Integer degreemin,
- const Standard_Integer degreemax)
+ const Standard_Integer degreemax)
{
mydegremin = degreemin;
mydegremax = degreemax;
}
-
void Approx_ComputeLine::SetTolerances(const Standard_Real Tolerance3d,
- const Standard_Real Tolerance2d)
+ const Standard_Real Tolerance2d)
{
mytol3d = Tolerance3d;
mytol2d = Tolerance2d;
}
-
void Approx_ComputeLine::SetConstraints(const AppParCurves_Constraint FirstC,
- const AppParCurves_Constraint LastC)
+ const AppParCurves_Constraint LastC)
{
myfirstC = FirstC;
- mylastC = LastC;
+ mylastC = LastC;
}
-
-
-Standard_Boolean Approx_ComputeLine::IsAllApproximated()
-const {
+Standard_Boolean Approx_ComputeLine::IsAllApproximated() const
+{
return alldone;
}
-Standard_Boolean Approx_ComputeLine::IsToleranceReached()
-const {
+Standard_Boolean Approx_ComputeLine::IsToleranceReached() const
+{
return tolreached;
}
void Approx_ComputeLine::Error(const Standard_Integer Index,
- Standard_Real& tol3d,
- Standard_Real& tol2d) const
+ Standard_Real& tol3d,
+ Standard_Real& tol2d) const
{
tol3d = Tolers3d.Value(Index);
tol2d = Tolers2d.Value(Index);
#include <Standard_OutOfRange.hxx>
+void Extrema_CurveLocator::Locate(const Pnt& P,
+ const Curve1& C,
+ const Standard_Integer NbU,
+ POnC& Papp)
+{
+
+ /*-----------------------------------------------------------------------------
+ Fonction:
+ Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
+ point le plus proche du point P.
+ L'echantillonnage est fait a parametre constant sur l'intervalle de
+ definition de la courbe.
+ -----------------------------------------------------------------------------*/
+
+ if (NbU < 2)
+ {
+ throw Standard_OutOfRange();
+ }
-void Extrema_CurveLocator::Locate (const Pnt& P, const Curve1& C,
- const Standard_Integer NbU,
- POnC& Papp) {
-
-/*-----------------------------------------------------------------------------
-Fonction:
- Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
- point le plus proche du point P.
- L'echantillonnage est fait a parametre constant sur l'intervalle de
- definition de la courbe.
------------------------------------------------------------------------------*/
-
- if (NbU < 2) { throw Standard_OutOfRange(); }
-
- Standard_Real U = Tool1::FirstParameter(C);
- Standard_Real PasU = (Tool1::LastParameter(C) - U)/ (NbU - 1);
- Standard_Real Dist2Min = RealLast(), UMin=0;
- Pnt PntMin;
+ Standard_Real U = Tool1::FirstParameter(C);
+ Standard_Real PasU = (Tool1::LastParameter(C) - U) / (NbU - 1);
+ Standard_Real Dist2Min = RealLast(), UMin = 0;
+ Pnt PntMin;
Standard_Real Dist2;
- Pnt Pt;
- for ( Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU) {
- Pt = Tool1::Value(C, U);
+ Pnt Pt;
+ for (Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU)
+ {
+ Pt = Tool1::Value(C, U);
Dist2 = Pt.SquareDistance(P);
- if (Dist2 < Dist2Min) {
+ if (Dist2 < Dist2Min)
+ {
Dist2Min = Dist2;
- UMin = U;
- PntMin = Pt;
+ UMin = U;
+ PntMin = Pt;
}
}
- Papp.SetValues(UMin,PntMin);
+ Papp.SetValues(UMin, PntMin);
}
-
-
-void Extrema_CurveLocator::Locate (const Pnt& P, const Curve1& C,
- const Standard_Integer NbU,
- const Standard_Real Umin,
- const Standard_Real Usup,
- POnC& Papp) {
-
-/*-----------------------------------------------------------------------------
-Fonction:
- Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
- point le plus proche du point P.
- L'echantillonnage est fait a parametre constant sur l'intervalle de
- definition de la courbe.
------------------------------------------------------------------------------*/
-
- if (NbU < 2) { throw Standard_OutOfRange(); }
+void Extrema_CurveLocator::Locate(const Pnt& P,
+ const Curve1& C,
+ const Standard_Integer NbU,
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ POnC& Papp)
+{
+
+ /*-----------------------------------------------------------------------------
+ Fonction:
+ Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
+ point le plus proche du point P.
+ L'echantillonnage est fait a parametre constant sur l'intervalle de
+ definition de la courbe.
+ -----------------------------------------------------------------------------*/
+
+ if (NbU < 2)
+ {
+ throw Standard_OutOfRange();
+ }
Standard_Real U1, U2, U11, U12;
- Standard_Real Uinf = Tool1::FirstParameter(C);
+ Standard_Real Uinf = Tool1::FirstParameter(C);
Standard_Real Ulast = Tool1::LastParameter(C);
-
- U1 = Min(Uinf, Ulast);
- U2 = Max(Uinf, Ulast);
+ U1 = Min(Uinf, Ulast);
+ U2 = Max(Uinf, Ulast);
U11 = Min(Umin, Usup);
U12 = Max(Umin, Usup);
- if (U11 < U1 - RealEpsilon()) U11 = U1;
- if (U12 > U2 + RealEpsilon()) U12 = U2;
+ if (U11 < U1 - RealEpsilon())
+ U11 = U1;
+ if (U12 > U2 + RealEpsilon())
+ U12 = U2;
- Standard_Real U = U11;
- Standard_Real PasU = (U12 - U)/ (NbU - 1);
- Standard_Real Dist2Min = RealLast(), UMin=0;
- Pnt PntMin;
+ Standard_Real U = U11;
+ Standard_Real PasU = (U12 - U) / (NbU - 1);
+ Standard_Real Dist2Min = RealLast(), UMin = 0;
+ Pnt PntMin;
Standard_Real Dist2;
- Pnt Pt;
- for ( Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU) {
- Pt = Tool1::Value(C, U);
+ Pnt Pt;
+ for (Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU)
+ {
+ Pt = Tool1::Value(C, U);
Dist2 = Pt.SquareDistance(P);
- if (Dist2 < Dist2Min) {
+ if (Dist2 < Dist2Min)
+ {
Dist2Min = Dist2;
- UMin = U;
- PntMin = Pt;
+ UMin = U;
+ PntMin = Pt;
}
}
Papp.SetValues(UMin, PntMin);
}
-
-
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//Modified by MPS : 21-05-97 PRO 7598
-// Le nombre de solutions rendu est mySqDist.Length() et non
-// mySqDist.Length()/2
-// ajout des valeurs absolues dans le test d'orthogonalite de
-// GetStateNumber()
+// Modified by MPS : 21-05-97 PRO 7598
+// Le nombre de solutions rendu est mySqDist.Length() et non
+// mySqDist.Length()/2
+// ajout des valeurs absolues dans le test d'orthogonalite de
+// GetStateNumber()
/*-----------------------------------------------------------------------------
Fonctions permettant de rechercher une distance extremale entre 2 courbes
Si on note Duu et Dvv, les derivees secondes de C1 et C2, les derivees de F1
et F2 sont egales a:
{ Duf1(u,v) = -||Du|| + C1C2.Duu/||Du||- F1(u,v)*Duu*Du/||Du||**2
-{ Dvf1(u,v) = Dv.Du/||Du||
+{ Dvf1(u,v) = Dv.Du/||Du||
{ Duf2(u,v) = -Du.Dv/||Dv||
{ Dvf2(u,v) = ||Dv|| + C2C1.Dvv/||Dv||- F2(u,v)*Dv*Dvv/||Dv||**2
#include <Precision.hxx>
-
static const Standard_Real MinTol = 1.e-20;
static const Standard_Real TolFactor = 1.e-12;
static const Standard_Real MinStep = 1e-7;
static const Standard_Integer MaxOrder = 3;
+//=================================================================================================
-
-//=============================================================================
Standard_Real Extrema_FuncExtCC::SearchOfTolerance(const Standard_Address C)
{
const Standard_Integer NPoint = 10;
- Standard_Real aStartParam, anEndParam;
+ Standard_Real aStartParam, anEndParam;
- if(C==myC1)
+ if (C == myC1)
{
aStartParam = myUinfium;
- anEndParam = myUsupremum;
+ anEndParam = myUsupremum;
}
- else if(C==myC2)
+ else if (C == myC2)
{
aStartParam = myVinfium;
- anEndParam = myVsupremum;
+ anEndParam = myVsupremum;
}
else
{
- //Warning: No curve for tolerance computing!
+ // Warning: No curve for tolerance computing!
return MinTol;
}
- const Standard_Real aStep = (anEndParam - aStartParam)/(Standard_Real)NPoint;
+ const Standard_Real aStep = (anEndParam - aStartParam) / (Standard_Real)NPoint;
Standard_Integer aNum = 0;
- Standard_Real aMax = -Precision::Infinite(); //Maximum value of 1st derivative
+ Standard_Real aMax = -Precision::Infinite(); // Maximum value of 1st derivative
//(it is computed with using NPoint point)
do
{
- Standard_Real u = aStartParam + aNum*aStep; //parameter for every point
- if(u > anEndParam)
+ Standard_Real u = aStartParam + aNum * aStep; // parameter for every point
+ if (u > anEndParam)
u = anEndParam;
- Pnt Ptemp; //empty point (is not used below)
- Vec VDer; // 1st derivative vector
+ Pnt Ptemp; // empty point (is not used below)
+ Vec VDer; // 1st derivative vector
Tool1::D1(*((Curve1*)C), u, Ptemp, VDer);
Standard_Real vm = VDer.Magnitude();
- if(vm > aMax)
+ if (vm > aMax)
aMax = vm;
- }
- while(++aNum < NPoint+1);
+ } while (++aNum < NPoint + 1);
- return Max(aMax*TolFactor,MinTol);
+ return Max(aMax * TolFactor, MinTol);
}
-//=============================================================================
-Extrema_FuncExtCC::Extrema_FuncExtCC(const Standard_Real thetol) : myC1 (0), myC2 (0), myTol (thetol)
+//=================================================================================================
+
+Extrema_FuncExtCC::Extrema_FuncExtCC(const Standard_Real thetol)
+ : myC1(0),
+ myC2(0),
+ myTol(thetol)
{
- math_Vector V1(1,2), V2(1,2);
+ math_Vector V1(1, 2), V2(1, 2);
V1(1) = 0.0;
V2(1) = 0.0;
V1(2) = 0.0;
V2(2) = 0.0;
SubIntervalInitialize(V1, V2);
myMaxDerivOrderC1 = 0;
- myTolC1=MinTol;
+ myTolC1 = MinTol;
myMaxDerivOrderC2 = 0;
- myTolC2=MinTol;
+ myTolC2 = MinTol;
}
-//=============================================================================
-Extrema_FuncExtCC::Extrema_FuncExtCC (const Curve1& C1,
- const Curve2& C2,
- const Standard_Real thetol) :
-myC1 ((Standard_Address)&C1), myC2 ((Standard_Address)&C2),
-myTol (thetol)
+//=================================================================================================
+
+Extrema_FuncExtCC::Extrema_FuncExtCC(const Curve1& C1, const Curve2& C2, const Standard_Real thetol)
+ : myC1((Standard_Address)&C1),
+ myC2((Standard_Address)&C2),
+ myTol(thetol)
{
- math_Vector V1(1,2), V2(1,2);
+ math_Vector V1(1, 2), V2(1, 2);
V1(1) = Tool1::FirstParameter(*((Curve1*)myC1));
V2(1) = Tool1::LastParameter(*((Curve1*)myC1));
V1(2) = Tool2::FirstParameter(*((Curve2*)myC2));
V2(2) = Tool2::LastParameter(*((Curve2*)myC2));
SubIntervalInitialize(V1, V2);
- switch(Tool1::GetType(*((Curve1*)myC1)))
+ switch (Tool1::GetType(*((Curve1*)myC1)))
{
- case GeomAbs_BezierCurve:
- case GeomAbs_BSplineCurve:
- case GeomAbs_OffsetCurve:
- case GeomAbs_OtherCurve:
- myMaxDerivOrderC1 = MaxOrder;
- myTolC1 = SearchOfTolerance((Standard_Address)&C1);
- break;
- default:
- myMaxDerivOrderC1 = 0;
- myTolC1=MinTol;
- break;
+ case GeomAbs_BezierCurve:
+ case GeomAbs_BSplineCurve:
+ case GeomAbs_OffsetCurve:
+ case GeomAbs_OtherCurve:
+ myMaxDerivOrderC1 = MaxOrder;
+ myTolC1 = SearchOfTolerance((Standard_Address)&C1);
+ break;
+ default:
+ myMaxDerivOrderC1 = 0;
+ myTolC1 = MinTol;
+ break;
}
- switch(Tool2::GetType(*((Curve2*)myC2)))
+ switch (Tool2::GetType(*((Curve2*)myC2)))
{
- case GeomAbs_BezierCurve:
- case GeomAbs_BSplineCurve:
- case GeomAbs_OffsetCurve:
- case GeomAbs_OtherCurve:
- myMaxDerivOrderC2 = MaxOrder;
- myTolC2 = SearchOfTolerance((Standard_Address)&C2);
- break;
- default:
- myMaxDerivOrderC2 = 0;
- myTolC2=MinTol;
- break;
+ case GeomAbs_BezierCurve:
+ case GeomAbs_BSplineCurve:
+ case GeomAbs_OffsetCurve:
+ case GeomAbs_OtherCurve:
+ myMaxDerivOrderC2 = MaxOrder;
+ myTolC2 = SearchOfTolerance((Standard_Address)&C2);
+ break;
+ default:
+ myMaxDerivOrderC2 = 0;
+ myTolC2 = MinTol;
+ break;
}
}
-//=============================================================================
-void Extrema_FuncExtCC::SetCurve (const Standard_Integer theRank, const Curve1& C)
+//=================================================================================================
+
+void Extrema_FuncExtCC::SetCurve(const Standard_Integer theRank, const Curve1& C)
{
- Standard_OutOfRange_Raise_if (theRank < 1 || theRank > 2, "Extrema_FuncExtCC::SetCurve()")
+ Standard_OutOfRange_Raise_if(theRank < 1 || theRank > 2, "Extrema_FuncExtCC::SetCurve()")
if (theRank == 1)
+ {
+ myC1 = (Standard_Address)&C;
+ switch (/*Tool1::GetType(*((Curve1*)myC1))*/ C.GetType())
{
- myC1 = (Standard_Address)&C;
- switch(/*Tool1::GetType(*((Curve1*)myC1))*/ C.GetType())
- {
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
case GeomAbs_OffsetCurve:
case GeomAbs_OtherCurve:
myMaxDerivOrderC1 = MaxOrder;
- myTolC1 = SearchOfTolerance((Standard_Address)&C);
+ myTolC1 = SearchOfTolerance((Standard_Address)&C);
break;
default:
myMaxDerivOrderC1 = 0;
- myTolC1=MinTol;
+ myTolC1 = MinTol;
break;
- }
}
- else if (theRank == 2)
+ }
+ else if (theRank == 2)
+ {
+ myC2 = (Standard_Address)&C;
+ switch (/*Tool2::GetType(*((Curve2*)myC2))*/ C.GetType())
{
- myC2 = (Standard_Address)&C;
- switch(/*Tool2::GetType(*((Curve2*)myC2))*/C.GetType())
- {
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
case GeomAbs_OffsetCurve:
case GeomAbs_OtherCurve:
myMaxDerivOrderC2 = MaxOrder;
- myTolC2 = SearchOfTolerance((Standard_Address)&C);
+ myTolC2 = SearchOfTolerance((Standard_Address)&C);
break;
default:
myMaxDerivOrderC2 = 0;
- myTolC2=MinTol;
+ myTolC2 = MinTol;
break;
- }
}
+ }
}
-//=============================================================================
-Standard_Boolean Extrema_FuncExtCC::Value (const math_Vector& UV, math_Vector& F)
+//=================================================================================================
+
+Standard_Boolean Extrema_FuncExtCC::Value(const math_Vector& UV, math_Vector& F)
{
myU = UV(1);
myV = UV(2);
- Tool1::D1(*((Curve1*)myC1), myU,myP1,myDu);
- Tool2::D1(*((Curve2*)myC2), myV,myP2,myDv);
+ Tool1::D1(*((Curve1*)myC1), myU, myP1, myDu);
+ Tool2::D1(*((Curve2*)myC2), myV, myP2, myDv);
- Vec P1P2 (myP1,myP2);
+ Vec P1P2(myP1, myP2);
Standard_Real Ndu = myDu.Magnitude();
-
- if(myMaxDerivOrderC1 != 0)
+ if (myMaxDerivOrderC1 != 0)
{
if (Ndu <= myTolC1)
{
- //Derivative is approximated by Taylor-series
+ // Derivative is approximated by Taylor-series
const Standard_Real DivisionFactor = 1.e-3;
- Standard_Real du;
- if((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
+ Standard_Real du;
+ if ((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
du = 0.0;
else
- du = myUsupremum-myUinfium;
+ du = myUsupremum - myUinfium;
- const Standard_Real aDelta = Max(du*DivisionFactor,MinStep);
+ const Standard_Real aDelta = Max(du * DivisionFactor, MinStep);
- Standard_Integer n = 1; //Derivative order
- Vec V;
+ Standard_Integer n = 1; // Derivative order
+ Vec V;
Standard_Boolean IsDeriveFound;
do
{
- V = Tool1::DN(*((Curve1*)myC1),myU,++n);
- Ndu = V.Magnitude();
+ V = Tool1::DN(*((Curve1*)myC1), myU, ++n);
+ Ndu = V.Magnitude();
IsDeriveFound = (Ndu > myTolC1);
- }
- while(!IsDeriveFound && n < myMaxDerivOrderC1);
+ } while (!IsDeriveFound && n < myMaxDerivOrderC1);
- if(IsDeriveFound)
+ if (IsDeriveFound)
{
Standard_Real u;
- if(myU-myUinfium < aDelta)
- u = myU+aDelta;
+ if (myU - myUinfium < aDelta)
+ u = myU + aDelta;
else
- u = myU-aDelta;
+ u = myU - aDelta;
Pnt P1, P2;
- Tool1::D0(*((Curve1*)myC1),Min(myU, u),P1);
- Tool1::D0(*((Curve1*)myC1),Max(myU, u),P2);
+ Tool1::D0(*((Curve1*)myC1), Min(myU, u), P1);
+ Tool1::D0(*((Curve1*)myC1), Max(myU, u), P2);
- Vec V1(P1,P2);
+ Vec V1(P1, P2);
Standard_Real aDirFactor = V.Dot(V1);
- if(aDirFactor < 0.0)
+ if (aDirFactor < 0.0)
myDu = -V;
else
myDu = V;
- }//if(IsDeriveFound)
+ } // if(IsDeriveFound)
else
{
- //Derivative is approximated by three points
+ // Derivative is approximated by three points
- Pnt Ptemp; //(0,0,0)-coordinate
- Pnt P1, P2, P3;
+ Pnt Ptemp; //(0,0,0)-coordinate
+ Pnt P1, P2, P3;
Standard_Boolean IsParameterGrown;
- if(myU-myUinfium < 2*aDelta)
+ if (myU - myUinfium < 2 * aDelta)
{
- Tool1::D0(*((Curve1*)myC1),myU,P1);
- Tool1::D0(*((Curve1*)myC1),myU+aDelta,P2);
- Tool1::D0(*((Curve1*)myC1),myU+2*aDelta,P3);
+ Tool1::D0(*((Curve1*)myC1), myU, P1);
+ Tool1::D0(*((Curve1*)myC1), myU + aDelta, P2);
+ Tool1::D0(*((Curve1*)myC1), myU + 2 * aDelta, P3);
IsParameterGrown = Standard_True;
}
else
{
- Tool1::D0(*((Curve1*)myC1),myU-2*aDelta,P1);
- Tool1::D0(*((Curve1*)myC1),myU-aDelta,P2);
- Tool1::D0(*((Curve1*)myC1),myU,P3);
+ Tool1::D0(*((Curve1*)myC1), myU - 2 * aDelta, P1);
+ Tool1::D0(*((Curve1*)myC1), myU - aDelta, P2);
+ Tool1::D0(*((Curve1*)myC1), myU, P3);
IsParameterGrown = Standard_False;
}
- Vec V1(Ptemp,P1), V2(Ptemp,P2), V3(Ptemp,P3);
+ Vec V1(Ptemp, P1), V2(Ptemp, P2), V3(Ptemp, P3);
- if(IsParameterGrown)
- myDu=-3*V1+4*V2-V3;
+ if (IsParameterGrown)
+ myDu = -3 * V1 + 4 * V2 - V3;
else
- myDu=V1-4*V2+3*V3;
- }//else of if(IsDeriveFound)
- Ndu = myDu.Magnitude();
- }//if (Ndu <= myTolC1) condition
- }//if(myMaxDerivOrder != 0)
+ myDu = V1 - 4 * V2 + 3 * V3;
+ } // else of if(IsDeriveFound)
+ Ndu = myDu.Magnitude();
+ } // if (Ndu <= myTolC1) condition
+ } // if(myMaxDerivOrder != 0)
if (Ndu <= MinTol)
{
- //Warning: 1st derivative of C1 is equal to zero!
+ // Warning: 1st derivative of C1 is equal to zero!
return Standard_False;
}
Standard_Real Ndv = myDv.Magnitude();
- if(myMaxDerivOrderC2 != 0)
+ if (myMaxDerivOrderC2 != 0)
{
if (Ndv <= myTolC2)
- {
+ {
const Standard_Real DivisionFactor = 1.e-3;
- Standard_Real dv;
- if((myVsupremum >= RealLast()) || (myVinfium <= RealFirst()))
+ Standard_Real dv;
+ if ((myVsupremum >= RealLast()) || (myVinfium <= RealFirst()))
dv = 0.0;
else
- dv = myVsupremum-myVinfium;
+ dv = myVsupremum - myVinfium;
- const Standard_Real aDelta = Max(dv*DivisionFactor,MinStep);
+ const Standard_Real aDelta = Max(dv * DivisionFactor, MinStep);
- //Derivative is approximated by Taylor-series
+ // Derivative is approximated by Taylor-series
- Standard_Integer n = 1; //Derivative order
- Vec V;
+ Standard_Integer n = 1; // Derivative order
+ Vec V;
Standard_Boolean IsDeriveFound;
do
{
- V = Tool2::DN(*((Curve2*)myC2),myV,++n);
- Ndv = V.Magnitude();
+ V = Tool2::DN(*((Curve2*)myC2), myV, ++n);
+ Ndv = V.Magnitude();
IsDeriveFound = (Ndv > myTolC2);
- }
- while(!IsDeriveFound && n < myMaxDerivOrderC2);
+ } while (!IsDeriveFound && n < myMaxDerivOrderC2);
- if(IsDeriveFound)
+ if (IsDeriveFound)
{
Standard_Real v;
- if(myV-myVinfium < aDelta)
- v = myV+aDelta;
+ if (myV - myVinfium < aDelta)
+ v = myV + aDelta;
else
- v = myV-aDelta;
+ v = myV - aDelta;
Pnt P1, P2;
- Tool2::D0(*((Curve2*)myC2),Min(myV, v),P1);
- Tool2::D0(*((Curve2*)myC2),Max(myV, v),P2);
+ Tool2::D0(*((Curve2*)myC2), Min(myV, v), P1);
+ Tool2::D0(*((Curve2*)myC2), Max(myV, v), P2);
- Vec V1(P1,P2);
+ Vec V1(P1, P2);
Standard_Real aDirFactor = V.Dot(V1);
- if(aDirFactor < 0.0)
+ if (aDirFactor < 0.0)
myDv = -V;
else
myDv = V;
- }//if(IsDeriveFound)
+ } // if(IsDeriveFound)
else
{
- //Derivative is approximated by three points
+ // Derivative is approximated by three points
- Pnt Ptemp; //(0,0,0)-coordinate
- Pnt P1, P2, P3;
+ Pnt Ptemp; //(0,0,0)-coordinate
+ Pnt P1, P2, P3;
Standard_Boolean IsParameterGrown;
- if(myV-myVinfium < 2*aDelta)
+ if (myV - myVinfium < 2 * aDelta)
{
- Tool2::D0(*((Curve2*)myC2),myV,P1);
- Tool2::D0(*((Curve2*)myC2),myV+aDelta,P2);
- Tool2::D0(*((Curve2*)myC2),myV+2*aDelta,P3);
+ Tool2::D0(*((Curve2*)myC2), myV, P1);
+ Tool2::D0(*((Curve2*)myC2), myV + aDelta, P2);
+ Tool2::D0(*((Curve2*)myC2), myV + 2 * aDelta, P3);
IsParameterGrown = Standard_True;
}
else
{
- Tool2::D0(*((Curve2*)myC2),myV-2*aDelta,P1);
- Tool2::D0(*((Curve2*)myC2),myV-aDelta,P2);
- Tool2::D0(*((Curve2*)myC2),myV,P3);
+ Tool2::D0(*((Curve2*)myC2), myV - 2 * aDelta, P1);
+ Tool2::D0(*((Curve2*)myC2), myV - aDelta, P2);
+ Tool2::D0(*((Curve2*)myC2), myV, P3);
IsParameterGrown = Standard_False;
}
- Vec V1(Ptemp,P1), V2(Ptemp,P2), V3(Ptemp,P3);
+ Vec V1(Ptemp, P1), V2(Ptemp, P2), V3(Ptemp, P3);
- if(IsParameterGrown)
- myDv=-3*V1+4*V2-V3;
+ if (IsParameterGrown)
+ myDv = -3 * V1 + 4 * V2 - V3;
else
- myDv=V1-4*V2+3*V3;
- }//else of if(IsDeriveFound)
+ myDv = V1 - 4 * V2 + 3 * V3;
+ } // else of if(IsDeriveFound)
Ndv = myDv.Magnitude();
- }//if (Ndv <= myTolC2)
- }//if(myMaxDerivOrder != 0)
+ } // if (Ndv <= myTolC2)
+ } // if(myMaxDerivOrder != 0)
if (Ndv <= MinTol)
{
- //1st derivative of C2 is equal to zero!
+ // 1st derivative of C2 is equal to zero!
return Standard_False;
}
- F(1) = P1P2.Dot(myDu)/Ndu;
- F(2) = P1P2.Dot(myDv)/Ndv;
+ F(1) = P1P2.Dot(myDu) / Ndu;
+ F(2) = P1P2.Dot(myDv) / Ndv;
return Standard_True;
}
+
//=============================================================================
-Standard_Boolean Extrema_FuncExtCC::Derivatives (const math_Vector& UV,
- math_Matrix& Df)
+Standard_Boolean Extrema_FuncExtCC::Derivatives(const math_Vector& UV, math_Matrix& Df)
{
- math_Vector F(1,2);
- return Values(UV,F,Df);
+ math_Vector F(1, 2);
+ return Values(UV, F, Df);
}
+
//=============================================================================
-Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
- math_Vector& F,
- math_Matrix& Df)
+Standard_Boolean Extrema_FuncExtCC::Values(const math_Vector& UV, math_Vector& F, math_Matrix& Df)
{
myU = UV(1);
myV = UV(2);
- if(Value(UV, F) == Standard_False) //Computes F, myDu, myDv
+ if (Value(UV, F) == Standard_False) // Computes F, myDu, myDv
{
- //Warning: No function value found!
+ // Warning: No function value found!
return Standard_False;
- }//if(Value(UV, F) == Standard_False)
+ } // if(Value(UV, F) == Standard_False)
Vec Du, Dv, Duu, Dvv;
- Tool1::D2(*((Curve1*)myC1), myU,myP1,Du,Duu);
- Tool2::D2(*((Curve2*)myC2), myV,myP2,Dv,Dvv);
-
- //Calling of "Value(...)" function change class member values.
- //After running it is necessary to return to previous values.
- const Standard_Real myU_old = myU, myV_old = myV;
- const Pnt myP1_old = myP1, myP2_old = myP2;
- const Vec myDu_old = myDu, myDv_old = myDv;
+ Tool1::D2(*((Curve1*)myC1), myU, myP1, Du, Duu);
+ Tool2::D2(*((Curve2*)myC2), myV, myP2, Dv, Dvv);
+ // Calling of "Value(...)" function change class member values.
+ // After running it is necessary to return to previous values.
+ const Standard_Real myU_old = myU, myV_old = myV;
+ const Pnt myP1_old = myP1, myP2_old = myP2;
+ const Vec myDu_old = myDu, myDv_old = myDv;
- //Attention: aDelta value must be greater than same value for "Value(...)"
- // function to avoid of points' collisions.
+ // Attention: aDelta value must be greater than same value for "Value(...)"
+ // function to avoid of points' collisions.
const Standard_Real DivisionFactor = 0.01;
Standard_Real du;
- if((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
+ if ((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
du = 0.0;
else
- du = myUsupremum-myUinfium;
+ du = myUsupremum - myUinfium;
- const Standard_Real aDeltaU = Max(du*DivisionFactor,MinStep);
+ const Standard_Real aDeltaU = Max(du * DivisionFactor, MinStep);
Standard_Real dv;
- if((myVsupremum >= RealLast()) || (myVinfium <= RealFirst()))
+ if ((myVsupremum >= RealLast()) || (myVinfium <= RealFirst()))
dv = 0.0;
else
- dv = myVsupremum-myVinfium;
+ dv = myVsupremum - myVinfium;
- const Standard_Real aDeltaV = Max(dv*DivisionFactor,MinStep);
+ const Standard_Real aDeltaV = Max(dv * DivisionFactor, MinStep);
- Vec P1P2 (myP1,myP2);
+ Vec P1P2(myP1, myP2);
- if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
+ if ((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
{
- //Derivative is approximated by three points
+ // Derivative is approximated by three points
- math_Vector FF1(1,2), FF2(1,2), FF3(1,2);
+ math_Vector FF1(1, 2), FF2(1, 2), FF3(1, 2);
Standard_Real F1, F2, F3;
/////////////////////////// Search of DF1_u derivative (begin) ///////////////////
- if(myU-myUinfium < 2*aDeltaU)
+ if (myU - myUinfium < 2 * aDeltaU)
{
- F1=F(1);
- math_Vector UV2(1,2), UV3(1,2);
- UV2(1)=myU+aDeltaU;
- UV2(2)=myV;
- UV3(1)=myU+2*aDeltaU;
- UV3(2)=myV;
- if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
+ F1 = F(1);
+ math_Vector UV2(1, 2), UV3(1, 2);
+ UV2(1) = myU + aDeltaU;
+ UV2(2) = myV;
+ UV3(1) = myU + 2 * aDeltaU;
+ UV3(2) = myV;
+ if (!((Value(UV2, FF2)) && (Value(UV3, FF3))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F2 = FF2(1);
F3 = FF3(1);
- Df(1,1) = (-3*F1+4*F2-F3)/(2.0*aDeltaU);
- }//if(myU-myUinfium < 2*aDeltaU)
+ Df(1, 1) = (-3 * F1 + 4 * F2 - F3) / (2.0 * aDeltaU);
+ } // if(myU-myUinfium < 2*aDeltaU)
else
{
F3 = F(1);
- math_Vector UV2(1,2), UV1(1,2);
- UV2(1)=myU-aDeltaU;
- UV2(2)=myV;
- UV1(1)=myU-2*aDeltaU;
- UV1(2)=myV;
+ math_Vector UV2(1, 2), UV1(1, 2);
+ UV2(1) = myU - aDeltaU;
+ UV2(2) = myV;
+ UV1(1) = myU - 2 * aDeltaU;
+ UV1(2) = myV;
- if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
+ if (!((Value(UV2, FF2)) && (Value(UV1, FF1))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F1 = FF1(1);
F2 = FF2(1);
- Df(1,1) = (F1-4*F2+3*F3)/(2.0*aDeltaU);
- }//else of if(myU-myUinfium < 2*aDeltaU) condition
+ Df(1, 1) = (F1 - 4 * F2 + 3 * F3) / (2.0 * aDeltaU);
+ } // else of if(myU-myUinfium < 2*aDeltaU) condition
/////////////////////////// Search of DF1_u derivative (end) ///////////////////
- //Return to previous values
+ // Return to previous values
myU = myU_old;
myV = myV_old;
/////////////////////////// Search of DF1_v derivative (begin) ///////////////////
- if(myV-myVinfium < 2*aDeltaV)
+ if (myV - myVinfium < 2 * aDeltaV)
{
- F1=F(1);
- math_Vector UV2(1,2), UV3(1,2);
- UV2(1)=myU;
- UV2(2)=myV+aDeltaV;
- UV3(1)=myU;
- UV3(2)=myV+2*aDeltaV;
-
- if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
+ F1 = F(1);
+ math_Vector UV2(1, 2), UV3(1, 2);
+ UV2(1) = myU;
+ UV2(2) = myV + aDeltaV;
+ UV3(1) = myU;
+ UV3(2) = myV + 2 * aDeltaV;
+
+ if (!((Value(UV2, FF2)) && (Value(UV3, FF3))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F2 = FF2(1);
F3 = FF3(1);
- Df(1,2) = (-3*F1+4*F2-F3)/(2.0*aDeltaV);
- }//if(myV-myVinfium < 2*aDeltaV)
+ Df(1, 2) = (-3 * F1 + 4 * F2 - F3) / (2.0 * aDeltaV);
+ } // if(myV-myVinfium < 2*aDeltaV)
else
{
F3 = F(1);
- math_Vector UV2(1,2), UV1(1,2);
- UV2(1)=myU;
- UV2(2)=myV-aDeltaV;
- UV1(1)=myU;
- UV1(2)=myV-2*aDeltaV;
- if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
+ math_Vector UV2(1, 2), UV1(1, 2);
+ UV2(1) = myU;
+ UV2(2) = myV - aDeltaV;
+ UV1(1) = myU;
+ UV1(2) = myV - 2 * aDeltaV;
+ if (!((Value(UV2, FF2)) && (Value(UV1, FF1))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F1 = FF1(1);
F2 = FF2(1);
- Df(1,2) = (F1-4*F2+3*F3)/(2.0*aDeltaV);
- }//else of if(myV-myVinfium < 2*aDeltaV)
+ Df(1, 2) = (F1 - 4 * F2 + 3 * F3) / (2.0 * aDeltaV);
+ } // else of if(myV-myVinfium < 2*aDeltaV)
/////////////////////////// Search of DF1_v derivative (end) ///////////////////
- //Return to previous values
- myU = myU_old;
- myV = myV_old;
- myP1 = myP1_old, myP2 = myP2_old;
- myDu = myDu_old, myDv = myDv_old;
- }//if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
+ // Return to previous values
+ myU = myU_old;
+ myV = myV_old;
+ myP1 = myP1_old, myP2 = myP2_old;
+ myDu = myDu_old, myDv = myDv_old;
+ } // if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
else
{
const Standard_Real Ndu = myDu.Magnitude();
- Df(1,1) = - Ndu + (P1P2.Dot(Duu)/Ndu) - F(1)*(myDu.Dot(Duu)/(Ndu*Ndu));
- Df(1,2) = myDv.Dot(myDu)/Ndu;
- }//else of if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
+ Df(1, 1) = -Ndu + (P1P2.Dot(Duu) / Ndu) - F(1) * (myDu.Dot(Duu) / (Ndu * Ndu));
+ Df(1, 2) = myDv.Dot(myDu) / Ndu;
+ } // else of if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
- if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
+ if ((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
{
- //Derivative is approximated by three points
+ // Derivative is approximated by three points
- math_Vector FF1(1,2), FF2(1,2), FF3(1,2);
+ math_Vector FF1(1, 2), FF2(1, 2), FF3(1, 2);
Standard_Real F1, F2, F3;
/////////////////////////// Search of DF2_v derivative (begin) ///////////////////
- if(myV-myVinfium < 2*aDeltaV)
+ if (myV - myVinfium < 2 * aDeltaV)
{
- F1=F(2);
- math_Vector UV2(1,2), UV3(1,2);
- UV2(1)=myU;
- UV2(2)=myV+aDeltaV;
- UV3(1)=myU;
- UV3(2)=myV+2*aDeltaV;
-
- if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
+ F1 = F(2);
+ math_Vector UV2(1, 2), UV3(1, 2);
+ UV2(1) = myU;
+ UV2(2) = myV + aDeltaV;
+ UV3(1) = myU;
+ UV3(2) = myV + 2 * aDeltaV;
+
+ if (!((Value(UV2, FF2)) && (Value(UV3, FF3))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F2 = FF2(2);
F3 = FF3(2);
- Df(2,2) = (-3*F1+4*F2-F3)/(2.0*aDeltaV);
+ Df(2, 2) = (-3 * F1 + 4 * F2 - F3) / (2.0 * aDeltaV);
- }//if(myV-myVinfium < 2*aDeltaV)
+ } // if(myV-myVinfium < 2*aDeltaV)
else
{
F3 = F(2);
- math_Vector UV2(1,2), UV1(1,2);
- UV2(1)=myU;
- UV2(2)=myV-aDeltaV;
- UV1(1)=myU;
- UV1(2)=myV-2*aDeltaV;
+ math_Vector UV2(1, 2), UV1(1, 2);
+ UV2(1) = myU;
+ UV2(2) = myV - aDeltaV;
+ UV1(1) = myU;
+ UV1(2) = myV - 2 * aDeltaV;
- if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
+ if (!((Value(UV2, FF2)) && (Value(UV1, FF1))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F1 = FF1(2);
F2 = FF2(2);
- Df(2,2) = (F1-4*F2+3*F3)/(2.0*aDeltaV);
- }//else of if(myV-myVinfium < 2*aDeltaV)
+ Df(2, 2) = (F1 - 4 * F2 + 3 * F3) / (2.0 * aDeltaV);
+ } // else of if(myV-myVinfium < 2*aDeltaV)
/////////////////////////// Search of DF2_v derivative (end) ///////////////////
- //Return to previous values
+ // Return to previous values
myU = myU_old;
myV = myV_old;
/////////////////////////// Search of DF2_u derivative (begin) ///////////////////
- if(myU-myUinfium < 2*aDeltaU)
+ if (myU - myUinfium < 2 * aDeltaU)
{
- F1=F(2);
- math_Vector UV2(1,2), UV3(1,2);
- UV2(1)=myU+aDeltaU;
- UV2(2)=myV;
- UV3(1)=myU+2*aDeltaU;
- UV3(2)=myV;
- if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
+ F1 = F(2);
+ math_Vector UV2(1, 2), UV3(1, 2);
+ UV2(1) = myU + aDeltaU;
+ UV2(2) = myV;
+ UV3(1) = myU + 2 * aDeltaU;
+ UV3(2) = myV;
+ if (!((Value(UV2, FF2)) && (Value(UV3, FF3))))
{
- //There are many points close to singularity points and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F2 = FF2(2);
F3 = FF3(2);
- Df(2,1) = (-3*F1+4*F2-F3)/(2.0*aDeltaU);
- }//if(myU-myUinfium < 2*aDelta)
+ Df(2, 1) = (-3 * F1 + 4 * F2 - F3) / (2.0 * aDeltaU);
+ } // if(myU-myUinfium < 2*aDelta)
else
{
F3 = F(2);
- math_Vector UV2(1,2), UV1(1,2);
- UV2(1)=myU-aDeltaU;
- UV2(2)=myV;
- UV1(1)=myU-2*aDeltaU;
- UV1(2)=myV;
+ math_Vector UV2(1, 2), UV1(1, 2);
+ UV2(1) = myU - aDeltaU;
+ UV2(2) = myV;
+ UV1(1) = myU - 2 * aDeltaU;
+ UV1(2) = myV;
- if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
+ if (!((Value(UV2, FF2)) && (Value(UV1, FF1))))
{
- //There are many points close to singularity points
- //and which have zero-derivative.
- //Try to decrease aDelta variable's value.
+ // There are many points close to singularity points
+ // and which have zero-derivative.
+ // Try to decrease aDelta variable's value.
return Standard_False;
}
F1 = FF1(2);
F2 = FF2(2);
- Df(2,1) = (F1-4*F2+3*F3)/(2.0*aDeltaU);
- }//else of if(myU-myUinfium < 2*aDeltaU)
+ Df(2, 1) = (F1 - 4 * F2 + 3 * F3) / (2.0 * aDeltaU);
+ } // else of if(myU-myUinfium < 2*aDeltaU)
/////////////////////////// Search of DF2_u derivative (end) ///////////////////
- //Return to previous values
- myU = myU_old;
- myV = myV_old;
+ // Return to previous values
+ myU = myU_old;
+ myV = myV_old;
myP1 = myP1_old;
myP2 = myP2_old;
myDu = myDu_old;
myDv = myDv_old;
- }//if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
+ } // if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
else
{
Standard_Real Ndv = myDv.Magnitude();
- Df(2,2) = Ndv + (P1P2.Dot(Dvv)/Ndv) - F(2)*(myDv.Dot(Dvv)/(Ndv*Ndv));
- Df(2,1) = -myDu.Dot(myDv)/Ndv;
- }//else of if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
+ Df(2, 2) = Ndv + (P1P2.Dot(Dvv) / Ndv) - F(2) * (myDv.Dot(Dvv) / (Ndv * Ndv));
+ Df(2, 1) = -myDu.Dot(myDv) / Ndv;
+ } // else of if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
return Standard_True;
-}//end of function
+} // end of function
+
//=============================================================================
-Standard_Integer Extrema_FuncExtCC::GetStateNumber ()
+Standard_Integer Extrema_FuncExtCC::GetStateNumber()
{
- Vec Du (myDu), Dv (myDv);
- Vec P1P2 (myP1, myP2);
+ Vec Du(myDu), Dv(myDv);
+ Vec P1P2(myP1, myP2);
Standard_Real mod = Du.Magnitude();
- if(mod > myTolC1) {
+ if (mod > myTolC1)
+ {
Du /= mod;
}
mod = Dv.Magnitude();
- if(mod > myTolC2) {
+ if (mod > myTolC2)
+ {
Dv /= mod;
}
- if (Abs(P1P2.Dot(Du)) <= myTol && Abs(P1P2.Dot(Dv)) <= myTol) {
+ if (Abs(P1P2.Dot(Du)) <= myTol && Abs(P1P2.Dot(Dv)) <= myTol)
+ {
mySqDist.Append(myP1.SquareDistance(myP2));
myPoints.Append(POnC(myU, myP1));
myPoints.Append(POnC(myV, myP2));
}
return 0;
}
+
//=============================================================================
-void Extrema_FuncExtCC::Points (const Standard_Integer N,
- POnC& P1,
- POnC& P2) const
+void Extrema_FuncExtCC::Points(const Standard_Integer N, POnC& P1, POnC& P2) const
{
- P1 = myPoints.Value(2*N-1);
- P2 = myPoints.Value(2*N);
+ P1 = myPoints.Value(2 * N - 1);
+ P2 = myPoints.Value(2 * N);
}
+
//=============================================================================
void Extrema_FuncExtCC::SubIntervalInitialize(const math_Vector& theInfBound,
const math_Vector& theSupBound)
{
- myUinfium = theInfBound(1);
+ myUinfium = theInfBound(1);
myUsupremum = theSupBound(1);
- myVinfium = theInfBound(2);
+ myVinfium = theInfBound(2);
myVsupremum = theSupBound(2);
}
+
//=============================================================================
static const Standard_Integer MaxOrder = 3;
-
-
/*-----------------------------------------------------------------------------
Fonction permettant de rechercher une distance extremale entre un point P et
une courbe C (en partant d'un point approche C(u0)).
Standard_Real Extrema_FuncExtPC::SearchOfTolerance()
{
const Standard_Integer NPoint = 10;
- const Standard_Real aStep = (myUsupremum - myUinfium)/(Standard_Real)NPoint;
+ const Standard_Real aStep = (myUsupremum - myUinfium) / (Standard_Real)NPoint;
Standard_Integer aNum = 0;
- Standard_Real aMax = -Precision::Infinite(); //Maximum value of 1st derivative
+ Standard_Real aMax = -Precision::Infinite(); // Maximum value of 1st derivative
//(it is computed with using NPoint point)
do
{
- Standard_Real u = myUinfium + aNum*aStep; //parameter for every point
- if(u > myUsupremum)
+ Standard_Real u = myUinfium + aNum * aStep; // parameter for every point
+ if (u > myUsupremum)
u = myUsupremum;
- Pnt Ptemp; //empty point (is not used below)
- Vec VDer; // 1st derivative vector
+ Pnt Ptemp; // empty point (is not used below)
+ Vec VDer; // 1st derivative vector
Tool::D1(*((Curve*)myC), u, Ptemp, VDer);
- if(Precision::IsInfinite(VDer.X()) || Precision::IsInfinite(VDer.Y()))
+ if (Precision::IsInfinite(VDer.X()) || Precision::IsInfinite(VDer.Y()))
{
continue;
}
Standard_Real vm = VDer.Magnitude();
- if(vm > aMax)
+ if (vm > aMax)
aMax = vm;
- }
- while(++aNum < NPoint+1);
-
- return Max(aMax*TolFactor,MinTol);
+ } while (++aNum < NPoint + 1);
+ return Max(aMax * TolFactor, MinTol);
}
//=============================================================================
-Extrema_FuncExtPC::Extrema_FuncExtPC():
-myU(0.),
-myD1f(0.)
-{
- myPinit = Standard_False;
- myCinit = Standard_False;
+Extrema_FuncExtPC::Extrema_FuncExtPC()
+ : myU(0.),
+ myD1f(0.)
+{
+ myPinit = Standard_False;
+ myCinit = Standard_False;
myD1Init = Standard_False;
- SubIntervalInitialize(0.0,0.0);
+ SubIntervalInitialize(0.0, 0.0);
myMaxDerivOrder = 0;
- myTol=MinTol;
+ myTol = MinTol;
}
//=============================================================================
-Extrema_FuncExtPC::Extrema_FuncExtPC (const Pnt& P,
- const Curve& C): myU(0.), myD1f(0.)
+Extrema_FuncExtPC::Extrema_FuncExtPC(const Pnt& P, const Curve& C)
+ : myU(0.),
+ myD1f(0.)
{
- myP = P;
- myC = (Standard_Address)&C;
- myPinit = Standard_True;
- myCinit = Standard_True;
+ myP = P;
+ myC = (Standard_Address)&C;
+ myPinit = Standard_True;
+ myCinit = Standard_True;
myD1Init = Standard_False;
- SubIntervalInitialize(Tool::FirstParameter(*((Curve*)myC)),
- Tool::LastParameter(*((Curve*)myC)));
+ SubIntervalInitialize(Tool::FirstParameter(*((Curve*)myC)), Tool::LastParameter(*((Curve*)myC)));
- switch(Tool::GetType(*((Curve*)myC)))
+ switch (Tool::GetType(*((Curve*)myC)))
{
- case GeomAbs_BezierCurve:
- case GeomAbs_BSplineCurve:
- case GeomAbs_OffsetCurve:
- case GeomAbs_OtherCurve:
- myMaxDerivOrder = MaxOrder;
- myTol = SearchOfTolerance();
- break;
- default:
- myMaxDerivOrder = 0;
- myTol=MinTol;
- break;
+ case GeomAbs_BezierCurve:
+ case GeomAbs_BSplineCurve:
+ case GeomAbs_OffsetCurve:
+ case GeomAbs_OtherCurve:
+ myMaxDerivOrder = MaxOrder;
+ myTol = SearchOfTolerance();
+ break;
+ default:
+ myMaxDerivOrder = 0;
+ myTol = MinTol;
+ break;
}
}
+
//=============================================================================
void Extrema_FuncExtPC::Initialize(const Curve& C)
{
- myC = (Standard_Address)&C;
+ myC = (Standard_Address)&C;
myCinit = Standard_True;
myPoint.Clear();
mySqDist.Clear();
myIsMin.Clear();
- SubIntervalInitialize(Tool::FirstParameter(*((Curve*)myC)),
- Tool::LastParameter(*((Curve*)myC)));
+ SubIntervalInitialize(Tool::FirstParameter(*((Curve*)myC)), Tool::LastParameter(*((Curve*)myC)));
- switch(Tool::GetType(*((Curve*)myC)))
+ switch (Tool::GetType(*((Curve*)myC)))
{
- case GeomAbs_BezierCurve:
- case GeomAbs_BSplineCurve:
- case GeomAbs_OffsetCurve:
- case GeomAbs_OtherCurve:
- myMaxDerivOrder = MaxOrder;
- myTol = SearchOfTolerance();
- break;
- default:
- myMaxDerivOrder = 0;
- myTol=MinTol;
- break;
+ case GeomAbs_BezierCurve:
+ case GeomAbs_BSplineCurve:
+ case GeomAbs_OffsetCurve:
+ case GeomAbs_OtherCurve:
+ myMaxDerivOrder = MaxOrder;
+ myTol = SearchOfTolerance();
+ break;
+ default:
+ myMaxDerivOrder = 0;
+ myTol = MinTol;
+ break;
}
}
void Extrema_FuncExtPC::SetPoint(const Pnt& P)
{
- myP = P;
+ myP = P;
myPinit = Standard_True;
myPoint.Clear();
mySqDist.Clear();
//=============================================================================
-
-Standard_Boolean Extrema_FuncExtPC::Value (const Standard_Real U, Standard_Real& F)
+Standard_Boolean Extrema_FuncExtPC::Value(const Standard_Real U, Standard_Real& F)
{
if (!myPinit || !myCinit)
throw Standard_TypeMismatch("No init");
myU = U;
Vec D1c;
- Tool::D1(*((Curve*)myC),myU,myPc,D1c);
+ Tool::D1(*((Curve*)myC), myU, myPc, D1c);
- if(Precision::IsInfinite(D1c.X()) || Precision::IsInfinite(D1c.Y()))
+ if (Precision::IsInfinite(D1c.X()) || Precision::IsInfinite(D1c.Y()))
{
F = Precision::Infinite();
return Standard_False;
Standard_Real Ndu = D1c.Magnitude();
- if(myMaxDerivOrder != 0)
+ if (myMaxDerivOrder != 0)
{
if (Ndu <= myTol) // Cas Singulier (PMN 22/04/1998)
{
const Standard_Real DivisionFactor = 1.e-3;
- Standard_Real du;
- if((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
+ Standard_Real du;
+ if ((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
du = 0.0;
else
- du = myUsupremum-myUinfium;
+ du = myUsupremum - myUinfium;
- const Standard_Real aDelta = Max(du*DivisionFactor,MinStep);
- //Derivative is approximated by Taylor-series
+ const Standard_Real aDelta = Max(du * DivisionFactor, MinStep);
+ // Derivative is approximated by Taylor-series
- Standard_Integer n = 1; //Derivative order
- Vec V;
+ Standard_Integer n = 1; // Derivative order
+ Vec V;
Standard_Boolean IsDeriveFound;
do
{
- V = Tool::DN(*((Curve*)myC),myU,++n);
- Ndu = V.Magnitude();
+ V = Tool::DN(*((Curve*)myC), myU, ++n);
+ Ndu = V.Magnitude();
IsDeriveFound = (Ndu > myTol);
- }
- while(!IsDeriveFound && n < myMaxDerivOrder);
+ } while (!IsDeriveFound && n < myMaxDerivOrder);
- if(IsDeriveFound)
+ if (IsDeriveFound)
{
Standard_Real u;
- if(myU-myUinfium < aDelta)
- u = myU+aDelta;
+ if (myU - myUinfium < aDelta)
+ u = myU + aDelta;
else
- u = myU-aDelta;
+ u = myU - aDelta;
Pnt P1, P2;
- Tool::D0(*((Curve*)myC),Min(myU, u),P1);
- Tool::D0(*((Curve*)myC),Max(myU, u),P2);
+ Tool::D0(*((Curve*)myC), Min(myU, u), P1);
+ Tool::D0(*((Curve*)myC), Max(myU, u), P2);
- Vec V1(P1,P2);
+ Vec V1(P1, P2);
Standard_Real aDirFactor = V.Dot(V1);
- if(aDirFactor < 0.0)
+ if (aDirFactor < 0.0)
D1c = -V;
else
D1c = V;
- }//if(IsDeriveFound)
+ } // if(IsDeriveFound)
else
{
- //Derivative is approximated by three points
+ // Derivative is approximated by three points
- Pnt Ptemp; //(0,0,0)-coordinate
- Pnt P1, P2, P3;
+ Pnt Ptemp; //(0,0,0)-coordinate
+ Pnt P1, P2, P3;
Standard_Boolean IsParameterGrown;
- if(myU-myUinfium < 2*aDelta)
+ if (myU - myUinfium < 2 * aDelta)
{
- Tool::D0(*((Curve*)myC),myU,P1);
- Tool::D0(*((Curve*)myC),myU+aDelta,P2);
- Tool::D0(*((Curve*)myC),myU+2*aDelta,P3);
+ Tool::D0(*((Curve*)myC), myU, P1);
+ Tool::D0(*((Curve*)myC), myU + aDelta, P2);
+ Tool::D0(*((Curve*)myC), myU + 2 * aDelta, P3);
IsParameterGrown = Standard_True;
}
else
{
- Tool::D0(*((Curve*)myC),myU-2*aDelta,P1);
- Tool::D0(*((Curve*)myC),myU-aDelta,P2);
- Tool::D0(*((Curve*)myC),myU,P3);
+ Tool::D0(*((Curve*)myC), myU - 2 * aDelta, P1);
+ Tool::D0(*((Curve*)myC), myU - aDelta, P2);
+ Tool::D0(*((Curve*)myC), myU, P3);
IsParameterGrown = Standard_False;
}
- Vec V1(Ptemp,P1), V2(Ptemp,P2), V3(Ptemp,P3);
+ Vec V1(Ptemp, P1), V2(Ptemp, P2), V3(Ptemp, P3);
- if(IsParameterGrown)
- D1c=-3*V1+4*V2-V3;
+ if (IsParameterGrown)
+ D1c = -3 * V1 + 4 * V2 - V3;
else
- D1c=V1-4*V2+3*V3;
+ D1c = V1 - 4 * V2 + 3 * V3;
}
Ndu = D1c.Magnitude();
- }//(if (Ndu <= myTol)) condition
- }//if(myMaxDerivOrder != 0)
+ } //(if (Ndu <= myTol)) condition
+ } // if(myMaxDerivOrder != 0)
if (Ndu <= MinTol)
{
- //Warning: 1st derivative is equal to zero!
+ // Warning: 1st derivative is equal to zero!
return Standard_False;
}
- Vec PPc (myP,myPc);
- F = PPc.Dot(D1c)/Ndu;
+ Vec PPc(myP, myPc);
+ F = PPc.Dot(D1c) / Ndu;
return Standard_True;
}
//=============================================================================
-Standard_Boolean Extrema_FuncExtPC::Derivative (const Standard_Real U, Standard_Real& D1f)
+Standard_Boolean Extrema_FuncExtPC::Derivative(const Standard_Real U, Standard_Real& D1f)
{
- if (!myPinit || !myCinit) throw Standard_TypeMismatch();
+ if (!myPinit || !myCinit)
+ throw Standard_TypeMismatch();
Standard_Real F;
- return Values(U,F,D1f); /* on fait appel a Values pour simplifier la
- sauvegarde de l'etat. */
+ return Values(U, F, D1f); /* on fait appel a Values pour simplifier la
+ sauvegarde de l'etat. */
}
+
//=============================================================================
-Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U,
- Standard_Real& F,
- Standard_Real& D1f)
+Standard_Boolean Extrema_FuncExtPC::Values(const Standard_Real U,
+ Standard_Real& F,
+ Standard_Real& D1f)
{
if (!myPinit || !myCinit)
throw Standard_TypeMismatch("No init");
Pnt myPc_old = myPc, myP_old = myP;
- if(Value(U,F) == Standard_False)
+ if (Value(U, F) == Standard_False)
{
- //Warning: No function value found!;
+ // Warning: No function value found!;
myD1Init = Standard_False;
return Standard_False;
}
- myU = U;
+ myU = U;
myPc = myPc_old;
- myP = myP_old;
+ myP = myP_old;
- Vec D1c,D2c;
- Tool::D2(*((Curve*)myC),myU,myPc,D1c,D2c);
+ Vec D1c, D2c;
+ Tool::D2(*((Curve*)myC), myU, myPc, D1c, D2c);
Standard_Real Ndu = D1c.Magnitude();
if (Ndu <= myTol) // Cas Singulier (PMN 22/04/1998)
{
- //Derivative is approximated by three points
+ // Derivative is approximated by three points
- //Attention: aDelta value must be greater than same value for "Value(...)"
- // function to avoid of points' collisions.
+ // Attention: aDelta value must be greater than same value for "Value(...)"
+ // function to avoid of points' collisions.
const Standard_Real DivisionFactor = 0.01;
- Standard_Real du;
- if((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
+ Standard_Real du;
+ if ((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
du = 0.0;
else
- du = myUsupremum-myUinfium;
+ du = myUsupremum - myUinfium;
- const Standard_Real aDelta = Max(du*DivisionFactor,MinStep);
+ const Standard_Real aDelta = Max(du * DivisionFactor, MinStep);
Standard_Real F1, F2, F3;
- if(myU-myUinfium < 2*aDelta)
+ if (myU - myUinfium < 2 * aDelta)
{
- F1=F;
- //const Standard_Real U1 = myU;
+ F1 = F;
+ // const Standard_Real U1 = myU;
const Standard_Real U2 = myU + aDelta;
const Standard_Real U3 = myU + aDelta * 2.0;
- if(!((Value(U2,F2)) && (Value(U3,F3))))
+ if (!((Value(U2, F2)) && (Value(U3, F3))))
{
- //There are many points close to singularity points and
- //which have zero-derivative. Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and
+ // which have zero-derivative. Try to decrease aDelta variable's value.
myD1Init = Standard_False;
return Standard_False;
}
- //After calling of Value(...) function variable myU will be redeterminated.
- //So we must return it previous value.
- D1f=(-3*F1+4*F2-F3)/(2.0*aDelta);
+ // After calling of Value(...) function variable myU will be redeterminated.
+ // So we must return it previous value.
+ D1f = (-3 * F1 + 4 * F2 - F3) / (2.0 * aDelta);
}
else
{
- F3 = F;
+ F3 = F;
const Standard_Real U1 = myU - aDelta * 2.0;
const Standard_Real U2 = myU - aDelta;
- //const Standard_Real U3 = myU;
+ // const Standard_Real U3 = myU;
- if(!((Value(U2,F2)) && (Value(U1,F1))))
+ if (!((Value(U2, F2)) && (Value(U1, F1))))
{
- //There are many points close to singularity points and
- //which have zero-derivative. Try to decrease aDelta variable's value.
+ // There are many points close to singularity points and
+ // which have zero-derivative. Try to decrease aDelta variable's value.
myD1Init = Standard_False;
return Standard_False;
}
- //After calling of Value(...) function variable myU will be redeterminated.
- //So we must return it previous value.
- D1f=(F1-4*F2+3*F3)/(2.0*aDelta);
+ // After calling of Value(...) function variable myU will be redeterminated.
+ // So we must return it previous value.
+ D1f = (F1 - 4 * F2 + 3 * F3) / (2.0 * aDelta);
}
- myU = U;
+ myU = U;
myPc = myPc_old;
- myP = myP_old;
+ myP = myP_old;
}
else
{
- Vec PPc (myP,myPc);
- D1f = Ndu + (PPc.Dot(D2c)/Ndu) - F*(D1c.Dot(D2c))/(Ndu*Ndu);
+ Vec PPc(myP, myPc);
+ D1f = Ndu + (PPc.Dot(D2c) / Ndu) - F * (D1c.Dot(D2c)) / (Ndu * Ndu);
}
myD1f = D1f;
myD1Init = Standard_True;
return Standard_True;
}
+
//=============================================================================
-Standard_Integer Extrema_FuncExtPC::GetStateNumber ()
+Standard_Integer Extrema_FuncExtPC::GetStateNumber()
{
- if (!myPinit || !myCinit) throw Standard_TypeMismatch();
+ if (!myPinit || !myCinit)
+ throw Standard_TypeMismatch();
mySqDist.Append(myPc.SquareDistance(myP));
// It is necessary to always compute myD1f.
}
myIsMin.Append(IntVal);
- myPoint.Append(POnC(myU,myPc));
+ myPoint.Append(POnC(myU, myPc));
return 0;
}
+
//=============================================================================
-Standard_Integer Extrema_FuncExtPC::NbExt () const { return mySqDist.Length(); }
+Standard_Integer Extrema_FuncExtPC::NbExt() const
+{
+ return mySqDist.Length();
+}
+
//=============================================================================
-Standard_Real Extrema_FuncExtPC::SquareDistance (const Standard_Integer N) const
+Standard_Real Extrema_FuncExtPC::SquareDistance(const Standard_Integer N) const
{
- if (!myPinit || !myCinit) throw Standard_TypeMismatch();
+ if (!myPinit || !myCinit)
+ throw Standard_TypeMismatch();
return mySqDist.Value(N);
}
-//=============================================================================
-Standard_Boolean Extrema_FuncExtPC::IsMin (const Standard_Integer N) const
+
+//=================================================================================================
+
+Standard_Boolean Extrema_FuncExtPC::IsMin(const Standard_Integer N) const
{
- if (!myPinit || !myCinit) throw Standard_TypeMismatch();
+ if (!myPinit || !myCinit)
+ throw Standard_TypeMismatch();
return (myIsMin.Value(N) == 1);
}
-//=============================================================================
-const POnC & Extrema_FuncExtPC::Point (const Standard_Integer N) const
+
+//=================================================================================================
+
+const POnC& Extrema_FuncExtPC::Point(const Standard_Integer N) const
{
- if (!myPinit || !myCinit) throw Standard_TypeMismatch();
+ if (!myPinit || !myCinit)
+ throw Standard_TypeMismatch();
return myPoint.Value(N);
}
+
//=============================================================================
-void Extrema_FuncExtPC::SubIntervalInitialize(const Standard_Real theUfirst, const Standard_Real theUlast)
+void Extrema_FuncExtPC::SubIntervalInitialize(const Standard_Real theUfirst,
+ const Standard_Real theUlast)
{
- myUinfium = theUfirst;
+ myUinfium = theUfirst;
myUsupremum = theUlast;
}
#include <TColStd_HArray1OfReal.hxx>
#include <NCollection_Array1.hxx>
-
//=================================================================================================
void Extrema_GExtPC::Perform(const ThePoint& P)
mySqDist.Clear();
mypoint.Clear();
myismin.Clear();
- Standard_Integer i, NbExt, n;
- Standard_Real U;
- mysample = 17;
+ Standard_Integer i, NbExt, n;
+ Standard_Real U;
+ mysample = 17;
constexpr Standard_Real t3d = Precision::Confusion();
- if (Precision::IsInfinite(myuinf)) mydist1 = RealLast();
- else {
- Pf = TheCurveTool::Value(*((TheCurve*)myC), myuinf);
+ if (Precision::IsInfinite(myuinf))
+ mydist1 = RealLast();
+ else
+ {
+ Pf = TheCurveTool::Value(*((TheCurve*)myC), myuinf);
mydist1 = P.SquareDistance(Pf);
}
-
- if (Precision::IsInfinite(myusup)) mydist2 = RealLast();
- else {
- Pl = TheCurveTool::Value(*((TheCurve*)myC), myusup);
+
+ if (Precision::IsInfinite(myusup))
+ mydist2 = RealLast();
+ else
+ {
+ Pl = TheCurveTool::Value(*((TheCurve*)myC), myusup);
mydist2 = P.SquareDistance(Pl);
}
- TheCurve & aCurve = *((TheCurve*)myC);
+ TheCurve& aCurve = *((TheCurve*)myC);
- switch(type) {
- case GeomAbs_Circle:
- {
+ switch (type)
+ {
+ case GeomAbs_Circle: {
myExtPElC.Perform(P, TheCurveTool::Circle(aCurve), t3d, myuinf, myusup);
}
break;
- case GeomAbs_Ellipse:
- {
+ case GeomAbs_Ellipse: {
myExtPElC.Perform(P, TheCurveTool::Ellipse(aCurve), t3d, myuinf, myusup);
}
break;
- case GeomAbs_Parabola:
- {
- myExtPElC.Perform(P, TheCurveTool::Parabola(aCurve), t3d,myuinf,myusup);
+ case GeomAbs_Parabola: {
+ myExtPElC.Perform(P, TheCurveTool::Parabola(aCurve), t3d, myuinf, myusup);
}
break;
- case GeomAbs_Hyperbola:
- {
- myExtPElC.Perform(P,TheCurveTool::Hyperbola(aCurve),t3d, myuinf, myusup);
+ case GeomAbs_Hyperbola: {
+ myExtPElC.Perform(P, TheCurveTool::Hyperbola(aCurve), t3d, myuinf, myusup);
}
break;
- case GeomAbs_Line:
- {
+ case GeomAbs_Line: {
myExtPElC.Perform(P, TheCurveTool::Line(aCurve), t3d, myuinf, myusup);
}
break;
- case GeomAbs_BezierCurve:
- {
+ case GeomAbs_BezierCurve: {
myintuinf = myuinf;
myintusup = myusup;
- mysample = (TheCurveTool::Bezier(aCurve))->NbPoles() * 2;
+ mysample = (TheCurveTool::Bezier(aCurve))->NbPoles() * 2;
myExtPC.Initialize(aCurve);
IntervalPerform(P);
return;
}
- case GeomAbs_BSplineCurve:
- {
- const Standard_Integer
- aFirstIdx = TheCurveTool::BSpline(aCurve)->FirstUKnotIndex(),
- aLastIdx = TheCurveTool::BSpline(aCurve)->LastUKnotIndex();
+ case GeomAbs_BSplineCurve: {
+ const Standard_Integer aFirstIdx = TheCurveTool::BSpline(aCurve)->FirstUKnotIndex(),
+ aLastIdx = TheCurveTool::BSpline(aCurve)->LastUKnotIndex();
// const reference can not be used due to implementation of BRep_Adaptor.
TColStd_Array1OfReal aKnots(aFirstIdx, aLastIdx);
- TheCurveTool::BSpline(aCurve)->Knots(aKnots);
+ TheCurveTool::BSpline(aCurve)->Knots(aKnots);
// Workaround to work with:
// blend, where knots may be moved from parameter space.
if (TheCurveTool::IsPeriodic(aCurve))
{
Standard_Integer aPeriodShift =
- Standard_Integer ((myuinf - aKnots(aFirstIdx)) / TheCurveTool::Period(aCurve));
-
+ Standard_Integer((myuinf - aKnots(aFirstIdx)) / TheCurveTool::Period(aCurve));
+
if (myuinf < aKnots(aFirstIdx) - aTolCoeff)
aPeriodShift--;
Standard_Integer anIdx;
// Find first and last used knot.
- Standard_Integer aFirstUsedKnot = aFirstIdx,
- aLastUsedKnot = aLastIdx;
- for(anIdx = aFirstIdx; anIdx <= aLastIdx; anIdx++)
+ Standard_Integer aFirstUsedKnot = aFirstIdx, aLastUsedKnot = aLastIdx;
+ for (anIdx = aFirstIdx; anIdx <= aLastIdx; anIdx++)
{
Standard_Real aKnot = aKnots(anIdx) + aPeriodJump;
if (myuinf >= aKnot - aTolCoeff)
aFirstUsedKnot = anIdx;
else
break;
-
}
- for(anIdx = aLastIdx; anIdx >= aFirstIdx; anIdx--)
+ for (anIdx = aLastIdx; anIdx >= aFirstIdx; anIdx--)
{
Standard_Real aKnot = aKnots(anIdx) + aPeriodJump;
if (myusup <= aKnot + aTolCoeff)
if (mysample == 2)
{
- //BSpline of first degree, direct searching extrema for each knot interval
- ThePoint aPmin;
+ // BSpline of first degree, direct searching extrema for each knot interval
+ ThePoint aPmin;
Standard_Real tmin = 0., distmin = RealLast();
Standard_Real aMin1 = 0., aMin2 = 0.;
myExtPC.Initialize(aCurve);
for (anIdx = aFirstUsedKnot; anIdx < aLastUsedKnot; anIdx++)
{
- Standard_Real aF = aKnots(anIdx) + aPeriodJump,
- aL = aKnots(anIdx + 1) + aPeriodJump;
+ Standard_Real aF = aKnots(anIdx) + aPeriodJump, aL = aKnots(anIdx + 1) + aPeriodJump;
if (anIdx == aFirstUsedKnot)
{
aF = myuinf;
}
- else
- if (anIdx == aLastUsedKnot - 1)
+ else if (anIdx == aLastUsedKnot - 1)
{
aL = myusup;
}
-
ThePoint aP1, aP2;
TheCurveTool::D0(aCurve, aF, aP1);
TheCurveTool::D0(aCurve, aL, aP2);
- TheVector aBase1(P, aP1), aBase2(P, aP2);
- TheVector aV(aP2, aP1);
+ TheVector aBase1(P, aP1), aBase2(P, aP2);
+ TheVector aV(aP2, aP1);
Standard_Real aVal1 = aV.Dot(aBase1); // Derivative of (C(u) - P)^2
Standard_Real aVal2 = aV.Dot(aBase2); // Derivative of (C(u) - P)^2
if (anIdx == aFirstUsedKnot)
}
else
{
- aMin1 = aMin2;
+ aMin1 = aMin2;
if (distmin > aMin1)
{
distmin = aMin1;
- tmin = aF;
- aPmin = aP1;
+ tmin = aF;
+ aPmin = aP1;
}
}
- aMin2 = P.SquareDistance(aP2);
+ aMin2 = P.SquareDistance(aP2);
Standard_Real aMinSqDist = Min(aMin1, aMin2);
- Standard_Real aMinDer = Min(Abs(aVal1), Abs(aVal2));
+ Standard_Real aMinDer = Min(Abs(aVal1), Abs(aVal2));
if (!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2)))
{
- // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
- if (aVal1 * aVal2 <= 0.0 ||
- aMinSqDist < 100. * Precision::SquareConfusion() ||
- 2.*aMinDer < Precision::Confusion())
+ // Derivatives have opposite signs - min or max inside of interval (sufficient
+ // condition).
+ if (aVal1 * aVal2 <= 0.0 || aMinSqDist < 100. * Precision::SquareConfusion()
+ || 2. * aMinDer < Precision::Confusion())
{
myintuinf = aF;
myintusup = aL;
if (!Precision::IsInfinite(distmin))
{
Standard_Boolean isToAdd = Standard_True;
- NbExt = mypoint.Length();
+ NbExt = mypoint.Length();
for (i = 1; i <= NbExt && isToAdd; i++)
{
Standard_Real t = mypoint.Value(i).Parameter();
- isToAdd = (distmin < mySqDist(i)) && (Abs(t - tmin) > mytolu);
+ isToAdd = (distmin < mySqDist(i)) && (Abs(t - tmin) > mytolu);
}
if (isToAdd)
{
{
// Fill sample points.
- Standard_Integer aValIdx = 1;
- NCollection_Array1<Standard_Real> aVal(1, (mysample)* (aLastUsedKnot - aFirstUsedKnot) + 1);
- NCollection_Array1<Standard_Real> aParam(1, (mysample)* (aLastUsedKnot - aFirstUsedKnot) + 1);
+ Standard_Integer aValIdx = 1;
+ NCollection_Array1<Standard_Real> aVal(1,
+ (mysample) * (aLastUsedKnot - aFirstUsedKnot) + 1);
+ NCollection_Array1<Standard_Real> aParam(1,
+ (mysample) * (aLastUsedKnot - aFirstUsedKnot) + 1);
for (anIdx = aFirstUsedKnot; anIdx < aLastUsedKnot; anIdx++)
{
- Standard_Real aF = aKnots(anIdx) + aPeriodJump,
- aL = aKnots(anIdx + 1) + aPeriodJump;
+ Standard_Real aF = aKnots(anIdx) + aPeriodJump, aL = aKnots(anIdx + 1) + aPeriodJump;
if (anIdx == aFirstUsedKnot)
aF = myuinf;
for (Standard_Integer aPntIdx = 0; aPntIdx < mysample; aPntIdx++)
{
Standard_Real aCurrentParam = aF + aStep * aPntIdx;
- aVal(aValIdx) = TheCurveTool::Value(aCurve, aCurrentParam).SquareDistance(P);
+ aVal(aValIdx) = TheCurveTool::Value(aCurve, aCurrentParam).SquareDistance(P);
aParam(aValIdx) = aCurrentParam;
aValIdx++;
}
}
// Fill last point.
- aVal(aValIdx) = TheCurveTool::Value(aCurve, myusup).SquareDistance(P);
+ aVal(aValIdx) = TheCurveTool::Value(aCurve, myusup).SquareDistance(P);
aParam(aValIdx) = myusup;
myExtPC.Initialize(aCurve);
myismin.Append(Standard_True);
mypoint.Append(ThePOnC(aParam(anIdx), TheCurveTool::Value(aCurve, aParam(anIdx))));
}
- if ((aVal(anIdx) >= aVal(anIdx + 1) &&
- aVal(anIdx) >= aVal(anIdx - 1)) ||
- (aVal(anIdx) <= aVal(anIdx + 1) &&
- aVal(anIdx) <= aVal(anIdx - 1)))
+ if ((aVal(anIdx) >= aVal(anIdx + 1) && aVal(anIdx) >= aVal(anIdx - 1))
+ || (aVal(anIdx) <= aVal(anIdx + 1) && aVal(anIdx) <= aVal(anIdx - 1)))
{
myintuinf = aParam(anIdx - 1);
myintusup = aParam(anIdx + 1);
// Solve on the first and last intervals.
if (mydist1 > Precision::SquareConfusion() && !Precision::IsPositiveInfinite(mydist1))
{
- ThePoint aP1, aP2;
+ ThePoint aP1, aP2;
TheVector aV1, aV2;
TheCurveTool::D1(aCurve, aParam.Value(aParam.Lower()), aP1, aV1);
TheCurveTool::D1(aCurve, aParam.Value(aParam.Lower() + 1), aP2, aV2);
- TheVector aBase1(P, aP1), aBase2(P, aP2);
+ TheVector aBase1(P, aP1), aBase2(P, aP2);
Standard_Real aVal1 = aV1.Dot(aBase1); // Derivative of (C(u) - P)^2
Standard_Real aVal2 = aV2.Dot(aBase2); // Derivative of (C(u) - P)^2
if (!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2)))
{
- // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
- // Necessary condition - when point lies on curve.
- // Necessary condition - when derivative of point is too small.
- if (aVal1 * aVal2 <= 0.0 ||
- aBase1.Dot(aBase2) <= 0.0 ||
- 2.0 * Abs(aVal1) < Precision::Confusion())
+ // Derivatives have opposite signs - min or max inside of interval (sufficient
+ // condition). Necessary condition - when point lies on curve. Necessary condition -
+ // when derivative of point is too small.
+ if (aVal1 * aVal2 <= 0.0 || aBase1.Dot(aBase2) <= 0.0
+ || 2.0 * Abs(aVal1) < Precision::Confusion())
{
myintuinf = aParam(aVal.Lower());
myintusup = aParam(aVal.Lower() + 1);
if (mydist2 > Precision::SquareConfusion() && !Precision::IsPositiveInfinite(mydist2))
{
- ThePoint aP1, aP2;
+ ThePoint aP1, aP2;
TheVector aV1, aV2;
TheCurveTool::D1(aCurve, aParam.Value(aParam.Upper() - 1), aP1, aV1);
TheCurveTool::D1(aCurve, aParam.Value(aParam.Upper()), aP2, aV2);
- TheVector aBase1(P, aP1), aBase2(P, aP2);
+ TheVector aBase1(P, aP1), aBase2(P, aP2);
Standard_Real aVal1 = aV1.Dot(aBase1); // Derivative of (C(u) - P)^2
Standard_Real aVal2 = aV2.Dot(aBase2); // Derivative of (C(u) - P)^2
if (!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2)))
{
- // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
- // Necessary condition - when point lies on curve.
- // Necessary condition - when derivative of point is too small.
- if (aVal1 * aVal2 <= 0.0 ||
- aBase1.Dot(aBase2) <= 0.0 ||
- 2.0 * Abs(aVal2) < Precision::Confusion())
+ // Derivatives have opposite signs - min or max inside of interval (sufficient
+ // condition). Necessary condition - when point lies on curve. Necessary condition -
+ // when derivative of point is too small.
+ if (aVal1 * aVal2 <= 0.0 || aBase1.Dot(aBase2) <= 0.0
+ || 2.0 * Abs(aVal2) < Precision::Confusion())
{
myintuinf = aParam(aVal.Upper() - 1);
myintusup = aParam(aVal.Upper());
mydone = Standard_True;
break;
}
- default:
- {
- const Standard_Integer aMaxSample = 17;
- Standard_Boolean IntExtIsDone = Standard_False;
- Standard_Boolean IntIsNotValid;
+ default: {
+ const Standard_Integer aMaxSample = 17;
+ Standard_Boolean IntExtIsDone = Standard_False;
+ Standard_Boolean IntIsNotValid;
Handle(TColStd_HArray1OfReal) theHInter;
n = TheCurveTool::NbIntervals(aCurve, GeomAbs_C2);
if (n > 1)
else
{
theHInter = TheCurveTool::DeflCurvIntervals(aCurve);
- n = theHInter->Length() - 1;
+ n = theHInter->Length() - 1;
}
- mysample = Max(mysample / n, aMaxSample);
+ mysample = Max(mysample / n, aMaxSample);
Standard_Real maxint = 0.;
for (i = 1; i <= n; ++i)
{
}
}
Standard_Boolean isPeriodic = TheCurveTool::IsPeriodic(aCurve);
- TheVector V1;
- ThePoint PP;
- Standard_Real s1 = 0.0 ;
- Standard_Real s2 = 0.0;
+ TheVector V1;
+ ThePoint PP;
+ Standard_Real s1 = 0.0;
+ Standard_Real s2 = 0.0;
myExtPC.Initialize(aCurve);
for (i = 1; i <= n; i++)
{
myintuinf = theHInter->Value(i);
- myintusup = theHInter->Value(i+1);
- mysample = Max(RealToInt(aMaxSample*(myintusup - myintuinf) / maxint), 3);
-
+ myintusup = theHInter->Value(i + 1);
+ mysample = Max(RealToInt(aMaxSample * (myintusup - myintuinf) / maxint), 3);
+
Standard_Real anInfToCheck = myintuinf;
- Standard_Real aSupToCheck = myintusup;
-
- if (isPeriodic) {
+ Standard_Real aSupToCheck = myintusup;
+
+ if (isPeriodic)
+ {
Standard_Real aPeriod = TheCurveTool::Period(aCurve);
- anInfToCheck = ElCLib::InPeriod(myintuinf, myuinf, myuinf+aPeriod);
- aSupToCheck = myintusup+(anInfToCheck-myintuinf);
- }
+ anInfToCheck = ElCLib::InPeriod(myintuinf, myuinf, myuinf + aPeriod);
+ aSupToCheck = myintusup + (anInfToCheck - myintuinf);
+ }
IntIsNotValid = (myuinf > aSupToCheck) || (myusup < anInfToCheck);
- if(IntIsNotValid) continue;
+ if (IntIsNotValid)
+ continue;
+
+ if (myuinf >= anInfToCheck)
+ anInfToCheck = myuinf;
+ if (myusup <= aSupToCheck)
+ aSupToCheck = myusup;
+ if ((aSupToCheck - anInfToCheck) <= mytolu)
+ continue;
- if (myuinf >= anInfToCheck) anInfToCheck = myuinf;
- if (myusup <= aSupToCheck) aSupToCheck = myusup;
- if((aSupToCheck - anInfToCheck) <= mytolu) continue;
-
if (i != 1)
- {
+ {
TheCurveTool::D1(aCurve, myintuinf, PP, V1);
- s1 = (TheVector(P, PP))*V1;
- if (s1*s2 < 0.0) {
+ s1 = (TheVector(P, PP)) * V1;
+ if (s1 * s2 < 0.0)
+ {
mySqDist.Append(PP.SquareDistance(P));
myismin.Append((s1 < 0.0));
mypoint.Append(ThePOnC(myintuinf, PP));
}
}
- if (i != n) {
+ if (i != n)
+ {
TheCurveTool::D1(aCurve, myintusup, PP, V1);
- s2 = (TheVector(P, PP))*V1;
+ s2 = (TheVector(P, PP)) * V1;
}
IntervalPerform(P);
}
// Postprocessing.
- if (type == GeomAbs_BSplineCurve ||
- type == GeomAbs_OffsetCurve ||
- type == GeomAbs_OtherCurve)
+ if (type == GeomAbs_BSplineCurve || type == GeomAbs_OffsetCurve || type == GeomAbs_OtherCurve)
{
// Additional checking if the point is on the first or last point of the curve
// and does not added yet.
- if (mydist1 < Precision::SquareConfusion() ||
- mydist2 < Precision::SquareConfusion())
+ if (mydist1 < Precision::SquareConfusion() || mydist2 < Precision::SquareConfusion())
{
Standard_Boolean isFirstAdded = Standard_False;
Standard_Boolean isLastAdded = Standard_False;
- Standard_Integer aNbPoints = mypoint.Length();
+ Standard_Integer aNbPoints = mypoint.Length();
for (i = 1; i <= aNbPoints; i++)
{
U = mypoint.Value(i).Parameter();
{
// Verification de la validite des parametres:
ThePOnC PC = myExtPElC.Point(i);
- U = PC.Parameter();
+ U = PC.Parameter();
if (TheCurveTool::IsPeriodic(aCurve))
{
- U = ElCLib::InPeriod(U, myuinf, myuinf+TheCurveTool::Period(aCurve));
+ U = ElCLib::InPeriod(U, myuinf, myuinf + TheCurveTool::Period(aCurve));
}
- if ((U >= myuinf-mytolu) && (U <= myusup+mytolu))
+ if ((U >= myuinf - mytolu) && (U <= myusup + mytolu))
{
PC.SetValues(U, myExtPElC.Point(i).Value());
mySqDist.Append(myExtPElC.SquareDistance(i));
}
}
-
//=================================================================================================
-
void Extrema_GExtPC::Initialize(const TheCurve& C,
- const Standard_Real Uinf,
- const Standard_Real Usup,
- const Standard_Real TolF)
+ const Standard_Real Uinf,
+ const Standard_Real Usup,
+ const Standard_Real TolF)
{
- myC = (Standard_Address)&C;
+ myC = (Standard_Address)&C;
myintuinf = myuinf = Uinf;
myintusup = myusup = Usup;
- mytolf = TolF;
- mytolu = TheCurveTool::Resolution(*((TheCurve*)myC), Precision::Confusion());
- type = TheCurveTool::GetType(C);
- mydone = Standard_False;
- mydist1 = RealLast();
- mydist2 = RealLast();
- mysample = 17;
+ mytolf = TolF;
+ mytolu = TheCurveTool::Resolution(*((TheCurve*)myC), Precision::Confusion());
+ type = TheCurveTool::GetType(C);
+ mydone = Standard_False;
+ mydist1 = RealLast();
+ mydist2 = RealLast();
+ mysample = 17;
}
-
//=================================================================================================
-
void Extrema_GExtPC::IntervalPerform(const ThePoint& P)
{
Standard_Integer i;
- Standard_Real U;
+ Standard_Real U;
myExtPC.Initialize(mysample, myintuinf, myintusup, mytolu, mytolf);
myExtPC.Perform(P);
mydone = myExtPC.IsDone();
{
// Verification de la validite des parametres pour le cas trimme:
ThePOnC PC = myExtPC.Point(i);
- U = PC.Parameter();
+ U = PC.Parameter();
if (TheCurveTool::IsPeriodic(*((TheCurve*)myC)))
{
- U = ElCLib::InPeriod(U, myuinf, myuinf+TheCurveTool::Period(*((TheCurve*)myC)));
+ U = ElCLib::InPeriod(U, myuinf, myuinf + TheCurveTool::Period(*((TheCurve*)myC)));
}
if ((U >= myuinf - mytolu) && (U <= myusup + mytolu))
{
- AddSol(U, PC.Value(),
- myExtPC.SquareDistance(i),
- myExtPC.IsMin(i));
+ AddSol(U, PC.Value(), myExtPC.SquareDistance(i), myExtPC.IsMin(i));
}
}
}
}
-
//=================================================================================================
-
-void Extrema_GExtPC::AddSol(const Standard_Real theU, const ThePoint& theP,
- const Standard_Real theSqDist,
+void Extrema_GExtPC::AddSol(const Standard_Real theU,
+ const ThePoint& theP,
+ const Standard_Real theSqDist,
const Standard_Boolean isMin)
{
Standard_Integer i, NbExt = mypoint.Length();
mySqDist.Append(theSqDist);
myismin.Append(isMin);
mypoint.Append(PC);
-
- }
-
+}
//=================================================================================================
-
Extrema_GExtPC::Extrema_GExtPC()
{
- myC = 0;
- mydone = Standard_False;
- mydist1 = RealLast();
- mydist2 = RealLast();
- mytolu = 0.0;
- mytolf = 0.0;
- mysample = 17;
+ myC = 0;
+ mydone = Standard_False;
+ mydist1 = RealLast();
+ mydist2 = RealLast();
+ mytolu = 0.0;
+ mytolf = 0.0;
+ mysample = 17;
myintuinf = myintusup = myuinf = myusup = Precision::Infinite();
- type = GeomAbs_OtherCurve;
+ type = GeomAbs_OtherCurve;
}
//=================================================================================================
-
-Extrema_GExtPC::Extrema_GExtPC(const ThePoint& P,
- const TheCurve& C,
- const Standard_Real Uinf,
- const Standard_Real Usup,
- const Standard_Real TolF)
+Extrema_GExtPC::Extrema_GExtPC(const ThePoint& P,
+ const TheCurve& C,
+ const Standard_Real Uinf,
+ const Standard_Real Usup,
+ const Standard_Real TolF)
{
Initialize(C, Uinf, Usup, TolF);
Perform(P);
//=================================================================================================
-
-Extrema_GExtPC::Extrema_GExtPC(const ThePoint& P,
- const TheCurve& C,
- const Standard_Real TolF)
+Extrema_GExtPC::Extrema_GExtPC(const ThePoint& P, const TheCurve& C, const Standard_Real TolF)
{
- Initialize(C, TheCurveTool::FirstParameter(C),
- TheCurveTool::LastParameter(C), TolF);
+ Initialize(C, TheCurveTool::FirstParameter(C), TheCurveTool::LastParameter(C), TolF);
Perform(P);
}
-
//=================================================================================================
-
Standard_Boolean Extrema_GExtPC::IsDone() const
{
return mydone;
}
-
//=================================================================================================
-
-Standard_Real Extrema_GExtPC::SquareDistance(const Standard_Integer N) const
+Standard_Real Extrema_GExtPC::SquareDistance(const Standard_Integer N) const
{
- if ((N < 1) || (N > NbExt())) throw Standard_OutOfRange();
+ if ((N < 1) || (N > NbExt()))
+ throw Standard_OutOfRange();
return mySqDist.Value(N);
}
-
//=================================================================================================
-
Standard_Integer Extrema_GExtPC::NbExt() const
{
- if (!IsDone()) throw StdFail_NotDone();
+ if (!IsDone())
+ throw StdFail_NotDone();
return mySqDist.Length();
}
-
//=================================================================================================
-
Standard_Boolean Extrema_GExtPC::IsMin(const Standard_Integer N) const
{
- if ((N < 1) || (N > NbExt())) throw Standard_OutOfRange();
+ if ((N < 1) || (N > NbExt()))
+ throw Standard_OutOfRange();
return myismin.Value(N);
}
-
-
//=================================================================================================
-
-const ThePOnC & Extrema_GExtPC::Point(const Standard_Integer N) const
+const ThePOnC& Extrema_GExtPC::Point(const Standard_Integer N) const
{
- if ((N < 1) || (N > NbExt())) throw Standard_OutOfRange();
+ if ((N < 1) || (N > NbExt()))
+ throw Standard_OutOfRange();
return mypoint.Value(N);
}
-
//=================================================================================================
-
-void Extrema_GExtPC::TrimmedSquareDistances(Standard_Real& dist1,
- Standard_Real& dist2,
- ThePoint& P1,
- ThePoint& P2) const
+void Extrema_GExtPC::TrimmedSquareDistances(Standard_Real& dist1,
+ Standard_Real& dist2,
+ ThePoint& P1,
+ ThePoint& P2) const
{
dist1 = mydist1;
dist2 = mydist2;
- P1 = Pf;
- P2 = Pl;
+ P1 = Pf;
+ P2 = Pl;
}
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
-
//=================================================================================================
-
Extrema_GLocateExtPC::Extrema_GLocateExtPC()
-: myC(NULL),
- mydist2(0.0),
- myismin(Standard_False),
- myDone(Standard_False),
- myumin(0.0),
- myusup(0.0),
- mytol(0.0),
- type(GeomAbs_OtherCurve),
- numberext(0)
+ : myC(NULL),
+ mydist2(0.0),
+ myismin(Standard_False),
+ myDone(Standard_False),
+ myumin(0.0),
+ myusup(0.0),
+ mytol(0.0),
+ type(GeomAbs_OtherCurve),
+ numberext(0)
{
}
-
//=================================================================================================
-
-Extrema_GLocateExtPC::Extrema_GLocateExtPC (const ThePoint& P,
- const TheCurve& C,
- const Standard_Real U0,
- const Standard_Real TolF)
+Extrema_GLocateExtPC::Extrema_GLocateExtPC(const ThePoint& P,
+ const TheCurve& C,
+ const Standard_Real U0,
+ const Standard_Real TolF)
{
Initialize(C, TheCurveTool::FirstParameter(C), TheCurveTool::LastParameter(C), TolF);
Perform(P, U0);
//=================================================================================================
-
-Extrema_GLocateExtPC::Extrema_GLocateExtPC (const ThePoint& P,
- const TheCurve& C,
- const Standard_Real U0,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolF)
+Extrema_GLocateExtPC::Extrema_GLocateExtPC(const ThePoint& P,
+ const TheCurve& C,
+ const Standard_Real U0,
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolF)
{
Initialize(C, Umin, Usup, TolF);
Perform(P, U0);
}
-
-
//=================================================================================================
-
-void Extrema_GLocateExtPC::Initialize(const TheCurve& C,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolF)
+void Extrema_GLocateExtPC::Initialize(const TheCurve& C,
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolF)
{
- myC = (Standard_Address)&C;
- mytol = TolF;
- myumin = Umin;
- myusup = Usup;
- type = TheCurveTool::GetType(C);
+ myC = (Standard_Address)&C;
+ mytol = TolF;
+ myumin = Umin;
+ myusup = Usup;
+ type = TheCurveTool::GetType(C);
Standard_Real tolu = TheCurveTool::Resolution(C, Precision::Confusion());
- if ((type == GeomAbs_BSplineCurve) ||
- (type == GeomAbs_BezierCurve) ||
- (type == GeomAbs_OffsetCurve) ||
- (type == GeomAbs_OtherCurve))
+ if ((type == GeomAbs_BSplineCurve) || (type == GeomAbs_BezierCurve)
+ || (type == GeomAbs_OffsetCurve) || (type == GeomAbs_OtherCurve))
{
- myLocExtPC.Initialize(C, Umin, Usup, tolu);
+ myLocExtPC.Initialize(C, Umin, Usup, tolu);
}
- else {
+ else
+ {
myExtremPC.Initialize(C, Umin, Usup, tolu);
}
}
-
-
-
//=================================================================================================
-
-void Extrema_GLocateExtPC::Perform(const ThePoint& P,
- const Standard_Real U0)
+void Extrema_GLocateExtPC::Perform(const ThePoint& P, const Standard_Real U0)
{
Standard_Integer i, i1, i2, inter;
- Standard_Real Par, valU, valU2 = RealLast(),
- local_u0 ;
- Standard_Real myintuinf=0, myintusup=0;
- local_u0 = U0 ;
- switch(type)
+ Standard_Real Par, valU, valU2 = RealLast(), local_u0;
+ Standard_Real myintuinf = 0, myintusup = 0;
+ local_u0 = U0;
+ switch (type)
{
- case GeomAbs_OtherCurve:
- case GeomAbs_OffsetCurve:
- case GeomAbs_BSplineCurve:
- {
+ case GeomAbs_OtherCurve:
+ case GeomAbs_OffsetCurve:
+ case GeomAbs_BSplineCurve: {
// La recherche de l extremum est faite intervalle continu C2 par
// intervalle continu C2 de la courbe
- Standard_Integer n = TheCurveTool::NbIntervals(*((TheCurve*)myC), GeomAbs_C2);
- TColStd_Array1OfReal theInter(1, n+1);
+ Standard_Integer n = TheCurveTool::NbIntervals(*((TheCurve*)myC), GeomAbs_C2);
+ TColStd_Array1OfReal theInter(1, n + 1);
TheCurveTool::Intervals(*((TheCurve*)myC), theInter, GeomAbs_C2);
//
- // be gentle with the caller
+ // be gentle with the caller
//
- if (local_u0 < myumin) {
- local_u0 = myumin ;
+ if (local_u0 < myumin)
+ {
+ local_u0 = myumin;
}
- else if (local_u0 > myusup) {
- local_u0 = myusup ;
+ else if (local_u0 > myusup)
+ {
+ local_u0 = myusup;
}
// Recherche de l intervalle ou se trouve U0
Standard_Boolean found = Standard_False;
- inter = 1;
- while (!found && inter <= n) {
+ inter = 1;
+ while (!found && inter <= n)
+ {
// Intervalle commun a l intervalle C2 courant de la courbe et a
// l intervalle total de recherche de l'extremum (hla : au cas ou
// myintuinf > myintusup, c est que les 2 intervalles ne s intersectent
// pas, mais il n'y avait aucune raison de sortir en "return")
myintuinf = Max(theInter(inter), myumin);
- myintusup = Min(theInter(inter+1), myusup);
- if ((local_u0 >= myintuinf) && (local_u0 < myintusup)) found = Standard_True;
+ myintusup = Min(theInter(inter + 1), myusup);
+ if ((local_u0 >= myintuinf) && (local_u0 < myintusup))
+ found = Standard_True;
inter++;
}
- if( found ) inter--; //IFV 16.06.00 - inter is increased after found!
+ if (found)
+ inter--; // IFV 16.06.00 - inter is increased after found!
// Essai sur l intervalle trouve
- myLocExtPC.Initialize((*((TheCurve*)myC)), myintuinf,
- myintusup, mytol);
+ myLocExtPC.Initialize((*((TheCurve*)myC)), myintuinf, myintusup, mytol);
myLocExtPC.Perform(P, local_u0);
myDone = myLocExtPC.IsDone();
- if (myDone) {
- mypp = myLocExtPC.Point();
+ if (myDone)
+ {
+ mypp = myLocExtPC.Point();
myismin = myLocExtPC.IsMin();
mydist2 = myLocExtPC.SquareDistance();
}
- else {
+ else
+ {
Standard_Integer k = 1;
// Essai sur les intervalles alentours:
i1 = inter;
i2 = inter;
Standard_Real s1inf, s2inf, s1sup, s2sup;
- ThePoint P1;
- TheVector V1;
+ ThePoint P1;
+ TheVector V1;
TheCurveTool::D1(*((TheCurve*)myC), myintuinf, P1, V1);
- s2inf = (TheVector(P, P1)*V1);
+ s2inf = (TheVector(P, P1) * V1);
TheCurveTool::D1(*((TheCurve*)myC), myintusup, P1, V1);
- s1sup = (TheVector(P, P1)*V1);
-
+ s1sup = (TheVector(P, P1) * V1);
while (!myDone && (i2 > 0) && (i1 <= n))
{
if (i1 <= n)
{
myintuinf = Max(theInter(i1), myumin);
- myintusup = Min(theInter(i1+1), myusup);
+ myintusup = Min(theInter(i1 + 1), myusup);
if (myintuinf < myintusup)
{
TheCurveTool::D1(*((TheCurve*)myC), myintuinf, P1, V1);
- s2sup = (TheVector(P, P1)*V1);
- if(Precision::IsInfinite(s2sup) || Precision::IsInfinite(s1sup))
+ s2sup = (TheVector(P, P1) * V1);
+ if (Precision::IsInfinite(s2sup) || Precision::IsInfinite(s1sup))
{
break;
}
- if (s1sup*s2sup <= RealEpsilon())
+ if (s1sup * s2sup <= RealEpsilon())
{
// extremum:
myDone = Standard_True;
}
TheCurveTool::D1(*((TheCurve*)myC), myintusup, P1, V1);
- s1sup = (TheVector(P, P1)*V1);
- myLocExtPC.Initialize((*((TheCurve*)myC)), myintuinf,
- myintusup, mytol);
- myLocExtPC.Perform(P, (myintuinf + myintusup)*0.5);
+ s1sup = (TheVector(P, P1) * V1);
+ myLocExtPC.Initialize((*((TheCurve*)myC)), myintuinf, myintusup, mytol);
+ myLocExtPC.Perform(P, (myintuinf + myintusup) * 0.5);
myDone = myLocExtPC.IsDone();
- if (myDone) {
- mypp = myLocExtPC.Point();
+ if (myDone)
+ {
+ mypp = myLocExtPC.Point();
myismin = myLocExtPC.IsMin();
mydist2 = myLocExtPC.SquareDistance();
break;
if (i2 > 0)
{
myintuinf = Max(theInter(i2), myumin);
- myintusup = Min(theInter(i2+1), myusup);
+ myintusup = Min(theInter(i2 + 1), myusup);
if (myintuinf < myintusup)
{
TheCurveTool::D1(*((TheCurve*)myC), myintusup, P1, V1);
- s1inf = (TheVector(P, P1)*V1);
- if(Precision::IsInfinite(s2inf) || Precision::IsInfinite(s1inf))
+ s1inf = (TheVector(P, P1) * V1);
+ if (Precision::IsInfinite(s2inf) || Precision::IsInfinite(s1inf))
{
break;
}
- if (s1inf*s2inf <= RealEpsilon())
+ if (s1inf * s2inf <= RealEpsilon())
{
// extremum:
myDone = Standard_True;
}
TheCurveTool::D1(*((TheCurve*)myC), myintuinf, P1, V1);
- s2inf = (TheVector(P, P1)*V1);
- myLocExtPC.Initialize((*((TheCurve*)myC)), myintuinf,
- myintusup, mytol);
- myLocExtPC.Perform(P, (myintuinf+myintusup)*0.5 );
+ s2inf = (TheVector(P, P1) * V1);
+ myLocExtPC.Initialize((*((TheCurve*)myC)), myintuinf, myintusup, mytol);
+ myLocExtPC.Perform(P, (myintuinf + myintusup) * 0.5);
myDone = myLocExtPC.IsDone();
-
+
if (myDone)
{
- mypp = myLocExtPC.Point();
+ mypp = myLocExtPC.Point();
myismin = myLocExtPC.IsMin();
mydist2 = myLocExtPC.SquareDistance();
break;
break;
- case GeomAbs_BezierCurve:
- {
+ case GeomAbs_BezierCurve: {
myLocExtPC.Perform(P, U0);
myDone = myLocExtPC.IsDone();
}
break;
- default:
- {
+ default: {
myExtremPC.Perform(P);
numberext = 0;
if (myExtremPC.IsDone())
{
for (i = 1; i <= myExtremPC.NbExt(); i++)
{
- Par = myExtremPC.Point(i).Parameter();
+ Par = myExtremPC.Point(i).Parameter();
valU = Abs(Par - U0);
if (valU <= valU2)
{
- valU2 = valU;
+ valU2 = valU;
numberext = i;
- myDone = Standard_True;
+ myDone = Standard_True;
}
}
}
}
}
-
-
-
//=================================================================================================
-
-Standard_Boolean Extrema_GLocateExtPC::IsDone () const
+Standard_Boolean Extrema_GLocateExtPC::IsDone() const
{
return myDone;
}
-
//=================================================================================================
-
-Standard_Real Extrema_GLocateExtPC::SquareDistance () const
+Standard_Real Extrema_GLocateExtPC::SquareDistance() const
{
if (!IsDone())
{
throw StdFail_NotDone();
}
- Standard_Real d=0;
- if ((type == GeomAbs_BezierCurve)) {
- d = myLocExtPC.SquareDistance();
+ Standard_Real d = 0;
+ if ((type == GeomAbs_BezierCurve))
+ {
+ d = myLocExtPC.SquareDistance();
}
- else if(type == GeomAbs_BSplineCurve ||
- type == GeomAbs_OffsetCurve ||
- type == GeomAbs_OtherCurve) {
+ else if (type == GeomAbs_BSplineCurve || type == GeomAbs_OffsetCurve
+ || type == GeomAbs_OtherCurve)
+ {
d = mydist2;
}
- else {
- if (numberext != 0) {
+ else
+ {
+ if (numberext != 0)
+ {
d = myExtremPC.SquareDistance(numberext);
}
}
return d;
}
-
//=================================================================================================
-
-Standard_Boolean Extrema_GLocateExtPC::IsMin () const
+Standard_Boolean Extrema_GLocateExtPC::IsMin() const
{
if (!IsDone())
{
throw StdFail_NotDone();
}
Standard_Boolean b = 0;
- if ((type == GeomAbs_BezierCurve)) {
+ if ((type == GeomAbs_BezierCurve))
+ {
b = myLocExtPC.IsMin();
}
- else if(type == GeomAbs_BSplineCurve ||
- type == GeomAbs_OffsetCurve ||
- type == GeomAbs_OtherCurve) {
+ else if (type == GeomAbs_BSplineCurve || type == GeomAbs_OffsetCurve
+ || type == GeomAbs_OtherCurve)
+ {
b = myismin;
}
- else {
- if (numberext != 0) {
+ else
+ {
+ if (numberext != 0)
+ {
b = myExtremPC.IsMin(numberext);
}
}
return b;
}
-
//=================================================================================================
-
-const ThePOnC & Extrema_GLocateExtPC::Point () const
+const ThePOnC& Extrema_GLocateExtPC::Point() const
{
if (!IsDone())
{
{
return myLocExtPC.Point();
}
- else if(type == GeomAbs_BSplineCurve ||
- type == GeomAbs_OffsetCurve ||
- type == GeomAbs_OtherCurve) {
+ else if (type == GeomAbs_BSplineCurve || type == GeomAbs_OffsetCurve
+ || type == GeomAbs_OtherCurve)
+ {
return mypp;
}
return myExtremPC.Point(numberext);
#include <GCPnts_AbscissaPoint.hxx>
// Comparator, used in std::sort.
-static Standard_Boolean comp(const gp_XY& theA,
- const gp_XY& theB)
+static Standard_Boolean comp(const gp_XY& theA, const gp_XY& theB)
{
if (theA.X() < theB.X())
{
return Standard_False;
}
-static void ChangeIntervals(Handle(TColStd_HArray1OfReal)& theInts, const Standard_Integer theNbInts)
+static void ChangeIntervals(Handle(TColStd_HArray1OfReal)& theInts,
+ const Standard_Integer theNbInts)
{
- Standard_Integer aNbInts = theInts->Length() - 1;
- Standard_Integer aNbAdd = theNbInts - aNbInts;
+ Standard_Integer aNbInts = theInts->Length() - 1;
+ Standard_Integer aNbAdd = theNbInts - aNbInts;
Handle(TColStd_HArray1OfReal) aNewInts = new TColStd_HArray1OfReal(1, theNbInts + 1);
- Standard_Integer aNbLast = theInts->Length();
- Standard_Integer i;
+ Standard_Integer aNbLast = theInts->Length();
+ Standard_Integer i;
if (aNbInts == 1)
{
aNewInts->SetValue(1, theInts->First());
aNewInts->SetValue(theNbInts + 1, theInts->Last());
Standard_Real dt = (theInts->Last() - theInts->First()) / theNbInts;
- Standard_Real t = theInts->First() + dt;
+ Standard_Real t = theInts->First() + dt;
for (i = 2; i <= theNbInts; ++i, t += dt)
{
aNewInts->SetValue(i, t);
//
while (aNbAdd > 0)
{
- Standard_Real anLIntMax = -1.;
- Standard_Integer aMaxInd = -1;
+ Standard_Real anLIntMax = -1.;
+ Standard_Integer aMaxInd = -1;
for (i = 1; i < aNbLast; ++i)
{
Standard_Real anL = aNewInts->Value(i + 1) - aNewInts->Value(i);
if (anL > anLIntMax)
{
anLIntMax = anL;
- aMaxInd = i;
+ aMaxInd = i;
}
}
}
theInts = aNewInts;
}
+
class Extrema_CCPointsInspector : public NCollection_CellFilter_InspectorXY
{
public:
typedef gp_XY Target;
+
//! Constructor; remembers the tolerance
- Extrema_CCPointsInspector (const Standard_Real theTol)
+ Extrema_CCPointsInspector(const Standard_Real theTol)
{
- myTol = theTol * theTol;
+ myTol = theTol * theTol;
myIsFind = Standard_False;
}
- void ClearFind()
- {
- myIsFind = Standard_False;
- }
+ void ClearFind() { myIsFind = Standard_False; }
- Standard_Boolean isFind()
- {
- return myIsFind;
- }
+ Standard_Boolean isFind() { return myIsFind; }
//! Set current point to search for coincidence
- void SetCurrent (const gp_XY& theCurPnt)
- {
- myCurrent = theCurPnt;
- }
+ void SetCurrent(const gp_XY& theCurPnt) { myCurrent = theCurPnt; }
//! Implementation of inspection method
- NCollection_CellFilter_Action Inspect (const Target& theObject)
+ NCollection_CellFilter_Action Inspect(const Target& theObject)
{
- gp_XY aPt = myCurrent.Subtracted(theObject);
+ gp_XY aPt = myCurrent.Subtracted(theObject);
const Standard_Real aSQDist = aPt.SquareModulus();
- if(aSQDist < myTol)
+ if (aSQDist < myTol)
{
myIsFind = Standard_True;
}
}
private:
- Standard_Real myTol;
- gp_XY myCurrent;
+ Standard_Real myTol;
+ gp_XY myCurrent;
Standard_Boolean myIsFind;
};
//=======================================================================
-//function : ProjPOnC
-//purpose : Projects the point on the curve and returns the minimal
+// function : ProjPOnC
+// purpose : Projects the point on the curve and returns the minimal
// projection distance
//=======================================================================
-static Standard_Real ProjPOnC(const Pnt& theP,
- Extrema_GExtPC& theProjTool)
+static Standard_Real ProjPOnC(const Pnt& theP, Extrema_GExtPC& theProjTool)
{
Standard_Real aDist = ::RealLast();
theProjTool.Perform(theP);
//=================================================================================================
Extrema_GenExtCC::Extrema_GenExtCC()
-: myIsFindSingleSolution(Standard_False),
- myParallel(Standard_False),
- myCurveMinTol(Precision::PConfusion()),
- myLowBorder(1,2),
- myUppBorder(1,2),
- myDone(Standard_False)
+ : myIsFindSingleSolution(Standard_False),
+ myParallel(Standard_False),
+ myCurveMinTol(Precision::PConfusion()),
+ myLowBorder(1, 2),
+ myUppBorder(1, 2),
+ myDone(Standard_False)
{
myC[0] = myC[1] = 0;
}
//=================================================================================================
-Extrema_GenExtCC::Extrema_GenExtCC(const Curve1& C1,
- const Curve2& C2)
-: myIsFindSingleSolution(Standard_False),
- myParallel(Standard_False),
- myCurveMinTol(Precision::PConfusion()),
- myLowBorder(1,2),
- myUppBorder(1,2),
- myDone(Standard_False)
+Extrema_GenExtCC::Extrema_GenExtCC(const Curve1& C1, const Curve2& C2)
+ : myIsFindSingleSolution(Standard_False),
+ myParallel(Standard_False),
+ myCurveMinTol(Precision::PConfusion()),
+ myLowBorder(1, 2),
+ myUppBorder(1, 2),
+ myDone(Standard_False)
{
- myC[0] = (Standard_Address)&C1;
- myC[1] = (Standard_Address)&C2;
+ myC[0] = (Standard_Address)&C1;
+ myC[1] = (Standard_Address)&C2;
myLowBorder(1) = C1.FirstParameter();
myLowBorder(2) = C2.FirstParameter();
myUppBorder(1) = C1.LastParameter();
//=================================================================================================
-Extrema_GenExtCC::Extrema_GenExtCC(const Curve1& C1,
- const Curve2& C2,
+Extrema_GenExtCC::Extrema_GenExtCC(const Curve1& C1,
+ const Curve2& C2,
const Standard_Real Uinf,
const Standard_Real Usup,
const Standard_Real Vinf,
const Standard_Real Vsup)
-: myIsFindSingleSolution(Standard_False),
- myParallel(Standard_False),
- myCurveMinTol(Precision::PConfusion()),
- myLowBorder(1,2),
- myUppBorder(1,2),
- myDone(Standard_False)
+ : myIsFindSingleSolution(Standard_False),
+ myParallel(Standard_False),
+ myCurveMinTol(Precision::PConfusion()),
+ myLowBorder(1, 2),
+ myUppBorder(1, 2),
+ myDone(Standard_False)
{
- myC[0] = (Standard_Address)&C1;
- myC[1] = (Standard_Address)&C2;
+ myC[0] = (Standard_Address)&C1;
+ myC[1] = (Standard_Address)&C2;
myLowBorder(1) = Uinf;
myLowBorder(2) = Vinf;
myUppBorder(1) = Usup;
//=================================================================================================
-void Extrema_GenExtCC::SetParams(const Curve1& C1,
- const Curve2& C2,
+void Extrema_GenExtCC::SetParams(const Curve1& C1,
+ const Curve2& C2,
const Standard_Real Uinf,
const Standard_Real Usup,
const Standard_Real Vinf,
const Standard_Real Vsup)
{
- myC[0] = (Standard_Address)&C1;
- myC[1] = (Standard_Address)&C2;
+ myC[0] = (Standard_Address)&C1;
+ myC[1] = (Standard_Address)&C2;
myLowBorder(1) = Uinf;
myLowBorder(2) = Vinf;
myUppBorder(1) = Usup;
void Extrema_GenExtCC::Perform()
{
- myDone = Standard_False;
+ myDone = Standard_False;
myParallel = Standard_False;
- Curve1 &C1 = *(Curve1*)myC[0];
- Curve2 &C2 = *(Curve2*)myC[1];
+ Curve1& C1 = *(Curve1*)myC[0];
+ Curve2& C2 = *(Curve2*)myC[1];
Standard_Integer aNbInter[2];
- GeomAbs_Shape aContinuity = GeomAbs_C2;
- aNbInter[0] = C1.NbIntervals(aContinuity);
- aNbInter[1] = C2.NbIntervals(aContinuity);
+ GeomAbs_Shape aContinuity = GeomAbs_C2;
+ aNbInter[0] = C1.NbIntervals(aContinuity);
+ aNbInter[1] = C2.NbIntervals(aContinuity);
if (aNbInter[0] * aNbInter[1] > 100)
{
aNbInter[1] = C2.NbIntervals(aContinuity);
}
- Standard_Real anL[2];
- Standard_Integer indmax = -1, indmin = -1;
+ Standard_Real anL[2];
+ Standard_Integer indmax = -1, indmin = -1;
const Standard_Real mult = 20.;
- if (!(Precision::IsInfinite(C1.FirstParameter()) || Precision::IsInfinite(C1.LastParameter()) ||
- Precision::IsInfinite(C2.FirstParameter()) || Precision::IsInfinite(C2.LastParameter())))
+ if (!(Precision::IsInfinite(C1.FirstParameter()) || Precision::IsInfinite(C1.LastParameter())
+ || Precision::IsInfinite(C2.FirstParameter()) || Precision::IsInfinite(C2.LastParameter())))
{
anL[0] = GCPnts_AbscissaPoint::Length(C1);
anL[1] = GCPnts_AbscissaPoint::Length(C2);
Standard_Integer aNbIntOpt = 0;
if (indmax >= 0)
{
- aNbIntOpt = RealToInt(anL[indmax] * aNbInter[indmin] / anL[indmin] / (mult / 4.)) + 1;
+ aNbIntOpt = RealToInt(anL[indmax] * aNbInter[indmin] / anL[indmin] / (mult / 4.)) + 1;
if (aNbIntOpt > 100 || aNbIntOpt < aNbInter[indmax])
{
indmax = -1;
{
if (indmax == 0)
{
- //Change anIntervals1
+ // Change anIntervals1
ChangeIntervals(anIntervals1, aNbIntOpt);
aNbInter[0] = anIntervals1->Length() - 1;
}
else
{
- //Change anIntervals2;
+ // Change anIntervals2;
ChangeIntervals(anIntervals2, aNbIntOpt);
aNbInter[1] = anIntervals2->Length() - 1;
}
}
// Lipchitz constant computation.
- const Standard_Real aMaxLC = 10000.;
- Standard_Real aLC = 100.0; // Default value.
+ const Standard_Real aMaxLC = 10000.;
+ Standard_Real aLC = 100.0; // Default value.
const Standard_Real aMaxDer1 = 1.0 / C1.Resolution(1.0);
const Standard_Real aMaxDer2 = 1.0 / C2.Resolution(1.0);
- Standard_Real aMaxDer = Max(aMaxDer1, aMaxDer2) * Sqrt(2.0);
+ Standard_Real aMaxDer = Max(aMaxDer1, aMaxDer2) * Sqrt(2.0);
if (aLC > aMaxDer)
aLC = aMaxDer;
// Change constant value according to the concrete curve types.
Standard_Boolean isConstLockedFlag = Standard_False;
- //To prevent LipConst to became too small
+ // To prevent LipConst to became too small
const Standard_Real aCR = 0.001;
if (aMaxDer1 / aMaxDer < aCR || aMaxDer2 / aMaxDer < aCR)
{
}
if (aMaxDer > aMaxLC)
{
- aLC = aMaxLC;
+ aLC = aMaxLC;
isConstLockedFlag = Standard_True;
}
if (C1.GetType() == GeomAbs_Line)
if (aLC > aMaxDer)
{
isConstLockedFlag = Standard_True;
- aLC = aMaxDer;
+ aLC = aMaxDer;
}
}
if (C2.GetType() == GeomAbs_Line)
if (aLC > aMaxDer)
{
isConstLockedFlag = Standard_True;
- aLC = aMaxDer;
+ aLC = aMaxDer;
}
}
- Extrema_GlobOptFuncCCC2 aFunc (C1, C2);
+ Extrema_GlobOptFuncCCC2 aFunc(C1, C2);
if (aLC < aMaxLC || aMaxDer > aMaxLC)
{
- //Estimation of Lipschitz constant by gradient of optimization function
- //using sampling in parameter space.
- math_Vector aT(1, 2), aG(1, 2);
- Standard_Real aF, aMaxG = 0.;
- Standard_Real t1, t2, dt1, dt2;
+ // Estimation of Lipschitz constant by gradient of optimization function
+ // using sampling in parameter space.
+ math_Vector aT(1, 2), aG(1, 2);
+ Standard_Real aF, aMaxG = 0.;
+ Standard_Real t1, t2, dt1, dt2;
Standard_Integer n1 = 21, n2 = 21, i1, i2;
dt1 = (C1.LastParameter() - C1.FirstParameter()) / (n1 - 1);
dt2 = (C2.LastParameter() - C2.FirstParameter()) / (n2 - 1);
{
aT(2) = t2;
aFunc.Values(aT, aF, aG);
- Standard_Real aMod = aG(1)*aG(1) + aG(2)*aG(2);
- aMaxG = Max(aMaxG, aMod);
+ Standard_Real aMod = aG(1) * aG(1) + aG(2) * aG(2);
+ aMaxG = Max(aMaxG, aMod);
}
}
aMaxG = Sqrt(aMaxG);
if (aMaxG > aMaxDer)
{
- aLC = Min(aMaxG, aMaxLC);
+ aLC = Min(aMaxG, aMaxLC);
isConstLockedFlag = Standard_True;
}
if (aMaxG > 100. * aMaxLC)
{
- aLC = 100. * aMaxLC;
+ aLC = 100. * aMaxLC;
isConstLockedFlag = Standard_True;
}
else if (aMaxG < 0.1 * aMaxDer)
math_GlobOptMin aFinder(&aFunc, myLowBorder, myUppBorder, aLC);
aFinder.SetLipConstState(isConstLockedFlag);
aFinder.SetContinuity(aContinuity == GeomAbs_C2 ? 2 : 1);
- Standard_Real aDiscTol = 1.0e-2;
+ Standard_Real aDiscTol = 1.0e-2;
Standard_Real aValueTol = 1.0e-2;
- Standard_Real aSameTol = myCurveMinTol / (aDiscTol);
+ Standard_Real aSameTol = myCurveMinTol / (aDiscTol);
aFinder.SetTol(aDiscTol, aSameTol);
aFinder.SetFunctionalMinimalValue(0.0); // Best distance cannot be lower than 0.0.
// Size computed to have cell index inside of int32 value.
- const Standard_Real aCellSize = Max(Max(anIntervals1->Last() - anIntervals1->First(),
- anIntervals2->Last() - anIntervals2->First())
- * Precision::PConfusion() / (2.0 * Sqrt(2.0)),
- Precision::PConfusion());
- Extrema_CCPointsInspector anInspector(aCellSize);
+ const Standard_Real aCellSize = Max(
+ Max(anIntervals1->Last() - anIntervals1->First(), anIntervals2->Last() - anIntervals2->First())
+ * Precision::PConfusion() / (2.0 * Sqrt(2.0)),
+ Precision::PConfusion());
+ Extrema_CCPointsInspector anInspector(aCellSize);
NCollection_CellFilter<Extrema_CCPointsInspector> aFilter(aCellSize);
- NCollection_Vector<gp_XY> aPnts;
-
- Standard_Integer i,j,k;
- math_Vector aFirstBorderInterval(1,2);
- math_Vector aSecondBorderInterval(1,2);
- Standard_Real aF = RealLast(); // Best functional value.
- Standard_Real aCurrF = RealLast(); // Current functional value computed on current interval.
- for(i = 1; i <= aNbInter[0]; i++)
+ NCollection_Vector<gp_XY> aPnts;
+
+ Standard_Integer i, j, k;
+ math_Vector aFirstBorderInterval(1, 2);
+ math_Vector aSecondBorderInterval(1, 2);
+ Standard_Real aF = RealLast(); // Best functional value.
+ Standard_Real aCurrF = RealLast(); // Current functional value computed on current interval.
+ for (i = 1; i <= aNbInter[0]; i++)
{
- for(j = 1; j <= aNbInter[1]; j++)
+ for (j = 1; j <= aNbInter[1]; j++)
{
- aFirstBorderInterval(1) = anIntervals1->Value(i);
- aFirstBorderInterval(2) = anIntervals2->Value(j);
+ aFirstBorderInterval(1) = anIntervals1->Value(i);
+ aFirstBorderInterval(2) = anIntervals2->Value(j);
aSecondBorderInterval(1) = anIntervals1->Value(i + 1);
aSecondBorderInterval(2) = anIntervals2->Value(j + 1);
}
// Save found solutions avoiding repetitions.
- math_Vector sol(1,2);
- for(k = 1; k <= aFinder.NbExtrema(); k++)
+ math_Vector sol(1, 2);
+ for (k = 1; k <= aFinder.NbExtrema(); k++)
{
aFinder.Points(k, sol);
gp_XY aPnt2d(sol(1), sol(2));
gp_XY aXYmin = anInspector.Shift(aPnt2d, -aCellSize);
- gp_XY aXYmax = anInspector.Shift(aPnt2d, aCellSize);
+ gp_XY aXYmax = anInspector.Shift(aPnt2d, aCellSize);
anInspector.ClearFind();
anInspector.SetCurrent(aPnt2d);
Standard_Boolean bDifferentSolutions = Standard_False;
Standard_Boolean isParallel = Standard_True;
- Standard_Real aVal = 0.0;
- math_Vector aVec(1, 2, 0.0);
+ Standard_Real aVal = 0.0;
+ math_Vector aVec(1, 2, 0.0);
// Iterate on all solutions and collect the extreme solutions on all parallel segments.
for (Standard_Integer anIdx = 0; anIdx < aNbSol - 1; anIdx++)
if (aNext.Y() > aCurrent.Y())
{
bDifferentSolutions = Standard_True;
- bDirsCoinside = Standard_True;
+ bDirsCoinside = Standard_True;
}
else if (aNext.Y() < aCurrent.Y())
{
bDifferentSolutions = Standard_True;
- bDirsCoinside = Standard_False;
+ bDirsCoinside = Standard_False;
}
}
}
{
Standard_Real aDist1 = ProjPOnC(C1.Value(aT1[iT]), anExtPC2);
Standard_Real aDist2 = ProjPOnC(C2.Value(aT2[iT]), anExtPC1);
- isParallel = (Abs(Min(aDist1, aDist2) - aF * aF) < Precision::Confusion());
+ isParallel = (Abs(Min(aDist1, aDist2) - aF * aF) < Precision::Confusion());
}
}
//=================================================================================================
-Standard_Boolean Extrema_GenExtCC::IsDone() const
+Standard_Boolean Extrema_GenExtCC::IsDone() const
{
- return myDone;
+ return myDone;
}
//=================================================================================================
-Standard_Boolean Extrema_GenExtCC::IsParallel() const
+Standard_Boolean Extrema_GenExtCC::IsParallel() const
{
- if (!IsDone()) throw StdFail_NotDone();
+ if (!IsDone())
+ throw StdFail_NotDone();
return myParallel;
}
Standard_Integer Extrema_GenExtCC::NbExt() const
{
- if (!IsDone()) throw StdFail_NotDone();
+ if (!IsDone())
+ throw StdFail_NotDone();
return myPoints1.Length();
}
throw Standard_OutOfRange();
}
- return Tool1::Value(*((Curve1*)myC[0]), myPoints1(N)).SquareDistance(Tool2::Value(*((Curve2*)myC[1]), myPoints2(N)));
+ return Tool1::Value(*((Curve1*)myC[0]), myPoints1(N))
+ .SquareDistance(Tool2::Value(*((Curve2*)myC[1]), myPoints2(N)));
}
//=================================================================================================
-void Extrema_GenExtCC::Points(const Standard_Integer N,
- POnC& P1,
- POnC& P2) const
+void Extrema_GenExtCC::Points(const Standard_Integer N, POnC& P1, POnC& P2) const
{
if (N < 1 || N > NbExt())
{
#include <Standard_OutOfRange.hxx>
#include <Standard_NotImplemented.hxx>
-
//=================================================================================================
-
-Extrema_GenExtPC::Extrema_GenExtPC ()
-: myDone(Standard_False),
- myInit(Standard_False),
- mynbsample(0),
- myumin(0.0),
- myusup(0.0),
- mytolu(0.0),
- mytolF(0.0)
-{
+Extrema_GenExtPC::Extrema_GenExtPC()
+ : myDone(Standard_False),
+ myInit(Standard_False),
+ mynbsample(0),
+ myumin(0.0),
+ myusup(0.0),
+ mytolu(0.0),
+ mytolF(0.0)
+{
}
-
-
//=================================================================================================
-
-Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
- const Curve& C,
- const Standard_Integer NbSample,
- const Standard_Real TolU,
- const Standard_Real TolF) : myF (P,C)
+Extrema_GenExtPC::Extrema_GenExtPC(const Pnt& P,
+ const Curve& C,
+ const Standard_Integer NbSample,
+ const Standard_Real TolU,
+ const Standard_Real TolF)
+ : myF(P, C)
{
Initialize(C, NbSample, TolU, TolF);
Perform(P);
}
-
//=================================================================================================
-
-Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
- const Curve& C,
- const Standard_Integer NbSample,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolU,
- const Standard_Real TolF) : myF (P,C)
+Extrema_GenExtPC::Extrema_GenExtPC(const Pnt& P,
+ const Curve& C,
+ const Standard_Integer NbSample,
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolU,
+ const Standard_Real TolF)
+ : myF(P, C)
{
Initialize(C, NbSample, Umin, Usup, TolU, TolF);
Perform(P);
}
-
//=================================================================================================
-
void Extrema_GenExtPC::Initialize(const Curve& C,
- const Standard_Integer NbU,
- const Standard_Real TolU,
- const Standard_Real TolF)
+ const Standard_Integer NbU,
+ const Standard_Real TolU,
+ const Standard_Real TolF)
{
- myInit = Standard_True;
+ myInit = Standard_True;
mynbsample = NbU;
- mytolu = TolU;
- mytolF = TolF;
+ mytolu = TolU;
+ mytolF = TolF;
myF.Initialize(C);
myumin = Tool::FirstParameter(C);
myusup = Tool::LastParameter(C);
//=================================================================================================
-
void Extrema_GenExtPC::Initialize(const Curve& C,
- const Standard_Integer NbU,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolU,
- const Standard_Real TolF)
+ const Standard_Integer NbU,
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolU,
+ const Standard_Real TolF)
{
- myInit = Standard_True;
+ myInit = Standard_True;
mynbsample = NbU;
- mytolu = TolU;
- mytolF = TolF;
+ mytolu = TolU;
+ mytolF = TolF;
myF.Initialize(C);
myumin = Umin;
myusup = Usup;
}
-
//=================================================================================================
-
void Extrema_GenExtPC::Initialize(const Standard_Integer NbU,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolU,
- const Standard_Real TolF)
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolU,
+ const Standard_Real TolF)
{
mynbsample = NbU;
- mytolu = TolU;
- mytolF = TolF;
- myumin = Umin;
- myusup = Usup;
+ mytolu = TolU;
+ mytolF = TolF;
+ myumin = Umin;
+ myusup = Usup;
}
//=================================================================================================
-
void Extrema_GenExtPC::Initialize(const Curve& C)
{
myF.Initialize(C);
}
-
-
//=================================================================================================
-
void Extrema_GenExtPC::Perform(const Pnt& P)
/*-----------------------------------------------------------------------------
Fonction:
-----------------------------------------------------------------------------*/
{
myF.SetPoint(P);
- myF.SubIntervalInitialize(myumin,myusup);
+ myF.SubIntervalInitialize(myumin, myusup);
myDone = Standard_False;
- math_FunctionRoots S (myF, myumin, myusup, mynbsample, mytolu, mytolF, mytolF);
- if (!S.IsDone() ||
- S.IsAllNull()) { return; }
+ math_FunctionRoots S(myF, myumin, myusup, mynbsample, mytolu, mytolF, mytolF);
+ if (!S.IsDone() || S.IsAllNull())
+ {
+ return;
+ }
myDone = Standard_True;
}
-
-
//=================================================================================================
-
-Standard_Boolean Extrema_GenExtPC::IsDone () const {
+Standard_Boolean Extrema_GenExtPC::IsDone() const
+{
return myDone;
}
-
//=================================================================================================
+Standard_Integer Extrema_GenExtPC::NbExt() const
+{
-Standard_Integer Extrema_GenExtPC::NbExt () const {
-
- if (!IsDone()) { throw StdFail_NotDone(); }
+ if (!IsDone())
+ {
+ throw StdFail_NotDone();
+ }
return myF.NbExt();
}
-
//=================================================================================================
-
-Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const
+Standard_Real Extrema_GenExtPC::SquareDistance(const Standard_Integer N) const
{
if ((N < 1) || (N > NbExt()))
{
return myF.SquareDistance(N);
}
-
//=================================================================================================
-
-Standard_Boolean Extrema_GenExtPC::IsMin (const Standard_Integer N) const {
+Standard_Boolean Extrema_GenExtPC::IsMin(const Standard_Integer N) const
+{
if ((N < 1) || (N > NbExt()))
{
return myF.IsMin(N);
}
-
//=================================================================================================
-
-const POnC & Extrema_GenExtPC::Point (const Standard_Integer N) const
+const POnC& Extrema_GenExtPC::Point(const Standard_Integer N) const
{
if ((N < 1) || (N > NbExt()))
{
return myF.Point(N);
}
+
//=============================================================================
#include <math_FunctionSetRoot.hxx>
#include <math_Vector.hxx>
-//=============================================================================
-Extrema_GenLocateExtCC::Extrema_GenLocateExtCC (const Curve1& C1,
- const Curve2& C2,
- const Standard_Real U0, const Standard_Real V0,
- const Standard_Real TolU, const Standard_Real TolV)
+//=================================================================================================
+
+Extrema_GenLocateExtCC::Extrema_GenLocateExtCC(const Curve1& C1,
+ const Curve2& C2,
+ const Standard_Real U0,
+ const Standard_Real V0,
+ const Standard_Real TolU,
+ const Standard_Real TolV)
/*-----------------------------------------------------------------------------
Fonction:
Recherche du couple de valeurs de parametre (U,V) tel que:
- 100. .
-----------------------------------------------------------------------------*/
{
- myDone = Standard_False;
+ myDone = Standard_False;
mySqDist = RealLast();
Standard_Real Uinf = Tool1::FirstParameter(C1);
Standard_Real Usup = Tool1::LastParameter(C1);
Standard_Real Uu;
- if (Uinf>Usup) {
- Uu=Uinf;
- Uinf=Usup;
- Usup =Uu;
+ if (Uinf > Usup)
+ {
+ Uu = Uinf;
+ Uinf = Usup;
+ Usup = Uu;
}
Standard_Real Vinf = Tool2::FirstParameter(C2);
Standard_Real Vsup = Tool2::LastParameter(C2);
- if (Vinf>Vsup) {
- Uu=Vinf;
- Vinf=Vsup;
- Vsup =Uu;
+ if (Vinf > Vsup)
+ {
+ Uu = Vinf;
+ Vinf = Vsup;
+ Vsup = Uu;
}
- Extrema_CCLocF F (C1,C2);
- math_Vector Tol(1, 2);
- Tol(1) = TolU;
- Tol(2) = TolV;
+ Extrema_CCLocF F(C1, C2);
+ math_Vector Tol(1, 2);
+ Tol(1) = TolU;
+ Tol(2) = TolV;
Standard_Real Tolf = 1.e-10;
- math_Vector Start(1,2);
- math_Vector Uuinf(1,2);
- math_Vector Uusup(1,2);
+ math_Vector Start(1, 2);
+ math_Vector Uuinf(1, 2);
+ math_Vector Uusup(1, 2);
Start(1) = U0;
Start(2) = V0;
- Uuinf(1)=Uinf;
- Uuinf(2)=Vinf;
- Uusup(1)=Usup;
- Uusup(2)=Vsup;
+ Uuinf(1) = Uinf;
+ Uuinf(2) = Vinf;
+ Uusup(1) = Usup;
+ Uusup(2) = Vsup;
math_FunctionSetRoot S(F, Tol);
S.Perform(F, Start, Uuinf, Uusup);
- if (S.IsDone() && F.NbExt() > 0) {
+ if (S.IsDone() && F.NbExt() > 0)
+ {
mySqDist = F.SquareDistance(1);
- F.Points(1,myPoint1,myPoint2);
- Start(1)=myPoint1.Parameter();
- Start(2)=myPoint2.Parameter();
- math_Vector Ff(1,2);
- F.Value(Start,Ff);
-// cout << "Ff(1) = "<<Ff(1)<<endl;
-// cout << "Ff(2) = "<<Ff(2)<<endl;
- if ((Ff(1)<Tolf) && (Ff(2)<Tolf) ) myDone = Standard_True;
+ F.Points(1, myPoint1, myPoint2);
+ Start(1) = myPoint1.Parameter();
+ Start(2) = myPoint2.Parameter();
+ math_Vector Ff(1, 2);
+ F.Value(Start, Ff);
+ // cout << "Ff(1) = "<<Ff(1)<<endl;
+ // cout << "Ff(2) = "<<Ff(2)<<endl;
+ if ((Ff(1) < Tolf) && (Ff(2) < Tolf))
+ myDone = Standard_True;
}
}
+
//=============================================================================
-Standard_Boolean Extrema_GenLocateExtCC::IsDone () const { return myDone; }
+Standard_Boolean Extrema_GenLocateExtCC::IsDone() const
+{
+ return myDone;
+}
+
//=============================================================================
Standard_Real Extrema_GenLocateExtCC::SquareDistance() const
{
- if (!IsDone()) { throw StdFail_NotDone(); }
+ if (!IsDone())
+ {
+ throw StdFail_NotDone();
+ }
return mySqDist;
}
+
//=============================================================================
-void Extrema_GenLocateExtCC::Point (POnC& P1, POnC& P2)
- const
+void Extrema_GenLocateExtCC::Point(POnC& P1, POnC& P2) const
{
- if (!IsDone()) { throw StdFail_NotDone(); }
+ if (!IsDone())
+ {
+ throw StdFail_NotDone();
+ }
P1 = myPoint1;
P2 = myPoint2;
}
+
//=============================================================================
//=================================================================================================
-
Extrema_GenLocateExtPC::Extrema_GenLocateExtPC()
-: myDone(Standard_False),
- mytolU(0.0),
- myumin(0.0),
- myusup(0.0)
+ : myDone(Standard_False),
+ mytolU(0.0),
+ myumin(0.0),
+ myusup(0.0)
{
}
-
//=================================================================================================
-
-Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
- const Curve& C,
- const Standard_Real U0,
- const Standard_Real TolU)
+Extrema_GenLocateExtPC::Extrema_GenLocateExtPC(const Pnt& P,
+ const Curve& C,
+ const Standard_Real U0,
+ const Standard_Real TolU)
{
Initialize(C, Tool::FirstParameter(C), Tool::LastParameter(C), TolU);
Perform(P, U0);
}
-
//=================================================================================================
-
-Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
- const Curve& C,
- const Standard_Real U0,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolU)
+Extrema_GenLocateExtPC::Extrema_GenLocateExtPC(const Pnt& P,
+ const Curve& C,
+ const Standard_Real U0,
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolU)
{
Initialize(C, Umin, Usup, TolU);
Perform(P, U0);
}
-
//=================================================================================================
-
void Extrema_GenLocateExtPC::Initialize(const Curve& C,
- const Standard_Real Umin,
- const Standard_Real Usup,
- const Standard_Real TolU)
+ const Standard_Real Umin,
+ const Standard_Real Usup,
+ const Standard_Real TolU)
{
myDone = Standard_False;
myF.Initialize(C);
mytolU = TolU;
}
-
//=================================================================================================
-
-void Extrema_GenLocateExtPC::Perform(const Pnt& P,
- const Standard_Real U0)
+void Extrema_GenLocateExtPC::Perform(const Pnt& P, const Standard_Real U0)
/*-----------------------------------------------------------------------------
Fonction:
-----------------------------------------------------------------------------*/
{
myF.SetPoint(P);
- math_FunctionRoot S (myF, U0, mytolU, myumin, myusup);
+ math_FunctionRoot S(myF, U0, mytolU, myumin, myusup);
myDone = S.IsDone();
- if (myDone) {
+ if (myDone)
+ {
Standard_Real uu, ff;
- POnC PP = Point();
- uu = PP.Parameter();
- if(myF.Value(uu, ff)) {
- if (Abs(ff) >= 1.e-07) myDone = Standard_False;
+ POnC PP = Point();
+ uu = PP.Parameter();
+ if (myF.Value(uu, ff))
+ {
+ if (Abs(ff) >= 1.e-07)
+ myDone = Standard_False;
}
- else myDone = Standard_False;
+ else
+ myDone = Standard_False;
}
}
//=================================================================================================
-
-Standard_Boolean Extrema_GenLocateExtPC::IsDone () const
+Standard_Boolean Extrema_GenLocateExtPC::IsDone() const
{
return myDone;
}
-
//=================================================================================================
-
-Standard_Real Extrema_GenLocateExtPC::SquareDistance() const
+Standard_Real Extrema_GenLocateExtPC::SquareDistance() const
{
if (!IsDone())
{
return myF.SquareDistance(1);
}
-
//=================================================================================================
-
-Standard_Boolean Extrema_GenLocateExtPC::IsMin () const
+Standard_Boolean Extrema_GenLocateExtPC::IsMin() const
{
if (!IsDone())
{
return myF.IsMin(1);
}
-
//=================================================================================================
-
-const POnC & Extrema_GenLocateExtPC::Point () const
+const POnC& Extrema_GenLocateExtPC::Point() const
{
if (!IsDone())
{
}
return myF.Point(1);
}
-
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-Extrema_Point::Extrema_Point() :myU(0.0) {}
-
+Extrema_Point::Extrema_Point()
+ : myU(0.0)
+{
+}
-Extrema_Point::Extrema_Point (const Standard_Real U, const Pnt& P)
+Extrema_Point::Extrema_Point(const Standard_Real U, const Pnt& P)
{
myU = U;
myP = P;
myU = U;
myP = P;
}
-
-