When importing a CAD model into Blender, is there a way to make the surfaces split cleanly?

T

taiga

enter image description here

I usually use IRONCAD (CAD for mechanical design) in my work, and when I import a model created with this CAD into Blender, it is imported with a dirty division of the surface tangent to the curved surface, as shown in the attached image. I always have to manually fix this to a clean surface division, but it is very time consuming. Is there an add-on or other software conversion that can do this automatically, or is there some easy way to do this?
 

Unreplied Threads

Xliibを用いたプログラミングにおける、XAllocColorCells()関数の使い方について。

Xlibを用いたプログラミングで、2つのプライベートカラーセルを割り当てようと以下のコードを書きました。

Code:
#include <stdio.h>
#include <stdlib.h>

#include <X11/Xlib.h>

int main( void )
{
    Display *display;
    Window parent, window;
    int screen;
    Colormap cmap;
    unsigned long plane_mask, pixels[2];
    int border, background;

    display = XOpenDisplay( "" );
    if ( !display ) {
                fprintf( stderr, "XOpenDisplay error\n" );
                exit( 1 );
    }

    screen = DefaultScreen( display );
    parent = RootWindow( display, screen );
    cmap = DefaultColormap( display, screen );

    if ( !XAllocColorCells( display, cmap, False,
                                &plane_mask, 0, pixels, 2 ) ) {
            fprintf( stderr, "XAllocColorCells error\n" );
            exit( 1 );
    }

    getchar();

}

するとビルドは正常に通るのですが、実行時にXAllocColorCells()の部分でプライベートカラーセルの割り当てに失敗し、自らコーディングしたエラーメッセージ"XAllocColorCells error"が表示されプログラムが終了してしまいます。
XAllocColorCells()を用いて2つのプライベートカラーセルを正常に割り当てるようにするにはどのように書けばいいでしょうか、ご教示お願いいたします。

環境は、
↓OSのバージョン
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
↓GNOMEのバージョン
GNOME Shell 46.0

以上です。よろしくお願い致します。

FInd scheduling conflicts within a timetable

So, I've been assigned the following tasks. I'm given a timetable. Several classes that have a weekday, as well as an hour at which they start and end. Also, they have a room assigned and are part of a curriculum for one (or more) majors.

The data is provided in a XML file. The schema of said XML file is provided via an XSD file. I use JAXB to create classes out of the XSD file, and to unmarshall data from the XML file.

Within a given timetable, I have to find scheduling conflicts. A scheduling conflict is defined as either

a) two classes taking place in the same room at overlapping times b) two classes that both need to be visited for the same major can also not overlap

Two classes overlapping that take place in different rooms and are not compusory for the same major don't coutn as a schedulign conflict.

This is my result. I'd be grateful for every hint I can get.

Code:
timetable.xml
<?xml version="1.0" encoding="UTF-8"?>
<university>
    <lectures>
        <lecture>
            <id>l-0</id>
            <name>Calculus 101</name>
            <roombookings>
                <booking>
                    <room>Audimax</room>
                    <weekday>Mon</weekday>
                    <startTime>10:00:00</startTime>
                    <endTime>12:00:00</endTime>
                </booking>
                <booking>
                    <room>Audimax</room>
                    <weekday>Wed</weekday>
                    <startTime>10:00:00</startTime>
                    <endTime>14:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-1</id>
            <name>Counting 101</name>
            <roombookings>
                <booking>
                    <room>Audimax</room>
                    <weekday>Mon</weekday>
                    <startTime>15:00:00</startTime>
                    <endTime>17:00:00</endTime>
                </booking>
                <booking>
                    <room>Audimax</room>
                    <weekday>Fri</weekday>
                    <startTime>10:00:00</startTime>
                    <endTime>12:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-2</id>
            <name>Tricky Problems 101</name>
            <roombookings>
                <booking>
                    <room>Room A</room>
                    <weekday>Tue</weekday>
                    <startTime>09:00:00</startTime>
                    <endTime>11:00:00</endTime>
                </booking>
                <booking>
                    <room>Room B</room>
                    <weekday>Thur</weekday>
                    <startTime>10:00:00</startTime>
                    <endTime>12:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-3</id>
            <name>Timetabling 101</name>
            <roombookings>
                <booking>
                    <room>Room B</room>
                    <weekday>Thur</weekday>
                    <startTime>14:00:00</startTime>
                    <endTime>17:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-4</id>
            <name>Computer Stuff 101</name>
            <roombookings>
                <booking>
                    <room>Room A</room>
                    <weekday>Tue</weekday>
                    <startTime>12:00:00</startTime>
                    <endTime>14:00:00</endTime>
                </booking>
                <booking>
                    <room>Room B</room>
                    <weekday>Wed</weekday>
                    <startTime>16:00:00</startTime>
                    <endTime>19:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-5</id>
            <name>Cool Numbers 101</name>
            <roombookings>
                <booking>
                    <room>Room A</room>
                    <weekday>Thur</weekday>
                    <startTime>08:00:00</startTime>
                    <endTime>12:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-6</id>
            <name>Quantum Leaps 101</name>
            <roombookings>
                <booking>
                    <room>Room A</room>
                    <weekday>Mon</weekday>
                    <startTime>14:00:00</startTime>
                    <endTime>18:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-7</id>
            <name>Tiny Stuff 101</name>
            <roombookings>
                <booking>
                    <room>Room A</room>
                    <weekday>Tue</weekday>
                    <startTime>10:00:00</startTime>
                    <endTime>13:00:00</endTime>
                </booking>
                <booking>
                    <room>Room B</room>
                    <weekday>Fri</weekday>
                    <startTime>11:00:00</startTime>
                    <endTime>13:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-8</id>
            <name>Big Stuff 101</name>
            <roombookings>
                <booking>
                    <room>Room B</room>
                    <weekday>Tue</weekday>
                    <startTime>13:00:00</startTime>
                    <endTime>15:00:00</endTime>
                </booking>
                <booking>
                    <room>Room B</room>
                    <weekday>Wed</weekday>
                    <startTime>16:00:00</startTime>
                    <endTime>18:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
        <lecture>
            <id>l-9</id>
            <name>Stars and Stuff 101</name>
            <roombookings>
                <booking>
                    <room>Room B</room>
                    <weekday>Wed</weekday>
                    <startTime>15:00:00</startTime>
                    <endTime>17:00:00</endTime>
                </booking>
            </roombookings>
        </lecture>
    </lectures>

    <curricula>
        <curriculum>
            <name>Maths</name>
            <lecture>l-0</lecture>
            <lecture>l-1</lecture>
            <lecture>l-2</lecture>
            <lecture>l-3</lecture>
            <lecture>l-4</lecture>
            <lecture>l-5</lecture>
        </curriculum>
        <curriculum>
            <name>Physics</name>
            <lecture>l-0</lecture>
            <lecture>l-1</lecture>
            <lecture>l-6</lecture>
            <lecture>l-7</lecture>
            <lecture>l-8</lecture>
            <lecture>l-9</lecture>
        </curriculum>
    </curricula>
</university>

Code:
public class MathplanApplication {
    
    private static String ROOMCONFLICT_MSG = """
        Course with ID %s and course with ID %s have a room conflict for room %s %n""";
    
    private static String SubjectCONFLICT_MSG = """
        Course with ID %s and course with ID %s have a program conflict for program %s
        """;
    
    public static void main(String[] args) throws FileNotFoundException {
        
        SpringApplication.run(MathplanApplication.class, args);
        
        try {
            
            List<ClassBooking> cbList = 
                UniversityFileParser.parseUniversityFile(
                "./src/main/resources/timetable.xml");
            
            ScheduleConflictDiscovery.findSchedulingConflicts(cbList);
            
            resultPresentation();
        } catch (Exception e) {
            
            e.printStackTrace();
        }
    }

    private static void resultPresentation() {
        
        if(!ScheduleConflictDiscovery.getRoomConflicts().isEmpty()) {
            System.out.printf("There were %d room conflicts discovered: %n", 
                ScheduleConflictDiscovery.getRoomConflicts().size());
        }
        
        ScheduleConflictDiscovery.getRoomConflicts().forEach(
            st -> printRoomConflict(st));
        
        if(!ScheduleConflictDiscovery.getRoomConflicts().isEmpty()) {
            System.out.printf("%nThere were %d program conflicts discovered: %n", 
                ScheduleConflictDiscovery.getProgramConflicts().size());
        }
        
        ScheduleConflictDiscovery.getProgramConflicts().forEach(
            st -> printProgramConflict(st));
    }

    private static void printRoomConflict(Set<ClassBooking> st) {
        String[] ids = new String[2];
        String room = null;
        int counter = 0;
        
        for(ClassBooking cb: st) {
            ids[counter] = cb.getId();
            room = cb.getRoom();
            counter++;
        }
        
        System.out.printf(ROOMCONFLICT_MSG, ids[0], ids[1], room);
    }
    
    private static void printProgramConflict(Set<ClassBooking> st) {
        ClassBooking[] cbs = new ClassBooking[2];
        int counter = 0;
        
        for(ClassBooking cb: st) {
            cbs[counter] = cb;
            counter++;
        }
        
        cbs[0].getInCurriculum().retainAll(cbs[1].getInCurriculum());
        
        String degree = cbs[0].getInCurriculum().stream().findFirst().get();
        
        System.out.printf(SubjectCONFLICT_MSG, cbs[0].getId(), cbs[1].getId(), degree);
    }
}

Code:
    private String id;
    private String room;
    private DayOfWeek weekday;
    private LocalTime beginTime;
    private LocalTime endTime;
    private Set<String> inCurriculum;
    
    public ClassBooking(String id, String room, DayOfWeek weekday, 
            LocalTime beginTime, LocalTime endTime, Set<String> inCurriculum) {
        super();
        this.id = id;
        this.room = room;
        this.weekday = weekday;
        this.beginTime = beginTime;
        this.endTime = endTime;
        this.inCurriculum = inCurriculum;
    }
    
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getRoom() {
        return room;
    }
    public void setRoom(String room) {
        this.room = room;
    }
    public DayOfWeek getWeekday() {
        return weekday;
    }
    public void setWeekday(DayOfWeek weekday) {
        this.weekday = weekday;
    }
    public LocalTime getBeginTime() {
        return beginTime;
    }
    public void setBeginTime(LocalTime beginTime) {
        this.beginTime = beginTime;
    }
    public LocalTime getEndTime() {
        return endTime;
    }
    public void setEndTime(LocalTime endTime) {
        this.endTime = endTime;
    }

    public Set<String> getInCurriculum() {
        return inCurriculum;
    }

    public void setInCurriculum(Set<String> inCurriculum) {
        this.inCurriculum = inCurriculum;
    }

    @Override
    public int hashCode() {
        return Objects.hash(beginTime, endTime, id, inCurriculum, room, weekday);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ClassBooking other = (ClassBooking) obj;
        return Objects.equals(beginTime, other.beginTime) && Objects.equals(endTime, other.endTime)
                && Objects.equals(id, other.id) && Objects.equals(inCurriculum, other.inCurriculum)
                && Objects.equals(room, other.room) && weekday == other.weekday;
    }

    @Override
    public String toString() {
        return "ClassBooking [id=" + id + ", room=" + room + ", weekday=" + weekday + ", beginTime=" + beginTime
                + ", endTime=" + endTime + ", inCurriculum=" + inCurriculum + "]";
    }
}

Code:
public class UniversityFileParser {

    private static JAXBContext jaxbContext;
    private static Map<String,List<String>> curriculumMap = new HashMap<>();
    
    private UniversityFileParser() throws JAXBException {
        jaxbContext = JAXBContext.newInstance(University.class);
    }
    
    public static List<ClassBooking> parseUniversityFile(String fileURL) 
        throws FileNotFoundException, JAXBException {
        
        University university = (University) JAXBIntrospector.getValue(
                jaxbContext.createUnmarshaller().unmarshal(new FileReader(fileURL)));
        
        parseCurriculum(university);
        
        return parseLectures(university);
    }

    private static List<ClassBooking> parseLectures(University university) {

        List<List<ClassBooking>> fuck = university.getLectures().getLecture()
            .stream().map(lecture -> parseBookings(lecture.getId(), 
                    lecture.getRoombookings())).toList();
        
        return fuck.stream().flatMap(Collection::stream).toList();
    }
    
    private static List<ClassBooking> parseBookings(String id, 
            Roombookings roomBookings) {
        
        List<ClassBooking> classBookings = new ArrayList<>();
        
        for(Booking b: roomBookings.getBooking()) {
            
            ClassBooking cb = new ClassBooking(id,b.getRoom(),
                getWeekday(b.getWeekday()),
                LocalTime.of(b.getStartTime().getHour(), 0),
                LocalTime.of(b.getEndTime().getHour(), 0),
                addPrograms(id));
            
            classBookings.add(cb);
        }
        
        return classBookings;
    }
    
    private static void parseCurriculum(University university) {
        
        for(Curriculum curr: university.getCurricula().getCurriculum()){
            List<Lecture> newCurriculum =
                    curr.getLecture().stream().map(entry -> (Lecture) entry.getValue())
                    .toList();
            
            List<String> newCurriculumString = newCurriculum.stream().
                    map(Lecture::getId).toList();
            System.out.println(newCurriculumString);
            curriculumMap.put(curr.getName(), newCurriculumString);
            
        }
    }
    
    private static Set<String> addPrograms(String courseID) {
        
        Set<String> programSet = new HashSet<>();
        
        for(String degree: curriculumMap.keySet()) {
            if(curriculumMap.get(degree).contains(courseID)) {
                programSet.add(degree);
            }
        }
        
        return programSet;
    }
    
    //I can't change it because JAXB delivers them to me with three letters
    private static DayOfWeek getWeekday(String weekday) {
        switch(weekday) {
            case("Mon"):
                return DayOfWeek.MONDAY;
            case("Tue"):
                return DayOfWeek.TUESDAY;
            case("Wed"):
                return DayOfWeek.WEDNESDAY;
            case("Thur"):
                return DayOfWeek.THURSDAY;
            case("Fri"):
                return DayOfWeek.FRIDAY;
            default:
                return null;
        }
    }
}```

```public class ScheduleConflictDiscovery {
    
    private static Set<Set<ClassBooking>> roomConflicts;
    private static List<Set<ClassBooking>> programConflicts;

    public static void findSchedulingConflicts(List<ClassBooking> cbList) {
        
        roomConflicts = new HashSet<>();
        programConflicts = new ArrayList<>();
        
        for(int i = 0;i<cbList.size();i++) {
            
            ClassBooking currCB = cbList.get(i);
            
            List<ClassBooking> overlaps = IntStream.range(i+1, cbList.size()).filter(j -> hasOverLap(currCB, cbList.get(j))).mapToObj(k -> cbList.get(k)).toList();
            findConflicts(currCB, overlaps);
            
        }
        
        roomConflicts.forEach(x -> System.out.println(x));
    }
    
    public static void findConflicts(ClassBooking currentCB, List<ClassBooking> overlaps) {
        
        for(ClassBooking cb: overlaps) {
            
            if(currentCB.getRoom().equals(cb.getRoom())) {
                Set<ClassBooking> cbSet = Set.of(currentCB, cb);
                roomConflicts.add(cbSet);
            }
            
            Set<String> copy = new HashSet<>(currentCB.getInCurriculum());
            copy.retainAll(cb.getInCurriculum());
            
            if(!copy.isEmpty()) {
                Set<ClassBooking> cbSet = Set.of(currentCB, cb);
                programConflicts.add(cbSet);
            }
        }
        
        
    }
    
    //Is just preliminary, I will make a single return statement out of it once I'm 
    //done testing
    private static boolean hasOverLap(ClassBooking cb1, ClassBooking cb2) {
        
        if(cb1.getWeekday() != cb2.getWeekday()) {
            
            return false;
        }
        
        if((cb1.getBeginTime().isBefore(cb2.getBeginTime()) || 
                cb1.getBeginTime().equals(cb2.getBeginTime())) && 
                cb1.getEndTime().isAfter(cb2.getBeginTime())) {
            
            return true;
        }
        
        if((cb1.getBeginTime().isAfter(cb2.getBeginTime()) ||
                cb1.getBeginTime().equals(cb2.getBeginTime())) && 
                cb1.getBeginTime().isBefore(cb2.getEndTime())) {
            
            return true;
        }
        
        return false;
    }

    public static Set<Set<ClassBooking>> getRoomConflicts() {
        return roomConflicts;
    }

    public static void setRoomConflicts(Set<Set<ClassBooking>> roomConflicts) {
        ScheduleConflictDiscovery.roomConflicts = roomConflicts;
    }

    public static List<Set<ClassBooking>> getProgramConflicts() {
        return programConflicts;
    }

    public static void setProgramConflicts(List<Set<ClassBooking>> programConflicts) {
        ScheduleConflictDiscovery.programConflicts = programConflicts;
    }
    
    
}
```

MinMax product for large matrices

I created this program which runs with no error, but I'd like to have some comments if it is possible to optimize it, since I need to run the program with N = 3200. In this case it takes a lot of time to end. I left it running during the night to get the answer.

The math notation of the program:

\$ A = (a_{ij}) \space \text{is an} \space N \times N \space \text{matrix} \\ B = \text{max_prod(A)} \space \text{is an} \space N \times N \space \text{matrix where} \\ \space \space \space \space \space b_{ij} = \min\{\max(a_{ik}, b_{kj}); k = 1, \dots,N\} \$

Code:
import numpy as np

def min_max(mat1, mat2, i, j):
    ''' this function takes 2 matrices and 2 indexes
    and return the minimum of the element wise maximum 
    between row i of mat1 and col j of mat2 '''
    return min(np.maximum(mat1[i,:], mat2[:,j]))

def max_prod(mat1,mat2):
    ''' this function takes 2 matrices and return a new matrix
    where position (i,j) is min_max(mat1, mat2, i, j) '''
    n = len(mat1)
    my_prod = np.zeros((n,n), dtype=float)
    for i in range(n):
        for j in range(i,n):
            my_prod[i,j] = min_max(mat1,mat2,i,j)
            my_prod[j,i] = min_max(mat2,mat1,j,i)
    return my_prod

N = 5
A = np.random.randint(1,20, size=(N,N))

print max_prod(A,A)

EMI Shielding on PCB

  • vicatcu
  • Physics
  • Replies: 0
I'm thinking about replacing an 915MHz RF module on a PCB I designed with an equivalent circuit directly implemented on my PCB to overcome some supply chain issues. The module I'm replacing has an EMI shield covering it, so I'm thinking I should at least include provisions for an EMI shield on my PCB as well (i.e. at least a footprint). I went over to Digikey and I found this and this by way of parametric search and availability considerations.

enter image description here enter image description here

The main question that brings me here is the fact that there are these "vent holes" in the top of this EMI shield, whereas the module I'm replacing has no vent holes in the top. Will the vent holes compromise the effectiveness of the EMI shield? How significant of an effect is that?

A secondary, related question I have is whether an EMI shield like this can be included in an SMT assembly process as a component? Would it compromise the reflow of the parts under the EMI shield or does it have to be a added as second pass through the reflow oven?

TPM - Ecc based encryption / decryption using the public key

  • TrinityTonic
  • Technology
  • Replies: 0
Our device comes with a device certificate which was signed with our private registration authority (CA). The private key (type ECC) was generated on the device itself - to be more specific directly on the on-board TPM. The public key is included inside the device certificate.

Now we have a use-case where we want to encrypt some sensitive file to be used on the device and wondered how we could do this with existing mechanisms. Could the public ECC key inside the device certificate (or something derived from it) be used to encrypt data that only the device would be able to decrypt using its private TPM-based ECC key (or something derived from it)?

What options do we have to encrypt something for the device while using device-specific information - we would not like that the encrypted file would work on every device which would be the case if we used a shared secret and symmetric encryption directly.

How are RSA and Elliptic Curve keys generated deterministically?

Going through the TPM tutorial: https://google.github.io/tpm-js/#pg_keys

Primary keys are derived from the primary seeds using a deterministic key derivation function (KDF).

The output of KDF would be some pseudo-random bytes. For RSA, the bytes might not be a prime number. For elliptic curves, the bytes would likely not be a co-ordinate on the curve. Even ignoring that output is coming from a KDF I'm unclear on how a "seed" can be used to generate RSA and EC keys deterministically.

How web browsers and WebCrypto API protects secrets

I tried to search and take a look at a way to securely generate or import secret keys on client-side. First I tried to see if it is possible to take advantage of TPM in Windows but as far as I understood it is not possible to use it. So as far as I got the correct way to deal with encryption keys was using Web Crypto API. I figured out that it uses IndexedDB to store the keys. I truly want to know how these keys are being protected from getting extracted if imported. I know that you need to set extractable property of the Key to false but does it take advantage of TPM or any hardware module to protect keys or just software based protection? BTW I read how KeyStore protects keys so I wonder if for web applications we have such an alternative.
Top