Skip to content

Commit f888e28

Browse files
Merge pull request #52 from bitbybit-dev/develop
Develop
2 parents 09010cf + e40f900 commit f888e28

File tree

10 files changed

+332
-73
lines changed

10 files changed

+332
-73
lines changed

lib/api/inputs/occ-inputs.ts

Lines changed: 145 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,18 +958,105 @@ export namespace OCCT {
958958
*/
959959
removeEnd = false;
960960
}
961-
export class FaceSubdivisionToRectanglesDto<T> {
961+
export class FaceSubdivideToRectangleWiresDto<T> {
962962
/**
963963
* Provide options without default values
964964
*/
965-
constructor(shape?: T, nrRectanglesU?: number, nrRectanglesV?: number, scalePatternU?: number[], scalePatternV?: number[], filletPattern?: number[], inclusionPattern?: boolean[]) {
965+
constructor(shape?: T, nrRectanglesU?: number, nrRectanglesV?: number, scalePatternU?: number[], scalePatternV?: number[], filletPattern?: number[], inclusionPattern?: boolean[], offsetFromBorderU?: number, offsetFromBorderV?: number) {
966966
if (shape !== undefined) { this.shape = shape; }
967967
if (nrRectanglesU !== undefined) { this.nrRectanglesU = nrRectanglesU; }
968968
if (nrRectanglesV !== undefined) { this.nrRectanglesU = nrRectanglesV; }
969969
if (scalePatternU !== undefined) { this.scalePatternU = scalePatternU; }
970970
if (scalePatternV !== undefined) { this.scalePatternV = scalePatternV; }
971971
if (filletPattern !== undefined) { this.filletPattern = filletPattern; }
972972
if (inclusionPattern !== undefined) { this.inclusionPattern = inclusionPattern; }
973+
if (offsetFromBorderU !== undefined) { this.offsetFromBorderU = offsetFromBorderU; }
974+
if (offsetFromBorderV !== undefined) { this.offsetFromBorderV = offsetFromBorderV; }
975+
}
976+
/**
977+
* Openascade Face
978+
* @default undefined
979+
*/
980+
shape: T;
981+
/**
982+
* Number of rectangles on U direction
983+
* @default 10
984+
* @minimum 1
985+
* @maximum Infinity
986+
* @step 1
987+
*/
988+
nrRectanglesU = 10;
989+
/**
990+
* Number of rectangles on V direction
991+
* @default 10
992+
* @minimum 1
993+
* @maximum Infinity
994+
* @step 1
995+
*/
996+
nrRectanglesV = 10;
997+
/**
998+
* Rectangle scale pattern on u direction - numbers between 0 and 1, if 1 or undefined is used, no scaling is applied
999+
* @default undefined
1000+
* @optional true
1001+
*/
1002+
scalePatternU: number[];
1003+
/**
1004+
* Rectangle scale pattern on v direction - numbers between 0 and 1, if 1 or undefined is used, no scaling is applied
1005+
* @default undefined
1006+
* @optional true
1007+
*/
1008+
scalePatternV: number[];
1009+
/**
1010+
* Rectangle fillet scale pattern - numbers between 0 and 1, if 0 is used, no fillet is applied,
1011+
* if 1 is used, the fillet will be exactly half of the length of the shorter side of the rectangle
1012+
* @default undefined
1013+
* @optional true
1014+
*/
1015+
filletPattern: number[];
1016+
/**
1017+
* Rectangle inclusion pattern - true means that the rectangle will be included,
1018+
* false means that the rectangle will be removed from the face
1019+
* @default undefined
1020+
* @optional true
1021+
*/
1022+
inclusionPattern: boolean[];
1023+
/**
1024+
* If offset on U is bigger then 0 we will use a smaller space for rectangles to be placed. This means that even rectangle of U param 1 will be offset from the face border
1025+
* That is often required to create a pattern that is not too close to the face border
1026+
* It should not be bigger then half of the total width of the face as that will create problems
1027+
* @default 0
1028+
* @minimum 0
1029+
* @maximum 0.5
1030+
* @step 0.01
1031+
*/
1032+
offsetFromBorderU = 0;
1033+
/**
1034+
* If offset on V is bigger then 0 we will use a smaller space for rectangles to be placed. This means that even rectangle of V param 1 will be offset from the face border
1035+
* That is often required to create a pattern that is not too close to the face border
1036+
* It should not be bigger then half of the total width of the face as that will create problems
1037+
* @default 0
1038+
* @minimum 0
1039+
* @maximum 0.5
1040+
* @step 0.01
1041+
*/
1042+
offsetFromBorderV = 0;
1043+
}
1044+
1045+
export class FaceSubdivideToRectangleHolesDto<T> {
1046+
/**
1047+
* Provide options without default values
1048+
*/
1049+
constructor(shape?: T, nrRectanglesU?: number, nrRectanglesV?: number, scalePatternU?: number[], scalePatternV?: number[], filletPattern?: number[], inclusionPattern?: boolean[], holesToFaces?: boolean, offsetFromBorderU?: number, offsetFromBorderV?: number) {
1050+
if (shape !== undefined) { this.shape = shape; }
1051+
if (nrRectanglesU !== undefined) { this.nrRectanglesU = nrRectanglesU; }
1052+
if (nrRectanglesV !== undefined) { this.nrRectanglesU = nrRectanglesV; }
1053+
if (scalePatternU !== undefined) { this.scalePatternU = scalePatternU; }
1054+
if (scalePatternV !== undefined) { this.scalePatternV = scalePatternV; }
1055+
if (filletPattern !== undefined) { this.filletPattern = filletPattern; }
1056+
if (inclusionPattern !== undefined) { this.inclusionPattern = inclusionPattern; }
1057+
if (holesToFaces !== undefined) { this.holesToFaces = holesToFaces; }
1058+
if (offsetFromBorderU !== undefined) { this.offsetFromBorderU = offsetFromBorderU; }
1059+
if (offsetFromBorderV !== undefined) { this.offsetFromBorderV = offsetFromBorderV; }
9731060
}
9741061
/**
9751062
* Openascade Face
@@ -1023,6 +1110,26 @@ export namespace OCCT {
10231110
* @default false
10241111
*/
10251112
holesToFaces = false;
1113+
/**
1114+
* If offset on U is bigger then 0 we will use a smaller space for rectangles to be placed. This means that even rectangle of U param 1 will be offset from the face border
1115+
* That is often required to create a pattern that is not too close to the face border
1116+
* It should not be bigger then half of the total width of the face as that will create problems
1117+
* @default 0
1118+
* @minimum 0
1119+
* @maximum 0.5
1120+
* @step 0.01
1121+
*/
1122+
offsetFromBorderU = 0;
1123+
/**
1124+
* If offset on V is bigger then 0 we will use a smaller space for rectangles to be placed. This means that even rectangle of V param 1 will be offset from the face border
1125+
* That is often required to create a pattern that is not too close to the face border
1126+
* It should not be bigger then half of the total width of the face as that will create problems
1127+
* @default 0
1128+
* @minimum 0
1129+
* @maximum 0.5
1130+
* @step 0.01
1131+
*/
1132+
offsetFromBorderV = 0;
10261133
}
10271134
export class FaceSubdivisionControlledDto<T> {
10281135
/**
@@ -4624,9 +4731,10 @@ export namespace OCCT {
46244731
planar = false;
46254732
}
46264733
export class FaceFromWireOnFaceDto<T, U> {
4627-
constructor(wire?: T, face?: U) {
4734+
constructor(wire?: T, face?: U, inside?: boolean) {
46284735
if (wire !== undefined) { this.wire = wire; }
46294736
if (face !== undefined) { this.face = face; }
4737+
if (inside !== undefined) { this.inside = inside; }
46304738
}
46314739
/**
46324740
* Wire shape to convert into a face
@@ -4638,11 +4746,17 @@ export namespace OCCT {
46384746
* @default undefined
46394747
*/
46404748
face: U;
4749+
/**
4750+
* Indication if wire is inside the surface or outside
4751+
* @default true
4752+
*/
4753+
inside = true;
46414754
}
46424755
export class FacesFromWiresOnFaceDto<T, U> {
4643-
constructor(wires?: T[], face?: U) {
4756+
constructor(wires?: T[], face?: U, inside?: boolean) {
46444757
if (wires !== undefined) { this.wires = wires; }
46454758
if (face !== undefined) { this.face = face; }
4759+
if (inside !== undefined) { this.inside = inside; }
46464760
}
46474761
/**
46484762
* Wire shape to convert into a face
@@ -4654,6 +4768,11 @@ export namespace OCCT {
46544768
* @default undefined
46554769
*/
46564770
face: U;
4771+
/**
4772+
* Indication if wire is inside the surface or outside
4773+
* @default true
4774+
*/
4775+
inside = true;
46574776
}
46584777
export class FaceFromWiresDto<T> {
46594778
constructor(shapes?: T[], planar?: boolean) {
@@ -4687,6 +4806,28 @@ export namespace OCCT {
46874806
*/
46884807
planar = false;
46894808
}
4809+
export class FaceFromWiresOnFaceDto<T, U> {
4810+
constructor(wires?: T[], face?: U, inside?: boolean) {
4811+
if (wires !== undefined) { this.wires = wires; }
4812+
if (face !== undefined) { this.face = face; }
4813+
if (inside !== undefined) { this.inside = inside; }
4814+
}
4815+
/**
4816+
* Wire shapes to convert into a faces
4817+
* @default undefined
4818+
*/
4819+
wires: T[];
4820+
/**
4821+
* Guide face to use as a base
4822+
* @default undefined
4823+
*/
4824+
face: U;
4825+
/**
4826+
* Indication if wire is inside the surface or outside
4827+
* @default true
4828+
*/
4829+
inside = true;
4830+
}
46904831
export class SewDto<T> {
46914832
constructor(shapes: T[], tolerance?: number) {
46924833
if (shapes !== undefined) { this.shapes = shapes; }

lib/api/vector-helper.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ export class VectorHelperService {
9494
return [x, y, z];
9595
}
9696

97+
angleBetweenVectors(vector1: [number, number, number], vector2: [number, number, number]): number {
98+
const dotProduct = vector1[0] * vector2[0] + vector1[1] * vector2[1] + vector1[2] * vector2[2];
99+
const magnitude1 = this.magnitude(vector1);
100+
const magnitude2 = this.magnitude(vector2);
101+
return Math.acos(dotProduct / (magnitude1 * magnitude2));
102+
}
103+
97104
distanceBetweenPoints(point1: [number, number, number], point2: [number, number, number]): number {
98105
const x = point2[0] - point1[0];
99106
const y = point2[1] - point1[1];

lib/occ-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class OccHelper {
6666
this.enumService, this.entitiesService, this.converterService, this.geomService, this.edgesService, this.booleansService);
6767

6868
this.facesService = new FacesService(occ, this.occRefReturns, this.entitiesService, this.enumService,
69-
this.shapeGettersService, this.converterService, this.booleansService, this.wiresService, this.filletsService);
69+
this.shapeGettersService, this.converterService, this.booleansService, this.wiresService, this.transformsService, this.vecHelper, this.filletsService);
7070

7171
this.shellsService = new ShellsService(occ, this.shapeGettersService, this.converterService, this.facesService);
7272

lib/services/base/entities.service.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,22 @@ export class EntitiesService {
144144
return shell;
145145
}
146146

147-
bRepBuilderAPIMakeFaceFromWires(wires: TopoDS_Wire[], planar: boolean): TopoDS_Face {
147+
bRepBuilderAPIMakeFaceFromWires(wires: TopoDS_Wire[], planar: boolean, guideFace?: TopoDS_Face, inside?: boolean): TopoDS_Face {
148148
let face;
149149
const faces = [];
150150
wires.forEach(currentWire => {
151151
if (faces.length > 0) {
152-
const faceBuilder = new this.occ.BRepBuilderAPI_MakeFace_22(
153-
faces[faces.length - 1], currentWire);
152+
const faceBuilder = new this.occ.BRepBuilderAPI_MakeFace_22(faces[faces.length - 1], currentWire);
154153
faces.push(faceBuilder.Face());
155154
faceBuilder.delete();
156155
} else {
157-
const faceBuilder = new this.occ.BRepBuilderAPI_MakeFace_15(currentWire, planar);
156+
let faceBuilder;
157+
if (!guideFace) {
158+
faceBuilder = new this.occ.BRepBuilderAPI_MakeFace_15(currentWire, planar);
159+
} else {
160+
const surface = this.occ.BRep_Tool.Surface_2(guideFace);
161+
faceBuilder = new this.occ.BRepBuilderAPI_MakeFace_21(surface, currentWire, inside);
162+
}
158163
faces.push(faceBuilder.Face());
159164
faceBuilder.delete();
160165
}
@@ -174,22 +179,22 @@ export class EntitiesService {
174179
return face;
175180
}
176181

177-
bRepBuilderAPIMakeFacesFromWiresOnFace(face: TopoDS_Face, wires: TopoDS_Wire[]): TopoDS_Face[] {
182+
bRepBuilderAPIMakeFacesFromWiresOnFace(face: TopoDS_Face, wires: TopoDS_Wire[], inside: boolean): TopoDS_Face[] {
178183
const surface = this.occ.BRep_Tool.Surface_2(face);
179-
const res = wires.map(wire => this.bRepBuilderAPIMakeFaceFromWireOnSurface(surface, wire));
184+
const res = wires.map(wire => this.bRepBuilderAPIMakeFaceFromWireOnSurface(surface, wire, inside));
180185
surface.delete();
181186
return res;
182187
}
183188

184-
bRepBuilderAPIMakeFaceFromWireOnFace(face: TopoDS_Face, wire: TopoDS_Wire): TopoDS_Face {
189+
bRepBuilderAPIMakeFaceFromWireOnFace(face: TopoDS_Face, wire: TopoDS_Wire, inside: boolean): TopoDS_Face {
185190
const surface = this.occ.BRep_Tool.Surface_2(face);
186-
const res = this.bRepBuilderAPIMakeFaceFromWireOnSurface(surface, wire);
191+
const res = this.bRepBuilderAPIMakeFaceFromWireOnSurface(surface, wire, inside);
187192
surface.delete();
188193
return res;
189194
}
190195

191-
bRepBuilderAPIMakeFaceFromWireOnSurface(surface: Handle_Geom_Surface, wire: TopoDS_Wire): TopoDS_Face {
192-
const faceMaker = new this.occ.BRepBuilderAPI_MakeFace_21(surface, wire, true);
196+
bRepBuilderAPIMakeFaceFromWireOnSurface(surface: Handle_Geom_Surface, wire: TopoDS_Wire, inside: boolean): TopoDS_Face {
197+
const faceMaker = new this.occ.BRepBuilderAPI_MakeFace_21(surface, wire, inside);
193198
const f = faceMaker.Face();
194199
faceMaker.delete();
195200
return f;

0 commit comments

Comments
 (0)