Commit a91eabb8 authored by unknown's avatar unknown Committed by jean-pierre charras

Apply vrml_layer_pth, from Cirilo Bernardo

parent 52d2e7eb
This diff is collapsed.
This diff is collapsed.
...@@ -70,6 +70,7 @@ struct VERTEX_3D ...@@ -70,6 +70,7 @@ struct VERTEX_3D
double y; double y;
int i; // vertex index int i; // vertex index
int o; // vertex order int o; // vertex order
bool pth; // true for plate-through hole
}; };
struct TRIPLET_3D struct TRIPLET_3D
...@@ -93,12 +94,18 @@ private: ...@@ -93,12 +94,18 @@ private:
double minSegLength; // min. segment length double minSegLength; // min. segment length
double maxSegLength; // max. segment length double maxSegLength; // max. segment length
// Vertex offsets to work around a suspected GLU tesselator bug
double offsetX;
double offsetY;
bool fix; // when true, no more vertices may be added by the user bool fix; // when true, no more vertices may be added by the user
int idx; // vertex index (number of contained vertices) int idx; // vertex index (number of contained vertices)
int ord; // vertex order (number of ordered vertices) int ord; // vertex order (number of ordered vertices)
unsigned int idxout; // outline index to first point in 3D outline unsigned int idxout; // outline index to first point in 3D outline
std::vector<VERTEX_3D*> vertices; // vertices of all contours std::vector<VERTEX_3D*> vertices; // vertices of all contours
std::vector<std::list<int>*> contours; // lists of vertices for each contour std::vector<std::list<int>*> contours; // lists of vertices for each contour
std::vector<bool>pth; // indicates whether a 'contour' is a PTH or not
std::vector<bool>solid; // indicates whether a 'contour' is a solid or a hole
std::vector< double > areas; // area of the contours (positive if winding is CCW) std::vector< double > areas; // area of the contours (positive if winding is CCW)
std::list<TRIPLET_3D> triplets; // output facet triplet list (triplet of ORDER values) std::list<TRIPLET_3D> triplets; // output facet triplet list (triplet of ORDER values)
std::list<std::list<int>*> outline; // indices for outline outputs (index by ORDER values) std::list<std::list<int>*> outline; // indices for outline outputs (index by ORDER values)
...@@ -136,6 +143,9 @@ private: ...@@ -136,6 +143,9 @@ private:
// calculate number of sides on an arc (angle is in radians) // calculate number of sides on an arc (angle is in radians)
int calcNSides( double aRadius, double aAngle ); int calcNSides( double aRadius, double aAngle );
// returns the number of solid or hole contours
int checkNContours( bool holes );
public: public:
/// set to true when a fault is encountered during tesselation /// set to true when a fault is encountered during tesselation
bool Fault; bool Fault;
...@@ -191,9 +201,11 @@ public: ...@@ -191,9 +201,11 @@ public:
* Function NewContour * Function NewContour
* creates a new list of vertices and returns an index to the list * creates a new list of vertices and returns an index to the list
* *
* @param aPlatedHole is true if the new contour will represent a plated hole
*
* @return int: index to the list or -1 if the operation failed * @return int: index to the list or -1 if the operation failed
*/ */
int NewContour( void ); int NewContour( bool aPlatedHole = false );
/** /**
* Function AddVertex * Function AddVertex
...@@ -231,7 +243,8 @@ public: ...@@ -231,7 +243,8 @@ public:
* *
* @return bool: true if the new contour was successfully created * @return bool: true if the new contour was successfully created
*/ */
bool AppendCircle( double aXpos, double aYpos, double aRadius, int aContourID, bool aHoleFlag = false ); bool AppendCircle( double aXpos, double aYpos, double aRadius,
int aContourID, bool aHoleFlag = false );
/** /**
* Function AddCircle * Function AddCircle
...@@ -241,10 +254,12 @@ public: ...@@ -241,10 +254,12 @@ public:
* @param aYpos is the Y coordinate of the hole center * @param aYpos is the Y coordinate of the hole center
* @param aRadius is the radius of the hole * @param aRadius is the radius of the hole
* @param aHoleFlag determines if the contour to be created is a cutout * @param aHoleFlag determines if the contour to be created is a cutout
* @param aPlatedHole is true if this is a plated hole
* *
* @return bool: true if the new contour was successfully created * @return bool: true if the new contour was successfully created
*/ */
bool AddCircle( double aXpos, double aYpos, double aRadius, bool aHoleFlag = false ); bool AddCircle( double aXpos, double aYpos, double aRadius,
bool aHoleFlag = false, bool aPlatedHole = false );
/** /**
* Function AddSlot * Function AddSlot
...@@ -256,11 +271,12 @@ public: ...@@ -256,11 +271,12 @@ public:
* @param aSlotWidth is the width of the slot along the minor axis * @param aSlotWidth is the width of the slot along the minor axis
* @param aAngle (degrees) is the orientation of the slot * @param aAngle (degrees) is the orientation of the slot
* @param aHoleFlag determines whether the slot is a hole or a solid * @param aHoleFlag determines whether the slot is a hole or a solid
* @param aPlatedHole is true if this is a plated slot
* *
* @return bool: true if the slot was successfully created * @return bool: true if the slot was successfully created
*/ */
bool AddSlot( double aCenterX, double aCenterY, double aSlotLength, double aSlotWidth, bool AddSlot( double aCenterX, double aCenterY, double aSlotLength, double aSlotWidth,
double aAngle, bool aHoleFlag = false ); double aAngle, bool aHoleFlag = false, bool aPlatedHole = false );
/** /**
* Function AppendArc * Function AppendArc
...@@ -289,11 +305,14 @@ public: ...@@ -289,11 +305,14 @@ public:
* @param aArcWidth is the width of the arc * @param aArcWidth is the width of the arc
* @param aAngle is the included angle (degrees) * @param aAngle is the included angle (degrees)
* @param aHoleFlag determines whether the arc is to be a hole or a solid * @param aHoleFlag determines whether the arc is to be a hole or a solid
* @param aPlatedHole is true if this is a plated slotted arc
* *
* @return bool: true if the feature was successfully created * @return bool: true if the feature was successfully created
*/ */
bool AddArc( double aCenterX, double aCenterY, double aStartX, double aStartY, bool AddArc( double aCenterX, double aCenterY,
double aArcWidth, double aAngle, bool aHoleFlag = false ); double aStartX, double aStartY,
double aArcWidth, double aAngle,
bool aHoleFlag = false, bool aPlatedHole = false );
/** /**
* Function Tesselate * Function Tesselate
...@@ -302,10 +321,11 @@ public: ...@@ -302,10 +321,11 @@ public:
* *
* @param holes is an optional pointer to cutouts to be imposed on the * @param holes is an optional pointer to cutouts to be imposed on the
* surface. * surface.
* @param aHolesOnly is true if the outline contains only holes
* *
* @return bool: true if the operation succeeded * @return bool: true if the operation succeeded
*/ */
bool Tesselate( VRML_LAYER* holes = NULL ); bool Tesselate( VRML_LAYER* holes = NULL, bool aHolesOnly = false );
/** /**
* Function WriteVertices * Function WriteVertices
...@@ -351,19 +371,26 @@ public: ...@@ -351,19 +371,26 @@ public:
* writes out the vertex sets required to render an extruded solid * writes out the vertex sets required to render an extruded solid
* *
* @param aOutFile is the file to write to * @param aOutFile is the file to write to
* @param aIncludePlatedHoles is true if holes marked as plated should
* be rendered. Default is false since the user will usually
* render these holes in a different color
* *
* @return bool: true if the operation succeeded * @return bool: true if the operation succeeded
*/ */
bool Write3DIndices( std::ofstream& aOutFile ); bool Write3DIndices( std::ofstream& aOutFile, bool aIncludePlatedHoles = false );
/** /**
* Function AddExtraVertex * Function AddExtraVertex
* adds an extra vertex as required by the GLU tesselator * adds an extra vertex as required by the GLU tesselator.
*
* @param aXpos is the X coordinate of the newly created point
* @param aYpos is the Y coordinate of the newly created point
* @param aPlatedHole is true if this point is part of a plated hole
* *
* @return VERTEX_3D*: is the new vertex or NULL if a vertex * @return VERTEX_3D*: is the new vertex or NULL if a vertex
* could not be created. * could not be created.
*/ */
VERTEX_3D* AddExtraVertex( double aXpos, double aYpos ); VERTEX_3D* AddExtraVertex( double aXpos, double aYpos, bool aPlatedHole );
/** /**
* Function glStart * Function glStart
...@@ -429,6 +456,8 @@ public: ...@@ -429,6 +456,8 @@ public:
* Returns the error message related to the last failed operation * Returns the error message related to the last failed operation
*/ */
const std::string& GetError( void ); const std::string& GetError( void );
void SetVertexOffsets( double aXoffset, double aYoffset );
}; };
#endif // VRML_LAYER_H #endif // VRML_LAYER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment