g4tools  5.4.0
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
tools::hatcher Class Reference
Collaboration diagram for tools::hatcher:
Collaboration graph
[legend]

Public Member Functions

 hatcher ()
 
virtual ~hatcher ()
 
bool compute_polyline (vec3f *listPoints, unsigned int number)
 draw the hatch into the polyline bounding box given in argument You have to get all compute points by the get_points() method Number of points can be get by number_of_points() The number of vertices in the return polyline can be get by number_of_vertices() and vertice table by get_vertices More...
 
bool check_polyline (vec3f *listPoints, unsigned int number)
 test if the polygone given is correct for hatching More...
 
void set_spacing (float a)
 
void set_angle (float a)
 
void set_offset (float a)
 
void set_offset_point (vec3f a)
 
void set_precision_factor (float a)
 
bool set_strip_width (float a)
 
float get_spacing () const
 
float get_angle () const
 
float get_offset () const
 
const vec3fget_offset_point ()
 
float get_precision_factor () const
 
float get_strip_width () const
 
const vec3fget_normal ()
 
const std::vector< vec3f > & points ()
 vector of compute points
Be careful with this function because it can return a set of non convex polygone if you have a non convex polygone at beginning !So, when you want to draw it, you have to use a tesselisation algorithm first More...
 
const std::vector< unsigned int > & vertices ()
 vector of numbers of vertices More...
 

Protected Types

enum  ResolveErrors {
  RESOLVE_OK = 0, RESOLVE_COLINEAR, RESOLVE_Z_ERROR, RESOLVE_PRECISION_ERROR,
  RESOLVE_UNDEFINED
}
 

Protected Member Functions

 hatcher (const hatcher &a_from)
 
hatcheroperator= (const hatcher &a_from)
 
bool compute_single_polyline (vec3f *listPoints, unsigned int number)
 draw the hatch into the polyline bounding box given in argument More...
 
vec2f resolve_system (const vec3f &A, const vec3f &B, const vec3f &C)
 Compute a vector system equation aA+bB=C return SbVec2f(0,0) if there is an error set the resolveResult variable to the error code : COLINEAR if A and B are PRECISION_ERROR if there is a lack of precision in computing Z_ERROR if there s no solution for Z UNDEFINED never throw return a SbVec2f for result. More...
 

Protected Attributes

vec3f fNormal
 normal vector for the current polyline More...
 
float fShift
 Spacing vector between two hatch. More...
 
float fDirAngle
 The angle (given in radians) is the one between the first line (point 1-point0) and the hatch lines, in the polyline plan. More...
 
float fOffsetValue
 between 0-1. More...
 
vec3f fOffset
 first point of the hatch. More...
 
vec3f fShiftVec
 Orientation vector for the hatch
More...
 
float fPrecisionFactor
 factor for compute error between two points More...
 
vec3f fDirVec
 hatch direction Vector More...
 
float fStripWidth
 strip with size : set to 0 by default between 0 and 1.0 means no strip, 0.5 means strip size is half of distance between two hatches More...
 
std::vector< vec3ffPoints
 vector list of points More...
 
std::vector< unsigned int > fVertices
 vector vertices number More...
 
std::vector< std::vector< int > > fConflictNumHatchLineTab
 conflict line table More...
 
std::vector< float > fHatchShiftToMatchPointVec
 hatchShiftToMatchPointVec tab More...
 
int fFirstNumHatch
 first hatch number to draw More...
 
unsigned int fNumberHatchToDraw
 number of hatch to draw More...
 
bool fFirstPolyline
 
ResolveErrors fResolveResult
 

Detailed Description

Definition at line 56 of file hatcher.

Member Enumeration Documentation

◆ ResolveErrors

Enumerator
RESOLVE_OK 
RESOLVE_COLINEAR 
RESOLVE_Z_ERROR 
RESOLVE_PRECISION_ERROR 
RESOLVE_UNDEFINED 

Definition at line 258 of file hatcher.

258  {
259  RESOLVE_OK = 0,
264  };

Constructor & Destructor Documentation

◆ hatcher() [1/2]

tools::hatcher::hatcher ( )
inline

Definition at line 58 of file hatcher.

59  :fShift(.1f)
60  ,fDirAngle(fpi()/4)
61  ,fOffsetValue(.0f)
62  ,fOffset(vec3f(FLT_MAX,FLT_MAX,FLT_MAX))
63  ,fPrecisionFactor (.0001f) // good value to get rid of some errors
64  ,fStripWidth(0.0)
65  ,fFirstNumHatch(0)
67  ,fFirstPolyline(true)
69  {}

