mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
The algorithm that builds outlines ("silhouettes") makes an outline in 2d parametric space of the surface starting from some previously detected point where normal is orthogonal to direction of view. So, the surface is previously discretized into (m*n) sample points and some of them become starting points for future outlines. If the surface has non-uniform parametrization and/or some local extremums of curvature, the outlines can not be built without breaks, so there are several groups of consequent outlines in this case. Unfortunately, it leads to the situation when current number of sample points becomes insufficient to build all the parts of outlines. The idea is to detect the "holes" between already constructed parts of outlines and then complete the construction. New auxiliary draw command for testing of HLR. Correction according to the remarks. Update of test case according to the developer's directive
170 lines
5.0 KiB
Plaintext
170 lines
5.0 KiB
Plaintext
// Copyright (c) 1995-1999 Matra Datavision
|
|
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
|
//
|
|
// This file is part of Open CASCADE Technology software library.
|
|
//
|
|
// This library is free software; you can redistribute it and/or modify it under
|
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
// by the Free Software Foundation, with special exception defined in the file
|
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
// distribution for complete text of the license and disclaimer of any warranty.
|
|
//
|
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
// commercial license or contractual agreement.
|
|
|
|
#ifndef OCCT_DEBUG
|
|
#define No_Standard_RangeError
|
|
#define No_Standard_OutOfRange
|
|
#endif
|
|
|
|
|
|
void IntWalk_IWalking::AddPointInCurrentLine
|
|
(const Standard_Integer N,
|
|
const ThePointOfPath& PathPnt,
|
|
const Handle(IntWalk_TheIWLine)& CurrentLine) const {
|
|
|
|
|
|
IntSurf_PntOn2S Psol;
|
|
Psol.SetValue(ThePointOfPathTool::Value3d(PathPnt),
|
|
reversed,wd1[N].ustart,wd1[N].vstart);
|
|
CurrentLine->AddPoint(Psol);
|
|
}
|
|
|
|
|
|
void IntWalk_IWalking::MakeWalkingPoint
|
|
(const Standard_Integer Case,
|
|
const Standard_Real U,
|
|
const Standard_Real V,
|
|
TheIWFunction& sp,
|
|
IntSurf_PntOn2S& Psol )
|
|
|
|
{
|
|
|
|
// Case == 1 : make a WalkinkPoint.
|
|
// Case == 2 : make a WalkinkPoint.
|
|
// The computation of the tangency on is done
|
|
// Case == 10 + i : make a WalkinkPoint according to i.
|
|
// but F is updated according to U and V
|
|
// Case == other : the exception Standard_Failure is raised.
|
|
|
|
if (Case == 1)
|
|
Psol.SetValue(sp.Point(),reversed, U, V);
|
|
else if (Case == 2) {
|
|
Psol.SetValue(sp.Point(),reversed, U, V);
|
|
}
|
|
else if (Case == 11 || Case == 12 ) {
|
|
Standard_Real aUV[2], aFF[1], aDD[1][2];
|
|
math_Vector UV(aUV,1, 2);
|
|
math_Vector FF(aFF,1, 1);
|
|
math_Matrix DD(aDD,1, 1, 1, 2);
|
|
UV(1) = U;
|
|
UV(2) = V;
|
|
sp.Values(UV, FF, DD);
|
|
MakeWalkingPoint(Case - 10, U, V, sp, Psol);
|
|
}
|
|
else {
|
|
Standard_ConstructionError::Raise();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntWalk_IWalking::OpenLine(const Standard_Integer N,
|
|
const IntSurf_PntOn2S& Psol,
|
|
const ThePOPIterator& Pnts1,
|
|
TheIWFunction& sp,
|
|
const Handle(IntWalk_TheIWLine)& Line )
|
|
// **************** open the line and restart in the other direction********
|
|
|
|
{
|
|
ThePointOfPath PathPnt;
|
|
|
|
Standard_Real aUV[2], aFF[1], aDD[1][2];
|
|
math_Vector UV(aUV,1, 2);
|
|
math_Vector FF(aFF,1, 1);
|
|
math_Matrix DD(aDD,1, 1, 1, 2);
|
|
|
|
previousPoint = Line->Value(1);
|
|
if (!reversed) {
|
|
previousPoint.ParametersOnS2(UV(1),UV(2));
|
|
}
|
|
else {
|
|
previousPoint.ParametersOnS1(UV(1),UV(2));
|
|
}
|
|
sp.Values(UV, FF, DD);
|
|
previousd3d = sp.Direction3d();
|
|
previousd2d = sp.Direction2d();
|
|
|
|
if (N>0) { //departure point given at input
|
|
PathPnt = Pnts1.Value(N);
|
|
//mark the line as open with a given stop point
|
|
Line->AddStatusFirst(Standard_False,Standard_True,N,PathPnt);
|
|
|
|
|
|
AddPointInCurrentLine(N,PathPnt,Line);
|
|
|
|
}
|
|
else {
|
|
if (N <0) Line->AddPoint(Psol);
|
|
Line->AddStatusFirst(Standard_False,Standard_False);
|
|
//mark the line as open without given stop point
|
|
}
|
|
Line->Reverse(); //inverser la ligne
|
|
Line->SetTangentVector(previousd3d.Reversed(),Line->NbPoints());
|
|
}
|
|
|
|
Standard_Boolean IntWalk_IWalking::IsValidEndPoint(const Standard_Integer IndOfPoint,
|
|
const Standard_Integer IndOfLine)
|
|
{
|
|
if (PointLineLine.IsEmpty())
|
|
return Standard_True;
|
|
|
|
TColStd_ListIteratorOfListOfInteger itl(PointLineLine(IndOfPoint));
|
|
for (; itl.More(); itl.Next())
|
|
if (itl.Value() == IndOfLine)
|
|
{
|
|
PointLineLine(IndOfPoint).Remove(itl);
|
|
return Standard_True;
|
|
}
|
|
return Standard_False;
|
|
}
|
|
|
|
void IntWalk_IWalking::RemoveTwoEndPoints(const Standard_Integer IndOfPoint)
|
|
{
|
|
if (PointLineLine.IsBound(IndOfPoint))
|
|
{
|
|
Standard_Integer Line1 = PointLineLine(IndOfPoint).First();
|
|
Standard_Integer Line2 = PointLineLine(IndOfPoint).Last();
|
|
for (Standard_Integer iseq = 1; iseq <= seqAlone.Length(); iseq++)
|
|
{
|
|
if (seqAlone(iseq) == Line1 ||
|
|
seqAlone(iseq) == Line2)
|
|
seqAlone.Remove(iseq--);
|
|
}
|
|
}
|
|
}
|
|
|
|
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++)
|
|
{
|
|
gp_Pnt2d P2d1 = aLine->Value(i).ValueOnSurface(reversed);
|
|
if (Abs(P2d1.X() - theP2d.X()) <= tolerance(1) &&
|
|
Abs(P2d1.Y() - theP2d.Y()) <= tolerance(2))
|
|
return Standard_True;
|
|
if (i < aLine->NbPoints())
|
|
{
|
|
gp_Pnt2d P2d2 = aLine->Value(i+1).ValueOnSurface(reversed);
|
|
gp_Vec2d PP1(theP2d, P2d1);
|
|
gp_Vec2d PP2(theP2d, P2d2);
|
|
if (PP1 * PP2 < 0)
|
|
return Standard_True;
|
|
}
|
|
}
|
|
return Standard_False;
|
|
}
|