◆ ~hatcher()

virtual tools::hatcher::~hatcher ( )
inlinevirtual

Definition at line 70 of file hatcher.

70 {}

◆ hatcher() [2/2]

tools::hatcher::hatcher ( const hatcher a_from)
inlineprotected

Definition at line 72 of file hatcher.

73  :fNormal(a_from.fNormal)
74  ,fShift(a_from.fShift)
75  ,fDirAngle(a_from.fDirAngle)
76  ,fOffsetValue(a_from.fOffsetValue)
77  ,fOffset(a_from.fOffset)
78  ,fShiftVec(a_from.fShiftVec)
79  ,fPrecisionFactor(a_from.fPrecisionFactor)
80  ,fDirVec(a_from.fDirVec)
81  ,fStripWidth(a_from.fStripWidth)
82  ,fPoints(a_from.fPoints)
83  ,fVertices(a_from.fVertices)
84  ,fConflictNumHatchLineTab(a_from.fConflictNumHatchLineTab)
85  ,fHatchShiftToMatchPointVec(a_from.fHatchShiftToMatchPointVec)
86  ,fFirstNumHatch(a_from.fFirstNumHatch)
87  ,fNumberHatchToDraw(a_from.fNumberHatchToDraw)
88  ,fFirstPolyline(a_from.fFirstPolyline)
89  ,fResolveResult(a_from.fResolveResult)
90  {}

Member Function Documentation

◆ check_polyline()

bool tools::hatcher::check_polyline ( vec3f listPoints,
unsigned int  number 
)

test if the polygone given is correct for hatching

Returns
FALSE if :
  • All points are not in the same plan
  • Number of points <3
  • Offset point is not in the same plan
  • There is less than three different points
  • The vector from point[0],point[1] is colinear to point[0],lastPoint

◆ compute_polyline()

bool tools::hatcher::compute_polyline ( vec3f listPoints,
unsigned int  number 
)

draw the hatch into the polyline bounding box given in argument You have to get all compute points by the get_points() method Number of points can be get by number_of_points() The number of vertices in the return polyline can be get by number_of_vertices() and vertice table by get_vertices

Returns
FALSE if :
  • All points are not in the same plan
  • There is a precision error on one or more point

◆ compute_single_polyline()

bool tools::hatcher::compute_single_polyline ( vec3f listPoints,
unsigned int  number 
)
protected

draw the hatch into the polyline bounding box given in argument

Returns
FALSE if :
  • All points are not in the same plan
  • There is a precision error on one or more point

◆ get_angle()

float tools::hatcher::get_angle ( ) const
inline

Definition at line 153 of file hatcher.

153 {return fDirAngle;}

◆ get_normal()

const vec3f& tools::hatcher::get_normal ( )
inline

Definition at line 158 of file hatcher.

158 {return fNormal;}

◆ get_offset()

float tools::hatcher::get_offset ( ) const
inline

Definition at line 154 of file hatcher.

154 {return fOffsetValue;}

◆ get_offset_point()

const vec3f& tools::hatcher::get_offset_point ( )
inline

Definition at line 155 of file hatcher.

155 {return fOffset;}

◆ get_precision_factor()

float tools::hatcher::get_precision_factor ( ) const
inline

Definition at line 156 of file hatcher.

156 {return fPrecisionFactor;}

◆ get_spacing()

float tools::hatcher::get_spacing ( ) const
inline

Definition at line 152 of file hatcher.

152 {return fShift;}

◆ get_strip_width()

float tools::hatcher::get_strip_width ( ) const
inline

Definition at line 157 of file hatcher.

157 {return fStripWidth;}

◆ operator=()

hatcher& tools::hatcher::operator= ( const hatcher a_from)
inlineprotected

Definition at line 91 of file hatcher.

91  {
92  fNormal = a_from.fNormal;
93  fShift = a_from.fShift;
94  fDirAngle = a_from.fDirAngle;
95  fOffsetValue = a_from.fOffsetValue;
96  fOffset = a_from.fOffset;
97  fShiftVec = a_from.fShiftVec;
98  fPrecisionFactor = a_from.fPrecisionFactor;
99  fDirVec = a_from.fDirVec;
100  fStripWidth = a_from.fStripWidth;
101  fPoints = a_from.fPoints;
102  fVertices = a_from.fVertices;
103  fConflictNumHatchLineTab = a_from.fConflictNumHatchLineTab;
104  fHatchShiftToMatchPointVec = a_from.fHatchShiftToMatchPointVec;
105  fFirstNumHatch = a_from.fFirstNumHatch;
106  fNumberHatchToDraw = a_from.fNumberHatchToDraw;
107  fFirstPolyline = a_from.fFirstPolyline;
108  fResolveResult = a_from.fResolveResult;
109  return *this;
110  }

◆ points()

const std::vector<vec3f>& tools::hatcher::points ( )
inline

vector of compute points
Be careful with this function because it can return a set of non convex polygone if you have a non convex polygone at beginning !So, when you want to draw it, you have to use a tesselisation algorithm first

Definition at line 166 of file hatcher.

166 {return fPoints;}

◆ resolve_system()

vec2f tools::hatcher::resolve_system ( const vec3f A,
const vec3f B,
const vec3f C 
)
protected

Compute a vector system equation aA+bB=C return SbVec2f(0,0) if there is an error set the resolveResult variable to the error code : COLINEAR if A and B are PRECISION_ERROR if there is a lack of precision in computing Z_ERROR if there s no solution for Z UNDEFINED never throw return a SbVec2f for result.

a is 'x' value and b is 'y' if it is correct

◆ set_angle()

void tools::hatcher::set_angle ( float  a)
inline

Definition at line 137 of file hatcher.

137 {fDirAngle = a;} //set the Direction angle for the hatch in radians.

◆ set_offset()

void tools::hatcher::set_offset ( float  a)
inline

Definition at line 138 of file hatcher.

138 {fOffsetValue = a;} //set the offset value for this hatch.

◆ set_offset_point()

void tools::hatcher::set_offset_point ( vec3f  a)
inline

Definition at line 139 of file hatcher.

139 {fOffset = a;} //set the offset Point for this hatch.

◆ set_precision_factor()

void tools::hatcher::set_precision_factor ( float  a)
inline

Definition at line 140 of file hatcher.

140 {fPrecisionFactor = a;} //set the precision factor for computing (0.0001 is default).

◆ set_spacing()

void tools::hatcher::set_spacing ( float  a)
inline

Definition at line 136 of file hatcher.

136 {fShift = a;} //set the spacing for this hatch.

◆ set_strip_width()

bool tools::hatcher::set_strip_width ( float  a)
inline

Definition at line 142 of file hatcher.

142  {
143  // set the strip width value(0 is default and means no strip).
144  if (a<0 || a>1) {
145  fStripWidth = 0;
146  return false;
147  }
148  fStripWidth = a;
149  return true;
150  }

◆ vertices()

const std::vector<unsigned int>& tools::hatcher::vertices ( )
inline

vector of numbers of vertices

Definition at line 170 of file hatcher.

170 {return fVertices;}

Member Data Documentation

◆ fConflictNumHatchLineTab

std::vector< std::vector<int> > tools::hatcher::fConflictNumHatchLineTab
protected

conflict line table

Definition at line 246 of file hatcher.

◆ fDirAngle

float tools::hatcher::fDirAngle
protected

The angle (given in radians) is the one between the first line (point 1-point0) and the hatch lines, in the polyline plan.

Given in the direct axis ((point1-point0),(lastPoint-point0), normalPlanVec). The angle in compute only one time for the first polyline. Changes on angle value for others polyline will not take effect.This is to perform correct hatching between the polylines

Definition at line 210 of file hatcher.

◆ fDirVec

vec3f tools::hatcher::fDirVec
protected

hatch direction Vector

Definition at line 231 of file hatcher.

◆ fFirstNumHatch

int tools::hatcher::fFirstNumHatch
protected

first hatch number to draw

Definition at line 252 of file hatcher.

◆ fFirstPolyline

bool tools::hatcher::fFirstPolyline
protected

Definition at line 257 of file hatcher.

◆ fHatchShiftToMatchPointVec

std::vector<float> tools::hatcher::fHatchShiftToMatchPointVec
protected

hatchShiftToMatchPointVec tab

Definition at line 249 of file hatcher.

◆ fNormal

vec3f tools::hatcher::fNormal
protected

normal vector for the current polyline

Definition at line 198 of file hatcher.

◆ fNumberHatchToDraw

unsigned int tools::hatcher::fNumberHatchToDraw
protected

number of hatch to draw

Definition at line 255 of file hatcher.

◆ fOffset

vec3f tools::hatcher::fOffset
protected

first point of the hatch.

offset = firstPolylinePoint+ShiftVec*offsetValue

Definition at line 222 of file hatcher.

◆ fOffsetValue

float tools::hatcher::fOffsetValue
protected

between 0-1.

This value set the offset of the hatch.0 meen that the hatch will touch the first point of the polyline, and 1 meen that first hatch will be draw at a 'spacing' distance to first point

Definition at line 217 of file hatcher.

◆ fPoints

std::vector<vec3f> tools::hatcher::fPoints
protected

vector list of points

Definition at line 240 of file hatcher.

◆ fPrecisionFactor

float tools::hatcher::fPrecisionFactor
protected

factor for compute error between two points

Definition at line 228 of file hatcher.

◆ fResolveResult

ResolveErrors tools::hatcher::fResolveResult
protected

Definition at line 265 of file hatcher.

◆ fShift

float tools::hatcher::fShift
protected

Spacing vector between two hatch.

Definition at line 201 of file hatcher.

◆ fShiftVec

vec3f tools::hatcher::fShiftVec
protected

Orientation vector for the hatch

Definition at line 225 of file hatcher.

◆ fStripWidth

float tools::hatcher::fStripWidth
protected

strip with size : set to 0 by default between 0 and 1.0 means no strip, 0.5 means strip size is half of distance between two hatches

Definition at line 237 of file hatcher.

◆ fVertices

std::vector<unsigned int> tools::hatcher::fVertices
protected

vector vertices number

Definition at line 243 of file hatcher.


The documentation for this class was generated from the following file:
tools::hatcher::fOffset
vec3f fOffset
first point of the hatch.
Definition: hatcher:222
tools::hatcher::RESOLVE_UNDEFINED
@ RESOLVE_UNDEFINED
Definition: hatcher:263
tools::hatcher::fShift
float fShift
Spacing vector between two hatch.
Definition: hatcher:201
tools::hatcher::fShiftVec
vec3f fShiftVec
Orientation vector for the hatch
Definition: hatcher:225
tools::hatcher::fNormal
vec3f fNormal
normal vector for the current polyline
Definition: hatcher:198
tools::hatcher::fHatchShiftToMatchPointVec
std::vector< float > fHatchShiftToMatchPointVec
hatchShiftToMatchPointVec tab
Definition: hatcher:249
tools::hatcher::fPoints
std::vector< vec3f > fPoints
vector list of points
Definition: hatcher:240
tools::hatcher::fConflictNumHatchLineTab
std::vector< std::vector< int > > fConflictNumHatchLineTab
conflict line table
Definition: hatcher:246
tools::hatcher::RESOLVE_PRECISION_ERROR
@ RESOLVE_PRECISION_ERROR
Definition: hatcher:262
tools::fpi
float fpi()
Definition: mathf:11
tools::hatcher::fResolveResult
ResolveErrors fResolveResult
Definition: hatcher:265
tools::hatcher::RESOLVE_OK
@ RESOLVE_OK
Definition: hatcher:259
tools::hatcher::fFirstPolyline
bool fFirstPolyline
Definition: hatcher:257
tools::hatcher::fStripWidth
float fStripWidth
strip with size : set to 0 by default between 0 and 1.0 means no strip, 0.5 means strip size is half ...
Definition: hatcher:237
tools::hatcher::fOffsetValue
float fOffsetValue
between 0-1.
Definition: hatcher:217
tools::hatcher::RESOLVE_COLINEAR
@ RESOLVE_COLINEAR
Definition: hatcher:260
tools::hatcher::RESOLVE_Z_ERROR
@ RESOLVE_Z_ERROR
Definition: hatcher:261
tools::hatcher::fNumberHatchToDraw
unsigned int fNumberHatchToDraw
number of hatch to draw
Definition: hatcher:255
tools::hatcher::fFirstNumHatch
int fFirstNumHatch
first hatch number to draw
Definition: hatcher:252
tools::hatcher::fDirAngle
float fDirAngle
The angle (given in radians) is the one between the first line (point 1-point0) and the hatch lines,...
Definition: hatcher:210
tools::hatcher::fVertices
std::vector< unsigned int > fVertices
vector vertices number
Definition: hatcher:243
tools::hatcher::fPrecisionFactor
float fPrecisionFactor
factor for compute error between two points
Definition: hatcher:228
tools::hatcher::fDirVec
vec3f fDirVec
hatch direction Vector
Definition: hatcher:231